From: Chris Lattner Date: Sun, 12 Apr 2009 20:13:14 +0000 (+0000) Subject: add a new isNull() method to DeclGroupRef. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=20401698e3bd93a24bb5d9e18e435895cefe5fd1;p=clang add a new isNull() method to DeclGroupRef. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@68909 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/DeclGroup.h b/include/clang/AST/DeclGroup.h index 1a8546339b..65666899e2 100644 --- a/include/clang/AST/DeclGroup.h +++ b/include/clang/AST/DeclGroup.h @@ -84,6 +84,7 @@ public: typedef Decl** iterator; typedef Decl* const * const_iterator; + bool isNull() const { return D == 0; } bool isSingleDecl() const { return getKind() == SingleDeclKind; } bool isDeclGroup() const { return getKind() == DeclGroupKind; } diff --git a/lib/Sema/SemaStmt.cpp b/lib/Sema/SemaStmt.cpp index d2e158658c..1428c48847 100644 --- a/lib/Sema/SemaStmt.cpp +++ b/lib/Sema/SemaStmt.cpp @@ -40,10 +40,11 @@ Sema::OwningStmtResult Sema::ActOnNullStmt(SourceLocation SemiLoc) { Sema::OwningStmtResult Sema::ActOnDeclStmt(DeclGroupPtrTy dg, SourceLocation StartLoc, SourceLocation EndLoc) { + DeclGroupRef DG = dg.getAsVal(); + // If we have an invalid decl, just return an error. - if (!dg) return StmtError(); + if (DG.isNull()) return StmtError(); - DeclGroupRef DG = dg.getAsVal(); return Owned(new (Context) DeclStmt(DG, StartLoc, EndLoc)); }