aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGabor Greif <ggreif@gmail.com>2009-03-18 23:44:22 +0000
committerGabor Greif <ggreif@gmail.com>2009-03-18 23:44:22 +0000
commitfb5cab24e271d35e2476c5f60d28ddbabc6ac492 (patch)
treeab4636b1f1a5d09f9bd2e13dbf8592def05dfae8
parent5697aa0d75c87bafec78984048d558f8d12ca1b3 (diff)
Add a sugared version of ASTOwningResult::take,
that does a downcast. It is named takeAs<T>(). The plain-pointer version is also added, but that side seems to be seriously bitrotten. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@67258 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/Parse/Ownership.h16
1 files changed, 14 insertions, 2 deletions
diff --git a/include/clang/Parse/Ownership.h b/include/clang/Parse/Ownership.h
index 9665576a05..ce0707e9bf 100644
--- a/include/clang/Parse/Ownership.h
+++ b/include/clang/Parse/Ownership.h
@@ -204,8 +204,8 @@ namespace clang
/// when recovering from errors. These are in ActionBase because the smart
/// pointers need access to them.
virtual void DeleteExpr(ExprTy *E) {}
- virtual void DeleteStmt(StmtTy *E) {}
- virtual void DeleteTemplateParams(TemplateParamsTy *E) {}
+ virtual void DeleteStmt(StmtTy *S) {}
+ virtual void DeleteTemplateParams(TemplateParamsTy *P) {}
};
/// ASTDestroyer - The type of an AST node destruction function pointer.
@@ -383,6 +383,12 @@ namespace clang
return tmp;
}
+ /// Take outside ownership of the raw pointer and cast it down.
+ template<typename T>
+ T *takeAs() {
+ return static_cast<T*>(take());
+ }
+
/// Alias for interface familiarity with unique_ptr.
void * release() { return take(); }
@@ -443,6 +449,12 @@ namespace clang
return Result.get();
}
+ /// Take outside ownership of the raw pointer and cast it down.
+ template<typename T>
+ T *takeAs() {
+ return static_cast<T*>(take());
+ }
+
/// Alias for interface familiarity with unique_ptr.
void * release() { return take(); }