[PATCH] D52742: [analyzer][WIP] Add macro expansions to the plist output

Umann Kristóf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Mon Oct 1 12:34:39 PDT 2018


Szelethus created this revision.
Szelethus added reviewers: NoQ, george.karpenkov, xazax.hun, rnkovacs, dcoughlin, MTC, dkrupp.
Herald added subscribers: cfe-commits, mikhail.ramalho, a.sidorin, szepet, whisperity.

This is the implementation of the inclusion of macro expansions into the plist output.

This approach is very much different to what `HTMLRewrite` does -- the motivation behind this was that

- I **really** wanted to avoid `const_cast`,
- This patch aims to only expand macros relevant to the bugpath, so there's no point in lexing everything.

Sadly, it seems like I couldn't get away with a solution not re-implementing parts of the preprocessor -- macro arguments are expanded manually and somewhat painfully, but I am very confident about it's stability and correctness.

I included plenty of comments, maybe a little too much, but my reasoning was that the future maintainer of this code probably won't be expert on how to handle the preprocessor and the lexer, so judging from how much I struggled with it, I figured the extra explanation was justified.

There are still some tests I'd like to perform, and some small details are still under debate (such as whether the kind of the plist entry will be `macro_expansion` or not), but the actual implementation of how macros are expanded won't be changed (unless I encounter a crash).


Repository:
  rC Clang

https://reviews.llvm.org/D52742

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  test/Analysis/plist-macros-with-expansion.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D52742.167803.patch
Type: text/x-patch
Size: 20158 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20181001/0211906a/attachment-0001.bin>


More information about the cfe-commits mailing list