[clang-tools-extra] r188036 - Fix false error message for function-style macro instance used as arguments in other function-style macros instances, and add test for it.

John Thompson John.Thompson.JTSoftware at gmail.com
Thu Aug 8 17:22:20 PDT 2013


Author: jtsoftware
Date: Thu Aug  8 19:22:20 2013
New Revision: 188036

URL: http://llvm.org/viewvc/llvm-project?rev=188036&view=rev
Log:
Fix false error message for function-style macro instance used as arguments in other function-style macros instances, and add test for it.

Added:
    clang-tools-extra/trunk/test/modularize/Inputs/NestedMacro.h
    clang-tools-extra/trunk/test/modularize/NoProblemsNestedMacro.modularize
Modified:
    clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp

Modified: clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp?rev=188036&r1=188035&r2=188036&view=diff
==============================================================================
--- clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp (original)
+++ clang-tools-extra/trunk/modularize/PreprocessorTracker.cpp Thu Aug  8 19:22:20 2013
@@ -334,6 +334,12 @@ std::string getMacroUnexpandedString(cla
 
 // Get the expansion for a macro instance, given the information
 // provided by PPCallbacks.
+// FIXME: This doesn't support function-style macro instances
+// passed as arguments to another function-style macro. However,
+// since it still expands the inner arguments, it still
+// allows modularize to effectively work with respect to macro
+// consistency checking, although it displays the incorrect
+// expansion in error messages.
 std::string getMacroExpandedString(clang::Preprocessor &PP,
                                    llvm::StringRef MacroName,
                                    const clang::MacroInfo *MI,
@@ -1214,6 +1220,9 @@ void PreprocessorCallbacks::MacroExpands
                                          clang::SourceRange Range,
                                          const clang::MacroArgs *Args) {
   clang::SourceLocation Loc = Range.getBegin();
+  // Ignore macro argument expansions.
+  if (!Loc.isFileID())
+    return;
   clang::IdentifierInfo *II = MacroNameTok.getIdentifierInfo();
   const clang::MacroInfo *MI = PP.getMacroInfo(II);
   std::string MacroName = II->getName().str();

Added: clang-tools-extra/trunk/test/modularize/Inputs/NestedMacro.h
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/Inputs/NestedMacro.h?rev=188036&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/modularize/Inputs/NestedMacro.h (added)
+++ clang-tools-extra/trunk/test/modularize/Inputs/NestedMacro.h Thu Aug  8 19:22:20 2013
@@ -0,0 +1,5 @@
+// Verification of fix for nested macro.
+
+#define FUNCMACROINNER(a) a
+#define FUNCMACROOUTER(b, c) FUNCMACROINNER(b) + FUNCMACROINNER(c)
+int FuncMacroValue = FUNCMACROOUTER(1, 2);

Added: clang-tools-extra/trunk/test/modularize/NoProblemsNestedMacro.modularize
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/modularize/NoProblemsNestedMacro.modularize?rev=188036&view=auto
==============================================================================
--- clang-tools-extra/trunk/test/modularize/NoProblemsNestedMacro.modularize (added)
+++ clang-tools-extra/trunk/test/modularize/NoProblemsNestedMacro.modularize Thu Aug  8 19:22:20 2013
@@ -0,0 +1,3 @@
+# RUN: modularize %s -x c++
+
+Inputs/NestedMacro.h





More information about the cfe-commits mailing list