[cfe-commits] r162768 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp
Chad Rosier
mcrosier at apple.com
Tue Aug 28 11:22:58 PDT 2012
Committed r162773. Thanks, all.
Chad
On Aug 28, 2012, at 11:10 AM, Chandler Carruth wrote:
> On Tue, Aug 28, 2012 at 11:08 AM, John McCall <rjmccall at apple.com> wrote:
> On Aug 28, 2012, at 11:05 AM, Chad Rosier wrote:
> > On Aug 28, 2012, at 10:48 AM, Dmitri Gribenko wrote:
> >> On Tue, Aug 28, 2012 at 10:43 AM, Chad Rosier <mcrosier at apple.com> wrote:
> >>> +std::string AsmStmt::generateAsmString(ASTContext &C) const {
> >>> + StmtClass stmtClass = getStmtClass();
> >>> + if (stmtClass == Stmt::GCCAsmStmtClass)
> >>> + return static_cast<const GCCAsmStmt*>(this)->generateAsmString(C);
> >>> + if (stmtClass == Stmt::MSAsmStmtClass)
> >>> + return static_cast<const MSAsmStmt*>(this)->generateAsmString(C);
> >>> + llvm_unreachable("unknown asm statement kind!");
> >>> +}
> >>
> >> It is conventional to use cast<> in such cases.
> >
> > I based these changes off of John's work in r125183. I don't claim to be an expert on the use of casts, but I'm guessing John used the static_cast to elide the run-time checks. John, please correct me if I'm wrong…
>
> I don't remember, but it's a bit different in macro-metaprogrammed code. Here you might as well use cast<>.
>
> Better yet, use dyn_cast and remove the raw getStmtClass...
>
> if (GCCAsmStmt *GCCAS = dyn_cast<GCCAsmStmt>(this))
> GCCAS->generateAsmString(C);
> if (MSAsmStmt *MSAS = dyn_cast<MSAsmStmt>(this))
> MSAS->generateAsmString(C);
> llvm_unreachable(...);
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20120828/97f5ac36/attachment.html>
More information about the cfe-commits
mailing list