[cfe-commits] [PATCH] Properly check for unused comparisons in arguments to function-like macros

Chandler Carruth chandlerc at gmail.com
Fri Jan 4 13:40:52 PST 2013


  Do you need to add any new tests to cover the macro body case fully?

  What happens when only part of a comparison comes from the macro body? I wonder if we should suppress the warning if the start and end location come from different expansions (regardless of argument vs. body). Thoughts Richard?


================
Comment at: include/clang/Basic/SourceManager.h:1135-1136
@@ +1134,4 @@
+  /// \brief Tests whether the given source location represents the expansion of
+  /// a macro body (as opposed to an expansion of the argument to a
+  /// function-like macro).
+  bool isMacroBodyExpansion(SourceLocation Loc) const;
----------------
I'd put the parenthetical in its own sentence and not in the brief.

================
Comment at: lib/Basic/SourceManager.cpp:986-987
@@ +985,4 @@
+  FileID FID = getFileID(Loc);
+  const SrcMgr::SLocEntry *E = &getSLocEntry(FID);
+  const SrcMgr::ExpansionInfo &Expansion = E->getExpansion();
+  return Expansion.isMacroBodyExpansion();
----------------
Why make E a pointer?

Actually, why make a temporary? getSLocEntry(FID).getExpansion() not work?

I see its because that's what is done in the prior function. Perhaps both should be fixed, but whatev...


http://llvm-reviews.chandlerc.com/D259



More information about the cfe-commits mailing list