[PATCH v2 5/6] Add a flag to BuildDeclarationNameExpr to not reject invalid decls.
David Blaikie
dblaikie at gmail.com
Wed Nov 12 15:30:26 PST 2014
On Wed, Nov 5, 2014 at 1:06 PM, Kaelyn Takata <rikka at google.com> wrote:
>
>
> On Tue, Nov 4, 2014 at 4:36 PM, David Blaikie <dblaikie at gmail.com> wrote:
>
>> It's helpful to either use an enum (which always seems a bit silly) or a
>> comment (more realistic, especially since you only have to comment that
>> single caller in attemptRecovery) to describe what the boolean value is for
>> ("/*AcceptInvalidDecl*/ true").
>>
>
> I've added comments for both boolean values in the call to
> SemaRef.BuildDeclarationNameExpr from attemptRecovery.
>
>>
>> What's this flag needed/used for?
>>
>
> The flag is needed to get a valid DeclRefExpr during error recovery even
> when the Decl isn't marked as valid.
>
Why does this need to be a flag? (what bad things happen if we always
accept invalid decls?)
> For example, with the full patch set, not having the flag causes the last
> error of test/SemaCXX/conversion-function.cpp (at line 419) to fail to be
> typo-corrected. With the flag or without this patchset:
>
> ~/llvm/tools/clang/test/SemaCXX/conversion-function.cpp:419:18: error: no
> member named 'e' in 'PR18234::A'; did you mean simply 'e'?
> bool k1 = e == A::e; // expected-error {{no member named 'e'}}
> ^~~~
> e
> ~/llvm/tools/clang/test/SemaCXX/conversion-function.cpp:418:8: note: 'e'
> declared here
> A::E e = a; // expected-note {{here}}
> ^
> 4 warnings and 26 errors generated.
>
> With this patchset but without this flag:
>
> ~/llvm/tools/clang/test/SemaCXX/conversion-function.cpp:419:21: error: no
> member named 'e' in 'PR18234::A'
> bool k1 = e == A::e; // expected-error {{no member named 'e'}}
> ~~~^
> 4 warnings and 26 errors generated.
>
>
>> On Wed, Oct 29, 2014 at 12:49 PM, Kaelyn Takata <rikka at google.com> wrote:
>>
>>> ---
>>> include/clang/Sema/Sema.h | 6 ++++--
>>> lib/Sema/SemaExpr.cpp | 15 ++++++++-------
>>> lib/Sema/SemaExprCXX.cpp | 2 +-
>>> 3 files changed, 13 insertions(+), 10 deletions(-)
>>>
>>>
>>> _______________________________________________
>>> 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/20141112/0a160c2e/attachment.html>
More information about the cfe-commits
mailing list