This is an archive of the discontinued LLVM Phabricator instance.

[Analyzer] Document a gotcha: for C++ -analyze-function requires parameters in function name
ClosedPublic

Authored by george.karpenkov on Sep 7 2017, 2:51 PM.

Diff Detail

Event Timeline

NoQ edited edge metadata.EditedSep 8 2017, 1:41 AM

Yeah, in D22856 i intended -analyze-function to work in pair with -analyzer-display-progress - you can always copy-paste the fully qualified name from there, even if it's an ObjC method or even an anonymous block. But i guess i failed to explain this in D22874.

I suggest something like: "This also works with C++ objects methods, functions in namespaces, and overloaded functions, Objective-C class and instance methods, and even blocks, but in these cases a fully qualified name should be used. Note: In C++ you always need to specify function arguments, even if it is a regular function. If you are not sure how to fully qualify the name, consult how it is displayed in the output of -analyzer-display-progress"

NoQ added a comment.Sep 8 2017, 1:55 AM

Or maybe just add an example with blocks below your text?:

If you're not sure how to specify function name, consult how -analyzer-display-progress displays it.

It even works with blocks which are anonymous but can be identified by line numbers:

$ clang -cc1 -fblocks -analyze -analyzer-checker=core test.c -analyzer-display-progress
ANALYZE (Syntax): test.c foo
ANALYZE (Syntax): test.c block (line: 2, col: 25)
ANALYZE (Path,  Inline_Regular): test.c foo
ANALYZE (Path,  Inline_Regular): test.c block (line: 2, col: 25)
$ clang -cc1 -fblocks -analyze -analyzer-checker=core test.c -analyzer-display-progress -analyze-function "block (line: 2, col: 25)"
ANALYZE (Syntax): test.c block (line: 2, col: 25)
ANALYZE (Path,  Inline_Regular): test.c block (line: 2, col: 25)

@NoQ To clarify: your proposed update is to checker_dev_manual, CC1Options.td stays the same, right?

In an ideal world of course we would like to warn the user if they try to use unqualified name to resolve a C++ identifier.
Or even resolve the name if no overloads exist (which is often the case for tests).
Though that's not the top priority.

zaks.anna accepted this revision.Sep 22 2017, 8:16 PM

Looks great! Thanks!

This revision is now accepted and ready to land.Sep 22 2017, 8:16 PM
This revision was automatically updated to reflect the committed changes.