aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2021-08-22 19:00:43 +0000
committerDimitry Andric <dim@FreeBSD.org>2021-11-13 20:39:49 +0000
commitfe6060f10f634930ff71b7c50291ddc610da2475 (patch)
tree1483580c790bd4d27b6500a7542b5ee00534d3cc /contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
parentb61bce17f346d79cecfd8f195a64b10f77be43b1 (diff)
parent344a3780b2e33f6ca763666c380202b18aab72a3 (diff)
Diffstat (limited to 'contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp')
-rw-r--r--contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp43
1 files changed, 42 insertions, 1 deletions
diff --git a/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp b/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
index 51c6e02e2e2e..d811aeec84a0 100644
--- a/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
+++ b/contrib/llvm-project/clang/lib/Basic/IdentifierTable.cpp
@@ -107,8 +107,9 @@ namespace {
KEYCXX20 = 0x200000,
KEYOPENCLCXX = 0x400000,
KEYMSCOMPAT = 0x800000,
+ KEYSYCL = 0x1000000,
KEYALLCXX = KEYCXX | KEYCXX11 | KEYCXX20,
- KEYALL = (0xffffff & ~KEYNOMS18 &
+ KEYALL = (0x1ffffff & ~KEYNOMS18 &
~KEYNOOPENCL) // KEYNOMS18 and KEYNOOPENCL are used to exclude.
};
@@ -155,6 +156,8 @@ static KeywordStatus getKeywordStatus(const LangOptions &LangOpts,
if (LangOpts.CPlusPlus && (Flags & KEYALLCXX)) return KS_Future;
if (LangOpts.CPlusPlus && !LangOpts.CPlusPlus20 && (Flags & CHAR8SUPPORT))
return KS_Future;
+ if (LangOpts.isSYCL() && (Flags & KEYSYCL))
+ return KS_Enabled;
return KS_Disabled;
}
@@ -227,6 +230,9 @@ void IdentifierTable::AddKeywords(const LangOptions &LangOpts) {
if (LangOpts.DeclSpecKeyword)
AddKeyword("__declspec", tok::kw___declspec, KEYALL, LangOpts, *this);
+ if (LangOpts.IEEE128)
+ AddKeyword("__ieee128", tok::kw___float128, KEYALL, LangOpts, *this);
+
// Add the 'import' contextual keyword.
get("import").setModulesImport(true);
}
@@ -270,6 +276,39 @@ bool IdentifierInfo::isCPlusPlusKeyword(const LangOptions &LangOpts) const {
return !isKeyword(LangOptsNoCPP);
}
+ReservedIdentifierStatus
+IdentifierInfo::isReserved(const LangOptions &LangOpts) const {
+ StringRef Name = getName();
+
+ // '_' is a reserved identifier, but its use is so common (e.g. to store
+ // ignored values) that we don't warn on it.
+ if (Name.size() <= 1)
+ return ReservedIdentifierStatus::NotReserved;
+
+ // [lex.name] p3
+ if (Name[0] == '_') {
+
+ // Each name that begins with an underscore followed by an uppercase letter
+ // or another underscore is reserved.
+ if (Name[1] == '_')
+ return ReservedIdentifierStatus::StartsWithDoubleUnderscore;
+
+ if ('A' <= Name[1] && Name[1] <= 'Z')
+ return ReservedIdentifierStatus::
+ StartsWithUnderscoreFollowedByCapitalLetter;
+
+ // This is a bit misleading: it actually means it's only reserved if we're
+ // at global scope because it starts with an underscore.
+ return ReservedIdentifierStatus::StartsWithUnderscoreAtGlobalScope;
+ }
+
+ // Each name that contains a double underscore (__) is reserved.
+ if (LangOpts.CPlusPlus && Name.contains("__"))
+ return ReservedIdentifierStatus::ContainsDoubleUnderscore;
+
+ return ReservedIdentifierStatus::NotReserved;
+}
+
tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
// We use a perfect hash function here involving the length of the keyword,
// the first and third character. For preprocessor ID's there are no
@@ -305,9 +344,11 @@ tok::PPKeywordKind IdentifierInfo::getPPKeywordID() const {
CASE( 6, 'p', 'a', pragma);
CASE( 7, 'd', 'f', defined);
+ CASE( 7, 'e', 'i', elifdef);
CASE( 7, 'i', 'c', include);
CASE( 7, 'w', 'r', warning);
+ CASE( 8, 'e', 'i', elifndef);
CASE( 8, 'u', 'a', unassert);
CASE(12, 'i', 'c', include_next);