diff --git a/clang/lib/Basic/Attributes.cpp b/clang/lib/Basic/Attributes.cpp index 867d241a2cf84..bb4faa675ea9f 100644 --- a/clang/lib/Basic/Attributes.cpp +++ b/clang/lib/Basic/Attributes.cpp @@ -157,8 +157,10 @@ unsigned AttributeCommonInfo::calculateAttributeSpellingListIndex() const { // Both variables will be used in tablegen generated // attribute spell list index matching code. auto Syntax = static_cast(getSyntax()); - StringRef Scope = normalizeAttrScopeName(getScopeName(), Syntax); - StringRef Name = normalizeAttrName(getAttrName(), Scope, Syntax); + // We use std::string instead of StringRef to prevent local stack + // allocation of literal strings for comparison. + const std::string Scope(normalizeAttrScopeName(getScopeName(), Syntax)); + const std::string Name(normalizeAttrName(getAttrName(), Scope, Syntax)); #include "clang/Sema/AttrSpellingListIndex.inc" }