From 96fefc34b4aa8fa37ba5a50cd52fc4a6544c47f7 Mon Sep 17 00:00:00 2001 From: Evgeny Mankov Date: Tue, 30 Oct 2018 19:35:59 +0300 Subject: [PATCH] [HIPIFY][fix][#739] Fix garbage after replacements [Issue] https://github.com/ROCm-Developer-Tools/HIP/issues/739 [Resolution] Always use an std::string not a clang::StringRef for replacement P.S. Occurred only on Linux, on Windows works fine. [ROCm/hip commit: a8e6033aa3c0f8fe1050f64313bba958cf41e266] --- projects/hip/hipify-clang/src/HipifyAction.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/hip/hipify-clang/src/HipifyAction.cpp b/projects/hip/hipify-clang/src/HipifyAction.cpp index 5d1c9f9666..ce185c39a8 100644 --- a/projects/hip/hipify-clang/src/HipifyAction.cpp +++ b/projects/hip/hipify-clang/src/HipifyAction.cpp @@ -24,7 +24,7 @@ void HipifyAction::RewriteString(StringRef s, clang::SourceLocation start) { Statistics::current().incrementCounter(counter, name.str()); if (!counter.unsupported) { clang::SourceLocation sl = start.getLocWithOffset(begin + 1); - ct::Replacement Rep(SM, sl, name.size(), repName); + ct::Replacement Rep(SM, sl, name.size(), repName.str()); clang::FullSourceLoc fullSL(sl, SM); insertReplacement(Rep, fullSL); } @@ -70,7 +70,7 @@ void HipifyAction::RewriteToken(const clang::Token& t) { return; } StringRef repName = found->second.hipName; - ct::Replacement Rep(SM, sl, name.size(), repName); + ct::Replacement Rep(SM, sl, name.size(), repName.str()); clang::FullSourceLoc fullSL(sl, SM); insertReplacement(Rep, fullSL); } @@ -219,7 +219,7 @@ void HipifyAction::InclusionDirective(clang::SourceLocation hash_loc, } const char *B = SM.getCharacterData(sl); const char *E = SM.getCharacterData(filename_range.getEnd()); - ct::Replacement Rep(SM, sl, E - B, newInclude); + ct::Replacement Rep(SM, sl, E - B, newInclude.str()); insertReplacement(Rep, clang::FullSourceLoc{sl, SM}); }