[cfe-dev] Clang + ccache == different warnings?

Rafael Espíndola rafael.espindola at gmail.com
Fri Jun 1 12:40:04 PDT 2012

On 1 June 2012 15:08, Larry Gritz <lg at larrygritz.com> wrote:
> After compiling my apps with clang 3.1, and fixing all the new warnings it found that gcc did not care about, I wanted to get clang + ccache working together.  I set up a bash script "~/bin/clang" that looks like this:
>        #!/bin/bash
>        ccache /opt/local/bin/clang $@
> Obviously this just calls ccache with the clang path and arguments.  The surprising thing is that when I invoke clang this way, several classes of warnings are flagged that were not noticed when I ran /opt/local/bin/clang.
> The above example is on OS X, where I've installed clang 3.1 via Macports.  But I've reproduced the same effect on Linux using clang/llvm that I compiled from the svn (3.1 branch) as well.
> Is this expected behavior?  Does anybody have an explanation for what's going on here?

The problem is that ccache give clang a preprocessed file to compile
and clang uses macro expansion context in its warnings. You might be
able to use CCACHE_CPP2 to avoid the problem.

> --
> Larry Gritz
> lg at larrygritz.com


More information about the cfe-dev mailing list