[cfe-commits] r103893 - /cfe/trunk/lib/AST/TypeLoc.cpp
John McCall
rjmccall at apple.com
Sat May 15 19:09:32 PDT 2010
Author: rjmccall
Date: Sat May 15 21:09:32 2010
New Revision: 103893
URL: http://llvm.org/viewvc/llvm-project?rev=103893&view=rev
Log:
Avoid doing two switches in TypeLoc's initialize() loop. The optimizer
can probably do this for us, but it's actually somewhat nicer to write it
out here.
Modified:
cfe/trunk/lib/AST/TypeLoc.cpp
Modified: cfe/trunk/lib/AST/TypeLoc.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/TypeLoc.cpp?rev=103893&r1=103892&r2=103893&view=diff
==============================================================================
--- cfe/trunk/lib/AST/TypeLoc.cpp (original)
+++ cfe/trunk/lib/AST/TypeLoc.cpp Sat May 15 21:09:32 2010
@@ -92,9 +92,20 @@
/// 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 {
More information about the cfe-commits
mailing list