This is an archive of the discontinued LLVM Phabricator instance.

[clang-tidy] Define __clang_analyzer__ macro for clang-tidy for compatibility with clang static analyzer. 2nd try.
ClosedPublic

Authored by zinovy.nis on May 1 2018, 11:18 AM.

Details

Summary

This macro is widely used in many well-known projects, ex. Chromium.

But it's not set for clang-tidy, so for ex. DCHECK in Chromium is not considered as [[no-return]], and a lot of false-positive warnings about nullptr dereferenced are emitted.

This patch fixes the issue.
This revision is the second version of https://reviews.llvm.org/D44906.

Diff Detail

Repository
rL LLVM

Event Timeline

zinovy.nis created this revision.May 1 2018, 11:18 AM
alexfh requested changes to this revision.May 3 2018, 8:54 AM
alexfh added inline comments.
clang-tidy/ClangTidy.cpp
536 ↗(On Diff #144757)

I would add a comment that we only do this to define the analyzer-specific macro, not to actually use the analyzer frontend action.

This revision now requires changes to proceed.May 3 2018, 8:54 AM
  • Added comments on why setting ProgramAction explicitly.
zinovy.nis marked an inline comment as done.May 3 2018, 11:12 AM
alexfh accepted this revision.May 3 2018, 11:17 AM

LG. Thank you!

This revision is now accepted and ready to land.May 3 2018, 11:17 AM

Thanks Alexander for your feedback!

This revision was automatically updated to reflect the committed changes.