[cfe-commits] r59798 - /cfe/trunk/include/clang/Basic/Diagnostic.h

Chris Lattner sabre at nondot.org
Thu Nov 20 22:59:12 PST 2008


Author: lattner
Date: Fri Nov 21 00:59:12 2008
New Revision: 59798

URL: http://llvm.org/viewvc/llvm-project?rev=59798&view=rev
Log:
move the diagnostic location and ID out of DiagnosticInfo and store it in
the Diagnostic class. Since we can already only have one diagnostic in 
flight at a time, this shrinks DiagnosticInfo.

This reduces DiagnosticInfo to being basically a rather crazy smart pointer
to a DiagnosticInfo :)


Modified:
    cfe/trunk/include/clang/Basic/Diagnostic.h

Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Diagnostic.h?rev=59798&r1=59797&r2=59798&view=diff

==============================================================================
--- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
+++ cfe/trunk/include/clang/Basic/Diagnostic.h Fri Nov 21 00:59:12 2008
@@ -182,7 +182,14 @@
   // tradeoff to keep these objects small.  Assertions verify that only one
   // diagnostic is in flight at a time.
   friend class DiagnosticInfo;
+
+  /// CurDiagLoc - This is the location of the current diagnostic that is in
+  /// flight.
+  FullSourceLoc CurDiagLoc;
   
+  /// CurDiagID - This is the ID of the current diagnostic that is in flight.
+  unsigned CurDiagID;
+
   enum {
     /// MaxArguments - The maximum number of arguments we can hold. We currently
     /// only support up to 10 arguments (%0-%9).  A single diagnostic with more
@@ -233,8 +240,6 @@
 /// for more info.
 class DiagnosticInfo {
   mutable Diagnostic *DiagObj;
-  FullSourceLoc Loc;
-  unsigned DiagID;
   void operator=(const DiagnosticInfo&); // DO NOT IMPLEMENT
 public:
   enum ArgumentKind {
@@ -246,20 +251,20 @@
   };
   
   
-  DiagnosticInfo(Diagnostic *diagObj, FullSourceLoc loc, unsigned diagID) :
-    DiagObj(diagObj), Loc(loc), DiagID(diagID) {
+  DiagnosticInfo(Diagnostic *diagObj, FullSourceLoc Loc, unsigned DiagID) :
+    DiagObj(diagObj) {
     if (DiagObj == 0) return;
     assert(DiagObj->NumDiagArgs == -1 &&
            "Multiple diagnostics in flight at once!");
     DiagObj->NumDiagArgs = DiagObj->NumDiagRanges = 0;
+    DiagObj->CurDiagLoc = Loc;
+    DiagObj->CurDiagID = DiagID;
   }
   
   /// Copy constructor.  When copied, this "takes" the diagnostic info from the
   /// input and neuters it.
   DiagnosticInfo(const DiagnosticInfo &D) {
     DiagObj = D.DiagObj;
-    Loc = D.Loc;
-    DiagID = D.DiagID;
     D.DiagObj = 0;
   }
   
@@ -275,8 +280,8 @@
   }
   
   const Diagnostic *getDiags() const { return DiagObj; }
-  unsigned getID() const { return DiagID; }
-  const FullSourceLoc &getLocation() const { return Loc; }
+  unsigned getID() const { return DiagObj->CurDiagID; }
+  const FullSourceLoc &getLocation() const { return DiagObj->CurDiagLoc; }
   
   /// Operator bool: conversion of DiagnosticInfo to bool always returns true.
   /// This allows is to be used in boolean error contexts like:





More information about the cfe-commits mailing list