aboutsummaryrefslogtreecommitdiffstats
path: root/include/llvm/GlobalVariable.h
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2002-10-06 22:29:58 +0000
committerChris Lattner <sabre@nondot.org>2002-10-06 22:29:58 +0000
commitac8a58d50067bd1e1fc009cdb526d872b4cd5155 (patch)
treef5a15459198562cfe14233c38ce83a14370a01a7 /include/llvm/GlobalVariable.h
parent7d3f8671c15901df8417acc20c01ca82ff8cc180 (diff)
downloadexternal_llvm-ac8a58d50067bd1e1fc009cdb526d872b4cd5155.zip
external_llvm-ac8a58d50067bd1e1fc009cdb526d872b4cd5155.tar.gz
external_llvm-ac8a58d50067bd1e1fc009cdb526d872b4cd5155.tar.bz2
- Add new isExternal() method to GlobalVariable to mirror Function.
- doxygenize comments and add new comments git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@4046 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/GlobalVariable.h')
-rw-r--r--include/llvm/GlobalVariable.h31
1 files changed, 21 insertions, 10 deletions
diff --git a/include/llvm/GlobalVariable.h b/include/llvm/GlobalVariable.h
index fd5e3a6..12862cc 100644
--- a/include/llvm/GlobalVariable.h
+++ b/include/llvm/GlobalVariable.h
@@ -42,10 +42,22 @@ public:
// Specialize setName to handle symbol table majik...
virtual void setName(const std::string &name, SymbolTable *ST = 0);
- // The initializer for the global variable/constant is held by Operands[0] if
- // an initializer is specified.
- //
- inline bool hasInitializer() const { return !Operands.empty(); }
+ /// isExternal - Is this global variable lacking an initializer? If so, the
+ /// global variable is defined in some other translation unit, and is thus
+ /// externally defined here.
+ ///
+ bool isExternal() const { return Operands.empty(); }
+
+ /// hasInitializer - Unless a global variable isExternal(), it has an
+ /// initializer. The initializer for the global variable/constant is held by
+ /// Operands[0] if an initializer is specified.
+ ///
+ inline bool hasInitializer() const { return !isExternal(); }
+
+ /// getInitializer - Return the initializer for this global variable. It is
+ /// illegal to call this method if the global is external, because we cannot
+ /// tell what the value is initialized to!
+ ///
inline Constant *getInitializer() const {
assert(hasInitializer() && "GV doesn't have initializer!");
return (Constant*)Operands[0].get();
@@ -63,17 +75,16 @@ public:
}
}
- // getNext/Prev - Return the next or previous instruction in the list. The
- // last node in the list is a terminator instruction.
+ // getNext/Prev - Return the next or previous global variable in the list.
GlobalVariable *getNext() { return Next; }
const GlobalVariable *getNext() const { return Next; }
GlobalVariable *getPrev() { return Prev; }
const GlobalVariable *getPrev() const { return Prev; }
- // If the value is a global constant, its value is immutable throughout the
- // runtime execution of the program. Assigning a value into the constant
- // leads to undefined behavior.
- //
+ /// If the value is a global constant, its value is immutable throughout the
+ /// runtime execution of the program. Assigning a value into the constant
+ /// leads to undefined behavior.
+ ///
inline bool isConstant() const { return isConstantGlobal; }
virtual void print(std::ostream &OS) const;