return llvm::DIType();
}
-/// ContainsFwdDecl - True if Ty is either a forward declaration or a
-/// derived type of a forward declaration.
-static bool ContainsFwdDecl(llvm::DIType Ty) {
- // Composite types such as structs inherit from DIDerivedType, so
- // check this first and do an early exit.
- if (Ty.isForwardDecl())
- return true;
-
- if (Ty.isDerivedType()) {
- llvm::DIDerivedType DTy(Ty);
- return ContainsFwdDecl(DTy.getTypeDerivedFrom());
- }
-
- return false;
-}
-
/// getCompletedTypeOrNull - Get the type from the cache or return null if it
/// doesn't exist.
llvm::DIType CGDebugInfo::getCompletedTypeOrNull(QualType Ty) {
}
// Verify that any cached debug info still exists.
- if (V != 0) {
- llvm::DIType CachedType(cast<llvm::MDNode>(V));
+ if (V != 0)
+ return llvm::DIType(cast<llvm::MDNode>(V));
- // Unless we are limiting debug info, attempt to resolve any
- // forward declarations.
- if (DebugKind > CodeGenOptions::LimitedDebugInfo &&
- ContainsFwdDecl(CachedType))
- return llvm::DIType();
+ return llvm::DIType();
+}
- return CachedType;
- }
+void CGDebugInfo::completeFwdDecl(const RecordDecl &RD) {
+ // In limited debug info we only want to do this if the complete type was
+ // required.
+ if (DebugKind <= CodeGenOptions::LimitedDebugInfo)
+ return;
- return llvm::DIType();
+ llvm::DIType T = getTypeOrNull(CGM.getContext().getRecordType(&RD));
+
+ if (T.Verify() && T.isForwardDecl())
+ getOrCreateType(QTy, getOrCreateFile(RD.getLocation());
}
/// getCachedInterfaceTypeOrNull - Get the type from the interface
llvm::DIType getOrCreateInterfaceType(QualType Ty,
SourceLocation Loc);
+ void completeFwdDecls(const RecordDecl *TD);
+
private:
/// EmitDeclare - Emit call to llvm.dbg.declare for a variable declaration.
void EmitDeclare(const VarDecl *decl, unsigned Tag, llvm::Value *AI,
// yet, we'll just do it lazily.
if (RecordDeclTypes.count(Context.getTagDeclType(RD).getTypePtr()))
ConvertRecordDeclType(RD);
+
+ // If necessary, provide the full definition of a type only used with a
+ // declaration so far.
+ if (CGDebugInfo *DI = CGM.getModuleDebugInfo())
+ DI->completeFwdDecls(RD);
}
static llvm::Type *getTypeForFormat(llvm::LLVMContext &VMContext,