Skip to content

Commit 09f735e

Browse files
committed
Addressed review comments and refactored the code.
1 parent 10d54cc commit 09f735e

File tree

4 files changed

+15
-12
lines changed

4 files changed

+15
-12
lines changed

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5734,7 +5734,7 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
57345734
// action to determine this.
57355735
if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID &&
57365736
!Header.empty()) {
5737-
// Add the -include-header option to add the integration header
5737+
// Add the -include-internal-header option to add the integration header
57385738
CmdArgs.push_back("-include-internal-header");
57395739
CmdArgs.push_back(Args.MakeArgString(Header));
57405740
// When creating dependency information, filter out the generated

clang/lib/Frontend/PrintPreprocessedOutput.cpp

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -271,24 +271,14 @@ static bool is_separator(char value) {
271271
return false;
272272
}
273273

274-
static StringRef remove_leading_dotbackslah(StringRef Path) {
275-
// Remove leading ".\" (or ".\\" or ".\.\" etc.)
276-
while (Path.size() > 2 && Path[0] == '.' && is_separator(Path[1])) {
277-
Path = Path.substr(2);
278-
while (Path.size() > 0 && is_separator(Path[0]))
279-
Path = Path.substr(1);
280-
}
281-
return Path;
282-
}
283-
284274
void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
285275
const char *Extra,
286276
unsigned ExtraLen) {
287277
startNewLineIfNeeded();
288278

289279
// Emit #line directives or GNU line markers depending on what mode we're in.
290280
StringRef CurFilenameWithNoLeaningDotSlash =
291-
remove_leading_dotbackslah(CurFilename.str());
281+
llvm::sys::path::remove_leading_dotbackslah(CurFilename.str());
292282
if ((CurFilenameWithNoLeaningDotSlash ==
293283
PP.getPreprocessorOpts().IncludeFooter) ||
294284
CurFilenameWithNoLeaningDotSlash ==

llvm/include/llvm/Support/Path.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,12 @@ bool replace_path_prefix(SmallVectorImpl<char> &Path, StringRef OldPrefix,
201201
/// @result The cleaned-up \a path.
202202
StringRef remove_leading_dotslash(StringRef path, Style style = Style::native);
203203

204+
/// Remove redundant leading ".\" pieces and consecutive separators.
205+
///
206+
/// @param path Input path.
207+
/// @result The cleaned-up \a path.
208+
StringRef remove_leading_dotbackslah(StringRef path);
209+
204210
/// In-place remove any './' and optionally '../' components from a path.
205211
///
206212
/// @param path processed path

llvm/lib/Support/Path.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,13 @@ StringRef remove_leading_dotslash(StringRef Path, Style style) {
711711
return Path;
712712
}
713713

714+
StringRef remove_leading_dotbackslah(StringRef Path) {
715+
// Remove leading ".\\".
716+
if (Path.size() > 2 && Path[0] == '.' && Path[1] == '\\')
717+
Path = Path.substr(2);
718+
return Path;
719+
}
720+
714721
// Remove path traversal components ("." and "..") when possible, and
715722
// canonicalize slashes.
716723
bool remove_dots(SmallVectorImpl<char> &the_path, bool remove_dot_dot,

0 commit comments

Comments
 (0)