[cfe-dev] Rewriting Types

Eli Friedman eli.friedman at gmail.com
Tue May 13 07:13:11 PDT 2008


(Resend; I forgot to cc the list.)

In clang/lib/Parse/ParseStmt.cpp, I see a comment "// FIXME: Pass in
the right location for the end of the declstmt.".  That seems likely
to be causing your issue.

-Eli

On Tue, May 13, 2008 at 5:55 AM, Stephan Creutz
<stephan.creutz at inf.tu-dresden.de> wrote:
> Hi,
>
> I'm trying to rewrite types in declaration statements, e.g. "int a, b,
> c" to "long a; long b; long c;". To do this I use the rewriter as
> follows:
>
> void TypeVisitor::VisitDeclStmt(DeclStmt *ds)
> {
>    ScopedDecl *sd = ds->getDecl();
>    while (sd) {
>        if (VarDecl *vd = dyn_cast<VarDecl>(sd)) {
>            vd->setType(context.LongTy);
>        }
>        sd = sd->getNextDeclarator();
>    }
>
>    if (rewriter.ReplaceStmt(ds, ds))
>        llvm::cerr << "cannot rewrite\n";
> }
>
> In my resulting file I get something like this: "long a; long b; long c;
> a, b, c;". That is almost the expected output except the extra
> "a, b, c;".
>
> What is wrong in my code? Or is it in general the wrong approach to
> rewrite types?
>
> Thank you very much in advance,
> Stephan
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
>



More information about the cfe-dev mailing list