瀏覽代碼

[modules] Don't bother creating a ModuleMacro representing a #undef that overrides nothing.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@236374 91177308-0d34-0410-b5e6-96231b3b80d8
Richard Smith 10 年之前
父節點
當前提交
b4742f0fba
共有 1 個文件被更改,包括 5 次插入2 次删除
  1. 5 2
      lib/Lex/PPLexerChange.cpp

+ 5 - 2
lib/Lex/PPLexerChange.cpp

@@ -685,8 +685,11 @@ void Preprocessor::LeaveSubmodule() {
         // FIXME: Issue a warning if multiple headers for the same submodule
         // FIXME: Issue a warning if multiple headers for the same submodule
         // define a macro, rather than silently ignoring all but the first.
         // define a macro, rather than silently ignoring all but the first.
         bool IsNew;
         bool IsNew;
-        addModuleMacro(Info.M, II, Def, Macro.second.getOverriddenMacros(),
-                       IsNew);
+        // Don't bother creating a module macro if it would represent a #undef
+        // that doesn't override anything.
+        if (Def || !Macro.second.getOverriddenMacros().empty())
+          addModuleMacro(Info.M, II, Def, Macro.second.getOverriddenMacros(),
+                         IsNew);
         break;
         break;
       }
       }
     }
     }