Skip to content

Commit 6bd0c2f

Browse files
committed
Update based on review feedback
* Switch to using a binary_search * Remove an unnecessary check for empty()
1 parent 1308a4e commit 6bd0c2f

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

clang/lib/Sema/SemaDecl.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6119,17 +6119,20 @@ static bool isKeywordInCPlusPlus(const Sema &S, const IdentifierInfo *II) {
61196119
// or not. Note, this treats all keywords as being enabled, regardless of the
61206120
// setting of other language options. It intentionally disables the modules
61216121
// keywords because those are conditional keywords, so may be safe to use.
6122-
static llvm::SmallPtrSet<IdentifierInfo *, 32> Keywords;
6122+
static llvm::SmallVector<uintptr_t, 48> Keywords;
61236123
if (Keywords.empty()) {
61246124
#define MODULES_KEYWORD(NAME)
61256125
#define KEYWORD(NAME, FLAGS) \
6126-
Keywords.insert(&S.getPreprocessor().getIdentifierTable().get(#NAME));
6126+
Keywords.push_back(reinterpret_cast<uint64_t>( \
6127+
&S.getPreprocessor().getIdentifierTable().get(#NAME)));
61276128
#define CXX_KEYWORD_OPERATOR(NAME, TOK) \
6128-
Keywords.insert(&S.getPreprocessor().getIdentifierTable().get(#NAME));
6129+
Keywords.push_back(reinterpret_cast<uint64_t>( \
6130+
&S.getPreprocessor().getIdentifierTable().get(#NAME)));
61296131
#include "clang/Basic/TokenKinds.def"
6132+
llvm::sort(Keywords);
61306133
}
61316134

6132-
return Keywords.contains(II);
6135+
return llvm::binary_search(Keywords, reinterpret_cast<uintptr_t>(II));
61336136
}
61346137

61356138
void Sema::warnOnReservedIdentifier(const NamedDecl *D) {
@@ -10451,7 +10454,7 @@ Sema::ActOnFunctionDeclarator(Scope *S, Declarator &D, DeclContext *DC,
1045110454
// will not be pushed onto a scope chain. That means we will not issue any
1045210455
// reserved identifier warnings for the declaration, but we will for the
1045310456
// definition. Handle those here.
10454-
if (!Params.empty() && !D.isFunctionDefinition()) {
10457+
if (!D.isFunctionDefinition()) {
1045510458
for (const ParmVarDecl *PVD : Params)
1045610459
warnOnReservedIdentifier(PVD);
1045710460
}

0 commit comments

Comments
 (0)