[cfe-dev] Using clang static analyzer on linux with Objective C for arm-apple-darwin9-gcc

Jay Bone jbonedev at gmail.com
Thu May 28 12:21:01 PDT 2009


On Wed, May 27, 2009 at 10:17 PM, Ted Kremenek <kremenek at apple.com> wrote:

>
> On May 27, 2009, at 10:01 PM, Eli Friedman wrote:
>
>  I have an Objective C project which compiles fine under Fedora 8 on x86
>>> gcc-4.2.1 cross compiler for arm-apple-darwin9.
>>>
>>> When I use scan-build with ccc-analyzer it fails to compile. The first
>>> compiler error is
>>>
>>> /Projects/iphone/toolchain/toolchain/sys/usr/include/Foundation/NSObject.h:105:
>>> error: expected ‘;’ before ‘__attribute__’
>>>
>>> I can provide more info, please let me know what kind of info is needed.
>>>
>>
>> Is that error coming out of gcc?  (The complete console output might
>> be useful here.)  If it is, it's probably a bug in the scan-build
>> script.  Also, if you could show a few lines around the error, it
>> might be useful for figuring out what exactly the error is complaining
>> about.
>>
>
> I don't think it's a scan-build bug, but just a limitation of what the
> scan-build script can do.  It doesn't know what version of gcc you want to
> use, so it just uses the system default gcc.  It sounds like it isn't
> calling Jay's cross compiler.
>
> scan-build "interposes" on a build by overriding the CC environment
> variable to point to ccc-analyzer.  ccc-analyzer then calls 'gcc' to do the
> compilation, and 'clang-cc' to do the analysis.
>
> Jay: To have scan-build use your cross-compiler, check out the '-use-cc'
> option.  'scan-build' with no options will tell you more.


Thanks Ted and Eli for the replies.

I've just tried --use-cc, I get about the same result as when I tried
hacking around setting CCC_CC in my env to point to my cross compiler.
(After digging through the perl code in ccc-analyzer)

When I use this method, I get a bunch of errors about not finding header
files. This is because my cross compiler was compiled with --with-sysroot

Now I can change my Makefile to pass
--sysroot=/home/foo/Projects/iphone/toolchain/toolchain/sys to cc,
which is the --with-sysroot parameter my compiler was compiled with. But
it's not clear to me why this needs to be done. If it's using my cross
compiler, shouldn't it find these?

Anyway to workaround that I can alter my Makefile to pass --sysroot and
-I/path/to/header/location to cc.

After doing that I get output like this below.

/home/foo/Projects/iphone/clang/llvm/tools/clang/utils/ccc-analyzer -c
--sysroot=/home/foo/Projects/iphone/toolchain/toolchain/sys
-I/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include
src/BrowseUITableViewController.m -o BrowseUITableViewController.o
In file included from src/BrowseUITableViewController.m:1:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UIKit.h:10:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UIActivityIndicatorView.h:8:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UIView.h:10:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UIInterface.h:10:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UIColor.h:9:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/CoreGraphics/CoreGraphics.h:25:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/CoreGraphics/CGEvent.h:17:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/CoreServices/CoreServices.h:21:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/AE/AE.h:20:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/CarbonCore/CarbonCore.h:160:
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/fenv.h:41:6:
error: #error  This fenv header and set of APIs is intended for the ARM
(with VFP) architecture only.
    #error  This fenv header and set of APIs is intended for the ARM (with
VFP) architecture only.
     ^
In file included from src/BrowseUITableViewController.m:1:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UIKit.h:46:
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UITableView.h:158:58:
warning: property type 'id<UITableViewDelegate>' is incompatible with type
'id<UIScrollViewDelegate>' inherited from 'UIScrollView'
@property(nonatomic,assign)   id <UITableViewDelegate>   delegate;
                                                         ^
In file included from src/BrowseUITableViewController.m:1:
In file included from
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UIKit.h:51:
/home/foo/Projects/iphone/toolchain/toolchain/sys/usr/include/UIKit/UITextView.h:50:52:
warning: property type 'id<UITextViewDelegate>' is incompatible with type
'id<UIScrollViewDelegate>' inherited from 'UIScrollView'
@property(nonatomic,assign) id<UITextViewDelegate> delegate;
                                                   ^
3 diagnostics generated.
....
.^^ And the same for all of the other files in my project.

At the end I see:
scan-build: Removing directory '/tmp/scan-build-2009-05-28-1' because it
contains no reports.

The files do actually build--I see generated .o object files and the linked
binary, but I don't see what I'm looking for, or at least what I think I am
looking for, which is warnings about memory allocation/deallocation.

Thanks again for your help with this.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20090528/dd2d880e/attachment.html>


More information about the cfe-dev mailing list