From patchwork Thu Apr 17 20:15:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Evans X-Patchwork-Id: 610 Return-Path: X-Original-To: siddhesh@wilcox.dreamhost.com Delivered-To: siddhesh@wilcox.dreamhost.com Received: from homiemail-mx21.g.dreamhost.com (peon2454.g.dreamhost.com [208.113.200.127]) by wilcox.dreamhost.com (Postfix) with ESMTP id 55A9F360060 for ; Thu, 17 Apr 2014 13:15:21 -0700 (PDT) Received: by homiemail-mx21.g.dreamhost.com (Postfix, from userid 14314964) id 017381323D15; Thu, 17 Apr 2014 13:15:20 -0700 (PDT) X-Original-To: gdb@patchwork.siddhesh.in Delivered-To: x14314964@homiemail-mx21.g.dreamhost.com Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by homiemail-mx21.g.dreamhost.com (Postfix) with ESMTPS id C14181305C36 for ; Thu, 17 Apr 2014 13:15:20 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; q=dns; s=default; b=xnWYnGkVQdapdIeJuZn7bSf8NiTgE 93cwcxLeyc3E9ZmeYBn5dhS00ir+x23UKfMSuonS+yVeSs2h0V8SPbsUzOAFdIP1 A0e0tPVG0EAy29DGdE6SHhVnjmCM0o0ZX1g14NnkM/XOkS9ibC/8cTEne01l+DIo azG4pf57mSi4m8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type; s=default; bh=T8kg6FbHJbElYDYsTnd5ww3hnJY=; b=dmo sbZxyLx0tajCyaFI5IFotsz9mnaNTBsf2sHM7go5HBn2p1Fiom8QzhAybqUFAsC2 2Tzi+3g/tAQgDT+ZsQUnxNXFAUthVGiEsOyDr3AQBikg/sC4atO4kCvEAvnEhhk4 wigNOoMIQAw5u4fwE4oGhA7CTq1qCKHURQTSfvf4= Received: (qmail 3031 invoked by alias); 17 Apr 2014 20:15:18 -0000 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org Delivered-To: mailing list gdb-patches@sourceware.org Received: (qmail 3017 invoked by uid 89); 17 Apr 2014 20:15:17 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pd0-f202.google.com Received: from mail-pd0-f202.google.com (HELO mail-pd0-f202.google.com) (209.85.192.202) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-SHA encrypted) ESMTPS; Thu, 17 Apr 2014 20:15:15 +0000 Received: by mail-pd0-f202.google.com with SMTP id fp1so115288pdb.1 for ; Thu, 17 Apr 2014 13:15:13 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id:mime-version :content-type; bh=wn1V41hACzg2zuUewPKeXz/l1AGCvRk8dWrbx4OTw1Q=; b=IKY95Dr0/9B6akcVnzuG4oTGO43y1WDKkgW6Uulr28wi6WyaN5OAdqSWQ/v/kgDpMR PbdjByYgD/aXhWWUcIGqcM2PBMfF/4irKd6Dh0aAFgHVddWsaN5K/WNE4SivF3YrVlTs aJRLFrRISMTQj2G9F4lCHrsR2akWJJiDL+1IelVheD5yB+Avd8KmJzImUNzATWcwT7P5 kNW9+/VbuLIwS9RHXz3eiSrBmkc4MpDisL4aj+Mo7KWkGINuIQ/UsSLy2dX3aBPxkWjg s89szl8M6yfHuYn2yHoPckTQtfKrP3HU1xLFymCpAHd8OGCgZWhKqhuW2Cg2/Tjw9U0g GkGA== X-Gm-Message-State: ALoCoQnymvLLaYTHEQ4bIxGDtSG+Gjc0oj6pqe6z1di3nXTxXqT6wnaLz0NDBhjSb5a0zb6AlruGP/bY1uTwxfiUcyaj+97HhcujPNuTHfR7kAe/5HBXNo+s0TWo0mMD+vpp9AIvOxvi4ngIzTD1PmggLHwoEl2zY9sq+4YGdC2QEPshe3cltpk1O1W0zG8gxMxSPXHwIQWRUMVYye52aEKBOAIRCJSlDNn2QnzMHjf4OCMVHxThrIg= X-Received: by 10.67.30.197 with SMTP id kg5mr8143473pad.36.1397765713200; Thu, 17 Apr 2014 13:15:13 -0700 (PDT) Received: from corp2gmr1-2.hot.corp.google.com (corp2gmr1-2.hot.corp.google.com [172.24.189.93]) by gmr-mx.google.com with ESMTPS id s65si3666625yhc.2.2014.04.17.13.15.13 for (version=TLSv1.1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 17 Apr 2014 13:15:13 -0700 (PDT) Received: from ruffy.mtv.corp.google.com (ruffy.mtv.corp.google.com [172.17.128.44]) by corp2gmr1-2.hot.corp.google.com (Postfix) with ESMTP id C79CC5A4252 for ; Thu, 17 Apr 2014 13:15:12 -0700 (PDT) From: Doug Evans To: gdb-patches@sourceware.org Subject: [PATCH] eval.c (evaluate_subexp_standard): Add some comments. Date: Thu, 17 Apr 2014 13:15:12 -0700 Message-ID: MIME-Version: 1.0 X-IsSubscribed: yes X-DH-Original-To: gdb@patchwork.siddhesh.in Hi. Reading this part of evaluate_subexp_standard was harder than it could be (for me anyway). 2014-04-17 Doug Evans * eval.c (evaluate_subexp_standard): Add some comments. diff --git a/gdb/eval.c b/gdb/eval.c index 3e62ead..8cc923d 100644 --- a/gdb/eval.c +++ b/gdb/eval.c @@ -1363,7 +1363,7 @@ evaluate_subexp_standard (struct type *expect_type, op = exp->elts[*pos].opcode; nargs = longest_to_int (exp->elts[pc + 1].longconst); /* Allocate arg vector, including space for the function to be - called in argvec[0] and a terminating NULL. */ + called in argvec[0], a potential `this', and a terminating NULL. */ argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 3)); if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR) @@ -1514,6 +1514,7 @@ evaluate_subexp_standard (struct type *expect_type, name, TYPE_TAG_NAME (type)); tem = 1; + /* arg2 is left as NULL on purpose. */ } else { @@ -1521,6 +1522,8 @@ evaluate_subexp_standard (struct type *expect_type, || TYPE_CODE (type) == TYPE_CODE_UNION); function_name = name; + /* We need a properly typed value for method lookup. For + static methods arg2 is otherwise unused. */ arg2 = value_zero (type, lval_memory); ++nargs; tem = 2; @@ -1570,7 +1573,8 @@ evaluate_subexp_standard (struct type *expect_type, } } - /* Evaluate arguments. */ + /* Evaluate arguments (if not already done, e.g., namespace::func() + and overload-resolution is off). */ for (; tem <= nargs; tem++) { /* Ensure that array expressions are coerced into pointer @@ -1580,6 +1584,7 @@ evaluate_subexp_standard (struct type *expect_type, /* Signal end of arglist. */ argvec[tem] = 0; + if (op == OP_ADL_FUNC) { struct symbol *symp; @@ -1609,7 +1614,8 @@ evaluate_subexp_standard (struct type *expect_type, int static_memfuncp; char *tstr; - /* Method invocation : stuff "this" as first parameter. */ + /* Method invocation: stuff "this" as first parameter. + If the method turns out to be static we undo this below. */ argvec[1] = arg2; if (op != OP_SCOPE) @@ -1663,6 +1669,7 @@ evaluate_subexp_standard (struct type *expect_type, argvec[1] = arg2; /* the ``this'' pointer */ } + /* Take out `this' if needed. */ if (static_memfuncp) { argvec[1] = argvec[0];