<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 22 May 2017 at 14:42, Reid Kleckner via cfe-commits <span dir="ltr"><<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: rnk<br>
Date: Mon May 22 16:42:58 2017<br>
New Revision: 303582<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=303582&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?rev=303582&view=rev</a><br>
Log:<br>
Give files from #line the characteristics of the current file<br>
<br>
This allows #line directives to appear in system headers that have code<br>
that clang would normally warn on. This is compatible with GCC, which is<br>
easy to test by running `gcc -E`.<br>
<br>
Fixes PR30752<br>
<br>
Added:<br>
    cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>line.h<br>
    cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>noline.h<br>
    cfe/trunk/test/Frontend/<wbr>system-header-line-directive.c<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/<wbr>SourceManager.h<br>
    cfe/trunk/include/clang/Basic/<wbr>SourceManagerInternals.h<br>
    cfe/trunk/lib/Basic/<wbr>SourceManager.cpp<br>
    cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp<br>
    cfe/trunk/lib/Lex/<wbr>PPDirectives.cpp<br>
    cfe/trunk/lib/Lex/Pragma.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>SourceManager.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManager.h?rev=303582&r1=303581&r2=303582&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/SourceManager.h?<wbr>rev=303582&r1=303581&r2=<wbr>303582&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>SourceManager.h (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>SourceManager.h Mon May 22 16:42:58 2017<br>
@@ -1399,10 +1399,9 @@ public:<br>
   /// specified by Loc.<br>
   ///<br>
   /// If FilenameID is -1, it is considered to be unspecified.<br>
-  void AddLineNote(SourceLocation Loc, unsigned LineNo, int FilenameID);<br>
   void AddLineNote(SourceLocation Loc, unsigned LineNo, int FilenameID,<br>
                    bool IsFileEntry, bool IsFileExit,<br>
-                   bool IsSystemHeader, bool IsExternCHeader);<br>
+                   SrcMgr::CharacteristicKind FileKind);<br>
<br>
   /// \brief Determine if the source manager has a line table.<br>
   bool hasLineTable() const { return LineTable != nullptr; }<br>
<br>
Modified: cfe/trunk/include/clang/Basic/<wbr>SourceManagerInternals.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/SourceManagerInternals.h?rev=303582&r1=303581&r2=303582&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/include/<wbr>clang/Basic/<wbr>SourceManagerInternals.h?rev=<wbr>303582&r1=303581&r2=303582&<wbr>view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/include/clang/Basic/<wbr>SourceManagerInternals.h (original)<br>
+++ cfe/trunk/include/clang/Basic/<wbr>SourceManagerInternals.h Mon May 22 16:42:58 2017<br>
@@ -102,8 +102,6 @@ public:<br>
   unsigned getNumFilenames() const { return FilenamesByID.size(); }<br>
<br>
   void AddLineNote(FileID FID, unsigned Offset,<br>
-                   unsigned LineNo, int FilenameID);<br>
-  void AddLineNote(FileID FID, unsigned Offset,<br>
                    unsigned LineNo, int FilenameID,<br>
                    unsigned EntryExit, SrcMgr::CharacteristicKind FileKind);<br>
<br>
<br>
Modified: cfe/trunk/lib/Basic/<wbr>SourceManager.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/SourceManager.cpp?rev=303582&r1=303581&r2=303582&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Basic/<wbr>SourceManager.cpp?rev=303582&<wbr>r1=303581&r2=303582&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Basic/<wbr>SourceManager.cpp (original)<br>
+++ cfe/trunk/lib/Basic/<wbr>SourceManager.cpp Mon May 22 16:42:58 2017<br>
@@ -183,48 +183,22 @@ unsigned LineTableInfo::<wbr>getLineTableFile<br>
   return IterBool.first->second;<br>
 }<br>
