[cfe-dev] CompilerInstance as CPP compiler?
Adam Smalin
acidzombie24 at gmail.com
Wed Jun 22 10:20:58 PDT 2011
using this dummy source file
struct AA {
int a, b, c;
void ff(int z){ }
};
void funcAZ() {}
int main(){
struct AA aa;
int a=1;
}
I ran the code at the end of this email. there are no cmd line arguments and
the file is a.cpp.
When it runs my ASTConsumer i get the assert error
Unexpected diagnostic outside source file processing
however if i remove the ff function in AA, it runs fine. I assume the
problem is the compiler is running in c mode and i am using c++ source.
How do i tell it to compile in C++ mode?
CompilerInstance compiler;
compiler.createDiagnostics(argc, argv);
CompilerInvocation::CreateFromArgs( compiler.getInvocation(),
argv + 1, argv + argc, compiler.getDiagnostics() );
compiler.setTarget( TargetInfo::CreateTargetInfo(
compiler.getDiagnostics(), compiler.getTargetOpts() ) );
compiler.createFileManager();
compiler.createSourceManager(compiler.getFileManager());
compiler.createPreprocessor();
compiler.createASTContext();
compiler.setASTConsumer( new PrintFunctionsConsumer);
compiler.createSema(false, NULL);
compiler.InitializeSourceManager( main_input_file );
ParseAST( compiler.getPreprocessor(), &compiler.getASTConsumer(),
compiler.getASTContext() );
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20110622/2173fee1/attachment.html>
More information about the cfe-dev
mailing list