From d1358177833835117425d5b87be0755936530f84 Mon Sep 17 00:00:00 2001 From: Adrian Prantl Date: Tue, 11 Dec 2018 16:58:46 +0000 Subject: [PATCH] Remove CGDebugInfo::getOrCreateFile() and use TheCU->getFile() directly. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@348866 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGDebugInfo.cpp | 39 +++++++++++++++---------------------- lib/CodeGen/CGDebugInfo.h | 3 --- 2 files changed, 16 insertions(+), 26 deletions(-) diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index d9c184c209..3f0837edc4 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -220,7 +220,7 @@ llvm::DIScope *CGDebugInfo::getContextDescriptor(const Decl *Context, if (const auto *RDecl = dyn_cast(Context)) if (!RDecl->isDependentType()) return getOrCreateType(CGM.getContext().getTypeDeclType(RDecl), - getOrCreateMainFile()); + TheCU->getFile()); return Default; } @@ -404,7 +404,7 @@ Optional CGDebugInfo::getSource(const SourceManager &SM, llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) { if (!Loc.isValid()) // If Location is not valid then use main input file. - return getOrCreateMainFile(); + return TheCU->getFile(); SourceManager &SM = CGM.getContext().getSourceManager(); PresumedLoc PLoc = SM.getPresumedLoc(Loc); @@ -412,7 +412,7 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) { StringRef FileName = PLoc.getFilename(); if (PLoc.isInvalid() || FileName.empty()) // If the location is not valid then use main input file. - return getOrCreateMainFile(); + return TheCU->getFile(); // Cache the results. auto It = DIFileCache.find(FileName.data()); @@ -471,13 +471,6 @@ CGDebugInfo::createFile(StringRef FileName, return F; } -llvm::DIFile *CGDebugInfo::getOrCreateMainFile() { - return createFile( - remapDIPath(TheCU->getFilename()), remapDIPath(TheCU->getDirectory()), - TheCU->getFile()->getChecksum(), - CGM.getCodeGenOpts().EmbedSource ? TheCU->getSource() : None); -} - std::string CGDebugInfo::remapDIPath(StringRef Path) const { for (const auto &Entry : DebugPrefixMap) if (Path.startswith(Entry.first)) @@ -641,9 +634,9 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { return nullptr; case BuiltinType::ObjCClass: if (!ClassTy) - ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - "objc_class", TheCU, - getOrCreateMainFile(), 0); + ClassTy = + DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, + "objc_class", TheCU, TheCU->getFile(), 0); return ClassTy; case BuiltinType::ObjCId: { // typedef struct objc_class *Class; @@ -655,21 +648,21 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { return ObjTy; if (!ClassTy) - ClassTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, - "objc_class", TheCU, - getOrCreateMainFile(), 0); + ClassTy = + DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, + "objc_class", TheCU, TheCU->getFile(), 0); unsigned Size = CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy); auto *ISATy = DBuilder.createPointerType(ClassTy, Size); - ObjTy = DBuilder.createStructType( - TheCU, "objc_object", getOrCreateMainFile(), 0, 0, 0, - llvm::DINode::FlagZero, nullptr, llvm::DINodeArray()); + ObjTy = DBuilder.createStructType(TheCU, "objc_object", TheCU->getFile(), 0, + 0, 0, llvm::DINode::FlagZero, nullptr, + llvm::DINodeArray()); DBuilder.replaceArrays( ObjTy, DBuilder.getOrCreateArray(&*DBuilder.createMemberType( - ObjTy, "isa", getOrCreateMainFile(), 0, Size, 0, 0, + ObjTy, "isa", TheCU->getFile(), 0, Size, 0, 0, llvm::DINode::FlagZero, ISATy))); return ObjTy; } @@ -677,7 +670,7 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType *BT) { if (!SelTy) SelTy = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, "objc_selector", TheCU, - getOrCreateMainFile(), 0); + TheCU->getFile(), 0); return SelTy; } @@ -998,7 +991,7 @@ llvm::DIType *CGDebugInfo::getOrCreateStructPtrType(StringRef Name, if (Cache) return Cache; Cache = DBuilder.createForwardDecl(llvm::dwarf::DW_TAG_structure_type, Name, - TheCU, getOrCreateMainFile(), 0); + TheCU, TheCU->getFile(), 0); unsigned Size = CGM.getContext().getTypeSize(CGM.getContext().VoidPtrTy); Cache = DBuilder.createPointerType(Cache, Size); return Cache; @@ -4476,7 +4469,7 @@ void CGDebugInfo::EmitExplicitCastType(QualType Ty) { if (CGM.getCodeGenOpts().getDebugInfo() < codegenoptions::LimitedDebugInfo) return; - if (auto *DieTy = getOrCreateType(Ty, getOrCreateMainFile())) + if (auto *DieTy = getOrCreateType(Ty, TheCU->getFile())) // Don't ignore in case of explicit cast where it is referenced indirectly. DBuilder.retainType(DieTy); } diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index 5b0d2d7fc9..031e40b9dd 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -548,9 +548,6 @@ private: Optional> CSInfo, Optional Source); - /// Get the file info for main compile unit. - llvm::DIFile *getOrCreateMainFile(); - /// Get the type from the cache or create a new type if necessary. llvm::DIType *getOrCreateType(QualType Ty, llvm::DIFile *Fg); -- 2.40.0