diff options
author | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-12-30 18:45:03 +0000 |
---|---|---|
committer | Saleem Abdulrasool <compnerd@compnerd.org> | 2016-12-30 18:45:03 +0000 |
commit | 20dfba0d707ed664d63334854be03257edc814fc (patch) | |
tree | 98f1d4fe40a6130a3ddbf9f4082c5848f98f47ce /clang/lib/CodeGen/BackendUtil.cpp | |
parent | 90705006331bcd97f7c14efd10f035dd270744f4 (diff) | |
download | bcm5719-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.cpp | 23 |
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) { |