diff options
author | Reid Kleckner <rnk@google.com> | 2015-12-02 22:34:30 +0000 |
---|---|---|
committer | Reid Kleckner <rnk@google.com> | 2015-12-02 22:34:30 +0000 |
commit | 1f11b4e3a724ccfd9b8a583a681e5b5364ed4065 (patch) | |
tree | 44161f84b1c2a0fdd69718a36403ec949f169943 /llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp | |
parent | 8c04472edf7f1248e400ea4e08ac0d19bd481715 (diff) | |
download | bcm5719-llvm-1f11b4e3a724ccfd9b8a583a681e5b5364ed4065.tar.gz bcm5719-llvm-1f11b4e3a724ccfd9b8a583a681e5b5364ed4065.zip |
Use std::string instead of strdup() and free() in WinCodeViewLineTables
llvm-svn: 254557
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp index 8b1bea8049e..c2c0f84e5c9 100644 --- a/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/WinCodeViewLineTables.cpp @@ -27,15 +27,15 @@ StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) { 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. - std::string Filepath; if (Filename.find(':') == 1) Filepath = Filename; else @@ -74,8 +74,7 @@ StringRef WinCodeViewLineTables::getFullFilepath(const MDNode *S) { while ((Cursor = Filepath.find("\\\\", Cursor)) != std::string::npos) Filepath.erase(Cursor, 1); - Result = strdup(Filepath.c_str()); - return StringRef(Result); + return Filepath; } void WinCodeViewLineTables::maybeRecordLocation(DebugLoc DL, |