[PATCH] D52794: [analyzer][PlistMacroExpansion] Part 2.: Retrieving the macro name and primitive expansion

Umann Kristóf via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Oct 31 08:54:38 PDT 2018


Szelethus planned changes to this revision.
Szelethus added a comment.

I'll put this patch on hold while I'm investigating the issue @xazax.hun mentioned.

Mind you, again, other patches don't depend strictly on this part, I'll only need to change the for loop. Hopefully. You never know.



================
Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:753
+    // macro.
+    if (const MacroInfo *MI = PP.getMacroInfo(II)) {
+      getExpandedMacroImpl(Printer, T.getLocation(), PP);
----------------
xazax.hun wrote:
> This might not be completely correct. We are using the preprocessor state after processing the whole translation unit rather than the preprocessor state at the expansion location. This might not cause any problems unless there is a collision between macro names and non-macro names. Also, undefs, redefs might cause troubles.
Yup, you're right, I'm afraid :/

I'll investigate whether I can gather the macro definition at the spelling location with `Lexer`.


================
Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:796
+  const MacroInfo *MI = PP.getMacroInfo(II);
+  assert(MI && "This IdentifierInfo should refer to a macro!");
+
----------------
xazax.hun wrote:
> Could this assertion fail due to undefs in the code?
Yes... yes it could.


Repository:
  rC Clang

https://reviews.llvm.org/D52794





More information about the cfe-commits mailing list