r208004 - Add -Wnon-modular-include* options

Ben Langmuir blangmuir at apple.com
Mon May 5 14:44:14 PDT 2014


Author: benlangmuir
Date: Mon May  5 16:44:13 2014
New Revision: 208004

URL: http://llvm.org/viewvc/llvm-project?rev=208004&view=rev
Log:
Add -Wnon-modular-include* options

Warn on non-modular includes in various contexts.

-Wnon-modular-include
 -Wnon-modular-include-in-module
  -Wnon-modular-include-in-framework-module

Where each group is a subgroup of those above it.

Added:
    cfe/trunk/test/Modules/Inputs/require-modular-includes/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/A.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/A.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModule.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/B.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/B.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/C.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap
    cfe/trunk/test/Modules/Inputs/require-modular-includes/NotFramework.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/NotInModule.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/module.modulemap
    cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/bar/
    cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h
    cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/foo.h
    cfe/trunk/test/Modules/require-modular-includes.m
Modified:
    cfe/trunk/include/clang/Basic/DiagnosticGroups.td
    cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
    cfe/trunk/include/clang/Lex/ModuleMap.h
    cfe/trunk/lib/Lex/ModuleMap.cpp
    cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=208004&r1=208003&r2=208004&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Mon May  5 16:44:13 2014
@@ -186,6 +186,12 @@ def IncompatiblePointerTypes
     [IncompatiblePointerTypesDiscardsQualifiers]>;
 def IncompleteUmbrella : DiagGroup<"incomplete-umbrella">;
 def IncompleteModule : DiagGroup<"incomplete-module", [IncompleteUmbrella]>;
+def NonModularIncludeInFrameworkModule
+  : DiagGroup<"non-modular-include-in-framework-module">;
+def NonModularIncludeInModule : DiagGroup<"non-modular-include-in-module",
+                                          [NonModularIncludeInFrameworkModule]>;
+def NonModularInclude : DiagGroup<"non-modular-include",
+                                  [NonModularIncludeInModule]>;
 def InvalidNoreturn : DiagGroup<"invalid-noreturn">;
 def InvalidSourceEncoding : DiagGroup<"invalid-source-encoding">;
 def KNRPromotedParameter : DiagGroup<"knr-promoted-parameter">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=208004&r1=208003&r2=208004&view=diff
==============================================================================
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Mon May  5 16:44:13 2014
@@ -620,6 +620,14 @@ def error_use_of_private_header_outside_
   "use of private header from outside its module: '%0'">;
 def error_undeclared_use_of_module : Error<
   "module %0 does not depend on a module exporting '%1'">;
+def warn_non_modular_include_in_framework_module : Warning<
+  "include of non-modular header inside framework module '%0'">,
+  InGroup<NonModularIncludeInFrameworkModule>, DefaultIgnore;
+def warn_non_modular_include_in_module : Warning<
+  "include of non-modular header inside module '%0'">,
+  InGroup<NonModularIncludeInModule>, DefaultIgnore;
+def warn_non_modular_include : Warning<
+  "include of non-modular header">, InGroup<NonModularInclude>, DefaultIgnore;
 
 def warn_header_guard : Warning<
   "%0 is used as a header guard here, followed by #define of a different macro">,

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=208004&r1=208003&r2=208004&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Mon May  5 16:44:13 2014
@@ -195,6 +195,13 @@ private:
   KnownHeader findHeaderInUmbrellaDirs(const FileEntry *File,
                     SmallVectorImpl<const DirectoryEntry *> &IntermediateDirs);
 
+  /// \brief A convenience method to determine if \p File is (possibly nested)
+  /// in an umbrella directory.
+  bool isHeaderInUmbrellaDirs(const FileEntry *File) {
+    SmallVector<const DirectoryEntry *, 2> IntermediateDirs;
+    return static_cast<bool>(findHeaderInUmbrellaDirs(File, IntermediateDirs));
+  }
+
 public:
   /// \brief Construct a new module map.
   ///

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=208004&r1=208003&r2=208004&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon May  5 16:44:13 2014
@@ -230,56 +230,57 @@ static bool violatesPrivateInclude(Modul
          RequestedModule->getTopLevelModule() != RequestingModule;
 }
 
