Skip to content

Commit 7fe537c

Browse files
committed
Addressed review comments.
1 parent 83794f6 commit 7fe537c

File tree

2 files changed

+26
-23
lines changed

2 files changed

+26
-23
lines changed

clang/lib/Frontend/PrintPreprocessedOutput.cpp

Lines changed: 25 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -272,32 +272,35 @@ void PrintPPOutputPPCallbacks::WriteLineInfo(unsigned LineNo,
272272
unsigned ExtraLen) {
273273
startNewLineIfNeeded();
274274

275-
StringRef CurFilenameWithNoLeaningDotSlash =
275+
if (PP.getLangOpts().isSYCL()) {
276+
StringRef CurFilenameWithNoLeadingDotSlash =
276277
llvm::sys::path::remove_leading_dotbackslash(CurFilename.str());
277-
if ((CurFilenameWithNoLeaningDotSlash ==
278-
PP.getPreprocessorOpts().IncludeFooter) ||
279-
CurFilenameWithNoLeaningDotSlash ==
280-
PP.getPreprocessorOpts().IncludeHeader) {
281-
CurFilename = "<uninit>";
278+
if ((CurFilenameWithNoLeadingDotSlash ==
279+
PP.getPreprocessorOpts().IncludeFooter) ||
280+
CurFilenameWithNoLeadingDotSlash ==
281+
PP.getPreprocessorOpts().IncludeHeader) {
282+
CurFilename = "<uninit>";
283+
}
282284
}
283-
// Emit #line directives or GNU line markers depending on what mode we're in.
284-
if (UseLineDirectives) {
285-
*OS << "#line" << ' ' << LineNo << ' ' << '"';
286-
OS->write_escaped(CurFilename);
287-
*OS << '"';
288-
} else {
289-
*OS << '#' << ' ' << LineNo << ' ' << '"';
290-
OS->write_escaped(CurFilename);
291-
*OS << '"';
292285

293-
if (ExtraLen)
294-
OS->write(Extra, ExtraLen);
286+
// Emit #line directives or GNU line markers depending on what mode we're in.
287+
if (UseLineDirectives) {
288+
*OS << "#line" << ' ' << LineNo << ' ' << '"';
289+
OS->write_escaped(CurFilename);
290+
*OS << '"';
291+
} else {
292+
*OS << '#' << ' ' << LineNo << ' ' << '"';
293+
OS->write_escaped(CurFilename);
294+
*OS << '"';
295+
296+
if (ExtraLen)
297+
OS->write(Extra, ExtraLen);
295298

296-
if (FileType == SrcMgr::C_System)
297-
OS->write(" 3", 2);
298-
else if (FileType == SrcMgr::C_ExternCSystem)
299-
OS->write(" 3 4", 4);
300-
}
299+
if (FileType == SrcMgr::C_System)
300+
OS->write(" 3", 2);
301+
else if (FileType == SrcMgr::C_ExternCSystem)
302+
OS->write(" 3 4", 4);
303+
}
301304

302305
*OS << '\n';
303306
}

clang/test/Preprocessor/print_line_empty_file.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ int foo() { return 42; }
66
#line 4 "bug.c"
77
int bar() { return 21; }
88

9-
// CHECK: # 1 "[[INPUT:.+\.c]]" 2
9+
// CHECK: # 21 ""
1010
// CHECK: int foo() { return 42; }
1111
// CHECK: # 4 "bug.c"
1212
// CHECK: int bar() { return 21; }

0 commit comments

Comments
 (0)