r285057 - Include full filename range for missing includes

Erik Verbruggen via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 25 03:13:10 PDT 2016


Author: erikjv
Date: Tue Oct 25 05:13:10 2016
New Revision: 285057

URL: http://llvm.org/viewvc/llvm-project?rev=285057&view=rev
Log:
Include full filename range for missing includes

For the purpose of highlighting in an IDE.

Added:
    cfe/trunk/test/Preprocessor/missing-include-range-check.h
Modified:
    cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=285057&r1=285056&r2=285057&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Tue Oct 25 05:13:10 2016
@@ -1847,7 +1847,8 @@ void Preprocessor::HandleIncludeDirectiv
 
       // If the file is still not found, just go with the vanilla diagnostic
       if (!File)
-        Diag(FilenameTok, diag::err_pp_file_not_found) << Filename;
+        Diag(FilenameTok, diag::err_pp_file_not_found) << Filename
+                                                       << FilenameRange;
     }
   }
 

Added: cfe/trunk/test/Preprocessor/missing-include-range-check.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/missing-include-range-check.h?rev=285057&view=auto
==============================================================================
--- cfe/trunk/test/Preprocessor/missing-include-range-check.h (added)
+++ cfe/trunk/test/Preprocessor/missing-include-range-check.h Tue Oct 25 05:13:10 2016
@@ -0,0 +1,8 @@
+// RUN: env CINDEXTEST_KEEP_GOING=1 c-index-test -test-load-source all %s > /dev/null 2> %t.err
+// RUN: FileCheck < %t.err -check-prefix=CHECK-RANGE %s
+
+#include <foobar.h>
+#include "moozegnarf.h"
+
+// CHECK-RANGE: rewrite-includes-missing.c:4:10:{4:10-4:19}: fatal error: 'foobar.h' file not found
+// CHECK-RANGE: rewrite-includes-missing.c:5:10:{5:10-5:24}: fatal error: 'moozegnarf.h' file not found




More information about the cfe-commits mailing list