+static Module *getTopLevelOrNull(Module *M) {
+  return M ? M->getTopLevelModule() : nullptr;
+}
+
 void ModuleMap::diagnoseHeaderInclusion(Module *RequestingModule,
                                         SourceLocation FilenameLoc,
                                         StringRef Filename,
                                         const FileEntry *File) {
   // No errors for indirect modules. This may be a bit of a problem for modules
   // with no source files.
-  if (RequestingModule != SourceModule)
+  if (getTopLevelOrNull(RequestingModule) != getTopLevelOrNull(SourceModule))
     return;
 
   if (RequestingModule)
     resolveUses(RequestingModule, /*Complain=*/false);
 
-  HeadersMap::iterator Known = findKnownHeader(File);
-  if (Known == Headers.end()) {
-    if (LangOpts.ModulesStrictDeclUse)
-      Diags.Report(FilenameLoc, diag::error_undeclared_use_of_module)
-          << RequestingModule->getFullModuleName() << Filename;
-    return;
-  }
-
+  bool Excluded = false;
   Module *Private = NULL;
   Module *NotUsed = NULL;
-  for (SmallVectorImpl<KnownHeader>::iterator I = Known->second.begin(),
-                                              E = Known->second.end();
-       I != E; ++I) {
-    // Excluded headers don't really belong to a module.
-    if (I->getRole() == ModuleMap::ExcludedHeader)
-      continue;
-
-    // If 'File' is part of 'RequestingModule' we can definitely include it.
-    if (I->getModule() == RequestingModule)
-      return;
 
-    // Remember private headers for later printing of a diagnostic.
-    if (violatesPrivateInclude(RequestingModule, File, I->getRole(),
-                               I->getModule())) {
-      Private = I->getModule();
-      continue;
-    }
+  HeadersMap::iterator Known = findKnownHeader(File);
+  if (Known != Headers.end()) {
+    for (const KnownHeader &Header : Known->second) {
+      // Excluded headers don't really belong to a module.
+      if (Header.getRole() == ModuleMap::ExcludedHeader) {
+        Excluded = true;
+        continue;
+      }
+
+      // If 'File' is part of 'RequestingModule' we can definitely include it.
+      if (Header.getModule() == RequestingModule)
+        return;
+
+      // Remember private headers for later printing of a diagnostic.
+      if (violatesPrivateInclude(RequestingModule, File, Header.getRole(),
+                                 Header.getModule())) {
+        Private = Header.getModule();
+        continue;
+      }
+
+      // If uses need to be specified explicitly, we are only allowed to return
+      // modules that are explicitly used by the requesting module.
+      if (RequestingModule && LangOpts.ModulesDeclUse &&
+          !directlyUses(RequestingModule, Header.getModule())) {
+        NotUsed = Header.getModule();
+        continue;
+      }
 
-    // If uses need to be specified explicitly, we are only allowed to return
-    // modules that are explicitly used by the requesting module.
-    if (RequestingModule && LangOpts.ModulesDeclUse &&
-        !directlyUses(RequestingModule, I->getModule())) {
-      NotUsed = I->getModule();
-      continue;
+      // We have found a module that we can happily use.
+      return;
     }
-
-    // We have found a module that we can happily use.
-    return;
   }
 
   // We have found a header, but it is private.
@@ -296,7 +297,22 @@ void ModuleMap::diagnoseHeaderInclusion(
     return;
   }
 
-  // Headers for which we have not found a module are fine to include.
+  if (Excluded || isHeaderInUmbrellaDirs(File))
+    return;
+
+  // At this point, only non-modular includes remain.
+
+  if (LangOpts.ModulesStrictDeclUse) {
+    Diags.Report(FilenameLoc, diag::error_undeclared_use_of_module)
+        << RequestingModule->getFullModuleName() << Filename;
+  } else if (RequestingModule) {
+    diag::kind DiagID = RequestingModule->getTopLevelModule()->IsFramework ?
+        diag::warn_non_modular_include_in_framework_module :
+        diag::warn_non_modular_include_in_module;
+    Diags.Report(FilenameLoc, DiagID) << RequestingModule->getFullModuleName();
+  } else {
+    Diags.Report(FilenameLoc, diag::warn_non_modular_include);
+  }
 }
 
 ModuleMap::KnownHeader

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=208004&r1=208003&r2=208004&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Mon May  5 16:44:13 2014
@@ -611,22 +611,32 @@ const FileEntry *Preprocessor::LookupFil
   // to one of the headers on the #include stack.  Walk the list of the current
   // headers on the #include stack and pass them to HeaderInfo.
   if (IsFileLexer()) {
-    if ((CurFileEnt = SourceMgr.getFileEntryForID(CurPPLexer->getFileID())))
+    if ((CurFileEnt = SourceMgr.getFileEntryForID(CurPPLexer->getFileID()))) {
       if ((FE = HeaderInfo.LookupSubframeworkHeader(Filename, CurFileEnt,
                                                     SearchPath, RelativePath,
-                                                    SuggestedModule)))
+                                                    SuggestedModule))) {
+        if (SuggestedModule && !LangOpts.AsmPreprocessor)
+          HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
+              getModuleForLocation(FilenameLoc), FilenameLoc, Filename, FE);
         return FE;
+      }
+    }
   }
 
   for (unsigned i = 0, e = IncludeMacroStack.size(); i != e; ++i) {
     IncludeStackInfo &ISEntry = IncludeMacroStack[e-i-1];
     if (IsFileLexer(ISEntry)) {
       if ((CurFileEnt =
-           SourceMgr.getFileEntryForID(ISEntry.ThePPLexer->getFileID())))
+           SourceMgr.getFileEntryForID(ISEntry.ThePPLexer->getFileID()))) {
         if ((FE = HeaderInfo.LookupSubframeworkHeader(
                 Filename, CurFileEnt, SearchPath, RelativePath,
-                SuggestedModule)))
+                SuggestedModule))) {
+          if (SuggestedModule && !LangOpts.AsmPreprocessor)
+            HeaderInfo.getModuleMap().diagnoseHeaderInclusion(
+                getModuleForLocation(FilenameLoc), FilenameLoc, Filename, FE);
           return FE;
+        }
+      }
     }
   }
 

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/A.framework/Headers/A.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "B/B.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModule.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModule.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModule.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// AnotherModule.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/AnotherModuleExcluded.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// AnotherModuleExcluded.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/B.framework/Headers/B.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "C.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/C.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/C.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/C.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/C.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// C.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/ExcludedFromAnotherModule.framework/Headers/ExcludedFromAnotherModule.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "AnotherModuleExcluded.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromAnotherModule.framework/Headers/FromAnotherModule.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "AnotherModule.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleFail.framework/Headers/FromImportedModuleFail.h Mon May  5 16:44:13 2014
@@ -0,0 +1,2 @@
+// FromImportedModuleFail.h
+#include "NotInModule.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "FromImportedModuleOK2.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Headers/FromImportedModuleOK2.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// FromImportedModuleOK2.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedModuleOK.framework/Modules/module.modulemap Mon May  5 16:44:13 2014
@@ -0,0 +1,4 @@
+framework module FromImportedModuleOK {
+  header "FromImportedModuleOK.h"
+  header "FromImportedModuleOK2.h"
+}

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Headers/Header.h Mon May  5 16:44:13 2014
@@ -0,0 +1,2 @@
+// Header.h
+#include "NotInModule.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromImportedSubModule.framework/Modules/module.modulemap Mon May  5 16:44:13 2014
@@ -0,0 +1,5 @@
+framework module FromImportedSubModule {
+  module Sub {
+    header "Header.h"
+  }
+}

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h?rev=208004&view=auto
==============================================================================
    (empty)

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Headers/FromNonModularSubframework.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "Subframework/Subframework.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromNonModularSubframework.framework/Modules/module.modulemap Mon May  5 16:44:13 2014
@@ -0,0 +1,3 @@
+framework module FromNonModularSubframework {
+  header "FromNonModularSubframework.h"
+}

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Frameworks/Subframework.framework/Headers/Subframework.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// Subframework.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Headers/FromSubframework.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "Subframework/Subframework.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromSubframework.framework/Modules/module.modulemap Mon May  5 16:44:13 2014
@@ -0,0 +1,7 @@
+framework module FromSubframework {
+  umbrella header "FromSubframework.h"
+
+  framework module Subframework {
+    umbrella header "Subframework.h"
+  }
+}

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/FromUmbrella.framework/Headers/FromUmbrella.h Mon May  5 16:44:13 2014
@@ -0,0 +1,2 @@
+#include "umbrella/foo.h"
+#include "umbrella/bar/bar.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/Excluded.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// Excluded.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Headers/IncludeExcluded.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+#include "Excluded.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/IncludeExcluded.framework/Modules/module.modulemap Mon May  5 16:44:13 2014
@@ -0,0 +1,4 @@
+framework module IncludeExcluded {
+  header "IncludeExcluded.h"
+  exclude header "Excluded.h"
+}

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/NotFramework.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/NotFramework.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/NotFramework.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/NotFramework.h Mon May  5 16:44:13 2014
@@ -0,0 +1,2 @@
+// NotFramework.h
+#import "NotInModule.h"

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/NotInModule.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/NotInModule.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/NotInModule.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/NotInModule.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// NotInModule.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/module.modulemap
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/module.modulemap?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/module.modulemap Mon May  5 16:44:13 2014
@@ -0,0 +1,12 @@
+module AnotherModule {
+  header "AnotherModule.h"
+  exclude header "AnotherModuleExcluded.h"
+}
+module Umbrella {
+  umbrella "umbrella"
+}
+module NotFramework {
+  header "NotFramework.h"
+}
+
+framework module * { }

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/bar/bar.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// bar.h

