[cfe-commits] [PATCH] Speed up parsing of global declarations.

Manuel Klimek klimek at google.com
Tue Dec 11 05:00:35 PST 2012



================
Comment at: lib/Sema/SemaDecl.cpp:7242
@@ -7241,2 +7241,3 @@
 
-    if (!prev)
+      if (!prev && getDiagnostics().getDiagnosticLevel(
+                       diag::warn_missing_variable_declarations,
----------------
Benjamin Kramer wrote:
> Manuel Klimek wrote:
> > Joey Gouly wrote:
> > > I'm just wondering if we couldn't make this check on all diagnostics. 
> > On IRC Chandler proposed yesterday that a long-term solution to this problem would be to change diagnostics to a pattern like:
> > if (DiagStream *DS = Diag(var-getLocation(), diag::warn...) {
> >   *DS << var;
> > }
> > 
> > I personally think that's a good plan, but orthogonal to us fixing where we're missing checks in the hot path right now.
> Should the check be hoisted up a level so the decls aren't walked when we're not going to emit a warning?
Yep. And another small speedup (~0.8%) on our real-world benchmark :) Thx!

================
Comment at: lib/Basic/DiagnosticIDs.cpp:227
@@ +226,3 @@
+static std::pair<unsigned, bool>
+DiagnosticClassCache[diag::DIAG_UPPER_LIMIT] = {};
+
----------------
Joey Gouly wrote:
> You need to remove the "= {}" for this to be ok under C++98.
Done. By the way, if you know a better solution than using pairs here I'd be all ears... Especially since DiagClass really only has 4 values... (5 if you count the invalid state)


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



More information about the cfe-commits mailing list