Move getLocStart() in Sema::ConvertArgumentsForCall

Reid Kleckner rnk at google.com
Thu Apr 24 18:12:09 PDT 2014


It's not clear that the fix is correct.  The source location of the first
argument may also be invalid.  Maybe the downstream assert should be
relaxed?

I have half a test case:
int foo(int x = 0) {
  return x;
}
int main() {
  return foo();
}

The AST of the call is:
      `-CallExpr 0x15cc18 <col:10, col:17> 'int'
        |-ImplicitCastExpr 0x15cc08 <col:10, col:13> 'int (*)(int)'
<FunctionToPointerDecay>
        | `-DeclRefExpr 0x15c9c0 <col:10, col:13> 'int (int)' lvalue
CXXMethod 0x15c7c0 'foo' 'int (int)'
        `-CXXDefaultArgExpr 0x15cc40 <<invalid sloc>> 'int'

The default argument has an invalid sloc, but the call itself does not.  If
it did, we could get an invalid sloc for the whole thing, but I don't know
how to trigger that.


On Wed, Apr 23, 2014 at 3:33 PM, Keno Fischer
<kfischer at college.harvard.edu>wrote:

> Any chance this could be applied?
>
>
> On Thu, Mar 20, 2014 at 10:57 PM, Keno Fischer <
> kfischer at college.harvard.edu> wrote:
>
>> I had a look, but I don't think I have a way to write a reasonably small
>> test case and there isn't much there in terms of setting up the rest of the
>> compiler to be able to test this one issue.
>>
>>
>> On Wed, Mar 19, 2014 at 4:41 PM, David Blaikie <dblaikie at gmail.com>wrote:
>>
>>> On Wed, Mar 19, 2014 at 11:53 AM, Keno Fischer
>>> <kfischer at college.harvard.edu> wrote:
>>> > I'm not sure I can come up with a reasonably well isolated test case. I
>>> > encountered this in an application that uses clang as a library. From
>>> what I
>>> > can see most of the test cases use the clang driver to test for bugs.
>>> Is
>>> > there any examples of test cases that go through the C++ API (since I
>>> know
>>> > how to trigger it there)?
>>>
>>> The unit tests provide API level testing - tools/clang/unittests.
>>> Though not all API surface is readily unit testable and we'll usually
>>> allow an untested change if there's just no accessible test point...
>>> as unfortunate as it is and as much as we'd like that to change.
>>>
>>> >
>>> >
>>> > On Wed, Mar 19, 2014 at 11:07 AM, David Blaikie <dblaikie at gmail.com>
>>> wrote:
>>> >>
>>> >> A test case would be good, if possible
>>> >>
>>> >> On Tue, Mar 18, 2014 at 9:44 PM, Keno Fischer
>>> >> <kfischer at college.harvard.edu> wrote:
>>> >> > Sema::ConvertArgumentsForCall calls setNumArgs on the CallExpr. This
>>> >> > changes
>>> >> > the result of getLocStart if the SourceLocation stored in the
>>> CallExpr
>>> >> > is
>>> >> > invalid and in that case may lead to an assertion failure. This
>>> quick
>>> >> > patch
>>> >> > fixes that.
>>> >> >
>>> >> > I don't have commit access so let me know if anything else is
>>> needed.
>>> >> >
>>> >> > _______________________________________________
>>> >> > cfe-commits mailing list
>>> >> > cfe-commits at cs.uiuc.edu
>>> >> > http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>>> >> >
>>> >
>>> >
>>>
>>
>>
>
> _______________________________________________
> cfe-commits mailing list
> cfe-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20140424/ff0b98a7/attachment.html>


More information about the cfe-commits mailing list