r174567 - Be a little more permissive with -fmodules-ignore-macro= by removing everything after the second '=' if it is there.
Douglas Gregor
dgregor at apple.com
Wed Feb 6 17:18:49 PST 2013
Author: dgregor
Date: Wed Feb 6 19:18:48 2013
New Revision: 174567
URL: http://llvm.org/viewvc/llvm-project?rev=174567&view=rev
Log:
Be a little more permissive with -fmodules-ignore-macro= by removing everything after the second '=' if it is there.
Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/test/Modules/ignored_macros.m
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=174567&r1=174566&r2=174567&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Feb 6 19:18:48 2013
@@ -754,13 +754,8 @@ namespace {
: HSOpts(HSOpts) { }
bool operator()(const std::pair<std::string, bool> &def) const {
- // Dig out the macro name.
- StringRef MacroName = def.first;
- StringRef::size_type EqPos = MacroName.find('=');
- if (EqPos != StringRef::npos)
- MacroName = MacroName.substr(0, EqPos);
-
- return HSOpts.ModulesIgnoreMacros.count(MacroName) > 0;
+ StringRef MacroDef = def.first;
+ return HSOpts.ModulesIgnoreMacros.count(MacroDef.split('=').first) > 0;
}
};
}
Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=174567&r1=174566&r2=174567&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Feb 6 19:18:48 2013
@@ -816,8 +816,8 @@ static void ParseHeaderSearchArgs(Header
for (arg_iterator it = Args.filtered_begin(OPT_fmodules_ignore_macro),
ie = Args.filtered_end(); it != ie; ++it) {
- const Arg *A = *it;
- Opts.ModulesIgnoreMacros.insert(A->getValue());
+ StringRef MacroDef = (*it)->getValue();
+ Opts.ModulesIgnoreMacros.insert(MacroDef.split('=').first);
}
// Add -I..., -F..., and -index-header-map options in order.
@@ -1617,14 +1617,9 @@ std::string CompilerInvocation::getModul
// If we're supposed to ignore this macro for the purposes of modules,
// don't put it into the hash.
if (!hsOpts.ModulesIgnoreMacros.empty()) {
- // Dig out the macro name.
- StringRef MacroName = I->first;
- StringRef::size_type EqPos = MacroName.find('=');
- if (EqPos != StringRef::npos)
- MacroName = MacroName.substr(0, EqPos);
-
// Check whether we're ignoring this macro.
- if (hsOpts.ModulesIgnoreMacros.count(MacroName))
+ StringRef MacroDef = I->first;
+ if (hsOpts.ModulesIgnoreMacros.count(MacroDef.split('=').first))
continue;
}
Modified: cfe/trunk/test/Modules/ignored_macros.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ignored_macros.m?rev=174567&r1=174566&r2=174567&view=diff
==============================================================================
--- cfe/trunk/test/Modules/ignored_macros.m (original)
+++ cfe/trunk/test/Modules/ignored_macros.m Wed Feb 6 19:18:48 2013
@@ -26,6 +26,13 @@
// RUN: %clang_cc1 -fmodule-cache-path %t.modules -DIGNORED=1 -fmodules-ignore-macro=IGNORED -fmodules -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
// RUN: %clang_cc1 -fmodule-cache-path %t.modules -DIGNORED=1 -fmodules -I %S/Inputs -include-pch %t.pch -fmodules-ignore-macro=IGNORED -DNO_IGNORED_ANYWHERE -fmodules-ignore-macro=NO_IGNORED_ANYWHERE %s -verify
+// Fifth trial: pass -DIGNORED=1 and -fmodules-ignore-macro=IGNORED=1
+// to both invocations, so modules will be built without the IGNORED
+// macro.
+// RUN: rm -rf %t.modules
+// RUN: %clang_cc1 -fmodule-cache-path %t.modules -DIGNORED=1 -fmodules-ignore-macro=IGNORED=1 -fmodules -I %S/Inputs -emit-pch -o %t.pch -x objective-c-header %s -verify
+// RUN: %clang_cc1 -fmodule-cache-path %t.modules -DIGNORED=1 -fmodules -I %S/Inputs -include-pch %t.pch -fmodules-ignore-macro=IGNORED=1 -DNO_IGNORED_ANYWHERE -fmodules-ignore-macro=NO_IGNORED_ANYWHERE %s -verify
+
// expected-no-diagnostics
#ifndef HEADER
More information about the cfe-commits
mailing list