summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-07-14 18:10:41 +0000
committerChris Lattner <sabre@nondot.org>2011-07-14 18:10:41 +0000
commit923053a1d66dd8729523913ea02de2bf7f3fbf50 (patch)
treebca387289b6ee025b1398c55831cfa9645201bd3
parentd616cf3497195ff070115bafd46c98cfa928a15a (diff)
downloadbcm5719-llvm-923053a1d66dd8729523913ea02de2bf7f3fbf50.tar.gz
bcm5719-llvm-923053a1d66dd8729523913ea02de2bf7f3fbf50.zip
consolidate GlobalValue::isDeclaration into one
non-virtual function. llvm-svn: 135163
-rw-r--r--llvm/include/llvm/Function.h6
-rw-r--r--llvm/include/llvm/GlobalAlias.h5
-rw-r--r--llvm/include/llvm/GlobalValue.h4
-rw-r--r--llvm/include/llvm/GlobalVariable.h5
-rw-r--r--llvm/lib/VMCore/Globals.cpp21
5 files changed, 15 insertions, 26 deletions
diff --git a/llvm/include/llvm/Function.h b/llvm/include/llvm/Function.h
index 093f8b5e8af..0aa5b2a9fa4 100644
--- a/llvm/include/llvm/Function.h
+++ b/llvm/include/llvm/Function.h
@@ -139,12 +139,6 @@ public:
/// arguments.
bool isVarArg() const;
- /// isDeclaration - Is the body of this function unknown? (The basic block
- /// list is empty if so.) This is true for function declarations, but not
- /// true for function definitions.
- ///
- virtual bool isDeclaration() const { return BasicBlocks.empty(); }
-
/// getIntrinsicID - This method returns the ID number of the specified
/// function, or Intrinsic::not_intrinsic if the function is not an
/// instrinsic, or if the pointer is null. This value is always defined to be
diff --git a/llvm/include/llvm/GlobalAlias.h b/llvm/include/llvm/GlobalAlias.h
index 66eb11cfd32..c3d3c38bd34 100644
--- a/llvm/include/llvm/GlobalAlias.h
+++ b/llvm/include/llvm/GlobalAlias.h
@@ -47,11 +47,6 @@ public:
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
- /// isDeclaration - Is this global variable lacking an initializer? If so,
- /// the global variable is defined in some other translation unit, and is thus
- /// only a declaration here.
- virtual bool isDeclaration() const;
-
/// removeFromParent - This method unlinks 'this' from the containing module,
/// but does not delete it.
///
diff --git a/llvm/include/llvm/GlobalValue.h b/llvm/include/llvm/GlobalValue.h
index 69995e19caa..d77a4dbdb31 100644
--- a/llvm/include/llvm/GlobalValue.h
+++ b/llvm/include/llvm/GlobalValue.h
@@ -266,8 +266,8 @@ public:
virtual void destroyConstant();
/// isDeclaration - Return true if the primary definition of this global
- /// value is outside of the current translation unit...
- virtual bool isDeclaration() const = 0;
+ /// value is outside of the current translation unit.
+ bool isDeclaration() const;
/// removeFromParent - This method unlinks 'this' from the containing module,
/// but does not delete it.
diff --git a/llvm/include/llvm/GlobalVariable.h b/llvm/include/llvm/GlobalVariable.h
index 0fe89934350..bbc09c177e2 100644
--- a/llvm/include/llvm/GlobalVariable.h
+++ b/llvm/include/llvm/GlobalVariable.h
@@ -68,11 +68,6 @@ public:
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
- /// isDeclaration - Is this global variable lacking an initializer? If so,
- /// the global variable is defined in some other translation unit, and is thus
- /// only a declaration here.
- virtual bool isDeclaration() const { return getNumOperands() == 0; }
-
/// hasInitializer - Unless a global variable isExternal(), it has an
/// initializer. The initializer for the global variable/constant is held by
/// Initializer if an initializer is specified.
diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp
index dfb88f49277..0e0d667392b 100644
--- a/llvm/lib/VMCore/Globals.cpp
+++ b/llvm/lib/VMCore/Globals.cpp
@@ -61,6 +61,19 @@ void GlobalValue::setAlignment(unsigned Align) {
Alignment = Log2_32(Align) + 1;
assert(getAlignment() == Align && "Alignment representation error!");
}
+
+bool GlobalValue::isDeclaration() const {
+ if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(this))
+ return GV->getNumOperands() == 0;
+
+ if (const Function *F = dyn_cast<Function>(this))
+ return F->empty();
+
+ const GlobalAlias *GA = cast<GlobalAlias>(this);
+ if (const GlobalValue *AV = GA->getAliasedGlobal())
+ return AV->isDeclaration();
+ return false;
+}
//===----------------------------------------------------------------------===//
// GlobalVariable Implementation
@@ -202,14 +215,6 @@ void GlobalAlias::eraseFromParent() {
getParent()->getAliasList().erase(this);
}
-bool GlobalAlias::isDeclaration() const {
- const GlobalValue* AV = getAliasedGlobal();
- if (AV)
- return AV->isDeclaration();
- else
- return false;
-}
-
void GlobalAlias::setAliasee(Constant *Aliasee) {
assert((!Aliasee || Aliasee->getType() == getType()) &&
"Alias and aliasee types should match!");
OpenPOWER on IntegriCloud