OSDN Git Service

consolidate GlobalValue::isDeclaration into one
authorChris Lattner <sabre@nondot.org>
Thu, 14 Jul 2011 18:10:41 +0000 (18:10 +0000)
committerChris Lattner <sabre@nondot.org>
Thu, 14 Jul 2011 18:10:41 +0000 (18:10 +0000)
non-virtual function.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@135163 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Function.h
include/llvm/GlobalAlias.h
include/llvm/GlobalValue.h
include/llvm/GlobalVariable.h
lib/VMCore/Globals.cpp

index 093f8b5..0aa5b2a 100644 (file)
@@ -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
index 66eb11c..c3d3c38 100644 (file)
@@ -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.
   ///
index 69995e1..d77a4db 100644 (file)
@@ -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.
index 0fe8993..bbc09c1 100644 (file)
@@ -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.
index dfb88f4..0e0d667 100644 (file)
@@ -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!");