diff options
| author | Anders Carlsson <andersca@mac.com> | 2010-01-26 05:19:50 +0000 | 
|---|---|---|
| committer | Anders Carlsson <andersca@mac.com> | 2010-01-26 05:19:50 +0000 | 
| commit | 17ed0496c566930ff51923b9c9b98da687213dda (patch) | |
| tree | c711071cd72bc496d6a5b34a8839b2214c268773 | |
| parent | cc0f734cd0ea84bc9a7d5a2df40a11126ac3ae2a (diff) | |
| download | bcm5719-llvm-17ed0496c566930ff51923b9c9b98da687213dda.tar.gz bcm5719-llvm-17ed0496c566930ff51923b9c9b98da687213dda.zip  | |
Fix the test I broke, and also fix a crash when declaring a virtual destructor. Add debug info support for pure virtual member functions.
llvm-svn: 94519
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 46 | ||||
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.h | 2 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/PR4890-debug-info-dtor.cpp | 6 | ||||
| -rw-r--r-- | clang/test/CodeGenCXX/debug-info.cpp | 17 | 
4 files changed, 43 insertions, 28 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 14f34a7c729..e1aeb5ed8cc 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -521,27 +521,21 @@ CollectRecordFields(const RecordDecl *Decl,  /// CreateCXXMemberFunction - A helper function to create a DISubprogram for  /// a single member function GlobalDecl.  llvm::DISubprogram -CGDebugInfo::CreateCXXMemberFunction(GlobalDecl GD, +CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method,                                       llvm::DICompileUnit Unit,                                       llvm::DICompositeType &RecordTy) { -  const CXXMethodDecl *Method = cast<CXXMethodDecl>(GD.getDecl()); - -  llvm::StringRef MethodName; +  bool IsCtorOrDtor =  +    isa<CXXConstructorDecl>(Method) || isa<CXXDestructorDecl>(Method); +   +  llvm::StringRef MethodName = getFunctionName(Method);    llvm::StringRef MethodLinkageName;    llvm::DIType MethodTy = getOrCreateType(Method->getType(), Unit); -  if (const CXXConstructorDecl *CDecl = dyn_cast<CXXConstructorDecl>(Method)) { -    (void)CDecl; -    MethodName = Method->getName(); -    // FIXME : Find linkage name. -  } else if (const CXXDestructorDecl *DDecl = dyn_cast<CXXDestructorDecl>(Method)) { -    (void)DDecl; -    MethodName = getFunctionName(Method); -    // FIXME : Find linkage name. -  } else { -    // regular method -    MethodName = getFunctionName(Method); +   +  // Since a single ctor/dtor corresponds to multiple functions, it doesn't +  // make sense to give a single ctor/dtor a linkage name. +  if (!IsCtorOrDtor)      MethodLinkageName = CGM.getMangledName(Method); -  } +    SourceManager &SM = CGM.getContext().getSourceManager();    // Get the location for the method. @@ -559,10 +553,17 @@ CGDebugInfo::CreateCXXMemberFunction(GlobalDecl GD,    llvm::DIType ContainingType;    unsigned Virtuality = 0;     unsigned VIndex = 0; +      if (Method->isVirtual()) { -    // FIXME: Identify pure virtual functions. -    Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual; -    VIndex = CGM.getVtableInfo().getMethodVtableIndex(Method); +    if (Method->isPure()) +      Virtuality = llvm::dwarf::DW_VIRTUALITY_pure_virtual; +    else +      Virtuality = llvm::dwarf::DW_VIRTUALITY_virtual; +     +    // It doesn't make sense to give a virtual destructor a vtable index, +    // since a single destructor has two entries in the vtable. +    if (!isa<CXXDestructorDecl>(Method)) +      VIndex = CGM.getVtableInfo().getMethodVtableIndex(Method);      ContainingType = RecordTy;    } @@ -573,8 +574,11 @@ CGDebugInfo::CreateCXXMemberFunction(GlobalDecl GD,                                    MethodTy, /*isLocalToUnit=*/false,                                     Method->isThisDeclarationADefinition(),                                    Virtuality, VIndex, ContainingType); -  if (Method->isThisDeclarationADefinition()) -    SPCache[cast<FunctionDecl>(Method)] = llvm::WeakVH(SP.getNode()); +   +  // Don't cache ctors or dtors since we have to emit multiple functions for +  // a single ctor or dtor. +  if (!IsCtorOrDtor && Method->isThisDeclarationADefinition()) +    SPCache[Method] = llvm::WeakVH(SP.getNode());    return SP;  } diff --git a/clang/lib/CodeGen/CGDebugInfo.h b/clang/lib/CodeGen/CGDebugInfo.h index e785bef1016..405f02ba7bf 100644 --- a/clang/lib/CodeGen/CGDebugInfo.h +++ b/clang/lib/CodeGen/CGDebugInfo.h @@ -88,7 +88,7 @@ class CGDebugInfo {                                       const Type *Ty, QualType PointeeTy,                                       llvm::DICompileUnit U); -  llvm::DISubprogram CreateCXXMemberFunction(GlobalDecl GD, +  llvm::DISubprogram CreateCXXMemberFunction(const CXXMethodDecl *Method,                                               llvm::DICompileUnit Unit,                                               llvm::DICompositeType &RecordTy); diff --git a/clang/test/CodeGenCXX/PR4890-debug-info-dtor.cpp b/clang/test/CodeGenCXX/PR4890-debug-info-dtor.cpp deleted file mode 100644 index bcaf1b96274..00000000000 --- a/clang/test/CodeGenCXX/PR4890-debug-info-dtor.cpp +++ /dev/null @@ -1,6 +0,0 @@ -// RUN: %clang_cc1 -emit-llvm-only -g %s -struct X { -  ~X(); -}; - -X::~X() { } diff --git a/clang/test/CodeGenCXX/debug-info.cpp b/clang/test/CodeGenCXX/debug-info.cpp index cb6e830a49e..f18e9b08a02 100644 --- a/clang/test/CodeGenCXX/debug-info.cpp +++ b/clang/test/CodeGenCXX/debug-info.cpp @@ -24,3 +24,20 @@ namespace EmptyNameCrash {    typedef struct { A x; } B;    B x;  } + +// PR4890 +namespace PR4890 { +  struct X { +    ~X(); +  }; + +  X::~X() { } +} + +namespace VirtualDtor { +  struct Y { +    virtual ~Y(); +  }; +   +  Y::~Y() { } +}  | 

