From b9826408e4f6634b3777f08b44fc69610cb22583 Mon Sep 17 00:00:00 2001 From: Siva Chandra Reddy Date: Wed, 29 Jan 2020 13:29:52 -0800 Subject: [PATCH] [libc] Fix build after 777180a32b61070a10dd330b4f038bf24e916af1. Implicit conversion from llvm::StringRef to std::string was made explicit in the above commit. --- libc/utils/HdrGen/Generator.cpp | 2 +- libc/utils/HdrGen/Main.cpp | 2 +- libc/utils/HdrGen/PublicAPICommand.cpp | 18 ++++++++++-------- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/libc/utils/HdrGen/Generator.cpp b/libc/utils/HdrGen/Generator.cpp index 996f3bf26990..7ad93e9f3752 100644 --- a/libc/utils/HdrGen/Generator.cpp +++ b/libc/utils/HdrGen/Generator.cpp @@ -58,7 +58,7 @@ void Generator::parseCommandArgs(llvm::StringRef ArgStr, ArgVector &Args) { A = A.trim(' '); if (A.startswith(ParamNamePrefix) && A.endswith(ParamNameSuffix)) { A = A.drop_front(ParamNamePrefixSize).drop_back(ParamNameSuffixSize); - A = ArgMap[A]; + A = ArgMap[std::string(A)]; } } } diff --git a/libc/utils/HdrGen/Main.cpp b/libc/utils/HdrGen/Main.cpp index 13ff5baa0e97..779705c1930b 100644 --- a/libc/utils/HdrGen/Main.cpp +++ b/libc/utils/HdrGen/Main.cpp @@ -31,7 +31,7 @@ llvm::cl::list ReplacementValues( void ParseArgValuePairs(std::unordered_map &Map) { for (std::string &R : ReplacementValues) { auto Pair = llvm::StringRef(R).split('='); - Map[Pair.first] = Pair.second; + Map[std::string(Pair.first)] = std::string(Pair.second); } } diff --git a/libc/utils/HdrGen/PublicAPICommand.cpp b/libc/utils/HdrGen/PublicAPICommand.cpp index 95b58b1daa01..c07283814550 100644 --- a/libc/utils/HdrGen/PublicAPICommand.cpp +++ b/libc/utils/HdrGen/PublicAPICommand.cpp @@ -102,7 +102,7 @@ class APIGenerator { std::string getTypeAsString(llvm::Record *TypeRecord) { if (isaNamedType(TypeRecord) || isaStructType(TypeRecord)) { - return TypeRecord->getValueAsString("Name"); + return std::string(TypeRecord->getValueAsString("Name")); } else if (isaPtrType(TypeRecord)) { return getTypeAsString(TypeRecord->getValueAsDef("PointeeType")) + " *"; } else if (isaConstType(TypeRecord)) { @@ -123,15 +123,17 @@ class APIGenerator { auto MacroSpecList = HeaderSpec->getValueAsListOfDefs("Macros"); // TODO: Trigger a fatal error on duplicate specs. for (llvm::Record *MacroSpec : MacroSpecList) - MacroSpecMap[MacroSpec->getValueAsString("Name")] = MacroSpec; + MacroSpecMap[std::string(MacroSpec->getValueAsString("Name"))] = + MacroSpec; auto TypeSpecList = HeaderSpec->getValueAsListOfDefs("Types"); for (llvm::Record *TypeSpec : TypeSpecList) - TypeSpecMap[TypeSpec->getValueAsString("Name")] = TypeSpec; + TypeSpecMap[std::string(TypeSpec->getValueAsString("Name"))] = + TypeSpec; auto FunctionSpecList = HeaderSpec->getValueAsListOfDefs("Functions"); for (llvm::Record *FunctionSpec : FunctionSpecList) { - FunctionSpecMap[FunctionSpec->getValueAsString("Name")] = + FunctionSpecMap[std::string(FunctionSpec->getValueAsString("Name"))] = FunctionSpec; } } @@ -144,19 +146,19 @@ class APIGenerator { // generating the API. auto MacroDefList = PublicAPI->getValueAsListOfDefs("Macros"); for (llvm::Record *MacroDef : MacroDefList) - MacroDefsMap[MacroDef->getValueAsString("Name")] = MacroDef; + MacroDefsMap[std::string(MacroDef->getValueAsString("Name"))] = MacroDef; auto TypeDeclList = PublicAPI->getValueAsListOfDefs("TypeDeclarations"); for (llvm::Record *TypeDecl : TypeDeclList) - TypeDeclsMap[TypeDecl->getValueAsString("Name")] = TypeDecl; + TypeDeclsMap[std::string(TypeDecl->getValueAsString("Name"))] = TypeDecl; auto StructList = PublicAPI->getValueAsListOfStrings("Structs"); for (llvm::StringRef StructName : StructList) - Structs.insert(StructName); + Structs.insert(std::string(StructName)); auto FunctionList = PublicAPI->getValueAsListOfStrings("Functions"); for (llvm::StringRef FunctionName : FunctionList) - Functions.insert(FunctionName); + Functions.insert(std::string(FunctionName)); } void index(llvm::RecordKeeper &Records) {