Modify __has_attribute so that it only looks for GNU-style attributes. Removes the ability to look for generic attributes and keywords via this macro, which has the potential to be a breaking change. However, since there is __has_cpp_attribute and __has_declspec_attribute, and given the limited usefulness of querying a generic attribute name regardless of syntax, this seems like the correct path forward.

llvm-svn: 223468
This commit is contained in:
Aaron Ballman 2014-12-05 15:24:55 +00:00
parent 3c0f9b4a7d
commit a6f759e423
5 changed files with 11 additions and 7 deletions

View File

@ -47,7 +47,11 @@ sections with improvements to Clang's support for those languages.
Major New Features
------------------
- A big one.
- The __has_attribute built-in macro no longer queries for attributes across
multiple attribute syntaxes (GNU, C++11, __declspec, etc). Instead, it only
queries GNU-style attributes. With the addition of __has_cpp_attribute and
__has_declspec_attribute, this allows for more precise coverage of attribute
syntax querying.
Improvements to Clang's diagnostics

View File

@ -18,8 +18,6 @@ namespace clang {
class IdentifierInfo;
enum class AttrSyntax {
/// Is the attribute identifier generally known for any syntax?
Generic,
/// Is the identifier known as a GNU-style attribute?
GNU,
/// Is the identifier known as a __declspec-style attribute?

View File

@ -1425,7 +1425,7 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
// Check for a builtin is trivial.
Value = FeatureII->getBuiltinID() != 0;
} else if (II == Ident__has_attribute)
Value = hasAttribute(AttrSyntax::Generic, nullptr, FeatureII,
Value = hasAttribute(AttrSyntax::GNU, nullptr, FeatureII,
getTargetInfo().getTriple(), getLangOpts());
else if (II == Ident__has_cpp_attribute)
Value = hasAttribute(AttrSyntax::CXX, ScopeII, FeatureII,

View File

@ -48,3 +48,8 @@ int has_no_volatile_attribute();
#if !__has_attribute(dllexport)
int does_not_have_dllexport();
#endif
// CHECK: does_not_have_uuid
#if !__has_attribute(uuid)
int does_not_have_uuid
#endif

View File

@ -1920,9 +1920,6 @@ void EmitClangAttrHasAttrImpl(RecordKeeper &Records, raw_ostream &OS) {
}
OS << "switch (Syntax) {\n";
OS << "case AttrSyntax::Generic:\n";
OS << " return llvm::StringSwitch<int>(Name)\n";
GenerateHasAttrSpellingStringSwitch(Attrs, OS);
OS << "case AttrSyntax::GNU:\n";
OS << " return llvm::StringSwitch<int>(Name)\n";
GenerateHasAttrSpellingStringSwitch(GNU, OS, "GNU");