aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-02-17 07:02:32 +0000
committerDouglas Gregor <dgregor@apple.com>2011-02-17 07:02:32 +0000
commitf4a03cc2b022fab0ffac6c65449555c52036dece (patch)
tree13f71285731ff3a69964e65bd4b15fbcb07a0dbc
parentc6daf0b29d6c48a99cb1ad707973a7e6dfcafd58 (diff)
De-virtualize Decl::isOutOfLine().
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125730 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/Decl.h4
-rw-r--r--include/clang/AST/DeclBase.h7
-rw-r--r--lib/AST/Decl.cpp4
-rw-r--r--lib/AST/DeclBase.cpp9
4 files changed, 17 insertions, 7 deletions
diff --git a/include/clang/AST/Decl.h b/include/clang/AST/Decl.h
index e8431c1106..7140e808ef 100644
--- a/include/clang/AST/Decl.h
+++ b/include/clang/AST/Decl.h
@@ -787,7 +787,7 @@ public:
/// \brief Determine whether this is or was instantiated from an out-of-line
/// definition of a static data member.
- virtual bool isOutOfLine() const;
+ bool isOutOfLine() const;
/// \brief If this is a static data member, find its out-of-line definition.
VarDecl *getOutOfLineDefinition();
@@ -1690,7 +1690,7 @@ public:
/// \brief Determine whether this is or was instantiated from an out-of-line
/// definition of a member function.
- virtual bool isOutOfLine() const;
+ bool isOutOfLine() const;
// Implement isa/cast/dyncast/etc.
static bool classof(const Decl *D) { return classofKind(D->getKind()); }
diff --git a/include/clang/AST/DeclBase.h b/include/clang/AST/DeclBase.h
index e99d54771a..472cb3bb74 100644
--- a/include/clang/AST/DeclBase.h
+++ b/include/clang/AST/DeclBase.h
@@ -459,9 +459,10 @@ public:
return const_cast<Decl*>(this)->getLexicalDeclContext();
}
- virtual bool isOutOfLine() const {
- return getLexicalDeclContext() != getDeclContext();
- }
+ /// \brief Determine whether this declaration was written out-of-line, which
+ /// typically indicates that it was written with a qualified name in a scope
+ /// outside of its semantic scope.
+ bool isOutOfLine() const;
/// setDeclContext - Set both the semantic and lexical DeclContext
/// to DC.
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index 9aeb04fa44..fded8ff38c 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -1159,7 +1159,7 @@ const Expr *VarDecl::getAnyInitializer(const VarDecl *&D) const {
}
bool VarDecl::isOutOfLine() const {
- if (Decl::isOutOfLine())
+ if (getLexicalDeclContext() != getDeclContext())
return true;
if (!isStaticDataMember())
@@ -1883,7 +1883,7 @@ SourceLocation FunctionDecl::getPointOfInstantiation() const {
}
bool FunctionDecl::isOutOfLine() const {
- if (Decl::isOutOfLine())
+ if (getLexicalDeclContext() != getDeclContext())
return true;
// If this function was instantiated from a member function of a
diff --git a/lib/AST/DeclBase.cpp b/lib/AST/DeclBase.cpp
index e16bd22f33..a95ea3f646 100644
--- a/lib/AST/DeclBase.cpp
+++ b/lib/AST/DeclBase.cpp
@@ -172,6 +172,15 @@ void PrettyStackTraceDecl::print(llvm::raw_ostream &OS) const {
// Out-of-line virtual method providing a home for Decl.
Decl::~Decl() { }
+bool Decl::isOutOfLine() const {
+ if (const VarDecl *VD = dyn_cast<VarDecl>(this))
+ return VD->isOutOfLine();
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(this))
+ return FD->isOutOfLine();
+
+ return getLexicalDeclContext() != getDeclContext();
+}
+
void Decl::setDeclContext(DeclContext *DC) {
if (isOutOfSemaDC())
delete getMultipleDC();