Skip to content

Commit 4018317

Browse files
authoredJan 23, 2025
[Clang] restrict use of attribute names reserved by the C++ standard (#106036)
Fixes #92196 https://eel.is/c++draft/macro.names#2 > A translation unit shall not #define or #undef names lexically identical to keywords, to the identifiers listed in Table [4](https://eel.is/c++draft/lex.name#tab:lex.name.special), or to the [attribute-token](https://eel.is/c++draft/dcl.attr.grammar#nt:attribute-token)s described in [[dcl.attr]](https://eel.is/c++draft/dcl.attr), except that the names likely and unlikely may be defined as function-like macros ([[cpp.replace]](https://eel.is/c++draft/cpp.replace))[.](https://eel.is/c++draft/macro.names#2.sentence-1)
1 parent c3ecbe6 commit 4018317

File tree

17 files changed

+234
-28
lines changed

17 files changed

+234
-28
lines changed
 

‎clang/docs/ReleaseNotes.rst

+2
Original file line numberDiff line numberDiff line change
@@ -807,6 +807,8 @@ Improvements to Clang's diagnostics
807807

808808
- Clang now emits a ``-Wignored-qualifiers`` diagnostic when a base class includes cv-qualifiers (#GH55474).
809809

810+
- Clang now diagnoses the use of attribute names reserved by the C++ standard (#GH92196).
811+
810812
Improvements to Clang's time-trace
811813
----------------------------------
812814

‎clang/include/clang/Basic/AttributeCommonInfo.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -61,13 +61,18 @@ class AttributeCommonInfo {
6161
};
6262
enum Kind {
6363
#define PARSED_ATTR(NAME) AT_##NAME,
64-
#include "clang/Sema/AttrParsedAttrList.inc"
64+
#include "clang/Basic/AttrParsedAttrList.inc"
6565
#undef PARSED_ATTR
6666
NoSemaHandlerAttribute,
6767
IgnoredAttribute,
6868
UnknownAttribute,
6969
};
7070
enum class Scope { NONE, CLANG, GNU, MSVC, OMP, HLSL, GSL, RISCV };
71+
enum class AttrArgsInfo {
72+
None,
73+
Optional,
74+
Required,
75+
};
7176

7277
private:
7378
const IdentifierInfo *AttrName = nullptr;
@@ -241,6 +246,8 @@ class AttributeCommonInfo {
241246
static Kind getParsedKind(const IdentifierInfo *Name,
242247
const IdentifierInfo *Scope, Syntax SyntaxUsed);
243248

249+
static AttrArgsInfo getCXX11AttrArgsInfo(const IdentifierInfo *Name);
250+
244251
private:
245252
/// Get an index into the attribute spelling list
246253
/// defined in Attr.td. This index is used by an attribute

‎clang/include/clang/Basic/Attributes.h

+5
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,11 @@ int hasAttribute(AttributeCommonInfo::Syntax Syntax,
2323
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
2424
const TargetInfo &Target, const LangOptions &LangOpts);
2525

26+
int hasAttribute(AttributeCommonInfo::Syntax Syntax,
27+
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
28+
const TargetInfo &Target, const LangOptions &LangOpts,
29+
bool CheckPlugins);
30+
2631
} // end namespace clang
2732

2833
#endif // LLVM_CLANG_BASIC_ATTRIBUTES_H

‎clang/include/clang/Basic/CMakeLists.txt

+11
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ clang_tablegen(AttrList.inc -gen-clang-attr-list
3636
SOURCE Attr.td
3737
TARGET ClangAttrList)
3838

39+
clang_tablegen(AttrParsedAttrList.inc -gen-clang-attr-parsed-attr-list
40+
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
41+
SOURCE Attr.td
42+
TARGET ClangAttrParsedAttrList)
43+
3944
clang_tablegen(AttrSubMatchRulesList.inc -gen-clang-attr-subject-match-rule-list
4045
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
4146
SOURCE Attr.td
@@ -53,6 +58,12 @@ clang_tablegen(AttrHasAttributeImpl.inc -gen-clang-attr-has-attribute-impl
5358
TARGET ClangAttrHasAttributeImpl
5459
)
5560

61+
clang_tablegen(CXX11AttributeInfo.inc -gen-cxx11-attribute-info
62+
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
63+
SOURCE Attr.td
64+
TARGET CXX11AttributeInfo
65+
)
66+
5667
clang_tablegen(Builtins.inc -gen-clang-builtins
5768
SOURCE Builtins.td
5869
TARGET ClangBuiltins)

‎clang/include/clang/Basic/DiagnosticGroups.td

+3-1
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,7 @@ def AmbiguousMacro : DiagGroup<"ambiguous-macro">;
760760
def KeywordAsMacro : DiagGroup<"keyword-macro">;
761761
def ReservedIdAsMacro : DiagGroup<"reserved-macro-identifier">;
762762
def ReservedIdAsMacroAlias : DiagGroup<"reserved-id-macro", [ReservedIdAsMacro]>;
763+
def ReservedAttributeIdentifier : DiagGroup<"reserved-attribute-identifier">;
763764
def RestrictExpansionMacro : DiagGroup<"restrict-expansion">;
764765
def FinalMacro : DiagGroup<"final-macro">;
765766

@@ -935,7 +936,8 @@ def SignedEnumBitfield : DiagGroup<"signed-enum-bitfield">;
935936

936937
def ReservedModuleIdentifier : DiagGroup<"reserved-module-identifier">;
937938
def ReservedIdentifier : DiagGroup<"reserved-identifier",
938-
[ReservedIdAsMacro, ReservedModuleIdentifier, UserDefinedLiterals]>;
939+
[ReservedIdAsMacro, ReservedModuleIdentifier,
940+
UserDefinedLiterals, ReservedAttributeIdentifier]>;
939941

940942
// Unreachable code warning groups.
941943
//

‎clang/include/clang/Basic/DiagnosticLexKinds.td

+3
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,9 @@ def warn_pp_macro_hides_keyword : Extension<
407407
def warn_pp_macro_is_reserved_id : Warning<
408408
"macro name is a reserved identifier">, DefaultIgnore,
409409
InGroup<ReservedIdAsMacro>;
410+
def warn_pp_macro_is_reserved_attribute_id : Warning<
411+
"%0 is a reserved attribute identifier">, DefaultIgnore,
412+
InGroup<ReservedAttributeIdentifier>;
410413
def warn_pp_objc_macro_redef_ignored : Warning<
411414
"ignoring redefinition of Objective-C qualifier macro">,
412415
InGroup<DiagGroup<"objc-macro-redefinition">>;

‎clang/include/clang/Lex/Preprocessor.h

+5-5
Original file line numberDiff line numberDiff line change
@@ -2271,6 +2271,11 @@ class Preprocessor {
22712271
}
22722272
}
22732273

2274+
/// Determine whether the next preprocessor token to be
2275+
/// lexed is a '('. If so, consume the token and return true, if not, this
2276+
/// method should have no observable side-effect on the lexed tokens.
2277+
bool isNextPPTokenLParen();
2278+
22742279
private:
22752280
/// Identifiers used for SEH handling in Borland. These are only
22762281
/// allowed in particular circumstances
@@ -2648,11 +2653,6 @@ class Preprocessor {
26482653

26492654
void removeCachedMacroExpandedTokensOfLastLexer();
26502655

2651-
/// Determine whether the next preprocessor token to be
2652-
/// lexed is a '('. If so, consume the token and return true, if not, this
2653-
/// method should have no observable side-effect on the lexed tokens.
2654-
bool isNextPPTokenLParen();
2655-
26562656
/// After reading "MACRO(", this method is invoked to read all of the formal
26572657
/// arguments specified for the macro invocation. Returns null on error.
26582658
MacroArgs *ReadMacroCallArgumentList(Token &MacroName, MacroInfo *MI,

‎clang/include/clang/Sema/CMakeLists.txt

-5
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,6 @@ clang_tablegen(AttrTemplateInstantiate.inc -gen-clang-attr-template-instantiate
33
SOURCE ../Basic/Attr.td
44
TARGET ClangAttrTemplateInstantiate)
55

6-
clang_tablegen(AttrParsedAttrList.inc -gen-clang-attr-parsed-attr-list
7-
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
8-
SOURCE ../Basic/Attr.td
9-
TARGET ClangAttrParsedAttrList)
10-
116
clang_tablegen(AttrParsedAttrKinds.inc -gen-clang-attr-parsed-attr-kinds
127
-I ${CMAKE_CURRENT_SOURCE_DIR}/../../
138
SOURCE ../Basic/Attr.td

‎clang/lib/Basic/Attributes.cpp

+26-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ static int hasAttributeImpl(AttributeCommonInfo::Syntax Syntax, StringRef Name,
3333

3434
int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,
3535
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
36-
const TargetInfo &Target, const LangOptions &LangOpts) {
36+
const TargetInfo &Target, const LangOptions &LangOpts,
37+
bool CheckPlugins) {
3738
StringRef Name = Attr->getName();
3839
// Normalize the attribute name, __foo__ becomes foo.
3940
if (Name.size() >= 4 && Name.starts_with("__") && Name.ends_with("__"))
@@ -61,14 +62,23 @@ int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,
6162
if (res)
6263
return res;
6364

64-
// Check if any plugin provides this attribute.
65-
for (auto &Ptr : getAttributePluginInstances())
66-
if (Ptr->hasSpelling(Syntax, Name))
67-
return 1;
65+
if (CheckPlugins) {
66+
// Check if any plugin provides this attribute.
67+
for (auto &Ptr : getAttributePluginInstances())
68+
if (Ptr->hasSpelling(Syntax, Name))
69+
return 1;
70+
}
6871

6972
return 0;
7073
}
7174

75+
int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,
76+
const IdentifierInfo *Scope, const IdentifierInfo *Attr,
77+
const TargetInfo &Target, const LangOptions &LangOpts) {
78+
return hasAttribute(Syntax, Scope, Attr, Target, LangOpts,
79+
/*CheckPlugins=*/true);
80+
}
81+
7282
const char *attr::getSubjectMatchRuleSpelling(attr::SubjectMatchRule Rule) {
7383
switch (Rule) {
7484
#define ATTR_MATCH_RULE(NAME, SPELLING, IsAbstract) \
@@ -151,6 +161,17 @@ AttributeCommonInfo::getParsedKind(const IdentifierInfo *Name,
151161
return ::getAttrKind(normalizeName(Name, ScopeName, SyntaxUsed), SyntaxUsed);
152162
}
153163

164+
AttributeCommonInfo::AttrArgsInfo
165+
AttributeCommonInfo::getCXX11AttrArgsInfo(const IdentifierInfo *Name) {
166+
StringRef AttrName =
167+
normalizeAttrName(Name, /*NormalizedScopeName*/ "", Syntax::AS_CXX11);
168+
#define CXX11_ATTR_ARGS_INFO
169+
return llvm::StringSwitch<AttributeCommonInfo::AttrArgsInfo>(AttrName)
170+
#include "clang/Basic/CXX11AttributeInfo.inc"
171+
.Default(AttributeCommonInfo::AttrArgsInfo::None);
172+
#undef CXX11_ATTR_ARGS_INFO
173+
}
174+
154175
std::string AttributeCommonInfo::getNormalizedFullName() const {
155176
return static_cast<std::string>(
156177
normalizeName(getAttrName(), getScopeName(), getSyntax()));

‎clang/lib/Lex/PPDirectives.cpp

+27-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
///
1212
//===----------------------------------------------------------------------===//
1313

14+
#include "clang/Basic/AttributeCommonInfo.h"
15+
#include "clang/Basic/Attributes.h"
1416
#include "clang/Basic/CharInfo.h"
1517
#include "clang/Basic/DirectoryEntry.h"
1618
#include "clang/Basic/FileManager.h"
@@ -97,7 +99,8 @@ SourceRange Preprocessor::DiscardUntilEndOfDirective(Token &Tmp) {
9799
enum MacroDiag {
98100
MD_NoWarn, //> Not a reserved identifier
99101
MD_KeywordDef, //> Macro hides keyword, enabled by default
100-
MD_ReservedMacro //> #define of #undef reserved id, disabled by default
102+
MD_ReservedMacro, //> #define of #undef reserved id, disabled by default
103+
MD_ReservedAttributeIdentifier
101104
};
102105

103106
/// Enumerates possible %select values for the pp_err_elif_after_else and
@@ -173,6 +176,22 @@ static bool isLanguageDefinedBuiltin(const SourceManager &SourceMgr,
173176
return false;
174177
}
175178

179+
static bool isReservedCXXAttributeName(Preprocessor &PP, IdentifierInfo *II) {
180+
const LangOptions &Lang = PP.getLangOpts();
181+
if (Lang.CPlusPlus &&
182+
hasAttribute(AttributeCommonInfo::AS_CXX11, /* Scope*/ nullptr, II,
183+
PP.getTargetInfo(), Lang, /*CheckPlugins*/ false) > 0) {
184+
AttributeCommonInfo::AttrArgsInfo AttrArgsInfo =
185+
AttributeCommonInfo::getCXX11AttrArgsInfo(II);
186+
if (AttrArgsInfo == AttributeCommonInfo::AttrArgsInfo::Required)
187+
return PP.isNextPPTokenLParen();
188+
189+
return !PP.isNextPPTokenLParen() ||
190+
AttrArgsInfo == AttributeCommonInfo::AttrArgsInfo::Optional;
191+
}
192+
return false;
193+
}
194+
176195
static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
177196
const LangOptions &Lang = PP.getLangOpts();
178197
StringRef Text = II->getName();
@@ -182,6 +201,8 @@ static MacroDiag shouldWarnOnMacroDef(Preprocessor &PP, IdentifierInfo *II) {
182201
return MD_KeywordDef;
183202
if (Lang.CPlusPlus11 && (Text == "override" || Text == "final"))
184203
return MD_KeywordDef;
204+
if (isReservedCXXAttributeName(PP, II))
205+
return MD_ReservedAttributeIdentifier;
185206
return MD_NoWarn;
186207
}
187208

@@ -190,6 +211,8 @@ static MacroDiag shouldWarnOnMacroUndef(Preprocessor &PP, IdentifierInfo *II) {
190211
// Do not warn on keyword undef. It is generally harmless and widely used.
191212
if (isReservedInAllContexts(II->isReserved(Lang)))
192213
return MD_ReservedMacro;
214+
if (isReservedCXXAttributeName(PP, II))
215+
return MD_ReservedAttributeIdentifier;
193216
return MD_NoWarn;
194217
}
195218

@@ -365,6 +388,9 @@ bool Preprocessor::CheckMacroName(Token &MacroNameTok, MacroUse isDefineUndef,
365388
}
366389
if (D == MD_ReservedMacro)
367390
Diag(MacroNameTok, diag::warn_pp_macro_is_reserved_id);
391+
if (D == MD_ReservedAttributeIdentifier)
392+
Diag(MacroNameTok, diag::warn_pp_macro_is_reserved_attribute_id)
393+
<< II->getName();
368394
}
369395

370396
// Okay, we got a good identifier.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST1
2+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST2
3+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST3
4+
// RUN: %clang_cc1 -triple x86_64-linux-gnu -std=c++11 -Wreserved-attribute-identifier -fsyntax-only -verify %s -DTEST4
5+
6+
#ifdef TEST1
7+
8+
#define assume
9+
#undef assume
10+
11+
#define noreturn // expected-warning {{noreturn is a reserved attribute identifier}}
12+
#undef noreturn // expected-warning {{noreturn is a reserved attribute identifier}}
13+
14+
#define carries_dependency // expected-warning {{carries_dependency is a reserved attribute identifier}}
15+
#undef carries_dependency // expected-warning {{carries_dependency is a reserved attribute identifier}}
16+
17+
#define deprecated // expected-warning {{deprecated is a reserved attribute identifier}}
18+
#undef deprecated // expected-warning {{deprecated is a reserved attribute identifier}}
19+
20+
#define fallthrough // expected-warning {{fallthrough is a reserved attribute identifier}}
21+
#undef fallthrough // expected-warning {{fallthrough is a reserved attribute identifier}}
22+
23+
#define likely // expected-warning {{likely is a reserved attribute identifier}}
24+
#undef likely // expected-warning {{likely is a reserved attribute identifier}}
25+
26+
#define no_unique_address // expected-warning {{no_unique_address is a reserved attribute identifier}}
27+
#undef no_unique_address // expected-warning {{no_unique_address is a reserved attribute identifier}}
28+
29+
#define unlikely // expected-warning {{unlikely is a reserved attribute identifier}}
30+
#undef unlikely // expected-warning {{unlikely is a reserved attribute identifier}}
31+
32+
#define maybe_unused // expected-warning {{maybe_unused is a reserved attribute identifier}}
33+
#undef maybe_unused // expected-warning {{maybe_unused is a reserved attribute identifier}}
34+
35+
#define nodiscard // expected-warning {{nodiscard is a reserved attribute identifier}}
36+
#undef nodiscard // expected-warning {{nodiscard is a reserved attribute identifier}}
37+
38+
#elif TEST2
39+
40+
#define assume "test"
41+
#undef assume
42+
43+
#define noreturn "test" // expected-warning {{noreturn is a reserved attribute identifier}}
44+
#undef noreturn // expected-warning {{noreturn is a reserved attribute identifier}}
45+
46+
#define carries_dependency "test" // expected-warning {{carries_dependency is a reserved attribute identifier}}
47+
#undef carries_dependency // expected-warning {{carries_dependency is a reserved attribute identifier}}
48+
49+
#define deprecated "test" // expected-warning {{deprecated is a reserved attribute identifier}}
50+
#undef deprecated // expected-warning {{deprecated is a reserved attribute identifier}}
51+
52+
#define fallthrough "test" // expected-warning {{fallthrough is a reserved attribute identifier}}
53+
#undef fallthrough // expected-warning {{fallthrough is a reserved attribute identifier}}
54+
55+
#define likely "test" // expected-warning {{likely is a reserved attribute identifier}}
56+
#undef likely // expected-warning {{likely is a reserved attribute identifier}}
57+
58+
#define no_unique_address "test" // expected-warning {{no_unique_address is a reserved attribute identifier}}
59+
#undef no_unique_address // expected-warning {{no_unique_address is a reserved attribute identifier}}
60+
61+
#define unlikely "test" // expected-warning {{unlikely is a reserved attribute identifier}}
62+
#undef unlikely // expected-warning {{unlikely is a reserved attribute identifier}}
63+
64+
#define maybe_unused "test" // expected-warning {{maybe_unused is a reserved attribute identifier}}
65+
#undef maybe_unused // expected-warning {{maybe_unused is a reserved attribute identifier}}
66+
67+
#define nodiscard "test" // expected-warning {{nodiscard is a reserved attribute identifier}}
68+
#undef nodiscard // expected-warning {{nodiscard is a reserved attribute identifier}}
69+
70+
#elif TEST3
71+
72+
#define assume() "test" // expected-warning {{assume is a reserved attribute identifier}}
73+
#define deprecated() "test" // expected-warning {{deprecated is a reserved attribute identifier}}
74+
#define nodiscard() "test" // expected-warning {{nodiscard is a reserved attribute identifier}}
75+
#define noreturn() "test"
76+
#define carries_dependency() "test"
77+
#define fallthrough() "test"
78+
#define likely() "test"
79+
#define no_unique_address() "test"
80+
#define unlikely() "test"
81+
#define maybe_unused() "test"
82+
83+
#elif TEST4
84+
85+
#define assume() // expected-warning {{assume is a reserved attribute identifier}}
86+
#define deprecated() // expected-warning {{deprecated is a reserved attribute identifier}}
87+
#define nodiscard() // expected-warning {{nodiscard is a reserved attribute identifier}}
88+
#define noreturn()
89+
#define carries_dependency()
90+
#define fallthrough()
91+
#define likely()
92+
#define no_unique_address()
93+
#define unlikely()
94+
#define maybe_unused()
95+
96+
#else
97+
98+
#error Unknown test
99+
100+
#endif

‎clang/utils/TableGen/ClangAttrEmitter.cpp

+30
Original file line numberDiff line numberDiff line change
@@ -3743,6 +3743,36 @@ void EmitClangRegularKeywordAttributeInfo(const RecordKeeper &Records,
37433743
OS << "#undef KEYWORD_ATTRIBUTE\n";
37443744
}
37453745

3746+
void EmitCXX11AttributeInfo(const RecordKeeper &Records, raw_ostream &OS) {
3747+
OS << "#if defined(CXX11_ATTR_ARGS_INFO)\n";
3748+
for (auto *R : Records.getAllDerivedDefinitions("Attr")) {
3749+
for (const FlattenedSpelling &SI : GetFlattenedSpellings(*R)) {
3750+
if (SI.variety() == "CXX11" && SI.nameSpace().empty()) {
3751+
unsigned RequiredArgs = 0;
3752+
unsigned OptionalArgs = 0;
3753+
for (const auto *Arg : R->getValueAsListOfDefs("Args")) {
3754+
if (Arg->getValueAsBit("Fake"))
3755+
continue;
3756+
3757+
if (Arg->getValueAsBit("Optional"))
3758+
OptionalArgs++;
3759+
else
3760+
RequiredArgs++;
3761+
}
3762+
OS << ".Case(\"" << SI.getSpellingRecord().getValueAsString("Name")
3763+
<< "\","
3764+
<< "AttributeCommonInfo::AttrArgsInfo::"
3765+
<< (RequiredArgs ? "Required"
3766+
: OptionalArgs ? "Optional"
3767+
: "None")
3768+
<< ")"
3769+
<< "\n";
3770+
}
3771+
}
3772+
}
3773+
OS << "#endif // CXX11_ATTR_ARGS_INFO\n";
3774+
}
3775+
37463776
// Emits the list of spellings for attributes.
37473777
void EmitClangAttrHasAttrImpl(const RecordKeeper &Records, raw_ostream &OS) {
37483778
emitSourceFileHeader("Code to implement the __has_attribute logic", OS,

‎clang/utils/TableGen/TableGen.cpp

+6
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ enum ActionType {
6969
GenClangOpenCLBuiltins,
7070
GenClangOpenCLBuiltinHeader,
7171
GenClangOpenCLBuiltinTests,
72+
GenCXX11AttributeInfo,
7273
GenArmNeon,
7374
GenArmFP16,
7475
GenArmBF16,
@@ -228,6 +229,8 @@ cl::opt<ActionType> Action(
228229
"Generate OpenCL builtin header"),
229230
clEnumValN(GenClangOpenCLBuiltinTests, "gen-clang-opencl-builtin-tests",
230231
"Generate OpenCL builtin declaration tests"),
232+
clEnumValN(GenCXX11AttributeInfo, "gen-cxx11-attribute-info",
233+
"Generate CXX11 attributes info"),
231234
clEnumValN(GenArmNeon, "gen-arm-neon", "Generate arm_neon.h for clang"),
232235
clEnumValN(GenArmFP16, "gen-arm-fp16", "Generate arm_fp16.h for clang"),
233236
clEnumValN(GenArmBF16, "gen-arm-bf16", "Generate arm_bf16.h for clang"),
@@ -336,6 +339,9 @@ bool ClangTableGenMain(raw_ostream &OS, const RecordKeeper &Records) {
336339
case GenClangAttrSubjectMatchRulesParserStringSwitches:
337340
EmitClangAttrSubjectMatchRulesParserStringSwitches(Records, OS);
338341
break;
342+
case GenCXX11AttributeInfo:
343+
EmitCXX11AttributeInfo(Records, OS);
344+
break;
339345
case GenClangAttrImpl:
340346
EmitClangAttrImpl(Records, OS);
341347
break;

‎clang/utils/TableGen/TableGenBackends.h

+2
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,8 @@ void EmitClangAttrParserStringSwitches(const llvm::RecordKeeper &Records,
4949
llvm::raw_ostream &OS);
5050
void EmitClangAttrSubjectMatchRulesParserStringSwitches(
5151
const llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
52+
void EmitCXX11AttributeInfo(const llvm::RecordKeeper &Records,
53+
llvm::raw_ostream &OS);
5254
void EmitClangAttrClass(const llvm::RecordKeeper &Records,
5355
llvm::raw_ostream &OS);
5456
void EmitClangAttrImpl(const llvm::RecordKeeper &Records,

‎llvm/utils/gn/secondary/clang/lib/Basic/BUILD.gn

+1-4
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ static_library("Basic") {
2222
public_deps = [
2323
# public_dep because public header Version.h includes generated Version.inc.
2424
"//clang/include/clang/Basic:AttrList",
25+
"//clang/include/clang/Basic:AttrParsedAttrList",
2526
"//clang/include/clang/Basic:AttrSubMatchRulesList",
2627
"//clang/include/clang/Basic:Builtins",
2728
"//clang/include/clang/Basic:BuiltinsBPF",
@@ -42,10 +43,6 @@ static_library("Basic") {
4243
"//clang/include/clang/Basic:riscv_vector_builtins",
4344
"//clang/include/clang/Basic:version",
4445

45-
# public_dep because public header AttributeCommonInfo.h includes generated
46-
# AttrParsedAttrList.inc.
47-
"//clang/include/clang/Sema:AttrParsedAttrList",
48-
4946
# public_dep because public header OpenMPKinds.h includes generated
5047
# OMP.h.inc.
5148
"//llvm/include/llvm/Frontend/OpenMP:public_tablegen",

‎llvm/utils/gn/secondary/clang/lib/Sema/BUILD.gn

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ static_library("Sema") {
99
configs += [ "//llvm/utils/gn/build:clang_code" ]
1010
deps = [
1111
":OpenCLBuiltins",
12+
"//clang/include/clang/Basic:AttrParsedAttrList",
1213
"//clang/include/clang/Basic:arm_cde_builtin_aliases",
1314
"//clang/include/clang/Basic:arm_cde_builtin_sema",
1415
"//clang/include/clang/Basic:arm_mve_builtin_aliases",
@@ -22,7 +23,6 @@ static_library("Sema") {
2223
"//clang/include/clang/Basic:riscv_vector_builtin_sema",
2324
"//clang/include/clang/Sema:AttrParsedAttrImpl",
2425
"//clang/include/clang/Sema:AttrParsedAttrKinds",
25-
"//clang/include/clang/Sema:AttrParsedAttrList",
2626
"//clang/include/clang/Sema:AttrSpellingListIndex",
2727
"//clang/include/clang/Sema:AttrTemplateInstantiate",
2828
"//clang/lib/APINotes",

‎utils/bazel/llvm-project-overlay/clang/BUILD.bazel

+4-5
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,10 @@ gentbl(
572572
"-gen-clang-attr-list",
573573
"include/clang/Basic/AttrList.inc",
574574
),
575+
(
576+
"-gen-clang-attr-parsed-attr-list",
577+
"include/clang/Basic/AttrParsedAttrList.inc",
578+
),
575579
(
576580
"-gen-clang-attr-subject-match-rule-list",
577581
"include/clang/Basic/AttrSubMatchRulesList.inc",
@@ -1135,10 +1139,6 @@ gentbl(
11351139
"-gen-clang-attr-parsed-attr-kinds",
11361140
"include/clang/Sema/AttrParsedAttrKinds.inc",
11371141
),
1138-
(
1139-
"-gen-clang-attr-parsed-attr-list",
1140-
"include/clang/Sema/AttrParsedAttrList.inc",
1141-
),
11421142
(
11431143
"-gen-clang-attr-spelling-index",
11441144
"include/clang/Sema/AttrSpellingListIndex.inc",
@@ -1174,7 +1174,6 @@ cc_library(
11741174
textual_hdrs = [
11751175
"include/clang/Sema/AttrParsedAttrImpl.inc",
11761176
"include/clang/Sema/AttrParsedAttrKinds.inc",
1177-
"include/clang/Sema/AttrParsedAttrList.inc",
11781177
"include/clang/Sema/AttrSpellingListIndex.inc",
11791178
"include/clang/Sema/AttrTemplateInstantiate.inc",
11801179
"lib/Sema/OpenCLBuiltins.inc",

0 commit comments

Comments
 (0)
Please sign in to comment.