From: Gabor Greif Date: Wed, 18 Mar 2009 23:44:22 +0000 (+0000) Subject: Add a sugared version of ASTOwningResult::take, X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb5cab24e271d35e2476c5f60d28ddbabc6ac492;p=clang Add a sugared version of ASTOwningResult::take, that does a downcast. It is named takeAs(). 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 --- 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 + T *takeAs() { + return static_cast(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 + T *takeAs() { + return static_cast(take()); + } + /// Alias for interface familiarity with unique_ptr. void * release() { return take(); }