diff options
author | Chandler Carruth <chandlerc@gmail.com> | 2015-08-30 07:51:18 +0000 |
---|---|---|
committer | Chandler Carruth <chandlerc@gmail.com> | 2015-08-30 07:51:18 +0000 |
commit | d96f37a77264faace54254166c23bf3d0ba8f98d (patch) | |
tree | baa6d62ece85a2526b7eed265569e8f6ce4aab14 /clang/lib/Driver | |
parent | 3309ef6f02854949f9d64d69f82504c362fe3fd1 (diff) | |
download | bcm5719-llvm-d96f37a77264faace54254166c23bf3d0ba8f98d.tar.gz bcm5719-llvm-d96f37a77264faace54254166c23bf3d0ba8f98d.zip |
Update for several APIs in LLVM that now use StringRefs rather than
const char pointers. In turn, push this through Clang APIs as well,
simplifying a number of bits of code that was handling the oddities of
nullptrs.
llvm-svn: 246375
Diffstat (limited to 'clang/lib/Driver')
-rw-r--r-- | clang/lib/Driver/ToolChain.cpp | 7 | ||||
-rw-r--r-- | clang/lib/Driver/Tools.cpp | 21 | ||||
-rw-r--r-- | clang/lib/Driver/Tools.h | 5 |
3 files changed, 15 insertions, 18 deletions
diff --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp index 787422a22fb..d4381e7e23f 100644 --- a/clang/lib/Driver/ToolChain.cpp +++ b/clang/lib/Driver/ToolChain.cpp @@ -310,9 +310,10 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList &Args, MCPU = A->getValue(); if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) MArch = A->getValue(); - std::string CPU = Triple.isOSBinFormatMachO() - ? tools::arm::getARMCPUForMArch(MArch, Triple) - : tools::arm::getARMTargetCPU(MCPU, MArch, Triple); + std::string CPU = + Triple.isOSBinFormatMachO() + ? tools::arm::getARMCPUForMArch(MArch, Triple).str() + : tools::arm::getARMTargetCPU(MCPU, MArch, Triple); StringRef Suffix = tools::arm::getLLVMArchSuffixForARM(CPU, tools::arm::getARMArch(MArch, Triple)); diff --git a/clang/lib/Driver/Tools.cpp b/clang/lib/Driver/Tools.cpp index e9df9500fb2..099cab11f8e 100644 --- a/clang/lib/Driver/Tools.cpp +++ b/clang/lib/Driver/Tools.cpp @@ -559,7 +559,7 @@ static void checkARMCPUName(const Driver &D, const Arg *A, const ArgList &Args, const llvm::Triple &Triple) { std::string CPU = arm::getARMTargetCPU(CPUName, ArchName, Triple); std::string Arch = arm::getARMArch(ArchName, Triple); - if (strcmp(arm::getLLVMArchSuffixForARM(CPU, Arch), "") == 0) + if (arm::getLLVMArchSuffixForARM(CPU, Arch).empty()) D.Diag(diag::err_drv_clang_unsupported) << A->getAsString(Args); } @@ -6018,33 +6018,30 @@ const std::string arm::getARMArch(StringRef Arch, const llvm::Triple &Triple) { std::string CPU = llvm::sys::getHostCPUName(); if (CPU != "generic") { // Translate the native cpu into the architecture suffix for that CPU. - const char *Suffix = arm::getLLVMArchSuffixForARM(CPU, MArch); + StringRef Suffix = arm::getLLVMArchSuffixForARM(CPU, MArch); // If there is no valid architecture suffix for this CPU we don't know how // to handle it, so return no architecture. - if (strcmp(Suffix, "") == 0) + if (Suffix.empty()) MArch = ""; else - MArch = std::string("arm") + Suffix; + MArch = std::string("arm") + Suffix.str(); } } return MArch; } + /// Get the (LLVM) name of the minimum ARM CPU for the arch we are targeting. -const char *arm::getARMCPUForMArch(StringRef Arch, const llvm::Triple &Triple) { +StringRef arm::getARMCPUForMArch(StringRef Arch, const llvm::Triple &Triple) { std::string MArch = getARMArch(Arch, Triple); // getARMCPUForArch defaults to the triple if MArch is empty, but empty MArch // here means an -march=native that we can't handle, so instead return no CPU. if (MArch.empty()) - return ""; + return StringRef(); // We need to return an empty string here on invalid MArch values as the // various places that call this function can't cope with a null result. - const char *result = Triple.getARMCPUForArch(MArch); - if (result) - return result; - else - return ""; + return Triple.getARMCPUForArch(MArch); } /// getARMTargetCPU - Get the (LLVM) name of the ARM cpu we are targeting. @@ -6067,7 +6064,7 @@ std::string arm::getARMTargetCPU(StringRef CPU, StringRef Arch, /// getLLVMArchSuffixForARM - Get the LLVM arch name to use for a particular /// CPU (or Arch, if CPU is generic). // FIXME: This is redundant with -mcpu, why does LLVM use this. -const char *arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch) { +StringRef arm::getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch) { if (CPU == "generic") return llvm::ARM::getSubArch( llvm::ARM::parseArch(Arch)); diff --git a/clang/lib/Driver/Tools.h b/clang/lib/Driver/Tools.h index 1b1086a5b32..010bac0b046 100644 --- a/clang/lib/Driver/Tools.h +++ b/clang/lib/Driver/Tools.h @@ -244,9 +244,8 @@ std::string getARMTargetCPU(StringRef CPU, StringRef Arch, const llvm::Triple &Triple); const std::string getARMArch(StringRef Arch, const llvm::Triple &Triple); -const char* getARMCPUForMArch(StringRef Arch, - const llvm::Triple &Triple); -const char* getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch); +StringRef getARMCPUForMArch(StringRef Arch, const llvm::Triple &Triple); +StringRef getLLVMArchSuffixForARM(StringRef CPU, StringRef Arch); void appendEBLinkFlags(const llvm::opt::ArgList &Args, ArgStringList &CmdArgs, const llvm::Triple &Triple); |