diff --git a/clang/include/clang/Basic/ParsedAttrInfo.h b/clang/include/clang/Basic/ParsedAttrInfo.h --- a/clang/include/clang/Basic/ParsedAttrInfo.h +++ b/clang/include/clang/Basic/ParsedAttrInfo.h @@ -20,6 +20,7 @@ #include "llvm/ADT/ArrayRef.h" #include "llvm/Support/Registry.h" #include +#include namespace clang { @@ -137,6 +138,8 @@ typedef llvm::Registry ParsedAttrInfoRegistry; +const std::list> &getAttributePluginInstances(); + } // namespace clang #endif // LLVM_CLANG_BASIC_PARSEDATTRINFO_H diff --git a/clang/lib/Basic/ParsedAttrInfo.cpp b/clang/lib/Basic/ParsedAttrInfo.cpp --- a/clang/lib/Basic/ParsedAttrInfo.cpp +++ b/clang/lib/Basic/ParsedAttrInfo.cpp @@ -12,7 +12,21 @@ //===----------------------------------------------------------------------===// #include "clang/Basic/ParsedAttrInfo.h" +#include "llvm/Support/ManagedStatic.h" +#include +#include using namespace clang; LLVM_INSTANTIATE_REGISTRY(ParsedAttrInfoRegistry) + +const std::list> & +clang::getAttributePluginInstances() { + static llvm::ManagedStatic>> + PluginAttrInstances; + if (PluginAttrInstances->empty()) + for (auto It : ParsedAttrInfoRegistry::entries()) + PluginAttrInstances->emplace_back(It.instantiate()); + + return *PluginAttrInstances; +} diff --git a/clang/lib/Sema/ParsedAttr.cpp b/clang/lib/Sema/ParsedAttr.cpp --- a/clang/lib/Sema/ParsedAttr.cpp +++ b/clang/lib/Sema/ParsedAttr.cpp @@ -19,7 +19,6 @@ #include "llvm/ADT/SmallString.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" -#include "llvm/Support/ManagedStatic.h" #include #include #include @@ -118,13 +117,7 @@ if (A.getParsedKind() == AttributeCommonInfo::IgnoredAttribute) return IgnoredParsedAttrInfo; - // Otherwise this may be an attribute defined by a plugin. First instantiate - // all plugin attributes if we haven't already done so. - static llvm::ManagedStatic>> - PluginAttrInstances; - if (PluginAttrInstances->empty()) - for (auto It : ParsedAttrInfoRegistry::entries()) - PluginAttrInstances->emplace_back(It.instantiate()); + // Otherwise this may be an attribute defined by a plugin. // Search for a ParsedAttrInfo whose name and syntax match. std::string FullName = A.getNormalizedFullName(); @@ -132,7 +125,7 @@ if (SyntaxUsed == AttributeCommonInfo::AS_ContextSensitiveKeyword) SyntaxUsed = AttributeCommonInfo::AS_Keyword; - for (auto &Ptr : *PluginAttrInstances) + for (auto &Ptr : getAttributePluginInstances()) for (auto &S : Ptr->Spellings) if (S.Syntax == SyntaxUsed && S.NormalizedFullName == FullName) return *Ptr;