<br>
-/// AddLineNote - Add a line note to the line table that indicates that there<br>
-/// is a \#line at the specified FID/Offset location which changes the presumed<br>
-/// location to LineNo/FilenameID.<br>
-void LineTableInfo::AddLineNote(<wbr>FileID FID, unsigned Offset,<br>
-                                unsigned LineNo, int FilenameID) {<br>
-  std::vector<LineEntry> &Entries = LineEntries[FID];<br>
-<br>
-  assert((Entries.empty() || Entries.back().FileOffset < Offset) &&<br>
-         "Adding line entries out of order!");<br>
-<br>
-  SrcMgr::CharacteristicKind Kind = SrcMgr::C_User;<br>
-  unsigned IncludeOffset = 0;<br>
-<br>
-  if (!Entries.empty()) {<br>
-    // If this is a '#line 4' after '#line 42 "foo.h"', make sure to remember<br>
-    // that we are still in "foo.h".<br>
-    if (FilenameID == -1)<br>
-      FilenameID = Entries.back().FilenameID;<br>
-<br>
-    // If we are after a line marker that switched us to system header mode, or<br>
-    // that set #include information, preserve it.<br>
-    Kind = Entries.back().FileKind;<br>
-    IncludeOffset = Entries.back().IncludeOffset;<br>
-  }<br>
-<br>
-  Entries.push_back(LineEntry::<wbr>get(Offset, LineNo, FilenameID, Kind,<br>
-                                   IncludeOffset));<br>
-}<br>
-<br>
-/// AddLineNote This is the same as the previous version of AddLineNote, but is<br>
-/// used for GNU line markers.  If EntryExit is 0, then this doesn't change the<br>
-/// presumed \#include stack.  If it is 1, this is a file entry, if it is 2 then<br>
-/// this is a file exit.  FileKind specifies whether this is a system header or<br>
-/// extern C system header.<br>
-void LineTableInfo::AddLineNote(<wbr>FileID FID, unsigned Offset,<br>
-                                unsigned LineNo, int FilenameID,<br>
-                                unsigned EntryExit,<br>
+/// Add a line note to the line table that indicates that there is a \#line or<br>
+/// GNU line marker at the specified FID/Offset location which changes the<br>
+/// presumed location to LineNo/FilenameID. If EntryExit is 0, then this doesn't<br>
+/// change the presumed \#include stack.  If it is 1, this is a file entry, if<br>
+/// it is 2 then this is a file exit. FileKind specifies whether this is a<br>
+/// system header or extern C system header.<br>
+void LineTableInfo::AddLineNote(<wbr>FileID FID, unsigned Offset, unsigned LineNo,<br>
+                                int FilenameID, unsigned EntryExit,<br>
                                 SrcMgr::CharacteristicKind FileKind) {<br>
-  assert(FilenameID != -1 && "Unspecified filename should use other accessor");<br>
-<br>
   std::vector<LineEntry> &Entries = LineEntries[FID];<br>
<br>
+  // An unspecified FilenameID means use the last filename if available, or the<br>
+  // main source file otherwise.<br>
+  if (FilenameID == -1 && !Entries.empty())<br>
+    FilenameID = Entries.back().FilenameID;<br>
+<br>
   assert((Entries.empty() || Entries.back().FileOffset < Offset) &&<br>
          "Adding line entries out of order!");<br>
<br>
@@ -281,47 +255,20 @@ unsigned SourceManager::<wbr>getLineTableFile<br>
   return getLineTable().<wbr>getLineTableFilenameID(Name);<br>
 }<br>
<br>
-<br>
 /// AddLineNote - Add a line note to the line table for the FileID and offset<br>
 /// specified by Loc.  If FilenameID is -1, it is considered to be<br>
 /// unspecified.<br>
 void SourceManager::AddLineNote(<wbr>SourceLocation Loc, unsigned LineNo,<br>
-                                int FilenameID) {<br>
-  std::pair<FileID, unsigned> LocInfo = getDecomposedExpansionLoc(Loc)<wbr>;<br>
-<br>
-  bool Invalid = false;<br>
-  const SLocEntry &Entry = getSLocEntry(LocInfo.first, &Invalid);<br>
-  if (!Entry.isFile() || Invalid)<br>
-    return;<br>
-<br>
-  const SrcMgr::FileInfo &FileInfo = Entry.getFile();<br>
-<br>
-  // Remember that this file has #line directives now if it doesn't already.<br>
-  const_cast<SrcMgr::FileInfo&>(<wbr>FileInfo).<wbr>setHasLineDirectives();<br>
-<br>
-  getLineTable().AddLineNote(<wbr>LocInfo.first, LocInfo.second, LineNo, FilenameID);<br>
-}<br>
-<br>
-/// AddLineNote - Add a GNU line marker to the line table.<br>
-void SourceManager::AddLineNote(<wbr>SourceLocation Loc, unsigned LineNo,<br>
                                 int FilenameID, bool IsFileEntry,<br>
-                                bool IsFileExit, bool IsSystemHeader,<br>
-                                bool IsExternCHeader) {<br>
-  // If there is no filename and no flags, this is treated just like a #line,<br>
-  // which does not change the flags of the previous line marker.<br>
-  if (FilenameID == -1) {<br>
-    assert(!IsFileEntry && !IsFileExit && !IsSystemHeader && !IsExternCHeader &&<br>
-           "Can't set flags without setting the filename!");<br>
-    return AddLineNote(Loc, LineNo, FilenameID);<br>
-  }<br>
-<br>
+                                bool IsFileExit,<br>
+                                SrcMgr::CharacteristicKind FileKind) {<br>
   std::pair<FileID, unsigned> LocInfo = getDecomposedExpansionLoc(Loc)<wbr>;<br>
<br>
   bool Invalid = false;<br>
   const SLocEntry &Entry = getSLocEntry(LocInfo.first, &Invalid);<br>
   if (!Entry.isFile() || Invalid)<br>
     return;<br>
-<br>
+<br>
   const SrcMgr::FileInfo &FileInfo = Entry.getFile();<br>
<br>
   // Remember that this file has #line directives now if it doesn't already.<br>
@@ -329,14 +276,6 @@ void SourceManager::AddLineNote(<wbr>SourceLo<br>
<br>
   (void) getLineTable();<br>
<br>
-  SrcMgr::CharacteristicKind FileKind;<br>
-  if (IsExternCHeader)<br>
-    FileKind = SrcMgr::C_ExternCSystem;<br>
-  else if (IsSystemHeader)<br>
-    FileKind = SrcMgr::C_System;<br>
-  else<br>
-    FileKind = SrcMgr::C_User;<br>
-<br>
   unsigned EntryExit = 0;<br>
   if (IsFileEntry)<br>
     EntryExit = 1;<br>
<br>
Modified: cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=303582&r1=303581&r2=303582&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/<wbr>Frontend/FrontendAction.cpp?<wbr>rev=303582&r1=303581&r2=<wbr>303582&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp (original)<br>
+++ cfe/trunk/lib/Frontend/<wbr>FrontendAction.cpp Mon May 22 16:42:58 2017<br>
@@ -252,7 +252,8 @@ static SourceLocation ReadOriginalFileNa<br>
<br>
   if (AddLineNote)<br>
     CI.getSourceManager().<wbr>AddLineNote(<br>
-        LineNoLoc, LineNo, SourceMgr.<wbr>getLineTableFilenameID(<wbr>InputFile));<br>
+        LineNoLoc, LineNo, SourceMgr.<wbr>getLineTableFilenameID(<wbr>InputFile), false,<br>
+        false, SrcMgr::C_User);<br>
<br>
   return T.getLocation();<br>
 }<br>
<br>
Modified: cfe/trunk/lib/Lex/<wbr>PPDirectives.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=303582&r1=303581&r2=303582&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Lex/<wbr>PPDirectives.cpp?rev=303582&<wbr>r1=303581&r2=303582&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Lex/<wbr>PPDirectives.cpp (original)<br>
+++ cfe/trunk/lib/Lex/<wbr>PPDirectives.cpp Mon May 22 16:42:58 2017<br>
@@ -1171,18 +1171,26 @@ void Preprocessor::<wbr>HandleLineDirective()<br>
     CheckEndOfDirective("line", true);<br>
   }<br>
