[PATCH] D93095: Introduce -Wreserved-identifier
serge via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Jan 19 02:00:11 PST 2021
serge-sans-paille added inline comments.
================
Comment at: clang/lib/AST/Decl.cpp:1099
+ const DeclContext *CurrentContext = getDeclContext();
+ while (true) {
+ if (isa<TranslationUnitDecl>(CurrentContext))
----------------
aaron.ballman wrote:
> Rather than trying to manually decide whether the name will be exposed at the top level, I wonder if we should use `Sema::LookupName()` to try to find the name in the global scope. That would move this code from `AST` into `Sema` to avoid layering issues, so it'd be something more like `bool Sema::IsDeclReserved(const NamedDecl *ND) const` or `bool Sema::IsIdentifierReserved(const IdentifierInfo *II) const`.
>
> The idea is to perform the lookup in global scope and if the lookup finds the identifier, then regardless of how it got there (anonymous union field, anonymous namespaces, enumeration constants, etc), we know it may conflict with an external declaration and diagnose.
>
> WDYT?
That's an interesting proposal.Let me try that!
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D93095/new/
https://reviews.llvm.org/D93095
More information about the cfe-commits
mailing list