clang++ vs. ClangTool.buildASTs()

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

clang++ vs. ClangTool.buildASTs()

Robinson, Paul via cfe-dev
Hello all,

When compiling the following code there is a difference when using
clang++ from command line or ClangTool.buildASTs().

unsigned long * Pointer = (int) 0;

clang++ -c foo.cpp:
warning: expression which evaluates to zero treated as a null pointer
constant of type 'unsigned long *' [-Wnon-literal-null-conversion]

error: cannot initialize a variable of type 'unsigned long *' with an
rvalue of type 'int'

The code to build the AST is similar to this.

OptionCategory category("MYTOOL");
const char *   argv[32];
int            argc=0;

argv[argc++] = "MYTOOL";
argv[argc++] = "file.c";
argv[argc++] = "-x";
argv[argc++] = "c++";
argv[argc++] = "--";

CommonOptionsParser cop(argc, (const char **) argv, category);
ClangTool           tool(cop.getCompilations(), cop.getSourcePathList());

vector<unique_ptr<ASTUnit>> asts;

int result = tool.buildASTs(asts);

Is there something I'm missing to pass to the ClangTool to avoid that an
error is emitted instead of a warning.

cfe-dev mailing list
[hidden email]