From ed86058b53f971ed93cc79c8b4fc76da37ca0664 Mon Sep 17 00:00:00 2001 From: Erich Keane Date: Thu, 7 May 2020 12:11:03 -0700 Subject: Add static assert to ID Table to make sure aux targets work right. I discovered that the limit on possible builtins managed by this ObjCOrBuiltin variable is too low when combining large targets, since aux-targets are appended to the targets list. A runtime assert exists for this, however this patch creates a static-assert as well. The logic for said static-assert is to make sure we have the room for the aux-target and target to both be the largest list, which makes sure we have room for all possible combinations. I also incremented the number of bits by 1, since I discovered this currently broken. The current bit-count was 36, so this doesn't increase any size. --- clang/lib/Basic/IdentifierTable.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'clang/lib/Basic/IdentifierTable.cpp') 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 //===----------------------------------------------------------------------===// -- cgit v1.1