-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[Clang] Improve EmitClangAttrSpellingListIndex #114899
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 3 commits
cf4d70c
2970041
95b7569
87ac151
6f7c76d
8e0ab3c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,6 +17,8 @@ | |
| #include "clang/Basic/ParsedAttrInfo.h" | ||
| #include "clang/Basic/TargetInfo.h" | ||
|
|
||
| #include "llvm/ADT/StringMap.h" | ||
|
|
||
| using namespace clang; | ||
|
|
||
| static int hasAttributeImpl(AttributeCommonInfo::Syntax Syntax, StringRef Name, | ||
|
|
@@ -153,12 +155,35 @@ std::string AttributeCommonInfo::getNormalizedFullName() const { | |
| normalizeName(getAttrName(), getScopeName(), getSyntax())); | ||
| } | ||
|
|
||
| const llvm::StringMap<AttributeCommonInfo::Scope> ScopeMap = { | ||
| {"", AttributeCommonInfo::Scope::NONE}, | ||
| {"clang", AttributeCommonInfo::Scope::CLANG}, | ||
| {"gnu", AttributeCommonInfo::Scope::GNU}, | ||
| {"msvc", AttributeCommonInfo::Scope::MSVC}, | ||
| {"omp", AttributeCommonInfo::Scope::OMP}, | ||
| {"hlsl", AttributeCommonInfo::Scope::HLSL}, | ||
| {"gsl", AttributeCommonInfo::Scope::GSL}, | ||
| {"riscv", AttributeCommonInfo::Scope::RISCV}}; | ||
|
|
||
| AttributeCommonInfo::Scope | ||
| getScopeFromNormalizedScopeName(StringRef ScopeName) { | ||
| auto It = ScopeMap.find(ScopeName); | ||
| if (It == ScopeMap.end()) { | ||
chinmaydd marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| llvm_unreachable("Unknown normalized scope name. Shouldn't get here"); | ||
| } | ||
|
|
||
| return It->second; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This looks like exactly what
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ooof, yeah, you're right. This should jsut be a
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Interesting, I had no idea about |
||
| } | ||
|
|
||
| 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 = normalizeAttrScopeName(getScopeName(), Syntax); | ||
| StringRef Name = normalizeAttrName(getAttrName(), Scope, Syntax); | ||
| StringRef ScopeName = normalizeAttrScopeName(getScopeName(), Syntax); | ||
| StringRef Name = normalizeAttrName(getAttrName(), ScopeName, Syntax); | ||
|
|
||
| AttributeCommonInfo::Scope ComputedScope = | ||
| getScopeFromNormalizedScopeName(ScopeName); | ||
|
|
||
| #include "clang/Sema/AttrSpellingListIndex.inc" | ||
| } | ||
Uh oh!
There was an error while loading. Please reload this page.