<div dir="ltr">Sorry, I <span class="">involuntarily </span>sent the email without setting the subject.<br><div><div class="gmail_extra"><br><br><div class="gmail_quote">2014-05-01 13:31 GMT+02:00 Aitor San Juan <span dir="ltr"><<a href="mailto:aitor.sj@opendeusto.es" target="_blank">aitor.sj@opendeusto.es</a>></span>:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hello,<br><br>In a checker I want to test whether an argument to a function call is a String literal, but I'm a bit stuck. Could anybody shed a bit of light on this?<br>
<br>1. This way seems to not work (although no compile-time error), but I don't understand why:<br>
<br>const Expr *arg = CE->getArg(0); // CE is a CallExpr<br>if ((arg != NULL) && (clang::isa<clang::StringLiteral>(arg))){<br>...<br><br>2. The following does not compile:<br><br>const Expr *arg = CE->getArg(0); // CE is a CallExpr<br>

if (StringLiteral *SL = dyn_cast<StringLiteral>(arg)) {<br><br>invalid conversion from ‘llvm::cast_retty<clang::StringLiteral, const clang::Expr*>::ret_type {aka const clang::StringLiteral*}’ to ‘clang::StringLiteral*’ [-fpermissive]<br>

    if (StringLiteral *SL = dyn_cast<StringLiteral>(arg)) {<br>                                                                           ^<br>3. The following does not compile, however there's a non-const getArg() method:<br>

<br>Expr *arg = CE->getArg(0); // CE is a CallExpr<br>if (StringLiteral *SL = dyn_cast<StringLiteral>(arg)) {<br><br>error: invalid conversion from ‘const clang::Expr*’ to ‘clang::Expr*’ [-fpermissive]<br>    Expr *arg = CE->getArg(0);<br>

                            ^<br><br></div>
</blockquote></div><br></div></div></div>