Add type checking for tentative definitions at the end of the
translation unit.

Thread the various declarations of variables via
VarDecl::getPreviousDeclaration.

llvm-svn: 66601
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index eaf69f0..9bc07d5 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/lib/AST/Decl.cpp
@@ -273,6 +273,22 @@
 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
 //===----------------------------------------------------------------------===//