ParsedAttr::Syntax SyntaxUsed) {
// Normalize the attribute name, __foo__ becomes foo. This is only allowable
// for GNU attributes, and attributes using the double square bracket syntax.
- bool IsGNU = SyntaxUsed == ParsedAttr::AS_GNU ||
- ((SyntaxUsed == ParsedAttr::AS_CXX11 ||
- SyntaxUsed == ParsedAttr::AS_C2x) &&
- NormalizedScopeName == "gnu");
- if (IsGNU && AttrName.size() >= 4 && AttrName.startswith("__") &&
+ bool ShouldNormalize =
+ SyntaxUsed == ParsedAttr::AS_GNU ||
+ ((SyntaxUsed == ParsedAttr::AS_CXX11 ||
+ SyntaxUsed == ParsedAttr::AS_C2x) &&
+ (NormalizedScopeName == "gnu" || NormalizedScopeName == "clang"));
+ if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith("__") &&
AttrName.endswith("__"))
AttrName = AttrName.slice(2, AttrName.size() - 2);
};
// Verify that we can handle the [[_Clang::optnone]] and
-// [[__clang__::optnone]] spellings.
+// [[__clang__::optnone]] spellings, as well as [[clang::__optnone__]].
[[_Clang::optnone]] int foo3();
[[__clang__::optnone]] int foo4(); // expected-warning {{'__clang__' is a predefined macro name, not an attribute scope specifier; did you mean '_Clang' instead?}}
+[[clang::__optnone__]] int foo5();
+[[_Clang::__optnone__]] int foo6();
-[[_Clang::optnone]] int foo5; // expected-warning {{'optnone' attribute only applies to functions}}
+[[_Clang::optnone]] int foo7; // expected-warning {{'optnone' attribute only applies to functions}}