r371985 - Move some definitions from Sema to Basic to fix shared libs build
Erich Keane via cfe-commits
cfe-commits at lists.llvm.org
Mon Sep 16 06:58:59 PDT 2019
Author: erichkeane
Date: Mon Sep 16 06:58:59 2019
New Revision: 371985
URL: http://llvm.org/viewvc/llvm-project?rev=371985&view=rev
Log:
Move some definitions from Sema to Basic to fix shared libs build
r371875 moved some functionality around to a Basic header file, but
didn't move its definitions as well. This patch moves some things
around so that shared library building can work.
Modified:
cfe/trunk/lib/Basic/Attributes.cpp
cfe/trunk/lib/Sema/ParsedAttr.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
Modified: cfe/trunk/lib/Basic/Attributes.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Attributes.cpp?rev=371985&r1=371984&r2=371985&view=diff
==============================================================================
--- cfe/trunk/lib/Basic/Attributes.cpp (original)
+++ cfe/trunk/lib/Basic/Attributes.cpp Mon Sep 16 06:58:59 2019
@@ -1,5 +1,6 @@
#include "clang/Basic/Attributes.h"
#include "clang/Basic/AttrSubjectMatchRules.h"
+#include "clang/Basic/AttributeCommonInfo.h"
#include "clang/Basic/IdentifierTable.h"
#include "llvm/ADT/StringSwitch.h"
using namespace clang;
@@ -21,7 +22,7 @@ int clang::hasAttribute(AttrSyntax Synta
#include "clang/Basic/AttrHasAttributeImpl.inc"
- return 0;
+ return 0;
}
const char *attr::getSubjectMatchRuleSpelling(attr::SubjectMatchRule Rule) {
@@ -33,3 +34,75 @@ const char *attr::getSubjectMatchRuleSpe
}
llvm_unreachable("Invalid subject match rule");
}
+
+static StringRef
+normalizeAttrScopeName(StringRef ScopeName,
+ AttributeCommonInfo::Syntax SyntaxUsed) {
+ // Normalize the "__gnu__" scope name to be "gnu" and the "_Clang" scope name
+ // to be "clang".
+ if (SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
+ SyntaxUsed == AttributeCommonInfo::AS_C2x) {
+ if (ScopeName == "__gnu__")
+ ScopeName = "gnu";
+ else if (ScopeName == "_Clang")
+ ScopeName = "clang";
+ }
+ return ScopeName;
+}
+
+static StringRef normalizeAttrName(StringRef AttrName,
+ StringRef NormalizedScopeName,
+ AttributeCommonInfo::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 ShouldNormalize =
+ SyntaxUsed == AttributeCommonInfo::AS_GNU ||
+ ((SyntaxUsed == AttributeCommonInfo::AS_CXX11 ||
+ SyntaxUsed == AttributeCommonInfo::AS_C2x) &&
+ (NormalizedScopeName.empty() || NormalizedScopeName == "gnu" ||
+ NormalizedScopeName == "clang"));
+ if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith("__") &&
+ AttrName.endswith("__"))
+ AttrName = AttrName.slice(2, AttrName.size() - 2);
+
+ return AttrName;
+}
+
+bool AttributeCommonInfo::isGNUScope() const {
+ return ScopeName && (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"));
+}
+
+#include "clang/Sema/AttrParsedAttrKinds.inc"
+
+AttributeCommonInfo::Kind
+AttributeCommonInfo::getParsedKind(const IdentifierInfo *Name,
+ const IdentifierInfo *ScopeName,
+ Syntax SyntaxUsed) {
+ StringRef AttrName = Name->getName();
+
+ SmallString<64> FullName;
+ if (ScopeName)
+ FullName += normalizeAttrScopeName(ScopeName->getName(), SyntaxUsed);
+
+ AttrName = normalizeAttrName(AttrName, FullName, SyntaxUsed);
+
+ // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
+ // unscoped.
+ if (ScopeName || SyntaxUsed == AS_CXX11 || SyntaxUsed == AS_C2x)
+ FullName += "::";
+ FullName += AttrName;
+
+ return ::getAttrKind(FullName, SyntaxUsed);
+}
+
+unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
+ // Both variables will be used in tablegen generated
+ // attribute spell list index matching code.
+ auto Syntax = static_cast<AttributeCommonInfo::Syntax>(getSyntax());
+ StringRef Scope =
+ getScopeName() ? normalizeAttrScopeName(getScopeName()->getName(), Syntax)
+ : "";
+ StringRef Name = normalizeAttrName(getAttrName()->getName(), Scope, Syntax);
+
+#include "clang/Sema/AttrSpellingListIndex.inc"
+}
Modified: cfe/trunk/lib/Sema/ParsedAttr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/ParsedAttr.cpp?rev=371985&r1=371984&r2=371985&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/ParsedAttr.cpp (original)
+++ cfe/trunk/lib/Sema/ParsedAttr.cpp Mon Sep 16 06:58:59 2019
@@ -100,76 +100,6 @@ void AttributePool::takePool(AttributePo
pool.Attrs.clear();
}
-#include "clang/Sema/AttrParsedAttrKinds.inc"
-
-static StringRef normalizeAttrScopeName(StringRef ScopeName,
- ParsedAttr::Syntax SyntaxUsed) {
- // Normalize the "__gnu__" scope name to be "gnu" and the "_Clang" scope name
- // to be "clang".
- if (SyntaxUsed == ParsedAttr::AS_CXX11 ||
- SyntaxUsed == ParsedAttr::AS_C2x) {
- if (ScopeName == "__gnu__")
- ScopeName = "gnu";
- else if (ScopeName == "_Clang")
- ScopeName = "clang";
- }
- return ScopeName;
-}
-
-static StringRef normalizeAttrName(StringRef AttrName,
- StringRef NormalizedScopeName,
- 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 ShouldNormalize =
- SyntaxUsed == ParsedAttr::AS_GNU ||
- ((SyntaxUsed == ParsedAttr::AS_CXX11 ||
- SyntaxUsed == ParsedAttr::AS_C2x) &&
- (NormalizedScopeName.empty() || NormalizedScopeName == "gnu" ||
- NormalizedScopeName == "clang"));
- if (ShouldNormalize && AttrName.size() >= 4 && AttrName.startswith("__") &&
- AttrName.endswith("__"))
- AttrName = AttrName.slice(2, AttrName.size() - 2);
-
- return AttrName;
-}
-
-bool AttributeCommonInfo::isGNUScope() const {
- return ScopeName && (ScopeName->isStr("gnu") || ScopeName->isStr("__gnu__"));
-}
-AttributeCommonInfo::Kind
-AttributeCommonInfo::getParsedKind(const IdentifierInfo *Name,
- const IdentifierInfo *ScopeName,
- Syntax SyntaxUsed) {
- StringRef AttrName = Name->getName();
-
- SmallString<64> FullName;
- if (ScopeName)
- FullName += normalizeAttrScopeName(ScopeName->getName(), SyntaxUsed);
-
- AttrName = normalizeAttrName(AttrName, FullName, SyntaxUsed);
-
- // Ensure that in the case of C++11 attributes, we look for '::foo' if it is
- // unscoped.
- if (ScopeName || SyntaxUsed == AS_CXX11 || SyntaxUsed == AS_C2x)
- FullName += "::";
- FullName += AttrName;
-
- return ::getAttrKind(FullName, SyntaxUsed);
-}
-
-unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const {
- // Both variables will be used in tablegen generated
- // attribute spell list index matching code.
- auto Syntax = static_cast<ParsedAttr::Syntax>(getSyntax());
- StringRef Scope =
- getScopeName() ? normalizeAttrScopeName(getScopeName()->getName(), Syntax)
- : "";
- StringRef Name = normalizeAttrName(getAttrName()->getName(), Scope, Syntax);
-
-#include "clang/Sema/AttrSpellingListIndex.inc"
-}
-
struct ParsedAttrInfo {
unsigned NumArgs : 4;
unsigned OptArgs : 4;
Modified: cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp?rev=371985&r1=371984&r2=371985&view=diff
==============================================================================
--- cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp Mon Sep 16 06:58:59 2019
@@ -3725,10 +3725,10 @@ void EmitClangAttrParsedAttrKinds(Record
// specific attribute, or MSP430-specific attribute. Additionally, an
// attribute can be spelled GNU<"dllexport"> and Declspec<"dllexport">
// for the same semantic attribute. Ultimately, we need to map each of
- // these to a single ParsedAttr::Kind value, but the StringMatcher
- // class cannot handle duplicate match strings. So we generate a list of
- // string to match based on the syntax, and emit multiple string matchers
- // depending on the syntax used.
+ // these to a single AttributeCommonInfo::Kind value, but the
+ // StringMatcher class cannot handle duplicate match strings. So we
+ // generate a list of string to match based on the syntax, and emit
+ // multiple string matchers depending on the syntax used.
std::string AttrName;
if (Attr.isSubClassOf("TargetSpecificAttr") &&
!Attr.isValueUnset("ParseKind")) {
@@ -3773,33 +3773,33 @@ void EmitClangAttrParsedAttrKinds(Record
if (SemaHandler)
Matches->push_back(StringMatcher::StringPair(
- Spelling, "return ParsedAttr::AT_" + AttrName + ";"));
+ Spelling, "return AttributeCommonInfo::AT_" + AttrName + ";"));
else
Matches->push_back(StringMatcher::StringPair(
- Spelling, "return ParsedAttr::IgnoredAttribute;"));
+ Spelling, "return AttributeCommonInfo::IgnoredAttribute;"));
}
}
}
- OS << "static ParsedAttr::Kind getAttrKind(StringRef Name, ";
- OS << "ParsedAttr::Syntax Syntax) {\n";
- OS << " if (ParsedAttr::AS_GNU == Syntax) {\n";
+ OS << "static AttributeCommonInfo::Kind getAttrKind(StringRef Name, ";
+ OS << "AttributeCommonInfo::Syntax Syntax) {\n";
+ OS << " if (AttributeCommonInfo::AS_GNU == Syntax) {\n";
StringMatcher("Name", GNU, OS).Emit();
- OS << " } else if (ParsedAttr::AS_Declspec == Syntax) {\n";
+ OS << " } else if (AttributeCommonInfo::AS_Declspec == Syntax) {\n";
StringMatcher("Name", Declspec, OS).Emit();
- OS << " } else if (ParsedAttr::AS_Microsoft == Syntax) {\n";
+ OS << " } else if (AttributeCommonInfo::AS_Microsoft == Syntax) {\n";
StringMatcher("Name", Microsoft, OS).Emit();
- OS << " } else if (ParsedAttr::AS_CXX11 == Syntax) {\n";
+ OS << " } else if (AttributeCommonInfo::AS_CXX11 == Syntax) {\n";
StringMatcher("Name", CXX11, OS).Emit();
- OS << " } else if (ParsedAttr::AS_C2x == Syntax) {\n";
+ OS << " } else if (AttributeCommonInfo::AS_C2x == Syntax) {\n";
StringMatcher("Name", C2x, OS).Emit();
- OS << " } else if (ParsedAttr::AS_Keyword == Syntax || ";
- OS << "ParsedAttr::AS_ContextSensitiveKeyword == Syntax) {\n";
+ OS << " } else if (AttributeCommonInfo::AS_Keyword == Syntax || ";
+ OS << "AttributeCommonInfo::AS_ContextSensitiveKeyword == Syntax) {\n";
StringMatcher("Name", Keywords, OS).Emit();
- OS << " } else if (ParsedAttr::AS_Pragma == Syntax) {\n";
+ OS << " } else if (AttributeCommonInfo::AS_Pragma == Syntax) {\n";
StringMatcher("Name", Pragma, OS).Emit();
OS << " }\n";
- OS << " return ParsedAttr::UnknownAttribute;\n"
+ OS << " return AttributeCommonInfo::UnknownAttribute;\n"
<< "}\n";
}
More information about the cfe-commits
mailing list