How to remove error limit in Clang Libtooling? - clang

I made C/C++ source code modification tool using Clang Libtooling. I ran into the following error while executing my tool on test programs.
fatal error: too many errors emitted, stopping now [-ferror-limit=]
20 errors generated.
But I would like for the tool to ignore this limit, print all the errors, and execute AST modification as normal. Is there a way to fix this problem using Clang Libtooling?

Thanks to #dratenik, I solved the problem by adding an ArgumentAdjuster which passes Clang the option -ferror-limit=0.
clang::tooling::ClangTool tool(compileDb, filename);
tool.appendArgumentsAdjuster(clang::tooling::getInsertArgumentAdjuster(
"-ferror-limit=0"));
tool.run(...);

Related

Why does dialyzer fail on nocatch?

I ran Dialyzer and got the following error:
Checking whether the PLT /tmp/.BRANCH.service.deps.plt is up-to-date...
{"init terminating in do_boot",
{{case_clause,
{{nocatch,
{dialyzer_error,
[78,111,116,32,97,32,114,101,103,117,108,97,114,32,102,105,108,
101,58,32,
"/usr/lib/erlang/lib/compiler-6.0.3/ebin/beam_a.beam",10]}},
[{dialyzer_plt,compute_md5_from_file,1,
[{file,"dialyzer_plt.erl"},{line,543}]},
{dialyzer_plt,compute_new_md5_1,3,
[{file,"dialyzer_plt.erl"},{line,509}]},
{dialyzer_plt,check_plt1,3,[{file,"dialyzer_plt.erl"},{line,485}]},
{dialyzer_plt,'-subproc/1-fun-0-',1,
[{file,"dialyzer_plt.erl"},{line,603}]}]}},
[{dialyzer_cl,check_plt,3,[{file,"dialyzer_cl.erl"},{line,249}]},
{dialyzer_cl,plt_common,3,[{file,"dialyzer_cl.erl"},{line,182}]},
{dialyzer,'-cl_check_init/1-fun-0-',1,[{file,"dialyzer.erl"},{line,94}]},
{dialyzer,doit,1,[{file,"dialyzer.erl"},{line,236}]},
{dialyzer,plain_cl,0,[{file,"dialyzer.erl"},{line,75}]},
{init,start_em,1,[]},
{init,do_boot,3,[]}]}}
What went wrong and how do I fix it? What do the list of integers mean?
The print-out inside the dialyzer_error tuple is an iolist. We can pretty print it using the Erlang shell (started with erl):
1> [78,111,116,32,97,32,114,101,103,117,108,97,114,32,102,105,108,101,58,32].
"Not a regular file: "
2>
You realize it is complaining about bytecode (.beam) from a previous compiler version than the current one I am running. I removed them, and then it ran.

Command PhaseScriptExecution failed with a nonzero exit code when using Mapbox

I have had the bellow error for some time now.
I have tried creating new projects
fixing the problem within the project
Resetting all cocoa pods and more
And yet I have still not been able to get rid of this error.
Error below:
/Users/myUsername/Desktop/MapboxMap117/Pods/Target Support Files/Pods-MapboxMap117/Pods-MapboxMap117-frameworks.sh: line 114: local: `/Users/myUsername/Desktop/MapboxMap117/Pods/Mapbox-iOS-SDK/dynamic/826E141E-8875-3C3B-A106-2B772F8A0684.bcsymbolmap': not a valid identifier
Command PhaseScriptExecution failed with a nonzero exit code
I am also getting: (dont know if it is related)
/Users/myUsername/Desktop/MapboxMap117/Pods/Target Support Files/Pods-MapboxMap117/Pods-MapboxMap117-frameworks.sh: line 114: local: `=': not a valid identifier
How can I fix this error?
Note:
It may have something to do with the code in my "mainVC" which I call "mapVC". I think this because when I get rid of all the code in there or comment it out the project does not get the error.
/Users/myUsername/Desktop/MapboxMap117/Pods/Target Support Files/Pods-MapboxMap117/Pods-MapboxMap117-frameworks.sh: line 114: local: `=': not a valid identifier
I believe the problem is likely coming from this. I have had a similar problem where I had spaces around the "=" when I got rid of the spaces it fix the problem.
Go to that location and get rid of the spaces.
build again
Problem should be solved.

Doxygen: Can a \post start with \ref or any other Special Command?

I'm getting an error from Clang when using CLANG_WARN_DOCUMENTATION_COMMENTS on a doxygen block that contains following line
\post \ref something == somethingelse
The warning says "Empty paragraph passed to '\post' command"
Is this a valid use of \post?
If it is, does anyone know if there's a way to suppress this warning without disabling all documentation warnings?
Cheers.

What would cause a compiler to fail randomly?

I am using the clang compiler on windows. I used the installer from the LLVM website. Sometimes it gives me a compiler error.
clang -I./include main.c CoreFoundation.dll
it gives:
In file included from main.c:4:
In file included from ./include\CoreFoundation/CFNumberFormatter.h:110:
./include\CoreFoundation/CFXMLParser.h:159:81: error: unknown type name 'CFXMLNodeRef'
typedef void * (*CFXMLParserCreateXMLStructureCallBack)(CFXMLParserRef parser,
CFXMLNodeRef nodeDesc, void *info);
...
and sometimes this..
In file included from main.c:4:
In file included from ./include\CoreFoundation/CoreFoundation.h:86:
./include\CoreFoundation/CFDateFormatter.h:104:105: error: unknown type name 'CFDateRef'; did you mean 'CFDataRef'?
CFStringRef CFDateFormatterCreateStringWithDate(CFAllocatorRef allocator, CFDateFormatterRef formatter, CFDateRef date) AVAILABLE_MAC_OS_X_VERSION_10_3_AND_LATER;
...
...and other similar warnings, seemingly randomly choosing where to stop. Sometimes it compiles through without error. When it gives an error, they seem to be be about not finding a symbol from an included file. It doesn't complain about not finding the file. But it doesn't consistently stop at the same point and sometimes compiles successfully.
I can reproduce this "error" under Linux with gcc. I even get the "report this compiler bug pls" message.
When it gives an error, they seem to be be about not finding a symbol from an included file
You can get this:
if you compile with multiple threads (eg. make -j8)
if you abort the compile and then start it again without "cleaning" all obj files
if you compiled your source, changed something and compile without "cleaning"
if your compiler/make/build process changes the order every time... (had this with cmake and opencv 3 source)

HDF5 example not working

I tried building the first example here and got errors. Right on the first line there's a missing include statement, but I managed to figure out it should be
#include "hdf5.h"
But even after fixing that I got more errors:
$ h5cc ./example1.c
./example1.c: In function ‘main’:
./example1.c:66:4: error: too few arguments to function ‘H5Dcreate2’
In file included from /usr/include/hdf5.h:27:0,
from ./example1.c:6:
/usr/include/H5Dpublic.h:104:14: note: declared here
Any idea how to solve it?
The example code was written for release 1.6 of hdf5, and as such will simply not compile on a 1.8 release without modification.
If you want to get the code to work on 1.8, you need to enable 1.6 compatibility, which means passing in the flag:
-DH5_USE_16_API
to the h5cc command line like:
h5cc -DH5_USE_16_API ./example1.c
and it should compile correctly; otherwise you will have to rewrite the code to make use of the 1.8 API.

Resources