summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/BackendUtil.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2016-12-30 18:45:03 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2016-12-30 18:45:03 +0000
commit20dfba0d707ed664d63334854be03257edc814fc (patch)
tree98f1d4fe40a6130a3ddbf9f4082c5848f98f47ce /clang/lib/CodeGen/BackendUtil.cpp
parent90705006331bcd97f7c14efd10f035dd270744f4 (diff)
downloadbcm5719-llvm-20dfba0d707ed664d63334854be03257edc814fc.tar.gz
bcm5719-llvm-20dfba0d707ed664d63334854be03257edc814fc.zip
CodeGen: use a StringSwitch instead of cascasding ifs
Change the cascading ifs to a StringSwitch to simplify the conversion of the relocation model. NFC llvm-svn: 290762
Diffstat (limited to 'clang/lib/CodeGen/BackendUtil.cpp')
-rw-r--r--clang/lib/CodeGen/BackendUtil.cpp23
1 files changed, 8 insertions, 15 deletions
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 54f05ef75d0..164e52d7de2 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -504,21 +504,14 @@ void EmitAssemblyHelper::CreateTargetMachine(bool MustCreateTM) {
// Keep this synced with the equivalent code in tools/driver/cc1as_main.cpp.
llvm::Optional<llvm::Reloc::Model> RM;
- if (CodeGenOpts.RelocationModel == "static") {
- RM = llvm::Reloc::Static;
- } else if (CodeGenOpts.RelocationModel == "pic") {
- RM = llvm::Reloc::PIC_;
- } else if (CodeGenOpts.RelocationModel == "ropi") {
- RM = llvm::Reloc::ROPI;
- } else if (CodeGenOpts.RelocationModel == "rwpi") {
- RM = llvm::Reloc::RWPI;
- } else if (CodeGenOpts.RelocationModel == "ropi-rwpi") {
- RM = llvm::Reloc::ROPI_RWPI;
- } else {
- assert(CodeGenOpts.RelocationModel == "dynamic-no-pic" &&
- "Invalid PIC model!");
- RM = llvm::Reloc::DynamicNoPIC;
- }
+ RM = llvm::StringSwitch<llvm::Reloc::Model>(CodeGenOpts.RelocationModel)
+ .Case("static", llvm::Reloc::Static)
+ .Case("pic", llvm::Reloc::PIC_)
+ .Case("ropi", llvm::Reloc::ROPI)
+ .Case("rwpi", llvm::Reloc::RWPI)
+ .Case("ropi-rwpi", llvm::Reloc::ROPI_RWPI)
+ .Case("dynamic-no-pic", llvm::Reloc::DynamicNoPIC);
+ assert(RM.hasValue() && "invalid PIC model!");
CodeGenOpt::Level OptLevel = CodeGenOpt::Default;
switch (CodeGenOpts.OptimizationLevel) {
OpenPOWER on IntegriCloud