summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorIlya Biryukov <ibiryukov@google.com>2018-12-04 16:30:45 +0000
committerIlya Biryukov <ibiryukov@google.com>2018-12-04 16:30:45 +0000
commit660d233ea5a5e5fd17c3dfd84bbf0b0a0522cc04 (patch)
tree78c237bc6bce24d07d294d40470295f28178fb8d /clang/lib/CodeGen
parent449a7f0dbb621edf2a6351924a170e268ec6957d (diff)
downloadbcm5719-llvm-660d233ea5a5e5fd17c3dfd84bbf0b0a0522cc04.tar.gz
bcm5719-llvm-660d233ea5a5e5fd17c3dfd84bbf0b0a0522cc04.zip
Revert "Avoid emitting redundant or unusable directories in DIFile metadata entries."
This reverts commit r348154 and follow-up commits r348211 and r3248213. Reason: the original commit broke compiler-rt tests and a follow-up fix (r348203) broke our integrate and was reverted. llvm-svn: 348280
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp47
-rw-r--r--clang/lib/CodeGen/CodeGenAction.cpp16
2 files changed, 15 insertions, 48 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index c556996be09..3492fbacd33 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -181,7 +181,8 @@ void CGDebugInfo::setLocation(SourceLocation Loc) {
SourceManager &SM = CGM.getContext().getSourceManager();
auto *Scope = cast<llvm::DIScope>(LexicalBlockStack.back());
PresumedLoc PCLoc = SM.getPresumedLoc(CurLoc);
- if (PCLoc.isInvalid() || Scope->getFile() == getOrCreateFile(CurLoc))
+
+ if (PCLoc.isInvalid() || Scope->getFilename() == PCLoc.getFilename())
return;
if (auto *LBF = dyn_cast<llvm::DILexicalBlockFile>(Scope)) {
@@ -409,13 +410,13 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
SourceManager &SM = CGM.getContext().getSourceManager();
PresumedLoc PLoc = SM.getPresumedLoc(Loc);
- StringRef FileName = PLoc.getFilename();
- if (PLoc.isInvalid() || FileName.empty())
+ if (PLoc.isInvalid() || StringRef(PLoc.getFilename()).empty())
// If the location is not valid then use main input file.
return getOrCreateMainFile();
// Cache the results.
- auto It = DIFileCache.find(FileName.data());
+ const char *fname = PLoc.getFilename();
+ auto It = DIFileCache.find(fname);
if (It != DIFileCache.end()) {
// Verify that the information still exists.
@@ -430,41 +431,11 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
if (CSKind)
CSInfo.emplace(*CSKind, Checksum);
- StringRef Dir;
- StringRef File;
- std::string RemappedFile = remapDIPath(FileName);
- std::string CurDir = remapDIPath(getCurrentDirname());
- SmallString<128> DirBuf;
- SmallString<128> FileBuf;
- if (llvm::sys::path::is_absolute(RemappedFile)) {
- // Strip the common prefix (if it is more than just "/") from current
- // directory and FileName for a more space-efficient encoding.
- auto FileIt = llvm::sys::path::begin(RemappedFile);
- auto FileE = llvm::sys::path::end(RemappedFile);
- auto CurDirIt = llvm::sys::path::begin(CurDir);
- auto CurDirE = llvm::sys::path::end(CurDir);
- for (; CurDirIt != CurDirE && *CurDirIt == *FileIt; ++CurDirIt, ++FileIt)
- llvm::sys::path::append(DirBuf, *CurDirIt);
- if (std::distance(llvm::sys::path::begin(CurDir), CurDirIt) == 1) {
- // The common prefix only the root; stripping it would cause
- // LLVM diagnostic locations to be more confusing.
- Dir = {};
- File = RemappedFile;
- } else {
- for (; FileIt != FileE; ++FileIt)
- llvm::sys::path::append(FileBuf, *FileIt);
- Dir = DirBuf;
- File = FileBuf;
- }
- } else {
- Dir = CurDir;
- File = RemappedFile;
- }
- llvm::DIFile *F =
- DBuilder.createFile(File, Dir, CSInfo,
- getSource(SM, SM.getFileID(Loc)));
+ llvm::DIFile *F = DBuilder.createFile(
+ remapDIPath(PLoc.getFilename()), remapDIPath(getCurrentDirname()), CSInfo,
+ getSource(SM, SM.getFileID(Loc)));
- DIFileCache[FileName.data()].reset(F);
+ DIFileCache[fname].reset(F);
return F;
}
diff --git a/clang/lib/CodeGen/CodeGenAction.cpp b/clang/lib/CodeGen/CodeGenAction.cpp
index fd4506f2d19..1a2b0616dc7 100644
--- a/clang/lib/CodeGen/CodeGenAction.cpp
+++ b/clang/lib/CodeGen/CodeGenAction.cpp
@@ -549,16 +549,12 @@ const FullSourceLoc BackendConsumer::getBestLocationFromDebugLoc(
SourceLocation DILoc;
if (D.isLocationAvailable()) {
- D.getLocation(Filename, Line, Column);
- if (Line > 0) {
- const FileEntry *FE = FileMgr.getFile(Filename);
- if (!FE)
- FE = FileMgr.getFile(D.getAbsolutePath());
- if (FE) {
- // If -gcolumn-info was not used, Column will be 0. This upsets the
- // source manager, so pass 1 if Column is not set.
- DILoc = SourceMgr.translateFileLineCol(FE, Line, Column ? Column : 1);
- }
+ D.getLocation(&Filename, &Line, &Column);
+ const FileEntry *FE = FileMgr.getFile(Filename);
+ if (FE && Line > 0) {
+ // If -gcolumn-info was not used, Column will be 0. This upsets the
+ // source manager, so pass 1 if Column is not set.
+ DILoc = SourceMgr.translateFileLineCol(FE, Line, Column ? Column : 1);
}
BadDebugInfo = DILoc.isInvalid();
}
OpenPOWER on IntegriCloud