Author: Leonard Grey
Date: 2022-06-03T12:11:48-04:00
New Revision: dd6bcdbf21716c56d3defd7f4cacddc7befd5de1
URL:
https://github.com/llvm/llvm-project/commit/dd6bcdbf21716c56d3defd7f4cacddc7befd5de1
DIFF:
https://github.com/llvm/llvm-project/commit/dd6bcdbf21716c56d3defd7f4cacddc7befd5de1.diff
LOG: [Attributes] Remove AttrSyntax and migrate uses to
AttributeCommonInfo::Syntax (NFC)
This is setup for allowing hasAttribute to work for plugin-provided attributes
Differential Revision: https://reviews.llvm.org/D126902
Added:
Modified:
clang/include/clang/Basic/Attributes.h
clang/lib/Basic/Attributes.cpp
clang/lib/Lex/PPMacroExpansion.cpp
clang/lib/Parse/ParseDecl.cpp
clang/lib/Parse/ParseDeclCXX.cpp
clang/utils/TableGen/ClangAttrEmitter.cpp
Removed:
diff --git a/clang/include/clang/Basic/Attributes.h
b/clang/include/clang/Basic/Attributes.h
index 4afb6a1b9ca25..3fc5fbacdb2cb 100644
--- a/clang/include/clang/Basic/Attributes.h
+++ b/clang/include/clang/Basic/Attributes.h
@@ -9,6 +9,7 @@
#ifndef LLVM_CLANG_BASIC_ATTRIBUTES_H
#define LLVM_CLANG_BASIC_ATTRIBUTES_H
+#include "clang/Basic/AttributeCommonInfo.h"
#include "clang/Basic/LangOptions.h"
#include "clang/Basic/TargetInfo.h"
@@ -16,28 +17,11 @@ namespace clang {
class IdentifierInfo;
-enum class AttrSyntax {
- /// Is the identifier known as a GNU-style attribute?
- GNU,
- /// Is the identifier known as a __declspec-style attribute?
- Declspec,
- /// Is the identifier known as a [] Microsoft-style attribute?
- Microsoft,
- // Is the identifier known as a C++-style attribute?
- CXX,
- // Is the identifier known as a C-style attribute?
- C,
- // Is the identifier known as a pragma attribute?
- Pragma,
- // Is the identifier known as a HLSL semantic?
- HLSLSemantic,
-};
-
/// Return the version number associated with the attribute if we
/// recognize and implement the attribute specified by the given information.
-int hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
- const IdentifierInfo *Attr, const TargetInfo &Target,
- const LangOptions &LangOpts);
+int hasAttribute(AttributeCommonInfo::Syntax Syntax,
+ const IdentifierInfo *Scope, const IdentifierInfo *Attr,
+ const TargetInfo &Target, const LangOptions &LangOpts);
} // end namespace clang
diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp
index bd27dc13a92f0..960c9773d192a 100644
--- a/clang/lib/Basic/Attributes.cpp
+++ b/clang/lib/Basic/Attributes.cpp
@@ -5,9 +5,9 @@
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
-int clang::hasAttribute(AttrSyntax Syntax, const IdentifierInfo *Scope,
-const IdentifierInfo *Attr, const TargetInfo &Target,
-const LangOptions &LangOpts) {
+int clang::hasAttribute(AttributeCommonInfo::Syntax Syntax,
+const IdentifierInfo *Scope, const IdentifierInfo
*Attr,
+const TargetInfo &Target, const LangOptions &LangOpts)
{
StringRef Name = Attr->getName();
// Normalize the attribute name, __foo__ becomes foo.
if (Name.size() >= 4 && Name.startswith("__") && Name.endswith("__"))
diff --git a/clang/lib/Lex/PPMacroExpansion.cpp
b/clang/lib/Lex/PPMacroExpansion.cpp
index 07ee07e20bb2d..063199b0e6ce5 100644
--- a/clang/lib/Lex/PPMacroExpansion.cpp
+++ b/clang/lib/Lex/PPMacroExpansion.cpp
@@ -11,6 +11,7 @@
//
//===--===//
+#include "clang/Basic/AttributeCommonInfo.h"
#include "clang/Basic/Attributes.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/FileManager.h"
@@ -1689,8 +1690,9 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
[this](Token &Tok, bool &HasLexedNextToken) -> int {
IdentifierInfo *II = ExpectFeatureIdentifierInfo(Tok, *this,
diag::err_feature_check_malformed);
-return II ? hasAttribute(AttrSyntax::GNU, nullptr, II,
- getTargetInfo(), getLangOpts()) : 0;
+return II ? hasAttribute(AttributeCommonInfo::Syntax::AS_GNU, nullptr,
+ II, getTargetInfo(), getLangOpts())
+ : 0;
});
} else if (II == Ident__has_declspec) {
EvaluateFeatureLikeBuiltinMacro(OS, Tok, II, *this, true,
@@ -1700,8 +1702,8 @@ void Preprocessor::ExpandBuiltinMacro(Token &Tok) {
if (II) {
const LangOptions &LangOpts = getLangOpts();
return LangOpts.DeclSpecKeyword &&
- hasAttribute(AttrSyntax::Declspec, nullptr, II,
- getTargetInfo(), LangOpts);
+ hasAttribute(AttributeCommonInfo::Syntax::AS_Declspec,
nullptr,
+ II, getTargetInfo(), LangOpts);