From e7b87e5cc902d7601887e58009d6ac7d9c76f8fa Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Sun, 26 Oct 2014 23:40:33 +0000 Subject: [PATCH] Fix 80-column and other odd formatting. llvm-svn: 220659 --- clang/lib/CodeGen/CGDebugInfo.cpp | 815 ++++++++++++++++++-------------------- 1 file changed, 388 insertions(+), 427 deletions(-) diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index 92c2a9b..05df170 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -67,7 +67,7 @@ SaveAndRestoreLocation::~SaveAndRestoreLocation() { } NoLocation::NoLocation(CodeGenFunction &CGF, CGBuilderTy &B) - : SaveAndRestoreLocation(CGF, B) { + : SaveAndRestoreLocation(CGF, B) { if (DI) Builder.SetCurrentDebugLocation(llvm::DebugLoc()); } @@ -78,7 +78,7 @@ NoLocation::~NoLocation() { } ArtificialLocation::ArtificialLocation(CodeGenFunction &CGF, CGBuilderTy &B) - : SaveAndRestoreLocation(CGF, B) { + : SaveAndRestoreLocation(CGF, B) { if (DI) Builder.SetCurrentDebugLocation(llvm::DebugLoc()); } @@ -102,14 +102,16 @@ ArtificialLocation::~ArtificialLocation() { void CGDebugInfo::setLocation(SourceLocation Loc) { // If the new location isn't valid return. - if (Loc.isInvalid()) return; + if (Loc.isInvalid()) + return; CurLoc = CGM.getContext().getSourceManager().getExpansionLoc(Loc); // If we've changed files in the middle of a lexical scope go ahead // and create a new lexical scope with file node if it's different // from the one in the scope. - if (LexicalBlockStack.empty()) return; + if (LexicalBlockStack.empty()) + return; SourceManager &SM = CGM.getContext().getSourceManager(); llvm::DIScope Scope(LexicalBlockStack.back()); @@ -120,15 +122,14 @@ void CGDebugInfo::setLocation(SourceLocation Loc) { if (Scope.isLexicalBlockFile()) { llvm::DILexicalBlockFile LBF = llvm::DILexicalBlockFile(Scope); - llvm::DIDescriptor D - = DBuilder.createLexicalBlockFile(LBF.getScope(), - getOrCreateFile(CurLoc)); + llvm::DIDescriptor D = DBuilder.createLexicalBlockFile( + LBF.getScope(), getOrCreateFile(CurLoc)); llvm::MDNode *N = D; LexicalBlockStack.pop_back(); LexicalBlockStack.push_back(N); } else if (Scope.isLexicalBlock() || Scope.isSubprogram()) { - llvm::DIDescriptor D - = DBuilder.createLexicalBlockFile(Scope, getOrCreateFile(CurLoc)); + llvm::DIDescriptor D = + DBuilder.createLexicalBlockFile(Scope, getOrCreateFile(CurLoc)); llvm::MDNode *N = D; LexicalBlockStack.pop_back(); LexicalBlockStack.push_back(N); @@ -140,8 +141,8 @@ llvm::DIScope CGDebugInfo::getContextDescriptor(const Decl *Context) { if (!Context) return TheCU; - llvm::DenseMap::iterator - I = RegionMap.find(Context); + llvm::DenseMap::iterator I = + RegionMap.find(Context); if (I != RegionMap.end()) { llvm::Value *V = I->second; return llvm::DIScope(dyn_cast_or_null(V)); @@ -154,7 +155,7 @@ llvm::DIScope CGDebugInfo::getContextDescriptor(const Decl *Context) { if (const RecordDecl *RDecl = dyn_cast(Context)) if (!RDecl->isDependentType()) return getOrCreateType(CGM.getContext().getTypeDeclType(RDecl), - getOrCreateMainFile()); + getOrCreateMainFile()); return TheCU; } @@ -162,10 +163,10 @@ llvm::DIScope CGDebugInfo::getContextDescriptor(const Decl *Context) { /// name is constructed on demand (e.g. C++ destructor) then the name /// is stored on the side. StringRef CGDebugInfo::getFunctionName(const FunctionDecl *FD) { - assert (FD && "Invalid FunctionDecl!"); + assert(FD && "Invalid FunctionDecl!"); IdentifierInfo *FII = FD->getIdentifier(); - FunctionTemplateSpecializationInfo *Info - = FD->getTemplateSpecializationInfo(); + FunctionTemplateSpecializationInfo *Info = + FD->getTemplateSpecializationInfo(); if (!Info && FII) return FII->getName(); @@ -194,20 +195,20 @@ StringRef CGDebugInfo::getObjCMethodName(const ObjCMethodDecl *OMD) { OS << (OMD->isInstanceMethod() ? '-' : '+') << '['; const DeclContext *DC = OMD->getDeclContext(); if (const ObjCImplementationDecl *OID = - dyn_cast(DC)) { - OS << OID->getName(); + dyn_cast(DC)) { + OS << OID->getName(); } else if (const ObjCInterfaceDecl *OID = - dyn_cast(DC)) { - OS << OID->getName(); + dyn_cast(DC)) { + OS << OID->getName(); } else if (const ObjCCategoryImplDecl *OCD = - dyn_cast(DC)){ - OS << ((const NamedDecl *)OCD)->getIdentifier()->getNameStart() << '(' << - OCD->getIdentifier()->getNameStart() << ')'; + dyn_cast(DC)) { + OS << ((const NamedDecl *)OCD)->getIdentifier()->getNameStart() << '(' + << OCD->getIdentifier()->getNameStart() << ')'; } else if (isa(DC)) { // We can extract the type of the class from the self pointer. - if (ImplicitParamDecl* SelfDecl = OMD->getSelfDecl()) { + if (ImplicitParamDecl *SelfDecl = OMD->getSelfDecl()) { QualType ClassTy = - cast(SelfDecl->getType())->getPointeeType(); + cast(SelfDecl->getType())->getPointeeType(); ClassTy.print(OS, PrintingPolicy(LangOptions())); } } @@ -223,8 +224,7 @@ StringRef CGDebugInfo::getSelectorName(Selector S) { } /// getClassName - Get class name including template argument list. -StringRef -CGDebugInfo::getClassName(const RecordDecl *RD) { +StringRef CGDebugInfo::getClassName(const RecordDecl *RD) { // quick optimization to avoid having to intern strings that are already // stored reliably elsewhere if (!isa(RD)) @@ -257,7 +257,7 @@ llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) { // Cache the results. const char *fname = PLoc.getFilename(); llvm::DenseMap::iterator it = - DIFileCache.find(fname); + DIFileCache.find(fname); if (it != DIFileCache.end()) { // Verify that the information still exists. @@ -283,7 +283,7 @@ unsigned CGDebugInfo::getLineNumber(SourceLocation Loc) { return 0; SourceManager &SM = CGM.getContext().getSourceManager(); PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc); - return PLoc.isValid()? PLoc.getLine() : 0; + return PLoc.isValid() ? PLoc.getLine() : 0; } /// getColumnNumber - Get column number for the location. @@ -297,7 +297,7 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc, bool Force) { return 0; SourceManager &SM = CGM.getContext().getSourceManager(); PresumedLoc PLoc = SM.getPresumedLoc(Loc.isValid() ? Loc : CurLoc); - return PLoc.isValid()? PLoc.getColumn() : 0; + return PLoc.isValid() ? PLoc.getColumn() : 0; } StringRef CGDebugInfo::getCurrentDirname() { @@ -388,8 +388,7 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) { StringRef BTName; switch (BT->getKind()) { #define BUILTIN_TYPE(Id, SingletonId) -#define PLACEHOLDER_TYPE(Id, SingletonId) \ - case BuiltinType::Id: +#define PLACEHOLDER_TYPE(Id, SingletonId) case BuiltinType::Id: #include "clang/AST/BuiltinTypes.def" case BuiltinType::Dependent: llvm_unreachable("Unexpected builtin type"); @@ -425,8 +424,9 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) { DBuilder.createStructType(TheCU, "objc_object", getOrCreateMainFile(), 0, 0, 0, 0, llvm::DIType(), llvm::DIArray()); - ObjTy.setArrays(DBuilder.getOrCreateArray(&*DBuilder.createMemberType( - ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, 0, ISATy))); + ObjTy.setArrays(DBuilder.getOrCreateArray( + &*DBuilder.createMemberType(ObjTy, "isa", getOrCreateMainFile(), 0, + Size, 0, 0, 0, ISATy))); return ObjTy; } case BuiltinType::ObjCSel: { @@ -438,8 +438,7 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) { } case BuiltinType::OCLImage1d: - return getOrCreateStructPtrType("opencl_image1d_t", - OCLImage1dDITy); + return getOrCreateStructPtrType("opencl_image1d_t", OCLImage1dDITy); case BuiltinType::OCLImage1dArray: return getOrCreateStructPtrType("opencl_image1d_array_t", OCLImage1dArrayDITy); @@ -447,53 +446,71 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) { return getOrCreateStructPtrType("opencl_image1d_buffer_t", OCLImage1dBufferDITy); case BuiltinType::OCLImage2d: - return getOrCreateStructPtrType("opencl_image2d_t", - OCLImage2dDITy); + return getOrCreateStructPtrType("opencl_image2d_t", OCLImage2dDITy); case BuiltinType::OCLImage2dArray: return getOrCreateStructPtrType("opencl_image2d_array_t", OCLImage2dArrayDITy); case BuiltinType::OCLImage3d: - return getOrCreateStructPtrType("opencl_image3d_t", - OCLImage3dDITy); + return getOrCreateStructPtrType("opencl_image3d_t", OCLImage3dDITy); case BuiltinType::OCLSampler: - return DBuilder.createBasicType("opencl_sampler_t", - CGM.getContext().getTypeSize(BT), - CGM.getContext().getTypeAlign(BT), - llvm::dwarf::DW_ATE_unsigned); + return DBuilder.createBasicType( + "opencl_sampler_t", CGM.getContext().getTypeSize(BT), + CGM.getContext().getTypeAlign(BT), llvm::dwarf::DW_ATE_unsigned); case BuiltinType::OCLEvent: - return getOrCreateStructPtrType("opencl_event_t", - OCLEventDITy); + return getOrCreateStructPtrType("opencl_event_t", OCLEventDITy); case BuiltinType::UChar: - case BuiltinType::Char_U: Encoding = llvm::dwarf::DW_ATE_unsigned_char; break; + case BuiltinType::Char_U: + Encoding = llvm::dwarf::DW_ATE_unsigned_char; + break; case BuiltinType::Char_S: - case BuiltinType::SChar: Encoding = llvm::dwarf::DW_ATE_signed_char; break; + case BuiltinType::SChar: + Encoding = llvm::dwarf::DW_ATE_signed_char; + break; case BuiltinType::Char16: - case BuiltinType::Char32: Encoding = llvm::dwarf::DW_ATE_UTF; break; + case BuiltinType::Char32: + Encoding = llvm::dwarf::DW_ATE_UTF; + break; case BuiltinType::UShort: case BuiltinType::UInt: case BuiltinType::UInt128: case BuiltinType::ULong: case BuiltinType::WChar_U: - case BuiltinType::ULongLong: Encoding = llvm::dwarf::DW_ATE_unsigned; break; + case BuiltinType::ULongLong: + Encoding = llvm::dwarf::DW_ATE_unsigned; + break; case BuiltinType::Short: case BuiltinType::Int: case BuiltinType::Int128: case BuiltinType::Long: case BuiltinType::WChar_S: - case BuiltinType::LongLong: Encoding = llvm::dwarf::DW_ATE_signed; break; - case BuiltinType::Bool: Encoding = llvm::dwarf::DW_ATE_boolean; break; + case BuiltinType::LongLong: + Encoding = llvm::dwarf::DW_ATE_signed; + break; + case BuiltinType::Bool: + Encoding = llvm::dwarf::DW_ATE_boolean; + break; case BuiltinType::Half: case BuiltinType::Float: case BuiltinType::LongDouble: - case BuiltinType::Double: Encoding = llvm::dwarf::DW_ATE_float; break; + case BuiltinType::Double: + Encoding = llvm::dwarf::DW_ATE_float; + break; } switch (BT->getKind()) { - case BuiltinType::Long: BTName = "long int"; break; - case BuiltinType::LongLong: BTName = "long long int"; break; - case BuiltinType::ULong: BTName = "long unsigned int"; break; - case BuiltinType::ULongLong: BTName = "long long unsigned int"; break; + case BuiltinType::Long: + BTName = "long int"; + break; + case BuiltinType::LongLong: + BTName = "long long int"; + break; + case BuiltinType::ULong: + BTName = "long unsigned int"; + break; + case BuiltinType::ULongLong: + BTName = "long long unsigned int"; + break; default: BTName = BT->getName(CGM.getLangOpts()); break; @@ -501,8 +518,7 @@ llvm::DIType CGDebugInfo::CreateType(const BuiltinType *BT) { // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(BT); uint64_t Align = CGM.getContext().getTypeAlign(BT); - llvm::DIType DbgTy = - DBuilder.createBasicType(BTName, Size, Align, Encoding); + llvm::DIType DbgTy = DBuilder.createBasicType(BTName, Size, Align, Encoding); return DbgTy; } @@ -515,7 +531,7 @@ llvm::DIType CGDebugInfo::CreateType(const ComplexType *Ty) { uint64_t Size = CGM.getContext().getTypeSize(Ty); uint64_t Align = CGM.getContext().getTypeAlign(Ty); llvm::DIType DbgTy = - DBuilder.createBasicType("complex", Size, Align, Encoding); + DBuilder.createBasicType("complex", Size, Align, Encoding); return DbgTy; } @@ -564,25 +580,23 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCObjectPointerType *Ty, // whereas 'id' is treated as an ObjCPointerType. For the // debug info, we want to emit 'id' in both cases. if (Ty->isObjCQualifiedIdType()) - return getOrCreateType(CGM.getContext().getObjCIdType(), Unit); + return getOrCreateType(CGM.getContext().getObjCIdType(), Unit); - llvm::DIType DbgTy = - CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty, - Ty->getPointeeType(), Unit); + llvm::DIType DbgTy = CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, + Ty, Ty->getPointeeType(), Unit); return DbgTy; } -llvm::DIType CGDebugInfo::CreateType(const PointerType *Ty, - llvm::DIFile Unit) { +llvm::DIType CGDebugInfo::CreateType(const PointerType *Ty, llvm::DIFile Unit) { return CreatePointerLikeType(llvm::dwarf::DW_TAG_pointer_type, Ty, Ty->getPointeeType(), Unit); } /// In C++ mode, types have linkage, so we can rely on the ODR and /// on their mangled names, if they're external. -static SmallString<256> -getUniqueTagTypeName(const TagType *Ty, CodeGenModule &CGM, - llvm::DICompileUnit TheCU) { +static SmallString<256> getUniqueTagTypeName(const TagType *Ty, + CodeGenModule &CGM, + llvm::DICompileUnit TheCU) { SmallString<256> FullName; // FIXME: ODR should apply to ObjC++ exactly the same wasy it does to C++. // For now, only apply ODR with C++. @@ -685,9 +699,9 @@ llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty, unsigned Flags = llvm::DIDescriptor::FlagAppleBlock; unsigned LineNo = getLineNumber(CurLoc); - EltTy = DBuilder.createStructType(Unit, "__block_descriptor", - Unit, LineNo, FieldOffset, 0, - Flags, llvm::DIType(), Elements); + EltTy = DBuilder.createStructType(Unit, "__block_descriptor", Unit, LineNo, + FieldOffset, 0, Flags, llvm::DIType(), + Elements); // Bit size, align and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(Ty); @@ -707,43 +721,45 @@ llvm::DIType CGDebugInfo::CreateType(const BlockPointerType *Ty, FieldTy = DescTy; FieldSize = CGM.getContext().getTypeSize(Ty); FieldAlign = CGM.getContext().getTypeAlign(Ty); - FieldTy = DBuilder.createMemberType(Unit, "__descriptor", Unit, - LineNo, FieldSize, FieldAlign, - FieldOffset, 0, FieldTy); + FieldTy = + DBuilder.createMemberType(Unit, "__descriptor", Unit, LineNo, FieldSize, + FieldAlign, FieldOffset, 0, FieldTy); EltTys.push_back(FieldTy); FieldOffset += FieldSize; Elements = DBuilder.getOrCreateArray(EltTys); - EltTy = DBuilder.createStructType(Unit, "__block_literal_generic", - Unit, LineNo, FieldOffset, 0, - Flags, llvm::DIType(), Elements); + EltTy = DBuilder.createStructType(Unit, "__block_literal_generic", Unit, + LineNo, FieldOffset, 0, Flags, + llvm::DIType(), Elements); BlockLiteralGeneric = DBuilder.createPointerType(EltTy, Size); return BlockLiteralGeneric; } -llvm::DIType CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, llvm::DIFile Unit) { +llvm::DIType CGDebugInfo::CreateType(const TemplateSpecializationType *Ty, + llvm::DIFile Unit) { assert(Ty->isTypeAlias()); llvm::DIType Src = getOrCreateType(Ty->getAliasedType(), Unit); SmallString<128> NS; llvm::raw_svector_ostream OS(NS); - Ty->getTemplateName().print(OS, CGM.getContext().getPrintingPolicy(), /*qualified*/ false); + Ty->getTemplateName().print(OS, CGM.getContext().getPrintingPolicy(), + /*qualified*/ false); TemplateSpecializationType::PrintTemplateArgumentList( OS, Ty->getArgs(), Ty->getNumArgs(), CGM.getContext().getPrintingPolicy()); - TypeAliasDecl *AliasDecl = - cast(Ty->getTemplateName().getAsTemplateDecl()) - ->getTemplatedDecl(); + TypeAliasDecl *AliasDecl = cast( + Ty->getTemplateName().getAsTemplateDecl())->getTemplatedDecl(); SourceLocation Loc = AliasDecl->getLocation(); llvm::DIFile File = getOrCreateFile(Loc); unsigned Line = getLineNumber(Loc); - llvm::DIDescriptor Ctxt = getContextDescriptor(cast(AliasDecl->getDeclContext())); + llvm::DIDescriptor Ctxt = + getContextDescriptor(cast(AliasDecl->getDeclContext())); return DBuilder.createTypedef(Src, internString(OS.str()), File, Line, Ctxt); } @@ -760,10 +776,10 @@ llvm::DIType CGDebugInfo::CreateType(const TypedefType *Ty, llvm::DIFile Unit) { const TypedefNameDecl *TyDecl = Ty->getDecl(); llvm::DIDescriptor TypedefContext = - getContextDescriptor(cast(Ty->getDecl()->getDeclContext())); + getContextDescriptor(cast(Ty->getDecl()->getDeclContext())); - return - DBuilder.createTypedef(Src, TyDecl->getName(), File, Line, TypedefContext); + return DBuilder.createTypedef(Src, TyDecl->getName(), File, Line, + TypedefContext); } llvm::DIType CGDebugInfo::CreateType(const FunctionType *Ty, @@ -801,24 +817,23 @@ static unsigned getAccessFlag(AccessSpecifier Access, const RecordDecl *RD) { if (Access == Default) return 0; - switch(Access) { - case clang::AS_private: return llvm::DIDescriptor::FlagPrivate; - case clang::AS_protected: return llvm::DIDescriptor::FlagProtected; - case clang::AS_public: return llvm::DIDescriptor::FlagPublic; - case clang::AS_none: return 0; + switch (Access) { + case clang::AS_private: + return llvm::DIDescriptor::FlagPrivate; + case clang::AS_protected: + return llvm::DIDescriptor::FlagProtected; + case clang::AS_public: + return llvm::DIDescriptor::FlagPublic; + case clang::AS_none: + return 0; } llvm_unreachable("unexpected access enumerator"); } -llvm::DIType CGDebugInfo::createFieldType(StringRef name, - QualType type, - uint64_t sizeInBitsOverride, - SourceLocation loc, - AccessSpecifier AS, - uint64_t offsetInBits, - llvm::DIFile tunit, - llvm::DIScope scope, - const RecordDecl* RD) { +llvm::DIType CGDebugInfo::createFieldType( + StringRef name, QualType type, uint64_t sizeInBitsOverride, + SourceLocation loc, AccessSpecifier AS, uint64_t offsetInBits, + llvm::DIFile tunit, llvm::DIScope scope, const RecordDecl *RD) { llvm::DIType debugType = getOrCreateType(type, tunit); // Get the location for the field. @@ -842,10 +857,10 @@ llvm::DIType CGDebugInfo::createFieldType(StringRef name, } /// CollectRecordLambdaFields - Helper for CollectRecordFields. -void CGDebugInfo:: -CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, - SmallVectorImpl &elements, - llvm::DIType RecordTy) { +void +CGDebugInfo::CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, + SmallVectorImpl &elements, + llvm::DIType RecordTy) { // For C++11 Lambdas a Field will be the same as a Capture, but the Capture // has the name and the location of the variable so we should iterate over // both concurrently. @@ -853,7 +868,8 @@ CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, RecordDecl::field_iterator Field = CXXDecl->field_begin(); unsigned fieldno = 0; for (CXXRecordDecl::capture_const_iterator I = CXXDecl->captures_begin(), - E = CXXDecl->captures_end(); I != E; ++I, ++Field, ++fieldno) { + E = CXXDecl->captures_end(); + I != E; ++I, ++Field, ++fieldno) { const LambdaCapture &C = *I; if (C.capturesVariable()) { VarDecl *V = C.getCapturedVar(); @@ -864,11 +880,10 @@ CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, SizeInBitsOverride = Field->getBitWidthValue(CGM.getContext()); assert(SizeInBitsOverride && "found named 0-width bitfield"); } - llvm::DIType fieldType - = createFieldType(VName, Field->getType(), SizeInBitsOverride, - C.getLocation(), Field->getAccess(), - layout.getFieldOffset(fieldno), VUnit, RecordTy, - CXXDecl); + llvm::DIType fieldType = createFieldType( + VName, Field->getType(), SizeInBitsOverride, C.getLocation(), + Field->getAccess(), layout.getFieldOffset(fieldno), VUnit, RecordTy, + CXXDecl); elements.push_back(fieldType); } else if (C.capturesThis()) { // TODO: Need to handle 'this' in some way by probably renaming the @@ -878,10 +893,9 @@ CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, FieldDecl *f = *Field; llvm::DIFile VUnit = getOrCreateFile(f->getLocation()); QualType type = f->getType(); - llvm::DIType fieldType - = createFieldType("this", type, 0, f->getLocation(), f->getAccess(), - layout.getFieldOffset(fieldno), VUnit, RecordTy, - CXXDecl); + llvm::DIType fieldType = createFieldType( + "this", type, 0, f->getLocation(), f->getAccess(), + layout.getFieldOffset(fieldno), VUnit, RecordTy, CXXDecl); elements.push_back(fieldType); } @@ -889,10 +903,9 @@ CollectRecordLambdaFields(const CXXRecordDecl *CXXDecl, } /// Helper for CollectRecordFields. -llvm::DIDerivedType -CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, - llvm::DIType RecordTy, - const RecordDecl* RD) { +llvm::DIDerivedType CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, + llvm::DIType RecordTy, + const RecordDecl *RD) { // Create the descriptor for the static variable, with or without // constant initializers. Var = Var->getCanonicalDecl(); @@ -920,12 +933,10 @@ CGDebugInfo::CreateRecordStaticField(const VarDecl *Var, } /// CollectRecordNormalField - Helper for CollectRecordFields. -void CGDebugInfo:: -CollectRecordNormalField(const FieldDecl *field, uint64_t OffsetInBits, - llvm::DIFile tunit, - SmallVectorImpl &elements, - llvm::DIType RecordTy, - const RecordDecl* RD) { +void CGDebugInfo::CollectRecordNormalField( + const FieldDecl *field, uint64_t OffsetInBits, llvm::DIFile tunit, + SmallVectorImpl &elements, llvm::DIType RecordTy, + const RecordDecl *RD) { StringRef name = field->getName(); QualType type = field->getType(); @@ -939,10 +950,9 @@ CollectRecordNormalField(const FieldDecl *field, uint64_t OffsetInBits, assert(SizeInBitsOverride && "found named 0-width bitfield"); } - llvm::DIType fieldType - = createFieldType(name, type, SizeInBitsOverride, - field->getLocation(), field->getAccess(), - OffsetInBits, tunit, RecordTy, RD); + llvm::DIType fieldType = + createFieldType(name, type, SizeInBitsOverride, field->getLocation(), + field->getAccess(), OffsetInBits, tunit, RecordTy, RD); elements.push_back(fieldType); } @@ -980,8 +990,8 @@ void CGDebugInfo::CollectRecordFields(const RecordDecl *record, elements.push_back(Field); } } else if (const auto *field = dyn_cast(I)) { - CollectRecordNormalField(field, layout.getFieldOffset(fieldNo), - tunit, elements, RecordTy, record); + CollectRecordNormalField(field, layout.getFieldOffset(fieldNo), tunit, + elements, RecordTy, record); // Bump field number for next field. ++fieldNo; @@ -1007,7 +1017,7 @@ llvm::DICompositeType CGDebugInfo::getOrCreateInstanceMethodType( // Add "this" pointer. llvm::DITypeArray Args = llvm::DISubroutineType( getOrCreateType(QualType(Func, 0), Unit)).getTypeArray(); - assert (Args.getNumElements() && "Invalid number of arguments!"); + assert(Args.getNumElements() && "Invalid number of arguments!"); SmallVector Elts; @@ -1025,7 +1035,7 @@ llvm::DICompositeType CGDebugInfo::getOrCreateInstanceMethodType( uint64_t Align = CGM.getContext().getTypeAlign(ThisPtrTy); llvm::DIType PointeeType = getOrCreateType(PointeeTy, Unit); llvm::DIType ThisPtrType = - DBuilder.createPointerType(PointeeType, Size, Align); + DBuilder.createPointerType(PointeeType, Size, Align); TypeCache[ThisPtr.getAsOpaquePtr()] = ThisPtrType; // TODO: This and the artificial type below are misleading, the // types aren't artificial the argument is, but the current @@ -1068,10 +1078,9 @@ static bool isFunctionLocalClass(const CXXRecordDecl *RD) { /// a single member function GlobalDecl. llvm::DISubprogram CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, - llvm::DIFile Unit, - llvm::DIType RecordTy) { + llvm::DIFile Unit, llvm::DIType RecordTy) { bool IsCtorOrDtor = - isa(Method) || isa(Method); + isa(Method) || isa(Method); StringRef MethodName = getFunctionName(Method); llvm::DICompositeType MethodTy = getOrCreateMethodType(Method, Unit); @@ -1120,7 +1129,7 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, if (CXXC->isExplicit()) Flags |= llvm::DIDescriptor::FlagExplicit; } else if (const CXXConversionDecl *CXXC = - dyn_cast(Method)) { + dyn_cast(Method)) { if (CXXC->isExplicit()) Flags |= llvm::DIDescriptor::FlagExplicit; } @@ -1132,14 +1141,11 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, Flags |= llvm::DIDescriptor::FlagRValueReference; llvm::DIArray TParamsArray = CollectFunctionTemplateParams(Method, Unit); - llvm::DISubprogram SP = - DBuilder.createMethod(RecordTy, MethodName, MethodLinkageName, - MethodDefUnit, MethodLine, - MethodTy, /*isLocalToUnit=*/false, - /* isDefinition=*/ false, - Virtuality, VIndex, ContainingType, - Flags, CGM.getLangOpts().Optimize, nullptr, - TParamsArray); + llvm::DISubprogram SP = DBuilder.createMethod( + RecordTy, MethodName, MethodLinkageName, MethodDefUnit, MethodLine, + MethodTy, /*isLocalToUnit=*/false, + /* isDefinition=*/false, Virtuality, VIndex, ContainingType, Flags, + CGM.getLangOpts().Optimize, nullptr, TParamsArray); SPCache[Method->getCanonicalDecl()] = llvm::WeakVH(SP); @@ -1149,15 +1155,14 @@ CGDebugInfo::CreateCXXMemberFunction(const CXXMethodDecl *Method, /// CollectCXXMemberFunctions - A helper function to collect debug info for /// C++ member functions. This is used while creating debug info entry for /// a Record. -void CGDebugInfo:: -CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit, - SmallVectorImpl &EltTys, - llvm::DIType RecordTy) { +void CGDebugInfo::CollectCXXMemberFunctions( + const CXXRecordDecl *RD, llvm::DIFile Unit, + SmallVectorImpl &EltTys, llvm::DIType RecordTy) { // Since we want more than just the individual member decls if we // have templated functions iterate over every declaration to gather // the functions. - for(const auto *I : RD->decls()) { + for (const auto *I : RD->decls()) { const auto *Method = dyn_cast(I); // If the member is implicit, don't add it to the member list. This avoids // the member being added to type units by LLVM, while still allowing it @@ -1186,10 +1191,9 @@ CollectCXXMemberFunctions(const CXXRecordDecl *RD, llvm::DIFile Unit, /// CollectCXXBases - A helper function to collect debug info for /// C++ base classes. This is used while creating debug info entry for /// a Record. -void CGDebugInfo:: -CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit, - SmallVectorImpl &EltTys, - llvm::DIType RecordTy) { +void CGDebugInfo::CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit, + SmallVectorImpl &EltTys, + llvm::DIType RecordTy) { const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD); for (const auto &BI : RD->bases()) { @@ -1197,15 +1201,15 @@ CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit, uint64_t BaseOffset; const CXXRecordDecl *Base = - cast(BI.getType()->getAs()->getDecl()); + cast(BI.getType()->getAs()->getDecl()); if (BI.isVirtual()) { if (CGM.getTarget().getCXXABI().isItaniumFamily()) { // virtual base offset offset is -ve. The code generator emits dwarf // expression where it expects +ve number. - BaseOffset = - 0 - CGM.getItaniumVTableContext() - .getVirtualBaseOffsetOffset(RD, Base).getQuantity(); + BaseOffset = 0 - CGM.getItaniumVTableContext() + .getVirtualBaseOffsetOffset(RD, Base) + .getQuantity(); } else { // In the MS ABI, store the vbtable offset, which is analogous to the // vbase offset offset in Itanium. @@ -1219,19 +1223,17 @@ CollectCXXBases(const CXXRecordDecl *RD, llvm::DIFile Unit, // BI->isVirtual() and bits when not. BFlags |= getAccessFlag(BI.getAccessSpecifier(), RD); - llvm::DIType DTy = - DBuilder.createInheritance(RecordTy, - getOrCreateType(BI.getType(), Unit), - BaseOffset, BFlags); + llvm::DIType DTy = DBuilder.createInheritance( + RecordTy, getOrCreateType(BI.getType(), Unit), BaseOffset, BFlags); EltTys.push_back(DTy); } } /// CollectTemplateParams - A helper function to collect template parameters. -llvm::DIArray CGDebugInfo:: -CollectTemplateParams(const TemplateParameterList *TPList, - ArrayRef TAList, - llvm::DIFile Unit) { +llvm::DIArray +CGDebugInfo::CollectTemplateParams(const TemplateParameterList *TPList, + ArrayRef TAList, + llvm::DIFile Unit) { SmallVector TemplateParams; for (unsigned i = 0, e = TAList.size(); i != e; ++i) { const TemplateArgument &TA = TAList[i]; @@ -1277,7 +1279,7 @@ CollectTemplateParams(const TemplateParameterList *TPList, // CodeGenModule::getMemberPointerConstant uint64_t fieldOffset = CGM.getContext().getFieldOffset(D); CharUnits chars = - CGM.getContext().toCharUnitsFromBits((int64_t) fieldOffset); + CGM.getContext().toCharUnitsFromBits((int64_t)fieldOffset); V = CGM.getCXXABI().EmitMemberDataPointer(MPT, chars); } llvm::DITemplateValueParameter TVP = @@ -1307,18 +1309,16 @@ CollectTemplateParams(const TemplateParameterList *TPList, TemplateParams.push_back(TVP); } break; case TemplateArgument::Template: { - llvm::DITemplateValueParameter TVP = - DBuilder.createTemplateTemplateParameter( - TheCU, Name, llvm::DIType(), - TA.getAsTemplate().getAsTemplateDecl() - ->getQualifiedNameAsString()); + llvm::DITemplateValueParameter + TVP = DBuilder.createTemplateTemplateParameter( + TheCU, Name, llvm::DIType(), + TA.getAsTemplate().getAsTemplateDecl()->getQualifiedNameAsString()); TemplateParams.push_back(TVP); } break; case TemplateArgument::Pack: { - llvm::DITemplateValueParameter TVP = - DBuilder.createTemplateParameterPack( - TheCU, Name, llvm::DIType(), - CollectTemplateParams(nullptr, TA.getPackAsArray(), Unit)); + llvm::DITemplateValueParameter TVP = DBuilder.createTemplateParameterPack( + TheCU, Name, llvm::DIType(), + CollectTemplateParams(nullptr, TA.getPackAsArray(), Unit)); TemplateParams.push_back(TVP); } break; case TemplateArgument::Expression: { @@ -1346,13 +1346,13 @@ CollectTemplateParams(const TemplateParameterList *TPList, /// CollectFunctionTemplateParams - A helper function to collect debug /// info for function template parameters. -llvm::DIArray CGDebugInfo:: -CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit) { +llvm::DIArray CGDebugInfo::CollectFunctionTemplateParams(const FunctionDecl *FD, + llvm::DIFile Unit) { if (FD->getTemplatedKind() == FunctionDecl::TK_FunctionTemplateSpecialization) { - const TemplateParameterList *TList = - FD->getTemplateSpecializationInfo()->getTemplate() - ->getTemplateParameters(); + const TemplateParameterList *TList = FD->getTemplateSpecializationInfo() + ->getTemplate() + ->getTemplateParameters(); return CollectTemplateParams( TList, FD->getTemplateSpecializationArgs()->asArray(), Unit); } @@ -1361,13 +1361,12 @@ CollectFunctionTemplateParams(const FunctionDecl *FD, llvm::DIFile Unit) { /// CollectCXXTemplateParams - A helper function to collect debug info for /// template parameters. -llvm::DIArray CGDebugInfo:: -CollectCXXTemplateParams(const ClassTemplateSpecializationDecl *TSpecial, - llvm::DIFile Unit) { +llvm::DIArray CGDebugInfo::CollectCXXTemplateParams( + const ClassTemplateSpecializationDecl *TSpecial, llvm::DIFile Unit) { // Always get the full list of parameters, not just the ones from // the specialization. TemplateParameterList *TPList = - TSpecial->getSpecializedTemplate()->getTemplateParameters(); + TSpecial->getSpecializedTemplate()->getTemplateParameters(); const TemplateArgumentList &TAList = TSpecial->getTemplateArgs(); return CollectTemplateParams(TPList, TAList.asArray(), Unit); } @@ -1384,8 +1383,8 @@ llvm::DIType CGDebugInfo::getOrCreateVTablePtrType(llvm::DIFile Unit) { llvm::DITypeArray SElements = DBuilder.getOrCreateTypeArray(STy); llvm::DIType SubTy = DBuilder.createSubroutineType(Unit, SElements); unsigned Size = Context.getTypeSize(Context.VoidPtrTy); - llvm::DIType vtbl_ptr_type = DBuilder.createPointerType(SubTy, Size, 0, - "__vtbl_ptr_type"); + llvm::DIType vtbl_ptr_type = + DBuilder.createPointerType(SubTy, Size, 0, "__vtbl_ptr_type"); VTablePtrType = DBuilder.createPointerType(vtbl_ptr_type, Size); return VTablePtrType; } @@ -1396,12 +1395,10 @@ StringRef CGDebugInfo::getVTableName(const CXXRecordDecl *RD) { return internString("_vptr$", RD->getNameAsString()); } - /// CollectVTableInfo - If the C++ class has vtable info then insert appropriate /// debug info entry in EltTys vector. -void CGDebugInfo:: -CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit, - SmallVectorImpl &EltTys) { +void CGDebugInfo::CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit, + SmallVectorImpl &EltTys) { const ASTRecordLayout &RL = CGM.getContext().getASTRecordLayout(RD); // If there is a primary base then it will hold vtable info. @@ -1413,11 +1410,9 @@ CollectVTableInfo(const CXXRecordDecl *RD, llvm::DIFile Unit, return; unsigned Size = CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy); - llvm::DIType VPTR - = DBuilder.createMemberType(Unit, getVTableName(RD), Unit, - 0, Size, 0, 0, - llvm::DIDescriptor::FlagArtificial, - getOrCreateVTablePtrType(Unit)); + llvm::DIType VPTR = DBuilder.createMemberType( + Unit, getVTableName(RD), Unit, 0, Size, 0, 0, + llvm::DIDescriptor::FlagArtificial, getOrCreateVTablePtrType(Unit)); EltTys.push_back(VPTR); } @@ -1443,7 +1438,7 @@ void CGDebugInfo::completeType(const EnumDecl *ED) { if (DebugKind <= CodeGenOptions::DebugLineTablesOnly) return; QualType Ty = CGM.getContext().getEnumType(ED); - void* TyPtr = Ty.getAsOpaquePtr(); + void *TyPtr = Ty.getAsOpaquePtr(); auto I = TypeCache.find(TyPtr); if (I == TypeCache.end() || !llvm::DIType(cast(static_cast(I->second))) @@ -1478,7 +1473,7 @@ void CGDebugInfo::completeClassData(const RecordDecl *RD) { if (DebugKind <= CodeGenOptions::DebugLineTablesOnly) return; QualType Ty = CGM.getContext().getRecordType(RD); - void* TyPtr = Ty.getAsOpaquePtr(); + void *TyPtr = Ty.getAsOpaquePtr(); auto I = TypeCache.find(TyPtr); if (I != TypeCache.end() && !llvm::DIType(cast(static_cast(I->second))) @@ -1609,7 +1604,6 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCObjectType *Ty, return getOrCreateType(Ty->getBaseType(), Unit); } - /// \return true if Getter has the default name for the property PD. static bool hasDefaultGetterName(const ObjCPropertyDecl *PD, const ObjCMethodDecl *Getter) { @@ -1619,7 +1613,7 @@ static bool hasDefaultGetterName(const ObjCPropertyDecl *PD, assert(Getter->getDeclName().isObjCZeroArgSelector()); return PD->getName() == - Getter->getDeclName().getObjCSelector().getNameForSlot(0); + Getter->getDeclName().getObjCSelector().getNameForSlot(0); } /// \return true if Setter has the default name for the property PD. @@ -1631,7 +1625,7 @@ static bool hasDefaultSetterName(const ObjCPropertyDecl *PD, assert(Setter->getDeclName().isObjCOneArgSelector()); return SelectorTable::constructSetterName(PD->getName()) == - Setter->getDeclName().getObjCSelector().getNameForSlot(0); + Setter->getDeclName().getObjCSelector().getNameForSlot(0); } /// CreateType - get objective-c interface type. @@ -1657,11 +1651,11 @@ llvm::DIType CGDebugInfo::CreateType(const ObjCInterfaceType *Ty, return FwdDecl; } - return CreateTypeDefinition(Ty, Unit); } -llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm::DIFile Unit) { +llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, + llvm::DIFile Unit) { ObjCInterfaceDecl *ID = Ty->getDecl(); llvm::DIFile DefUnit = getOrCreateFile(ID->getLocation()); unsigned Line = getLineNumber(ID->getLocation()); @@ -1675,16 +1669,15 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm if (ID->getImplementation()) Flags |= llvm::DIDescriptor::FlagObjcClassComplete; - llvm::DICompositeType RealDecl = - DBuilder.createStructType(Unit, ID->getName(), DefUnit, - Line, Size, Align, Flags, - llvm::DIType(), llvm::DIArray(), RuntimeLang); + llvm::DICompositeType RealDecl = DBuilder.createStructType( + Unit, ID->getName(), DefUnit, Line, Size, Align, Flags, llvm::DIType(), + llvm::DIArray(), RuntimeLang); QualType QTy(Ty, 0); TypeCache[QTy.getAsOpaquePtr()] = RealDecl; // Push the struct on region stack. - LexicalBlockStack.push_back(static_cast(RealDecl)); + LexicalBlockStack.push_back(static_cast(RealDecl)); RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl); // Convert all the elements. @@ -1693,12 +1686,11 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm ObjCInterfaceDecl *SClass = ID->getSuperClass(); if (SClass) { llvm::DIType SClassTy = - getOrCreateType(CGM.getContext().getObjCInterfaceType(SClass), Unit); + getOrCreateType(CGM.getContext().getObjCInterfaceType(SClass), Unit); if (!SClassTy.isValid()) return llvm::DIType(); - llvm::DIType InhTag = - DBuilder.createInheritance(RealDecl, SClassTy, 0, 0); + llvm::DIType InhTag = DBuilder.createInheritance(RealDecl, SClassTy, 0, 0); EltTys.push_back(InhTag); } @@ -1709,15 +1701,13 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm unsigned PLine = getLineNumber(Loc); ObjCMethodDecl *Getter = PD->getGetterMethodDecl(); ObjCMethodDecl *Setter = PD->getSetterMethodDecl(); - llvm::MDNode *PropertyNode = - DBuilder.createObjCProperty(PD->getName(), - PUnit, PLine, - hasDefaultGetterName(PD, Getter) ? "" : - getSelectorName(PD->getGetterName()), - hasDefaultSetterName(PD, Setter) ? "" : - getSelectorName(PD->getSetterName()), - PD->getPropertyAttributes(), - getOrCreateType(PD->getType(), PUnit)); + llvm::MDNode *PropertyNode = DBuilder.createObjCProperty( + PD->getName(), PUnit, PLine, + hasDefaultGetterName(PD, Getter) ? "" + : getSelectorName(PD->getGetterName()), + hasDefaultSetterName(PD, Setter) ? "" + : getSelectorName(PD->getSetterName()), + PD->getPropertyAttributes(), getOrCreateType(PD->getType(), PUnit)); EltTys.push_back(PropertyNode); } @@ -1757,8 +1747,8 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm // non-fragile ABI. For bitfields, use the bit offset into the first // byte of storage of the bitfield. For other fields, use zero. if (Field->isBitField()) { - FieldOffset = CGM.getObjCRuntime().ComputeBitfieldBitOffset( - CGM, ID, Field); + FieldOffset = + CGM.getObjCRuntime().ComputeBitfieldBitOffset(CGM, ID, Field); FieldOffset %= CGM.getContext().getCharWidth(); } else { FieldOffset = 0; @@ -1778,29 +1768,27 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty, llvm llvm::MDNode *PropertyNode = nullptr; if (ObjCImplementationDecl *ImpD = ID->getImplementation()) { if (ObjCPropertyImplDecl *PImpD = - ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) { + ImpD->FindPropertyImplIvarDecl(Field->getIdentifier())) { if (ObjCPropertyDecl *PD = PImpD->getPropertyDecl()) { SourceLocation Loc = PD->getLocation(); llvm::DIFile PUnit = getOrCreateFile(Loc); unsigned PLine = getLineNumber(Loc); ObjCMethodDecl *Getter = PD->getGetterMethodDecl(); ObjCMethodDecl *Setter = PD->getSetterMethodDecl(); - PropertyNode = - DBuilder.createObjCProperty(PD->getName(), - PUnit, PLine, - hasDefaultGetterName(PD, Getter) ? "" : - getSelectorName(PD->getGetterName()), - hasDefaultSetterName(PD, Setter) ? "" : - getSelectorName(PD->getSetterName()), - PD->getPropertyAttributes(), - getOrCreateType(PD->getType(), PUnit)); + PropertyNode = DBuilder.createObjCProperty( + PD->getName(), PUnit, PLine, + hasDefaultGetterName(PD, Getter) ? "" : getSelectorName( + PD->getGetterName()), + hasDefaultSetterName(PD, Setter) ? "" : getSelectorName( + PD->getSetterName()), + PD->getPropertyAttributes(), + getOrCreateType(PD->getType(), PUnit)); } } } - FieldTy = DBuilder.createObjCIVar(FieldName, FieldDefUnit, - FieldLine, FieldSize, FieldAlign, - FieldOffset, Flags, FieldTy, - PropertyNode); + FieldTy = DBuilder.createObjCIVar(FieldName, FieldDefUnit, FieldLine, + FieldSize, FieldAlign, FieldOffset, Flags, + FieldTy, PropertyNode); EltTys.push_back(FieldTy); } @@ -1828,8 +1816,7 @@ llvm::DIType CGDebugInfo::CreateType(const VectorType *Ty, llvm::DIFile Unit) { return DBuilder.createVectorType(Size, Align, ElementTy, SubscriptArray); } -llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, - llvm::DIFile Unit) { +llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIFile Unit) { uint64_t Size; uint64_t Align; @@ -1837,7 +1824,7 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, if (const VariableArrayType *VAT = dyn_cast(Ty)) { Size = 0; Align = - CGM.getContext().getTypeAlign(CGM.getContext().getBaseElementType(VAT)); + CGM.getContext().getTypeAlign(CGM.getContext().getBaseElementType(VAT)); } else if (Ty->isIncompleteArrayType()) { Size = 0; if (Ty->getElementType()->isIncompleteType()) @@ -1866,7 +1853,7 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, // struct foo { // int x[0]; // }; - int64_t Count = -1; // Count == -1 is an unbounded array. + int64_t Count = -1; // Count == -1 is an unbounded array. if (const ConstantArrayType *CAT = dyn_cast(Ty)) Count = CAT->getSize().getZExtValue(); @@ -1877,22 +1864,21 @@ llvm::DIType CGDebugInfo::CreateType(const ArrayType *Ty, llvm::DIArray SubscriptArray = DBuilder.getOrCreateArray(Subscripts); - llvm::DIType DbgTy = - DBuilder.createArrayType(Size, Align, getOrCreateType(EltTy, Unit), - SubscriptArray); + llvm::DIType DbgTy = DBuilder.createArrayType( + Size, Align, getOrCreateType(EltTy, Unit), SubscriptArray); return DbgTy; } llvm::DIType CGDebugInfo::CreateType(const LValueReferenceType *Ty, llvm::DIFile Unit) { - return CreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type, - Ty, Ty->getPointeeType(), Unit); + return CreatePointerLikeType(llvm::dwarf::DW_TAG_reference_type, Ty, + Ty->getPointeeType(), Unit); } llvm::DIType CGDebugInfo::CreateType(const RValueReferenceType *Ty, llvm::DIFile Unit) { - return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, - Ty, Ty->getPointeeType(), Unit); + return CreatePointerLikeType(llvm::dwarf::DW_TAG_rvalue_reference_type, Ty, + Ty->getPointeeType(), Unit); } llvm::DIType CGDebugInfo::CreateType(const MemberPointerType *Ty, @@ -1903,15 +1889,15 @@ llvm::DIType CGDebugInfo::CreateType(const MemberPointerType *Ty, getOrCreateType(Ty->getPointeeType(), U), ClassType); const FunctionProtoType *FPT = - Ty->getPointeeType()->getAs(); - return DBuilder.createMemberPointerType(getOrCreateInstanceMethodType( - CGM.getContext().getPointerType(QualType(Ty->getClass(), - FPT->getTypeQuals())), - FPT, U), ClassType); + Ty->getPointeeType()->getAs(); + return DBuilder.createMemberPointerType( + getOrCreateInstanceMethodType(CGM.getContext().getPointerType(QualType( + Ty->getClass(), FPT->getTypeQuals())), + FPT, U), + ClassType); } -llvm::DIType CGDebugInfo::CreateType(const AtomicType *Ty, - llvm::DIFile U) { +llvm::DIType CGDebugInfo::CreateType(const AtomicType *Ty, llvm::DIFile U) { // Ignore the atomic wrapping // FIXME: What is the correct representation? return getOrCreateType(Ty->getValueType(), U); @@ -1962,9 +1948,8 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { SmallVector Enumerators; ED = ED->getDefinition(); for (const auto *Enum : ED->enumerators()) { - Enumerators.push_back( - DBuilder.createEnumerator(Enum->getName(), - Enum->getInitVal().getSExtValue())); + Enumerators.push_back(DBuilder.createEnumerator( + Enum->getName(), Enum->getInitVal().getSExtValue())); } // Return a CompositeType for the enum itself. @@ -1973,13 +1958,13 @@ llvm::DIType CGDebugInfo::CreateTypeDefinition(const EnumType *Ty) { llvm::DIFile DefUnit = getOrCreateFile(ED->getLocation()); unsigned Line = getLineNumber(ED->getLocation()); llvm::DIDescriptor EnumContext = - getContextDescriptor(cast(ED->getDeclContext())); - llvm::DIType ClassTy = ED->isFixed() ? - getOrCreateType(ED->getIntegerType(), DefUnit) : llvm::DIType(); + getContextDescriptor(cast(ED->getDeclContext())); + llvm::DIType ClassTy = ED->isFixed() + ? getOrCreateType(ED->getIntegerType(), DefUnit) + : llvm::DIType(); llvm::DIType DbgTy = - DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit, Line, - Size, Align, EltArray, - ClassTy, FullName); + DBuilder.createEnumerationType(EnumContext, ED->getName(), DefUnit, Line, + Size, Align, EltArray, ClassTy, FullName); return DbgTy; } @@ -2000,7 +1985,8 @@ static QualType UnwrapTypeForDebugInfo(QualType T, const ASTContext &C) { if (Spec->isTypeAlias()) return C.getQualifiedType(T.getTypePtr(), Quals); T = Spec->desugar(); - break; } + break; + } case Type::TypeOfExpr: T = cast(T)->getUnderlyingExpr()->getType(); break; @@ -2080,7 +2066,7 @@ llvm::DIType CGDebugInfo::getOrCreateType(QualType Ty, llvm::DIFile Unit) { // Otherwise create the type. llvm::DIType Res = CreateTypeNode(Ty, Unit); - void* TyPtr = Ty.getAsOpaquePtr(); + void *TyPtr = Ty.getAsOpaquePtr(); // And update the type cache. TypeCache[TyPtr] = Res; @@ -2105,8 +2091,8 @@ unsigned CGDebugInfo::Checksum(const ObjCInterfaceDecl *ID) { ObjCInterfaceDecl *CGDebugInfo::getObjCInterfaceDecl(QualType Ty) { switch (Ty->getTypeClass()) { case Type::ObjCObjectPointer: - return getObjCInterfaceDecl(cast(Ty) - ->getPointeeType()); + return getObjCInterfaceDecl( + cast(Ty)->getPointeeType()); case Type::ObjCInterface: return cast(Ty)->getDecl(); default: @@ -2197,10 +2183,10 @@ llvm::DIType CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile Unit) { } assert(Diag && "Fall through without a diagnostic?"); - unsigned DiagID = CGM.getDiags().getCustomDiagID(DiagnosticsEngine::Error, - "debug information for %0 is not yet supported"); - CGM.getDiags().Report(DiagID) - << Diag; + unsigned DiagID = CGM.getDiags().getCustomDiagID( + DiagnosticsEngine::Error, + "debug information for %0 is not yet supported"); + CGM.getDiags().Report(DiagID) << Diag; return llvm::DIType(); } @@ -2215,7 +2201,8 @@ llvm::DIType CGDebugInfo::getOrCreateLimitedType(const RecordType *Ty, // We may have cached a forward decl when we could have created // a non-forward decl. Go ahead and create a non-forward decl // now. - if (T && !T.isForwardDecl()) return T; + if (T && !T.isForwardDecl()) + return T; // Otherwise create the type. llvm::DICompositeType Res = CreateLimitedType(Ty); @@ -2246,7 +2233,7 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { // just return that. llvm::DICompositeType T(getTypeOrNull(CGM.getContext().getRecordType(RD))); if (T && (!T.isForwardDecl() || !RD->getDefinition())) - return T; + return T; // If this is just a forward or incomplete declaration, construct an // appropriately marked node and just return it. @@ -2261,21 +2248,18 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU); if (RD->isUnion()) - RealDecl = DBuilder.createUnionType(RDContext, RDName, DefUnit, Line, - Size, Align, 0, llvm::DIArray(), 0, - FullName); + RealDecl = DBuilder.createUnionType(RDContext, RDName, DefUnit, Line, Size, + Align, 0, llvm::DIArray(), 0, FullName); else if (RD->isClass()) { // FIXME: This could be a struct type giving a default visibility different // than C++ class type, but needs llvm metadata changes first. - RealDecl = DBuilder.createClassType(RDContext, RDName, DefUnit, Line, - Size, Align, 0, 0, llvm::DIType(), - llvm::DIArray(), llvm::DIType(), - llvm::DIArray(), FullName); + RealDecl = DBuilder.createClassType( + RDContext, RDName, DefUnit, Line, Size, Align, 0, 0, llvm::DIType(), + llvm::DIArray(), llvm::DIType(), llvm::DIArray(), FullName); } else - RealDecl = DBuilder.createStructType(RDContext, RDName, DefUnit, Line, - Size, Align, 0, llvm::DIType(), - llvm::DIArray(), 0, llvm::DIType(), - FullName); + RealDecl = DBuilder.createStructType( + RDContext, RDName, DefUnit, Line, Size, Align, 0, llvm::DIType(), + llvm::DIArray(), 0, llvm::DIType(), FullName); RegionMap[Ty->getDecl()] = llvm::WeakVH(RealDecl); TypeCache[QualType(Ty, 0).getAsOpaquePtr()] = RealDecl; @@ -2283,7 +2267,7 @@ llvm::DICompositeType CGDebugInfo::CreateLimitedType(const RecordType *Ty) { if (const ClassTemplateSpecializationDecl *TSpecial = dyn_cast(RD)) RealDecl.setArrays(llvm::DIArray(), - CollectCXXTemplateParams(TSpecial, DefUnit)); + CollectCXXTemplateParams(TSpecial, DefUnit)); return RealDecl; } @@ -2313,14 +2297,12 @@ void CGDebugInfo::CollectContainingType(const CXXRecordDecl *RD, /// CreateMemberType - Create new member and increase Offset by FType's size. llvm::DIType CGDebugInfo::CreateMemberType(llvm::DIFile Unit, QualType FType, - StringRef Name, - uint64_t *Offset) { + StringRef Name, uint64_t *Offset) { llvm::DIType FieldTy = CGDebugInfo::getOrCreateType(FType, Unit); uint64_t FieldSize = CGM.getContext().getTypeSize(FType); unsigned FieldAlign = CGM.getContext().getTypeAlign(FType); - llvm::DIType Ty = DBuilder.createMemberType(Unit, Name, Unit, 0, - FieldSize, FieldAlign, - *Offset, 0, FieldTy); + llvm::DIType Ty = DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize, + FieldAlign, *Offset, 0, FieldTy); *Offset += FieldSize; return Ty; } @@ -2355,13 +2337,14 @@ llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) { return llvm::DISubprogram(); const FunctionDecl *FD = dyn_cast(D); - if (!FD) return llvm::DISubprogram(); + if (!FD) + return llvm::DISubprogram(); // Setup context. llvm::DIScope S = getContextDescriptor(cast(D->getDeclContext())); - llvm::DenseMap::iterator - MI = SPCache.find(FD->getCanonicalDecl()); + llvm::DenseMap::iterator MI = + SPCache.find(FD->getCanonicalDecl()); if (MI == SPCache.end()) { if (const CXXMethodDecl *MD = dyn_cast(FD->getCanonicalDecl())) { @@ -2379,8 +2362,8 @@ llvm::DISubprogram CGDebugInfo::getFunctionDeclaration(const Decl *D) { } for (auto NextFD : FD->redecls()) { - llvm::DenseMap::iterator - MI = SPCache.find(NextFD->getCanonicalDecl()); + llvm::DenseMap::iterator MI = + SPCache.find(NextFD->getCanonicalDecl()); if (MI != SPCache.end()) { llvm::Value *V = MI->second; llvm::DISubprogram SP(dyn_cast_or_null(V)); @@ -2416,7 +2399,7 @@ llvm::DICompositeType CGDebugInfo::getOrCreateFunctionType(const Decl *D, // Replace the instancetype keyword with the actual type. if (ResultTy == CGM.getContext().getObjCInstanceType()) ResultTy = CGM.getContext().getPointerType( - QualType(OMethod->getClassInterface()->getTypeForDecl(), 0)); + QualType(OMethod->getClassInterface()->getTypeForDecl(), 0)); Elts.push_back(getOrCreateType(ResultTy, F)); // "self" pointer is always first argument. @@ -2455,12 +2438,9 @@ llvm::DICompositeType CGDebugInfo::getOrCreateFunctionType(const Decl *D, } /// EmitFunctionStart - Constructs the debug code for entering a function. -void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, - SourceLocation Loc, - SourceLocation ScopeLoc, - QualType FnType, - llvm::Function *Fn, - CGBuilderTy &Builder) { +void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, SourceLocation Loc, + SourceLocation ScopeLoc, QualType FnType, + llvm::Function *Fn, CGBuilderTy &Builder) { StringRef Name; StringRef LinkageName; @@ -2479,8 +2459,8 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, LinkageName = Fn->getName(); } else if (const FunctionDecl *FD = dyn_cast(D)) { // If there is a DISubprogram for this function available then use it. - llvm::DenseMap::iterator - FI = SPCache.find(FD->getCanonicalDecl()); + llvm::DenseMap::iterator FI = + SPCache.find(FD->getCanonicalDecl()); if (FI != SPCache.end()) { llvm::Value *V = FI->second; llvm::DIDescriptor SP(dyn_cast_or_null(V)); @@ -2542,13 +2522,11 @@ void CGDebugInfo::EmitFunctionStart(GlobalDecl GD, // FunctionDecls. When/if we fix this we can have FDContext be TheCU/null for // all subprograms instead of the actual context since subprogram definitions // are emitted as CU level entities by the backend. - llvm::DISubprogram SP = - DBuilder.createFunction(FDContext, Name, LinkageName, Unit, LineNo, - getOrCreateFunctionType(D, FnType, Unit), - Fn->hasInternalLinkage(), true /*definition*/, - ScopeLine, Flags, - CGM.getLangOpts().Optimize, Fn, TParamsArray, - getFunctionDeclaration(D)); + llvm::DISubprogram SP = DBuilder.createFunction( + FDContext, Name, LinkageName, Unit, LineNo, + getOrCreateFunctionType(D, FnType, Unit), Fn->hasInternalLinkage(), + true /*definition*/, ScopeLine, Flags, CGM.getLangOpts().Optimize, Fn, + TParamsArray, getFunctionDeclaration(D)); if (HasDecl) DeclCache.insert(std::make_pair(D->getCanonicalDecl(), llvm::WeakVH(SP))); @@ -2568,7 +2546,8 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc, // Update our current location setLocation(Loc); - if (CurLoc.isInvalid() || CurLoc.isMacroID()) return; + if (CurLoc.isInvalid() || CurLoc.isMacroID()) + return; // Don't bother if things are the same as last time. SourceManager &SM = CGM.getContext().getSourceManager(); @@ -2577,17 +2556,15 @@ void CGDebugInfo::EmitLocation(CGBuilderTy &Builder, SourceLocation Loc, // New Builder may not be in sync with CGDebugInfo. if (!Builder.getCurrentDebugLocation().isUnknown() && Builder.getCurrentDebugLocation().getScope(CGM.getLLVMContext()) == - LexicalBlockStack.back()) + LexicalBlockStack.back()) return; // Update last state. PrevLoc = CurLoc; llvm::MDNode *Scope = LexicalBlockStack.back(); - Builder.SetCurrentDebugLocation(llvm::DebugLoc::get - (getLineNumber(CurLoc), - getColumnNumber(CurLoc, ForceColumnInfo), - Scope)); + Builder.SetCurrentDebugLocation(llvm::DebugLoc::get( + getLineNumber(CurLoc), getColumnNumber(CurLoc, ForceColumnInfo), Scope)); } /// CreateLexicalBlock - Creates a new lexical block node and pushes it on @@ -2609,9 +2586,8 @@ void CGDebugInfo::EmitLexicalBlockStart(CGBuilderTy &Builder, setLocation(Loc); // Emit a line table change for the current location inside the new scope. - Builder.SetCurrentDebugLocation(llvm::DebugLoc::get(getLineNumber(Loc), - getColumnNumber(Loc), - LexicalBlockStack.back())); + Builder.SetCurrentDebugLocation(llvm::DebugLoc::get( + getLineNumber(Loc), getColumnNumber(Loc), LexicalBlockStack.back())); if (DebugKind <= CodeGenOptions::DebugLineTablesOnly) return; @@ -2674,31 +2650,29 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, bool HasCopyAndDispose = CGM.getContext().BlockRequiresCopying(Type, VD); if (HasCopyAndDispose) { FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - EltTys.push_back(CreateMemberType(Unit, FType, "__copy_helper", - &FieldOffset)); - EltTys.push_back(CreateMemberType(Unit, FType, "__destroy_helper", - &FieldOffset)); + EltTys.push_back( + CreateMemberType(Unit, FType, "__copy_helper", &FieldOffset)); + EltTys.push_back( + CreateMemberType(Unit, FType, "__destroy_helper", &FieldOffset)); } bool HasByrefExtendedLayout; Qualifiers::ObjCLifetime Lifetime; - if (CGM.getContext().getByrefLifetime(Type, - Lifetime, HasByrefExtendedLayout) - && HasByrefExtendedLayout) { + if (CGM.getContext().getByrefLifetime(Type, Lifetime, + HasByrefExtendedLayout) && + HasByrefExtendedLayout) { FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy); - EltTys.push_back(CreateMemberType(Unit, FType, - "__byref_variable_layout", - &FieldOffset)); + EltTys.push_back( + CreateMemberType(Unit, FType, "__byref_variable_layout", &FieldOffset)); } CharUnits Align = CGM.getContext().getDeclAlign(VD); if (Align > CGM.getContext().toCharUnitsFromBits( - CGM.getTarget().getPointerAlign(0))) { - CharUnits FieldOffsetInBytes - = CGM.getContext().toCharUnitsFromBits(FieldOffset); - CharUnits AlignedOffsetInBytes - = FieldOffsetInBytes.RoundUpToAlignment(Align); - CharUnits NumPaddingBytes - = AlignedOffsetInBytes - FieldOffsetInBytes; + CGM.getTarget().getPointerAlign(0))) { + CharUnits FieldOffsetInBytes = + CGM.getContext().toCharUnitsFromBits(FieldOffset); + CharUnits AlignedOffsetInBytes = + FieldOffsetInBytes.RoundUpToAlignment(Align); + CharUnits NumPaddingBytes = AlignedOffsetInBytes - FieldOffsetInBytes; if (NumPaddingBytes.isPositive()) { llvm::APInt pad(32, NumPaddingBytes.getQuantity()); @@ -2714,9 +2688,8 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, FieldAlign = CGM.getContext().toBits(Align); *XOffset = FieldOffset; - FieldTy = DBuilder.createMemberType(Unit, VD->getName(), Unit, - 0, FieldSize, FieldAlign, - FieldOffset, 0, FieldTy); + FieldTy = DBuilder.createMemberType(Unit, VD->getName(), Unit, 0, FieldSize, + FieldAlign, FieldOffset, 0, FieldTy); EltTys.push_back(FieldTy); FieldOffset += FieldSize; @@ -2730,8 +2703,8 @@ llvm::DIType CGDebugInfo::EmitTypeForVarWithBlocksAttr(const VarDecl *VD, /// EmitDeclare - Emit local variable declaration debug info. void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::LLVMConstants Tag, - llvm::Value *Storage, - unsigned ArgNo, CGBuilderTy &Builder) { + llvm::Value *Storage, unsigned ArgNo, + CGBuilderTy &Builder) { assert(DebugKind >= CodeGenOptions::LimitedDebugInfo); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); @@ -2785,7 +2758,7 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::LLVMConstants Tag, addr.push_back(llvm::dwarf::DW_OP_plus); // offset of __forwarding field offset = CGM.getContext().toCharUnitsFromBits( - CGM.getTarget().getPointerWidth(0)); + CGM.getTarget().getPointerWidth(0)); addr.push_back(offset.getQuantity()); addr.push_back(llvm::dwarf::DW_OP_deref); addr.push_back(llvm::dwarf::DW_OP_plus); @@ -2794,14 +2767,13 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::LLVMConstants Tag, addr.push_back(offset.getQuantity()); // Create the descriptor for the variable. - llvm::DIVariable D = - DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope), - VD->getName(), Unit, Line, Ty, ArgNo); + llvm::DIVariable D = DBuilder.createLocalVariable( + Tag, llvm::DIDescriptor(Scope), VD->getName(), Unit, Line, Ty, ArgNo); // Insert an llvm.dbg.declare into the current block. llvm::Instruction *Call = - DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), - Builder.GetInsertBlock()); + DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), + Builder.GetInsertBlock()); Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); return; } else if (isa(VD->getType())) @@ -2820,16 +2792,13 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::LLVMConstants Tag, continue; // Use VarDecl's Tag, Scope and Line number. - llvm::DIVariable D = - DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope), - FieldName, Unit, Line, FieldTy, - CGM.getLangOpts().Optimize, Flags, - ArgNo); + llvm::DIVariable D = DBuilder.createLocalVariable( + Tag, llvm::DIDescriptor(Scope), FieldName, Unit, Line, FieldTy, + CGM.getLangOpts().Optimize, Flags, ArgNo); // Insert an llvm.dbg.declare into the current block. - llvm::Instruction *Call = - DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(), - Builder.GetInsertBlock()); + llvm::Instruction *Call = DBuilder.insertDeclare( + Storage, D, DBuilder.createExpression(), Builder.GetInsertBlock()); Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); } return; @@ -2837,15 +2806,13 @@ void CGDebugInfo::EmitDeclare(const VarDecl *VD, llvm::dwarf::LLVMConstants Tag, } // Create the descriptor for the variable. - llvm::DIVariable D = - DBuilder.createLocalVariable(Tag, llvm::DIDescriptor(Scope), - Name, Unit, Line, Ty, - CGM.getLangOpts().Optimize, Flags, ArgNo); + llvm::DIVariable D = DBuilder.createLocalVariable( + Tag, llvm::DIDescriptor(Scope), Name, Unit, Line, Ty, + CGM.getLangOpts().Optimize, Flags, ArgNo); // Insert an llvm.dbg.declare into the current block. - llvm::Instruction *Call = - DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(), - Builder.GetInsertBlock()); + llvm::Instruction *Call = DBuilder.insertDeclare( + Storage, D, DBuilder.createExpression(), Builder.GetInsertBlock()); Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, Scope)); } @@ -2865,14 +2832,14 @@ void CGDebugInfo::EmitDeclareOfAutoVariable(const VarDecl *VD, llvm::DIType CGDebugInfo::CreateSelfType(const QualType &QualTy, llvm::DIType Ty) { llvm::DIType CachedTy = getTypeOrNull(QualTy); - if (CachedTy) Ty = CachedTy; + if (CachedTy) + Ty = CachedTy; return DBuilder.createObjectPointerType(Ty); } -void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(const VarDecl *VD, - llvm::Value *Storage, - CGBuilderTy &Builder, - const CGBlockInfo &blockInfo) { +void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable( + const VarDecl *VD, llvm::Value *Storage, CGBuilderTy &Builder, + const CGBlockInfo &blockInfo) { assert(DebugKind >= CodeGenOptions::LimitedDebugInfo); assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!"); @@ -2901,7 +2868,7 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(const VarDecl *VD, const llvm::DataLayout &target = CGM.getDataLayout(); CharUnits offset = CharUnits::fromQuantity( - target.getStructLayout(blockInfo.StructureType) + target.getStructLayout(blockInfo.StructureType) ->getElementOffset(blockInfo.getCapture(VD).getIndex())); SmallVector addr; @@ -2913,8 +2880,8 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(const VarDecl *VD, addr.push_back(llvm::dwarf::DW_OP_deref); addr.push_back(llvm::dwarf::DW_OP_plus); // offset of __forwarding field - offset = CGM.getContext() - .toCharUnitsFromBits(target.getPointerSizeInBits(0)); + offset = + CGM.getContext().toCharUnitsFromBits(target.getPointerSizeInBits(0)); addr.push_back(offset.getQuantity()); addr.push_back(llvm::dwarf::DW_OP_deref); addr.push_back(llvm::dwarf::DW_OP_plus); @@ -2925,16 +2892,15 @@ void CGDebugInfo::EmitDeclareOfBlockDeclRefVariable(const VarDecl *VD, // Create the descriptor for the variable. llvm::DIVariable D = - DBuilder.createLocalVariable(llvm::dwarf::DW_TAG_auto_variable, - llvm::DIDescriptor(LexicalBlockStack.back()), - VD->getName(), Unit, Line, Ty); + DBuilder.createLocalVariable(llvm::dwarf::DW_TAG_auto_variable, + llvm::DIDescriptor(LexicalBlockStack.back()), + VD->getName(), Unit, Line, Ty); // Insert an llvm.dbg.declare into the current block. - llvm::Instruction *Call = - DBuilder.insertDeclare(Storage, D, DBuilder.createExpression(addr), - Builder.GetInsertPoint()); - Call->setDebugLoc(llvm::DebugLoc::get(Line, Column, - LexicalBlockStack.back())); + llvm::Instruction *Call = DBuilder.insertDeclare( + Storage, D, DBuilder.createExpression(addr), Builder.GetInsertPoint()); + Call->setDebugLoc( + llvm::DebugLoc::get(Line, Column, LexicalBlockStack.back())); } /// EmitDeclareOfArgVariable - Emit call to llvm.dbg.declare for an argument @@ -2947,13 +2913,13 @@ void CGDebugInfo::EmitDeclareOfArgVariable(const VarDecl *VD, llvm::Value *AI, } namespace { - struct BlockLayoutChunk { - uint64_t OffsetInBits; - const BlockDecl::Capture *Capture; - }; - bool operator<(const BlockLayoutChunk &l, const BlockLayoutChunk &r) { - return l.OffsetInBits < r.OffsetInBits; - } +struct BlockLayoutChunk { + uint64_t OffsetInBits; + const BlockDecl::Capture *Capture; +}; +bool operator<(const BlockLayoutChunk &l, const BlockLayoutChunk &r) { + return l.OffsetInBits < r.OffsetInBits; +} } void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, @@ -2975,9 +2941,9 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, getContextDescriptor(cast(blockDecl->getDeclContext())); const llvm::StructLayout *blockLayout = - CGM.getDataLayout().getStructLayout(block.StructureType); + CGM.getDataLayout().getStructLayout(block.StructureType); - SmallVector fields; + SmallVector fields; fields.push_back(createFieldType("__isa", C.VoidPtrTy, 0, loc, AS_public, blockLayout->getElementOffsetInBits(0), tunit, tunit)); @@ -2990,13 +2956,11 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, fields.push_back(createFieldType("__FuncPtr", C.VoidPtrTy, 0, loc, AS_public, blockLayout->getElementOffsetInBits(3), tunit, tunit)); - fields.push_back(createFieldType("__descriptor", - C.getPointerType(block.NeedsCopyDispose ? - C.getBlockDescriptorExtendedType() : - C.getBlockDescriptorType()), - 0, loc, AS_public, - blockLayout->getElementOffsetInBits(4), - tunit, tunit)); + fields.push_back(createFieldType( + "__descriptor", C.getPointerType(block.NeedsCopyDispose + ? C.getBlockDescriptorExtendedType() + : C.getBlockDescriptorType()), + 0, loc, AS_public, blockLayout->getElementOffsetInBits(4), tunit, tunit)); // We want to sort the captures by offset, not because DWARF // requires this, but because we're paranoid about debuggers. @@ -3006,7 +2970,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, if (blockDecl->capturesCXXThis()) { BlockLayoutChunk chunk; chunk.OffsetInBits = - blockLayout->getElementOffsetInBits(block.CXXThisIndex); + blockLayout->getElementOffsetInBits(block.CXXThisIndex); chunk.Capture = nullptr; chunks.push_back(chunk); } @@ -3022,7 +2986,7 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, BlockLayoutChunk chunk; chunk.OffsetInBits = - blockLayout->getElementOffsetInBits(captureInfo.getIndex()); + blockLayout->getElementOffsetInBits(captureInfo.getIndex()); chunk.Capture = &capture; chunks.push_back(chunk); } @@ -3030,15 +2994,16 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, // Sort by offset. llvm::array_pod_sort(chunks.begin(), chunks.end()); - for (SmallVectorImpl::iterator - i = chunks.begin(), e = chunks.end(); i != e; ++i) { + for (SmallVectorImpl::iterator i = chunks.begin(), + e = chunks.end(); + i != e; ++i) { uint64_t offsetInBits = i->OffsetInBits; const BlockDecl::Capture *capture = i->Capture; // If we have a null capture, this must be the C++ 'this' capture. if (!capture) { const CXXMethodDecl *method = - cast(blockDecl->getNonClosureContext()); + cast(blockDecl->getNonClosureContext()); QualType type = method->getThisType(C); fields.push_back(createFieldType("this", type, 0, loc, AS_public, @@ -3061,23 +3026,23 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, DBuilder.createMemberType(tunit, name, tunit, line, PtrInfo.Width, PtrInfo.Align, offsetInBits, 0, fieldType); } else { - fieldType = createFieldType(name, variable->getType(), 0, - loc, AS_public, offsetInBits, tunit, tunit); + fieldType = createFieldType(name, variable->getType(), 0, loc, AS_public, + offsetInBits, tunit, tunit); } fields.push_back(fieldType); } SmallString<36> typeName; - llvm::raw_svector_ostream(typeName) - << "__block_literal_" << CGM.getUniqueBlockCount(); + llvm::raw_svector_ostream(typeName) << "__block_literal_" + << CGM.getUniqueBlockCount(); llvm::DIArray fieldsArray = DBuilder.getOrCreateArray(fields); llvm::DIType type = - DBuilder.createStructType(tunit, typeName.str(), tunit, line, - CGM.getContext().toBits(block.BlockSize), - CGM.getContext().toBits(block.BlockAlign), - 0, llvm::DIType(), fieldsArray); + DBuilder.createStructType(tunit, typeName.str(), tunit, line, + CGM.getContext().toBits(block.BlockSize), + CGM.getContext().toBits(block.BlockAlign), 0, + llvm::DIType(), fieldsArray); type = DBuilder.createPointerType(type, CGM.PointerWidthInBits); // Get overall information about the block. @@ -3085,26 +3050,22 @@ void CGDebugInfo::EmitDeclareOfBlockLiteralArgVariable(const CGBlockInfo &block, llvm::MDNode *scope = LexicalBlockStack.back(); // Create the descriptor for the parameter. - llvm::DIVariable debugVar = - DBuilder.createLocalVariable(llvm::dwarf::DW_TAG_arg_variable, - llvm::DIDescriptor(scope), - Arg->getName(), tunit, line, type, - CGM.getLangOpts().Optimize, flags, - ArgNo); + llvm::DIVariable debugVar = DBuilder.createLocalVariable( + llvm::dwarf::DW_TAG_arg_variable, llvm::DIDescriptor(scope), + Arg->getName(), tunit, line, type, CGM.getLangOpts().Optimize, flags, + ArgNo); if (LocalAddr) { // Insert an llvm.dbg.value into the current block. - llvm::Instruction *DbgVal = - DBuilder.insertDbgValueIntrinsic(LocalAddr, 0, debugVar, - DBuilder.createExpression(), - Builder.GetInsertBlock()); + llvm::Instruction *DbgVal = DBuilder.insertDbgValueIntrinsic( + LocalAddr, 0, debugVar, DBuilder.createExpression(), + Builder.GetInsertBlock()); DbgVal->setDebugLoc(llvm::DebugLoc::get(line, column, scope)); } // Insert an llvm.dbg.declare into the current block. - llvm::Instruction *DbgDecl = - DBuilder.insertDeclare(Arg, debugVar, DBuilder.createExpression(), - Builder.GetInsertBlock()); + llvm::Instruction *DbgDecl = DBuilder.insertDeclare( + Arg, debugVar, DBuilder.createExpression(), Builder.GetInsertBlock()); DbgDecl->setDebugLoc(llvm::DebugLoc::get(line, column, scope)); } @@ -3151,10 +3112,9 @@ CGDebugInfo::CollectAnonRecordDecls(const RecordDecl *RD, llvm::DIFile Unit, continue; } // Use VarDecl's Tag, Scope and Line number. - GV = DBuilder.createGlobalVariable(DContext, FieldName, LinkageName, Unit, - LineNo, FieldTy, - Var->hasInternalLinkage(), Var, - llvm::DIDerivedType()); + GV = DBuilder.createGlobalVariable( + DContext, FieldName, LinkageName, Unit, LineNo, FieldTy, + Var->hasInternalLinkage(), Var, llvm::DIDerivedType()); } return GV; } @@ -3176,8 +3136,8 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, llvm::APInt ConstVal(32, 1); QualType ET = CGM.getContext().getAsArrayType(T)->getElementType(); - T = CGM.getContext().getConstantArrayType(ET, ConstVal, - ArrayType::Normal, 0); + T = CGM.getContext().getConstantArrayType(ET, ConstVal, ArrayType::Normal, + 0); } StringRef DeclName = D->getName(); @@ -3207,7 +3167,8 @@ void CGDebugInfo::EmitGlobalVariable(llvm::GlobalVariable *Var, // to find the name of any field in the union. if (T->isUnionType() && DeclName.empty()) { const RecordDecl *RD = cast(T)->getDecl(); - assert(RD->isAnonymousStructOrUnion() && "unnamed non-anonymous struct or union?"); + assert(RD->isAnonymousStructOrUnion() && + "unnamed non-anonymous struct or union?"); GV = CollectAnonRecordDecls(RD, Unit, LineNo, LinkageName, Var, DContext); } else { GV = DBuilder.createGlobalVariable( -- 2.7.4