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

Artem Dergachev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 16 16:11:13 PDT 2018


NoQ added inline comments.


================
Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:727
+
+static std::string getExpandedMacroImpl(TokenPrinter &Printer,
+                                        SourceLocation MacroLoc,
----------------
Whoa, that's so easy!


================
Comment at: lib/StaticAnalyzer/Core/PlistDiagnostics.cpp:787-791
+  // Acquire the macro's name.
+  Token TheTok;
+  RawLexer.LexFromRawLexer(TheTok);
+
+  std::string MacroName = PP.getSpelling(TheTok);
----------------
Not sure, random thought: Could this work in fact be done with the //static// `Lexer::getImmediateMacroName()` helper?


================
Comment at: test/Analysis/plist-macros-with-expansion.cpp:31
+// CHECK: <key>name</key><string>SET_PTR_VAR_TO_NULL</string>
+// CHECK: <key>expansion</key><string>ptr = 0</string>
 
----------------
Hmm, i think we can use `CHECK-NEXT:` here, in order to make sure these lines go sequentially.

Otherwise this second line may accidentally match someone else's expansion(?).


================
Comment at: test/Analysis/plist-macros-with-expansion.cpp:84
+
+// TODO: Expand argumnts.
+// CHECK: <key>name</key><string>TO_NULL</string>
----------------
Typo: `arguments`.


https://reviews.llvm.org/D52794





More information about the cfe-commits mailing list