Skip to content

Commit 03e70b4

Browse files
[SYCL] Add assert for LangOpts and ParseKind in LanguageOptionsSpecificAttr (#7947)
This commit adds asserts that all attributes deriving from LanguageOptionsSpecificAttr define both a ParseKind and a LangOpts value. Based on #7450 (comment) Signed-off-by: Larsen, Steffen <[email protected]>
1 parent abd38a8 commit 03e70b4

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

clang/utils/TableGen/ClangAttrEmitter.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4066,11 +4066,19 @@ static void GenerateLangOptRequirements(const Record &R,
40664066
// ParseKind name with other attributes. Attributes like these are considered
40674067
// valid for a given language option if any of the attributes they share
40684068
// ParseKind with accepts it.
4069-
if (R.isSubClassOf("LanguageOptionsSpecificAttr") &&
4070-
!R.isValueUnset("ParseKind")) {
4069+
if (R.isSubClassOf("LanguageOptionsSpecificAttr")) {
4070+
assert(!R.isValueUnset("ParseKind") &&
4071+
"Attributes deriving from LanguageOptionsSpecificAttr must all "
4072+
"define a ParseKind string value.");
4073+
assert(!R.isValueUnset("LangOpts") &&
4074+
"Attributes deriving from LanguageOptionsSpecificAttr must all "
4075+
"define a LangOpts list.");
40714076
const StringRef APK = R.getValueAsString("ParseKind");
40724077
for (const auto &I : Dupes) {
40734078
if (I.first == APK) {
4079+
assert(!I.second->isValueUnset("LangOpts") &&
4080+
"Attributes deriving from LanguageOptionsSpecificAttr must all "
4081+
"define a LangOpts list.");
40744082
std::vector<Record *> LO = I.second->getValueAsListOfDefs("LangOpts");
40754083
LangOpts.insert(LangOpts.end(), LO.begin(), LO.end());
40764084
}

0 commit comments

Comments
 (0)