]> granicus.if.org Git - clang/commitdiff
Avoid doing two switches in TypeLoc's initialize() loop. The optimizer
authorJohn McCall <rjmccall@apple.com>
Sun, 16 May 2010 02:09:32 +0000 (02:09 +0000)
committerJohn McCall <rjmccall@apple.com>
Sun, 16 May 2010 02:09:32 +0000 (02:09 +0000)
can probably do this for us, but it's actually somewhat nicer to write it
out here.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@103893 91177308-0d34-0410-b5e6-96231b3b80d8

lib/AST/TypeLoc.cpp

index fd9fbc191868a9b24598665fd3c7c71920e12683..e66738a65da4be706822f68afdfdcea8898acdcb 100644 (file)
@@ -92,9 +92,20 @@ namespace {
 /// recursively, as if the entire tree had been written in the
 /// given location.
 void TypeLoc::initializeImpl(TypeLoc TL, SourceLocation Loc) {
-  do {
-    TypeLocInitializer(Loc).Visit(TL);
-  } while ((TL = TL.getNextTypeLoc()));
+  while (true) {
+    switch (TL.getTypeLocClass()) {
+#define ABSTRACT_TYPELOC(CLASS, PARENT)
+#define TYPELOC(CLASS, PARENT)        \
+    case CLASS: {                     \
+      CLASS##TypeLoc TLCasted = cast<CLASS##TypeLoc>(TL); \
+      TLCasted.initializeLocal(Loc);  \
+      TL = TLCasted.getNextTypeLoc(); \
+      if (!TL) return;                \
+      continue;                       \
+    }
+#include "clang/AST/TypeLocNodes.def"
+    }
+  }
 }
 
 namespace {