[cfe-commits] r162768 - in /cfe/trunk: include/clang/AST/Stmt.h lib/AST/Stmt.cpp
John McCall
rjmccall at apple.com
Tue Aug 28 11:08:02 PDT 2012
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<>.
John.
More information about the cfe-commits
mailing list