diff --git a/clang/lib/Basic/Module.cpp b/clang/lib/Basic/Module.cpp index 541431dbbe7d9..92835c9aca7d6 100644 --- a/clang/lib/Basic/Module.cpp +++ b/clang/lib/Basic/Module.cpp @@ -276,7 +276,7 @@ bool Module::directlyUses(const Module *Requested) const { void Module::addRequirement(StringRef Feature, bool RequiredState, const LangOptions &LangOpts, const TargetInfo &Target) { - Requirements.push_back(Requirement(Feature, RequiredState)); + Requirements.push_back(Requirement(std::string(Feature), RequiredState)); // If this feature is currently available, we're done. if (hasFeature(Feature, LangOpts, Target) == RequiredState) diff --git a/clang/lib/Frontend/CompilerInvocation.cpp b/clang/lib/Frontend/CompilerInvocation.cpp index 14cbf39cee458..a8dfd8a97c8c3 100644 --- a/clang/lib/Frontend/CompilerInvocation.cpp +++ b/clang/lib/Frontend/CompilerInvocation.cpp @@ -340,7 +340,8 @@ static bool ParseAnalyzerArgs(AnalyzerOptions &Opts, ArgList &Args, SmallVector CheckersAndPackages; CheckerAndPackageList.split(CheckersAndPackages, ","); for (const StringRef &CheckerOrPackage : CheckersAndPackages) - Opts.CheckersAndPackages.emplace_back(CheckerOrPackage, IsEnabled); + Opts.CheckersAndPackages.emplace_back(std::string(CheckerOrPackage), + IsEnabled); } // Go through the analyzer configuration options. diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp index b4605bae4ed9d..ad942d1e45e72 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter1/toy.cpp @@ -727,7 +727,7 @@ Function *getFunction(std::string Name) { /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, - const std::string &VarName) { + StringRef VarName) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::getDoubleTy(*TheContext), nullptr, VarName); @@ -1076,7 +1076,7 @@ Function *FunctionAST::codegen() { Builder->CreateStore(&Arg, Alloca); // Add arguments to variable symbol table. - NamedValues[Arg.getName()] = Alloca; + NamedValues[std::string(Arg.getName())] = Alloca; } if (Value *RetVal = Body->codegen()) { diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp index 743d50829dc3b..136ae9636c56e 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter2/toy.cpp @@ -727,7 +727,7 @@ Function *getFunction(std::string Name) { /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, - const std::string &VarName) { + StringRef VarName) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::getDoubleTy(*TheContext), nullptr, VarName); @@ -1076,7 +1076,7 @@ Function *FunctionAST::codegen() { Builder->CreateStore(&Arg, Alloca); // Add arguments to variable symbol table. - NamedValues[Arg.getName()] = Alloca; + NamedValues[std::string(Arg.getName())] = Alloca; } if (Value *RetVal = Body->codegen()) { diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h index add38fdb81938..34c4b96835726 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/KaleidoscopeJIT.h @@ -100,13 +100,13 @@ class KaleidoscopeJIT { // Build a resolver and associate it with the new key. Resolvers[K] = createLegacyLookupResolver( ES, - [this](const std::string &Name) -> JITSymbol { - if (auto Sym = CompileLayer.findSymbol(Name, false)) + [this](StringRef Name) -> JITSymbol { + if (auto Sym = CompileLayer.findSymbol(std::string(Name), false)) return Sym; else if (auto Err = Sym.takeError()) return std::move(Err); - if (auto SymAddr = - RTDyldMemoryManager::getSymbolAddressInProcess(Name)) + if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess( + std::string(Name))) return JITSymbol(SymAddr, JITSymbolFlags::Exported); return nullptr; }, diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp index e9505033106e7..d082e510e291e 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter3/toy.cpp @@ -726,7 +726,7 @@ Function *getFunction(std::string Name) { /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, - const std::string &VarName) { + StringRef VarName) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName); @@ -1075,7 +1075,7 @@ Function *FunctionAST::codegen() { Builder.CreateStore(&Arg, Alloca); // Add arguments to variable symbol table. - NamedValues[Arg.getName()] = Alloca; + NamedValues[std::string(Arg.getName())] = Alloca; } if (Value *RetVal = Body->codegen()) { diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h index dd6304b7a78c8..c87565737f2de 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/KaleidoscopeJIT.h @@ -91,15 +91,15 @@ class KaleidoscopeJIT { KaleidoscopeJIT() : Resolver(createLegacyLookupResolver( ES, - [this](const std::string &Name) -> JITSymbol { + [this](StringRef Name) -> JITSymbol { if (auto Sym = IndirectStubsMgr->findStub(Name, false)) return Sym; - if (auto Sym = OptimizeLayer.findSymbol(Name, false)) + if (auto Sym = OptimizeLayer.findSymbol(std::string(Name), false)) return Sym; else if (auto Err = Sym.takeError()) return std::move(Err); - if (auto SymAddr = - RTDyldMemoryManager::getSymbolAddressInProcess(Name)) + if (auto SymAddr = RTDyldMemoryManager::getSymbolAddressInProcess( + std::string(Name))) return JITSymbol(SymAddr, JITSymbolFlags::Exported); return nullptr; }, diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp index bfd57e621cdaa..e39e8a94d0377 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter4/toy.cpp @@ -712,7 +712,7 @@ Function *getFunction(std::string Name) { /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, - const std::string &VarName) { + StringRef VarName) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName); @@ -1068,7 +1068,7 @@ Function *FunctionAST::codegen() { Builder.CreateStore(&Arg, Alloca); // Add arguments to variable symbol table. - NamedValues[Arg.getName()] = Alloca; + NamedValues[std::string(Arg.getName())] = Alloca; } if (Value *RetVal = Body->codegen()) { diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h index 1d9c98a9d72ad..d22f893ac6113 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/KaleidoscopeJIT.h @@ -98,10 +98,10 @@ class KaleidoscopeJIT { : ES(ES), Resolver(createLegacyLookupResolver( ES, - [this](const std::string &Name) -> JITSymbol { + [this](StringRef Name) -> JITSymbol { if (auto Sym = IndirectStubsMgr->findStub(Name, false)) return Sym; - if (auto Sym = OptimizeLayer.findSymbol(Name, false)) + if (auto Sym = OptimizeLayer.findSymbol(std::string(Name), false)) return Sym; else if (auto Err = Sym.takeError()) return std::move(Err); diff --git a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp index eff61fb954df4..b9819327f8430 100644 --- a/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp +++ b/llvm/examples/Kaleidoscope/BuildingAJIT/Chapter5/toy.cpp @@ -736,7 +736,7 @@ Function *getFunction(std::string Name) { /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, - const std::string &VarName) { + StringRef VarName) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName); @@ -1092,7 +1092,7 @@ Function *FunctionAST::codegen() { Builder.CreateStore(&Arg, Alloca); // Add arguments to variable symbol table. - NamedValues[Arg.getName()] = Alloca; + NamedValues[std::string(Arg.getName())] = Alloca; } if (Value *RetVal = Body->codegen()) { diff --git a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp index 2da3b602b62f3..92903741f2106 100644 --- a/llvm/examples/Kaleidoscope/Chapter8/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter8/toy.cpp @@ -731,7 +731,7 @@ Function *getFunction(std::string Name) { /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, - const std::string &VarName) { + StringRef VarName) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName); @@ -1080,7 +1080,7 @@ Function *FunctionAST::codegen() { Builder.CreateStore(&Arg, Alloca); // Add arguments to variable symbol table. - NamedValues[Arg.getName()] = Alloca; + NamedValues[std::string(Arg.getName())] = Alloca; } if (Value *RetVal = Body->codegen()) { diff --git a/llvm/examples/Kaleidoscope/Chapter9/toy.cpp b/llvm/examples/Kaleidoscope/Chapter9/toy.cpp index 21c8993e1a064..23b25b15c9b87 100644 --- a/llvm/examples/Kaleidoscope/Chapter9/toy.cpp +++ b/llvm/examples/Kaleidoscope/Chapter9/toy.cpp @@ -884,11 +884,10 @@ Function *getFunction(std::string Name) { /// CreateEntryBlockAlloca - Create an alloca instruction in the entry block of /// the function. This is used for mutable variables etc. static AllocaInst *CreateEntryBlockAlloca(Function *TheFunction, - const std::string &VarName) { + StringRef VarName) { IRBuilder<> TmpB(&TheFunction->getEntryBlock(), TheFunction->getEntryBlock().begin()); - return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, - VarName.c_str()); + return TmpB.CreateAlloca(Type::getDoubleTy(TheContext), nullptr, VarName); } Value *NumberExprAST::codegen() { @@ -1277,7 +1276,7 @@ Function *FunctionAST::codegen() { Builder.CreateStore(&Arg, Alloca); // Add arguments to variable symbol table. - NamedValues[Arg.getName()] = Alloca; + NamedValues[std::string(Arg.getName())] = Alloca; } KSDbgInfo.emitLocation(Body.get()); diff --git a/mlir/examples/toy/Ch2/include/toy/Parser.h b/mlir/examples/toy/Ch2/include/toy/Parser.h index bbab7f57f1408..e1634fca9d74f 100644 --- a/mlir/examples/toy/Ch2/include/toy/Parser.h +++ b/mlir/examples/toy/Ch2/include/toy/Parser.h @@ -171,7 +171,7 @@ class Parser { /// ::= identifier /// ::= identifier '(' expression ')' std::unique_ptr parseIdentifierExpr() { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.getNextToken(); // eat identifier. @@ -321,7 +321,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("identified", "after 'var' declaration"); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.getNextToken(); // eat id std::unique_ptr type; // Type is optional, it can be inferred @@ -400,7 +400,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("function name", "in prototype"); - std::string fnName = lexer.getId(); + std::string fnName(lexer.getId()); lexer.consume(tok_identifier); if (lexer.getCurToken() != '(') @@ -410,7 +410,7 @@ class Parser { std::vector> args; if (lexer.getCurToken() != ')') { do { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); auto decl = std::make_unique(std::move(loc), name); diff --git a/mlir/examples/toy/Ch3/include/toy/Parser.h b/mlir/examples/toy/Ch3/include/toy/Parser.h index bbab7f57f1408..e1634fca9d74f 100644 --- a/mlir/examples/toy/Ch3/include/toy/Parser.h +++ b/mlir/examples/toy/Ch3/include/toy/Parser.h @@ -171,7 +171,7 @@ class Parser { /// ::= identifier /// ::= identifier '(' expression ')' std::unique_ptr parseIdentifierExpr() { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.getNextToken(); // eat identifier. @@ -321,7 +321,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("identified", "after 'var' declaration"); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.getNextToken(); // eat id std::unique_ptr type; // Type is optional, it can be inferred @@ -400,7 +400,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("function name", "in prototype"); - std::string fnName = lexer.getId(); + std::string fnName(lexer.getId()); lexer.consume(tok_identifier); if (lexer.getCurToken() != '(') @@ -410,7 +410,7 @@ class Parser { std::vector> args; if (lexer.getCurToken() != ')') { do { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); auto decl = std::make_unique(std::move(loc), name); diff --git a/mlir/examples/toy/Ch4/include/toy/Parser.h b/mlir/examples/toy/Ch4/include/toy/Parser.h index bbab7f57f1408..e1634fca9d74f 100644 --- a/mlir/examples/toy/Ch4/include/toy/Parser.h +++ b/mlir/examples/toy/Ch4/include/toy/Parser.h @@ -171,7 +171,7 @@ class Parser { /// ::= identifier /// ::= identifier '(' expression ')' std::unique_ptr parseIdentifierExpr() { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.getNextToken(); // eat identifier. @@ -321,7 +321,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("identified", "after 'var' declaration"); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.getNextToken(); // eat id std::unique_ptr type; // Type is optional, it can be inferred @@ -400,7 +400,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("function name", "in prototype"); - std::string fnName = lexer.getId(); + std::string fnName(lexer.getId()); lexer.consume(tok_identifier); if (lexer.getCurToken() != '(') @@ -410,7 +410,7 @@ class Parser { std::vector> args; if (lexer.getCurToken() != ')') { do { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); auto decl = std::make_unique(std::move(loc), name); diff --git a/mlir/examples/toy/Ch5/include/toy/Parser.h b/mlir/examples/toy/Ch5/include/toy/Parser.h index bbab7f57f1408..e1634fca9d74f 100644 --- a/mlir/examples/toy/Ch5/include/toy/Parser.h +++ b/mlir/examples/toy/Ch5/include/toy/Parser.h @@ -171,7 +171,7 @@ class Parser { /// ::= identifier /// ::= identifier '(' expression ')' std::unique_ptr parseIdentifierExpr() { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.getNextToken(); // eat identifier. @@ -321,7 +321,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("identified", "after 'var' declaration"); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.getNextToken(); // eat id std::unique_ptr type; // Type is optional, it can be inferred @@ -400,7 +400,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("function name", "in prototype"); - std::string fnName = lexer.getId(); + std::string fnName(lexer.getId()); lexer.consume(tok_identifier); if (lexer.getCurToken() != '(') @@ -410,7 +410,7 @@ class Parser { std::vector> args; if (lexer.getCurToken() != ')') { do { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); auto decl = std::make_unique(std::move(loc), name); diff --git a/mlir/examples/toy/Ch6/include/toy/Parser.h b/mlir/examples/toy/Ch6/include/toy/Parser.h index bbab7f57f1408..e1634fca9d74f 100644 --- a/mlir/examples/toy/Ch6/include/toy/Parser.h +++ b/mlir/examples/toy/Ch6/include/toy/Parser.h @@ -171,7 +171,7 @@ class Parser { /// ::= identifier /// ::= identifier '(' expression ')' std::unique_ptr parseIdentifierExpr() { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.getNextToken(); // eat identifier. @@ -321,7 +321,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("identified", "after 'var' declaration"); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.getNextToken(); // eat id std::unique_ptr type; // Type is optional, it can be inferred @@ -400,7 +400,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("function name", "in prototype"); - std::string fnName = lexer.getId(); + std::string fnName(lexer.getId()); lexer.consume(tok_identifier); if (lexer.getCurToken() != '(') @@ -410,7 +410,7 @@ class Parser { std::vector> args; if (lexer.getCurToken() != ')') { do { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); auto decl = std::make_unique(std::move(loc), name); diff --git a/mlir/examples/toy/Ch7/include/toy/Parser.h b/mlir/examples/toy/Ch7/include/toy/Parser.h index e8b080fc4171f..3d91281787659 100644 --- a/mlir/examples/toy/Ch7/include/toy/Parser.h +++ b/mlir/examples/toy/Ch7/include/toy/Parser.h @@ -257,14 +257,15 @@ class Parser { } // Call to a user-defined function - return std::make_unique(std::move(loc), name, std::move(args)); + return std::make_unique(std::move(loc), std::string(name), + std::move(args)); } /// identifierexpr /// ::= identifier /// ::= identifier '(' expression ')' std::unique_ptr parseIdentifierExpr() { - std::string name = lexer.getId(); + std::string name(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.getNextToken(); // eat identifier. @@ -378,7 +379,7 @@ class Parser { /// Parse either a variable declaration or a call expression. std::unique_ptr parseDeclarationOrCallExpr() { auto loc = lexer.getLastLocation(); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.consume(tok_identifier); // Check for a call expression. @@ -396,7 +397,7 @@ class Parser { // Parse the variable name. if (lexer.getCurToken() != tok_identifier) return parseError("name", "in variable declaration"); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.getNextToken(); // eat id // Parse the initializer. @@ -410,7 +411,7 @@ class Parser { } VarType type; - type.name = typeName; + type.name = std::string(typeName); return std::make_unique(loc, std::move(id), std::move(type), std::move(expr)); } @@ -428,7 +429,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("type name", "in variable declaration"); auto loc = lexer.getLastLocation(); - std::string typeName = lexer.getId(); + std::string typeName(lexer.getId()); lexer.getNextToken(); // eat id // Parse the rest of the declaration. @@ -449,7 +450,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("identified", "after 'var' declaration"); - std::string id = lexer.getId(); + std::string id(lexer.getId()); lexer.getNextToken(); // eat id std::unique_ptr type; // Type is optional, it can be inferred @@ -537,7 +538,7 @@ class Parser { if (lexer.getCurToken() != tok_identifier) return parseError("function name", "in prototype"); - std::string fnName = lexer.getId(); + std::string fnName(lexer.getId()); lexer.consume(tok_identifier); if (lexer.getCurToken() != '(') @@ -551,7 +552,7 @@ class Parser { std::string name; // Parse either the name of the variable, or its type. - std::string nameOrType = lexer.getId(); + std::string nameOrType(lexer.getId()); auto loc = lexer.getLastLocation(); lexer.consume(tok_identifier); @@ -560,7 +561,7 @@ class Parser { type.name = std::move(nameOrType); // Parse the name. - name = lexer.getId(); + name = std::string(lexer.getId()); lexer.consume(tok_identifier); } else { // Otherwise, we just parsed the name. @@ -610,7 +611,7 @@ class Parser { lexer.consume(tok_struct); if (lexer.getCurToken() != tok_identifier) return parseError("name", "in struct definition"); - std::string name = lexer.getId(); + std::string name(lexer.getId()); lexer.consume(tok_identifier); // Parse: '{'