[PATCH] D94673: [analyzer][CTU] API for CTU macro expansions

Balázs Benics via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 17 06:36:54 PST 2021


steakhal added inline comments.


================
Comment at: clang/lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:835
+          CTU.getMacroExpansionContextForSourceLocation(MacroExpansionLoc)) {
+    return CTUMacroExpCtx->getExpandedText(MacroExpansionLoc);
   }
----------------
balazske wrote:
> I am not sure if `getExpandedText` will handle a source location that is not in the same TU. Probably the previous source location mapping mechanism (that is now removed) is needed additionally, so that here the original source location and the original `MacroExpansionContext` is available. Probably this can be done in other way, the `MacroExpansionContext` could handle this mapping. (A single `MacroExpansionContext` could handle every imported source location at least for on-demand parsing.)
Yes. For a complete CTU implementation, it seems inevitable to be able to acquire the proper MacroExpansionContext for an imported source-location. So the previous mapping will be likely back once we implement this functionality completely.

I think we can not implement it via having a single MacroExpansionContext due to layering violations.
I wanted this to be part of the Analysis library, but if it was concerned about CTU importing and stuff it would reside inside the cross_tu library.
I might be wrong about this though.


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

https://reviews.llvm.org/D94673



More information about the cfe-commits mailing list