[PATCH] D93223: [RFC][analyzer] Create MacroExpansionContext member in AnalysisConsumer and pass down to the diagnostics consumers

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 12 09:24:19 PST 2021


steakhal updated this revision to Diff 316126.
steakhal marked 2 inline comments as done.
steakhal added a comment.

Updates:

- New the construction of `MacroExpansionContext` won't hook the `Preprocessor` in the constructor. Hooking is done via the `registerForPreprocessor(PP)` member function.
- Hooking the PP now depends on the `ShouldDisplayMacroExpansions` analyzer option.
- Both `getExpandedText` and `getOriginalText` returns `Optional<StringRef>`. Semantics and comments changed accordingly. If the `ShouldDisplayMacroExpansions` analyzer flag is not set, both of these functions always return `None`.
- Removed the accidental `createHTMLSingleFileDiagnosticConsumer` prototype in `PathDiagnostic.h`.
- New unittest case added `NoneForNonExpansionLocations`.
- The rest of the tests were uplifted to unwrap the Optional to accommodate the new API.
- The last assertion of the `RedefUndef` unittest case was changed to match the new behavior for non-expansion locations.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93223/new/

https://reviews.llvm.org/D93223

Files:
  clang/include/clang/Analysis/MacroExpansionContext.h
  clang/include/clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h
  clang/lib/Analysis/MacroExpansionContext.cpp
  clang/lib/StaticAnalyzer/Core/HTMLDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  clang/lib/StaticAnalyzer/Core/TextDiagnostics.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/unittests/Analysis/MacroExpansionContextTest.cpp

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93223.316126.patch
Type: text/x-patch
Size: 33362 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20210112/6cba0ade/attachment-0001.bin>


More information about the cfe-commits mailing list