Skip to content

Commit c8b6f48

Browse files
committed
Remove old implementation, go back to checking only when enabled
1 parent 908162e commit c8b6f48

File tree

3 files changed

+4
-34
lines changed

3 files changed

+4
-34
lines changed

clang/include/clang/Basic/IdentifierTable.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -444,18 +444,13 @@ class alignas(IdentifierInfoAlignment) IdentifierInfo {
444444
}
445445
bool isCPlusPlusOperatorKeyword() const { return IsCPPOperatorKeyword; }
446446

447-
/// Return true if this identifier uses a keyword token and is a keyword in
448-
/// the specified language.
447+
/// Return true if this token is a keyword in the specified language.
449448
bool isKeyword(const LangOptions &LangOpts) const;
450449

451-
/// Return true if this identifier uses a keyword token and is a C++ keyword
452-
/// in the specified language.
450+
/// Return true if this token is a C++ keyword in the specified
451+
/// language.
453452
bool isCPlusPlusKeyword(const LangOptions &LangOpts) const;
454453

455-
/// Returns true if the name of this identifier matches a keyword given the
456-
/// specified language options.
457-
bool isNameKeyword(const LangOptions &LangOpts) const;
458-
459454
/// Get and set FETokenInfo. The language front-end is allowed to associate
460455
/// arbitrary metadata with this token.
461456
void *getFETokenInfo() const { return FETokenInfo; }

clang/lib/Basic/IdentifierTable.cpp

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -343,15 +343,6 @@ static KeywordStatus getTokenKwStatus(const LangOptions &LangOpts,
343343
}
344344
}
345345

346-
static KeywordStatus getNameKwStatus(const LangOptions &LangOpts,
347-
StringRef Name) {
348-
return llvm::StringSwitch<KeywordStatus>(Name)
349-
#define KEYWORD(NAME, FLAGS) .Case(#NAME, getKeywordStatus(LangOpts, FLAGS))
350-
#define CXX_KEYWORD_OPERATOR(NAME, TOK) .Case(#NAME, KS_Enabled)
351-
#include "clang/Basic/TokenKinds.def"
352-
.Default(KS_Disabled);
353-
}
354-
355346
/// Returns true if the identifier represents a keyword in the
356347
/// specified language.
357348
bool IdentifierInfo::isKeyword(const LangOptions &LangOpts) const {
@@ -364,21 +355,6 @@ bool IdentifierInfo::isKeyword(const LangOptions &LangOpts) const {
364355
}
365356
}
366357

367-
bool IdentifierInfo::isNameKeyword(const LangOptions &LangOpts) const {
368-
// This differs from IdentifierInfo::isCPlusPlusKeyword(). That function
369-
// tests if the identifier is a keyword token in C++ mode and then isn't a
370-
// keyword token in C modes. In our case, if it was a keyword, we wouldn't
371-
// have gotten the identifier for it anyway, so that function will always
372-
// return false for us. Instead, check against the identifier name directly.
373-
switch (getNameKwStatus(LangOpts, getName())) {
374-
case KS_Enabled:
375-
case KS_Extension:
376-
return true;
377-
default:
378-
return false;
379-
}
380-
}
381-
382358
/// Returns true if the identifier represents a C++ keyword in the
383359
/// specified language.
384360
bool IdentifierInfo::isCPlusPlusKeyword(const LangOptions &LangOpts) const {

clang/lib/Sema/SemaDecl.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6145,9 +6145,8 @@ void Sema::warnOnReservedIdentifier(const NamedDecl *D) {
61456145
}
61466146
// Diagnose use of C++ keywords in C as being incompatible with C++.
61476147
if (!getLangOpts().CPlusPlus &&
6148-
/* !Diags.isIgnored(diag::warn_identifier_is_cpp_keyword,
6148+
!Diags.isIgnored(diag::warn_identifier_is_cpp_keyword,
61496149
D->getLocation()) &&
6150-
*/
61516150
isKeywordInCPlusPlus(*this, D->getIdentifier()))
61526151
Diag(D->getLocation(), diag::warn_identifier_is_cpp_keyword) << D;
61536152
}

0 commit comments

Comments
 (0)