This is an archive of the discontinued LLVM Phabricator instance.

[static analyzer] Define __clang_analyzer__ macro in driver
ClosedPublic

Authored by jkorous on Sep 23 2019, 3:57 PM.

Diff Detail

Repository
rL LLVM

Event Timeline

jkorous created this revision.Sep 23 2019, 3:57 PM
NoQ added inline comments.Sep 23 2019, 4:46 PM
clang/test/Analysis/misc-ps.m
5–7 ↗(On Diff #221428)

We can make a new test that tests the driver instead, i.e. something like

// RUN: %clang --analyze %s
#ifndef __clang_analyzer__
#error __clang_analyzer__ not defined
#endif
jkorous updated this revision to Diff 221445.Sep 23 2019, 5:21 PM

Added the test.

NoQ accepted this revision.Sep 23 2019, 5:25 PM

Thanks! I like how it makes the option transparent to fellow developers by having it show up in the -### run-line.

This revision is now accepted and ready to land.Sep 23 2019, 5:25 PM
This revision was automatically updated to reflect the committed changes.
jkorous marked 2 inline comments as done.
Herald added a project: Restricted Project. · View Herald TranscriptSep 23 2019, 5:32 PM
dexonsmith added inline comments.Sep 23 2019, 6:17 PM
clang/test/Analysis/misc-ps.m
5–7 ↗(On Diff #221428)

Would it be better to add -D__clang_analyzer__ to the %clang_analyze_cc1 expansion?

jkorous marked an inline comment as done.Sep 23 2019, 6:28 PM
jkorous added inline comments.
clang/test/Analysis/misc-ps.m
5–7 ↗(On Diff #221428)

Good idea.

5–7 ↗(On Diff #221428)

Good question! It seems to me I probably should (to keep implicit assumptions in tests intact).

NoQ added inline comments.Sep 23 2019, 7:05 PM
clang/test/Analysis/misc-ps.m
5–7 ↗(On Diff #221428)

I don't really care, we don't ever need it in tests and we don't need more than one test to test the macro itself.

P.S. Whoops, i think we broke clang-tidy. I'm glad they had a test for this! :) I don't know how exactly were they picking up the macro.