[cfe-dev] Syntax Check while rewriting

madil90 madil90 at gmail.com
Wed Jan 23 02:58:05 PST 2013


Hi,
   I am parsing an AST and rewriting some code. Before rewriting some code,
I want to ensure that the resulting code will compile fine. I am trying to
output variables to a stream (ostream). e.g.

// code to be rewrited
cout<< std::string() <<endl;    ( this will compile fine)

// code to be rewrited
cout << new FILE() <<endl;      ( this won't compile as no "<<" operator
exists for FILE. Shouldn't rewrite this.)

    How can I find out whether the code of the above type (cout <<
any_type;) will compile fine? I mean, how can I check whether there exists a
"<<" operator for the given type? (I know every compiler does that when
checking the syntax. I just need to know how it does that so that I can
replicate that functionality)

Regards,
Adil




--
View this message in context: http://clang-developers.42468.n3.nabble.com/Syntax-Check-while-rewriting-tp4029976.html
Sent from the Clang Developers mailing list archive at Nabble.com.



More information about the cfe-dev mailing list