summaryrefslogtreecommitdiffstats
path: root/clang/lib
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-17 07:58:36 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-17 07:58:36 +0000
commit7edc20ac247d62ead0724d012339987f73dde7c3 (patch)
tree604da4f4e0060d5b768941496bc67c1bef8f2075 /clang/lib
parente5220011718514516640187c54ce9e659454a765 (diff)
downloadbcm5719-llvm-7edc20ac247d62ead0724d012339987f73dde7c3.tar.gz
bcm5719-llvm-7edc20ac247d62ead0724d012339987f73dde7c3.zip
Devirtualize Decl::getCanonicalDecl().
llvm-svn: 125735
Diffstat (limited to 'clang/lib')
-rw-r--r--clang/lib/AST/DeclBase.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp
index dfc5a6ae5d3..d8b7c9b5b00 100644
--- a/clang/lib/AST/DeclBase.cpp
+++ b/clang/lib/AST/DeclBase.cpp
@@ -143,6 +143,29 @@ bool Decl::isDefinedOutsideFunctionOrMethod() const {
return true;
}
+namespace {
+ template<typename Class, typename Result>
+ inline Result *getSpecificCanonicalDecl(Decl *D, Result *(Class::*Get)()) {
+ return (llvm::cast<Class>(D)->*Get)();
+ }
+
+ inline Decl *getSpecificCanonicalDecl(Decl *D, Decl *(Decl::*)()) {
+ // No specific implementation.
+ return D;
+ }
+}
+
+Decl *Decl::getCanonicalDecl() {
+ switch (getKind()) {
+#define ABSTRACT_DECL(Type)
+#define DECL(Type, Base) \
+ case Type: \
+ return getSpecificCanonicalDecl(this, &Type##Decl::getCanonicalDecl);
+#include "clang/AST/DeclNodes.inc"
+ }
+ return this;
+
+}
//===----------------------------------------------------------------------===//
// PrettyStackTraceDecl Implementation
OpenPOWER on IntegriCloud