From d2eec01cea817337616d497bd1c2261db6dbd5ee Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 30 Jun 2015 18:01:05 +0000 Subject: [PATCH] Use an early exit to improve readability. (NFC) git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241088 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 66 ++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 34 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 8daf8af4e1..8c4b4b3d06 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -1665,44 +1665,42 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, llvm::DIModule * CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) { - llvm::DIModule *ModuleRef = nullptr; auto it = ModuleRefCache.find(Mod.Signature); if (it != ModuleRefCache.end()) - ModuleRef = it->second; - else { - // Macro definitions that were defined with "-D" on the command line. - SmallString<128> ConfigMacros; - { - llvm::raw_svector_ostream OS(ConfigMacros); - const auto &PPOpts = CGM.getPreprocessorOpts(); - unsigned I = 0; - // Translate the macro definitions back into a commmand line. - for (auto &M : PPOpts.Macros) { - if (++I > 1) - OS << " "; - const std::string &Macro = M.first; - bool Undef = M.second; - OS << "\"-" << (Undef ? 'U' : 'D'); - for (char c : Macro) - switch (c) { - case '\\' : OS << "\\\\"; break; - case '"' : OS << "\\\""; break; - default: OS << c; - } - OS << '\"'; - } + return it->second; + + // Macro definitions that were defined with "-D" on the command line. + SmallString<128> ConfigMacros; + { + llvm::raw_svector_ostream OS(ConfigMacros); + const auto &PPOpts = CGM.getPreprocessorOpts(); + unsigned I = 0; + // Translate the macro definitions back into a commmand line. + for (auto &M : PPOpts.Macros) { + if (++I > 1) + OS << " "; + const std::string &Macro = M.first; + bool Undef = M.second; + OS << "\"-" << (Undef ? 'U' : 'D'); + for (char c : Macro) + switch (c) { + case '\\' : OS << "\\\\"; break; + case '"' : OS << "\\\""; break; + default: OS << c; + } + OS << '\"'; } - llvm::DIBuilder DIB(CGM.getModule()); - auto *CU = DIB.createCompileUnit( - TheCU->getSourceLanguage(), internString(Mod.ModuleName), - internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0, - internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature); - ModuleRef = DIB.createModule( - CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path), - internString(CGM.getHeaderSearchOpts().Sysroot)); - DIB.finalize(); - ModuleRefCache.insert(std::make_pair(Mod.Signature, ModuleRef)); } + llvm::DIBuilder DIB(CGM.getModule()); + auto *CU = DIB.createCompileUnit( + TheCU->getSourceLanguage(), internString(Mod.ModuleName), + internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0, + internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature); + llvm::DIModule *ModuleRef = + DIB.createModule(CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path), + internString(CGM.getHeaderSearchOpts().Sysroot)); + DIB.finalize(); + ModuleRefCache.insert(std::make_pair(Mod.Signature, ModuleRef)); return ModuleRef; } -- 2.40.0