[llvm] r189962 - Rename variables to match the style guide and clang-format.

Rafael Espindola rafael.espindola at gmail.com
Wed Sep 4 10:44:24 PDT 2013


Author: rafael
Date: Wed Sep  4 12:44:24 2013
New Revision: 189962

URL: http://llvm.org/viewvc/llvm-project?rev=189962&view=rev
Log:
Rename variables to match the style guide and clang-format.

Modified:
    llvm/trunk/tools/lto/LTOCodeGenerator.cpp
    llvm/trunk/tools/lto/LTOCodeGenerator.h

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.cpp?rev=189962&r1=189961&r2=189962&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.cpp (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.cpp Wed Sep  4 12:44:24 2013
@@ -70,11 +70,9 @@ const char* LTOCodeGenerator::getVersion
 }
 
 LTOCodeGenerator::LTOCodeGenerator()
-  : _context(getGlobalContext()),
-    _linker(new Module("ld-temp.o", _context)), _target(NULL),
-    _emitDwarfDebugInfo(false), _scopeRestrictionsDone(false),
-    _codeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC),
-    _nativeObjectFile(NULL) {
+    : Context(getGlobalContext()), Linker(new Module("ld-temp.o", Context)),
+      TargetMach(NULL), EmitDwarfDebugInfo(false), ScopeRestrictionsDone(false),
+      CodeModel(LTO_CODEGEN_PIC_MODEL_DYNAMIC), NativeObjectFile(NULL) {
   InitializeAllTargets();
   InitializeAllTargetMCs();
   InitializeAllAsmPrinters();
@@ -82,12 +80,13 @@ LTOCodeGenerator::LTOCodeGenerator()
 }
 
 LTOCodeGenerator::~LTOCodeGenerator() {
-  delete _target;
-  delete _nativeObjectFile;
-  delete _linker.getModule();
-
-  for (std::vector<char*>::iterator I = _codegenOptions.begin(),
-         E = _codegenOptions.end(); I != E; ++I)
+  delete TargetMach;
+  delete NativeObjectFile;
+  delete Linker.getModule();
+
+  for (std::vector<char *>::iterator I = CodegenOptions.begin(),
+                                     E = CodegenOptions.end();
+       I != E; ++I)
     free(*I);
 }
 
@@ -122,11 +121,11 @@ void LTOCodeGenerator::initializeLTOPass
 }
 
 bool LTOCodeGenerator::addModule(LTOModule* mod, std::string& errMsg) {
-  bool ret = _linker.linkInModule(mod->getLLVVMModule(), &errMsg);
+  bool ret = Linker.linkInModule(mod->getLLVVMModule(), &errMsg);
 
   const std::vector<const char*> &undefs = mod->getAsmUndefinedRefs();
   for (int i = 0, e = undefs.size(); i != e; ++i)
-    _asmUndefinedRefs[undefs[i]] = 1;
+    AsmUndefinedRefs[undefs[i]] = 1;
 
   return !ret;
 }
