Revert "Revert r178079, it caused PR15637."

This reverts commit r178497 since the backend has been fixed.

Also add a test to ensure that we're emitting template information for unions.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178587 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Eric Christopher 2013-04-02 22:59:11 +00:00
Родитель 58b65d953e
Коммит f068c92f22
4 изменённых файлов: 32 добавлений и 42 удалений

Просмотреть файл

@ -392,21 +392,12 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) {
llvm::DIType ISATy = DBuilder.createPointerType(ClassTy, Size); llvm::DIType ISATy = DBuilder.createPointerType(ClassTy, Size);
llvm::DIType FwdTy = ObjTy =
DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(), DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(),
0, 0, 0, 0, llvm::DIType(), llvm::DIArray()); 0, 0, 0, 0, llvm::DIType(), llvm::DIArray());
llvm::TrackingVH<llvm::MDNode> ObjNode(FwdTy); ObjTy.setTypeArray(DBuilder.getOrCreateArray(&*DBuilder.createMemberType(
SmallVector<llvm::Value *, 1> EltTys; ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 0, ISATy)));
llvm::DIType FieldTy =
DBuilder.createMemberType(llvm::DIDescriptor(ObjNode), "isa",
getOrCreateMainFile(), 0, Size,
0, 0, 0, ISATy);
EltTys.push_back(FieldTy);
llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
ObjNode->replaceOperandWith(10, Elements);
ObjTy = llvm::DIType(ObjNode);
return ObjTy; return ObjTy;
} }
case BuiltinType::ObjCSel: { case BuiltinType::ObjCSel: {
@ -1332,15 +1323,16 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) {
// may refer to the forward decl if the struct is recursive) and replace all // may refer to the forward decl if the struct is recursive) and replace all
// uses of the forward declaration with the final definition. // uses of the forward declaration with the final definition.
llvm::DIType FwdDecl = getOrCreateLimitedType(QualType(Ty, 0), DefUnit); llvm::DICompositeType FwdDecl(
getOrCreateLimitedType(QualType(Ty, 0), DefUnit));
assert(FwdDecl.Verify() &&
"The debug type of a RecordType should be a DICompositeType");
if (FwdDecl.isForwardDecl()) if (FwdDecl.isForwardDecl())
return FwdDecl; return FwdDecl;
llvm::TrackingVH<llvm::MDNode> FwdDeclNode(FwdDecl);
// Push the struct on region stack. // Push the struct on region stack.
LexicalBlockStack.push_back(FwdDeclNode); LexicalBlockStack.push_back(&*FwdDecl);
RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl); RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl);
// Add this to the completed-type cache while we're completing it recursively. // Add this to the completed-type cache while we're completing it recursively.
@ -1374,19 +1366,10 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) {
RegionMap.erase(Ty->getDecl()); RegionMap.erase(Ty->getDecl());
llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys); llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
// FIXME: Magic numbers ahoy! These should be changed when we FwdDecl.setTypeArray(Elements, TParamsArray);
// get some enums in llvm/Analysis/DebugInfo.h to refer to
// them.
if (RD->isUnion())
FwdDeclNode->replaceOperandWith(10, Elements);
else if (CXXDecl) {
FwdDeclNode->replaceOperandWith(10, Elements);
FwdDeclNode->replaceOperandWith(13, TParamsArray);
} else
FwdDeclNode->replaceOperandWith(10, Elements);
RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDeclNode); RegionMap[Ty->getDecl()] = llvm::WeakVH(FwdDecl);
return llvm::DIType(FwdDeclNode); return FwdDecl;
} }
/// CreateType - get objective-c object type. /// CreateType - get objective-c object type.
@ -1429,7 +1412,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
if (ID->getImplementation()) if (ID->getImplementation())
Flags |= llvm::DIDescriptor::FlagObjcClassComplete; Flags |= llvm::DIDescriptor::FlagObjcClassComplete;
llvm::DIType RealDecl = llvm::DICompositeType RealDecl =
DBuilder.createStructType(Unit, ID->getName(), DefUnit, DBuilder.createStructType(Unit, ID->getName(), DefUnit,
Line, Size, Align, Flags, Line, Size, Align, Flags,
llvm::DIType(), llvm::DIArray(), RuntimeLang); llvm::DIType(), llvm::DIArray(), RuntimeLang);
@ -1439,9 +1422,8 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
QualType QualTy = QualType(Ty, 0); QualType QualTy = QualType(Ty, 0);
CompletedTypeCache[QualTy.getAsOpaquePtr()] = RealDecl; CompletedTypeCache[QualTy.getAsOpaquePtr()] = RealDecl;
// Push the struct on region stack. // Push the struct on region stack.
llvm::TrackingVH<llvm::MDNode> FwdDeclNode(RealDecl);
LexicalBlockStack.push_back(FwdDeclNode); LexicalBlockStack.push_back(static_cast<llvm::MDNode*>(RealDecl));
RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl); RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl);
// Convert all the elements. // Convert all the elements.
@ -1561,7 +1543,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
} }
llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys); llvm::DIArray Elements = DBuilder.getOrCreateArray(EltTys);
FwdDeclNode->replaceOperandWith(10, Elements); RealDecl.setTypeArray(Elements);
// If the implementation is not yet set, we do not want to mark it // If the implementation is not yet set, we do not want to mark it
// as complete. An implementation may declare additional // as complete. An implementation may declare additional
@ -1570,7 +1552,7 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
CompletedTypeCache.erase(QualTy.getAsOpaquePtr()); CompletedTypeCache.erase(QualTy.getAsOpaquePtr());
LexicalBlockStack.pop_back(); LexicalBlockStack.pop_back();
return llvm::DIType(FwdDeclNode); return RealDecl;
} }
llvm::DIType CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) { llvm::DIType CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) {
@ -2842,7 +2824,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block,
// Insert an llvm.dbg.value into the current block. // Insert an llvm.dbg.value into the current block.
llvm::Instruction *DbgVal = llvm::Instruction *DbgVal =
DBuilder.insertDbgValueIntrinsic(LocalAddr, 0, debugVar, DBuilder.insertDbgValueIntrinsic(LocalAddr, 0, debugVar,
Builder.GetInsertBlock()); Builder.GetInsertBlock());
DbgVal->setDebugLoc(llvm::DebugLoc::get(line, column, scope)); DbgVal->setDebugLoc(llvm::DebugLoc::get(line, column, scope));
} }

