[clang] [Clang][TableGen] Use StringRef in FlattenedSpelling (PR #113809)
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Mon Oct 28 11:15:14 PDT 2024
================
@@ -49,40 +49,38 @@ using namespace llvm;
namespace {
class FlattenedSpelling {
- std::string V, N, NS;
+ StringRef V, N, NS;
bool K = false;
const Record &OriginalSpelling;
public:
- FlattenedSpelling(const std::string &Variety, const std::string &Name,
- const std::string &Namespace, bool KnownToGCC,
- const Record &OriginalSpelling)
+ FlattenedSpelling(StringRef Variety, StringRef Name, StringRef Namespace,
+ bool KnownToGCC, const Record &OriginalSpelling)
: V(Variety), N(Name), NS(Namespace), K(KnownToGCC),
OriginalSpelling(OriginalSpelling) {}
explicit FlattenedSpelling(const Record &Spelling)
- : V(std::string(Spelling.getValueAsString("Variety"))),
- N(std::string(Spelling.getValueAsString("Name"))),
- OriginalSpelling(Spelling) {
+ : V(Spelling.getValueAsString("Variety")),
+ N(Spelling.getValueAsString("Name")), OriginalSpelling(Spelling) {
assert(V != "GCC" && V != "Clang" &&
"Given a GCC spelling, which means this hasn't been flattened!");
if (V == "CXX11" || V == "C23" || V == "Pragma")
- NS = std::string(Spelling.getValueAsString("Namespace"));
+ NS = Spelling.getValueAsString("Namespace");
}
- const std::string &variety() const { return V; }
- const std::string &name() const { return N; }
- const std::string &nameSpace() const { return NS; }
+ StringRef variety() const { return V; }
+ StringRef name() const { return N; }
+ StringRef nameSpace() const { return NS; }
bool knownToGCC() const { return K; }
const Record &getSpellingRecord() const { return OriginalSpelling; }
};
struct FlattenedSpellingInfo {
- FlattenedSpellingInfo(std::string Syntax, std::string Scope,
- std::string TargetTest, uint32_t ArgMask)
+ FlattenedSpellingInfo(StringRef Syntax, StringRef Scope,
+ const std::string &TargetTest, uint32_t ArgMask)
: Syntax(Syntax), Scope(Scope), TargetTest(TargetTest), ArgMask(ArgMask) {
}
- std::string Syntax;
- std::string Scope;
+ StringRef Syntax;
+ StringRef Scope;
----------------
AaronBallman wrote:
Same concern here as above.
https://github.com/llvm/llvm-project/pull/113809
More information about the cfe-commits
mailing list