diff options
| author | Devang Patel <dpatel@apple.com> | 2010-07-08 19:56:29 +0000 |
|---|---|---|
| committer | Devang Patel <dpatel@apple.com> | 2010-07-08 19:56:29 +0000 |
| commit | 8f3f76f99192c4a27e7d8263713eb509cd468255 (patch) | |
| tree | fe9f80edb5c6ddf2c60ade81cd8e96b7e6f127f7 /clang | |
| parent | 63a622b768b3ba7c9d8dfe148aea0b9cd2b094f3 (diff) | |
| download | bcm5719-llvm-8f3f76f99192c4a27e7d8263713eb509cd468255.tar.gz bcm5719-llvm-8f3f76f99192c4a27e7d8263713eb509cd468255.zip | |
Handle forward declarations properly in debug info.
Patch by Alexander Kabaev.
PR 7595.
llvm-svn: 107900
Diffstat (limited to 'clang')
| -rw-r--r-- | clang/lib/CodeGen/CGDebugInfo.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index cd5e1c43bc0..d63db266667 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -758,22 +758,30 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty, // its members. Finally, we create a descriptor for the complete type (which // may refer to the forward decl if the struct is recursive) and replace all // uses of the forward declaration with the final definition. + llvm::DIDescriptor FDContext = + getContextDescriptor(dyn_cast<Decl>(RD->getDeclContext()), Unit); + + // If this is just a forward declaration, construct an appropriately + // marked node and just return it. + if (!RD->getDefinition()) { + llvm::DICompositeType FwdDecl = + DebugFactory.CreateCompositeType(Tag, FDContext, RD->getName(), + DefUnit, Line, 0, 0, 0, + llvm::DIType::FlagFwdDecl, + llvm::DIType(), llvm::DIArray()); + + return FwdDecl; + } // A RD->getName() is not unique. However, the debug info descriptors // are uniqued so use type name to ensure uniquness. llvm::SmallString<128> FwdDeclName; llvm::raw_svector_ostream(FwdDeclName) << "fwd.type." << FwdDeclCount++; - llvm::DIDescriptor FDContext = - getContextDescriptor(dyn_cast<Decl>(RD->getDeclContext()), Unit); llvm::DICompositeType FwdDecl = DebugFactory.CreateCompositeType(Tag, FDContext, FwdDeclName, DefUnit, Line, 0, 0, 0, 0, llvm::DIType(), llvm::DIArray()); - // If this is just a forward declaration, return it. - if (!RD->getDefinition()) - return FwdDecl; - llvm::MDNode *MN = FwdDecl; llvm::TrackingVH<llvm::MDNode> FwdDeclNode = MN; // Otherwise, insert it into the TypeCache so that recursive uses will find |

