summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Decl.cpp
diff options
context:
space:
mode:
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