@@ -134,11 +133,11 @@ bool LTOCodeGenerator::addModule(LTOModu
 void LTOCodeGenerator::setDebugInfo(lto_debug_model debug) {
   switch (debug) {
   case LTO_DEBUG_MODEL_NONE:
-    _emitDwarfDebugInfo = false;
+    EmitDwarfDebugInfo = false;
     return;
 
   case LTO_DEBUG_MODEL_DWARF:
-    _emitDwarfDebugInfo = true;
+    EmitDwarfDebugInfo = true;
     return;
   }
   llvm_unreachable("Unknown debug format!");
@@ -149,7 +148,7 @@ void LTOCodeGenerator::setCodePICModel(l
   case LTO_CODEGEN_PIC_MODEL_STATIC:
   case LTO_CODEGEN_PIC_MODEL_DYNAMIC:
   case LTO_CODEGEN_PIC_MODEL_DYNAMIC_NO_PIC:
-    _codeModel = model;
+    CodeModel = model;
     return;
   }
   llvm_unreachable("Unknown PIC model!");
@@ -173,7 +172,7 @@ bool LTOCodeGenerator::writeMergedModule
   }
 
   // write bitcode to it
-  WriteBitcodeToFile(_linker.getModule(), Out.os());
+  WriteBitcodeToFile(Linker.getModule(), Out.os());
   Out.os().close();
 
   if (Out.os().has_error()) {
@@ -214,8 +213,8 @@ bool LTOCodeGenerator::compile_to_file(c
     return false;
   }
 
-  _nativeObjectPath = Filename.c_str();
-  *name = _nativeObjectPath.c_str();
+  NativeObjectPath = Filename.c_str();
+  *name = NativeObjectPath.c_str();
   return true;
 }
 
@@ -225,37 +224,37 @@ const void* LTOCodeGenerator::compile(si
     return NULL;
 
   // remove old buffer if compile() called twice
-  delete _nativeObjectFile;
+  delete NativeObjectFile;
 
   // read .o file into memory buffer
   OwningPtr<MemoryBuffer> BuffPtr;
   if (error_code ec = MemoryBuffer::getFile(name, BuffPtr, -1, false)) {
     errMsg = ec.message();
-    sys::fs::remove(_nativeObjectPath);
+    sys::fs::remove(NativeObjectPath);
     return NULL;
   }
-  _nativeObjectFile = BuffPtr.take();
+  NativeObjectFile = BuffPtr.take();
 
   // remove temp files
-  sys::fs::remove(_nativeObjectPath);
+  sys::fs::remove(NativeObjectPath);
 
   // return buffer, unless error
-  if (_nativeObjectFile == NULL)
+  if (NativeObjectFile == NULL)
     return NULL;
-  *length = _nativeObjectFile->getBufferSize();
-  return _nativeObjectFile->getBufferStart();
+  *length = NativeObjectFile->getBufferSize();
+  return NativeObjectFile->getBufferStart();
 }
 
 bool LTOCodeGenerator::determineTarget(std::string &errMsg) {
-  if (_target != NULL)
+  if (TargetMach != NULL)
     return true;
 
   // if options were requested, set them
-  if (!_codegenOptions.empty())
-    cl::ParseCommandLineOptions(_codegenOptions.size(),
-                                const_cast<char **>(&_codegenOptions[0]));
+  if (!CodegenOptions.empty())
+    cl::ParseCommandLineOptions(CodegenOptions.size(),
+                                const_cast<char **>(&CodegenOptions[0]));
 
-  std::string TripleStr = _linker.getModule()->getTargetTriple();
+  std::string TripleStr = Linker.getModule()->getTargetTriple();
   if (TripleStr.empty())
     TripleStr = sys::getDefaultTargetTriple();
   llvm::Triple Triple(TripleStr);
@@ -268,7 +267,7 @@ bool LTOCodeGenerator::determineTarget(s
   // The relocation model is actually a static member of TargetMachine and
   // needs to be set before the TargetMachine is instantiated.
   Reloc::Model RelocModel = Reloc::Default;
-  switch (_codeModel) {
+  switch (CodeModel) {
   case LTO_CODEGEN_PIC_MODEL_STATIC:
     RelocModel = Reloc::Static;
     break;
@@ -285,17 +284,17 @@ bool LTOCodeGenerator::determineTarget(s
   Features.getDefaultSubtargetFeatures(Triple);
   std::string FeatureStr = Features.getString();
   // Set a default CPU for Darwin triples.
-  if (_mCpu.empty() && Triple.isOSDarwin()) {
+  if (MCpu.empty() && Triple.isOSDarwin()) {
     if (Triple.getArch() == llvm::Triple::x86_64)
-      _mCpu = "core2";
+      MCpu = "core2";
     else if (Triple.getArch() == llvm::Triple::x86)
-      _mCpu = "yonah";
+      MCpu = "yonah";
   }
   TargetOptions Options;
   LTOModule::getTargetOptions(Options);
-  _target = march->createTargetMachine(TripleStr, _mCpu, FeatureStr, Options,
-                                       RelocModel, CodeModel::Default,
-                                       CodeGenOpt::Aggressive);
+  TargetMach = march->createTargetMachine(TripleStr, MCpu, FeatureStr, Options,
+                                          RelocModel, CodeModel::Default,
+                                          CodeGenOpt::Aggressive);
   return true;
 }
 
@@ -309,9 +308,9 @@ applyRestriction(GlobalValue &GV,
 
   if (GV.isDeclaration())
     return;
-  if (_mustPreserveSymbols.count(Buffer))
+  if (MustPreserveSymbols.count(Buffer))
     mustPreserveList.push_back(GV.getName().data());
-  if (_asmUndefinedRefs.count(Buffer))
+  if (AsmUndefinedRefs.count(Buffer))
     asmUsed.insert(&GV);
 }
 
@@ -327,16 +326,18 @@ static void findUsedValues(GlobalVariabl
 }
 
 void LTOCodeGenerator::applyScopeRestrictions() {
-  if (_scopeRestrictionsDone) return;
-  Module *mergedModule = _linker.getModule();
+  if (ScopeRestrictionsDone)
+    return;
+  Module *mergedModule = Linker.getModule();
 
   // Start off with a verification pass.
   PassManager passes;
   passes.add(createVerifierPass());
 
   // mark which symbols can not be internalized
-  MCContext Context(_target->getMCAsmInfo(), _target->getRegisterInfo(), NULL);
-  Mangler mangler(Context, _target);
+  MCContext MContext(TargetMach->getMCAsmInfo(), TargetMach->getRegisterInfo(),
+                     NULL);
+  Mangler mangler(MContext, TargetMach);
   std::vector<const char*> mustPreserveList;
   SmallPtrSet<GlobalValue*, 8> asmUsed;
 
@@ -357,7 +358,7 @@ void LTOCodeGenerator::applyScopeRestric
     LLVMCompilerUsed->eraseFromParent();
 
   if (!asmUsed.empty()) {
-    llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(_context);
+    llvm::Type *i8PTy = llvm::Type::getInt8PtrTy(Context);
     std::vector<Constant*> asmUsed2;
     for (SmallPtrSet<GlobalValue*, 16>::const_iterator i = asmUsed.begin(),
            e = asmUsed.end(); i !=e; ++i) {
@@ -381,7 +382,7 @@ void LTOCodeGenerator::applyScopeRestric
   // apply scope restrictions
   passes.run(*mergedModule);
 
-  _scopeRestrictionsDone = true;
+  ScopeRestrictionsDone = true;
 }
 
 /// Optimize merged modules using various IPO passes
@@ -390,7 +391,7 @@ bool LTOCodeGenerator::generateObjectFil
   if (!this->determineTarget(errMsg))
     return false;
 
-  Module* mergedModule = _linker.getModule();
+  Module *mergedModule = Linker.getModule();
 
   // Mark which symbols can not be internalized
   this->applyScopeRestrictions();
@@ -402,8 +403,8 @@ bool LTOCodeGenerator::generateObjectFil
   passes.add(createVerifierPass());
 
   // Add an appropriate DataLayout instance for this module...
-  passes.add(new DataLayout(*_target->getDataLayout()));
-  _target->addAnalysisPasses(passes);
+  passes.add(new DataLayout(*TargetMach->getDataLayout()));
+  TargetMach->addAnalysisPasses(passes);
 
   // Enabling internalize here would use its AllButMain variant. It
   // keeps only main if it exists and does nothing for libraries. Instead
@@ -419,8 +420,8 @@ bool LTOCodeGenerator::generateObjectFil
 
   PassManager codeGenPasses;
 
-  codeGenPasses.add(new DataLayout(*_target->getDataLayout()));
-  _target->addAnalysisPasses(codeGenPasses);
+  codeGenPasses.add(new DataLayout(*TargetMach->getDataLayout()));
+  TargetMach->addAnalysisPasses(codeGenPasses);
 
   formatted_raw_ostream Out(out);
 
@@ -428,8 +429,8 @@ bool LTOCodeGenerator::generateObjectFil
   // the ObjCARCContractPass must be run, so do it unconditionally here.
   codeGenPasses.add(createObjCARCContractPass());
 
-  if (_target->addPassesToEmitFile(codeGenPasses, Out,
-                                   TargetMachine::CGFT_ObjectFile)) {
+  if (TargetMach->addPassesToEmitFile(codeGenPasses, Out,
+                                      TargetMachine::CGFT_ObjectFile)) {
     errMsg = "target file type not supported";
     return false;
   }
@@ -450,8 +451,8 @@ void LTOCodeGenerator::setCodeGenDebugOp
        !o.first.empty(); o = getToken(o.second)) {
     // ParseCommandLineOptions() expects argv[0] to be program name. Lazily add
     // that.
-    if (_codegenOptions.empty())
-      _codegenOptions.push_back(strdup("libLTO"));
-    _codegenOptions.push_back(strdup(o.first.str().c_str()));
+    if (CodegenOptions.empty())
+      CodegenOptions.push_back(strdup("libLTO"));
+    CodegenOptions.push_back(strdup(o.first.str().c_str()));
   }
 }

Modified: llvm/trunk/tools/lto/LTOCodeGenerator.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/lto/LTOCodeGenerator.h?rev=189962&r1=189961&r2=189962&view=diff
==============================================================================
--- llvm/trunk/tools/lto/LTOCodeGenerator.h (original)
+++ llvm/trunk/tools/lto/LTOCodeGenerator.h Wed Sep  4 12:44:24 2013
@@ -67,11 +67,9 @@ struct LTOCodeGenerator {
   void setDebugInfo(lto_debug_model);
   void setCodePICModel(lto_codegen_model);
 
-  void setCpu(const char* mCpu) { _mCpu = mCpu; }
+  void setCpu(const char *mCpu) { MCpu = mCpu; }
 
-  void addMustPreserveSymbol(const char* sym) {
-    _mustPreserveSymbols[sym] = 1;
-  }
+  void addMustPreserveSymbol(const char *sym) { MustPreserveSymbols[sym] = 1; }
 
   // To pass options to the driver and optimization passes. These options are
   // not necessarily for debugging purpose (The function name is misleading).
@@ -115,18 +113,18 @@ private:
 
   typedef llvm::StringMap<uint8_t> StringSet;
 
-  llvm::LLVMContext&          _context;
-  llvm::Linker                _linker;
-  llvm::TargetMachine*        _target;
-  bool                        _emitDwarfDebugInfo;
-  bool                        _scopeRestrictionsDone;
-  lto_codegen_model           _codeModel;
-  StringSet                   _mustPreserveSymbols;
-  StringSet                   _asmUndefinedRefs;
-  llvm::MemoryBuffer*         _nativeObjectFile;
-  std::vector<char*>          _codegenOptions;
-  std::string                 _mCpu;
-  std::string                 _nativeObjectPath;
+  llvm::LLVMContext &Context;
+  llvm::Linker Linker;
+  llvm::TargetMachine *TargetMach;
+  bool EmitDwarfDebugInfo;
+  bool ScopeRestrictionsDone;
+  lto_codegen_model CodeModel;
+  StringSet MustPreserveSymbols;
+  StringSet AsmUndefinedRefs;
+  llvm::MemoryBuffer *NativeObjectFile;
+  std::vector<char *> CodegenOptions;
+  std::string MCpu;
+  std::string NativeObjectPath;
 };
 
 #endif // LTO_CODE_GENERATOR_H





More information about the llvm-commits mailing list