[cfe-commits] r39448 - in /cfe/cfe/trunk: AST/Sema.cpp AST/Sema.h Sema/Sema.cpp Sema/Sema.h

clattner at cs.uiuc.edu clattner at cs.uiuc.edu
Wed Jul 11 09:44:32 PDT 2007


Author: clattner
Date: Wed Jul 11 11:44:32 2007
New Revision: 39448

URL: http://llvm.org/viewvc/llvm-project?rev=39448&view=rev
Log:
Add helper to emit two strings for a diagnostic.

Modified:
    cfe/cfe/trunk/AST/Sema.cpp
    cfe/cfe/trunk/AST/Sema.h
    cfe/cfe/trunk/Sema/Sema.cpp
    cfe/cfe/trunk/Sema/Sema.h

Modified: cfe/cfe/trunk/AST/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.cpp?rev=39448&r1=39447&r2=39448&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/Sema.cpp (original)
+++ cfe/cfe/trunk/AST/Sema.cpp Wed Jul 11 11:44:32 2007
@@ -15,6 +15,7 @@
 #include "Sema.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Basic/Diagnostic.h"
 using namespace llvm;
 using namespace clang;
 
@@ -26,20 +27,37 @@
 // Helper functions.
 //===----------------------------------------------------------------------===//
 
+bool Sema::Diag(SourceLocation Loc, unsigned DiagID) {
+  PP.getDiagnostics().Report(Loc, DiagID);
+  return true;
+}
+
 bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) {
-  PP.Diag(Loc, DiagID, Msg);
+  PP.getDiagnostics().Report(Loc, DiagID, &Msg, 1);
+  return true;
+}
+
+bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
+                const std::string &Msg2) {
+  std::string MsgArr[] = { Msg1, Msg2 };
+  PP.getDiagnostics().Report(Loc, DiagID, MsgArr, 2);
   return true;
 }
 
 bool Sema::Diag(SourceLocation Loc, unsigned DiagID, QualType t) {
   std::string Name;
   t.getAsString(Name);
-  PP.Diag(Loc, DiagID, Name);
+  PP.getDiagnostics().Report(Loc, DiagID, &Name, 1);
+  return true;
+}
+
+bool Sema::Diag(const LexerToken &Tok, unsigned DiagID) {
+  PP.getDiagnostics().Report(Tok.getLocation(), DiagID);
   return true;
 }
 
 bool Sema::Diag(const LexerToken &Tok, unsigned DiagID, const std::string &M) {
-  Diag(Tok.getLocation(), DiagID, M);
+  PP.getDiagnostics().Report(Tok.getLocation(), DiagID, &M, 1);
   return true;
 }
 

Modified: cfe/cfe/trunk/AST/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/AST/Sema.h?rev=39448&r1=39447&r2=39448&view=diff

==============================================================================
--- cfe/cfe/trunk/AST/Sema.h (original)
+++ cfe/cfe/trunk/AST/Sema.h Wed Jul 11 11:44:32 2007
@@ -56,10 +56,12 @@
   const LangOptions &getLangOptions() const;
   
   /// always returns true, which simplifies error handling (i.e. less code).
-  bool Diag(SourceLocation Loc, unsigned DiagID,
-            const std::string &Msg = std::string());
-  bool Diag(const LexerToken &Tok, unsigned DiagID,
-            const std::string &M = std::string());
+  bool Diag(SourceLocation Loc, unsigned DiagID);
+  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg);
+  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
+            const std::string &Msg2);
+  bool Diag(const LexerToken &Tok, unsigned DiagID);
+  bool Diag(const LexerToken &Tok, unsigned DiagID, const std::string &M);
   bool Diag(SourceLocation Loc, unsigned DiagID, QualType t);
   
   //===--------------------------------------------------------------------===//

Modified: cfe/cfe/trunk/Sema/Sema.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.cpp?rev=39448&r1=39447&r2=39448&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/Sema.cpp (original)
+++ cfe/cfe/trunk/Sema/Sema.cpp Wed Jul 11 11:44:32 2007
@@ -15,6 +15,7 @@
 #include "Sema.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/Lex/Preprocessor.h"
+#include "clang/Basic/Diagnostic.h"
 using namespace llvm;
 using namespace clang;
 
@@ -26,20 +27,37 @@
 // Helper functions.
 //===----------------------------------------------------------------------===//
 
+bool Sema::Diag(SourceLocation Loc, unsigned DiagID) {
+  PP.getDiagnostics().Report(Loc, DiagID);
+  return true;
+}
+
 bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg) {
-  PP.Diag(Loc, DiagID, Msg);
+  PP.getDiagnostics().Report(Loc, DiagID, &Msg, 1);
+  return true;
+}
+
+bool Sema::Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
+                const std::string &Msg2) {
+  std::string MsgArr[] = { Msg1, Msg2 };
+  PP.getDiagnostics().Report(Loc, DiagID, MsgArr, 2);
   return true;
 }
 
 bool Sema::Diag(SourceLocation Loc, unsigned DiagID, QualType t) {
   std::string Name;
   t.getAsString(Name);
-  PP.Diag(Loc, DiagID, Name);
+  PP.getDiagnostics().Report(Loc, DiagID, &Name, 1);
+  return true;
+}
+
+bool Sema::Diag(const LexerToken &Tok, unsigned DiagID) {
+  PP.getDiagnostics().Report(Tok.getLocation(), DiagID);
   return true;
 }
 
 bool Sema::Diag(const LexerToken &Tok, unsigned DiagID, const std::string &M) {
-  Diag(Tok.getLocation(), DiagID, M);
+  PP.getDiagnostics().Report(Tok.getLocation(), DiagID, &M, 1);
   return true;
 }
 

Modified: cfe/cfe/trunk/Sema/Sema.h
URL: http://llvm.org/viewvc/llvm-project/cfe/cfe/trunk/Sema/Sema.h?rev=39448&r1=39447&r2=39448&view=diff

==============================================================================
--- cfe/cfe/trunk/Sema/Sema.h (original)
+++ cfe/cfe/trunk/Sema/Sema.h Wed Jul 11 11:44:32 2007
@@ -56,10 +56,12 @@
   const LangOptions &getLangOptions() const;
   
   /// always returns true, which simplifies error handling (i.e. less code).
-  bool Diag(SourceLocation Loc, unsigned DiagID,
-            const std::string &Msg = std::string());
-  bool Diag(const LexerToken &Tok, unsigned DiagID,
-            const std::string &M = std::string());
+  bool Diag(SourceLocation Loc, unsigned DiagID);
+  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg);
+  bool Diag(SourceLocation Loc, unsigned DiagID, const std::string &Msg1,
+            const std::string &Msg2);
+  bool Diag(const LexerToken &Tok, unsigned DiagID);
+  bool Diag(const LexerToken &Tok, unsigned DiagID, const std::string &M);
   bool Diag(SourceLocation Loc, unsigned DiagID, QualType t);
   
   //===--------------------------------------------------------------------===//





More information about the cfe-commits mailing list