diff options
author | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-04-26 20:35:05 +0000 |
---|---|---|
committer | Sebastian Redl <sebastian.redl@getdesigned.at> | 2009-04-26 20:35:05 +0000 |
commit | a7b98a772cb63cd2eb5f1af194c2d5910adeea2a (patch) | |
tree | 6eedb2b10ca06fe8e509d699d9e39825660a7158 /clang/lib/AST/DeclBase.cpp | |
parent | 5bf1a6e98636a113adf6b8078b3e4d6f1181b406 (diff) | |
download | bcm5719-llvm-a7b98a772cb63cd2eb5f1af194c2d5910adeea2a.tar.gz bcm5719-llvm-a7b98a772cb63cd2eb5f1af194c2d5910adeea2a.zip |
Implement function-try-blocks. However, there's a very subtle bug that I can't track down.
llvm-svn: 70155
Diffstat (limited to 'clang/lib/AST/DeclBase.cpp')
-rw-r--r-- | clang/lib/AST/DeclBase.cpp | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/clang/lib/AST/DeclBase.cpp b/clang/lib/AST/DeclBase.cpp index a20786035a2..707383af3a8 100644 --- a/clang/lib/AST/DeclBase.cpp +++ b/clang/lib/AST/DeclBase.cpp @@ -20,6 +20,8 @@ #include "clang/AST/ExternalASTSource.h" #include "clang/AST/ASTContext.h" #include "clang/AST/Type.h" +#include "clang/AST/Stmt.h" +#include "clang/AST/StmtCXX.h" #include "llvm/ADT/DenseMap.h" #include "llvm/Support/raw_ostream.h" #include <algorithm> @@ -341,6 +343,21 @@ DeclContext *Decl::castToDeclContext(const Decl *D) { } } +CompoundStmt* Decl::getCompoundBody(ASTContext &Context) const { + return dyn_cast_or_null<CompoundStmt>(getBody(Context)); +} + +SourceLocation Decl::getBodyRBrace(ASTContext &Context) const { + Stmt *Body = getBody(Context); + if (!Body) + return SourceLocation(); + if (CompoundStmt *CS = dyn_cast<CompoundStmt>(Body)) + return CS->getRBracLoc(); + assert(isa<CXXTryStmt>(Body) && + "Body can only be CompoundStmt or CXXTryStmt"); + return cast<CXXTryStmt>(Body)->getSourceRange().getEnd(); +} + #ifndef NDEBUG void Decl::CheckAccessDeclContext() const { assert((Access != AS_none || isa<TranslationUnitDecl>(this) || |