[LLVMdev] Patch: MSIL backend global pointers initialization
Anton Korobeynikov
anton at korobeynikov.info
Fri Apr 3 15:07:51 PDT 2009
Hi, Artur
> + if (isa<ConstantExpr>(I->constant)){
> + const ConstantExpr *CE =
> dyn_cast<ConstantExpr>(I->constant);
> + printConstantExpr(CE);
> + ty = CE->getType();
> + } else {
> + const Function * F = dyn_cast<Function>(I->constant);
> + printValueLoad(F);
> + ty = F->getType();
> + }
You don't need to check stuff twice here.
1. Use dyn_cast<ConstantExpr> instead of isa + dyn_cast
2. In the "else" path you need to be sure, that I->constant is indeed
Function. Use cast, not dyn_cast.
PS: Also: "if (foo){" => "if (foo) {"
--
With best regards, Anton Korobeynikov.
Faculty of Mathematics & Mechanics, Saint Petersburg State University.
More information about the llvm-dev
mailing list