Author: rsmith Date: Fri Jan 8 16:36:45 2016 New Revision: 257222 URL: http://llvm.org/viewvc/llvm-project?rev=257222&view=rev Log: [modules] Make sure we always include the contents of private headers when building a module. Prior to this change, the private header's content would only be included if the header were included by another header in the same module. If not (if the private header is only used by the .cc files of the module, or is included from outside the module via -Wno-private-header), a #include of that file would be silently ignored.
Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp cfe/trunk/test/Modules/Inputs/dummy.h cfe/trunk/test/Modules/modular_maps.cpp cfe/trunk/test/Modules/separate_map_tree.cpp Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=257222&r1=257221&r2=257222&view=diff ============================================================================== --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original) +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Fri Jan 8 16:36:45 2016 @@ -187,15 +187,17 @@ collectModuleHeaderIncludes(const LangOp return std::error_code(); // Add includes for each of these headers. - for (Module::Header &H : Module->Headers[Module::HK_Normal]) { - Module->addTopHeader(H.Entry); - // Use the path as specified in the module map file. We'll look for this - // file relative to the module build directory (the directory containing - // the module map file) so this will find the same file that we found - // while parsing the module map. - if (std::error_code Err = addHeaderInclude(H.NameAsWritten, Includes, - LangOpts, Module->IsExternC)) - return Err; + for (auto HK : {Module::HK_Normal, Module::HK_Private}) { + for (Module::Header &H : Module->Headers[HK]) { + Module->addTopHeader(H.Entry); + // Use the path as specified in the module map file. We'll look for this + // file relative to the module build directory (the directory containing + // the module map file) so this will find the same file that we found + // while parsing the module map. + if (std::error_code Err = addHeaderInclude(H.NameAsWritten, Includes, + LangOpts, Module->IsExternC)) + return Err; + } } // Note that Module->PrivateHeaders will not be a TopHeader. Modified: cfe/trunk/test/Modules/Inputs/dummy.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/dummy.h?rev=257222&r1=257221&r2=257222&view=diff ============================================================================== --- cfe/trunk/test/Modules/Inputs/dummy.h (original) +++ cfe/trunk/test/Modules/Inputs/dummy.h Fri Jan 8 16:36:45 2016 @@ -1,3 +1,5 @@ // This module only exists to make local decl IDs and global decl IDs different. - +#ifndef DUMMY_H +#define DUMMY_H struct Dummy {} extern *dummy1, *dummy2, *dummy3; +#endif Modified: cfe/trunk/test/Modules/modular_maps.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/modular_maps.cpp?rev=257222&r1=257221&r2=257222&view=diff ============================================================================== --- cfe/trunk/test/Modules/modular_maps.cpp (original) +++ cfe/trunk/test/Modules/modular_maps.cpp Fri Jan 8 16:36:45 2016 @@ -16,4 +16,4 @@ #include "b.h" // expected-error {{private header}} @import C; const int v = a + c + x; -const int val = a + b + c + x; // expected-error {{undeclared identifier}} +const int val = a + b + c + x; Modified: cfe/trunk/test/Modules/separate_map_tree.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/separate_map_tree.cpp?rev=257222&r1=257221&r2=257222&view=diff ============================================================================== --- cfe/trunk/test/Modules/separate_map_tree.cpp (original) +++ cfe/trunk/test/Modules/separate_map_tree.cpp Fri Jan 8 16:36:45 2016 @@ -5,4 +5,4 @@ #include "public-in-b.h" // expected-error {{private header}} #include "public-in-c.h" #include "private-in-c.h" // expected-error {{private header}} -const int val = common + b + c + c_; // expected-error {{undeclared identifier}} +const int val = common + b + c + c_; _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits