diff --git a/projects/clr/hipamd/hipify-clang/src/HipifyAction.cpp b/projects/clr/hipamd/hipify-clang/src/HipifyAction.cpp index 87329680b3..8fb318776d 100644 --- a/projects/clr/hipamd/hipify-clang/src/HipifyAction.cpp +++ b/projects/clr/hipamd/hipify-clang/src/HipifyAction.cpp @@ -174,13 +174,10 @@ void HipifyAction::InclusionDirective(clang::SourceLocation hash_loc, return; } - char *B = nullptr; - const char *E = SM.getCharacterData(filename_range.getEnd()); clang::StringRef newInclude; // Keep the same include type that the user gave. if (!secondMainInclude) { - B = const_cast(SM.getCharacterData(sl)); clang::SmallString<128> includeBuffer; if (is_angled) { newInclude = llvm::Twine("<" + found->second.hipName + ">").toStringRef(includeBuffer); @@ -189,10 +186,10 @@ void HipifyAction::InclusionDirective(clang::SourceLocation hash_loc, } } else { // hashLoc is location of the '#', thus replacing the whole include directive by empty newInclude starting with '#'. - B = const_cast(SM.getCharacterData(hash_loc)); sl = hash_loc; } - + const char *B = SM.getCharacterData(sl); + const char *E = SM.getCharacterData(filename_range.getEnd()); ct::Replacement Rep(SM, sl, E - B, newInclude); insertReplacement(Rep, clang::FullSourceLoc{sl, SM}); }