[cfe-commits] r67258 - /cfe/trunk/include/clang/Parse/Ownership.h
Gabor Greif
ggreif at gmail.com
Wed Mar 18 16:44:22 PDT 2009
Author: ggreif
Date: Wed Mar 18 18:44:22 2009
New Revision: 67258
URL: http://llvm.org/viewvc/llvm-project?rev=67258&view=rev
Log:
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.
Modified:
cfe/trunk/include/clang/Parse/Ownership.h
Modified: cfe/trunk/include/clang/Parse/Ownership.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Parse/Ownership.h?rev=67258&r1=67257&r2=67258&view=diff
==============================================================================
--- cfe/trunk/include/clang/Parse/Ownership.h (original)
+++ cfe/trunk/include/clang/Parse/Ownership.h Wed Mar 18 18:44:22 2009
@@ -204,8 +204,8 @@
/// 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 @@
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 @@
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(); }
More information about the cfe-commits
mailing list