- Merge branch 'master' into fix-speed
    - Incorperate review feedback.

http://llvm-reviews.chandlerc.com/D197

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D197?vs=480&id=495#toc

Files:
  lib/Basic/DiagnosticIDs.cpp
  lib/Sema/SemaDecl.cpp

Index: lib/Basic/DiagnosticIDs.cpp
===================================================================
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -222,12 +222,20 @@
   return SFINAE_Report;
 }
 
+/// \brief Cache lookup of the DiagID -> ClassInfo ID mapping.
+static std::pair<unsigned, bool> DiagnosticClassCache[diag::DIAG_UPPER_LIMIT];
+
 /// getBuiltinDiagClass - Return the class field of the diagnostic.
 ///
 static unsigned getBuiltinDiagClass(unsigned DiagID) {
+  if (DiagnosticClassCache[DiagID].second) {
+    return DiagnosticClassCache[DiagID].first;
+  }
+  unsigned DiagClass = ~0U;
   if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
-    return Info->Class;
-  return ~0U;
+    DiagClass = Info->Class;
+  DiagnosticClassCache[DiagID] = std::make_pair(DiagClass, true);
+  return DiagClass;
 }
 
 
//===----------------------------------------------------------------------===//
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7232,7 +7232,10 @@
     }
   }
 
-  if (var->isThisDeclarationADefinition() &&
+  if (getDiagnostics().getDiagnosticLevel(
+                       diag::warn_missing_variable_declarations,
+                       var->getLocation()) &&
+      var->isThisDeclarationADefinition() &&
       var->getLinkage() == ExternalLinkage) {
     // Find a previous declaration that's not a definition.
     VarDecl *prev = var->getPreviousDecl();
Index: lib/Basic/DiagnosticIDs.cpp
===================================================================
--- lib/Basic/DiagnosticIDs.cpp
+++ lib/Basic/DiagnosticIDs.cpp
@@ -222,12 +222,20 @@
   return SFINAE_Report;
 }
 
+/// \brief Cache lookup of the DiagID -> ClassInfo ID mapping.
+static std::pair<unsigned, bool> DiagnosticClassCache[diag::DIAG_UPPER_LIMIT];
+
 /// getBuiltinDiagClass - Return the class field of the diagnostic.
 ///
 static unsigned getBuiltinDiagClass(unsigned DiagID) {
+  if (DiagnosticClassCache[DiagID].second) {
+    return DiagnosticClassCache[DiagID].first;
+  }
+  unsigned DiagClass = ~0U;
   if (const StaticDiagInfoRec *Info = GetDiagInfo(DiagID))
-    return Info->Class;
-  return ~0U;
+    DiagClass = Info->Class;
+  DiagnosticClassCache[DiagID] = std::make_pair(DiagClass, true);
+  return DiagClass;
 }
 
 //===----------------------------------------------------------------------===//
Index: lib/Sema/SemaDecl.cpp
===================================================================
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -7232,7 +7232,10 @@
     }
   }
 
-  if (var->isThisDeclarationADefinition() &&
+  if (getDiagnostics().getDiagnosticLevel(
+                       diag::warn_missing_variable_declarations,
+                       var->getLocation()) &&
+      var->isThisDeclarationADefinition() &&
       var->getLinkage() == ExternalLinkage) {
     // Find a previous declaration that's not a definition.
     VarDecl *prev = var->getPreviousDecl();
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to