#include "llvm/ADT/SmallString.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ManagedStatic.h"
#include <cassert>
#include <cstddef>
#include <utility>
// Otherwise this may be an attribute defined by a plugin. First instantiate
// all plugin attributes if we haven't already done so.
- static std::list<std::unique_ptr<ParsedAttrInfo>> PluginAttrInstances;
- if (PluginAttrInstances.empty())
+ static llvm::ManagedStatic<std::list<std::unique_ptr<ParsedAttrInfo>>>
+ PluginAttrInstances;
+ if (PluginAttrInstances->empty())
for (auto It : ParsedAttrInfoRegistry::entries())
- PluginAttrInstances.emplace_back(It.instantiate());
+ PluginAttrInstances->emplace_back(It.instantiate());
// Search for a ParsedAttrInfo whose name and syntax match.
std::string FullName = A.getNormalizedFullName();
if (SyntaxUsed == AttributeCommonInfo::AS_ContextSensitiveKeyword)
SyntaxUsed = AttributeCommonInfo::AS_Keyword;
- for (auto &Ptr : PluginAttrInstances)
+ for (auto &Ptr : *PluginAttrInstances)
for (auto &S : Ptr->Spellings)
if (S.Syntax == SyntaxUsed && S.NormalizedFullName == FullName)
return *Ptr;