Просмотреть файл

@ -51,7 +51,7 @@ class CGDebugInfo {
SourceLocation CurLoc, PrevLoc; SourceLocation CurLoc, PrevLoc;
llvm::DIType VTablePtrType; llvm::DIType VTablePtrType;
llvm::DIType ClassTy; llvm::DIType ClassTy;
llvm::DIType ObjTy; llvm::DICompositeType ObjTy;
llvm::DIType SelTy; llvm::DIType SelTy;
llvm::DIType OCLImage1dDITy, OCLImage1dArrayDITy, OCLImage1dBufferDITy; llvm::DIType OCLImage1dDITy, OCLImage1dArrayDITy, OCLImage1dBufferDITy;
llvm::DIType OCLImage2dDITy, OCLImage2dArrayDITy; llvm::DIType OCLImage2dDITy, OCLImage2dArrayDITy;

Просмотреть файл

@ -0,0 +1,15 @@
// RUN: %clang_cc1 -emit-llvm -g -triple x86_64-linux-gnu %s -o - | FileCheck %s
// Make sure that the union type has template parameters.
namespace PR15637 {
template <typename T> union Value { int a; };
void g(float value) {
Value<float> tempValue;
}
Value<float> f;
}
// CHECK: {{.*}}, metadata !"Value<float>", {{.*}}, null, metadata [[TTPARAM:.*]]} ; [ DW_TAG_union_type ] [Value<float>]
// CHECK: [[TTPARAM]] = metadata !{metadata [[PARAMS:.*]]}
// CHECK: [[PARAMS]] = metadata !{{{.*}}metadata !"T",{{.*}}} ; [ DW_TAG_template_type_parameter ]

Просмотреть файл

@ -67,10 +67,3 @@ class Cls {
Cls obj; Cls obj;
} }
namespace PR15637 {
template <typename T> union Value { int a; };
void g(float value) {
Value<float> tempValue;
}
}