Get parsing error code in clang::ParseAST

时间:2018-04-20 01:16:01

标签: compiler-errors clang

I am facing a problem as follows:

  • Given a source code in C. This source code may have some errors, such as undefined variable, undefined function.
  • If the source code has an error, I need to point out which type and the location of that error. Otherwise, produce an AST.

I am using clang library to produce and traverse the AST, but I cannot get the error code if the source code has a compile error. When it runs to the folllowing command, it just outputs the error message on the screen:

clang::ParseAST(
     compilerInstance.getPreprocessor(), 
     &consumer, 
     compilerInstance.getASTContext()
);

0 个答案:

没有答案