summaryrefslogtreecommitdiffstats
path: root/clang/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
commit0760fa16183831e487de3713503de7a9fecef9e3 (patch)
treef20a6b1c4303b8d12deb4f0e7d1717647e50a693 /clang/lib/AST/Decl.cpp
parent4dff6a497381e271d8ce7cdd0b35e2b78b115328 (diff)
downloadbcm5719-llvm-0760fa16183831e487de3713503de7a9fecef9e3.tar.gz
bcm5719-llvm-0760fa16183831e487de3713503de7a9fecef9e3.zip
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
Diffstat (limited to 'clang/lib/AST/Decl.cpp')
-rw-r--r--clang/lib/AST/Decl.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/clang/lib/AST/Decl.cpp b/clang/lib/AST/Decl.cpp
index eaf69f0197c..9bc07d5ce3f 100644
--- a/clang/lib/AST/Decl.cpp
+++ b/clang/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
//===----------------------------------------------------------------------===//
OpenPOWER on IntegriCloud