git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@254557
91177308-0d34-0410-b5e6-
96231b3b80d8
auto *Scope = cast<DIScope>(S);
StringRef Dir = Scope->getDirectory(),
Filename = Scope->getFilename();
auto *Scope = cast<DIScope>(S);
StringRef Dir = Scope->getDirectory(),
Filename = Scope->getFilename();
- char *&Result = DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)];
- if (Result)
- return Result;
+ std::string &Filepath =
+ DirAndFilenameToFilepathMap[std::make_pair(Dir, Filename)];
+ if (!Filepath.empty())
+ return Filepath;
// Clang emits directory and relative filename info into the IR, but CodeView
// operates on full paths. We could change Clang to emit full paths too, but
// that would increase the IR size and probably not needed for other users.
// For now, just concatenate and canonicalize the path here.
// Clang emits directory and relative filename info into the IR, but CodeView
// operates on full paths. We could change Clang to emit full paths too, but
// that would increase the IR size and probably not needed for other users.
// For now, just concatenate and canonicalize the path here.
if (Filename.find(':') == 1)
Filepath = Filename;
else
if (Filename.find(':') == 1)
Filepath = Filename;
else
while ((Cursor = Filepath.find("\\\\", Cursor)) != std::string::npos)
Filepath.erase(Cursor, 1);
while ((Cursor = Filepath.find("\\\\", Cursor)) != std::string::npos)
Filepath.erase(Cursor, 1);
- Result = strdup(Filepath.c_str());
- return StringRef(Result);
}
void WinCodeViewLineTables::maybeRecordLocation(DebugLoc DL,
}
void WinCodeViewLineTables::maybeRecordLocation(DebugLoc DL,
- typedef std::map<std::pair<StringRef, StringRef>, char *>
+ typedef std::map<std::pair<StringRef, StringRef>, std::string>
DirAndFilenameToFilepathMapTy;
DirAndFilenameToFilepathMapTy DirAndFilenameToFilepathMap;
StringRef getFullFilepath(const MDNode *S);
DirAndFilenameToFilepathMapTy;
DirAndFilenameToFilepathMapTy DirAndFilenameToFilepathMap;
StringRef getFullFilepath(const MDNode *S);
public:
WinCodeViewLineTables(AsmPrinter *Asm);
public:
WinCodeViewLineTables(AsmPrinter *Asm);
- ~WinCodeViewLineTables() override {
- for (DirAndFilenameToFilepathMapTy::iterator
- I = DirAndFilenameToFilepathMap.begin(),
- E = DirAndFilenameToFilepathMap.end();
- I != E; ++I)
- free(I->second);
- }
-
void setSymbolSize(const llvm::MCSymbol *, uint64_t) override {}
/// \brief Emit the COFF section that holds the line table information.
void setSymbolSize(const llvm::MCSymbol *, uint64_t) override {}
/// \brief Emit the COFF section that holds the line table information.