aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Sema/SemaCodeComplete.cpp
diff options
context:
space:
mode:
authorserge-sans-paille <sguelton@redhat.com>2020-12-09 09:26:27 +0100
committerserge-sans-paille <sguelton@redhat.com>2021-05-04 11:19:01 +0200
commitb83b23275b745287bf9d3d72a93b593119f53f75 (patch)
tree631e684005609ed7cd0709d5d805aaddb5edf365 /clang/lib/Sema/SemaCodeComplete.cpp
parent46fa214a6f24549d83a69793b7e14585c2eefa2b (diff)
downloadllvm-b83b23275b745287bf9d3d72a93b593119f53f75.zip
llvm-b83b23275b745287bf9d3d72a93b593119f53f75.tar.gz
llvm-b83b23275b745287bf9d3d72a93b593119f53f75.tar.bz2
Introduce -Wreserved-identifier
Warn when a declaration uses an identifier that doesn't obey the reserved identifier rule from C and/or C++. Differential Revision: https://reviews.llvm.org/D93095
Diffstat (limited to 'clang/lib/Sema/SemaCodeComplete.cpp')
-rw-r--r--clang/lib/Sema/SemaCodeComplete.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 4330024e..8893bd2 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -739,18 +739,17 @@ getRequiredQualification(ASTContext &Context, const DeclContext *CurContext,
// Filter out names reserved for the implementation if they come from a
// system header.
static bool shouldIgnoreDueToReservedName(const NamedDecl *ND, Sema &SemaRef) {
- const IdentifierInfo *Id = ND->getIdentifier();
- if (!Id)
- return false;
-
+ ReservedIdentifierStatus Status = ND->isReserved(SemaRef.getLangOpts());
// Ignore reserved names for compiler provided decls.
- if (Id->isReservedName() && ND->getLocation().isInvalid())
+ if ((Status != ReservedIdentifierStatus::NotReserved) &&
+ (Status != ReservedIdentifierStatus::StartsWithUnderscoreAtGlobalScope) &&
+ ND->getLocation().isInvalid())
return true;
// For system headers ignore only double-underscore names.
// This allows for system headers providing private symbols with a single
// underscore.
- if (Id->isReservedName(/*doubleUnderscoreOnly=*/true) &&
+ if (Status == ReservedIdentifierStatus::StartsWithDoubleUnderscore &&
SemaRef.SourceMgr.isInSystemHeader(
SemaRef.SourceMgr.getSpellingLoc(ND->getLocation())))
return true;