diff options
-rw-r--r-- | clang/include/clang/Basic/IdentifierTable.h | 4 | ||||
-rw-r--r-- | clang/include/clang/Basic/TargetBuiltins.h | 9 | ||||
-rw-r--r-- | clang/lib/Basic/IdentifierTable.cpp | 7 |
3 files changed, 19 insertions, 1 deletions
diff --git a/clang/include/clang/Basic/IdentifierTable.h b/clang/include/clang/Basic/IdentifierTable.h index f23e727..31849bb 100644 --- a/clang/include/clang/Basic/IdentifierTable.h +++ b/clang/include/clang/Basic/IdentifierTable.h @@ -48,6 +48,8 @@ using IdentifierLocPair = std::pair<IdentifierInfo *, SourceLocation>; /// of a pointer to one of these classes. enum { IdentifierInfoAlignment = 8 }; +static constexpr int ObjCOrBuiltinIDBits = 14; + /// One of these records is kept for each identifier that /// is lexed. This contains information about whether the token was \#define'd, /// is a language keyword, or if it is a front-end token of some sort (e.g. a @@ -63,7 +65,7 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo { // ObjC keyword ('protocol' in '@protocol') or builtin (__builtin_inf). // First NUM_OBJC_KEYWORDS values are for Objective-C, // the remaining values are for builtins. - unsigned ObjCOrBuiltinID : 13; + unsigned ObjCOrBuiltinID : ObjCOrBuiltinIDBits; // True if there is a #define for this. unsigned HasMacro : 1; diff --git a/clang/include/clang/Basic/TargetBuiltins.h b/clang/include/clang/Basic/TargetBuiltins.h index bf07a89..db10077 100644 --- a/clang/include/clang/Basic/TargetBuiltins.h +++ b/clang/include/clang/Basic/TargetBuiltins.h @@ -15,6 +15,7 @@ #ifndef LLVM_CLANG_BASIC_TARGETBUILTINS_H #define LLVM_CLANG_BASIC_TARGETBUILTINS_H +#include <algorithm> #include <stdint.h> #include "clang/Basic/Builtins.h" #include "llvm/Support/MathExtras.h" @@ -308,6 +309,14 @@ namespace clang { }; } + static constexpr uint64_t LargestBuiltinID = std::max<uint64_t>( + {NEON::FirstTSBuiltin, ARM::LastTSBuiltin, SVE::FirstTSBuiltin, + AArch64::LastTSBuiltin, BPF::LastTSBuiltin, PPC::LastTSBuiltin, + NVPTX::LastTSBuiltin, AMDGPU::LastTSBuiltin, X86::LastTSBuiltin, + Hexagon::LastTSBuiltin, Mips::LastTSBuiltin, XCore::LastTSBuiltin, + Le64::LastTSBuiltin, SystemZ::LastTSBuiltin, + WebAssembly::LastTSBuiltin}); + } // end namespace clang. #endif diff --git a/clang/lib/Basic/IdentifierTable.cpp b/clang/lib/Basic/IdentifierTable.cpp index d7ef159..36b26d9 100644 --- a/clang/lib/Basic/IdentifierTable.cpp +++ b/clang/lib/Basic/IdentifierTable.cpp @@ -16,6 +16,7 @@ #include "clang/Basic/LangOptions.h" #include "clang/Basic/OperatorKinds.h" #include "clang/Basic/Specifiers.h" +#include "clang/Basic/TargetBuiltins.h" #include "clang/Basic/TokenKinds.h" #include "llvm/ADT/DenseMapInfo.h" #include "llvm/ADT/FoldingSet.h" @@ -32,6 +33,12 @@ using namespace clang; +// A check to make sure the ObjCOrBuiltinID has sufficient room to store the +// largest possible target/aux-target combination. If we exceed this, we likely +// need to just change the ObjCOrBuiltinIDBits value in IdentifierTable.h. +static_assert(2 * LargestBuiltinID < (2 << (ObjCOrBuiltinIDBits - 1)), + "Insufficient ObjCOrBuiltinID Bits"); + //===----------------------------------------------------------------------===// // IdentifierTable Implementation //===----------------------------------------------------------------------===// |