aboutsummaryrefslogtreecommitdiff
path: root/lib/AST/Decl.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2009-03-10 23:43:53 +0000
committerDouglas Gregor <dgregor@apple.com>2009-03-10 23:43:53 +0000
commit275a369f003f25bd22c00c1c0fc0251c7208caf4 (patch)
treef9088a9b40a3ce195904954931a36c1adb532f15 /lib/AST/Decl.cpp
parentdd98e2cad165ca73c769e4f105a4e47c2216387a (diff)
Add type checking for tentative definitions at the end of the
translation unit. Thread the various declarations of variables via VarDecl::getPreviousDeclaration. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@66601 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/AST/Decl.cpp')
-rw-r--r--lib/AST/Decl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/lib/AST/Decl.cpp b/lib/AST/Decl.cpp
index eaf69f0197..9bc07d5ce3 100644
--- a/lib/AST/Decl.cpp
+++ b/lib/AST/Decl.cpp
@@ -273,6 +273,22 @@ void VarDecl::Destroy(ASTContext& C) {
VarDecl::~VarDecl() {
}
+bool VarDecl::isTentativeDefinition(ASTContext &Context) const {
+ if (!isFileVarDecl() || Context.getLangOptions().CPlusPlus)
+ return false;
+
+ return (!getInit() &&
+ (getStorageClass() == None || getStorageClass() == Static));
+}
+
+const Expr *VarDecl::getDefinition(const VarDecl *&Def) {
+ Def = this;
+ while (Def && !Def->getInit())
+ Def = Def->getPreviousDeclaration();
+
+ return Def? Def->getInit() : 0;
+}
+
//===----------------------------------------------------------------------===//
// FunctionDecl Implementation
//===----------------------------------------------------------------------===//