r306732 - [ASTReader] Add test for previous change r306583 / 145692e.
Author: graydon Date: Thu Jun 29 12:42:35 2017 New Revision: 306732 URL: http://llvm.org/viewvc/llvm-project?rev=306732&view=rev Log: [ASTReader] Add test for previous change r306583 / 145692e. Summary: Add a test for the change to ASTReader that reproduces the logic for consolidating multiple ObjC interface definitions to the case of multiple ObjC protocol definitions. This test is a modified copy of the test that accompanied the original change to interfaces, in 2ba1979. Reviewers: bruno Reviewed By: bruno Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D34788 Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map cfe/trunk/test/Modules/lookup-assert-protocol.m Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h?rev=306732&view=auto == --- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h (added) +++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Base.h Thu Jun 29 12:42:35 2017 @@ -0,0 +1,3 @@ +@protocol BaseProtocol +- (void) test; +@end Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h?rev=306732&view=auto == --- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h (added) +++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/Derive.h Thu Jun 29 12:42:35 2017 @@ -0,0 +1,4 @@ +#include "Base.h" +@protocol DerivedProtocol +- (void) test2; +@end Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h?rev=306732&view=auto == --- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h (added) +++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/H3.h Thu Jun 29 12:42:35 2017 @@ -0,0 +1 @@ +#include "Base.h" Added: cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map?rev=306732&view=auto == --- cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map (added) +++ cfe/trunk/test/Modules/Inputs/lookup-assert-protocol/module.map Thu Jun 29 12:42:35 2017 @@ -0,0 +1,4 @@ +module X { + header "H3.h" + export * +} Added: cfe/trunk/test/Modules/lookup-assert-protocol.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/lookup-assert-protocol.m?rev=306732&view=auto == --- cfe/trunk/test/Modules/lookup-assert-protocol.m (added) +++ cfe/trunk/test/Modules/lookup-assert-protocol.m Thu Jun 29 12:42:35 2017 @@ -0,0 +1,17 @@ +// RUN: rm -rf %t +// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs/lookup-assert-protocol %s -verify +// expected-no-diagnostics + +#include "Derive.h" +#import + +__attribute__((objc_root_class)) +@interface Thing +@end + +@implementation Thing +- (void)test { +} +- (void)test2 { +} +@end ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
Re: r306583 - [ASTReader] Treat multiple defns of ObjC protocols the same as interfaces.
Yes, I wasn't sure how to test it at this level (there's a pending test at the swift level) but, as you pointed out in separate email, there was an adaptable test in the original commit this is a copy-and-modification of, so I copied-and-modified the test as well. Posted for review in https://reviews.llvm.org/D34788 <https://reviews.llvm.org/D34788> -Graydon > On Jun 28, 2017, at 2:18 PM, Bruno Cardoso Lopes > wrote: > > Hi Graydon, > > Can you please add a testcase for this? > > Thanks, > > On Wed, Jun 28, 2017 at 11:36 AM, Graydon Hoare via cfe-commits > mailto:cfe-commits@lists.llvm.org>> wrote: > Author: graydon > Date: Wed Jun 28 11:36:27 2017 > New Revision: 306583 > > URL: http://llvm.org/viewvc/llvm-project?rev=306583&view=rev > <http://llvm.org/viewvc/llvm-project?rev=306583&view=rev> > Log: > [ASTReader] Treat multiple defns of ObjC protocols the same as interfaces. > > Summary: > In change 2ba19793512, the ASTReader logic for ObjC interfaces was modified to > preserve the first definition-data read, "merging" later definitions into it > rather than overwriting it (though this "merging" is, in practice, a no-op > that > discards the later definition-data). > > Unfortunately this change was only made to ObjC interfaces, not protocols; > this > means that when (for example) loading a protocol that references an interface, > if both the protocol and interface are multiply defined (as can easily happen > if the same header is read from multiple contexts), an _inconsistent_ pair of > definitions is loaded: first-read for the interface and last-read for the > protocol. > > This in turn causes very subtle downstream bugs in the Swift ClangImporter, > which filters the results of name lookups based on the owning module of a > definition; inconsistency between a pair of related definitions causes name > lookup failures at various stages of compilation. > > To fix these downstream issues, this change replicates the logic applied to > interfaces in change 2ba19793512, but for ObjC protocols. > > rdar://30851899 > > Reviewers: doug.gregor, rsmith > > Reviewed By: doug.gregor > > Subscribers: jordan_rose, cfe-commits > > Differential Revision: https://reviews.llvm.org/D34741 > <https://reviews.llvm.org/D34741> > > Modified: > cfe/trunk/include/clang/AST/Redeclarable.h > cfe/trunk/lib/Serialization/ASTReaderDecl.cpp > > Modified: cfe/trunk/include/clang/AST/Redeclarable.h > URL: > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Redeclarable.h?rev=306583&r1=306582&r2=306583&view=diff > > <http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Redeclarable.h?rev=306583&r1=306582&r2=306583&view=diff> > == > --- cfe/trunk/include/clang/AST/Redeclarable.h (original) > +++ cfe/trunk/include/clang/AST/Redeclarable.h Wed Jun 28 11:36:27 2017 > @@ -21,6 +21,60 @@ > namespace clang { > class ASTContext; > > +// Some notes on redeclarables: > +// > +// - Every redeclarable is on a circular linked list. > +// > +// - Every decl has a pointer to the first element of the chain _and_ a > +//DeclLink that may point to one of 3 possible states: > +// - the "previous" (temporal) element in the chain > +// - the "latest" (temporal) element in the chain > +// - the an "uninitialized-latest" value (when newly-constructed) > +// > +// - The first element is also often called the canonical element. Every > +//element has a pointer to it so that "getCanonical" can be fast. > +// > +// - Most links in the chain point to previous, except the link out of > +//the first; it points to latest. > +// > +// - Elements are called "first", "previous", "latest" or > +//"most-recent" when referring to temporal order: order of addition > +//to the chain. > +// > +// - To make matters confusing, the DeclLink type uses the term "next" > +//for its pointer-storage internally (thus functions like > +//NextIsPrevious). It's easiest to just ignore the implementation of > +//DeclLink when making sense of the redeclaration chain. > +// > +// - There's
r306583 - [ASTReader] Treat multiple defns of ObjC protocols the same as interfaces.
Author: graydon Date: Wed Jun 28 11:36:27 2017 New Revision: 306583 URL: http://llvm.org/viewvc/llvm-project?rev=306583&view=rev Log: [ASTReader] Treat multiple defns of ObjC protocols the same as interfaces. Summary: In change 2ba19793512, the ASTReader logic for ObjC interfaces was modified to preserve the first definition-data read, "merging" later definitions into it rather than overwriting it (though this "merging" is, in practice, a no-op that discards the later definition-data). Unfortunately this change was only made to ObjC interfaces, not protocols; this means that when (for example) loading a protocol that references an interface, if both the protocol and interface are multiply defined (as can easily happen if the same header is read from multiple contexts), an _inconsistent_ pair of definitions is loaded: first-read for the interface and last-read for the protocol. This in turn causes very subtle downstream bugs in the Swift ClangImporter, which filters the results of name lookups based on the owning module of a definition; inconsistency between a pair of related definitions causes name lookup failures at various stages of compilation. To fix these downstream issues, this change replicates the logic applied to interfaces in change 2ba19793512, but for ObjC protocols. rdar://30851899 Reviewers: doug.gregor, rsmith Reviewed By: doug.gregor Subscribers: jordan_rose, cfe-commits Differential Revision: https://reviews.llvm.org/D34741 Modified: cfe/trunk/include/clang/AST/Redeclarable.h cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Modified: cfe/trunk/include/clang/AST/Redeclarable.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Redeclarable.h?rev=306583&r1=306582&r2=306583&view=diff == --- cfe/trunk/include/clang/AST/Redeclarable.h (original) +++ cfe/trunk/include/clang/AST/Redeclarable.h Wed Jun 28 11:36:27 2017 @@ -21,6 +21,60 @@ namespace clang { class ASTContext; +// Some notes on redeclarables: +// +// - Every redeclarable is on a circular linked list. +// +// - Every decl has a pointer to the first element of the chain _and_ a +//DeclLink that may point to one of 3 possible states: +// - the "previous" (temporal) element in the chain +// - the "latest" (temporal) element in the chain +// - the an "uninitialized-latest" value (when newly-constructed) +// +// - The first element is also often called the canonical element. Every +//element has a pointer to it so that "getCanonical" can be fast. +// +// - Most links in the chain point to previous, except the link out of +//the first; it points to latest. +// +// - Elements are called "first", "previous", "latest" or +//"most-recent" when referring to temporal order: order of addition +//to the chain. +// +// - To make matters confusing, the DeclLink type uses the term "next" +//for its pointer-storage internally (thus functions like +//NextIsPrevious). It's easiest to just ignore the implementation of +//DeclLink when making sense of the redeclaration chain. +// +// - There's also a "definition" link for several types of +//redeclarable, where only one definition should exist at any given +//time (and the defn pointer is stored in the decl's "data" which +//is copied to every element on the chain when it's changed). +// +//Here is some ASCII art: +// +// "first" "latest" +// "canonical" "most recent" +// ++ first+--+ +// || <--- | | +// || | | +// || | | +// || +--+ | | +// || first | | | | +// || < | | | | +// || | | | | +// | @class A | link | @interface A | link | @class A | +// | seen first | < | seen second | < | seen third | +// || | | | | +// ++ +--+ +--+ +// | data | defn | data | defn | data | +// || > | | < | | +// ++ +--+ +--+ +//| | ^ ^ +//| |defn | | +//| link+-+ | +//+-->---+ + /// \brief Provides common interface for the Decls that can be redeclared. template class Redeclarable { Modifi
r299012 - Unbreak windows bot.
Author: graydon Date: Wed Mar 29 12:58:41 2017 New Revision: 299012 URL: http://llvm.org/viewvc/llvm-project?rev=299012&view=rev Log: Unbreak windows bot. Modified: cfe/trunk/test/PCH/emit-dependencies.c Modified: cfe/trunk/test/PCH/emit-dependencies.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/emit-dependencies.c?rev=299012&r1=299011&r2=299012&view=diff == --- cfe/trunk/test/PCH/emit-dependencies.c (original) +++ cfe/trunk/test/PCH/emit-dependencies.c Wed Mar 29 12:58:41 2017 @@ -1,7 +1,7 @@ // RUN: rm -f %t.pch // RUN: %clang_cc1 -emit-pch -o %t.pch %S/Inputs/chain-decls1.h // RUN: %clang_cc1 -include-pch %t.pch -fsyntax-only -MT %s.o -dependency-file - %s | FileCheck %s -// CHECK: Inputs/chain-decls1.h +// CHECK: chain-decls1.h int main() { f(); ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r299009 - [PCH] Attach instance's dependency collectors to PCH external AST sources.
Author: graydon Date: Wed Mar 29 12:33:09 2017 New Revision: 299009 URL: http://llvm.org/viewvc/llvm-project?rev=299009&view=rev Log: [PCH] Attach instance's dependency collectors to PCH external AST sources. Summary: When a PCH is included via -include-pch, clang should treat the current TU as dependent on the sourcefile that the PCH was generated from. This is currently _partly_ accomplished by InitializePreprocessor calling AddImplicitIncludePCH to synthesize an implicit #include of the sourcefile, into the preprocessor's Predefines buffer. For FrontendActions such as PreprocessOnlyAction (which is, curiously, what the driver winds up running one of in response to a plain clang -M) this is sufficient: the preprocessor cranks over its Predefines and emits a dependency reference to the initial sourcefile. For other FrontendActions (for example -emit-obj or -fsyntax-only) the Predefines buffer is reset to the suggested predefines buffer from the PCH, so the dependency edge is lost. The result is that clang emits a .d file in those cases that lacks a reference to the .h file responsible for the input (and in Swift's case, our .swiftdeps file winds up not including a reference to the source file for a PCH bridging header.) This patch fixes the problem by taking a different tack: ignoring the Predefines buffer (which seems a bit like a hack anyways) and directly attaching the CompilerInstance's DependencyCollectors (and legacy DependencyFileGenerator) to the ASTReader for the external AST. This approach is similar to the one chosen in earlier consultation with Bruno and Ben, and I think it's the least-bad solution, given several options. Reviewers: bruno, benlangmuir, doug.gregor Reviewed By: bruno, doug.gregor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D31378 Added: cfe/trunk/test/PCH/emit-dependencies.c Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h cfe/trunk/lib/Frontend/CompilerInstance.cpp Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=299009&r1=299008&r2=299009&view=diff == --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original) +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Wed Mar 29 12:33:09 2017 @@ -662,6 +662,8 @@ public: bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, ArrayRef> Extensions, + DependencyFileGenerator *DependencyFile, + ArrayRef> DependencyCollectors, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex); Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=299009&r1=299008&r2=299009&view=diff == --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original) +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Wed Mar 29 12:33:09 2017 @@ -497,6 +497,8 @@ void CompilerInstance::createPCHExternal AllowPCHWithCompilerErrors, getPreprocessor(), getASTContext(), getPCHContainerReader(), getFrontendOpts().ModuleFileExtensions, + TheDependencyFileGenerator.get(), + DependencyCollectors, DeserializationListener, OwnDeserializationListener, Preamble, getFrontendOpts().UseGlobalModuleIndex); @@ -507,6 +509,8 @@ IntrusiveRefCntPtr CompilerIn bool AllowPCHWithCompilerErrors, Preprocessor &PP, ASTContext &Context, const PCHContainerReader &PCHContainerRdr, ArrayRef> Extensions, +DependencyFileGenerator *DependencyFile, +ArrayRef> DependencyCollectors, void *DeserializationListener, bool OwnDeserializationListener, bool Preamble, bool UseGlobalModuleIndex) { HeaderSearchOptions &HSOpts = PP.getHeaderSearchInfo().getHeaderSearchOpts(); @@ -524,6 +528,12 @@ IntrusiveRefCntPtr CompilerIn Reader->setDeserializationListener( static_cast(DeserializationListener), /*TakeOwnership=*/OwnDeserializationListener); + + if (DependencyFile) +DependencyFile->AttachToASTReader(*Reader); + for (auto &Listener : DependencyCollectors) +Listener->attachToASTReader(*Reader); + switch (Reader->ReadAST(Path, Preamble ? serialization::MK_Preamble : serialization::MK_PCH, Added: cfe/trunk/test/PCH/emit-dependencies.c URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/emit-dependencies.c?rev=299009&view=auto == --- cfe/trunk/test/PCH/emit-dependencies.c (added) +++ cfe/trunk/test/PCH/emit-dependencies.c Wed Mar 29 12:33:09 2017 @@ -0,0 +1,9 @@ +// RUN: rm -f %t.pch +/
r292435 - [Modules] Correct test comment from obsolete earlier version of code. NFC
Author: graydon Date: Wed Jan 18 14:34:44 2017 New Revision: 292435 URL: http://llvm.org/viewvc/llvm-project?rev=292435&view=rev Log: [Modules] Correct test comment from obsolete earlier version of code. NFC Summary: Code committed in rL290219 went through a few iterations; test wound up with stale comment. Reviewers: doug.gregor, manmanren Reviewed By: manmanren Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28790 Modified: cfe/trunk/test/Modules/implicit-private-with-different-name.m Modified: cfe/trunk/test/Modules/implicit-private-with-different-name.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implicit-private-with-different-name.m?rev=292435&r1=292434&r2=292435&view=diff == --- cfe/trunk/test/Modules/implicit-private-with-different-name.m (original) +++ cfe/trunk/test/Modules/implicit-private-with-different-name.m Wed Jan 18 14:34:44 2017 @@ -3,7 +3,7 @@ // Build PCH using A, with adjacent private module APrivate, which winds up being implicitly referenced // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -emit-pch -o %t-A.pch %s -// Use the PCH with no explicit way to resolve PrivateA, still pick it up through MODULE_DIRECTORY reference in PCH control block +// Use the PCH with no explicit way to resolve APrivate, still pick it up by automatic second-chance search for "A" with "Private" appended // RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps -fmodules-cache-path=%t -F %S/Inputs/implicit-private-with-different-name -include-pch %t-A.pch %s -fsyntax-only // Check the fixit ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r292436 - [ASTReader] Add a DeserializationListener callback for IMPORTED_MODULES
Author: graydon Date: Wed Jan 18 14:36:59 2017 New Revision: 292436 URL: http://llvm.org/viewvc/llvm-project?rev=292436&view=rev Log: [ASTReader] Add a DeserializationListener callback for IMPORTED_MODULES Summary: Add a callback from ASTReader to DeserializationListener when the former reads an IMPORTED_MODULES block. This supports Swift in using PCH for bridging headers. Reviewers: doug.gregor, manmanren, bruno Reviewed By: manmanren Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D28779 Modified: cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h?rev=292436&r1=292435&r2=292436&view=diff == --- cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h (original) +++ cfe/trunk/include/clang/Serialization/ASTDeserializationListener.h Wed Jan 18 14:36:59 2017 @@ -26,6 +26,7 @@ class QualType; class MacroDefinitionRecord; class MacroInfo; class Module; +class SourceLocation; class ASTDeserializationListener { public: @@ -52,6 +53,9 @@ public: MacroDefinitionRecord *MD) {} /// \brief A module definition was read from the AST file. virtual void ModuleRead(serialization::SubmoduleID ID, Module *Mod) {} + /// \brief A module import was read from the AST file. + virtual void ModuleImportRead(serialization::SubmoduleID ID, +SourceLocation ImportLoc) {} }; } Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=292436&r1=292435&r2=292436&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Wed Jan 18 14:36:59 2017 @@ -3251,8 +3251,11 @@ ASTReader::ReadASTBlock(ModuleFile &F, u for (unsigned I = 0, N = Record.size(); I != N; /**/) { unsigned GlobalID = getGlobalSubmoduleID(F, Record[I++]); SourceLocation Loc = ReadSourceLocation(F, Record, I); - if (GlobalID) + if (GlobalID) { ImportedModules.push_back(ImportedSubmodule(GlobalID, Loc)); +if (DeserializationListener) + DeserializationListener->ModuleImportRead(GlobalID, Loc); + } } } break; ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r290233 - Fix windows build breakage in r290219. Unix path separators in testcase.
Author: graydon Date: Tue Dec 20 21:00:11 2016 New Revision: 290233 URL: http://llvm.org/viewvc/llvm-project?rev=290233&view=rev Log: Fix windows build breakage in r290219. Unix path separators in testcase. Modified: cfe/trunk/test/Modules/implicit-private-with-different-name.m Modified: cfe/trunk/test/Modules/implicit-private-with-different-name.m URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implicit-private-with-different-name.m?rev=290233&r1=290232&r2=290233&view=diff == --- cfe/trunk/test/Modules/implicit-private-with-different-name.m (original) +++ cfe/trunk/test/Modules/implicit-private-with-different-name.m Tue Dec 20 21:00:11 2016 @@ -11,7 +11,7 @@ // expected-warning@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{top-level module 'APrivate' in private module map, expected a submodule of 'A'}} // expected-note@Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap:1{{make 'APrivate' a submodule of 'A' to ensure it can be found by name}} -// CHECK: fix-it:"{{.*}}/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap":{1:18-1:26}:"A.Private" +// CHECK: fix-it:"{{.*}}module.private.modulemap":{1:18-1:26}:"A.Private" #ifndef HEADER #define HEADER ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r290221 - Fix build breakage in r290219. Notes should not be in diagnostic groups.
Author: graydon Date: Tue Dec 20 18:48:14 2016 New Revision: 290221 URL: http://llvm.org/viewvc/llvm-project?rev=290221&view=rev Log: Fix build breakage in r290219. Notes should not be in diagnostic groups. Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=290221&r1=290220&r2=290221&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 20 18:48:14 2016 @@ -646,8 +646,7 @@ def warn_mmap_mismatched_top_level_priva "top-level module '%0' in private module map, expected a submodule of '%1'">, InGroup; def note_mmap_rename_top_level_private_as_submodule : Note< - "make '%0' a submodule of '%1' to ensure it can be found by name">, - InGroup; + "make '%0' a submodule of '%1' to ensure it can be found by name">; def warn_auto_module_import : Warning< "treating #%select{include|import|include_next|__include_macros}0 as an " ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
r290219 - [modules] Handle modules with nonstandard names in module.private.modulemaps
Author: graydon Date: Tue Dec 20 18:24:39 2016 New Revision: 290219 URL: http://llvm.org/viewvc/llvm-project?rev=290219&view=rev Log: [modules] Handle modules with nonstandard names in module.private.modulemaps Summary: The module system supports accompanying a primary module (say Foo) with an auxiliary "private" module (defined in an adjacent module.private.modulemap file) that augments the primary module when associated private headers are available. The feature is intended to be used to augment the primary module with a submodule (say Foo.Private), however some users in the wild are choosing to augment the primary module with an additional top-level module with a "similar" name (in all cases so far: FooPrivate). This "works" when a user of the module initially imports a private header, such as '#import "Foo/something_private.h"' since the Foo import winds up importing FooPrivate in passing. But if the import is subsequently recorded in a PCH file, reloading the PCH will fail to validate because of a cross-check that attempts to find the module.modulemap (or module.private.modulemap) using HeaderSearch algorithm, applied to the "FooPrivate" name. Since it's stored in Foo.framework/Modules, not FooPrivate.framework/Modules, the check fails and the PCH is rejected. This patch adds a compensatory workaround in the HeaderSearch algorithm when searching (and failing to find) a module of the form FooPrivate: the name used to derive filesystem paths is decoupled from the module name being searched for, and if the initial search fails and the module is named "FooPrivate", the filesystem search name is altered to remove the "Private" suffix, and the algorithm is run a second time (still looking for a module named FooPrivate, but looking in directories derived from Foo). Accompanying this change is a new warning that triggers when a user loads a module.private.modulemap that defines a top-level module with a different name from the top-level module defined in its adjacent module.modulemap. Reviewers: doug.gregor, manmanren, bruno Subscribers: bruno, cfe-commits Differential Revision: https://reviews.llvm.org/D27852 Added: cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/ cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/ cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/ cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/a.h cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Headers/aprivate.h cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/ cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.modulemap cfe/trunk/test/Modules/Inputs/implicit-private-with-different-name/A.framework/Modules/module.private.modulemap cfe/trunk/test/Modules/implicit-private-with-different-name.m Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td cfe/trunk/include/clang/Lex/HeaderSearch.h cfe/trunk/lib/Lex/HeaderSearch.cpp cfe/trunk/lib/Lex/ModuleMap.cpp Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=290219&r1=290218&r2=290219&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Tue Dec 20 18:24:39 2016 @@ -243,6 +243,7 @@ def NonModularIncludeInModule : DiagGrou [NonModularIncludeInFrameworkModule]>; def IncompleteModule : DiagGroup<"incomplete-module", [IncompleteUmbrella, NonModularIncludeInModule]>; +def PrivateModule : DiagGroup<"private-module">; def CXX11InlineNamespace : DiagGroup<"c++11-inline-namespace">; def InvalidNoreturn : DiagGroup<"invalid-noreturn">; Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=290219&r1=290218&r2=290219&view=diff == --- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original) +++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Tue Dec 20 18:24:39 2016 @@ -642,6 +642,12 @@ def err_mmap_expected_feature : Error<"e def err_mmap_expected_attribute : Error<"expected an attribute name">; def warn_mmap_unknown_attribute : Warning<"unknown attribute '%0'">, InGroup; +def warn_mmap_mismatched_top_level_private : Warning< + "top-level module '%0' in private module map, expected a submodule of '%1'">, + InGroup; +def note_mmap_rename_top_level_private_as_submodule : Note< + "make '%0' a submodule of '%1' to ensure it can be found by name">,
r289276 - [modules] Add optional out-param to ASTReader::ReadAST for imported submodules.
Author: graydon Date: Fri Dec 9 15:45:49 2016 New Revision: 289276 URL: http://llvm.org/viewvc/llvm-project?rev=289276&view=rev Log: [modules] Add optional out-param to ASTReader::ReadAST for imported submodules. Summary: The Swift frontend is acquiring the ability to load non-module PCH files containing bridging definitions from C/ObjC. As part of this work, it needs to know which submodules were imported by a PCH in order to wrap them in local Swift modules. This information is collected by ASTReader::ReadAST in a local vector, but is currently kept private. The change here is just to make the type of the vector elements public, and provide an optional out-parameter to the ReadAST method to provide the vector's contents to a caller after a successful read. Reviewers: manmanren, rsmith, doug.gregor Subscribers: cfe-commits Differential Revision: https://reviews.llvm.org/D27580 Modified: cfe/trunk/include/clang/Serialization/ASTReader.h cfe/trunk/lib/Serialization/ASTReader.cpp Modified: cfe/trunk/include/clang/Serialization/ASTReader.h URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=289276&r1=289275&r2=289276&view=diff == --- cfe/trunk/include/clang/Serialization/ASTReader.h (original) +++ cfe/trunk/include/clang/Serialization/ASTReader.h Fri Dec 9 15:45:49 2016 @@ -821,6 +821,7 @@ private: // \brief A list of late parsed template function data. SmallVector LateParsedTemplates; +public: struct ImportedSubmodule { serialization::SubmoduleID ID; SourceLocation ImportLoc; @@ -829,6 +830,7 @@ private: : ID(ID), ImportLoc(ImportLoc) {} }; +private: /// \brief A list of modules that were imported by precompiled headers or /// any other non-module AST file. SmallVector ImportedModules; @@ -1404,9 +1406,13 @@ public: /// \param ClientLoadCapabilities The set of client load-failure /// capabilities, represented as a bitset of the enumerators of /// LoadFailureCapabilities. + /// + /// \param Imported optional out-parameter to append the list of modules + /// that were imported by precompiled headers or any other non-module AST file ASTReadResult ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, -unsigned ClientLoadCapabilities); +unsigned ClientLoadCapabilities, +SmallVectorImpl *Imported = nullptr); /// \brief Make the entities in the given module and any of its (non-explicit) /// submodules visible to name lookup. Modified: cfe/trunk/lib/Serialization/ASTReader.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=289276&r1=289275&r2=289276&view=diff == --- cfe/trunk/lib/Serialization/ASTReader.cpp (original) +++ cfe/trunk/lib/Serialization/ASTReader.cpp Fri Dec 9 15:45:49 2016 @@ -3578,7 +3578,8 @@ static bool SkipCursorToBlock(BitstreamC ASTReader::ASTReadResult ASTReader::ReadAST(StringRef FileName, ModuleKind Type, SourceLocation ImportLoc, -unsigned ClientLoadCapabilities) { +unsigned ClientLoadCapabilities, +SmallVectorImpl *Imported) { llvm::SaveAndRestore SetCurImportLocRAII(CurrentImportLoc, ImportLoc); @@ -3744,6 +3745,10 @@ ASTReader::ASTReadResult ASTReader::Read } UnresolvedModuleRefs.clear(); + if (Imported) +Imported->append(ImportedModules.begin(), + ImportedModules.end()); + // FIXME: How do we load the 'use'd modules? They may not be submodules. // Might be unnecessary as use declarations are only used to build the // module itself. ___ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits