diff options
Diffstat (limited to 'clang/lib')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 26 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 5 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 4 | 
3 files changed, 27 insertions, 8 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 0344f562a7b..7855b91f1fa 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -19,6 +19,7 @@  #include "clang/AST/RecordLayout.h"  #include "clang/Basic/SourceManager.h"  #include "clang/Basic/FileManager.h" +#include "clang/Basic/TargetInfo.h"  #include "clang/Frontend/CompileOptions.h"  #include "llvm/Constants.h"  #include "llvm/DerivedTypes.h" @@ -33,12 +34,22 @@  using namespace clang;  using namespace clang::CodeGen; -CGDebugInfo::CGDebugInfo(CodeGenModule *m) +CGDebugInfo::CGDebugInfo(CodeGenModule *m, TargetInfo *t)    : M(m), isMainCompileUnitCreated(false), DebugFactory(M->getModule()),      BlockLiteralGenericSet(false) { +  LLVMMangler = new llvm::Mangler(m->getModule(), t->getUserLabelPrefix(), "."); +  // add chars used in ObjC method names so method names aren't mangled +  LLVMMangler->markCharAcceptable('['); +  LLVMMangler->markCharAcceptable(']'); +  LLVMMangler->markCharAcceptable('('); +  LLVMMangler->markCharAcceptable(')'); +  LLVMMangler->markCharAcceptable('-'); +  LLVMMangler->markCharAcceptable('+'); +  LLVMMangler->markCharAcceptable(' ');  }  CGDebugInfo::~CGDebugInfo() { +  delete LLVMMangler;    assert(RegionStack.empty() && "Region stack mismatch, stack not empty!");  } @@ -820,8 +831,6 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty,  void CGDebugInfo::EmitFunctionStart(const char *Name, QualType ReturnType,                                      llvm::Function *Fn,                                      CGBuilderTy &Builder) { -  const char *LinkageName = Name; -      // Skip the asm prefix if it exists.    //    // FIXME: This should probably be the unmangled name? @@ -834,7 +843,8 @@ void CGDebugInfo::EmitFunctionStart(const char *Name, QualType ReturnType,    unsigned LineNo = SM.getPresumedLoc(CurLoc).getLine();    llvm::DISubprogram SP = -    DebugFactory.CreateSubprogram(Unit, Name, Name, LinkageName, Unit, LineNo, +    DebugFactory.CreateSubprogram(Unit, Name, Name, LLVMMangler->getValueName(Fn),  +                                  Unit, LineNo,                                    getOrCreateType(ReturnType, Unit),                                    Fn->hasInternalLinkage(), true/*definition*/); @@ -969,7 +979,9 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,                                             ArrayType::Normal, 0);    } -  DebugFactory.CreateGlobalVariable(Unit, Name, Name, "", Unit, LineNo, +  DebugFactory.CreateGlobalVariable(Unit, Name, Name,  +                                    LLVMMangler->getValueName(Var), +                                    Unit, LineNo,                                      getOrCreateType(T, Unit),                                      Var->hasInternalLinkage(),                                      true/*definition*/, Var); @@ -999,7 +1011,9 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var,                                             ArrayType::Normal, 0);    } -  DebugFactory.CreateGlobalVariable(Unit, Name, Name, "", Unit, LineNo, +  DebugFactory.CreateGlobalVariable(Unit, Name, Name,  +                                    LLVMMangler->getValueName(Var), +                                    Unit, LineNo,                                      getOrCreateType(T, Unit),                                      Var->hasInternalLinkage(),                                      true/*definition*/, Var); diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index ac28e5b879e..5cb5f09da82 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -16,6 +16,7 @@  #include "clang/AST/Type.h"  #include "clang/Basic/SourceLocation.h" +#include "llvm/Support/Mangler.h"  #include "llvm/ADT/DenseMap.h"  #include "llvm/Analysis/DebugInfo.h"  #include <map> @@ -25,6 +26,7 @@  namespace clang {    class VarDecl;    class ObjCInterfaceDecl; +  class TargetInfo;  namespace CodeGen {    class CodeGenModule; @@ -34,6 +36,7 @@ namespace CodeGen {  /// the backend.  class CGDebugInfo {    CodeGenModule *M; +  llvm::Mangler *LLVMMangler;    bool isMainCompileUnitCreated;    llvm::DIFactory DebugFactory; @@ -68,7 +71,7 @@ class CGDebugInfo {    llvm::DIType CreateType(const ArrayType *Ty, llvm::DICompileUnit U);  public: -  CGDebugInfo(CodeGenModule *m); +  CGDebugInfo(CodeGenModule *m, TargetInfo *t);    ~CGDebugInfo();    /// setLocation - Update the current source location. If \arg loc is diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b516da9a728..9ac68718a5c 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -52,7 +52,9 @@ CodeGenModule::CodeGenModule(ASTContext &C, const CompileOptions &compileOpts,      Runtime = CreateMacObjCRuntime(*this);    // If debug info generation is enabled, create the CGDebugInfo object. -  DebugInfo = CompileOpts.DebugInfo ? new CGDebugInfo(this) : 0; +  DebugInfo = 0; +  if (CompileOpts.DebugInfo) +    DebugInfo = new CGDebugInfo(this, &Context.Target);  }  CodeGenModule::~CodeGenModule() {  | 