Added: cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/foo.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/foo.h?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/foo.h (added)
+++ cfe/trunk/test/Modules/Inputs/require-modular-includes/umbrella/foo.h Mon May  5 16:44:13 2014
@@ -0,0 +1 @@
+// foo.h

Added: cfe/trunk/test/Modules/require-modular-includes.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/require-modular-includes.m?rev=208004&view=auto
==============================================================================
--- cfe/trunk/test/Modules/require-modular-includes.m (added)
+++ cfe/trunk/test/Modules/require-modular-includes.m Mon May  5 16:44:13 2014
@@ -0,0 +1,95 @@
+// RUN: rm -rf %t
+// REQUIRES: shell
+
+// Including a header from the imported module
+// RUN: echo '@import FromImportedModuleOK;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fsyntax-only -x objective-c -
+
+// Including a non-modular header
+// RUN: echo '@import FromImportedModuleFail;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -I %S/Inputs/require-modular-includes \
+// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Including a header from a subframework
+// RUN: echo '@import FromSubframework;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fsyntax-only -x objective-c -
+
+// Including a header from a subframework (fail)
+// RUN: echo '@import FromNonModularSubframework;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -I %S/Inputs/require-modular-includes \
+// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Including a non-modular header from a submodule
+// RUN: echo '@import FromImportedSubModule;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -I %S/Inputs/require-modular-includes \
+// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Including a non-modular header (directly) with -fmodule-name set
+// RUN: echo '#include "NotInModule.h"' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fmodule-name=A -fsyntax-only -x objective-c -
+
+// Including a non-modular header (directly) with -Wnon-modular-include
+// RUN: echo '#include "NotInModule.h"' | \
+// RUN:   %clang_cc1 -Wnon-modular-include -fmodules \
+// RUN:     -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
+// RUN:     -fmodule-name=A -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Including an excluded header
+// RUN: echo '@import IncludeExcluded;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fsyntax-only -x objective-c -
+
+// Including a header from another module
+// RUN: echo '@import FromAnotherModule;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -I %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fsyntax-only -x objective-c -
+
+// Including an excluded header from another module
+// RUN: echo '@import ExcludedFromAnotherModule;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -I %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fsyntax-only -x objective-c -
+
+// Including a header from an umbrella directory
+// RUN: echo '@import FromUmbrella;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -I %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fsyntax-only -x objective-c -
+
+// A includes B includes non-modular C
+// RUN: echo '@import A;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -F %S/Inputs/require-modular-includes \
+// RUN:     -I %S/Inputs/require-modular-includes \
+// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// Non-framework module (pass)
+// RUN: echo '@import NotFramework;' | \
+// RUN:   %clang_cc1 -Wnon-modular-include-in-framework-module -fmodules \
+// RUN:     -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
+// RUN:     -Werror -fsyntax-only -x objective-c -
+
+// Non-framework module (fail)
+// RUN: echo '@import NotFramework;' | \
+// RUN:   not %clang_cc1 -Werror=non-modular-include -fmodules \
+// RUN:     -fmodules-cache-path=%t -I %S/Inputs/require-modular-includes \
+// RUN:     -fsyntax-only -x objective-c - 2>&1 | FileCheck %s
+
+// CHECK: include of non-modular header





More information about the cfe-commits mailing list