]> granicus.if.org Git - clang/commitdiff
Per discussion on cfe-dev, remove '#error' and '#warning' from diagnostic text.
authorTed Kremenek <kremenek@apple.com>
Thu, 2 Feb 2012 00:16:13 +0000 (00:16 +0000)
committerTed Kremenek <kremenek@apple.com>
Thu, 2 Feb 2012 00:16:13 +0000 (00:16 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@149566 91177308-0d34-0410-b5e6-96231b3b80d8

include/clang/Basic/DiagnosticLexKinds.td
lib/Lex/PPDirectives.cpp
test/Frontend/rewrite-macros.c
test/Index/retain-target-options.c
test/Misc/serialized-diags-no-category.c
test/Misc/warn-in-system-header.c
test/Preprocessor/line-directive.c

index 3a564c4aa81577260f8fc852029894526cea03db..fde522c573d48acbc9ada5e732314cfbc1f24087 100644 (file)
@@ -148,8 +148,13 @@ def err_invalid_pth_file : Error<
 //===----------------------------------------------------------------------===//
 // Preprocessor Diagnostics
 //===----------------------------------------------------------------------===//
-def pp_hash_warning : Warning<"#warning%0">,
+
+let CategoryName = "User Defined Issues" in {
+def pp_hash_warning : Warning<"%0">,
   InGroup<PoundWarning>, DefaultWarnShowInSystemHeader;
+def err_pp_hash_error : Error<"%0">;
+}
+
 def pp_include_next_in_primary : Warning<
   "#include_next in primary source file">;
 def pp_include_macros_out_of_predefines : Error<
@@ -223,7 +228,6 @@ def warn_cxx98_compat_empty_fnmacro_arg : Warning<
   InGroup<CXX98CompatPedantic>, DefaultIgnore;
 
 def err_pp_invalid_directive : Error<"invalid preprocessing directive">;
-def err_pp_hash_error : Error<"#error%0">;
 def err_pp_file_not_found : Error<"'%0' file not found">, DefaultFatal;
 def err_pp_error_opening_file : Error<
   "error opening file '%0': %1">, DefaultFatal;
index 76955604b08a7b826ea97d847b6699d695983a2f..9f2309e801daf52204bed688a8ece9e6bb45cb08 100644 (file)
@@ -1007,10 +1007,18 @@ void Preprocessor::HandleUserDiagnosticDirective(Token &Tok,
   // collapse multiple consequtive white space between tokens, but this isn't
   // specified by the standard.
   std::string Message = CurLexer->ReadToEndOfLine();
+
+  // Find the first non-whitespace character, so that we can make the
+  // diagnostic more succinct.
+  StringRef Msg(Message);
+  size_t i = Msg.find_first_not_of(' ');
+  if (i < Msg.size())
+    Msg = Msg.substr(i);
+  
   if (isWarning)
-    Diag(Tok, diag::pp_hash_warning) << Message;
+    Diag(Tok, diag::pp_hash_warning) << Msg;
   else
-    Diag(Tok, diag::err_pp_hash_error) << Message;
+    Diag(Tok, diag::err_pp_hash_error) << Msg;
 }
 
 /// HandleIdentSCCSDirective - Handle a #ident/#sccs directive.
index f44e545728e906fde1c8ae48a4913fff05c7620a..bc7479693bf50ec7046d60bbd904711a6296bf8e 100644 (file)
@@ -9,7 +9,7 @@ A(1,2)
 _Pragma("mark")
 
 // RUN: grep "//#warning eek" %t
-/* expected-warning {{#warning eek}} */ #warning eek
+/* expected-warning {{eek}} */ #warning eek
 
 // RUN: grep "//#pragma mark mark" %t
 #pragma mark mark
index 797971d12ce6c4f2bc06739cd920ff84c2446f9a..2fba476fb1ee8f0f9bde87c119cc7905c9b3158f 100644 (file)
@@ -2,7 +2,7 @@
 // RUN: c-index-test -test-load-source-reparse 1 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
 // RUN: c-index-test -test-load-source-reparse 5 all -target x86_64-apple-darwin10.0.0 -msse4.1 %s 2>&1 | FileCheck %s
 
-// CHECK: error: #error SSE4_1 used
+// CHECK: error: SSE4_1 used
 #if defined(__SSE4_1__)
 #error SSE4_1 used
 #endif
index 9c92ac33309d427e730db7711c7017fd07221a8b..3074892e0ebbb026c86671c0ee377c2c1dff7e5a 100644 (file)
@@ -7,6 +7,6 @@
 
 // This test case tests that we can handle both fatal errors and errors without categories.
 
-// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: #error foo []
+// CHECK: {{.*[/\\]}}serialized-diags-no-category.c:1:2: error: foo []
 // CHECK: Number of diagnostics: 2
 
index 7e4615e65efa29d19f5cdb210d67f8f7989c31a6..6e0237d0dcdc2e9e23744951f5ee8d1a38ee7c05 100644 (file)
@@ -1,4 +1,4 @@
 // RUN: %clang_cc1 -isystem %S %s -fsyntax-only -verify 
 
 #include <warn-in-system-header.h>
-// expected-warning {{#warning}}
+// expected-warning {{the cake is a lie}}
index 102469449e1232344e37b86535777cb29b7ed6ed..28e93029a5ce4a38659aaadabeab8bd325053f37 100644 (file)
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -pedantic %s
-// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: #error ABC'
-// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: #error DEF'
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:92:2: error: ABC'
+// RUN: %clang_cc1 -E %s 2>&1 | grep 'blonk.c:93:2: error: DEF'
 
 #line 'a'            // expected-error {{#line directive requires a positive integer argument}}
 #line 0              // expected-error {{#line directive requires a positive integer argument}}