From: Devang Patel Date: Mon, 26 Jul 2010 18:49:27 +0000 (+0000) Subject: Revert 109303. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e9b711c39827d7dcba0fc4cb787a4a7395285634;p=clang Revert 109303. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@109426 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp index 0309c6e09b..753cdcddd2 100644 --- a/lib/CodeGen/CGDebugInfo.cpp +++ b/lib/CodeGen/CGDebugInfo.cpp @@ -148,8 +148,13 @@ llvm::DIFile CGDebugInfo::getOrCreateFile(SourceLocation Loc) { return llvm::DIFile(cast(it->second)); } - llvm::DIFile F = DebugFactory.CreateFile(PLoc.getFilename(), - getCurrentDirname(), TheCU); + // FIXME: We shouldn't even need to call 'makeAbsolute()' in the cases + // where we can consult the FileEntry. + llvm::sys::Path AbsFileName(PLoc.getFilename()); + AbsFileName.makeAbsolute(); + + llvm::DIFile F = DebugFactory.CreateFile(AbsFileName.getLast(), + AbsFileName.getDirname(), TheCU); DIFileCache[fname] = F; return F; @@ -174,25 +179,6 @@ unsigned CGDebugInfo::getColumnNumber(SourceLocation Loc) { return PLoc.getColumn(); } -llvm::StringRef CGDebugInfo::getCurrentDirname() { - if (!CWDName.empty()) - return CWDName; - char *CompDirnamePtr = NULL; - llvm::sys::Path CWD = llvm::sys::Path::GetCurrentDirectory(); - CompDirnamePtr = DebugInfoNames.Allocate(CWD.size()); - memcpy(CompDirnamePtr, CWD.c_str(), CWD.size()); - return CWDName = llvm::StringRef(CompDirnamePtr, CWD.size()); -} - -/// getCompDirname - AT_comp_dir is empty if filename is absulte otherwise -/// it points to compilation directory. -llvm::StringRef CGDebugInfo::getCompDirname(llvm::StringRef Filename) { - llvm::sys::Path FilePath(Filename); - if (FilePath.isAbsolute()) - return llvm::StringRef(); - return getCurrentDirname(); -} - /// CreateCompileUnit - Create new compile unit. void CGDebugInfo::CreateCompileUnit() { @@ -202,22 +188,19 @@ void CGDebugInfo::CreateCompileUnit() { if (MainFileName.empty()) MainFileName = ""; + llvm::sys::Path AbsFileName(MainFileName); + AbsFileName.makeAbsolute(); + // The main file name provided via the "-main-file-name" option contains just // the file name itself with no path information. This file name may have had // a relative path, so we look into the actual file entry for the main // file to determine the real absolute path for the file. std::string MainFileDir; - if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) { + if (const FileEntry *MainFile = SM.getFileEntryForID(SM.getMainFileID())) MainFileDir = MainFile->getDir()->getName(); - if (MainFileDir != ".") - MainFileName = MainFileDir + "/" + MainFileName; - } + else + MainFileDir = AbsFileName.getDirname(); - // Save filename string. - char *FilenamePtr = DebugInfoNames.Allocate(MainFileName.length()); - memcpy(FilenamePtr, MainFileName.c_str(), MainFileName.length()); - llvm::StringRef Filename(FilenamePtr, MainFileName.length()); - unsigned LangTag; const LangOptions &LO = CGM.getLangOptions(); if (LO.CPlusPlus) { @@ -246,8 +229,7 @@ void CGDebugInfo::CreateCompileUnit() { // Create new compile unit. TheCU = DebugFactory.CreateCompileUnit( - LangTag, Filename, getCompDirname(Filename), - Producer, true, + LangTag, AbsFileName.getLast(), MainFileDir, Producer, true, LO.Optimize, CGM.getCodeGenOpts().DwarfDebugFlags, RuntimeVers); } diff --git a/lib/CodeGen/CGDebugInfo.h b/lib/CodeGen/CGDebugInfo.h index fc296acf45..fdfd3dca57 100644 --- a/lib/CodeGen/CGDebugInfo.h +++ b/lib/CodeGen/CGDebugInfo.h @@ -70,7 +70,6 @@ class CGDebugInfo { /// DebugInfoNames - This is a storage for names that are /// constructed on demand. For example, C++ destructors, C++ operators etc.. llvm::BumpPtrAllocator DebugInfoNames; - llvm::StringRef CWDName; llvm::DenseMap DIFileCache; llvm::DenseMap SPCache; @@ -199,13 +198,6 @@ private: llvm::DIDescriptor getContextDescriptor(const Decl *Decl, llvm::DIDescriptor &CU); - /// getCompDirname - AT_comp_dir is empty if filename is absulte otherwise - /// it points to compilation directory. - llvm::StringRef getCompDirname(llvm::StringRef Filename); - - /// getCurrentDirname - Return current directory name. - llvm::StringRef getCurrentDirname(); - /// CreateCompileUnit - Create new compile unit. void CreateCompileUnit();