<br>
-  SourceMgr.AddLineNote(<wbr>DigitTok.getLocation(), LineNo, FilenameID);<br>
+  // Take the file kind of the file containing the #line directive. #line<br>
+  // directives are often used for generated sources from the same codebase, so<br>
+  // the new file should generally be classified the same way as the current<br>
+  // file. This is visible in GCC's pre-processed output, which rewrites #line<br>
+  // to GNU line markers.<br>
+  SrcMgr::CharacteristicKind FileKind =<br>
+      SourceMgr.<wbr>getFileCharacteristic(<wbr>DigitTok.getLocation());<br>
+<br>
+  SourceMgr.AddLineNote(<wbr>DigitTok.getLocation(), LineNo, FilenameID, false,<br>
+                        false, FileKind);<br>
<br>
   if (Callbacks)<br>
     Callbacks->FileChanged(<wbr>CurPPLexer->getSourceLocation(<wbr>),<br>
-                           PPCallbacks::RenameFile,<br>
-                           SrcMgr::C_User);<br>
+                           PPCallbacks::RenameFile, FileKind);<br>
 }<br>
<br>
 /// ReadLineMarkerFlags - Parse and validate any flags at the end of a GNU line<br>
 /// marker directive.<br>
 static bool ReadLineMarkerFlags(bool &IsFileEntry, bool &IsFileExit,<br>
-                                bool &IsSystemHeader, bool &IsExternCHeader,<br>
+                                SrcMgr::CharacteristicKind &FileKind,<br>
                                 Preprocessor &PP) {<br>
   unsigned FlagVal;<br>
   Token FlagTok;<br>
@@ -1233,7 +1241,7 @@ static bool ReadLineMarkerFlags(bool &Is<br>
     return true;<br>
   }<br>
<br>
-  IsSystemHeader = true;<br>
+  FileKind = SrcMgr::C_System;<br>
<br>
   PP.Lex(FlagTok);<br>
   if (FlagTok.is(tok::eod)) return false;<br>
@@ -1247,7 +1255,7 @@ static bool ReadLineMarkerFlags(bool &Is<br>
     return true;<br>
   }<br>
<br>
-  IsExternCHeader = true;<br>
+  FileKind = SrcMgr::C_ExternCSystem;<br>
<br>
   PP.Lex(FlagTok);<br>
   if (FlagTok.is(tok::eod)) return false;<br>
@@ -1277,14 +1285,15 @@ void Preprocessor::<wbr>HandleDigitDirective(<br>
   Lex(StrTok);<br>
<br>
   bool IsFileEntry = false, IsFileExit = false;<br>
-  bool IsSystemHeader = false, IsExternCHeader = false;<br>
   int FilenameID = -1;<br>
+  SrcMgr::CharacteristicKind FileKind = SrcMgr::C_User;<br>
<br>
   // If the StrTok is "eod", then it wasn't present.  Otherwise, it must be a<br>
   // string followed by eod.<br>
-  if (StrTok.is(tok::eod))<br>
-    ; // ok<br>
-  else if (StrTok.isNot(tok::string_<wbr>literal)) {<br>
+  if (StrTok.is(tok::eod)) {<br>
+    // Treat this like "#line NN", which doesn't change file characteristics.<br>
+    FileKind = SourceMgr.<wbr>getFileCharacteristic(<wbr>DigitTok.getLocation());<br></blockquote><div><br></div><div>This change for "# <number>" handling makes sense (and I've checked and it matches GCC), but it looks like we don't have test coverage for either the old or new behavior. Can I interest you in adding some? :)</div><div><br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
+  } else if (StrTok.isNot(tok::string_<wbr>literal)) {<br>
     Diag(StrTok, diag::err_pp_linemarker_<wbr>invalid_filename);<br>
     return DiscardUntilEndOfDirective();<br>
   } else if (StrTok.hasUDSuffix()) {<br>
@@ -1303,15 +1312,13 @@ void Preprocessor::<wbr>HandleDigitDirective(<br>
     FilenameID = SourceMgr.<wbr>getLineTableFilenameID(<wbr>Literal.GetString());<br>
<br>
     // If a filename was present, read any flags that are present.<br>
-    if (ReadLineMarkerFlags(<wbr>IsFileEntry, IsFileExit,<br>
-                            IsSystemHeader, IsExternCHeader, *this))<br>
+    if (ReadLineMarkerFlags(<wbr>IsFileEntry, IsFileExit, FileKind, *this))<br>
       return;<br>
   }<br>
<br>
   // Create a line note with this information.<br>
-  SourceMgr.AddLineNote(<wbr>DigitTok.getLocation(), LineNo, FilenameID,<br>
-                        IsFileEntry, IsFileExit,<br>
-                        IsSystemHeader, IsExternCHeader);<br>
+  SourceMgr.AddLineNote(<wbr>DigitTok.getLocation(), LineNo, FilenameID, IsFileEntry,<br>
+                        IsFileExit, FileKind);<br>
<br>
   // If the preprocessor has callbacks installed, notify them of the #line<br>
   // change.  This is used so that the line marker comes out in -E mode for<br>
@@ -1322,11 +1329,6 @@ void Preprocessor::<wbr>HandleDigitDirective(<br>
       Reason = PPCallbacks::EnterFile;<br>
     else if (IsFileExit)<br>
       Reason = PPCallbacks::ExitFile;<br>
-    SrcMgr::CharacteristicKind FileKind = SrcMgr::C_User;<br>
-    if (IsExternCHeader)<br>
-      FileKind = SrcMgr::C_ExternCSystem;<br>
-    else if (IsSystemHeader)<br>
-      FileKind = SrcMgr::C_System;<br>
<br>
     Callbacks->FileChanged(<wbr>CurPPLexer->getSourceLocation(<wbr>), Reason, FileKind);<br>
   }<br>
<br>
Modified: cfe/trunk/lib/Lex/Pragma.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=303582&r1=303581&r2=303582&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/lib/Lex/<wbr>Pragma.cpp?rev=303582&r1=<wbr>303581&r2=303582&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/Lex/Pragma.cpp (original)<br>
+++ cfe/trunk/lib/Lex/Pragma.cpp Mon May 22 16:42:58 2017<br>
@@ -475,9 +475,9 @@ void Preprocessor::<wbr>HandlePragmaSystemHea<br>
   // Emit a line marker.  This will change any source locations from this point<br>
   // forward to realize they are in a system header.<br>
   // Create a line note with this information.<br>
-  SourceMgr.AddLineNote(<wbr>SysHeaderTok.getLocation(), PLoc.getLine()+1,<br>
+  SourceMgr.AddLineNote(<wbr>SysHeaderTok.getLocation(), PLoc.getLine() + 1,<br>
                         FilenameID, /*IsEntry=*/false, /*IsExit=*/false,<br>
-                        /*IsSystem=*/true, /*IsExternC=*/false);<br>
+                        SrcMgr::C_System);<br>
 }<br>
<br>
 /// HandlePragmaDependency - Handle \#pragma GCC dependency "foo" blah.<br>
<br>
Added: cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>line.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/line.h?rev=303582&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Frontend/Inputs/<wbr>SystemHeaderPrefix/line.h?rev=<wbr>303582&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>line.h (added)<br>
+++ cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>line.h Mon May 22 16:42:58 2017<br>
@@ -0,0 +1,2 @@<br>
+#line 1 "foo.h"<br>
+foo();<br>
<br>
Added: cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>noline.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/Inputs/SystemHeaderPrefix/noline.h?rev=303582&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Frontend/Inputs/<wbr>SystemHeaderPrefix/noline.h?<wbr>rev=303582&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>noline.h (added)<br>
+++ cfe/trunk/test/Frontend/<wbr>Inputs/SystemHeaderPrefix/<wbr>noline.h Mon May 22 16:42:58 2017<br>
@@ -0,0 +1 @@<br>
+foo();<br>
<br>
Added: cfe/trunk/test/Frontend/<wbr>system-header-line-directive.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Frontend/system-header-line-directive.c?rev=303582&view=auto" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project/cfe/trunk/test/<wbr>Frontend/system-header-line-<wbr>directive.c?rev=303582&view=<wbr>auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/Frontend/<wbr>system-header-line-directive.c (added)<br>
+++ cfe/trunk/test/Frontend/<wbr>system-header-line-directive.c Mon May 22 16:42:58 2017<br>
@@ -0,0 +1,20 @@<br>
+// RUN: %clang_cc1 -Wall %s -isystem %S/Inputs/SystemHeaderPrefix -verify<br>
+// RUN: %clang_cc1 %s -E -o - -isystem %S/Inputs/SystemHeaderPrefix | FileCheck %s<br>
+#include <noline.h><br>
+#include <line.h><br>
+<br>
+// This tests that "#line" directives in system headers preserve system<br>
+// header-ness just like GNU line markers that don't have filenames.  This was<br>
+// PR30752.<br>
+<br>
+// expected-no-diagnostics<br>
+<br>
+// CHECK: # {{[0-9]+}} "{{.*}}system-header-line-<wbr>directive.c" 2<br>
+// CHECK: # 1 "{{.*}}noline.h" 1 3<br>
+// CHECK: foo();<br>
+// CHECK: # 4 "{{.*}}system-header-line-<wbr>directive.c" 2<br>
+// CHECK: # 1 "{{.*}}line.h" 1 3<br>
+//      The "3" below indicates that "foo.h" is considered a system header.<br>
+// CHECK: # 1 "foo.h" 3<br>
+// CHECK: foo();<br>
+// CHECK: # {{[0-9]+}} "{{.*}}system-header-line-<wbr>directive.c" 2<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br></div></div>