[cfe-commits] r125730 - in /cfe/trunk: include/clang/AST/Decl.h include/clang/AST/DeclBase.h lib/AST/Decl.cpp lib/AST/DeclBase.cpp
Douglas Gregor
dgregor at apple.com
Wed Feb 16 23:02:32 PST 2011
Author: dgregor
Date: Thu Feb 17 01:02:32 2011
New Revision: 125730
URL: http://llvm.org/viewvc/llvm-project?rev=125730&view=rev
Log:
De-virtualize Decl::isOutOfLine().
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=125730&r1=125729&r2=125730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Thu Feb 17 01:02:32 2011
@@ -787,7 +787,7 @@
/// \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 @@
/// \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()); }
Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=125730&r1=125729&r2=125730&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Thu Feb 17 01:02:32 2011
@@ -459,9 +459,10 @@
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.
Modified: cfe/trunk/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=125730&r1=125729&r2=125730&view=diff
==============================================================================
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Thu Feb 17 01:02:32 2011
@@ -1159,7 +1159,7 @@
}
bool VarDecl::isOutOfLine() const {
- if (Decl::isOutOfLine())
+ if (getLexicalDeclContext() != getDeclContext())
return true;
if (!isStaticDataMember())
@@ -1883,7 +1883,7 @@
}
bool FunctionDecl::isOutOfLine() const {
- if (Decl::isOutOfLine())
+ if (getLexicalDeclContext() != getDeclContext())
return true;
// If this function was instantiated from a member function of a
Modified: cfe/trunk/lib/AST/DeclBase.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclBase.cpp?rev=125730&r1=125729&r2=125730&view=diff
==============================================================================
--- cfe/trunk/lib/AST/DeclBase.cpp (original)
+++ cfe/trunk/lib/AST/DeclBase.cpp Thu Feb 17 01:02:32 2011
@@ -172,6 +172,15 @@
// 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();
More information about the cfe-commits
mailing list