r335190 - Fix hmaptool cmake file to work on Windows

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 16:08:43 2018
New Revision: 335190

URL: http://llvm.org/viewvc/llvm-project?rev=335190=rev
Log:
Fix hmaptool cmake file to work on Windows

Unbreak a few windows buildbots:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/11315
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/10411/steps/test-check-all/logs/stdio

Modified:
cfe/trunk/utils/hmaptool/CMakeLists.txt

Modified: cfe/trunk/utils/hmaptool/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/hmaptool/CMakeLists.txt?rev=335190=335189=335190=diff
==
--- cfe/trunk/utils/hmaptool/CMakeLists.txt (original)
+++ cfe/trunk/utils/hmaptool/CMakeLists.txt Wed Jun 20 16:08:43 2018
@@ -1,14 +1,14 @@
 set(CLANG_HMAPTOOL hmaptool)
 
-add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/bin/${CLANG_HMAPTOOL}
+add_custom_command(OUTPUT 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL}
COMMAND ${CMAKE_COMMAND} -E make_directory
- ${CMAKE_BINARY_DIR}/bin
+ ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin
COMMAND ${CMAKE_COMMAND} -E copy
  ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL}
- ${CMAKE_BINARY_DIR}/bin/
+ ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${CLANG_HMAPTOOL})
 
-list(APPEND Depends ${CMAKE_BINARY_DIR}/bin/${CLANG_HMAPTOOL})
+list(APPEND Depends 
${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin/${CLANG_HMAPTOOL})
 install(PROGRAMS ${CLANG_HMAPTOOL} DESTINATION bin)
 
 add_custom_target(hmaptool ALL DEPENDS ${Depends})


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D46485: Add python tool to dump and construct header maps

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Hi Stella,

On Wed, Jun 20, 2018 at 3:44 PM Stella Stamenova via Phabricator
 wrote:
>
> stella.stamenova added a comment.
>
> This breaks the clang tests on Windows when building using Visual Studio as 
> none of the updated tests can find hmaptool.

Yes. I contacted Galina about that but maybe it was the wrong person
to contact.

> Visual Studio as a generator supports multiple configurations, so its bin 
> folder varies depending on the build configuration. The generalized version 
> of the bin directory is: ${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin. This is 
> actually the proper bin directory to use for any generator because 
> ${CMAKE_CFG_INTDIR} is simply '.' when the generator (such as ninja) doesn't 
> support multiple configurations.

Good to know.

> I can look into a fix and submit a change for review tomorrow if you can't, 
> but in the future please make sure to use the full path to the bin directory 
> (${CMAKE_BINARY_DIR}/${CMAKE_CFG_INTDIR}/bin) to avoid missing a generator.

I'll try to fix it now. Thanks for the heads up!

>
>
> Repository:
>   rC Clang
>
> https://reviews.llvm.org/D46485
>
>
>


-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r335184 - Warning for framework headers using double quote includes

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 15:11:59 2018
New Revision: 335184

URL: http://llvm.org/viewvc/llvm-project?rev=335184=rev
Log:
Warning for framework headers using double quote includes

Introduce -Wquoted-include-in-framework-header, which should fire a warning
whenever a quote include appears in a framework header and suggest a fix-it.
For instance, for header A.h added in the tests, this is how the warning looks
like:

./A.framework/Headers/A.h:2:10: warning: double-quoted include "A0.h" in 
framework header, expected angle-bracketed instead 
[-Wquoted-include-in-framework-header]
#include "A0.h"
 ^~
 
./A.framework/Headers/A.h:3:10: warning: double-quoted include "B.h" in 
framework header, expected angle-bracketed instead 
[-Wquoted-include-in-framework-header]
#include "B.h"
 ^
 

This helps users to prevent frameworks from using local headers when in fact
they should be targetting system level ones.

The warning is off by default.

Differential Revision: https://reviews.llvm.org/D47157

rdar://problem/37077034

Added:
cfe/trunk/test/Modules/Inputs/double-quotes/
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A.h
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Headers/A0.h
cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/double-quotes/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/B.h
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Headers/X.h
cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/

cfe/trunk/test/Modules/Inputs/double-quotes/X.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/a.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.h
cfe/trunk/test/Modules/Inputs/double-quotes/flat-header-path/Z.modulemap
cfe/trunk/test/Modules/Inputs/double-quotes/x.hmap.json
cfe/trunk/test/Modules/Inputs/double-quotes/z.yaml
cfe/trunk/test/Modules/double-quotes.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticGroups.td
cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=335184=335183=335184=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Wed Jun 20 15:11:59 2018
@@ -31,6 +31,7 @@ def AutoDisableVptrSanitizer : DiagGroup
 def Availability : DiagGroup<"availability">;
 def Section : DiagGroup<"section">;
 def AutoImport : DiagGroup<"auto-import">;
+def FrameworkHdrQuotedInclude : 
DiagGroup<"quoted-include-in-framework-header">;
 def CXX14BinaryLiteral : DiagGroup<"c++14-binary-literal">;
 def CXXPre14CompatBinaryLiteral : 
DiagGroup<"c++98-c++11-compat-binary-literal">;
 def GNUBinaryLiteral : DiagGroup<"gnu-binary-literal">;

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=335184=335183=335184=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Wed Jun 20 15:11:59 2018
@@ -714,6 +714,11 @@ def warn_mmap_redundant_export_as : Warn
 def err_mmap_submodule_export_as : Error<
   "only top-level modules can be re-exported as public">;
 
+def warn_quoted_include_in_framework_header : Warning<
+  "double-quoted include \"%0\" in framework header, "
+  "expected angle-bracketed instead"
+  >, InGroup, DefaultIgnore;
+
 def warn_auto_module_import : Warning<
   "treating #%select{include|import|include_next|__include_macros}0 as an "
   "import of module '%1'">, InGroup, DefaultIgnore;

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=335184=335183=335184=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Wed Jun 20 15:11:59 2018
@@ -621,6 +621,59 @@ static const char *copyString(StringRef
   return CopyStr;
 }
 
+static bool isFrameworkStylePath(StringRef Path,
+ SmallVectorImpl ) {
+  using namespace llvm::sys;
+  path::const_iterator I = path::begin(Path);
+  

r335177 - Add python tool to dump and construct header maps

2018-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jun 20 14:16:37 2018
New Revision: 335177

URL: http://llvm.org/viewvc/llvm-project?rev=335177=rev
Log:
Add python tool to dump and construct header maps

Header maps are binary files used by Xcode, which are used to map
header names or paths to other locations. Clang has support for
those since its inception, but there's not a lot of header map
testing around.

Since it's a binary format, testing becomes pretty much brittle
and its hard to even know what's inside if you don't have the
appropriate tools.

Add a python based tool that allows creating and dumping header
maps based on a json description of those. While here, rewrite
tests to use the tool and remove the binary files from the tree.

This tool was initially written by Daniel Dunbar.

Differential Revision: https://reviews.llvm.org/D46485

rdar://problem/39994722

Added:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap.json
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap.json
cfe/trunk/utils/hmaptool/
cfe/trunk/utils/hmaptool/CMakeLists.txt
cfe/trunk/utils/hmaptool/hmaptool   (with props)
Removed:
cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
cfe/trunk/test/Preprocessor/Inputs/nonportable-hmaps/foo.hmap
Modified:
cfe/trunk/CMakeLists.txt
cfe/trunk/test/CMakeLists.txt
cfe/trunk/test/Modules/crash-vfs-headermaps.m
cfe/trunk/test/Preprocessor/headermap-rel.c
cfe/trunk/test/Preprocessor/headermap-rel2.c
cfe/trunk/test/Preprocessor/nonportable-include-with-hmap.c

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=335177=335176=335177=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Wed Jun 20 14:16:37 2018
@@ -753,6 +753,7 @@ endif()
 if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)
   add_subdirectory(utils/ClangVisualizers)
 endif()
+add_subdirectory(utils/hmaptool)
 
 configure_file(
   ${CLANG_SOURCE_DIR}/include/clang/Config/config.h.cmake

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=335177=335176=335177=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed Jun 20 14:16:37 2018
@@ -54,6 +54,7 @@ list(APPEND CLANG_TEST_DEPS
   clang-rename
   clang-refactor
   clang-diff
+  hmaptool
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)

Modified: cfe/trunk/test/Modules/crash-vfs-headermaps.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-headermaps.m?rev=335177=335176=335177=diff
==
--- cfe/trunk/test/Modules/crash-vfs-headermaps.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-headermaps.m Wed Jun 20 14:16:37 2018
@@ -1,15 +1,9 @@
 // REQUIRES: crash-recovery, shell, system-darwin
 
-// This uses a headermap with this entry:
-//   Foo.h -> Foo/Foo.h
-
-// Copy out the headermap from test/Preprocessor/Inputs/headermap-rel and avoid
-// adding another binary format to the repository.
-
 // RUN: rm -rf %t
-// RUN: mkdir -p %t/m
-// RUN: cp -a %S/../Preprocessor/Inputs/headermap-rel %t/i
+// RUN: mkdir -p %t/m %t/i/Foo.framework/Headers
 // RUN: echo '// Foo.h' > %t/i/Foo.framework/Headers/Foo.h
+// RUN: hmaptool write %S/../Preprocessor/Inputs/headermap-rel/foo.hmap.json 
%t/i/foo.hmap
 
 // RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
 // RUN: %clang -fsyntax-only -fmodules -fmodules-cache-path=%t/m %s \

Removed: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap?rev=335176=auto
==
Binary files cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap 
(original) and cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap 
(removed) differ

Added: cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json?rev=335177=auto
==
--- cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json (added)
+++ cfe/trunk/test/Preprocessor/Inputs/headermap-rel/foo.hmap.json Wed Jun 20 
14:16:37 2018
@@ -0,0 +1,6 @@
+{
+  "mappings" :
+{
+ "Foo.h" : "Foo/Foo.h"
+}
+}

Removed: cfe/trunk/test/Preprocessor/Inputs/headermap-rel2/project-headers.hmap
URL: 

r334859 - [Modules] Improve .Private fix-its to handle 'explicit' and 'framework'

2018-06-15 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 15 13:13:28 2018
New Revision: 334859

URL: http://llvm.org/viewvc/llvm-project?rev=334859=rev
Log:
[Modules] Improve .Private fix-its to handle 'explicit' and 'framework'

When in the context of suggestion the fix-it from .Private to _Private
for private modules, trim off the 'explicit' and add 'framework' when
appropriate.

rdar://problem/41030554

Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/implicit-private-with-submodule/A.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/implicit-private-with-submodule.m

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=334859=334858=334859=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Fri Jun 15 13:13:28 2018
@@ -1403,6 +1403,13 @@ namespace clang {
 void parseConflict();
 void parseInferredModuleDecl(bool Framework, bool Explicit);
 
+/// Private modules are canonicalized as Foo_Private. Clang provides extra
+/// module map search logic to find the appropriate private module when PCH
+/// is used with implicit module maps. Warn when private modules are 
written
+/// in other ways (FooPrivate and Foo.Private), providing notes and fixits.
+void diagnosePrivateModules(SourceLocation ExplicitLoc,
+SourceLocation FrameworkLoc);
+
 using Attributes = ModuleMap::Attributes;
 
 bool parseOptionalAttributes(Attributes );
@@ -1672,11 +1679,8 @@ namespace {
 /// module map search logic to find the appropriate private module when PCH
 /// is used with implicit module maps. Warn when private modules are written
 /// in other ways (FooPrivate and Foo.Private), providing notes and fixits.
-static void diagnosePrivateModules(const ModuleMap ,
-   DiagnosticsEngine ,
-   const Module *ActiveModule,
-   SourceLocation InlineParent) {
-
+void ModuleMapParser::diagnosePrivateModules(SourceLocation ExplicitLoc,
+ SourceLocation FrameworkLoc) {
   auto GenNoteAndFixIt = [&](StringRef BadName, StringRef Canonical,
  const Module *M, SourceRange ReplLoc) {
 auto D = Diags.Report(ActiveModule->DefinitionLoc,
@@ -1693,6 +1697,7 @@ static void diagnosePrivateModules(const
 SmallString<128> FullName(ActiveModule->getFullModuleName());
 if (!FullName.startswith(M->Name) && !FullName.endswith("Private"))
   continue;
+SmallString<128> FixedPrivModDecl;
 SmallString<128> Canonical(M->Name);
 Canonical.append("_Private");
 
@@ -1702,8 +1707,20 @@ static void diagnosePrivateModules(const
   Diags.Report(ActiveModule->DefinitionLoc,
diag::warn_mmap_mismatched_private_submodule)
   << FullName;
-  GenNoteAndFixIt(FullName, Canonical, M,
-  SourceRange(InlineParent, ActiveModule->DefinitionLoc));
+
+  SourceLocation FixItInitBegin = CurrModuleDeclLoc;
+  if (FrameworkLoc.isValid())
+FixItInitBegin = FrameworkLoc;
+  if (ExplicitLoc.isValid())
+FixItInitBegin = ExplicitLoc;
+
+  if (FrameworkLoc.isValid() || ActiveModule->Parent->IsFramework)
+FixedPrivModDecl.append("framework ");
+  FixedPrivModDecl.append("module ");
+  FixedPrivModDecl.append(Canonical);
+
+  GenNoteAndFixIt(FullName, FixedPrivModDecl, M,
+  SourceRange(FixItInitBegin, 
ActiveModule->DefinitionLoc));
   continue;
 }
 
@@ -1747,6 +1764,7 @@ void ModuleMapParser::parseModuleDecl()
 
   // Parse 'explicit' or 'framework' keyword, if present.
   SourceLocation ExplicitLoc;
+  SourceLocation FrameworkLoc;
   bool Explicit = false;
   bool Framework = false;
 
@@ -1758,7 +1776,7 @@ void ModuleMapParser::parseModuleDecl()
 
   // Parse 'framework' keyword, if present.
   if (Tok.is(MMToken::FrameworkKeyword)) {
-consumeToken();
+FrameworkLoc = consumeToken();
 Framework = true;
   } 
   
@@ -1800,7 +1818,6 @@ void ModuleMapParser::parseModuleDecl()
   }
   
   Module *PreviousActiveModule = ActiveModule;  
-  SourceLocation LastInlineParentLoc = SourceLocation();
   if (Id.size() > 1) {
 // This module map defines a submodule. Go find the module of which it
 // is a submodule.
@@ -1811,7 +1828,6 @@ void ModuleMapParser::parseModuleDecl()
 if (I == 0)
   TopLevelModule = Next;
 ActiveModule = Next;
-LastInlineParentLoc = Id[I].second;
 continue;
   }
   
@@ -1934,7 +1950,7 @@ void ModuleMapParser::parseModuleDecl()
   !Diags.isIgnored(diag::warn_mmap_mismatched_private_module_name,
 

r334747 - [CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2

2018-06-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jun 14 11:20:04 2018
New Revision: 334747

URL: http://llvm.org/viewvc/llvm-project?rev=334747=rev
Log:
[CMAKE][c-index-test] Honor CMAKE_OSX_SYSROOT to compute include dir for libxml2

On MacOS, if CMAKE_OSX_SYSROOT is used and the user has command line tools
installed, we currently get the include path for libxml2 as
/usr/include/libxml2, instead of ${CMAKE_OSX_SYSROOT}/usr/include/libxml2.

Make it consistent on MacOS by prefixing ${CMAKE_OSX_SYSROOT} when
possible.

rdar://problem/41103601

Modified:
cfe/trunk/tools/c-index-test/CMakeLists.txt

Modified: cfe/trunk/tools/c-index-test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/CMakeLists.txt?rev=334747=334746=334747=diff
==
--- cfe/trunk/tools/c-index-test/CMakeLists.txt (original)
+++ cfe/trunk/tools/c-index-test/CMakeLists.txt Thu Jun 14 11:20:04 2018
@@ -40,7 +40,11 @@ set_target_properties(c-index-test
 
 # If libxml2 is available, make it available for c-index-test.
 if (CLANG_HAVE_LIBXML)
-  include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
+  if ((CMAKE_OSX_SYSROOT) AND (EXISTS 
${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR}))
+include_directories(SYSTEM ${CMAKE_OSX_SYSROOT}/${LIBXML2_INCLUDE_DIR})
+  else()
+include_directories(SYSTEM ${LIBXML2_INCLUDE_DIR})
+  endif()
   target_link_libraries(c-index-test PRIVATE ${LIBXML2_LIBRARIES})
 endif()
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r333718 - [Modules] Warning for module declarations lacking 'framework' qualifier

2018-05-31 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu May 31 18:26:18 2018
New Revision: 333718

URL: http://llvm.org/viewvc/llvm-project?rev=333718=rev
Log:
[Modules] Warning for module declarations lacking 'framework' qualifier

When a module declaration for a framework lacks the 'framework'
qualifier, the listed headers aren't found (because there's no
trigger for the special framework style path lookup) and the module
is silently not built. This leads to frameworks not being modularized
by accident, which is pretty bad.

Add a warning and suggest the user to add the 'framework' qualifier
when we can prove that it's the case.

rdar://problem/39193062

Added:
cfe/trunk/test/Modules/Inputs/incomplete-framework-module/
cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/Foo.h

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Headers/FooB.h

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Modules/

cfe/trunk/test/Modules/Inputs/incomplete-framework-module/Foo.framework/Modules/module.modulemap
cfe/trunk/test/Modules/incomplete-framework-module.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

Modified: cfe/trunk/include/clang/Basic/DiagnosticGroups.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticGroups.td?rev=333718=333717=333718=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticGroups.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticGroups.td Thu May 31 18:26:18 2018
@@ -285,6 +285,8 @@ def IncompatiblePointerTypes
 [IncompatiblePointerTypesDiscardsQualifiers,
  IncompatibleFunctionPointerTypes]>;
 def IncompleteUmbrella : DiagGroup<"incomplete-umbrella">;
+def IncompleteFrameworkModuleDeclaration
+  : DiagGroup<"incomplete-framework-module-declaration">;
 def NonModularIncludeInFrameworkModule
   : DiagGroup<"non-modular-include-in-framework-module">;
 def NonModularIncludeInModule : DiagGroup<"non-modular-include-in-module",

Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td?rev=333718=333717=333718=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td Thu May 31 18:26:18 2018
@@ -694,6 +694,11 @@ def warn_mmap_mismatched_private_module_
   InGroup;
 def note_mmap_rename_top_level_private_module : Note<
   "rename '%0' to ensure it can be found by name">;
+def warn_mmap_incomplete_framework_module_declaration : Warning<
+  "skipping '%0' because module declaration of '%1' lacks the 'framework' 
qualifier">,
+  InGroup;
+def note_mmap_add_framework_keyword : Note<
+  "use 'framework module' to declare module '%0'">;
 
 def err_mmap_duplicate_header_attribute : Error<
   "header attribute '%0' specified multiple times">;

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=333718=333717=333718=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Thu May 31 18:26:18 2018
@@ -303,8 +303,15 @@ private:
   Module *resolveModuleId(const ModuleId , Module *Mod, bool Complain) 
const;
 
   /// Add an unresolved header to a module.
+  ///
+  /// \param Mod The module in which we're adding the unresolved header
+  ///directive.
+  /// \param Header The unresolved header directive.
+  /// \param NeedsFramework If Mod is not a framework but a missing header 
would
+  ///be found in case Mod was, set it to true. False otherwise.
   void addUnresolvedHeader(Module *Mod,
-   Module::UnresolvedHeaderDirective Header);
+   Module::UnresolvedHeaderDirective Header,
+   bool );
 
   /// Look up the given header directive to find an actual header file.
   ///
@@ -312,14 +319,22 @@ private:
   /// \param Header The header directive to resolve.
   /// \param RelativePathName Filled in with the relative path name from the
   ///module to the resolved header.
+  /// \param NeedsFramework If M is not a framework but a missing header would
+  ///be found in case M was, set it to true. False otherwise.
   /// \return The resolved file, if any.
   const FileEntry *findHeader(Module *M,
   const Module::UnresolvedHeaderDirective ,

Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, May 18, 2018 at 12:46 PM Bruno Cardoso Lopes <
bruno.card...@gmail.com> wrote:

>
>
> On Fri, May 18, 2018 at 11:54 AM Vedant Kumar via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> On May 18, 2018, at 11:48 AM, Eric Liu  wrote:
>>
>>
>> So I have reverted this with r332751.
>>
>>
>> Thanks!
>>
>>
>> I can't see how this introduced cyclic dependencies in module build, as
>> the dependencies should be clangTooling -> clangFormat ->
>> clangToolingInclusions. I'm wondering if there is any module configurations
>> that I need to update to make this work. Right now, module doesn't seem to
>> make any difference between clangTooling and clangToolingInclusions...
>> I'd appreciate it if someone who knows how clang module build is set up
>> could help take a look.
>>
>>
>> + Bruno & David who have more experience in this area than I do.
>>
>
> Gonna try to reproduce and take a look!
>

I could reproduce it. You should be good to go if you add another top level
module for Inclusions (and break the dep):

--- a/include/clang/module.modulemap
+++ b/include/clang/module.modulemap
@@ -153,3 +153,8 @@ module Clang_ToolingCore {
   requires cplusplus
   umbrella "Tooling/Core" module * { export * }
 }
+
+module Clang_ToolingInclusions {
+  requires cplusplus
+  umbrella "Tooling/Inclusions" module * { export * }
+}

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r332720 - Move #include manipulation code to new lib/Tooling/Inclusions.

2018-05-18 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, May 18, 2018 at 11:54 AM Vedant Kumar via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> On May 18, 2018, at 11:48 AM, Eric Liu  wrote:
>
>
> So I have reverted this with r332751.
>
>
> Thanks!
>
>
> I can't see how this introduced cyclic dependencies in module build, as
> the dependencies should be clangTooling -> clangFormat ->
> clangToolingInclusions. I'm wondering if there is any module configurations
> that I need to update to make this work. Right now, module doesn't seem to
> make any difference between clangTooling and clangToolingInclusions...
> I'd appreciate it if someone who knows how clang module build is set up
> could help take a look.
>
>
> + Bruno & David who have more experience in this area than I do.
>

Gonna try to reproduce and take a look!


>
>
> Unfortunately, I couldn't reproduce this on my workstation as the module
> build seemed to be broken due to other errors.
>
>
> The build is dependent on having a set of modularized system headers --
> perhaps that's the issue.
>
>
> I was seeing a lot of warnings; the clang I used to build llvm was built
> near HEAD. Maybe my clang is too new?
>
>
> This sounds a bit suspicious. Can new clang diagnostics land without clean
> stage2 builds? If so, we can look into enabling -Werror on our stage2 bots
> to catch this sort of thing earlier.
>
> vedant
>
>
> Thanks,
> Eric
>
> On Fri, May 18, 2018 at 7:52 PM Eric Liu  wrote:
>
>> Sorry, I'll look into it right now. Will revert it if I can't find a
>> quick fix.
>>
>> On Fri, May 18, 2018, 19:49 Amara Emerson  wrote:
>>
>>> Hi Eric,
>>>
>>> Green dragon buildbots have started failing too, e.g.:
>>> http://green.lab.llvm.org/green/job/clang-stage2-Rthinlto/10222/
>>>
>>> If you don’t have a quick fix can you please revert it.
>>>
>>> Thanks,
>>> Amara
>>>
>>>
>>> On May 18, 2018, at 7:46 PM, Eric Liu  wrote:
>>>
>>> Hi Vedant,
>>>
>>> It seems that your build was not using cmake files in the source tree?
>>> lib/Tooling/Inclusions/ is a (new) standalone library
>>> (clangToolingInclusions, similar to clangToolingCore). You might need
>>> update your build to reflect this change. Let me know if you have any
>>> further question.
>>>
>>> Thanks,
>>> Eric
>>>
>>> On Fri, May 18, 2018 at 6:41 PM Vedant Kumar  wrote:
>>>
 Hi Eric,

 I think there might be a cyclic dependency issue here, possibly one
 that's only visible with LLVM_ENABLE_MODULES=On. I see:

 While building module 'Clang_Tooling' imported from /Users/vsk/src/
 llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:

 While building module 'Clang_Format' imported from /Users/vsk/src/
 llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:

 In file included from :1:


 /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Format/Format.h:20:10:
 fatal error: cyclic dependency in module 'Clang_Tooling': Clang_Tooling $>
 Clang_Format -> Clang_Tooling

 #include "clang/Tooling/Inclusions/IncludeStyle.h"
  ^
 While building module 'Clang_Tooling' imported from /Users/vsk/src/
 llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:
 In file included from :22:

 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringAction.h:14:
 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRules.h:14:
 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringActionRulesInternal.h:16:
 In file included from /Users/vsk/src/llvm.org
 -master/llvm/tools/clang/include/clang/Tooling/Refactoring/RefactoringResultConsumer.h:14:
 /Users/vsk/src/llvm.org-master/llvm/tools/clang/include/clang/Tooling/Refactoring/AtomicChange.h:19:10:
 fatal error: could not build module 'Clang_Format'
 #include "clang/Format/Format.h"
  ^~~
 /Users/vsk/src/llvm.org-master/llvm/tools/clang/lib/Tooling/Execution.cpp:10:10:
 fatal error: could not build module 'Clang_Tooling'
 #include "clang/Tooling/Execution.h"

  ^~~
 3 errors generated.

 Could you take a look?

 thanks,
 vedant

 > On May 18, 2018, at 7:16 AM, Eric Liu via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:
 >
 > Author: ioeric
 > Date: Fri May 18 07:16:37 2018
 > New Revision: 332720
 >
 > URL: http://llvm.org/viewvc/llvm-project?rev=332720=rev
 > Log:
 > Move #include manipulation code to new lib/Tooling/Inclusions.
 >
 > Summary:
 > clangToolingCore is linked into almost everything (incl. clang), but
 > not few tools need #include manipulation at this 

r331322 - [Modules] Allow @import to reach submodules in private module maps

2018-05-01 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue May  1 19:25:03 2018
New Revision: 331322

URL: http://llvm.org/viewvc/llvm-project?rev=331322=rev
Log:
[Modules] Allow @import to reach submodules in private module maps

A @import targeting a top level module from a private module map file
(@import Foo_Private), would fail if there's any submodule declaration
around (module Foo.SomeSub) in the same private module map.

This happens because compileModuleImpl, when building Foo_Private, will
start with the private module map and will not parse the public one,
which leads to unsuccessful parsing of Foo.SomeSub, since top level Foo
was never parsed.

Declaring other submodules in the private module map is not common and
should usually be avoided, but it shouldn't fail to build. Canonicalize
compileModuleImpl to always look at the public module first, so that all
necessary information is available when parsing the private one.

rdar://problem/39822328

Added:
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/SomeSub.h
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.private.modulemap

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/PrivateHeaders/APrivate.h
cfe/trunk/test/Modules/submodule-in-private-mmap.m
Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=331322=331321=331322=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue May  1 19:25:03 2018
@@ -1188,6 +1188,19 @@ compileModuleImpl(CompilerInstance 
   return !Instance.getDiagnostics().hasErrorOccurred();
 }
 
+static const FileEntry *getPublicModuleMap(const FileEntry *File,
+   FileManager ) {
+  StringRef Filename = llvm::sys::path::filename(File->getName());
+  SmallString<128> PublicFilename(File->getDir()->getName());
+  if (Filename == "module_private.map")
+llvm::sys::path::append(PublicFilename, "module.map");
+  else if (Filename == "module.private.modulemap")
+llvm::sys::path::append(PublicFilename, "module.modulemap");
+  else
+return nullptr;
+  return FileMgr.getFile(PublicFilename);
+}
+
 /// \brief Compile a module file for the given module, using the options 
 /// provided by the importing compiler instance. Returns true if the module
 /// was built without errors.
@@ -1204,6 +1217,13 @@ static bool compileModuleImpl(CompilerIn
   bool Result;
   if (const FileEntry *ModuleMapFile =
   ModMap.getContainingModuleMapFile(Module)) {
+// Canonicalize compilation to start with the public module map. This is
+// vital for submodules declarations in the private module maps to be
+// correctly parsed when depending on a top level module in the public one.
+if (const FileEntry *PublicMMFile = getPublicModuleMap(
+ModuleMapFile, ImportingInstance.getFileManager()))
+  ModuleMapFile = PublicMMFile;
+
 // Use the module map where this module resides.
 Result = compileModuleImpl(
 ImportingInstance, ImportLoc, Module->getTopLevelModuleName(),

Added: 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h?rev=331322=auto
==
--- 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/A.h 
Tue May  1 19:25:03 2018
@@ -0,0 +1 @@
+// A.h

Added: 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/SomeSub.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Headers/SomeSub.h?rev=331322=auto
==
(empty)

Added: 
cfe/trunk/test/Modules/Inputs/submodule-in-private-mmap/A.framework/Modules/module.modulemap
URL: 

r331233 - [Modules] Fix testcases from r331232

2018-04-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Apr 30 15:57:02 2018
New Revision: 331233

URL: http://llvm.org/viewvc/llvm-project?rev=331233=rev
Log:
[Modules] Fix testcases from r331232

Modified:

cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/non-ambiguous-enum.m

Modified: 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap?rev=331233=331232=331233=diff
==
--- 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
 (original)
+++ 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
 Mon Apr 30 15:57:02 2018
@@ -1,6 +1,5 @@
 
 framework module A {
   header "a.h"
-  //module * { export * }
   export *
 }

Modified: cfe/trunk/test/Modules/non-ambiguous-enum.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/non-ambiguous-enum.m?rev=331233=331232=331233=diff
==
--- cfe/trunk/test/Modules/non-ambiguous-enum.m (original)
+++ cfe/trunk/test/Modules/non-ambiguous-enum.m Mon Apr 30 15:57:02 2018
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fimplicit-module-maps -fmodules-cache-path=%t 
-F%S/Inputs/non-ambiguous-enum -fsyntax-only %s -verify
-#import 
-#import 
+#import 
+#import 
 
 // expected-no-diagnostics
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r331232 - [Modules] Handle ObjC/C ODR-like semantics for EnumConstantDecl

2018-04-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Apr 30 15:14:29 2018
New Revision: 331232

URL: http://llvm.org/viewvc/llvm-project?rev=331232=rev
Log:
[Modules] Handle ObjC/C ODR-like semantics for EnumConstantDecl

Support for ObjC/C ODR-like semantics with structural equivalence
checking was added back in r306918. There enums are handled and also
checked for structural equivalence. However, at use time of
EnumConstantDecl, support was missing for preventing ambiguous
name lookup.

Add the missing bits for properly merging EnumConstantDecl.

rdar://problem/38374569

Added:
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/

cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/B.framework/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/B.framework/Headers/
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/B.framework/Headers/b.h
cfe/trunk/test/Modules/non-ambiguous-enum.m
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=331232=331231=331232=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Mon Apr 30 15:14:29 2018
@@ -2547,6 +2547,20 @@ void ASTDeclReader::mergeRedeclarable(Re
   }
 }
 
+/// ODR-like semantics for C/ObjC allow us to merge tag types and a structural
+/// check in Sema guarantees the types can be merged (see C11 6.2.7/1 or C89
+/// 6.1.2.6/1). Although most merging is done in Sema, we need to guarantee
+/// that some types are mergeable during deserialization, otherwise name
+/// lookup fails. This is the case for EnumConstantDecl.
+bool allowODRLikeMergeInC(NamedDecl *ND) {
+  if (!ND)
+return false;
+  // TODO: implement merge for other necessary decls.
+  if (dyn_cast(ND))
+return true;
+  return false;
+}
+
 /// \brief Attempts to merge the given declaration (D) with another declaration
 /// of the same entity, for the case where the entity is not actually
 /// redeclarable. This happens, for instance, when merging the fields of
@@ -2557,10 +2571,12 @@ void ASTDeclReader::mergeMergeable(Merge
   if (!Reader.getContext().getLangOpts().Modules)
 return;
 
-  // ODR-based merging is only performed in C++. In C, identically-named things
-  // in different translation units are not redeclarations (but may still have
-  // compatible types).
-  if (!Reader.getContext().getLangOpts().CPlusPlus)
+  // ODR-based merging is performed in C++ and in some cases (tag types) in C.
+  // Note that C identically-named things in different translation units are
+  // not redeclarations, but may still have compatible types, where ODR-like
+  // semantics may apply.
+  if (!Reader.getContext().getLangOpts().CPlusPlus &&
+  !allowODRLikeMergeInC(dyn_cast(static_cast(D
 return;
 
   if (FindExistingResult ExistingRes = findExisting(static_cast(D)))

Added: cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h?rev=331232=auto
==
--- cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a.h 
Mon Apr 30 15:14:29 2018
@@ -0,0 +1 @@
+#include 

Added: cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h?rev=331232=auto
==
--- cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Headers/a0.h 
Mon Apr 30 15:14:29 2018
@@ -0,0 +1 @@
+#include 

Added: 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap?rev=331232=auto
==
--- 
cfe/trunk/test/Modules/Inputs/non-ambiguous-enum/A.framework/Modules/module.modulemap
 (added)
+++ 

r331063 - [Modules][ObjC] ASTReader should add protocols for class extensions

2018-04-27 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Apr 27 11:01:23 2018
New Revision: 331063

URL: http://llvm.org/viewvc/llvm-project?rev=331063=rev
Log:
[Modules][ObjC] ASTReader should add protocols for class extensions

During deserialization clang is currently missing the merging of
protocols into the canonical interface for the class extension.

This merging only currently happens during parsing and should also
be considered during deserialization.

rdar://problem/38724303

Added:
cfe/trunk/test/Modules/Inputs/class-extension/
cfe/trunk/test/Modules/Inputs/class-extension/a-private.h
cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h
cfe/trunk/test/Modules/Inputs/class-extension/a.h
cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap
cfe/trunk/test/Modules/class-extension-protocol.m
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=331063=331062=331063=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Fri Apr 27 11:01:23 2018
@@ -1205,6 +1205,12 @@ void ASTDeclReader::VisitObjCCategoryDec
 ProtoLocs.push_back(ReadSourceLocation());
   CD->setProtocolList(ProtoRefs.data(), NumProtoRefs, ProtoLocs.data(),
   Reader.getContext());
+
+  // Protocols in the class extension belong to the class.
+  if (NumProtoRefs > 0 && CD->ClassInterface && CD->IsClassExtension())
+CD->ClassInterface->mergeClassExtensionProtocolList(
+(ObjCProtocolDecl *const *)ProtoRefs.data(), NumProtoRefs,
+Reader.getContext());
 }
 
 void ASTDeclReader::VisitObjCCompatibleAliasDecl(ObjCCompatibleAliasDecl *CAD) 
{

Added: cfe/trunk/test/Modules/Inputs/class-extension/a-private.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/a-private.h?rev=331063=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/a-private.h (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/a-private.h Fri Apr 27 
11:01:23 2018
@@ -0,0 +1,5 @@
+#import "a.h"
+#import "a-proto.h"
+
+@interface A () 
+@end

Added: cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h?rev=331063=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/a-proto.h Fri Apr 27 11:01:23 
2018
@@ -0,0 +1,7 @@
+@protocol NSObject
+@end
+
+@protocol AProto 
+@property (nonatomic, readwrite, assign) int p0;
+@property (nonatomic, readwrite, assign) int p1;
+@end

Added: cfe/trunk/test/Modules/Inputs/class-extension/a.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/a.h?rev=331063=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/a.h (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/a.h Fri Apr 27 11:01:23 2018
@@ -0,0 +1,5 @@
+@interface NSObject
+@end
+
+@interface A : NSObject
+@end

Added: cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap?rev=331063=auto
==
--- cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/class-extension/module.modulemap Fri Apr 27 
11:01:23 2018
@@ -0,0 +1,11 @@
+
+module A {
+  header "a.h"
+  header "a-proto.h"
+  export *
+}
+
+module AP {
+  header "a-private.h"
+  export *
+}

Added: cfe/trunk/test/Modules/class-extension-protocol.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/class-extension-protocol.m?rev=331063=auto
==
--- cfe/trunk/test/Modules/class-extension-protocol.m (added)
+++ cfe/trunk/test/Modules/class-extension-protocol.m Fri Apr 27 11:01:23 2018
@@ -0,0 +1,9 @@
+// RUN: rm -rf %t.cache
+// RUN: %clang_cc1 %s -fsyntax-only -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t.cache -I%S/Inputs/class-extension -verify
+// expected-no-diagnostics
+
+#import "a-private.h"
+
+int foo(A *X) {
+  return X.p0 + X.p1;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330240 - [Modules] Turn on system header validation for implicit modules

2018-04-18 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Apr 17 23:07:49 2018
New Revision: 330240

URL: http://llvm.org/viewvc/llvm-project?rev=330240=rev
Log:
[Modules] Turn on system header validation for implicit modules

After r300027 implicit builds might fail when updating the SDK on
darwin. Make validation of system headers default when implicit modules
is on and allow modules to be rebuild when system headers change.

rdar://problem/19767523

Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/modules.m

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=330240=330239=330240=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue Apr 17 23:07:49 2018
@@ -1217,6 +1217,8 @@ def fmodules_disable_diagnostic_validati
 def fmodules_validate_system_headers : Flag<["-"], 
"fmodules-validate-system-headers">,
   Group, Flags<[CC1Option]>,
   HelpText<"Validate the system headers that a module depends on when loading 
the module">;
+def fno_modules_validate_system_headers : Flag<["-"], 
"fno-modules-validate-system-headers">,
+  Group, Flags<[DriverOption]>;
 def fmodules : Flag <["-"], "fmodules">, Group,
   Flags<[DriverOption, CC1Option]>,
   HelpText<"Enable the 'modules' language feature">;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=330240=330239=330240=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Apr 17 23:07:49 2018
@@ -2546,11 +2546,13 @@ static void RenderModulesOptions(Compila
 CmdArgs.push_back("-fmodules-strict-decluse");
 
   // -fno-implicit-modules turns off implicitly compiling modules on demand.
+  bool ImplicitModules = false;
   if (!Args.hasFlag(options::OPT_fimplicit_modules,
 options::OPT_fno_implicit_modules, HaveClangModules)) {
 if (HaveModules)
   CmdArgs.push_back("-fno-implicit-modules");
   } else if (HaveModules) {
+ImplicitModules = true;
 // -fmodule-cache-path specifies where our implicitly-built module files
 // should be written.
 SmallString<128> Path;
@@ -2657,7 +2659,11 @@ static void RenderModulesOptions(Compila
 options::OPT_fmodules_validate_once_per_build_session);
   }
 
-  Args.AddLastArg(CmdArgs, options::OPT_fmodules_validate_system_headers);
+  if (Args.hasFlag(options::OPT_fmodules_validate_system_headers,
+   options::OPT_fno_modules_validate_system_headers,
+   ImplicitModules))
+CmdArgs.push_back("-fmodules-validate-system-headers");
+
   Args.AddLastArg(CmdArgs, 
options::OPT_fmodules_disable_diagnostic_validation);
 }
 

Modified: cfe/trunk/test/Driver/modules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/modules.m?rev=330240=330239=330240=diff
==
--- cfe/trunk/test/Driver/modules.m (original)
+++ cfe/trunk/test/Driver/modules.m Tue Apr 17 23:07:49 2018
@@ -30,9 +30,15 @@
 // RUN: %clang -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT %s
 // MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT-NOT: 
-fmodules-validate-system-headers
 
+// RUN: %clang -fmodules -fsyntax-only -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD %s
+// MODULES_VALIDATE_SYSTEM_HEADERS_DEFAULT_MOD: 
-fmodules-validate-system-headers
+
 // RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
+// RUN: %clang -fno-modules-validate-system-headers -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID %s
+// MODULES_VALIDATE_SYSTEM_HEADERS_NOSYSVALID-NOT: 
-fmodules-validate-system-headers
+
 // RUN: %clang -### %s 2>&1 | FileCheck 
-check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
 // MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: 
-fmodules-disable-diagnostic-validation
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r330152 - Use export_as for autolinking frameworks

2018-04-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Apr 16 12:42:32 2018
New Revision: 330152

URL: http://llvm.org/viewvc/llvm-project?rev=330152=rev
Log:
Use export_as for autolinking frameworks

framework module SomeKitCore {
  ...
  export_as SomeKit
}

Given the module above, while generting autolink information during
codegen, clang should to emit '-framework SomeKitCore' only if SomeKit
was not imported in the relevant TU, otherwise it should use '-framework
SomeKit' instead.

rdar://problem/38269782

Added:
cfe/trunk/test/Modules/Inputs/exportas-link/
cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/
cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Headers/

cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Headers/OtherKit.h
cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Modules/

cfe/trunk/test/Modules/Inputs/exportas-link/OtherKit.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Headers/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Headers/SKWidget.h

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Headers/SomeKit.h
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Modules/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKit.framework/SomeKit.tbd
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Headers/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Headers/SKWidget.h

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Headers/SomeKitCore.h
cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Modules/

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/exportas-link/SomeKitCore.framework/SomeKitCore.tbd
cfe/trunk/test/Modules/use-exportas-for-link.m
Modified:
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=330152=330151=330152=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Mon Apr 16 12:42:32 2018
@@ -331,6 +331,10 @@ public:
   /// an entity from this module is used.
   llvm::SmallVector LinkLibraries;
 
+  /// Autolinking uses the framework name for linking purposes
+  /// when this is false and the export_as name otherwise.
+  bool UseExportAsModuleLinkName = false;
+
   /// \brief The set of "configuration macros", which are macros that
   /// (intentionally) change how this module is built.
   std::vector ConfigMacros;

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=330152=330151=330152=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Mon Apr 16 12:42:32 2018
@@ -21,6 +21,7 @@
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/PointerIntPair.h"
+#include "llvm/ADT/StringSet.h"
 #include "llvm/ADT/SmallPtrSet.h"
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringMap.h"
@@ -104,7 +105,19 @@ class ModuleMap {
   /// \brief The number of modules we have created in total.
   unsigned NumCreatedModules = 0;
 
+  /// In case a module has a export_as entry, it might have a pending link
+  /// name to be determined if that module is imported.
+  llvm::StringMap> PendingLinkAsModule;
+
 public:
+  /// Use PendingLinkAsModule information to mark top level link names that
+  /// are going to be replaced by export_as aliases.
+  void resolveLinkAsDependencies(Module *Mod);
+
+  /// Make module to use export_as as the link dependency name if enough
+  /// information is available or add it to a pending list otherwise.
+  void addLinkAsDependency(Module *Mod);
+
   /// \brief Flags describing the role of a module header.
   enum ModuleHeaderRole {
 /// \brief This header is normally included in the module.

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=330152=330151=330152=diff
==
--- 

Re: [PATCH] D45165: Use llvm::sys::fs::real_path() in clang.

2018-04-10 Thread Bruno Cardoso Lopes via cfe-commits
Thanks Nico!

On Tue, Apr 10, 2018 at 6:39 AM, Nico Weber via Phabricator
 wrote:
> thakis added a comment.
>
> r329698, thanks!
>
>
> https://reviews.llvm.org/D45165
>
>
>



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r328857 - [Modules] Improve fixit for framework private module maps

2018-03-29 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Mar 29 22:17:58 2018
New Revision: 328857

URL: http://llvm.org/viewvc/llvm-project?rev=328857=rev
Log:
[Modules] Improve fixit for framework private module maps

The wrong source range was being provided in some case, fix that to get
a better fixit.

rdar://problem/38520199

Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/implicit-private-with-submodule.m

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=328857=328856=328857=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Mar 29 22:17:58 2018
@@ -1630,14 +1630,15 @@ namespace {
 /// in other ways (FooPrivate and Foo.Private), providing notes and fixits.
 static void diagnosePrivateModules(const ModuleMap ,
DiagnosticsEngine ,
-   const Module *ActiveModule) {
+   const Module *ActiveModule,
+   SourceLocation InlineParent) {
 
   auto GenNoteAndFixIt = [&](StringRef BadName, StringRef Canonical,
- const Module *M) {
+ const Module *M, SourceRange ReplLoc) {
 auto D = Diags.Report(ActiveModule->DefinitionLoc,
   diag::note_mmap_rename_top_level_private_module);
 D << BadName << M->Name;
-D << FixItHint::CreateReplacement(ActiveModule->DefinitionLoc, Canonical);
+D << FixItHint::CreateReplacement(ReplLoc, Canonical);
   };
 
   for (auto E = Map.module_begin(); E != Map.module_end(); ++E) {
@@ -1657,7 +1658,8 @@ static void diagnosePrivateModules(const
   Diags.Report(ActiveModule->DefinitionLoc,
diag::warn_mmap_mismatched_private_submodule)
   << FullName;
-  GenNoteAndFixIt(FullName, Canonical, M);
+  GenNoteAndFixIt(FullName, Canonical, M,
+  SourceRange(InlineParent, ActiveModule->DefinitionLoc));
   continue;
 }
 
@@ -1667,7 +1669,8 @@ static void diagnosePrivateModules(const
   Diags.Report(ActiveModule->DefinitionLoc,
diag::warn_mmap_mismatched_private_module_name)
   << ActiveModule->Name;
-  GenNoteAndFixIt(ActiveModule->Name, Canonical, M);
+  GenNoteAndFixIt(ActiveModule->Name, Canonical, M,
+  SourceRange(ActiveModule->DefinitionLoc));
 }
   }
 }
@@ -1753,6 +1756,7 @@ void ModuleMapParser::parseModuleDecl()
   }
   
   Module *PreviousActiveModule = ActiveModule;  
+  SourceLocation LastInlineParentLoc = SourceLocation();
   if (Id.size() > 1) {
 // This module map defines a submodule. Go find the module of which it
 // is a submodule.
@@ -1763,6 +1767,7 @@ void ModuleMapParser::parseModuleDecl()
 if (I == 0)
   TopLevelModule = Next;
 ActiveModule = Next;
+LastInlineParentLoc = Id[I].second;
 continue;
   }
   
@@ -1882,7 +1887,7 @@ void ModuleMapParser::parseModuleDecl()
StartLoc) &&
   (MapFileName.endswith("module.private.modulemap") ||
MapFileName.endswith("module_private.map")))
-diagnosePrivateModules(Map, Diags, ActiveModule);
+diagnosePrivateModules(Map, Diags, ActiveModule, LastInlineParentLoc);
 
   bool Done = false;
   do {

Modified: cfe/trunk/test/Modules/implicit-private-with-submodule.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/implicit-private-with-submodule.m?rev=328857=328856=328857=diff
==
--- cfe/trunk/test/Modules/implicit-private-with-submodule.m (original)
+++ cfe/trunk/test/Modules/implicit-private-with-submodule.m Thu Mar 29 
22:17:58 2018
@@ -13,7 +13,7 @@
 
 // 
expected-warning@Inputs/implicit-private-with-submodule/A.framework/Modules/module.private.modulemap:1{{private
 submodule 'A.Private' in private module map, expected top-level module}}
 // 
expected-note@Inputs/implicit-private-with-submodule/A.framework/Modules/module.private.modulemap:1{{rename
 'A.Private' to ensure it can be found by name}}
-// CHECK: fix-it:"{{.*}}module.private.modulemap":{1:20-1:27}:"A_Private"
+// CHECK: fix-it:"{{.*}}module.private.modulemap":{1:18-1:27}:"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


r328053 - [Modules] Honor -fmodule-name when handling private framework modules

2018-03-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 20 15:36:39 2018
New Revision: 328053

URL: http://llvm.org/viewvc/llvm-project?rev=328053=rev
Log:
[Modules] Honor -fmodule-name when handling private framework modules

When skipping building the module for a private framework module,
LangOpts.CurrentModule isn't enough for implict modules builds; for
instance, in case a private module is built while building a public one,
LangOpts.CurrentModule doesn't reflect the -fmodule-name being passed
down, but instead the module name which triggered the build.

Store the actual -fmodule-name in LangOpts.ModuleName and actually
check a name was provided during compiler invocation in order to
skip building the private module.

rdar://problem/38434694

Added:
cfe/trunk/test/Modules/Inputs/bad-private-include/
cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/
cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/Headers/

cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/Headers/Bad.h
cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/Modules/

cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/Modules/module.private.modulemap

cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/PrivateHeaders/BadPrivate.h

cfe/trunk/test/Modules/Inputs/bad-private-include/Bad.framework/PrivateHeaders/Shared.h
cfe/trunk/test/Modules/bad-private-include.m
Modified:
cfe/trunk/include/clang/Basic/LangOptions.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=328053=328052=328053=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.h (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.h Tue Mar 20 15:36:39 2018
@@ -141,10 +141,14 @@ public:
   /// If none is specified, abort (GCC-compatible behaviour).
   std::string OverflowHandler;
 
+  /// The module currently being compiled as speficied by -fmodule-name.
+  std::string ModuleName;
+
   /// \brief The name of the current module, of which the main source file
   /// is a part. If CompilingModule is set, we are compiling the interface
   /// of this module, otherwise we are compiling an implementation file of
-  /// it.
+  /// it. This starts as ModuleName in case -fmodule-name is provided and
+  /// changes during compilation to reflect the current module.
   std::string CurrentModule;
 
   /// \brief The names of any features to enable in module 'requires' decls

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=328053=328052=328053=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Tue Mar 20 15:36:39 2018
@@ -1090,6 +1090,10 @@ compileModuleImpl(CompilerInstance 
   }),
   PPOpts.Macros.end());
 
+  // If the original compiler invocation had -fmodule-name, pass it through.
+  Invocation->getLangOpts()->ModuleName =
+  ImportingInstance.getInvocation().getLangOpts()->ModuleName;
+
   // Note the name of the module we're building.
   Invocation->getLangOpts()->CurrentModule = ModuleName;
 

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=328053=328052=328053=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Mar 20 15:36:39 2018
@@ -2372,7 +2372,8 @@ static void ParseLangArgs(LangOptions 
   Opts.DebuggerCastResultToId = Args.hasArg(OPT_fdebugger_cast_result_to_id);
   Opts.DebuggerObjCLiteral = Args.hasArg(OPT_fdebugger_objc_literal);
   Opts.ApplePragmaPack = Args.hasArg(OPT_fapple_pragma_pack);
-  Opts.CurrentModule = Args.getLastArgValue(OPT_fmodule_name_EQ);
+  Opts.ModuleName = Args.getLastArgValue(OPT_fmodule_name_EQ);
+  Opts.CurrentModule = Opts.ModuleName;
   Opts.AppExt = Args.hasArg(OPT_fapplication_extension);
   Opts.ModuleFeatures = Args.getAllArgValues(OPT_fmodule_feature);
   std::sort(Opts.ModuleFeatures.begin(), Opts.ModuleFeatures.end());

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=328053=328052=328053=diff
==
--- 

r325305 - [Modules] Extend -fmodule-name semantic for frameworks with private modules

2018-02-15 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Feb 15 16:12:57 2018
New Revision: 325305

URL: http://llvm.org/viewvc/llvm-project?rev=325305=rev
Log:
[Modules] Extend -fmodule-name semantic for frameworks with private modules

Assume Foo.framework with two module maps and two modules Foo and
Foo_Private.

Framework authors need to skip building both Foo and Foo_Private when
using -fmodule-name=Foo, since both are part of the framework and used
interchangeably during compilation.

rdar://problem/37500098

Added:
cfe/trunk/test/Modules/module-name-private.m
Modified:
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/lib/Lex/PPDirectives.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPDirectives.cpp?rev=325305=325304=325305=diff
==
--- cfe/trunk/lib/Lex/PPDirectives.cpp (original)
+++ cfe/trunk/lib/Lex/PPDirectives.cpp Thu Feb 15 16:12:57 2018
@@ -115,6 +115,24 @@ static bool isReservedId(StringRef Text,
   return false;
 }
 
+// The -fmodule-name option (represented here by \p CurrentModule) tells the
+// compiler to textually include headers in the specified module, meaning clang
+// won't build the specified module. This is useful in a number of situations,
+// for instance, when building a library that vends a module map, one might 
want
+// to avoid hitting intermediate build products containig the the module map or
+// avoid finding the system installed modulemap for that library.
+static bool isForModuleBuilding(Module *M, StringRef CurrentModule) {
+  StringRef TopLevelName = M->getTopLevelModuleName();
+
+  // When building framework Foo, we wanna make sure that Foo *and* Foo_Private
+  // are textually included and no modules are built for both.
+  if (M->getTopLevelModule()->IsFramework &&
+  !CurrentModule.endswith("_Private") && TopLevelName.endswith("_Private"))
+TopLevelName = TopLevelName.drop_back(8);
+
+  return TopLevelName == CurrentModule;
+}
+
 static MacroDiag shouldWarnOnMacroDef(Preprocessor , IdentifierInfo *II) {
   const LangOptions  = PP.getLangOpts();
   StringRef Text = II->getName();
@@ -1856,8 +1874,8 @@ void Preprocessor::HandleIncludeDirectiv
   // there is one. Don't do so if precompiled module support is disabled or we
   // are processing this module textually (because we're building the module).
   if (ShouldEnter && File && SuggestedModule && getLangOpts().Modules &&
-  SuggestedModule.getModule()->getTopLevelModuleName() !=
-  getLangOpts().CurrentModule) {
+  !isForModuleBuilding(SuggestedModule.getModule(),
+   getLangOpts().CurrentModule)) {
 // If this include corresponds to a module but that module is
 // unavailable, diagnose the situation and bail out.
 // FIXME: Remove this; loadModule does the same check (but produces
@@ -2004,7 +2022,7 @@ void Preprocessor::HandleIncludeDirectiv
   // ShouldEnter is false because we are skipping the header. In that
   // case, We are not importing the specified module.
   if (SkipHeader && getLangOpts().CompilingPCH &&
-  M->getTopLevelModuleName() == getLangOpts().CurrentModule)
+  isForModuleBuilding(M, getLangOpts().CurrentModule))
 return;
 
   makeModuleVisible(M, HashLoc);
@@ -2045,7 +2063,7 @@ void Preprocessor::HandleIncludeDirectiv
 // include headers in the specified module. We are not building the
 // specified module.
 if (getLangOpts().CompilingPCH &&
-M->getTopLevelModuleName() == getLangOpts().CurrentModule)
+isForModuleBuilding(M, getLangOpts().CurrentModule))
   return;
 
 assert(!CurLexerSubmodule && "should not have marked this as a module 
yet");

Added: cfe/trunk/test/Modules/module-name-private.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-name-private.m?rev=325305=auto
==
--- cfe/trunk/test/Modules/module-name-private.m (added)
+++ cfe/trunk/test/Modules/module-name-private.m Thu Feb 15 16:12:57 2018
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -verify -fmodules -fimplicit-module-maps 
-fmodules-cache-path=%t -F %S/Inputs/implicit-private-canonical -fsyntax-only 
%s -Wprivate-module -fmodule-name=A -Rmodule-build
+
+// Because of -fmodule-name=A, no module (A or A_Private) is supposed to be
+// built and -Rmodule-build should not produce any output.
+
+// expected-no-diagnostics
+
+#import 
+#import 
+
+int foo() { return APRIVATE; }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r325154 - [Modules] Add more language features to be used with requires-declaration

2018-02-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Feb 14 11:01:03 2018
New Revision: 325154

URL: http://llvm.org/viewvc/llvm-project?rev=325154=rev
Log:
[Modules] Add more language features to be used with requires-declaration

Features added: c99, c11, c17, cplusplus14 and cplusplus17.

rdar://problem/36328787
rdar://problem/36668431

Modified:
cfe/trunk/docs/Modules.rst
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
cfe/trunk/test/Modules/requires.m

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=325154=325153=325154=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Wed Feb 14 11:01:03 2018
@@ -430,6 +430,21 @@ cplusplus
 cplusplus11
   C++11 support is available.
 
+cplusplus14
+  C++14 support is available.
+
+cplusplus17
+  C++17 support is available.
+
+c99
+  C99 support is available.
+
+c11
+  C11 support is available.
+
+c17
+  C17 support is available.
+
 freestanding
   A freestanding environment is available.
 

Modified: cfe/trunk/lib/Basic/Module.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Module.cpp?rev=325154=325153=325154=diff
==
--- cfe/trunk/lib/Basic/Module.cpp (original)
+++ cfe/trunk/lib/Basic/Module.cpp Wed Feb 14 11:01:03 2018
@@ -78,6 +78,11 @@ static bool hasFeature(StringRef Feature
 .Case("coroutines", LangOpts.CoroutinesTS)
 .Case("cplusplus", LangOpts.CPlusPlus)
 .Case("cplusplus11", LangOpts.CPlusPlus11)
+.Case("cplusplus14", LangOpts.CPlusPlus14)
+.Case("cplusplus17", LangOpts.CPlusPlus17)
+.Case("c99", LangOpts.C99)
+.Case("c11", LangOpts.C11)
+.Case("c17", LangOpts.C17)
 .Case("freestanding", LangOpts.Freestanding)
 .Case("gnuinlineasm", LangOpts.GNUAsm)
 .Case("objc", LangOpts.ObjC1)

Modified: cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map?rev=325154=325153=325154=diff
==
--- cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map 
(original)
+++ cfe/trunk/test/Modules/Inputs/DependsOnModule.framework/module.map Wed Feb 
14 11:01:03 2018
@@ -37,4 +37,22 @@ framework module DependsOnModule {
   export *
 }
   }
+  explicit module CXX11 {
+requires cplusplus11
+  }
+  explicit module CXX14 {
+requires cplusplus14
+  }
+  explicit module CXX17 {
+requires cplusplus17
+  }
+  explicit module C99 {
+requires c99
+  }
+  explicit module C11 {
+requires c11
+  }
+  explicit module C17 {
+requires c17
+  }
 }

Modified: cfe/trunk/test/Modules/requires.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/requires.m?rev=325154=325153=325154=diff
==
--- cfe/trunk/test/Modules/requires.m (original)
+++ cfe/trunk/test/Modules/requires.m Wed Feb 14 11:01:03 2018
@@ -1,6 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t 
-fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify 
-fmodule-feature custom_req1
-
+// RUN: %clang_cc1 -Wauto-import -Wno-private-module -fmodules-cache-path=%t 
-fmodules -fimplicit-module-maps -F %S/Inputs -I %S/Inputs %s -verify -std=c89 
-DTEST_C_FEATURES
+#ifndef TEST_C_FEATURES
 // expected-error@DependsOnModule.framework/module.map:7 {{module 
'DependsOnModule.CXX' requires feature 'cplusplus'}}
 @import DependsOnModule.CXX; // expected-note {{module imported here}}
 @import DependsOnModule.NotCXX;
@@ -15,3 +16,17 @@
 @import RequiresWithMissingHeader.HeaderBefore; // expected-note {{module 
imported here}}
 // expected-er...@module.map:* {{module 
'RequiresWithMissingHeader.HeaderAfter' requires feature 'missing'}}
 @import RequiresWithMissingHeader.HeaderAfter; // expected-note {{module 
imported here}}
+// expected-error@DependsOnModule.framework/module.map:40 {{module 
'DependsOnModule.CXX11' requires feature 'cplusplus11'}}
+@import DependsOnModule.CXX11; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:43 {{module 
'DependsOnModule.CXX14' requires feature 'cplusplus14'}}
+@import DependsOnModule.CXX14; // expected-note {{module imported here}}
+// expected-error@DependsOnModule.framework/module.map:46 {{module 
'DependsOnModule.CXX17' requires feature 'cplusplus17'}}
+@import DependsOnModule.CXX17; // expected-note {{module imported here}}

r324965 - [Modules] Fix remapping from Foo.Private to Foo_Private to happen before typo correction

2018-02-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Feb 12 15:43:21 2018
New Revision: 324965

URL: http://llvm.org/viewvc/llvm-project?rev=324965=rev
Log:
[Modules] Fix remapping from Foo.Private to Foo_Private to happen before typo 
correction

Typo correction is the last step here, remapping should come first.

rdar://problem/37351970

Modified:
cfe/trunk/lib/Frontend/CompilerInstance.cpp

cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Modules/module.modulemap

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=324965=324964=324965=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Feb 12 15:43:21 2018
@@ -1859,6 +1859,39 @@ CompilerInstance::loadModule(SourceLocat
 for (unsigned I = 1, N = Path.size(); I != N; ++I) {
   StringRef Name = Path[I].first->getName();
   clang::Module *Sub = Module->findSubmodule(Name);
+
+  // If the user is requesting Foo.Private and it doesn't exist, try to
+  // match Foo_Private and emit a warning asking for the user to write
+  // @import Foo_Private instead. FIXME: remove this when existing clients
+  // migrate off of Foo.Private syntax.
+  if (!Sub && PP->getLangOpts().ImplicitModules && Name == "Private" &&
+  Module == Module->getTopLevelModule()) {
+SmallString<128> PrivateModule(Module->Name);
+PrivateModule.append("_Private");
+
+SmallVector PrivPath;
+auto  = PP->getIdentifierTable().get(
+PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
+PrivPath.push_back(std::make_pair(, Path[0].second));
+
+if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
+  Sub =
+  loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
+if (Sub) {
+  MapPrivateSubModToTopLevel = true;
+  if (!getDiagnostics().isIgnored(
+  diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
+getDiagnostics().Report(Path[I].second,
+diag::warn_no_priv_submodule_use_toplevel)
+<< Path[I].first << Module->getFullModuleName() << 
PrivateModule
+<< SourceRange(Path[0].second, Path[I].second)
+<< FixItHint::CreateReplacement(SourceRange(Path[0].second),
+PrivateModule);
+getDiagnostics().Report(Sub->DefinitionLoc,
+diag::note_private_top_level_defined);
+  }
+}
+  }
   
   if (!Sub) {
 // Attempt to perform typo correction to find a module name that works.
@@ -1894,39 +1927,6 @@ CompilerInstance::loadModule(SourceLocat
 }
   }
 
-  // If the user is requesting Foo.Private and it doesn't exist, try to
-  // match Foo_Private and emit a warning asking for the user to write
-  // @import Foo_Private instead. FIXME: remove this when existing clients
-  // migrate off of Foo.Private syntax.
-  if (!Sub && PP->getLangOpts().ImplicitModules && Name == "Private" &&
-  Module == Module->getTopLevelModule()) {
-SmallString<128> PrivateModule(Module->Name);
-PrivateModule.append("_Private");
-
-SmallVector PrivPath;
-auto  = PP->getIdentifierTable().get(
-PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
-PrivPath.push_back(std::make_pair(, Path[0].second));
-
-if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
-  Sub =
-  loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
-if (Sub) {
-  MapPrivateSubModToTopLevel = true;
-  if (!getDiagnostics().isIgnored(
-  diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
-getDiagnostics().Report(Path[I].second,
-diag::warn_no_priv_submodule_use_toplevel)
-<< Path[I].first << Module->getFullModuleName() << 
PrivateModule
-<< SourceRange(Path[0].second, Path[I].second)
-<< FixItHint::CreateReplacement(SourceRange(Path[0].second),
-PrivateModule);
-getDiagnostics().Report(Sub->DefinitionLoc,
-diag::note_private_top_level_defined);
-  }
-}
-  }
-
   if (!Sub) {
 // No submodule by this name. Complain, and don't look for further
 // submodules.

Modified: 
cfe/trunk/test/Modules/Inputs/implicit-private-canonical/A.framework/Modules/module.modulemap
URL: 

Re: r321855 - Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-09 Thread Bruno Cardoso Lopes via cfe-commits
Hi Eric,

On Mon, Jan 8, 2018 at 9:31 PM, Eric Fiselier  wrote:
> I haven't done a ton of investigation yet, but I suspect this commit is
> responsible for breaking my LLVM module selfhost build, which uses libc++ as
> the STL, and builds LLD (No bots appear to test this configuration).
>
> The error message can be found here:
> https://gist.github.com/EricWF/fb5e1d18eb1069d23788469b5fb15442
>
> I'll investigate further tomorrow, but I wanted to send this your way in
> case it looks familiar.

Haven't seen this one before, maybe because of this particular
configuration. I'm happy to help out fixing it, I can try a similar
setup and see what I get. It would be nice if you can confirm this is
the culprit commit though.


-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r321906 - Track shadow modules with a generation counter.

2018-01-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jan  5 14:13:56 2018
New Revision: 321906

URL: http://llvm.org/viewvc/llvm-project?rev=321906=rev
Log:
Track shadow modules with a generation counter.

This is a follow up to r321855, closing the gap between our internal shadow
modules implementation and upstream. It has been tested for longer and
provides a better approach for tracking shadow modules. Mostly NFCI.

rdar://problem/23612102

Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Frontend/FrontendAction.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=321906=321905=321906=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Fri Jan  5 14:13:56 2018
@@ -726,7 +726,6 @@ private:
   LoadModuleMapResult loadModuleMapFileImpl(const FileEntry *File,
 bool IsSystem,
 const DirectoryEntry *Dir,
-bool IsExplicitlyProvided,
 FileID ID = FileID(),
 unsigned *Offset = nullptr);
 

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=321906=321905=321906=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Fri Jan  5 14:13:56 2018
@@ -198,16 +198,14 @@ private:
   /// header.
   llvm::DenseMap UmbrellaDirs;
 
-  /// \brief The set of modules provided explicitly (e.g. by 
-fmodule-map-file),
-  /// which are allowed to shadow other implicitly discovered modules.
-  llvm::DenseSet ExplicitlyProvidedModules;
+  /// \brief A generation counter that is used to test whether modules of the
+  /// same name may shadow or are illegal redefintions.
+  ///
+  /// Modules from earlier scopes may shadow modules from later ones.
+  /// Modules from the same scope may not have the same name.
+  unsigned CurrentModuleScopeID = 0;
 
-  bool mayShadowModuleBeingParsed(Module *ExistingModule,
-  bool IsExplicitlyProvided) {
-assert(!ExistingModule->Parent && "expected top-level module");
-return !IsExplicitlyProvided &&
-   ExplicitlyProvidedModules.count(ExistingModule);
-  }
+  llvm::DenseMap ModuleScopeIDs;
 
   /// \brief The set of attributes that can be attached to a module.
   struct Attributes {
@@ -489,9 +487,9 @@ public:
   ///
   /// \returns The found or newly-created module, along with a boolean value
   /// that will be true if the module is newly-created.
-  std::pair
-  findOrCreateModule(StringRef Name, Module *Parent, bool IsFramework,
- bool IsExplicit, bool UsesExplicitModuleMapFile = false);
+  std::pair findOrCreateModule(StringRef Name, Module *Parent,
+   bool IsFramework,
+   bool IsExplicit);
 
   /// \brief Create a 'global module' for a C++ Modules TS module interface
   /// unit.
@@ -521,6 +519,19 @@ public:
   Module *createShadowedModule(StringRef Name, bool IsFramework,
Module *ShadowingModule);
 
+  /// \brief Creates a new declaration scope for module names, allowing
+  /// previously defined modules to shadow definitions from the new scope.
+  ///
+  /// \note Module names from earlier scopes will shadow names from the new
+  /// scope, which is the opposite of how shadowing works for variables.
+  void finishModuleDeclarationScope() { CurrentModuleScopeID += 1; }
+
+  bool mayShadowNewModule(Module *ExistingModule) {
+assert(!ExistingModule->Parent && "expected top-level module");
+assert(ModuleScopeIDs.count(ExistingModule) && "unknown module");
+return ModuleScopeIDs[ExistingModule] < CurrentModuleScopeID;
+  }
+
   /// \brief Retrieve the module map file containing the definition of the 
given
   /// module.
   ///
@@ -606,8 +617,6 @@ public:
   /// \brief Marks this header as being excluded from the given module.
   void excludeHeader(Module *Mod, Module::Header Header);
 
-  void setExplicitlyProvided(Module *Mod);
-
   /// \brief Parse the given module map file, and record any modules we 
   /// encounter.
   ///
@@ -634,7 +643,6 @@ public:
   /// \returns true if an error occurred, false otherwise.
   bool parseModuleMapFile(const FileEntry *File, bool IsSystem,
   const DirectoryEntry *HomeDir,
-  bool IsExplicitlyProvided = false,
   FileID ID = 

r321855 - Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-04 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jan  4 18:33:18 2018
New Revision: 321855

URL: http://llvm.org/viewvc/llvm-project?rev=321855=rev
Log:
Reapply r321781: [Modules] Allow modules specified by -fmodule-map-file to 
shadow implicitly found ones

When modules come from module map files explicitly specified by
-fmodule-map-file= arguments, allow those to override/shadow modules
with the same name that are found implicitly by header search. If such a
module is looked up by name (e.g. @import), we will always find the one
from -fmodule-map-file. If we try to use a shadowed module by including
one of its headers report an error.

This enables developers to force use of a specific copy of their module
to be used if there are multiple copies that would otherwise be visible,
for example if they develop modules that are installed in the default
search paths.

Patch originally by Ben Langmuir,
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html

Based on cfe-dev discussion:
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html

Differential Revision: https://reviews.llvm.org/D31269

rdar://problem/23612102

Added:
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321855=321854=321855=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Thu Jan  4 18:33:18 
2018
@@ -94,6 +94,9 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
+def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
+def err_module_build_shadowed_submodule : Error<
+  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321855=321854=321855=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Thu Jan  4 18:33:18 2018
@@ -197,6 +197,9 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
+  /// \brief A module with the same name that shadows this module.
+  Module *ShadowingModule = nullptr;
+
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -375,13 +378,20 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable, this parameter
-  /// will be set to one of the requirements that is not met for use of
-  /// this module.
+  /// \param Req If this module is unavailable because of a missing 
requirement,
+  /// this parameter will be set to one of the requirements that is not met for
+  /// use of this module.
+  ///
+  /// \param MissingHeader If this module is unavailable because of a missing
+  /// header, this parameter will be set to one of the missing headers.
+  ///
+  /// \param ShadowingModule If this module is unavailable because it is
+  /// shadowed, this parameter will be set to the shadowing module.
   bool isAvailable(const LangOptions , 
const TargetInfo ,

r321786 - Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones"

2018-01-03 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jan  3 23:31:24 2018
New Revision: 321786

URL: http://llvm.org/viewvc/llvm-project?rev=321786=rev
Log:
Revert "[Modules] Allow modules specified by -fmodule-map-file to shadow 
implicitly found ones"

This reverts r321781 until I fix the leaks pointed out by bots:

http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/12146
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-bootstrap/builds/3741

Removed:
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321786=321785=321786=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Jan  3 23:31:24 
2018
@@ -94,9 +94,6 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
-def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
-def err_module_build_shadowed_submodule : Error<
-  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321786=321785=321786=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Wed Jan  3 23:31:24 2018
@@ -197,9 +197,6 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
-  /// \brief A module with the same name that shadows this module.
-  Module *ShadowingModule = nullptr;
-
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -378,20 +375,13 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable because of a missing 
requirement,
-  /// this parameter will be set to one of the requirements that is not met for
-  /// use of this module.
-  ///
-  /// \param MissingHeader If this module is unavailable because of a missing
-  /// header, this parameter will be set to one of the missing headers.
-  ///
-  /// \param ShadowingModule If this module is unavailable because it is
-  /// shadowed, this parameter will be set to the shadowing module.
+  /// \param Req If this module is unavailable, this parameter
+  /// will be set to one of the requirements that is not met for use of
+  /// this module.
   bool isAvailable(const LangOptions , 
const TargetInfo ,
Requirement ,
-   UnresolvedHeaderDirective ,
-   Module *) const;
+   UnresolvedHeaderDirective ) const;
 
   /// \brief Determine whether this module is a submodule.
   bool isSubModule() const { return Parent != nullptr; }

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=321786=321785=321786=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Wed Jan  3 23:31:24 2018
@@ -726,7 +726,6 @@ private:
   

r321781 - [Modules] Allow modules specified by -fmodule-map-file to shadow implicitly found ones

2018-01-03 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Jan  3 18:17:40 2018
New Revision: 321781

URL: http://llvm.org/viewvc/llvm-project?rev=321781=rev
Log:
[Modules] Allow modules specified by -fmodule-map-file to shadow implicitly 
found ones

When modules come from module map files explicitly specified by
-fmodule-map-file= arguments, allow those to override/shadow modules
with the same name that are found implicitly by header search. If such a
module is looked up by name (e.g. @import), we will always find the one
from -fmodule-map-file. If we try to use a shadowed module by including
one of its headers report an error.

This enables developers to force use of a specific copy of their module
to be used if there are multiple copies that would otherwise be visible,
for example if they develop modules that are installed in the default
search paths.

Patch originally by Ben Langmuir,
http://lists.llvm.org/pipermail/cfe-commits/Week-of-Mon-20151116/143425.html

Based on cfe-dev discussion:
http://lists.llvm.org/pipermail/cfe-dev/2015-November/046164.html

Differential Revision: https://reviews.llvm.org/D31269

rdar://problem/23612102

Added:
cfe/trunk/test/Modules/Inputs/shadow/
cfe/trunk/test/Modules/Inputs/shadow/A1/
cfe/trunk/test/Modules/Inputs/shadow/A1/A.h
cfe/trunk/test/Modules/Inputs/shadow/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadow/A2/
cfe/trunk/test/Modules/Inputs/shadow/A2/A.h
cfe/trunk/test/Modules/Inputs/shadow/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A1/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/Foo.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/module.modulemap
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/A2/sys/A2.h
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/
cfe/trunk/test/Modules/Inputs/shadowed-submodule/Foo/module.modulemap
cfe/trunk/test/Modules/shadow.m
cfe/trunk/test/Modules/shadowed-submodule.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/include/clang/Basic/Module.h
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Basic/Module.cpp
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=321781=321780=321781=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Wed Jan  3 18:17:40 
2018
@@ -94,6 +94,9 @@ def remark_module_lock_failure : Remark<
   "could not acquire lock file for module '%0': %1">, InGroup;
 def remark_module_lock_timeout : Remark<
   "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
+def err_module_shadowed : Error<"import of shadowed module '%0'">, 
DefaultFatal;
+def err_module_build_shadowed_submodule : Error<
+  "build a shadowed submodule '%0'">, DefaultFatal;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/include/clang/Basic/Module.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Module.h?rev=321781=321780=321781=diff
==
--- cfe/trunk/include/clang/Basic/Module.h (original)
+++ cfe/trunk/include/clang/Basic/Module.h Wed Jan  3 18:17:40 2018
@@ -197,6 +197,9 @@ public:
   /// will be false to indicate that this (sub)module is not available.
   SmallVector Requirements;
 
+  /// \brief A module with the same name that shadows this module.
+  Module *ShadowingModule = nullptr;
+
   /// \brief Whether this module is missing a feature from \c Requirements.
   unsigned IsMissingRequirement : 1;
 
@@ -375,13 +378,20 @@ public:
   ///
   /// \param Target The target options used for the current translation unit.
   ///
-  /// \param Req If this module is unavailable, this parameter
-  /// will be set to one of the requirements that is not met for use of
-  /// this module.
+  /// \param Req If this module is unavailable because of a missing 
requirement,
+  /// this parameter will be set to one of the requirements 

r321342 - [Modules] Map missing private submodules from Foo.Private to Foo_Private

2017-12-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec 21 21:04:43 2017
New Revision: 321342

URL: http://llvm.org/viewvc/llvm-project?rev=321342=rev
Log:
[Modules] Map missing private submodules from Foo.Private to Foo_Private

In case `@import Foo.Private` fails because the submodule doesn't exist,
look for `Foo_Private` (if available) and build/load that module
instead. In that process emit a warning and tell the user about the
assumption.

The intention here is to assist all existing private modules owners
(in ObjC and Swift) to migrate to the new `Foo_Private` syntax.

rdar://problem/36023940

Added:
cfe/trunk/test/Modules/implicit-map-dot-private.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td?rev=321342=321341=321342=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticFrontendKinds.td Thu Dec 21 
21:04:43 2017
@@ -198,6 +198,11 @@ def err_missing_module : Error<
 def err_no_submodule : Error<"no submodule named %0 in module '%1'">;
 def err_no_submodule_suggest : Error<
   "no submodule named %0 in module '%1'; did you mean '%2'?">;
+def warn_no_priv_submodule_use_toplevel : Warning<
+  "no submodule named %0 in module '%1'; using top level '%2'">,
+  InGroup;
+def note_private_top_level_defined : Note<
+  "module defined here">;
 def warn_missing_submodule : Warning<"missing submodule '%0'">,
   InGroup;
 def note_module_import_here : Note<"module imported here">;

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=321342=321341=321342=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Dec 21 21:04:43 2017
@@ -1854,6 +1854,7 @@ CompilerInstance::loadModule(SourceLocat
 
   // Verify that the rest of the module path actually corresponds to
   // a submodule.
+  bool MapPrivateSubModToTopLevel = false;
   if (!getLangOpts().ModulesTS && Path.size() > 1) {
 for (unsigned I = 1, N = Path.size(); I != N; ++I) {
   StringRef Name = Path[I].first->getName();
@@ -1892,7 +1893,40 @@ CompilerInstance::loadModule(SourceLocat
   Sub = Module->findSubmodule(Best[0]);
 }
   }
-  
+
+  // If the user is requesting Foo.Private and it doesn't exist, try to
+  // match Foo_Private and emit a warning asking for the user to write
+  // @import Foo_Private instead. FIXME: remove this when existing clients
+  // migrate off of Foo.Private syntax.
+  if (!Sub && PP->getLangOpts().ImplicitModules && Name == "Private" &&
+  Module == Module->getTopLevelModule()) {
+SmallString<128> PrivateModule(Module->Name);
+PrivateModule.append("_Private");
+
+SmallVector PrivPath;
+auto  = PP->getIdentifierTable().get(
+PrivateModule, PP->getIdentifierInfo(Module->Name)->getTokenID());
+PrivPath.push_back(std::make_pair(, Path[0].second));
+
+if (PP->getHeaderSearchInfo().lookupModule(PrivateModule))
+  Sub =
+  loadModule(ImportLoc, PrivPath, Visibility, 
IsInclusionDirective);
+if (Sub) {
+  MapPrivateSubModToTopLevel = true;
+  if (!getDiagnostics().isIgnored(
+  diag::warn_no_priv_submodule_use_toplevel, ImportLoc)) {
+getDiagnostics().Report(Path[I].second,
+diag::warn_no_priv_submodule_use_toplevel)
+<< Path[I].first << Module->getFullModuleName() << 
PrivateModule
+<< SourceRange(Path[0].second, Path[I].second)
+<< FixItHint::CreateReplacement(SourceRange(Path[0].second),
+PrivateModule);
+getDiagnostics().Report(Sub->DefinitionLoc,
+diag::note_private_top_level_defined);
+  }
+}
+  }
+
   if (!Sub) {
 // No submodule by this name. Complain, and don't look for further
 // submodules.
@@ -1909,7 +1943,7 @@ CompilerInstance::loadModule(SourceLocat
   // Make the named module visible, if it's not already part of the module
   // we are parsing.
   if (ModuleName != getLangOpts().CurrentModule) {
-if (!Module->IsFromModuleFile) {
+if (!Module->IsFromModuleFile && !MapPrivateSubModToTopLevel) {
   // We have an umbrella header or directory that doesn't actually include
   // all of the headers within the directory it covers. Complain about
   // this missing submodule and recover by forgetting that we 

r318507 - Change path used in a test from r318503 to work on windows

2017-11-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Nov 16 20:26:07 2017
New Revision: 318507

URL: http://llvm.org/viewvc/llvm-project?rev=318507=rev
Log:
Change path used in a test from r318503 to work on windows

http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast/builds/13565

Modified:
cfe/trunk/test/Modules/module-imported-by-pch-path.m

Modified: cfe/trunk/test/Modules/module-imported-by-pch-path.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-imported-by-pch-path.m?rev=318507=318506=318507=diff
==
--- cfe/trunk/test/Modules/module-imported-by-pch-path.m (original)
+++ cfe/trunk/test/Modules/module-imported-by-pch-path.m Thu Nov 16 20:26:07 
2017
@@ -12,6 +12,6 @@ void test() {
   (void)MyModuleVersion; // should be found by implicit import
 }
 
-// CHECK: module 'MyModule' in AST file '{{.*MyModule.*pcm}}' (imported by AST 
file '[[PCH:.*header.pch]]') is not defined in any loaded module map file; 
maybe you need to load '[[PATH:.*folder-with-modulemap]]/module.modulemap'
+// CHECK: module 'MyModule' in AST file '{{.*MyModule.*pcm}}' (imported by AST 
file '[[PCH:.*header.pch]]') is not defined in any loaded module map file; 
maybe you need to load '[[PATH:.*folder-with-modulemap]]
 // CHECK: consider adding '[[PATH]]' to the header search path
 // CHECK: imported by '[[PCH]]'


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r318503 - [PCH+Modules] Improve diagnosticts to help out users pass an extra header search path

2017-11-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Nov 16 19:24:11 2017
New Revision: 318503

URL: http://llvm.org/viewvc/llvm-project?rev=318503=rev
Log:
[PCH+Modules] Improve diagnosticts to help out users pass an extra header 
search path

When mixing PCH and Implicit Modules, missing a header search path
can lead to the implicit built PCM to complaint about not finding its
matching module map.

Instead of adding more magic to implicit modules engine, add a note to
help the user add the appropriate path.

rdar://problem/33388847

Added:
cfe/trunk/test/Modules/module-imported-by-pch-path.m
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=318503=318502=318503=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Thu Nov 16 
19:24:11 2017
@@ -77,6 +77,8 @@ def err_imported_module_not_found : Erro
 "module '%0' in AST file '%1' (imported by AST file '%2') "
 "is not defined in any loaded module map file; "
 "maybe you need to load '%3'?">, DefaultFatal;
+def note_imported_by_pch_module_not_found : Note<
+"consider adding '%0' to the header search path">;
 def err_imported_module_modmap_changed : Error<
 "module '%0' imported by AST file '%1' found in a different module map 
file"
 " (%2) than when the importing AST file was built (%3)">, DefaultFatal;

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=318503=318502=318503=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Thu Nov 16 19:24:11 2017
@@ -3569,15 +3569,22 @@ ASTReader::ReadModuleMapFileBlock(Record
 if (!ModMap) {
   assert(ImportedBy && "top-level import should be verified");
   if ((ClientLoadCapabilities & ARR_OutOfDate) == 0) {
-if (auto *ASTFE = M ? M->getASTFile() : nullptr)
+if (auto *ASTFE = M ? M->getASTFile() : nullptr) {
   // This module was defined by an imported (explicit) module.
   Diag(diag::err_module_file_conflict) << F.ModuleName << F.FileName
<< ASTFE->getName();
-else
+} else {
   // This module was built with a different module map.
   Diag(diag::err_imported_module_not_found)
   << F.ModuleName << F.FileName << ImportedBy->FileName
   << F.ModuleMapPath;
+  // In case it was imported by a PCH, there's a chance the user is
+  // just missing to include the search path to the directory 
containing
+  // the modulemap.
+  if (ImportedBy->Kind == MK_PCH)
+Diag(diag::note_imported_by_pch_module_not_found)
+<< llvm::sys::path::parent_path(F.ModuleMapPath);
+}
   }
   return OutOfDate;
 }

Added: cfe/trunk/test/Modules/module-imported-by-pch-path.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/module-imported-by-pch-path.m?rev=318503=auto
==
--- cfe/trunk/test/Modules/module-imported-by-pch-path.m (added)
+++ cfe/trunk/test/Modules/module-imported-by-pch-path.m Thu Nov 16 19:24:11 
2017
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t.dst %t.cache
+// RUN: mkdir -p %t.dst/folder-with-modulemap %t.dst/pch-folder
+// RUN: echo '#import "folder-with-modulemap/included.h"' > %t.dst/header.h
+// RUN: echo 'extern int MyModuleVersion;' > 
%t.dst/folder-with-modulemap/MyModule.h
+// RUN: echo '@import MyModule;' > %t.dst/folder-with-modulemap/included.h
+// RUN: echo 'module MyModule { header "MyModule.h" }' > 
%t.dst/folder-with-modulemap/module.modulemap
+
+// RUN: %clang -o %t.dst/pch-folder/header.pch -x objective-c-header 
-fmodules-cache-path=%t.cache -fmodules %t.dst/header.h
+// RUN: not %clang -fsyntax-only -fmodules-cache-path=%t.cache -fmodules %s 
-include-pch %t.dst/pch-folder/header.pch 2>&1 | FileCheck %s
+
+void test() {
+  (void)MyModuleVersion; // should be found by implicit import
+}
+
+// CHECK: module 'MyModule' in AST file '{{.*MyModule.*pcm}}' (imported by AST 
file '[[PCH:.*header.pch]]') is not defined in any loaded module map file; 
maybe you need to load '[[PATH:.*folder-with-modulemap]]/module.modulemap'
+// CHECK: consider adding '[[PATH]]' to the header search path
+// CHECK: imported by '[[PCH]]'


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r316016 - [OpenCL] Restrict swizzle length check to OpenCL mode

2017-10-17 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Oct 17 10:54:57 2017
New Revision: 316016

URL: http://llvm.org/viewvc/llvm-project?rev=316016=rev
Log:
[OpenCL] Restrict swizzle length check to OpenCL mode

Changes behavior introduced in r298369 to only error out on
vector component invalid length access on OpenCL mode.

Differential Revision: https://reviews.llvm.org/D38868

rdar://problem/33568748

Added:
cfe/trunk/test/Sema/vector_swizzle_length.c
Modified:
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl

Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=316016=316015=316016=diff
==
--- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Oct 17 10:54:57 2017
@@ -384,7 +384,9 @@ CheckExtVectorComponent(Sema , QualTyp
 }
   }
 
-  if (!HalvingSwizzle) {
+  // OpenCL mode requires swizzle length to be in accordance with accepted
+  // sizes. Clang however supports arbitrary lengths for other languages.
+  if (S.getLangOpts().OpenCL && !HalvingSwizzle) {
 unsigned SwizzleLength = CompName->getLength();
 
 if (HexSwizzle)

Added: cfe/trunk/test/Sema/vector_swizzle_length.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector_swizzle_length.c?rev=316016=auto
==
--- cfe/trunk/test/Sema/vector_swizzle_length.c (added)
+++ cfe/trunk/test/Sema/vector_swizzle_length.c Tue Oct 17 10:54:57 2017
@@ -0,0 +1,10 @@
+// RUN: %clang_cc1 -x c %s -verify -pedantic -fsyntax-only
+// expected-no-diagnostics
+
+typedef float float8 __attribute__((ext_vector_type(8)));
+
+void foo() {
+float8 f2 = (float8){0, 0, 0, 0, 0, 0, 0, 0};
+(void)f2.s01234;
+(void)f2.xyzxy;
+}

Modified: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl?rev=316016=316015=316016=diff
==
--- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl (original)
+++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Tue Oct 17 10:54:57 2017
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
+// RUN: %clang_cc1 -x cl %s -verify -pedantic -fsyntax-only
 
 typedef float float8 __attribute__((ext_vector_type(8)));
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r315994 - [libc++] Fix PR34898 - vector iterator constructors and assign method perform push_back instead of emplace_back.

2017-10-17 Thread Bruno Cardoso Lopes via cfe-commits
Hi Eric,

This is also failing
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA/39697/

Can you take a look?

Thanks,

On Tue, Oct 17, 2017 at 9:07 AM, Eric Fiselier via cfe-commits
 wrote:
> These shadowing warnings should be fixed now.
>
> /Eric
>
> On Tue, Oct 17, 2017 at 10:03 AM, Maxim Kuvyrkov 
> wrote:
>>
>> Hi Eric,
>>
>> This seems to have broken ARM and AArch64 buildbots:
>>
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux/builds/850
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-arm-linux-noexceptions/builds/931
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux/builds/873
>>
>> http://lab.llvm.org:8011/builders/libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions/builds/826
>>
>> Would you please take a look?
>>
>> --
>> Maxim Kuvyrkov
>> www.linaro.org
>>
>>
>>
>>
>> > On Oct 17, 2017, at 4:03 PM, Eric Fiselier via cfe-commits
>> >  wrote:
>> >
>> > Author: ericwf
>> > Date: Tue Oct 17 06:03:17 2017
>> > New Revision: 315994
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=315994=rev
>> > Log:
>> > [libc++] Fix PR34898 - vector iterator constructors and assign method
>> > perform push_back instead of emplace_back.
>> >
>> > Summary:
>> > The constructors `vector(Iter, Iter, Alloc = Alloc{})` and `assign(Iter,
>> > Iter)` don't correctly perform EmplaceConstruction from the result of
>> > dereferencing the iterator. This results in them performing an additional
>> > and unneeded copy.
>> >
>> > This patch addresses the issue by correctly using `emplace_back` in
>> > C++11 and newer.
>> >
>> > There are also some bugs in our `insert` implementation, but those will
>> > be handled separately.
>> >
>> > @mclow.lists We should probably merge this into 5.1, agreed?
>> >
>> > Reviewers: mclow.lists, dlj, EricWF
>> >
>> > Reviewed By: mclow.lists, EricWF
>> >
>> > Subscribers: cfe-commits, mclow.lists
>> >
>> > Differential Revision: https://reviews.llvm.org/D38757
>> >
>> > Added:
>> >
>> > libcxx/trunk/test/std/containers/sequences/vector/vector.cons/assign_iter_iter.pass.cpp
>> >libcxx/trunk/test/support/emplace_constructible.h
>> > Modified:
>> >libcxx/trunk/include/deque
>> >libcxx/trunk/include/list
>> >libcxx/trunk/include/vector
>> >
>> > libcxx/trunk/test/std/containers/sequences/deque/deque.cons/assign_iter_iter.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
>> >
>> > libcxx/trunk/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp
>> >libcxx/trunk/test/support/container_test_types.h
>> >
>> > Modified: libcxx/trunk/include/deque
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/deque?rev=315994=315993=315994=diff
>> >
>> > ==
>> > --- libcxx/trunk/include/deque (original)
>> > +++ libcxx/trunk/include/deque Tue Oct 17 06:03:17 2017
>> > @@ -1356,7 +1356,6 @@ public:
>> > iterator insert(const_iterator __p, initializer_list
>> > __il)
>> > {return insert(__p, __il.begin(), __il.end());}
>> > #endif  // _LIBCPP_CXX03_LANG
>> > -
>> > iterator insert(const_iterator __p, const value_type& __v);
>> > iterator insert(const_iterator __p, size_type __n, const value_type&
>> > __v);
>> > template 
>> > @@ -2224,7 +2223,11 @@ deque<_Tp, _Allocator>::__append(_InpIte
>> >
>> > !__is_forward_iterator<_InpIter>::value>::type*)
>> > {
>> > for (; __f != __l; ++__f)
>> > +#ifdef _LIBCPP_CXX03_LANG
>> > push_back(*__f);
>> > +#else
>> > +emplace_back(*__f);
>> > +#endif
>> > }
>> >
>> > template 
>> >
>> > Modified: libcxx/trunk/include/list
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/list?rev=315994=315993=315994=diff
>> >
>> > ==
>> > --- libcxx/trunk/include/list (original)
>> > +++ libcxx/trunk/include/list Tue Oct 17 06:03:17 2017
>> > @@ -992,6 +992,15 @@ public:
>> > void push_front(const value_type& __x);
>> > void push_back(const value_type& __x);
>> >
>> > +#ifndef _LIBCPP_CXX03_LANG
>> > +template 
>> > +_LIBCPP_INLINE_VISIBILITY
>> > +void __emplace_back(_Arg&& __arg) {
>> > emplace_back(_VSTD::forward<_Arg>(__arg)); }
>> > +#else
>> > +_LIBCPP_INLINE_VISIBILITY
>> > +void __emplace_back(value_type const& __arg) { push_back(__arg); }
>> > +#endif
>> > +
>> > iterator insert(const_iterator __p, const value_type& __x);
>> > iterator insert(const_iterator 

r315829 - Mark test as unsupported until r315808 is fixed

2017-10-14 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Sat Oct 14 15:14:23 2017
New Revision: 315829

URL: http://llvm.org/viewvc/llvm-project?rev=315829=rev
Log:
Mark test as unsupported until r315808 is fixed

This is causing:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/43381

Modified:
cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl

Modified: cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl?rev=315829=315828=315829=diff
==
--- cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl (original)
+++ cfe/trunk/test/Misc/backend-resource-limit-diagnostics.cl Sat Oct 14 
15:14:23 2017
@@ -1,4 +1,5 @@
 // REQUIRES: amdgpu-registered-target
+// UNSUPPORTED: system-darwin
 // RUN: not %clang_cc1 -emit-codegen-only -triple=amdgcn-- %s 2>&1 | FileCheck 
%s
 
 // CHECK: error: local memory limit exceeded (48) in use_huge_lds


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r315627 - [lit] Raise the logic for enabling clang & lld substitutions to llvm.

2017-10-13 Thread Bruno Cardoso Lopes via cfe-commits
Hi Zachary,

I reverted this in r315712, since it's making one of our bots red
since yesterday (more explanations in the commit):
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA

Cheers,

On Thu, Oct 12, 2017 at 2:56 PM, Zachary Turner via cfe-commits
 wrote:
> Author: zturner
> Date: Thu Oct 12 14:56:05 2017
> New Revision: 315627
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315627=rev
> Log:
> [lit] Raise the logic for enabling clang & lld substitutions to llvm.
>
> This paves the way for other projects which might /use/ clang or
> lld but not necessarily need to the full set of functionality
> available to clang and lld tests to be able to have a basic set
> of substitutions that allow a project to run the clang or lld
> executables.
>
> Modified:
> cfe/trunk/test/lit.cfg.py
>
> Modified: cfe/trunk/test/lit.cfg.py
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=315627=315626=315627=diff
> ==
> --- cfe/trunk/test/lit.cfg.py (original)
> +++ cfe/trunk/test/lit.cfg.py Thu Oct 12 14:56:05 2017
> @@ -39,162 +39,43 @@ config.test_source_root = os.path.dirnam
>  # test_exec_root: The root path where tests should be run.
>  config.test_exec_root = os.path.join(config.clang_obj_root, 'test')
>
> -# Clear some environment variables that might affect Clang.
> -#
> -# This first set of vars are read by Clang, but shouldn't affect tests
> -# that aren't specifically looking for these features, or are required
> -# simply to run the tests at all.
> -#
> -# FIXME: Should we have a tool that enforces this?
> -
> -# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
> -#  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
> -#  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
> -#  'VC80COMNTOOLS')
> -possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
> -   'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
> -   'CPATH', 'C_INCLUDE_PATH', 
> 'CPLUS_INCLUDE_PATH',
> -   'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
> -   'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
> -   'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
> -   'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
> -   'LIBCLANG_RESOURCE_USAGE',
> -   'LIBCLANG_CODE_COMPLETION_LOGGING']
> -# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
> -if platform.system() != 'Windows':
> -possibly_dangerous_env_vars.append('INCLUDE')
> -
> -llvm_config.clear_environment(possibly_dangerous_env_vars)
> -
> -# Tweak the PATH to include the tools dir and the scripts dir.
> -llvm_config.with_environment(
> -'PATH', [config.llvm_tools_dir, config.clang_tools_dir], 
> append_path=True)
> +llvm_config.use_default_substitutions()
>
> -llvm_config.with_environment('LD_LIBRARY_PATH', [
> - config.llvm_shlib_dir, config.llvm_libs_dir], 
> append_path=True)
> +llvm_config.use_clang()
>
>  # Propagate path to symbolizer for ASan/MSan.
>  llvm_config.with_system_environment(
>  ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
>
> -llvm_config.use_default_substitutions()
> -
> -# Discover the 'clang' and 'clangcc' to use.
> -
> -
> -def inferClang(PATH):
> -# Determine which clang to use.
> -clang = os.getenv('CLANG')
> -
> -# If the user set clang in the environment, definitely use that and don't
> -# try to validate.
> -if clang:
> -return clang
> -
> -# Otherwise look in the path.
> -clang = lit.util.which('clang', PATH)
> -
> -if not clang:
> -lit_config.fatal("couldn't find 'clang' program, try setting "
> - 'CLANG in your environment')
> -
> -return clang
> -
> -
> -config.clang = inferClang(config.environment['PATH']).replace('\\', '/')
> -if not lit_config.quiet:
> -lit_config.note('using clang: %r' % config.clang)
> -
> -# Plugins (loadable modules)
> -# TODO: This should be supplied by Makefile or autoconf.
> -if sys.platform in ['win32', 'cygwin']:
> -has_plugins = config.enable_shared
> -else:
> -has_plugins = True
> -
> -if has_plugins and config.llvm_plugin_ext:
> -config.available_features.add('plugins')
> -
> -config.substitutions.append(('%llvmshlibdir', config.llvm_shlib_dir))
> -config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
>  config.substitutions.append(('%PATH%', config.environment['PATH']))
>
> -if config.clang_examples:
> -config.available_features.add('examples')
>
> -builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang)
> +# For each occurrence of a clang tool name, replace it with the full path to
> +# the build directory 

r315712 - Revert "[lit] Raise the logic for enabling clang & lld substitutions to llvm."

2017-10-13 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Oct 13 10:11:13 2017
New Revision: 315712

URL: http://llvm.org/viewvc/llvm-project?rev=315712=rev
Log:
Revert "[lit] Raise the logic for enabling clang & lld substitutions to llvm."

This reverts commit r315627, fixing bot failures:
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA

LIT is failing to properly apply substitution to debuginfo-tests
after this change.

rdar://problem/34979568

Modified:
cfe/trunk/test/lit.cfg.py

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=315712=315711=315712=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Fri Oct 13 10:11:13 2017
@@ -39,33 +39,71 @@ config.test_source_root = os.path.dirnam
 # test_exec_root: The root path where tests should be run.
 config.test_exec_root = os.path.join(config.clang_obj_root, 'test')
 
-llvm_config.use_default_substitutions()
+# Clear some environment variables that might affect Clang.
+#
+# This first set of vars are read by Clang, but shouldn't affect tests
+# that aren't specifically looking for these features, or are required
+# simply to run the tests at all.
+#
+# FIXME: Should we have a tool that enforces this?
 
-llvm_config.use_clang()
+# safe_env_vars = ('TMPDIR', 'TEMP', 'TMP', 'USERPROFILE', 'PWD',
+#  'MACOSX_DEPLOYMENT_TARGET', 'IPHONEOS_DEPLOYMENT_TARGET',
+#  'VCINSTALLDIR', 'VC100COMNTOOLS', 'VC90COMNTOOLS',
+#  'VC80COMNTOOLS')
+possibly_dangerous_env_vars = ['COMPILER_PATH', 'RC_DEBUG_OPTIONS',
+   'CINDEXTEST_PREAMBLE_FILE', 'LIBRARY_PATH',
+   'CPATH', 'C_INCLUDE_PATH', 'CPLUS_INCLUDE_PATH',
+   'OBJC_INCLUDE_PATH', 'OBJCPLUS_INCLUDE_PATH',
+   'LIBCLANG_TIMING', 'LIBCLANG_OBJTRACKING',
+   'LIBCLANG_LOGGING', 'LIBCLANG_BGPRIO_INDEX',
+   'LIBCLANG_BGPRIO_EDIT', 'LIBCLANG_NOTHREADS',
+   'LIBCLANG_RESOURCE_USAGE',
+   'LIBCLANG_CODE_COMPLETION_LOGGING']
+# Clang/Win32 may refer to %INCLUDE%. vsvarsall.bat sets it.
+if platform.system() != 'Windows':
+possibly_dangerous_env_vars.append('INCLUDE')
+
+llvm_config.clear_environment(possibly_dangerous_env_vars)
+
+# Tweak the PATH to include the tools dir and the scripts dir.
+llvm_config.with_environment(
+'PATH', [config.llvm_tools_dir, config.clang_tools_dir], append_path=True)
+
+llvm_config.with_environment('LD_LIBRARY_PATH', [
+ config.llvm_shlib_dir, config.llvm_libs_dir], 
append_path=True)
 
 # Propagate path to symbolizer for ASan/MSan.
 llvm_config.with_system_environment(
 ['ASAN_SYMBOLIZER_PATH', 'MSAN_SYMBOLIZER_PATH'])
 
-config.substitutions.append(('%PATH%', config.environment['PATH']))
+llvm_config.use_default_substitutions()
 
+# Discover the 'clang' and 'clangcc' to use.
 
-# For each occurrence of a clang tool name, replace it with the full path to
-# the build directory holding that tool.  We explicitly specify the directories
-# to search to ensure that we get the tools just built and not some random
-# tools that might happen to be in the user's PATH.
-tool_dirs = [config.clang_tools_dir, config.llvm_tools_dir]
 
-tools = [
-'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt',
-ToolSubst('%clang_func_map', command=FindTool(
-'clang-func-mapping'), unresolved='ignore'),
-]
+def inferClang(PATH):
+# Determine which clang to use.
+clang = os.getenv('CLANG')
 
-if config.clang_examples:
-tools.append('clang-interpreter')
+# If the user set clang in the environment, definitely use that and don't
+# try to validate.
+if clang:
+return clang
 
-llvm_config.add_tool_substitutions(tools, tool_dirs)
+# Otherwise look in the path.
+clang = lit.util.which('clang', PATH)
+
+if not clang:
+lit_config.fatal("couldn't find 'clang' program, try setting "
+ 'CLANG in your environment')
+
+return clang
+
+
+config.clang = inferClang(config.environment['PATH']).replace('\\', '/')
+if not lit_config.quiet:
+lit_config.note('using clang: %r' % config.clang)
 
 # Plugins (loadable modules)
 # TODO: This should be supplied by Makefile or autoconf.
@@ -77,6 +115,87 @@ else:
 if has_plugins and config.llvm_plugin_ext:
 config.available_features.add('plugins')
 
+config.substitutions.append(('%llvmshlibdir', config.llvm_shlib_dir))
+config.substitutions.append(('%pluginext', config.llvm_plugin_ext))
+config.substitutions.append(('%PATH%', config.environment['PATH']))
+
+if config.clang_examples:
+config.available_features.add('examples')
+
+builtin_include_dir = llvm_config.get_clang_builtin_include_dir(config.clang)
+
+tools = [
+# By 

Re: r298369 - [OpenCL] Added diagnostic for checking length of vector

2017-10-12 Thread Bruno Cardoso Lopes via cfe-commits
On Thu, Oct 12, 2017 at 8:39 AM, Anastasia Stulova
 wrote:
>
> I think this bit is a bit confusing to us. Some of our original OpenCL
> checks were removed in some places because in some cases OpenCL semantic was
> adopted elsewhere.

It's confusing indeed. We should probably enhance the docs for
scenarios like this.

> But I think this should indeed go under OpenCL check.

https://reviews.llvm.org/D38868

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [clang-tools-extra] r315287 - Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"

2017-10-10 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Oct 10, 2017 at 2:08 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Tue Oct 10 02:08:47 2017
> New Revision: 315287
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315287=rev
> Log:
> Revert "Revert r315214 since diff -Z isn't portable, this is breaking:"
>
> This reverts commit r315242 and restores r315214.
>
> To fix original failure, replaced non-portable `diff -Z` with portable
> alternative: `diff -b`.
>
> Added:
> clang-tools-extra/trunk/test/clangd/input-mirror.test
> Modified:
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315287=315286=315287=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Tue Oct 10 02:08:47 
> 2017
> @@ -37,6 +37,14 @@ void JSONOutput::log(const Twine 
>Logs.flush();
>  }
>
> +void JSONOutput::mirrorInput(const Twine ) {
> +  if (!InputMirror)
> +return;
> +
> +  *InputMirror << Message;
> +  InputMirror->flush();
> +}
> +
>  void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
>Output.log("Method ignored.\n");
>// Return that this method is unsupported.
> @@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
>  continue;
>}
>
> +  Out.mirrorInput(Line);
> +  // Mirror '\n' that gets consumed by std::getline, but is not included 
> in
> +  // the resulting Line.
> +  // Note that '\r' is part of Line, so we don't need to mirror it
> +  // separately.
> +  if (!In.eof())
> +Out.mirrorInput("\n");
> +
>llvm::StringRef LineRef(Line);
>
>// We allow YAML-style comments in headers. Technically this isn't part
> @@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
>if (LineRef.consume_front("Content-Length: ")) {
>  if (ContentLength != 0) {
>Out.log("Warning: Duplicate Content-Length header received. "
> -  "The previous value for this message ("
> -  + std::to_string(ContentLength)
> -  + ") was ignored.\n");
> +  "The previous value for this message (" +
> +  std::to_string(ContentLength) + ") was ignored.\n");
>  }
>
>  llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
> @@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
>// parser.
>std::vector JSON(ContentLength + 1, '\0');
>In.read(JSON.data(), ContentLength);
> +  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
>
>// If the stream is aborted before we read ContentLength bytes, In
>// will have eofbit and failbit set.
>if (!In) {
> -Out.log("Input was aborted. Read only "
> -+ std::to_string(In.gcount())
> -+ " bytes of expected "
> -+ std::to_string(ContentLength)
> -+ ".\n");
> +Out.log("Input was aborted. Read only " + 
> std::to_string(In.gcount()) +
> +" bytes of expected " + std::to_string(ContentLength) + 
> ".\n");
>  break;
>}
>
> @@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
>if (IsDone)
>  break;
>  } else {
> -  Out.log( "Warning: Missing Content-Length header, or message has zero "
> -   "length.\n" );
> +  Out.log("Warning: Missing Content-Length header, or message has zero "
> +  "length.\n");
>  }
>}
>  }
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315287=315286=315287=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Tue Oct 10 02:08:47 
> 2017
> @@ -24,8 +24,9 @@ namespace clangd {
>  /// them.
>  class JSONOutput : public Logger {
>  public:
> -  JSONOutput(llvm::raw_ostream , llvm::raw_ostream )
> -  : Outs(Outs), Logs(Logs) {}
> +  JSONOutput(llvm::raw_ostream , llvm::raw_ostream ,
> + llvm::raw_ostream *InputMirror = nullptr)
> +  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
>
>/// Emit a JSONRPC message.
>void writeMessage(const Twine );
> @@ -33,9 +34,15 @@ public:
>/// Write to the logging stream.
>void log(const Twine ) override;
>
> +  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror 
> is
> +  /// null.
> +  /// Unlike other methods 

Re: r298369 - [OpenCL] Added diagnostic for checking length of vector

2017-10-10 Thread Bruno Cardoso Lopes via cfe-commits
Hi Egor,

On Tue, Mar 21, 2017 at 6:20 AM, Egor Churaev via cfe-commits
 wrote:
> Author: echuraev
> Date: Tue Mar 21 08:20:57 2017
> New Revision: 298369
>
> URL: http://llvm.org/viewvc/llvm-project?rev=298369=rev
> Log:
> [OpenCL] Added diagnostic for checking length of vector
>
> Reviewers: Anastasia, cfe-commits
>
> Reviewed By: Anastasia
>
> Subscribers: bader, yaxunl
>
> Differential Revision: https://reviews.llvm.org/D30937
>
> Added:
> cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaExprMember.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=298369=298368=298369=diff
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Mar 21 08:20:57 
> 2017
> @@ -8236,6 +8236,8 @@ def err_opencl_ptrptr_kernel_param : Err
>  def err_kernel_arg_address_space : Error<
>"pointer arguments to kernel functions must reside in '__global', "
>"'__constant' or '__local' address space">;
> +def err_opencl_ext_vector_component_invalid_length : Error<
> +  "vector component access has invalid length %0.  Supported: 
> 1,2,3,4,8,16.">;
>  def err_opencl_function_variable : Error<
>"%select{non-kernel function|function scope}0 variable cannot be declared 
> in %1 address space">;
>  def err_static_function_scope : Error<
>
> Modified: cfe/trunk/lib/Sema/SemaExprMember.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprMember.cpp?rev=298369=298368=298369=diff
> ==
> --- cfe/trunk/lib/Sema/SemaExprMember.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaExprMember.cpp Tue Mar 21 08:20:57 2017
> @@ -284,6 +284,14 @@ IsRGBA(char c) {
>}
>  }
>
> +// OpenCL v1.1, s6.1.7
> +// The component swizzle length must be in accordance with the acceptable
> +// vector sizes.
> +static bool IsValidOpenCLComponentSwizzleLength(unsigned len)
> +{
> +  return (len >= 1 && len <= 4) || len == 8 || len == 16;
> +}
> +
>  /// Check an ext-vector component access expression.
>  ///
>  /// VK should be set in advance to the value kind of the base
> @@ -376,6 +384,19 @@ CheckExtVectorComponent(Sema , QualTyp
>  }
>}
>
> +  if (!HalvingSwizzle) {
> +unsigned SwizzleLength = CompName->getLength();
> +
> +if (HexSwizzle)
> +  SwizzleLength--;
> +
> +if (IsValidOpenCLComponentSwizzleLength(SwizzleLength) == false) {
> +  S.Diag(OpLoc, diag::err_opencl_ext_vector_component_invalid_length)
> +<< SwizzleLength << SourceRange(CompLoc);
> +  return QualType();
> +}
> +  }
> +
>// The component accessor looks fine - now we need to compute the actual 
> type.
>// The vector type is implied by the component accessor. For example,
>// vec4.b is a float, vec4.xy is a vec2, vec4.rgb is a vec3, etc.
>
> Added: cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl?rev=298369=auto
> ==
> --- cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl (added)
> +++ cfe/trunk/test/SemaOpenCL/vector_swizzle_length.cl Tue Mar 21 08:20:57 
> 2017
> @@ -0,0 +1,10 @@
> +// RUN: %clang_cc1 %s -verify -pedantic -fsyntax-only
> +
> +typedef float float8 __attribute__((ext_vector_type(8)));
> +
> +void foo() {
> +float8 f2 = (float8)(0, 0, 0, 0, 0, 0, 0, 0);
> +
> +f2.s01234; // expected-error {{vector component access has invalid 
> length 5.  Supported: 1,2,3,4,8,16}}
> +f2.xyzxy; // expected-error {{vector component access has invalid length 
> 5.  Supported: 1,2,3,4,8,16}}
> +}

Sorry for the necromancy here, but I wonder if we should only make
this if LangOpts.OpenCL in on. Is there an initial intent for not to?

The rationale is that we have given users support for ext_vector_type
without OpenCL mode with arbitrary vectors lengths not defined in
"6.1.2 Built-In Vector Data Types", that said it makes sense to
support the component notation for those. I'm happy to fix it, I just
need to know if this covers some background I'm not aware of.

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r315242 - Revert r315214 since diff -Z isn't portable, this is breaking:

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Oct  9 13:22:05 2017
New Revision: 315242

URL: http://llvm.org/viewvc/llvm-project?rev=315242=rev
Log:
Revert r315214 since diff -Z isn't portable, this is breaking:

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA


Removed:
clang-tools-extra/trunk/test/clangd/input-mirror.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315242=315241=315242=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 13:22:05 
2017
@@ -37,14 +37,6 @@ void JSONOutput::log(const Twine 
   Logs.flush();
 }
 
-void JSONOutput::mirrorInput(const Twine ) {
-  if (!InputMirror)
-return;
-
-  *InputMirror << Message;
-  InputMirror->flush();
-}
-
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
   Output.log("Method ignored.\n");
   // Return that this method is unsupported.
@@ -155,14 +147,6 @@ void clangd::runLanguageServerLoop(std::
 continue;
   }
 
-  Out.mirrorInput(Line);
-  // Mirror '\n' that gets consumed by std::getline, but is not included in
-  // the resulting Line.
-  // Note that '\r' is part of Line, so we don't need to mirror it
-  // separately.
-  if (!In.eof())
-Out.mirrorInput("\n");
-
   llvm::StringRef LineRef(Line);
 
   // We allow YAML-style comments in headers. Technically this isn't part
@@ -179,8 +163,9 @@ void clangd::runLanguageServerLoop(std::
   if (LineRef.consume_front("Content-Length: ")) {
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
-  "The previous value for this message (" +
-  std::to_string(ContentLength) + ") was ignored.\n");
+  "The previous value for this message ("
+  + std::to_string(ContentLength)
+  + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -200,13 +185,15 @@ void clangd::runLanguageServerLoop(std::
   // parser.
   std::vector JSON(ContentLength + 1, '\0');
   In.read(JSON.data(), ContentLength);
-  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
 
   // If the stream is aborted before we read ContentLength bytes, In
   // will have eofbit and failbit set.
   if (!In) {
-Out.log("Input was aborted. Read only " + std::to_string(In.gcount()) +
-" bytes of expected " + std::to_string(ContentLength) + ".\n");
+Out.log("Input was aborted. Read only "
++ std::to_string(In.gcount())
++ " bytes of expected "
++ std::to_string(ContentLength)
++ ".\n");
 break;
   }
 
@@ -222,8 +209,8 @@ void clangd::runLanguageServerLoop(std::
   if (IsDone)
 break;
 } else {
-  Out.log("Warning: Missing Content-Length header, or message has zero "
-  "length.\n");
+  Out.log( "Warning: Missing Content-Length header, or message has zero "
+   "length.\n" );
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315242=315241=315242=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 13:22:05 2017
@@ -24,9 +24,8 @@ namespace clangd {
 /// them.
 class JSONOutput : public Logger {
 public:
-  JSONOutput(llvm::raw_ostream , llvm::raw_ostream ,
- llvm::raw_ostream *InputMirror = nullptr)
-  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
+  JSONOutput(llvm::raw_ostream , llvm::raw_ostream )
+  : Outs(Outs), Logs(Logs) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const Twine );
@@ -34,15 +33,9 @@ public:
   /// Write to the logging stream.
   void log(const Twine ) override;
 
-  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is
-  /// null.
-  /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
-  void mirrorInput(const Twine );
-
 private:
   llvm::raw_ostream 
   llvm::raw_ostream 
-  llvm::raw_ostream *InputMirror;
 
   std::mutex StreamMutex;
 };

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 

Re: [clang-tools-extra] r315214 - [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Hi,

On Mon, Oct 9, 2017 at 9:58 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Mon Oct  9 09:58:16 2017
> New Revision: 315214
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315214=rev
> Log:
> [clangd] Added a command-line arg to mirror clangd input into a file.
>
> Summary: The arg is useful for debugging and creating test cases.
>
> Reviewers: bkramer, krasimir
>
> Reviewed By: bkramer
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D37970
>
> Added:
> clang-tools-extra/trunk/test/clangd/input-mirror.test
> Modified:
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315214=315213=315214=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 09:58:16 
> 2017
> @@ -37,6 +37,14 @@ void JSONOutput::log(const Twine 
>Logs.flush();
>  }
>
> +void JSONOutput::mirrorInput(const Twine ) {
> +  if (!InputMirror)
> +return;
> +
> +  *InputMirror << Message;
> +  InputMirror->flush();
> +}
> +
>  void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
>Output.log("Method ignored.\n");
>// Return that this method is unsupported.
> @@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
>  continue;
>}
>
> +  Out.mirrorInput(Line);
> +  // Mirror '\n' that gets consumed by std::getline, but is not included 
> in
> +  // the resulting Line.
> +  // Note that '\r' is part of Line, so we don't need to mirror it
> +  // separately.
> +  if (!In.eof())
> +Out.mirrorInput("\n");
> +
>llvm::StringRef LineRef(Line);
>
>// We allow YAML-style comments in headers. Technically this isn't part
> @@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
>if (LineRef.consume_front("Content-Length: ")) {
>  if (ContentLength != 0) {
>Out.log("Warning: Duplicate Content-Length header received. "
> -  "The previous value for this message ("
> -  + std::to_string(ContentLength)
> -  + ") was ignored.\n");
> +  "The previous value for this message (" +
> +  std::to_string(ContentLength) + ") was ignored.\n");
>  }
>
>  llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
> @@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
>// parser.
>std::vector JSON(ContentLength + 1, '\0');
>In.read(JSON.data(), ContentLength);
> +  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
>
>// If the stream is aborted before we read ContentLength bytes, In
>// will have eofbit and failbit set.
>if (!In) {
> -Out.log("Input was aborted. Read only "
> -+ std::to_string(In.gcount())
> -+ " bytes of expected "
> -+ std::to_string(ContentLength)
> -+ ".\n");
> +Out.log("Input was aborted. Read only " + 
> std::to_string(In.gcount()) +
> +" bytes of expected " + std::to_string(ContentLength) + 
> ".\n");
>  break;
>}
>
> @@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
>if (IsDone)
>  break;
>  } else {
> -  Out.log( "Warning: Missing Content-Length header, or message has zero "
> -   "length.\n" );
> +  Out.log("Warning: Missing Content-Length header, or message has zero "
> +  "length.\n");
>  }
>}
>  }
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315214=315213=315214=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 09:58:16 
> 2017
> @@ -24,8 +24,9 @@ namespace clangd {
>  /// them.
>  class JSONOutput : public Logger {
>  public:
> -  JSONOutput(llvm::raw_ostream , llvm::raw_ostream )
> -  : Outs(Outs), Logs(Logs) {}
> +  JSONOutput(llvm::raw_ostream , llvm::raw_ostream ,
> + llvm::raw_ostream *InputMirror = nullptr)
> +  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
>
>/// Emit a JSONRPC message.
>void writeMessage(const Twine );
> @@ -33,9 +34,15 @@ public:
>/// Write to the logging stream.
>void log(const Twine ) override;
>
> +  /// Mirror \p Message into InputMirror stream. Does 

Re: r312595 - [Darwin] Enable -fstack-protector (back) by default with -ffreestanding

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Sep 5, 2017 at 4:58 PM, Joerg Sonnenberger via cfe-commits
<cfe-commits@lists.llvm.org> wrote:
> On Tue, Sep 05, 2017 at 11:50:58PM -0000, Bruno Cardoso Lopes via cfe-commits 
> wrote:
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312595=312594=312595=diff
>> ==
>> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
>> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 16:50:58 2017
>> @@ -2302,11 +2302,6 @@ static void RenderSSPOptions(const ToolC
>>  else if (A->getOption().matches(options::OPT_fstack_protector_all))
>>StackProtectorLevel = LangOptions::SSPReq;
>>} else {
>> -// Only use a default stack protector on Darwin in case -ffreestanding 
>> is
>> -// not specified.
>> -if (EffectiveTriple.isOSDarwin() && !IsHosted)
>> -  StackProtectorLevel = 0;
>> -else
>>StackProtectorLevel = DefaultStackProtectorLevel;
>>}
>
> Indentation?

Thanks for the catch, done in r312599

>
> Joerg
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312599 - Fix indentation mistake from r312595

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Sep  5 17:44:10 2017
New Revision: 312599

URL: http://llvm.org/viewvc/llvm-project?rev=312599=rev
Log:
Fix indentation mistake from r312595

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312599=312598=312599=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 17:44:10 2017
@@ -2302,7 +2302,7 @@ static void RenderSSPOptions(const ToolC
 else if (A->getOption().matches(options::OPT_fstack_protector_all))
   StackProtectorLevel = LangOptions::SSPReq;
   } else {
-  StackProtectorLevel = DefaultStackProtectorLevel;
+StackProtectorLevel = DefaultStackProtectorLevel;
   }
 
   if (StackProtectorLevel) {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r312595 - [Darwin] Enable -fstack-protector (back) by default with -ffreestanding

2017-09-05 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Sep  5 16:50:58 2017
New Revision: 312595

URL: http://llvm.org/viewvc/llvm-project?rev=312595=rev
Log:
[Darwin] Enable -fstack-protector (back) by default with -ffreestanding

Go back to behavior prior to r289005.

rdar://problem/32987198

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/stack-protector.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=312595=312594=312595=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue Sep  5 16:50:58 2017
@@ -2302,11 +2302,6 @@ static void RenderSSPOptions(const ToolC
 else if (A->getOption().matches(options::OPT_fstack_protector_all))
   StackProtectorLevel = LangOptions::SSPReq;
   } else {
-// Only use a default stack protector on Darwin in case -ffreestanding is
-// not specified.
-if (EffectiveTriple.isOSDarwin() && !IsHosted)
-  StackProtectorLevel = 0;
-else
   StackProtectorLevel = DefaultStackProtectorLevel;
   }
 

Modified: cfe/trunk/test/Driver/stack-protector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stack-protector.c?rev=312595=312594=312595=diff
==
--- cfe/trunk/test/Driver/stack-protector.c (original)
+++ cfe/trunk/test/Driver/stack-protector.c Tue Sep  5 16:50:58 2017
@@ -36,27 +36,20 @@
 // Test default stack protector values for Darwin platforms
 
 // RUN: %clang -target armv7k-apple-watchos2.0 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_WATCHOS
+// RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_WATCHOS
 // SSP_WATCHOS: "-stack-protector" "1"
 // RUN: %clang -target arm64-apple-ios8.0.0 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_IOS
+// RUN: %clang -ffreestanding -target arm64-apple-ios8.0.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_IOS
 // SSP_IOS: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s -check-prefix=SSP_MACOSX
 // SSP_MACOSX: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.5 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_10_5
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.5 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_MACOSX_10_5
 // SSP_MACOSX_10_5: "-stack-protector" "1"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.5 
-mkernel -### %s 2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_KERNEL
 // SSP_MACOSX_KERNEL-NOT: "-stack-protector"
 // RUN: %clang -target x86_64-apple-darwin10 -mmacosx-version-min=10.6 -### %s 
2>&1 | FileCheck %s -check-prefix=SSP_MACOSX_10_6_KERNEL
+// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_MACOSX_10_6_KERNEL
 // SSP_MACOSX_10_6_KERNEL: "-stack-protector" "1"
 
-// Test default stack protector values for Darwin platforms with -ffreestanding
-
-// RUN: %clang -ffreestanding -target armv7k-apple-watchos2.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_FREE_WATCHOS
-// SSP_FREE_WATCHOS-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target arm64-apple-ios8.0.0 -### %s 2>&1 | 
FileCheck %s -check-prefix=SSP_FREE_IOS
-// SSP_FREE_IOS-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX
-// SSP_FREE_MACOSX-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.5 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX_10_5
-// SSP_FREE_MACOSX_10_5-NOT: "-stack-protector"
-// RUN: %clang -ffreestanding -target x86_64-apple-darwin10 
-mmacosx-version-min=10.6 -### %s 2>&1 | FileCheck %s 
-check-prefix=SSP_FREE_MACOSX_10_6_KERNEL
-// SSP_FREE_MACOSX_10_6_KERNEL-NOT: "-stack-protector"


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, Aug 11, 2017 at 9:27 PM, Richard Smith <rich...@metafoo.co.uk> wrote:
> On 11 August 2017 at 16:51, Bruno Cardoso Lopes via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
>>
>> On Thu, Aug 10, 2017 at 5:36 PM, Richard Smith <rich...@metafoo.co.uk>
>> wrote:
>> > On 10 August 2017 at 10:42, Hans Wennborg via cfe-commits
>> > <cfe-commits@lists.llvm.org> wrote:
>> >>
>> >> Sounds good to me.
>> >>
>> >> Richard, what do you think?
>> >>
>> >> On Thu, Aug 10, 2017 at 9:38 AM, Bruno Cardoso Lopes
>> >> <bruno.card...@gmail.com> wrote:
>> >> > Hi Hans, can we please get this merged into 5.0?
>> >> >
>> >> > Thanks,
>> >> >
>> >> > On Thu, Aug 10, 2017 at 12:16 PM, Bruno Cardoso Lopes via cfe-commits
>> >> > <cfe-commits@lists.llvm.org> wrote:
>> >> >> Author: bruno
>> >> >> Date: Thu Aug 10 08:16:24 2017
>> >> >> New Revision: 310605
>> >> >>
>> >> >> URL: http://llvm.org/viewvc/llvm-project?rev=310605=rev
>> >> >> Log:
>> >> >> [Modules] Prevent #import to reenter header if not building a
>> >> >> module.
>> >> >>
>> >> >> When non-modular headers are imported while not building a module
>> >> >> but
>> >> >> in -fmodules mode, be conservative and preserve the default #import
>> >> >> semantic: do not reenter headers.
>> >
>> >
>> > This comment doesn't appear to describe what this patch does: even when
>> > building a module it does not re-enter headers except for ones declared
>> > 'textual header' within the module being built. (isCompilingModuleHeader
>> > doesn't mean "are we compiling a module header right now?", it means "is
>> > this file declared as some kind of header within the current
>> > CompilingModule?".)
>>
>> What I'm trying to achieve here is: do not try to enter headers that
>> are not described as part of any module (textual) unless while
>> building a module. AFAIU, FileInfo.isCompilingModuleHeader is
>> basically LangOpts.isCompilingModule() && Mod->getTopLevelModule() ==
>> SourceModule, shouldn't it account for a more restrictive way to say
>> "are we compiling a textual header while building a module"?
>
>
> The "more restrictive" part is the problem: this also changes the behavior
> when we *are* building a module. Consider:
>
> // once.h
> #ifndef ONCE_H
> #define ONCE_H
> #pragma once
> extern int once;
> #endif
>
> // a.h
> #include "once.h"
>
> // b.h
> #include "once.h"
>
> // module.map
> module X { module A { header "a.h" } module B { header "b.h" } }
>
> This change appears to break the above module (when built with local
> submodule visibility enabled): module X.B no longer includes "once.h" and so
> no longer exports the "once" variable.

Nice testcase. I'll add it soon.

>> Checking for FileInfo.isCompilingModuleHeader has the additional
>> advantage that it would track previous attempts to import that header
>> while building a module, in which case it's going to try to re-enter.
>> It won't try to re-enter only in cases where that header was never
>> imported while building a header -> the same behavior #import has
>> without modules.
>>
>> Prior to r291644, clang would always avoid to re-enter a header. After
>> r291644 clang has a relaxed version of that, which I now proposing to
>> be less relaxed for #imports.
>>
>> > I'm nervous about taking this change: it will presumably break some
>> > cases
>> > (particularly with local submodule visibility enabled) where a #pragma
>> > once
>> > header is #included into multiple headers in the same module, by
>> > refusing to
>> > re-enter such headers -- and it will fix other such cases, depending on
>> > what
>> > exactly the header does and the structure of the module.
>>
>> I'd be interested in a such testcase to make sure we don't regress here!
>>
>> > If this were restricted to the case where we're not building a module
>> > (!LangOpts.isCompilingModule()), then I'd be OK putting it on the
>> > branch.
>>
>> Ok. It might not be a good idea to have this in 5.0 anyway, better
>> bake this for a while. But thinking forward, am I missi

r310775 - Revert "[Modules] Prevent #import to reenter header if not building a module."

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Aug 11 18:38:26 2017
New Revision: 310775

URL: http://llvm.org/viewvc/llvm-project?rev=310775=rev
Log:
Revert "[Modules] Prevent #import to reenter header if not building a module."

This reverts commit r310605. Richard pointed out a better way to achieve
this, which I'll post a patch for soon.

Removed:
cfe/trunk/test/Modules/Inputs/import-textual/x.h
cfe/trunk/test/Modules/import-textual-nomodules.m
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=310775=310774=310775=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Fri Aug 11 18:38:26 2017
@@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFil
 // headers find in the wild might rely only on #import and do not contain
 // controlling macros, be conservative and only try to enter textual 
headers
 // if such macro is present.
-if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
+if (!FileInfo.isModuleHeader &&
 FileInfo.getControllingMacro(ExternalLookup))
   TryEnterHdr = true;
 return TryEnterHdr;

Removed: cfe/trunk/test/Modules/Inputs/import-textual/x.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/import-textual/x.h?rev=310774=auto
==
--- cfe/trunk/test/Modules/Inputs/import-textual/x.h (original)
+++ cfe/trunk/test/Modules/Inputs/import-textual/x.h (removed)
@@ -1,6 +0,0 @@
-#ifndef RANDOM_DEP
-
-@interface X
-@end
-
-#endif // RANDOM_DEP

Removed: cfe/trunk/test/Modules/import-textual-nomodules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-textual-nomodules.m?rev=310774=auto
==
--- cfe/trunk/test/Modules/import-textual-nomodules.m (original)
+++ cfe/trunk/test/Modules/import-textual-nomodules.m (removed)
@@ -1,8 +0,0 @@
-// RUN: rm -rf %t
-// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps 
-I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
-
-// expected-no-diagnostics
-
-#import "x.h"
-#import "x.h"
-


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310706 - [modules] Set the lexical DC for dummy tag decls that refer to hidden

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
Hi Alex,

On Fri, Aug 11, 2017 at 9:06 AM, Alex Lorenz via cfe-commits
 wrote:
> Author: arphaman
> Date: Fri Aug 11 05:06:52 2017
> New Revision: 310706
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310706=rev
> Log:
> [modules] Set the lexical DC for dummy tag decls that refer to hidden
> declarations that are made visible after the dummy is parsed and ODR verified
>
> Prior to this commit the
> "(getContainingDC(DC) == CurContext && "The next DeclContext should be 
> lexically contained in the current one."),"
> assertion failure was triggered during semantic analysis of the dummy
> tag declaration that was declared in another tag declaration because its
> lexical context did not point to the outer tag decl.
>
> rdar://32292196
>
> Added:
> cfe/trunk/test/Modules/Inputs/innerstructredef.h
> cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/test/Modules/Inputs/module.map
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=310706=310705=310706=diff
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Aug 11 05:06:52 2017
> @@ -13722,6 +13722,7 @@ Decl *Sema::ActOnTag(Scope *S, unsigned
>// comparison.
>SkipBody->CheckSameAsPrevious = true;
>SkipBody->New = createTagFromNewDecl();
> +  SkipBody->New->setLexicalDeclContext(CurContext);

I think it would be cleaner to do this inside "createTagFromNewDecl" than here.

>SkipBody->Previous = Hidden;
>  } else {
>SkipBody->ShouldSkip = true;
>
> Added: cfe/trunk/test/Modules/Inputs/innerstructredef.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/innerstructredef.h?rev=310706=auto
> ==
> --- cfe/trunk/test/Modules/Inputs/innerstructredef.h (added)
> +++ cfe/trunk/test/Modules/Inputs/innerstructredef.h Fri Aug 11 05:06:52 2017
> @@ -0,0 +1,6 @@
> +struct Outer {
> +// This definition is actually hidden since only submodule 'one' is imported.
> +struct Inner {
> +  int x;
> +} field;
> +};
>
> Modified: cfe/trunk/test/Modules/Inputs/module.map
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=310706=310705=310706=diff
> ==
> --- cfe/trunk/test/Modules/Inputs/module.map (original)
> +++ cfe/trunk/test/Modules/Inputs/module.map Fri Aug 11 05:06:52 2017
> @@ -451,3 +451,12 @@ module DebugNestedB {
>  module objcAtKeywordMissingEnd {
>header "objcAtKeywordMissingEnd.h"
>  }
> +
> +module innerstructredef {
> +  module one {
> +header "empty.h"
> +  }
> +  module two {
> +   header "innerstructredef.h"
> +  }
> +}
>
> Added: cfe/trunk/test/Modules/inner-struct-redefines-invisible.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/inner-struct-redefines-invisible.m?rev=310706=auto
> ==
> --- cfe/trunk/test/Modules/inner-struct-redefines-invisible.m (added)
> +++ cfe/trunk/test/Modules/inner-struct-redefines-invisible.m Fri Aug 11 
> 05:06:52 2017
> @@ -0,0 +1,12 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs -fmodules 
> -fimplicit-module-maps -fmodules-cache-path=%t -verify %s
> +// expected-no-diagnostics
> +
> +@import innerstructredef.one;
> +
> +struct Outer {
> +// Should set lexical context when parsing 'Inner' here, otherwise there's a 
> crash:
> +struct Inner {
> +  int x;
> +} field;
> +};
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-11 Thread Bruno Cardoso Lopes via cfe-commits
On Thu, Aug 10, 2017 at 5:36 PM, Richard Smith <rich...@metafoo.co.uk> wrote:
> On 10 August 2017 at 10:42, Hans Wennborg via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
>>
>> Sounds good to me.
>>
>> Richard, what do you think?
>>
>> On Thu, Aug 10, 2017 at 9:38 AM, Bruno Cardoso Lopes
>> <bruno.card...@gmail.com> wrote:
>> > Hi Hans, can we please get this merged into 5.0?
>> >
>> > Thanks,
>> >
>> > On Thu, Aug 10, 2017 at 12:16 PM, Bruno Cardoso Lopes via cfe-commits
>> > <cfe-commits@lists.llvm.org> wrote:
>> >> Author: bruno
>> >> Date: Thu Aug 10 08:16:24 2017
>> >> New Revision: 310605
>> >>
>> >> URL: http://llvm.org/viewvc/llvm-project?rev=310605=rev
>> >> Log:
>> >> [Modules] Prevent #import to reenter header if not building a module.
>> >>
>> >> When non-modular headers are imported while not building a module but
>> >> in -fmodules mode, be conservative and preserve the default #import
>> >> semantic: do not reenter headers.
>
>
> This comment doesn't appear to describe what this patch does: even when
> building a module it does not re-enter headers except for ones declared
> 'textual header' within the module being built. (isCompilingModuleHeader
> doesn't mean "are we compiling a module header right now?", it means "is
> this file declared as some kind of header within the current
> CompilingModule?".)

What I'm trying to achieve here is: do not try to enter headers that
are not described as part of any module (textual) unless while
building a module. AFAIU, FileInfo.isCompilingModuleHeader is
basically LangOpts.isCompilingModule() && Mod->getTopLevelModule() ==
SourceModule, shouldn't it account for a more restrictive way to say
"are we compiling a textual header while building a module"?

Checking for FileInfo.isCompilingModuleHeader has the additional
advantage that it would track previous attempts to import that header
while building a module, in which case it's going to try to re-enter.
It won't try to re-enter only in cases where that header was never
imported while building a header -> the same behavior #import has
without modules.

Prior to r291644, clang would always avoid to re-enter a header. After
r291644 clang has a relaxed version of that, which I now proposing to
be less relaxed for #imports.

> I'm nervous about taking this change: it will presumably break some cases
> (particularly with local submodule visibility enabled) where a #pragma once
> header is #included into multiple headers in the same module, by refusing to
> re-enter such headers -- and it will fix other such cases, depending on what
> exactly the header does and the structure of the module.

I'd be interested in a such testcase to make sure we don't regress here!

> If this were restricted to the case where we're not building a module
> (!LangOpts.isCompilingModule()), then I'd be OK putting it on the branch.

Ok. It might not be a good idea to have this in 5.0 anyway, better
bake this for a while. But thinking forward, am I missing something
here? What about:

if ((LangOpts.isCompilingModule() || !isImport) && !FileInfo.isModuleHeader &&
FileInfo.getControllingMacro(ExternalLookup))
  TryEnterHdr = true;

Thanks,

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-10 Thread Bruno Cardoso Lopes via cfe-commits
Hi Hans, can we please get this merged into 5.0?

Thanks,

On Thu, Aug 10, 2017 at 12:16 PM, Bruno Cardoso Lopes via cfe-commits
<cfe-commits@lists.llvm.org> wrote:
> Author: bruno
> Date: Thu Aug 10 08:16:24 2017
> New Revision: 310605
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310605=rev
> Log:
> [Modules] Prevent #import to reenter header if not building a module.
>
> When non-modular headers are imported while not building a module but
> in -fmodules mode, be conservative and preserve the default #import
> semantic: do not reenter headers.
>
> rdar://problem/33745031
>
> Added:
> cfe/trunk/test/Modules/Inputs/import-textual/x.h
> cfe/trunk/test/Modules/import-textual-nomodules.m
> Modified:
> cfe/trunk/lib/Lex/HeaderSearch.cpp
>
> Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=310605=310604=310605=diff
> ==
> --- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
> +++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Aug 10 08:16:24 2017
> @@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFil
>  // headers find in the wild might rely only on #import and do not contain
>  // controlling macros, be conservative and only try to enter textual 
> headers
>  // if such macro is present.
> -if (!FileInfo.isModuleHeader &&
> +if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
>  FileInfo.getControllingMacro(ExternalLookup))
>TryEnterHdr = true;
>  return TryEnterHdr;
>
> Added: cfe/trunk/test/Modules/Inputs/import-textual/x.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/import-textual/x.h?rev=310605=auto
> ==
> --- cfe/trunk/test/Modules/Inputs/import-textual/x.h (added)
> +++ cfe/trunk/test/Modules/Inputs/import-textual/x.h Thu Aug 10 08:16:24 2017
> @@ -0,0 +1,6 @@
> +#ifndef RANDOM_DEP
> +
> +@interface X
> +@end
> +
> +#endif // RANDOM_DEP
>
> Added: cfe/trunk/test/Modules/import-textual-nomodules.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-textual-nomodules.m?rev=310605=auto
> ==
> --- cfe/trunk/test/Modules/import-textual-nomodules.m (added)
> +++ cfe/trunk/test/Modules/import-textual-nomodules.m Thu Aug 10 08:16:24 2017
> @@ -0,0 +1,8 @@
> +// RUN: rm -rf %t
> +// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps 
> -I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
> +
> +// expected-no-diagnostics
> +
> +#import "x.h"
> +#import "x.h"
> +
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r310605 - [Modules] Prevent #import to reenter header if not building a module.

2017-08-10 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Aug 10 08:16:24 2017
New Revision: 310605

URL: http://llvm.org/viewvc/llvm-project?rev=310605=rev
Log:
[Modules] Prevent #import to reenter header if not building a module.

When non-modular headers are imported while not building a module but
in -fmodules mode, be conservative and preserve the default #import
semantic: do not reenter headers.

rdar://problem/33745031

Added:
cfe/trunk/test/Modules/Inputs/import-textual/x.h
cfe/trunk/test/Modules/import-textual-nomodules.m
Modified:
cfe/trunk/lib/Lex/HeaderSearch.cpp

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=310605=310604=310605=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Thu Aug 10 08:16:24 2017
@@ -1143,7 +1143,7 @@ bool HeaderSearch::ShouldEnterIncludeFil
 // headers find in the wild might rely only on #import and do not contain
 // controlling macros, be conservative and only try to enter textual 
headers
 // if such macro is present.
-if (!FileInfo.isModuleHeader &&
+if (FileInfo.isCompilingModuleHeader && !FileInfo.isModuleHeader &&
 FileInfo.getControllingMacro(ExternalLookup))
   TryEnterHdr = true;
 return TryEnterHdr;

Added: cfe/trunk/test/Modules/Inputs/import-textual/x.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/import-textual/x.h?rev=310605=auto
==
--- cfe/trunk/test/Modules/Inputs/import-textual/x.h (added)
+++ cfe/trunk/test/Modules/Inputs/import-textual/x.h Thu Aug 10 08:16:24 2017
@@ -0,0 +1,6 @@
+#ifndef RANDOM_DEP
+
+@interface X
+@end
+
+#endif // RANDOM_DEP

Added: cfe/trunk/test/Modules/import-textual-nomodules.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/import-textual-nomodules.m?rev=310605=auto
==
--- cfe/trunk/test/Modules/import-textual-nomodules.m (added)
+++ cfe/trunk/test/Modules/import-textual-nomodules.m Thu Aug 10 08:16:24 2017
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fsyntax-only -fmodules -fimplicit-module-maps 
-I%S/Inputs/import-textual -fmodules-cache-path=%t %s -verify
+
+// expected-no-diagnostics
+
+#import "x.h"
+#import "x.h"
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r309752 - [Headers][Darwin] Allow #include_next to work on Darwin prior to 10.7

2017-08-01 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Aug 1, 2017 at 4:34 PM, Hans Wennborg <h...@chromium.org> wrote:
> Merged in r309764.
>
> You cc'd me on the bug, so I noticed that :-)
>
> Just marking a bug a release blocker doesn't generally work though; it
> needs to be marked as blocking PR33849. (Though I will search for
> "release blocker" severity bugs now and then.)
>
> On Tue, Aug 1, 2017 at 3:15 PM, Bruno Cardoso Lopes
> <bruno.card...@gmail.com> wrote:
>> Hi Hans,
>>
>> Can we merge this to 5.0 too? I tried to set up the bugzilla to mark
>> it as "release blocker", is that enough for you to see it? or next
>> time is something I can do to make your life easier?

Cool, thanks again!

>> Thanks,
>>
>> On Tue, Aug 1, 2017 at 3:10 PM, Bruno Cardoso Lopes via cfe-commits
>> <cfe-commits@lists.llvm.org> wrote:
>>> Author: bruno
>>> Date: Tue Aug  1 15:10:36 2017
>>> New Revision: 309752
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=309752=rev
>>> Log:
>>> [Headers][Darwin] Allow #include_next to work on Darwin prior to 
>>> 10.7
>>>
>>> This fixes PR31504 and it's a follow up from adding #include_next
>>> for Darwin in r289018.
>>>
>>> rdar://problem/29856682
>>>
>>> Modified:
>>> cfe/trunk/lib/Headers/float.h
>>>
>>> Modified: cfe/trunk/lib/Headers/float.h
>>> URL: 
>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/float.h?rev=309752=309751=309752=diff
>>> ==
>>> --- cfe/trunk/lib/Headers/float.h (original)
>>> +++ cfe/trunk/lib/Headers/float.h Tue Aug  1 15:10:36 2017
>>> @@ -33,6 +33,15 @@
>>>   */
>>>  #if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && 
>>> \
>>>  __STDC_HOSTED__ && __has_include_next()
>>> +
>>> +/* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra 
>>> level
>>> + * of #include_next to keep Metrowerks compilers happy. Avoid this
>>> + * extra indirection.
>>> + */
>>> +#ifdef __APPLE__
>>> +#define _FLOAT_H_
>>> +#endif
>>> +
>>>  #  include_next 
>>>
>>>  /* Undefine anything that we'll be redefining below. */
>>>
>>>
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>>
>>
>> --
>> Bruno Cardoso Lopes
>> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309752 - [Headers][Darwin] Allow #include_next to work on Darwin prior to 10.7

2017-08-01 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Aug  1 15:10:36 2017
New Revision: 309752

URL: http://llvm.org/viewvc/llvm-project?rev=309752=rev
Log:
[Headers][Darwin] Allow #include_next to work on Darwin prior to 10.7

This fixes PR31504 and it's a follow up from adding #include_next
for Darwin in r289018.

rdar://problem/29856682

Modified:
cfe/trunk/lib/Headers/float.h

Modified: cfe/trunk/lib/Headers/float.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/float.h?rev=309752=309751=309752=diff
==
--- cfe/trunk/lib/Headers/float.h (original)
+++ cfe/trunk/lib/Headers/float.h Tue Aug  1 15:10:36 2017
@@ -33,6 +33,15 @@
  */
 #if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
 __STDC_HOSTED__ && __has_include_next()
+
+/* Prior to Apple's 10.7 SDK, float.h SDK header used to apply an extra level
+ * of #include_next to keep Metrowerks compilers happy. Avoid this
+ * extra indirection.
+ */
+#ifdef __APPLE__
+#define _FLOAT_H_
+#endif
+
 #  include_next 
 
 /* Undefine anything that we'll be redefining below. */


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r309722 - [Sema] Fix lax conversion between non ext vectors

2017-08-01 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Aug  1 12:05:25 2017
New Revision: 309722

URL: http://llvm.org/viewvc/llvm-project?rev=309722=rev
Log:
[Sema] Fix lax conversion between non ext vectors

r282968 introduced a regression due to the lack of proper testing.
Re-add lax conversion support between non ext vectors for compound
assignments and add a test for that.

rdar://problem/28639467

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/Sema/vector-cast.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=309722=309721=309722=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Aug  1 12:05:25 2017
@@ -8288,7 +8288,7 @@ QualType Sema::CheckVectorOperands(ExprR
 // type. Note that this is already done by non-compound assignments in
 // CheckAssignmentConstraints. If it's a scalar type, only bitcast for
 // <1 x T> -> T. The result is also a vector type.
-} else if (OtherType->isExtVectorType() ||
+} else if (OtherType->isExtVectorType() || OtherType->isVectorType() ||
(OtherType->isScalarType() && VT->getNumElements() == 1)) {
   ExprResult *RHSExpr = 
   *RHSExpr = ImpCastExprToType(RHSExpr->get(), LHSType, CK_BitCast);

Modified: cfe/trunk/test/Sema/vector-cast.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-cast.c?rev=309722=309721=309722=diff
==
--- cfe/trunk/test/Sema/vector-cast.c (original)
+++ cfe/trunk/test/Sema/vector-cast.c Tue Aug  1 12:05:25 2017
@@ -48,6 +48,9 @@ typedef float float2 __attribute__ ((vec
 typedef __attribute__((vector_size(8))) double float64x1_t;
 typedef __attribute__((vector_size(16))) double float64x2_t;
 float64x1_t vget_low_f64(float64x2_t __p0);
+typedef float float16 __attribute__((__vector_size__(16)));
+typedef signed int vSInt32 __attribute__((__vector_size__(16)));
+typedef unsigned int vUInt32 __attribute__((__vector_size__(16)));
 
 void f4() {
   float2 f2;
@@ -73,3 +76,8 @@ void f5() {
   v = ptr; // expected-error-re {{assigning to 'short_sizeof_pointer' (vector 
of {{[0-9]+}} 'short' values) from incompatible type 'void *'}}
   ptr = v; // expected-error {{assigning to 'void *' from incompatible type 
'short_sizeof_pointer'}}
 }
+
+void f6(vSInt32 a0) {
+  vUInt32 counter = (float16){0.0f, 0.0f, 0.0f, 0.0f}; // expected-warning 
{{incompatible vector types initializing 'vUInt32' (vector of 4 'unsigned int' 
values) with an expression of type 'float16' (vector of 4 'float' values)}}
+  counter -= a0;
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r308225 - Check for _MSC_VER before defining _LIBCPP_MSVCRT

2017-07-17 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Jul 17 14:52:31 2017
New Revision: 308225

URL: http://llvm.org/viewvc/llvm-project?rev=308225=rev
Log:
Check for _MSC_VER before defining _LIBCPP_MSVCRT

Some targets (e.g. Darwin) might have the Win32 API available, but they
do not use MSVC CRT. Assume _LIBCPP_MSVCRT only when _MSC_VER is available
and __MINGW32__ isn't defined.

Differential Revision: https://reviews.llvm.org/D34588

rdar://problem/32628786

Modified:
libcxx/trunk/include/__config

Modified: libcxx/trunk/include/__config
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config?rev=308225=308224=308225=diff
==
--- libcxx/trunk/include/__config (original)
+++ libcxx/trunk/include/__config Mon Jul 17 14:52:31 2017
@@ -229,8 +229,9 @@
 #  define _LIBCPP_SHORT_WCHAR   1
 // Both MinGW and native MSVC provide a "MSVC"-like enviroment
 #  define _LIBCPP_MSVCRT_LIKE
-// If mingw not explicitly detected, assume using MS C runtime only.
-#  ifndef __MINGW32__
+// If mingw not explicitly detected, assume using MS C runtime only if
+// a MS compatibility version is specified.
+#  if defined(_MSC_VER) && !defined(__MINGW32__)
 #define _LIBCPP_MSVCRT // Using Microsoft's C Runtime library
 #  endif
 #  if (defined(_M_AMD64) || defined(__x86_64__)) || (defined(_M_ARM) || 
defined(__arm__))


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r307296 - [Objective-C] Fix non-determinism in clang

2017-07-06 Thread Bruno Cardoso Lopes via cfe-commits
Awesome, thanks!

On Thu, Jul 6, 2017 at 11:49 AM, Mandeep Singh Grang via cfe-commits
 wrote:
> Author: mgrang
> Date: Thu Jul  6 11:49:57 2017
> New Revision: 307296
>
> URL: http://llvm.org/viewvc/llvm-project?rev=307296=rev
> Log:
>  [Objective-C] Fix non-determinism in clang
>
> Summary: Iteration of the unordered Ivars causes 
> objc-modern-metadata-visibility.mm (uncovered by reverse iterating 
> SmallPtrSet).
>
> Reviewers: dblaikie, davide, rsmith
>
> Reviewed By: dblaikie
>
> Subscribers: cfe-commits, llvm-commits
>
> Differential Revision: https://reviews.llvm.org/D34860
>
> Added:
> cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
> Modified:
> cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
>
> Modified: cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp?rev=307296=307295=307296=diff
> ==
> --- cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp (original)
> +++ cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp Thu Jul  6 11:49:57 
> 2017
> @@ -146,7 +146,7 @@ namespace {
>
>  llvm::DenseMap RewrittenBlockExprs;
>  llvm::DenseMap -llvm::SmallPtrSet > ReferencedIvars;
> +llvm::SmallSetVector > 
> ReferencedIvars;
>
>  // ivar bitfield grouping containers
>  llvm::DenseSet 
> ObjCInterefaceHasBitfieldGroups;
> @@ -1013,7 +1013,7 @@ void RewriteModernObjC::RewritePropertyI
>  Setr = "\nextern \"C\" __declspec(dllimport) "
>  "void objc_setProperty (id, SEL, long, id, bool, bool);\n";
>}
> -
> +
>RewriteObjCMethodDecl(OID->getContainingInterface(),
>  PD->getSetterMethodDecl(), Setr);
>Setr += "{ ";
> @@ -3965,10 +3965,11 @@ void RewriteModernObjC::RewriteIvarOffse
>std::string ) {
>// write out ivar offset symbols which have been referenced in an ivar
>// access expression.
> -  llvm::SmallPtrSet Ivars = ReferencedIvars[CDecl];
> +  llvm::SmallSetVector Ivars = ReferencedIvars[CDecl];
> +
>if (Ivars.empty())
>  return;
> -
> +
>llvm::DenseSet 
> GroupSymbolOutput;
>for (ObjCIvarDecl *IvarDecl : Ivars) {
>  const ObjCInterfaceDecl *IDecl = IvarDecl->getContainingInterface();
>
> Added: cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm?rev=307296=auto
> ==
> --- cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm (added)
> +++ cfe/trunk/test/Rewriter/objc-modern-metadata-visibility2.mm Thu Jul  6 
> 11:49:57 2017
> @@ -0,0 +1,45 @@
> +// REQUIRES: abi-breaking-checks
> +// NOTE: This test has been split from objc-modern-metadata-visibility.mm in
> +// order to test with -reverse-iterate as this flag is only present with
> +// ABI_BREAKING_CHECKS.
> +
> +// RUN: %clang_cc1 -E %s -o %t.mm -mllvm -reverse-iterate
> +// RUN: %clang_cc1 -x objective-c++ -fblocks -fms-extensions -rewrite-objc 
> %t.mm -mllvm -reverse-iterate -o - | FileCheck %s
> +// rdar://11144048
> +
> +@class NSString;
> +
> +@interface NSObject {
> +Class isa;
> +}
> +@end
> +
> +@interface Sub : NSObject {
> +int subIvar;
> +NSString *nsstring;
> +@private
> +id PrivateIvar;
> +}
> +@end
> +
> +@implementation Sub
> +- (id) MyNSString { return subIvar ? PrivateIvar : nsstring; }
> +@end
> +
> +@interface NSString @end
> +@implementation NSString @end
> +
> +// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
> __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$subIvar;
> +// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long 
> OBJC_IVAR_$_Sub$PrivateIvar;
> +// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
> __declspec(dllimport) unsigned long OBJC_IVAR_$_Sub$nsstring;
> +// CHECK: #pragma warning(disable:4273)
> +// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
> __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$subIvar
> +// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" 
> __declspec(dllexport) unsigned long int OBJC_IVAR_$_Sub$nsstring
> +// CHECK: __declspec(allocate(".objc_ivar$B")) extern "C" unsigned long int 
> OBJC_IVAR_$_Sub$PrivateIvar
> +// CHECK: extern "C" __declspec(dllimport) struct _class_t 
> OBJC_METACLASS_$_NSObject;
> +// CHECK: extern "C" __declspec(dllexport) struct _class_t 
> OBJC_METACLASS_$_Sub
> +// CHECK: extern "C" __declspec(dllimport) struct _class_t 
> OBJC_CLASS_$_NSObject;
> +// CHECK: extern "C" __declspec(dllexport) struct _class_t OBJC_CLASS_$_Sub
> +// CHECK: extern "C" __declspec(dllexport) struct _class_t 
> OBJC_CLASS_$_NSString;
> +// CHECK: extern "C" __declspec(dllexport) struct _class_t 
> 

r306918 - [Modules] Implement ODR-like semantics for tag types in C/ObjC

2017-06-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 30 17:06:47 2017
New Revision: 306918

URL: http://llvm.org/viewvc/llvm-project?rev=306918=rev
Log:
[Modules] Implement ODR-like semantics for tag types in C/ObjC

Allow ODR for ObjC/C in the sense that we won't keep more that
one definition around (merge them). However, ensure the decl
pass the structural compatibility check in C11 6.2.7/1, for that,
reuse the structural equivalence checks used by the ASTImporter.

Few other considerations:
- Create error diagnostics for tag types mismatches and thread
them into the structural equivalence checks.
- Note that by doing this we only support redefinition between types
that are considered "compatible types" by C.

This is mixed approach of the suggestions discussed in
http://lists.llvm.org/pipermail/cfe-dev/2017-March/053257.html

Differential Revision: https://reviews.llvm.org/D31778

rdar://problem/31909368

Added:
cfe/trunk/test/Modules/Inputs/F.framework/
cfe/trunk/test/Modules/Inputs/F.framework/Headers/
cfe/trunk/test/Modules/Inputs/F.framework/Headers/F.h
cfe/trunk/test/Modules/Inputs/F.framework/Modules/
cfe/trunk/test/Modules/Inputs/F.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/F.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/F.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/F.framework/PrivateHeaders/NS.h
cfe/trunk/test/Modules/redefinition-c-tagtypes.m
Modified:
cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/ASTStructuralEquivalence.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Modules/elaborated-type-specifier-from-hidden-module.m
cfe/trunk/test/Modules/redefinition-same-header.m

Modified: cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h?rev=306918=306917=306918=diff
==
--- cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h (original)
+++ cfe/trunk/include/clang/AST/ASTStructuralEquivalence.h Fri Jun 30 17:06:47 
2017
@@ -62,9 +62,11 @@ struct StructuralEquivalenceContext {
   StructuralEquivalenceContext(
   ASTContext , ASTContext ,
   llvm::DenseSet ,
-  bool StrictTypeSpelling = false, bool Complain = true)
+  bool StrictTypeSpelling = false, bool Complain = true,
+  bool ErrorOnTagTypeMismatch = false)
   : FromCtx(FromCtx), ToCtx(ToCtx), NonEquivalentDecls(NonEquivalentDecls),
-StrictTypeSpelling(StrictTypeSpelling), Complain(Complain),
+StrictTypeSpelling(StrictTypeSpelling),
+ErrorOnTagTypeMismatch(ErrorOnTagTypeMismatch), Complain(Complain),
 LastDiagFromC2(false) {}
 
   DiagnosticBuilder Diag1(SourceLocation Loc, unsigned DiagID);

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=306918=306917=306918=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Fri Jun 30 17:06:47 2017
@@ -200,12 +200,17 @@ def note_odr_defined_here : Note<"also d
 def err_odr_function_type_inconsistent : Error<
   "external function %0 declared with incompatible types in different "
   "translation units (%1 vs. %2)">;
-def warn_odr_tag_type_inconsistent : Warning<
-  "type %0 has incompatible definitions in different translation units">,
-  InGroup>;
+def warn_odr_tag_type_inconsistent
+: Warning<"type %0 has incompatible definitions in different translation "
+  "units">,
+  InGroup>;
+def err_odr_tag_type_inconsistent
+: Error<"type %0 has incompatible definitions in different translation "
+"units">;
 def note_odr_tag_kind_here: Note<
   "%0 is a %select{struct|interface|union|class|enum}1 here">;
 def note_odr_field : Note<"field %0 has type %1 here">;
+def note_odr_field_name : Note<"field has name %0 here">;
 def note_odr_missing_field : Note<"no corresponding field here">;
 def note_odr_bit_field : Note<"bit-field %0 with type %1 and length %2 here">;
 def note_odr_not_bit_field : Note<"field %0 is not a bit-field">;

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=306918=306917=306918=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jun 30 17:06:47 2017
@@ -1542,6 +1542,10 @@ public:
 
   bool 

r306917 - Change enumerator default linkage type for C

2017-06-30 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jun 30 17:06:27 2017
New Revision: 306917

URL: http://llvm.org/viewvc/llvm-project?rev=306917=rev
Log:
Change enumerator default linkage type for C

Redeclaration lookup should never find hidden enumerators in C, because
they do not have linkage (C11 6.2.2/6)

The linkage of an enumerator should be VisibleNoLinkage, and
isHiddenDeclarationVisible should be checking hasExternalFormalLinkage.

This is was reviewed as part of D31778, but splitted into a different
commit for clarity.

rdar://problem/31909368

Modified:
cfe/trunk/include/clang/Basic/Visibility.h
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/test/Index/linkage.c

Modified: cfe/trunk/include/clang/Basic/Visibility.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Visibility.h?rev=306917=306916=306917=diff
==
--- cfe/trunk/include/clang/Basic/Visibility.h (original)
+++ cfe/trunk/include/clang/Basic/Visibility.h Fri Jun 30 17:06:27 2017
@@ -75,6 +75,9 @@ public:
   static LinkageInfo none() {
 return LinkageInfo(NoLinkage, DefaultVisibility, false);
   }
+  static LinkageInfo visible_none() {
+return LinkageInfo(VisibleNoLinkage, DefaultVisibility, false);
+  }
 
   Linkage getLinkage() const { return (Linkage)linkage_; }
   Visibility getVisibility() const { return (Visibility)visibility_; }

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=306917=306916=306917=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Fri Jun 30 17:06:27 2017
@@ -275,7 +275,7 @@ public:
   /// declarations, such as those in modules that have not yet been imported.
   bool isHiddenDeclarationVisible(NamedDecl *ND) const {
 return AllowHidden ||
-   (isForRedeclaration() && ND->isExternallyVisible());
+   (isForRedeclaration() && ND->hasExternalFormalLinkage());
   }
 
   /// Sets whether tag declarations should be hidden by non-tag

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=306917=306916=306917=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Fri Jun 30 17:06:27 2017
@@ -1251,7 +1251,9 @@ static LinkageInfo computeLVForDecl(cons
 
 case Decl::EnumConstant:
   // C++ [basic.link]p4: an enumerator has the linkage of its enumeration.
-  return getLVForDecl(cast(D->getDeclContext()), computation);
+  if (D->getASTContext().getLangOpts().CPlusPlus)
+return getLVForDecl(cast(D->getDeclContext()), computation);
+  return LinkageInfo::visible_none();
 
 case Decl::Typedef:
 case Decl::TypeAlias:

Modified: cfe/trunk/test/Index/linkage.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/linkage.c?rev=306917=306916=306917=diff
==
--- cfe/trunk/test/Index/linkage.c (original)
+++ cfe/trunk/test/Index/linkage.c Fri Jun 30 17:06:27 2017
@@ -20,7 +20,7 @@ void f16(void) {
 
 
 // CHECK: EnumDecl=Baz:3:6 (Definition)linkage=External
-// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=External
+// CHECK: EnumConstantDecl=Qux:3:12 (Definition)linkage=NoLinkage
 // CHECK: VarDecl=x:4:5linkage=External
 // CHECK: FunctionDecl=foo:5:6linkage=External
 // CHECK: VarDecl=w:6:12linkage=Internal


___
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.

2017-06-28 Thread Bruno Cardoso Lopes via cfe-commits
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 <
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=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=306582=306583=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 |
> +//  || > |  | < |  |
> +//  ++   +--+   +--+

Re: r303322 - [modules] Switch from inferring owning modules based on source location to

2017-06-21 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, Jun 21, 2017 at 4:56 PM, Richard Smith  wrote:
> On 21 June 2017 at 16:55, Bruno Cardoso Lopes 
> wrote:
>>
>> On Wed, Jun 21, 2017 at 4:44 PM, Richard Smith 
>> wrote:
>> > On 21 June 2017 at 14:51, Bruno Cardoso Lopes 
>> > wrote:
>> >>
>> >> Hi Richard,
>> >>
>> >> Somehow this commit caused some methods in ObjC to do not become
>> >> visible in an interface when compiling with modules on. I filed
>> >> https://bugs.llvm.org/show_bug.cgi?id=33552, any idea what could have
>> >> gone wrong here? `hasVisibleDeclarationImpl` doesn't seem to have
>> >> changed the logic.
>> >
>> >
>> > DeclObjC.cpp is making some incorrect assumptions about what the
>> > isHidden()
>> > flag on Decls means. Looks like we're going to need to move all of the
>> > ObjC
>> > lookup machinery out of DeclObjC into Sema to allow it to perform
>> > correct
>> > visibility checks. (For what it's worth, this would already have been
>> > broken
>> > for Objective-C++ and local submodule visibility mode prior to this
>> > change,
>> > as those modes both have situations where the "Hidden" flag is not the
>> > complete story with regard to whether a declaration is visible in a
>> > particular lookup context.)
>>
>> Oh, that's bad.
>>
>> Is there any workaround we can do on top of this change for now in
>> order to have the previous behavior for non-LSV and ObjC? This is
>> keeping Swift from building against upstream right now.
>
>
> Yes, I'm working on what should (hopefully) be a fairly quick short-term
> fix.

Thanks Richard!

>
>>
>> >> Thanks,
>> >>
>> >> On Wed, May 17, 2017 at 7:29 PM, Richard Smith via cfe-commits
>> >>  wrote:
>> >> > Author: rsmith
>> >> > Date: Wed May 17 21:29:20 2017
>> >> > New Revision: 303322
>> >> >
>> >> > URL: http://llvm.org/viewvc/llvm-project?rev=303322=rev
>> >> > Log:
>> >> > [modules] Switch from inferring owning modules based on source
>> >> > location
>> >> > to
>> >> > inferring based on the current module at the point of creation.
>> >> >
>> >> > This should result in no functional change except when building a
>> >> > preprocessed
>> >> > module (or more generally when using #pragma clang module begin/end
>> >> > to
>> >> > switch
>> >> > module in the middle of a file), in which case it allows us to
>> >> > correctly
>> >> > track
>> >> > the owning module for declarations. We can't map from FileID to
>> >> > module
>> >> > in the
>> >> > preprocessed module case, since all modules would have the same
>> >> > FileID.
>> >> >
>> >> > There are still a couple of remaining places that try to infer a
>> >> > module
>> >> > from a
>> >> > source location; I'll clean those up in follow-up changes.
>> >> >
>> >> > Modified:
>> >> > cfe/trunk/include/clang/AST/ASTContext.h
>> >> > cfe/trunk/include/clang/AST/DeclBase.h
>> >> > cfe/trunk/include/clang/Basic/LangOptions.h
>> >> > cfe/trunk/include/clang/Sema/Sema.h
>> >> > cfe/trunk/include/clang/Serialization/ASTWriter.h
>> >> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> >> > cfe/trunk/lib/Sema/SemaDecl.cpp
>> >> > cfe/trunk/lib/Sema/SemaLookup.cpp
>> >> > cfe/trunk/lib/Sema/SemaTemplate.cpp
>> >> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>> >> > cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> >> > cfe/trunk/test/Modules/preprocess-module.cpp
>> >> > cfe/trunk/test/SemaCXX/modules-ts.cppm
>> >> >
>> >> > Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> >> > URL:
>> >> >
>> >> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322=303321=303322=diff
>> >> >
>> >> >
>> >> > ==
>> >> > --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> >> > +++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 17 21:29:20 2017
>> >> > @@ -935,7 +935,7 @@ public:
>> >> >
>> >> >/// \brief Get the additional modules in which the definition \p
>> >> > Def
>> >> > has
>> >> >/// been merged.
>> >> > -  ArrayRef getModulesWithMergedDefinition(NamedDecl *Def) {
>> >> > +  ArrayRef getModulesWithMergedDefinition(const NamedDecl
>> >> > *Def) {
>> >> >  auto MergedIt = MergedDefModules.find(Def);
>> >> >  if (MergedIt == MergedDefModules.end())
>> >> >return None;
>> >> >
>> >> > Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> >> > URL:
>> >> >
>> >> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322=303321=303322=diff
>> >> >
>> >> >
>> >> > ==
>> >> > --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> >> > +++ cfe/trunk/include/clang/AST/DeclBase.h Wed May 17 21:29:20 2017
>> >> > @@ -332,15 +332,15 @@ private:
>> >> >bool AccessDeclContextSanity() const;
>> >> >
>> >> >  protected:
>> >> > -
>> >> >

Re: r303322 - [modules] Switch from inferring owning modules based on source location to

2017-06-21 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, Jun 21, 2017 at 4:44 PM, Richard Smith  wrote:
> On 21 June 2017 at 14:51, Bruno Cardoso Lopes 
> wrote:
>>
>> Hi Richard,
>>
>> Somehow this commit caused some methods in ObjC to do not become
>> visible in an interface when compiling with modules on. I filed
>> https://bugs.llvm.org/show_bug.cgi?id=33552, any idea what could have
>> gone wrong here? `hasVisibleDeclarationImpl` doesn't seem to have
>> changed the logic.
>
>
> DeclObjC.cpp is making some incorrect assumptions about what the isHidden()
> flag on Decls means. Looks like we're going to need to move all of the ObjC
> lookup machinery out of DeclObjC into Sema to allow it to perform correct
> visibility checks. (For what it's worth, this would already have been broken
> for Objective-C++ and local submodule visibility mode prior to this change,
> as those modes both have situations where the "Hidden" flag is not the
> complete story with regard to whether a declaration is visible in a
> particular lookup context.)

Oh, that's bad.

Is there any workaround we can do on top of this change for now in
order to have the previous behavior for non-LSV and ObjC? This is
keeping Swift from building against upstream right now.

>
>>
>> Thanks,
>>
>> On Wed, May 17, 2017 at 7:29 PM, Richard Smith via cfe-commits
>>  wrote:
>> > Author: rsmith
>> > Date: Wed May 17 21:29:20 2017
>> > New Revision: 303322
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=303322=rev
>> > Log:
>> > [modules] Switch from inferring owning modules based on source location
>> > to
>> > inferring based on the current module at the point of creation.
>> >
>> > This should result in no functional change except when building a
>> > preprocessed
>> > module (or more generally when using #pragma clang module begin/end to
>> > switch
>> > module in the middle of a file), in which case it allows us to correctly
>> > track
>> > the owning module for declarations. We can't map from FileID to module
>> > in the
>> > preprocessed module case, since all modules would have the same FileID.
>> >
>> > There are still a couple of remaining places that try to infer a module
>> > from a
>> > source location; I'll clean those up in follow-up changes.
>> >
>> > Modified:
>> > cfe/trunk/include/clang/AST/ASTContext.h
>> > cfe/trunk/include/clang/AST/DeclBase.h
>> > cfe/trunk/include/clang/Basic/LangOptions.h
>> > cfe/trunk/include/clang/Sema/Sema.h
>> > cfe/trunk/include/clang/Serialization/ASTWriter.h
>> > cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> > cfe/trunk/lib/Sema/SemaDecl.cpp
>> > cfe/trunk/lib/Sema/SemaLookup.cpp
>> > cfe/trunk/lib/Sema/SemaTemplate.cpp
>> > cfe/trunk/lib/Serialization/ASTWriter.cpp
>> > cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> > cfe/trunk/test/Modules/preprocess-module.cpp
>> > cfe/trunk/test/SemaCXX/modules-ts.cppm
>> >
>> > Modified: cfe/trunk/include/clang/AST/ASTContext.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322=303321=303322=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/AST/ASTContext.h (original)
>> > +++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 17 21:29:20 2017
>> > @@ -935,7 +935,7 @@ public:
>> >
>> >/// \brief Get the additional modules in which the definition \p Def
>> > has
>> >/// been merged.
>> > -  ArrayRef getModulesWithMergedDefinition(NamedDecl *Def) {
>> > +  ArrayRef getModulesWithMergedDefinition(const NamedDecl
>> > *Def) {
>> >  auto MergedIt = MergedDefModules.find(Def);
>> >  if (MergedIt == MergedDefModules.end())
>> >return None;
>> >
>> > Modified: cfe/trunk/include/clang/AST/DeclBase.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322=303321=303322=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/AST/DeclBase.h (original)
>> > +++ cfe/trunk/include/clang/AST/DeclBase.h Wed May 17 21:29:20 2017
>> > @@ -332,15 +332,15 @@ private:
>> >bool AccessDeclContextSanity() const;
>> >
>> >  protected:
>> > -
>> >Decl(Kind DK, DeclContext *DC, SourceLocation L)
>> > -: NextInContextAndBits(), DeclCtx(DC),
>> > -  Loc(L), DeclKind(DK), InvalidDecl(0),
>> > -  HasAttrs(false), Implicit(false), Used(false), Referenced(false),
>> > -  Access(AS_none), FromASTFile(0), Hidden(DC &&
>> > cast(DC)->Hidden),
>> > -  IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
>> > -  CacheValidAndLinkage(0)
>> > -  {
>> > +  : NextInContextAndBits(), DeclCtx(DC), Loc(L), DeclKind(DK),
>> > +InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false),
>> > +Referenced(false), Access(AS_none), FromASTFile(0),
>> > +Hidden(DC && cast(DC)->Hidden &&
>> 

Re: r303322 - [modules] Switch from inferring owning modules based on source location to

2017-06-21 Thread Bruno Cardoso Lopes via cfe-commits
Hi Richard,

Somehow this commit caused some methods in ObjC to do not become
visible in an interface when compiling with modules on. I filed
https://bugs.llvm.org/show_bug.cgi?id=33552, any idea what could have
gone wrong here? `hasVisibleDeclarationImpl` doesn't seem to have
changed the logic.

Thanks,

On Wed, May 17, 2017 at 7:29 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Wed May 17 21:29:20 2017
> New Revision: 303322
>
> URL: http://llvm.org/viewvc/llvm-project?rev=303322=rev
> Log:
> [modules] Switch from inferring owning modules based on source location to
> inferring based on the current module at the point of creation.
>
> This should result in no functional change except when building a preprocessed
> module (or more generally when using #pragma clang module begin/end to switch
> module in the middle of a file), in which case it allows us to correctly track
> the owning module for declarations. We can't map from FileID to module in the
> preprocessed module case, since all modules would have the same FileID.
>
> There are still a couple of remaining places that try to infer a module from a
> source location; I'll clean those up in follow-up changes.
>
> Modified:
> cfe/trunk/include/clang/AST/ASTContext.h
> cfe/trunk/include/clang/AST/DeclBase.h
> cfe/trunk/include/clang/Basic/LangOptions.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaLookup.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/test/Modules/preprocess-module.cpp
> cfe/trunk/test/SemaCXX/modules-ts.cppm
>
> Modified: cfe/trunk/include/clang/AST/ASTContext.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=303322=303321=303322=diff
> ==
> --- cfe/trunk/include/clang/AST/ASTContext.h (original)
> +++ cfe/trunk/include/clang/AST/ASTContext.h Wed May 17 21:29:20 2017
> @@ -935,7 +935,7 @@ public:
>
>/// \brief Get the additional modules in which the definition \p Def has
>/// been merged.
> -  ArrayRef getModulesWithMergedDefinition(NamedDecl *Def) {
> +  ArrayRef getModulesWithMergedDefinition(const NamedDecl *Def) {
>  auto MergedIt = MergedDefModules.find(Def);
>  if (MergedIt == MergedDefModules.end())
>return None;
>
> Modified: cfe/trunk/include/clang/AST/DeclBase.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=303322=303321=303322=diff
> ==
> --- cfe/trunk/include/clang/AST/DeclBase.h (original)
> +++ cfe/trunk/include/clang/AST/DeclBase.h Wed May 17 21:29:20 2017
> @@ -332,15 +332,15 @@ private:
>bool AccessDeclContextSanity() const;
>
>  protected:
> -
>Decl(Kind DK, DeclContext *DC, SourceLocation L)
> -: NextInContextAndBits(), DeclCtx(DC),
> -  Loc(L), DeclKind(DK), InvalidDecl(0),
> -  HasAttrs(false), Implicit(false), Used(false), Referenced(false),
> -  Access(AS_none), FromASTFile(0), Hidden(DC && cast(DC)->Hidden),
> -  IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
> -  CacheValidAndLinkage(0)
> -  {
> +  : NextInContextAndBits(), DeclCtx(DC), Loc(L), DeclKind(DK),
> +InvalidDecl(0), HasAttrs(false), Implicit(false), Used(false),
> +Referenced(false), Access(AS_none), FromASTFile(0),
> +Hidden(DC && cast(DC)->Hidden &&
> +   (!cast(DC)->isFromASTFile() ||
> +hasLocalOwningModuleStorage())),
> +IdentifierNamespace(getIdentifierNamespaceForKind(DK)),
> +CacheValidAndLinkage(0) {
>  if (StatisticsEnabled) add(DK);
>}
>
> @@ -698,6 +698,9 @@ public:
>Module *getLocalOwningModule() const {
>  if (isFromASTFile() || !Hidden)
>return nullptr;
> +
> +assert(hasLocalOwningModuleStorage() &&
> +   "hidden local decl but no local module storage");
>  return reinterpret_cast(this)[-1];
>}
>void setLocalOwningModule(Module *M) {
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.h?rev=303322=303321=303322=diff
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.h (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.h Wed May 17 21:29:20 2017
> @@ -168,7 +168,7 @@ public:
>
>/// Do we need to track the owning module for a local declaration?
>bool trackLocalOwningModule() const {
> -return ModulesLocalVisibility;
> +return isCompilingModule() || ModulesLocalVisibility || 

r305875 - Support MS builtins using 'long' on LP64 platforms

2017-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Jun 20 21:20:46 2017
New Revision: 305875

URL: http://llvm.org/viewvc/llvm-project?rev=305875=rev
Log:
Support MS builtins using 'long' on LP64 platforms

This allows for -fms-extensions to work the same on LP64. For example,
_BitScanReverse is expected to be 32-bit, matching Windows/LLP64, even
though long is 64-bit on x86_64 Darwin or Linux (LP64).

Implement this by adding a new character code 'N', which is 'int' if
the target is LP64 and the same 'L' otherwise

Differential Revision: https://reviews.llvm.org/D34377

rdar://problem/32599746

Added:
cfe/trunk/test/CodeGen/ms-intrinsics-other.c
Removed:
cfe/trunk/test/CodeGen/pr27892.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/include/clang/Basic/BuiltinsX86_64.def
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=305875=305874=305875=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Jun 20 21:20:46 2017
@@ -52,6 +52,7 @@
 //  LL  -> long long
 //  LLL -> __int128_t (e.g. LLLi)
 //  W   -> int64_t
+//  N   -> 'int' size if target is LP64, 'L' otherwise.
 //  S   -> signed
 //  U   -> unsigned
 //  I   -> Required to constant fold to an integer constant expression.
@@ -718,11 +719,11 @@ BUILTIN(__builtin_rindex, "c*cC*i", "Fn"
 LANGBUILTIN(_alloca,  "v*z", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__assume, "vb",  "n", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_ushort, "UsUs", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
-LIBBUILTIN(_byteswap_ulong,  "ULiULi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)
+LIBBUILTIN(_byteswap_ulong,  "UNiUNi",   "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LIBBUILTIN(_byteswap_uint64, "ULLiULLi", "fnc", "stdlib.h", ALL_MS_LANGUAGES)
 LANGBUILTIN(__debugbreak, "v",   "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(__exception_code, "ULi", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_exception_code,  "ULi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(__exception_code, "UNi", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_exception_code,  "UNi", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__exception_info, "v*",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_exception_info,  "v*",  "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(__abnormal_termination, "i", "n", ALL_MS_LANGUAGES)
@@ -730,33 +731,33 @@ LANGBUILTIN(_abnormal_termination,  "i",
 LANGBUILTIN(__GetExceptionInfo, "v*.", "ntu", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedAnd8,   "ccD*c","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedAnd16,  "ssD*s","n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedAnd,"LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedAnd,"NiNiD*Ni", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange8,   "ccD*cc", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange16,  "ssD*ss", "n", 
ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedCompareExchange,"LiLiD*LiLi", "n", 
ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedCompareExchange,"NiNiD*NiNi", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchange64,  "LLiLLiD*LLiLLi", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedCompareExchangePointer, "v*v*D*v*v*", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedDecrement16,"ssD*", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedDecrement,  "LiLiD*",   "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedExchange,   "LiLiD*Li", "n", 
ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedDecrement,  "NiNiD*",   "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchange,   "NiNiD*Ni", "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchange8,  "ccD*c","n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchange16, "ssD*s","n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeAdd8,   "ccD*c",  "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeAdd16,  "ssD*s",  "n", 
ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedExchangeAdd,"LiLiD*Li",   "n", 
ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangeAdd,"NiNiD*Ni",   "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangePointer,"v*v*D*v*",   "n", 
ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeSub8,   "ccD*c","n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedExchangeSub16,  "ssD*s","n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedExchangeSub,"LiLiD*Li", "n", ALL_MS_LANGUAGES)
+LANGBUILTIN(_InterlockedExchangeSub,"NiNiD*Ni", "n", ALL_MS_LANGUAGES)
 LANGBUILTIN(_InterlockedIncrement16,"ssD*", "n", ALL_MS_LANGUAGES)
-LANGBUILTIN(_InterlockedIncrement, 

r305874 - Run dos2unix on ms-intrinsics-rotations.c test. NFC

2017-06-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Jun 20 21:20:40 2017
New Revision: 305874

URL: http://llvm.org/viewvc/llvm-project?rev=305874=rev
Log:
Run dos2unix on ms-intrinsics-rotations.c test. NFC

Modified:
cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c

Modified: cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c?rev=305874=305873=305874=diff
==
--- cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c (original)
+++ cfe/trunk/test/CodeGen/ms-intrinsics-rotations.c Tue Jun 20 21:20:40 2017
@@ -1,181 +1,181 @@
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple thumbv7--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--windows -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple i686--linux -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
+// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-32BIT-LONG
 // RUN: %clang_cc1 -ffreestanding -fms-extensions -fms-compatibility 
-fms-compatibility-version=17.00 \
 // RUN: -triple x86_64--linux -emit-llvm %s -o - \
-// RUN: | FileCheck %s --check-prefixes CHECK,CHECK-64BIT-LONG
-
-// rotate left
-
-unsigned char test_rotl8(unsigned char value, unsigned char shift) {
-  return _rotl8(value, shift);
-}
-// CHECK: i8 @test_rotl8
-// CHECK:   [[SHIFT:%[0-9]+]] = and i8 %{{[0-9]+}}, 7
-// CHECK:   [[NEGSHIFT:%[0-9]+]] = sub i8 8, [[SHIFT]]
-// CHECK:   [[HIGH:%[0-9]+]] = shl i8 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK:   [[LOW:%[0-9]+]] = lshr i8 [[VALUE]], [[NEGSHIFT]]
-// CHECK:   [[ROTATED:%[0-9]+]] = or i8 [[HIGH]], [[LOW]]
-// CHECK:   [[ISZERO:%[0-9]+]] = icmp eq i8 [[SHIFT]], 0
-// CHECK:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i8 [[VALUE]], i8 
[[ROTATED]]
-// CHECK:   ret i8 [[RESULT]]
-// CHECK  }
-
-unsigned short test_rotl16(unsigned short value, unsigned char shift) {
-  return _rotl16(value, shift);
-}
-// CHECK: i16 @test_rotl16
-// CHECK:   [[SHIFT:%[0-9]+]] = and i16 %{{[0-9]+}}, 15
-// CHECK:   [[NEGSHIFT:%[0-9]+]] = sub i16 16, [[SHIFT]]
-// CHECK:   [[HIGH:%[0-9]+]] = shl i16 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK:   [[LOW:%[0-9]+]] = lshr i16 [[VALUE]], [[NEGSHIFT]]
-// CHECK:   [[ROTATED:%[0-9]+]] = or i16 [[HIGH]], [[LOW]]
-// CHECK:   [[ISZERO:%[0-9]+]] = icmp eq i16 [[SHIFT]], 0
-// CHECK:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i16 [[VALUE]], i16 
[[ROTATED]]
-// CHECK:   ret i16 [[RESULT]]
-// CHECK  }
-
-unsigned int test_rotl(unsigned int value, int shift) {
-  return _rotl(value, shift);
-}
-// CHECK: i32 @test_rotl
-// CHECK:   [[SHIFT:%[0-9]+]] = and i32 %{{[0-9]+}}, 31
-// CHECK:   [[NEGSHIFT:%[0-9]+]] = sub i32 32, [[SHIFT]]
-// CHECK:   [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK:   [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[NEGSHIFT]]
-// CHECK:   [[ROTATED:%[0-9]+]] = or i32 [[HIGH]], [[LOW]]
-// CHECK:   [[ISZERO:%[0-9]+]] = icmp eq i32 [[SHIFT]], 0
-// CHECK:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i32 [[VALUE]], i32 
[[ROTATED]]
-// CHECK:   ret i32 [[RESULT]]
-// CHECK  }
-
-unsigned long test_lrotl(unsigned long value, int shift) {
-  return _lrotl(value, shift);
-}
-// CHECK-32BIT-LONG: i32 @test_lrotl
-// CHECK-32BIT-LONG:   [[SHIFT:%[0-9]+]] = and i32 %{{[0-9]+}}, 31
-// CHECK-32BIT-LONG:   [[NEGSHIFT:%[0-9]+]] = sub i32 32, [[SHIFT]]
-// CHECK-32BIT-LONG:   [[HIGH:%[0-9]+]] = shl i32 [[VALUE:%[0-9]+]], [[SHIFT]]
-// CHECK-32BIT-LONG:   [[LOW:%[0-9]+]] = lshr i32 [[VALUE]], [[NEGSHIFT]]
-// CHECK-32BIT-LONG:   [[ROTATED:%[0-9]+]] = or i32 [[HIGH]], [[LOW]]
-// CHECK-32BIT-LONG:   [[ISZERO:%[0-9]+]] = icmp eq i32 [[SHIFT]], 0
-// CHECK-32BIT-LONG:   [[RESULT:%[0-9]+]] = select i1 [[ISZERO]], i32 
[[VALUE]], i32 [[ROTATED]]
-// CHECK-32BIT-LONG:   ret i32 [[RESULT]]
-// CHECK-32BIT-LONG  }
-
-// CHECK-64BIT-LONG: i64 @test_lrotl
-// CHECK-64BIT-LONG:   [[SHIFT:%[0-9]+]] = and i64 %{{[0-9]+}}, 63
-// CHECK-64BIT-LONG:   [[NEGSHIFT:%[0-9]+]] = sub i64 64, [[SHIFT]]
-// CHECK-64BIT-LONG:   [[HIGH:%[0-9]+]] = 

Re: r284060 - Implement MS _BitScan intrinsics

2017-06-19 Thread Bruno Cardoso Lopes via cfe-commits
On Fri, Jun 16, 2017 at 5:08 PM, Duncan P. N. Exon Smith
 wrote:
>
> On Jun 16, 2017, at 11:02, Reid Kleckner  wrote:
>
> We should fix it.
>
>
> Agreed.
>
> We just need a new character code in the builtin function prototype
> encoding. Currently there is no encoding for a portable int32_t that
> magically becomes "long" on 32-bit Windows. The closest thing we have is
> 'W', which is used by Neon intrinsics to select between "long" and "long
> long". It was added in r202004.
>
>
> Yup, I saw the 'W' as well.  That's the same approach I was using in a patch
> yesterday morning (I picked lowercase L ('l'), but there may be a better
> choice).  Likely Bruno will follow up with a working patch soon (I hit some
> problems with tests and then got tied up).

Right, here it is: https://reviews.llvm.org/D34377

Let me know what you guys think!

>
> On Fri, Jun 16, 2017 at 10:28 AM, Erik Schwiebert 
> wrote:
>>
>> We (Office developers for Apple platforms at Microsoft) would prefer to
>> have the intrinsics work properly for LP64, as that will generate the most
>> optimal and efficient code. That said, we understand that this may be odd to
>> implement from the compiler's perspective and can work around it if the
>> intrinsics are not supported for ms-extensions+LP64. At the end of the day
>> we need the compiler to clearly adopt one of those two options, and not sit
>> somewhere in the middle as it currently does. We don't turn on any flags
>> other than -fms-extensions; we don’t attempt to define MSC_VER and we do
>> conditionalize code based on __clang__ so the code is aware it is being
>> compiled by clang vs MSVC.
>>
>> So I think we'd prefer what Duncan and Apple are offering to do, but if
>> the larger clang community thinks that is a bad idea and wants to explicitly
>> disable the intrinsics, we could live with that.
>>
>> Thanks,
>> Schwieb
>>
>> -Original Message-
>> From: Erik Schwiebert
>> Sent: Friday, June 16, 2017 8:49 AM
>> To: 'Bruno Cardoso Lopes' ; Brian Kelley
>> ; Tomasz Kukielka 
>> Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits
>> 
>> Subject: RE: r284060 - Implement MS _BitScan intrinsics
>>
>> Adding Brian and Tomasz. I'm pretty sure we have the Windows SDK
>> intrinsics headers. I'm not sure which method we'd prefer, so I'll walk down
>> the hall and ask them. Tomasz is our header maestro (because we play crazy
>> #include_next games so we can use both Windows and macOS SDKs!)
>>
>> We'll get back to you ASAP.
>>
>> Schwieb
>>
>> -Original Message-
>> From: Bruno Cardoso Lopes [mailto:bruno.card...@gmail.com]
>> Sent: Thursday, June 15, 2017 4:41 PM
>> To: Erik Schwiebert 
>> Cc: dexonsm...@apple.com; Reid Kleckner ; cfe-commits
>> 
>> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>>
>> On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
>>  wrote:
>> > On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
>> >  wrote:
>> >> SGTM too. Regarding Duncan's last question -- I can't think of any such
>> >> customer. :) If you all think the right thing for clang to do is to infer
>> >> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with 
>> >> me!
>>
>> Thinking more about this; what if we mark such builtins as unsupported
>> for "LP64 (Darwin) + ms_extensions" and then you provide the
>> definitions via intrin.h (we can generate a compiler macro for this
>> scenario and conditionalize the include_next as we do for _MSC_VER)?
>> Do you use this header at all? Are there any other MS related flags
>> that get passed to the compiler?
>>
>> > SGTM as well!
>> >
>> >>
>> >> Thanks all!
>> >> Schwieb
>> >>
>> >> -Original Message-
>> >> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
>> >> Sent: Monday, June 12, 2017 1:55 PM
>> >> To: Reid Kleckner 
>> >> Cc: Saleem Abdulrasool ; Albert Gutowski
>> >> ; David Majnemer ;
>> >> cfe-commits ; Erik Schwiebert
>> >> 
>> >> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>> >>
>> >>
>> >>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>> >>>
>>  On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool
>>   wrote:
>>  I'm worried about changing this signature all the time.  I suspect
>>  that it will cause the following to be emitted for valid code:
>> 
>>  warning: incompatible pointer types passing 'unsigned long *' to
>>  parameter of type 'unsigned int *' [-Wincompatible-pointer-types]
>> 
>>  Switching the signature on LP64 sounds much better to me.
>> >>>
>> >>> 

Re: r284060 - Implement MS _BitScan intrinsics

2017-06-15 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Jun 13, 2017 at 8:13 PM, Bruno Cardoso Lopes
 wrote:
> On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
>  wrote:
>> SGTM too. Regarding Duncan's last question -- I can't think of any such 
>> customer. :) If you all think the right thing for clang to do is to infer 
>> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!

Thinking more about this; what if we mark such builtins as unsupported
for "LP64 (Darwin) + ms_extensions" and then you provide the
definitions via intrin.h (we can generate a compiler macro for this
scenario and conditionalize the include_next as we do for _MSC_VER)?
Do you use this header at all? Are there any other MS related flags
that get passed to the compiler?

> SGTM as well!
>
>>
>> Thanks all!
>> Schwieb
>>
>> -Original Message-
>> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
>> Sent: Monday, June 12, 2017 1:55 PM
>> To: Reid Kleckner 
>> Cc: Saleem Abdulrasool ; Albert Gutowski 
>> ; David Majnemer ; 
>> cfe-commits ; Erik Schwiebert 
>> 
>> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>>
>>
>>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>>>
 On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool  
 wrote:
 I'm worried about changing this signature all the time.  I suspect that it 
 will cause the following to be emitted for valid code:

 warning: incompatible pointer types passing 'unsigned long *' to parameter 
 of type 'unsigned int *' [-Wincompatible-pointer-types]

 Switching the signature on LP64 sounds much better to me.
>>>
>>> Right, we have to do this. It needs to be `long` on Windows.
>>
>> SGTM.  We'll go that way.
>
> +1 here!
>
>>> On Jun 8, 2017, at 12:21, Erik Schwiebert  wrote:
>>>
>>> It’s probably also better to not try to infer our weird desired behavior. 
>>> It should probably be controlled by a specific driver directive, like 
>>> “-fms-extensions-lp64-intrinsics” or something like that. Using a new 
>>> directive means that nobody can accidentally get this behavior if they for 
>>> some reason do want LLP64 behavior with Windows intrinsics.
>>
>> This seems overly complicated.  Is there a customer that:
>> - is on LP64,
>> - is using -fms-extensions,
>> - is using these intrinsics, and
>> - wants them to be 64-bit longs instead of 32-bit ints?
>> Put another way: who would use these intrinsics on LP64 and *not* want to 
>> mimic LLP64?
>>
>> If everyone using the intrinsics on LP64 is going to have to specify 
>> -fms-extensions-lp64-intrinsics, then we should just imply it.
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r284060 - Implement MS _BitScan intrinsics

2017-06-13 Thread Bruno Cardoso Lopes via cfe-commits
On Mon, Jun 12, 2017 at 2:01 PM, Erik Schwiebert via cfe-commits
 wrote:
> SGTM too. Regarding Duncan's last question -- I can't think of any such 
> customer. :) If you all think the right thing for clang to do is to infer 
> LLP64 behavior on LP64 (Darwin) + ms_extensions, then that is fine with me!

SGTM as well!

>
> Thanks all!
> Schwieb
>
> -Original Message-
> From: dexonsm...@apple.com [mailto:dexonsm...@apple.com]
> Sent: Monday, June 12, 2017 1:55 PM
> To: Reid Kleckner 
> Cc: Saleem Abdulrasool ; Albert Gutowski 
> ; David Majnemer ; 
> cfe-commits ; Erik Schwiebert 
> 
> Subject: Re: r284060 - Implement MS _BitScan intrinsics
>
>
>> On Jun 12, 2017, at 12:44, Reid Kleckner  wrote:
>>
>>> On Wed, Jun 7, 2017 at 7:31 PM, Saleem Abdulrasool  
>>> wrote:
>>> I'm worried about changing this signature all the time.  I suspect that it 
>>> will cause the following to be emitted for valid code:
>>>
>>> warning: incompatible pointer types passing 'unsigned long *' to parameter 
>>> of type 'unsigned int *' [-Wincompatible-pointer-types]
>>>
>>> Switching the signature on LP64 sounds much better to me.
>>
>> Right, we have to do this. It needs to be `long` on Windows.
>
> SGTM.  We'll go that way.

+1 here!

>> On Jun 8, 2017, at 12:21, Erik Schwiebert  wrote:
>>
>> It’s probably also better to not try to infer our weird desired behavior. It 
>> should probably be controlled by a specific driver directive, like 
>> “-fms-extensions-lp64-intrinsics” or something like that. Using a new 
>> directive means that nobody can accidentally get this behavior if they for 
>> some reason do want LLP64 behavior with Windows intrinsics.
>
> This seems overly complicated.  Is there a customer that:
> - is on LP64,
> - is using -fms-extensions,
> - is using these intrinsics, and
> - wants them to be 64-bit longs instead of 32-bit ints?
> Put another way: who would use these intrinsics on LP64 and *not* want to 
> mimic LLP64?
>
> If everyone using the intrinsics on LP64 is going to have to specify 
> -fms-extensions-lp64-intrinsics, then we should just imply it.
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r303630 - Allow to use vfs::FileSystem for file accesses inside ASTUnit.

2017-05-24 Thread Bruno Cardoso Lopes via cfe-commits
On Wed, May 24, 2017 at 12:18 AM, Ilya Biryukov  wrote:
> We test it in clangd (https://reviews.llvm.org/D33416).
> Logically, it's  a single change, split into two part: for cfe and
> clang-tools-extra.

I see, thanks!

>
> On Wed, May 24, 2017 at 1:48 AM, Bruno Cardoso Lopes
>  wrote:
>>
>> Any specific reason why this doesn't contain a testcase?
>>
>> On Tue, May 23, 2017 at 4:37 AM, Ilya Biryukov via cfe-commits
>>  wrote:
>> > Author: ibiryukov
>> > Date: Tue May 23 06:37:52 2017
>> > New Revision: 303630
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=303630=rev
>> > Log:
>> > Allow to use vfs::FileSystem for file accesses inside ASTUnit.
>> >
>> > Reviewers: bkramer, krasimir, arphaman, akyrtzi
>> >
>> > Reviewed By: bkramer
>> >
>> > Subscribers: klimek, cfe-commits
>> >
>> > Differential Revision: https://reviews.llvm.org/D33397
>> >
>> > Modified:
>> > cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > cfe/trunk/include/clang/Frontend/CompilerInvocation.h
>> > cfe/trunk/lib/Frontend/ASTUnit.cpp
>> > cfe/trunk/lib/Frontend/CompilerInvocation.cpp
>> >
>> > Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
>> > URL:
>> > http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=303630=303629=303630=diff
>> >
>> > ==
>> > --- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
>> > +++ cfe/trunk/include/clang/Frontend/ASTUnit.h Tue May 23 06:37:52 2017
>> > @@ -59,6 +59,10 @@ class TargetInfo;
>> >  class FrontendAction;
>> >  class ASTDeserializationListener;
>> >
>> > +namespace vfs {
>> > +class FileSystem;
>> > +}
>> > +
>> >  /// \brief Utility class for loading a ASTContext from an AST file.
>> >  ///
>> >  class ASTUnit : public ModuleLoader {
>> > @@ -420,7 +424,8 @@ private:
>> >explicit ASTUnit(bool MainFileIsAST);
>> >
>> >bool Parse(std::shared_ptr PCHContainerOps,
>> > - std::unique_ptr OverrideMainBuffer);
>> > + std::unique_ptr OverrideMainBuffer,
>> > + IntrusiveRefCntPtr VFS);
>> >
>> >struct ComputedPreamble {
>> >  llvm::MemoryBuffer *Buffer;
>> > @@ -434,11 +439,13 @@ private:
>> >PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
>> >};
>> >ComputedPreamble ComputePreamble(CompilerInvocation ,
>> > -   unsigned MaxLines);
>> > +   unsigned MaxLines,
>> > +   IntrusiveRefCntPtr
>> > VFS);
>> >
>> >std::unique_ptr
>> > getMainBufferWithPrecompiledPreamble(
>> >std::shared_ptr PCHContainerOps,
>> > -  const CompilerInvocation , bool AllowRebuild
>> > = true,
>> > +  const CompilerInvocation ,
>> > +  IntrusiveRefCntPtr VFS, bool AllowRebuild =
>> > true,
>> >unsigned MaxLines = 0);
>> >void RealizeTopLevelDeclsFromPreamble();
>> >
>> > @@ -731,11 +738,17 @@ private:
>> >/// of this translation unit should be precompiled, to improve the
>> > performance
>> >/// of reparsing. Set to zero to disable preambles.
>> >///
>> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
>> > Note that
>> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
>> > so in order
>> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
>> > be an
>> > +  /// overlay over RealFileSystem).
>> > +  ///
>> >/// \returns \c true if a catastrophic failure occurred (which means
>> > that the
>> >/// \c ASTUnit itself is invalid), or \c false otherwise.
>> >bool LoadFromCompilerInvocation(
>> >std::shared_ptr PCHContainerOps,
>> > -  unsigned PrecompilePreambleAfterNParses);
>> > +  unsigned PrecompilePreambleAfterNParses,
>> > +  IntrusiveRefCntPtr VFS);
>> >
>> >  public:
>> >
>> > @@ -826,6 +839,11 @@ public:
>> >/// (e.g. because the PCH could not be loaded), this accepts the
>> > ASTUnit
>> >/// mainly to allow the caller to see the diagnostics.
>> >///
>> > +  /// \param VFS - A vfs::FileSystem to be used for all file accesses.
>> > Note that
>> > +  /// preamble is saved to a temporary directory on a RealFileSystem,
>> > so in order
>> > +  /// for it to be loaded correctly, VFS should have access to it(i.e.,
>> > be an
>> > +  /// overlay over RealFileSystem). RealFileSystem will be used if \p
>> > VFS is nullptr.
>> > +  ///
>> >// FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the
>> > ASTUnit, we
>> >// shouldn't need to specify them at construction time.
>> >static ASTUnit *LoadFromCommandLine(
>> > @@ -842,15 +860,23 @@ public:
>> >bool AllowPCHWithCompilerErrors = false, bool SkipFunctionBodies
>> > = false,
>> >bool UserFilesAreVolatile = false, bool ForSerialization = false,
>> >llvm::Optional ModuleFormat = llvm::None,
>> > -  

r302771 - Make tests from r302765 windows friendly

2017-05-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu May 11 02:06:52 2017
New Revision: 302771

URL: http://llvm.org/viewvc/llvm-project?rev=302771=rev
Log:
Make tests from r302765 windows friendly

and appease:
http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/2030

Modified:
cfe/trunk/test/Modules/redefinition-same-header.m
cfe/trunk/test/Sema/redefinition-same-header.c
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/test/Modules/redefinition-same-header.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/redefinition-same-header.m?rev=302771=302770=302771=diff
==
--- cfe/trunk/test/Modules/redefinition-same-header.m (original)
+++ cfe/trunk/test/Modules/redefinition-same-header.m Thu May 11 02:06:52 2017
@@ -3,18 +3,18 @@
 // RUN:   -fimplicit-module-maps -fmodules-cache-path=%t.tmp %s -verify
 
 // expected-error@Inputs/SameHeader/C.h:3 {{redefinition of 'c'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}/C.h' included multiple 
times, additional include site in header from module 'X.B'}}
+// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple 
times, additional include site in header from module 'X.B'}}
 // expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}/C.h' included 
multiple times, additional include site here}}
+// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included 
multiple times, additional include site here}}
 
 // expected-error@Inputs/SameHeader/C.h:5 {{redefinition of 'aaa'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}/C.h' included multiple 
times, additional include site in header from module 'X.B'}}
+// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple 
times, additional include site in header from module 'X.B'}}
 // expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}/C.h' included 
multiple times, additional include site here}}
+// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included 
multiple times, additional include site here}}
 
 // expected-error@Inputs/SameHeader/C.h:9 {{redefinition of 'fd_set'}}
-// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}/C.h' included multiple 
times, additional include site in header from module 'X.B'}}
+// expected-note-re@Inputs/SameHeader/B.h:3 {{'{{.*}}C.h' included multiple 
times, additional include site in header from module 'X.B'}}
 // expected-note@Inputs/SameHeader/module.modulemap:6 {{X.B defined here}}
-// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}/C.h' included 
multiple times, additional include site here}}
+// expected-note-re@redefinition-same-header.m:20 {{'{{.*}}C.h' included 
multiple times, additional include site here}}
 #include "A.h" // maps to a modular
 #include "C.h" // textual include

Modified: cfe/trunk/test/Sema/redefinition-same-header.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/redefinition-same-header.c?rev=302771=302770=302771=diff
==
--- cfe/trunk/test/Sema/redefinition-same-header.c (original)
+++ cfe/trunk/test/Sema/redefinition-same-header.c Thu May 11 02:06:52 2017
@@ -5,8 +5,8 @@
 
 // expected-error@a.h:1 {{redefinition of 'yyy'}}
 // expected-note@a.h:1 {{unguarded header; consider using #ifdef guards or 
#pragma once}}
-// expected-note-re@redefinition-same-header.c:11 {{'{{.*}}/a.h' included 
multiple times, additional include site here}}
-// expected-note-re@redefinition-same-header.c:12 {{'{{.*}}/a.h' included 
multiple times, additional include site here}}
+// expected-note-re@redefinition-same-header.c:11 {{'{{.*}}a.h' included 
multiple times, additional include site here}}
+// expected-note-re@redefinition-same-header.c:12 {{'{{.*}}a.h' included 
multiple times, additional include site here}}
 
 #include "a.h"
 #include "a.h"

Modified: cfe/trunk/test/SemaCXX/modules-ts.cppm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/modules-ts.cppm?rev=302771=302770=302771=diff
==
--- cfe/trunk/test/SemaCXX/modules-ts.cppm (original)
+++ cfe/trunk/test/SemaCXX/modules-ts.cppm Thu May 11 02:06:52 2017
@@ -18,7 +18,7 @@ int n;
 #if TEST >= 2
 // expected-error@-2 {{redefinition of '}}
 // expected-note@-3 {{unguarded header; consider using #ifdef guards or 
#pragma once}}
-// expected-note...@modules-ts.cppm:1 {{'{{.*}}/modules-ts.cppm' included 
multiple times, additional include site here}}
+// expected-note...@modules-ts.cppm:1 {{'{{.*}}modules-ts.cppm' included 
multiple times, additional include site here}}
 #endif
 
 #if TEST == 0


___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r302765 - [Sema] Improve redefinition errors pointing to the same header

2017-05-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu May 11 01:20:07 2017
New Revision: 302765

URL: http://llvm.org/viewvc/llvm-project?rev=302765=rev
Log:
[Sema] Improve redefinition errors pointing to the same header

Diagnostics related to redefinition errors that point to the same header
file do not provide much information that helps users fixing the issue.

- In the modules context, it usually happens because of non modular
includes.
- When modules aren't involved it might happen because of the lack of
header guards.

Enhance diagnostics in these scenarios.

Differential Revision: https://reviews.llvm.org/D28832

rdar://problem/31669175

Added:
cfe/trunk/test/Modules/Inputs/SameHeader/
cfe/trunk/test/Modules/Inputs/SameHeader/A.h
cfe/trunk/test/Modules/Inputs/SameHeader/B.h
cfe/trunk/test/Modules/Inputs/SameHeader/C.h
cfe/trunk/test/Modules/Inputs/SameHeader/module.modulemap
cfe/trunk/test/Modules/redefinition-same-header.m
cfe/trunk/test/Sema/redefinition-same-header.c
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302765=302764=302765=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May 11 01:20:07 
2017
@@ -4609,6 +4609,8 @@ def err_abi_tag_on_redeclaration : Error
   "cannot add 'abi_tag' attribute in a redeclaration">;
 def err_new_abi_tag_on_redeclaration : Error<
   "'abi_tag' %0 missing in original declaration">;
+def note_use_ifdef_guards : Note<
+  "unguarded header; consider using #ifdef guards or #pragma once">;
 
 def note_deleted_dtor_no_operator_delete : Note<
   "virtual destructor requires an unambiguous, accessible 'operator delete'">;
@@ -,6 +8890,13 @@ def ext_equivalent_internal_linkage_decl
   InGroup>;
 def note_equivalent_internal_linkage_decl : Note<
   "declared here%select{ in module '%1'|}0">;
+
+def note_redefinition_modules_same_file : Note<
+   "'%0' included multiple times, additional include site in header from 
module '%1'">;
+def note_redefinition_modules_same_file_modulemap : Note<
+   "consider adding '%0' as part of '%1' definition">;
+def note_redefinition_include_same_file : Note<
+   "'%0' included multiple times, additional include site here">;
 }
 
 let CategoryName = "Coroutines Issue" in {

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=302765=302764=302765=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Thu May 11 01:20:07 2017
@@ -2353,6 +2353,7 @@ public:
   void MergeVarDeclTypes(VarDecl *New, VarDecl *Old, bool MergeTypeWithOld);
   void MergeVarDeclExceptionSpecs(VarDecl *New, VarDecl *Old);
   bool checkVarDeclRedefinition(VarDecl *OldDefn, VarDecl *NewDefn);
+  void notePreviousDefinition(SourceLocation Old, SourceLocation New);
   bool MergeCXXFunctionDecl(FunctionDecl *New, FunctionDecl *Old, Scope *S);
 
   // AssignmentAction - This is used by all the assignment diagnostic functions

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=302765=302764=302765=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Thu May 11 01:20:07 2017
@@ -2021,7 +2021,7 @@ bool Sema::isIncompatibleTypedef(TypeDec
 Diag(New->getLocation(), diag::err_redefinition_variably_modified_typedef)
   << Kind << NewType;
 if (Old->getLocation().isValid())
-  Diag(Old->getLocation(), diag::note_previous_definition);
+  notePreviousDefinition(Old->getLocation(), New->getLocation());
 New->setInvalidDecl();
 return true;
   }
@@ -2034,7 +2034,7 @@ bool Sema::isIncompatibleTypedef(TypeDec
 Diag(New->getLocation(), diag::err_redefinition_different_typedef)
   << Kind << NewType << OldType;
 if (Old->getLocation().isValid())
-  Diag(Old->getLocation(), diag::note_previous_definition);
+  notePreviousDefinition(Old->getLocation(), New->getLocation());
 New->setInvalidDecl();
 return true;
   }
@@ -2101,7 +2101,7 @@ void Sema::MergeTypedefNameDecl(Scope *S
 
 NamedDecl *OldD = OldDecls.getRepresentativeDecl();
 if (OldD->getLocation().isValid())
-  Diag(OldD->getLocation(), diag::note_previous_definition);
+  notePreviousDefinition(OldD->getLocation(), New->getLocation());
 
 return New->setInvalidDecl();

r302491 - [Modules] Allow umbrella frameworks to define private submodules for subframeworks

2017-05-08 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon May  8 19:41:38 2017
New Revision: 302491

URL: http://llvm.org/viewvc/llvm-project?rev=302491=rev
Log:
[Modules] Allow umbrella frameworks to define private submodules for 
subframeworks

In r298391 we fixed the umbrella framework model to work when submodules
named "Private" are used. This complements the work by allowing the
umbrella framework model to work in general.

rdar://problem/31790067

Added:
cfe/trunk/test/Modules/Inputs/MainA.framework/
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h

cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h
cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/
cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/A.h
cfe/trunk/test/Modules/Inputs/MainA.framework/Headers/Main.h
cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/
cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/MainA.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/APriv.h
cfe/trunk/test/Modules/Inputs/MainA.framework/PrivateHeaders/MainPriv.h
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/test/Modules/find-privateheaders.m

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=302491=302490=302491=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Mon May  8 19:41:38 2017
@@ -1913,8 +1913,10 @@ void ModuleMapParser::parseHeaderDecl(MM
 // 'framework module FrameworkName.Private', since a 
'Private.Framework'
 // does not usually exist. However, since both are currently widely 
used
 // for private modules, make sure we find the right path in both cases.
-RelativePathName.resize(ActiveModule->IsFramework ? 0
-  : 
RelativePathLength);
+if (ActiveModule->IsFramework && ActiveModule->Name == "Private")
+  RelativePathName.clear();
+else
+  RelativePathName.resize(RelativePathLength);
 FullPathName.resize(FullPathLength);
 llvm::sys::path::append(RelativePathName, "PrivateHeaders",
 Header.FileName);

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h?rev=302491=auto
==
--- 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/B.h
 Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// B.h

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h?rev=302491=auto
==
--- 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/Headers/Sub.h
 Mon May  8 19:41:38 2017
@@ -0,0 +1,2 @@
+// Sub.h
+#import "B.h"

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h?rev=302491=auto
==
--- 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h
 Mon May  8 19:41:38 2017
@@ -0,0 +1 @@
+// BPriv.h

Added: 
cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/MainA.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h?rev=302491=auto

Re: r301613 - clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path separator \\, since r301597.

2017-04-27 Thread Bruno Cardoso Lopes via cfe-commits
Thanks!!

On Thu, Apr 27, 2017 at 9:17 PM, NAKAMURA Takumi via cfe-commits
 wrote:
> Author: chapuni
> Date: Thu Apr 27 23:17:31 2017
> New Revision: 301613
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301613=rev
> Log:
> clang/test/Index/index-module.m: Relax expressions to satisfy DOSish path 
> separator \\, since r301597.
>
> Modified:
> cfe/trunk/test/Index/index-module.m
>
> Modified: cfe/trunk/test/Index/index-module.m
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-module.m?rev=301613=301612=301613=diff
> ==
> --- cfe/trunk/test/Index/index-module.m (original)
> +++ cfe/trunk/test/Index/index-module.m Thu Apr 27 23:17:31 2017
> @@ -28,7 +28,7 @@ int glob;
>  // CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_OTHER_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]other\.h]]
>  | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule
>  // CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_NOT_CXX_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Headers[/\\]not_cxx\.h]]
>  | {{.*}} | hash loc:  | {{.*}} | module: DependsOnModule.NotCXX
>  // CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_SUB_H:.*/Modules/Inputs/DependsOnModule\.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]SubFramework\.h]]
>  | {{.*}} | hash loc:  | {{.*}} | module: 
> DependsOnModule.SubFramework
> -// CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks/SubFramework\.framework/Headers/Other\.h]]
>  | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 
> | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
> +// CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_SUB_OTHER_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]Frameworks[/\\]SubFramework\.framework[/\\]Headers[/\\]Other\.h]]
>  | name: "SubFramework/Other.h" | hash loc: [[DMOD_SUB_H]]:1:1 | isImport: 0 
> | isAngled: 0 | isModule: 0 | module: DependsOnModule.SubFramework.Other
>  // CHECK-DMOD-NEXT: [ppIncludedFile]: 
> [[DMOD_PRIVATE_H:.*/Modules/Inputs/DependsOnModule.framework[/\\]PrivateHeaders[/\\]DependsOnModulePrivate.h]]
>  | {{.*}} | hash loc:  | {{.*}} | module: 
> DependsOnModule.Private.DependsOnModule
>  // CHECK-DMOD-NEXT: [importedASTFile]: 
> {{.*}}.cache{{(.sys)?[/\\]}}Module.pcm | loc: [[DMOD_MODULE_H]]:1:1 | name: 
> "Module" | isImplicit: 1
>  // CHECK-DMOD-NEXT: [indexDeclaration]: kind: variable | name: 
> depends_on_module_other | {{.*}} | loc: [[DMOD_OTHER_H]]:1:5
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r301610 - Move functionality for handling module maps as inputs from the -emit-module

2017-04-27 Thread Bruno Cardoso Lopes via cfe-commits
On Thu, Apr 27, 2017 at 6:49 PM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Thu Apr 27 20:49:42 2017
> New Revision: 301610
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301610=rev
> Log:
> Move functionality for handling module maps as inputs from the -emit-module
> action to the general FrontendAction infrastructure.
>
> This permits applying -E, -ast-dump, -fsyntax-only, and so on to a module map
> compilation. (The -E form is not currently especially useful yet as there's no
> good way to take the output and use it to actually build a module.)

Yay! This is awesome Richard!!

> In order to support this, -cc1 now accepts -x -module-map in all cases
> where it accepts -x  for a language we can parse (not ir/ast). And for
> uniformity, we also accept -x -header for all such languages (we used
> to reject for cuda and renderscript), and -x -cpp-output for all such
> languages (we used to reject for c, cl, and renderscript).
>
> (None of these new alternatives are accepted by the driver yet, so no
> user-visible changes.)
>
> Added:
> cfe/trunk/test/Modules/preprocess-module.cpp
> Modified:
> cfe/trunk/include/clang/Frontend/FrontendActions.h
> cfe/trunk/include/clang/Frontend/FrontendOptions.h
> cfe/trunk/lib/Frontend/CompilerInstance.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.cpp
> cfe/trunk/lib/Frontend/FrontendAction.cpp
> cfe/trunk/lib/Frontend/FrontendActions.cpp
> cfe/trunk/lib/Frontend/FrontendOptions.cpp
>
> Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=301610=301609=301610=diff
> ==
> --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
> +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Apr 27 20:49:42 
> 2017
> @@ -99,8 +99,6 @@ class GenerateModuleAction : public ASTF
>CreateOutputFile(CompilerInstance , StringRef InFile) = 0;
>
>  protected:
> -  bool BeginSourceFileAction(CompilerInstance , StringRef Filename) 
> override;
> -
>std::unique_ptr CreateASTConsumer(CompilerInstance ,
>   StringRef InFile) override;
>
> @@ -112,20 +110,11 @@ protected:
>  };
>
>  class GenerateModuleFromModuleMapAction : public GenerateModuleAction {
> -  clang::Module *Module = nullptr;
> -  const FileEntry *ModuleMapForUniquing = nullptr;
> -  bool IsSystem = false;
> -
>  private:
>bool BeginSourceFileAction(CompilerInstance , StringRef Filename) 
> override;
>
>std::unique_ptr
>CreateOutputFile(CompilerInstance , StringRef InFile) override;
> -
> -public:
> -  GenerateModuleFromModuleMapAction() {}
> -  GenerateModuleFromModuleMapAction(const FileEntry *ModuleMap, bool 
> IsSystem)
> -  : ModuleMapForUniquing(ModuleMap), IsSystem(IsSystem) {}
>  };
>
>  class GenerateModuleInterfaceAction : public GenerateModuleAction {
>
> Modified: cfe/trunk/include/clang/Frontend/FrontendOptions.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendOptions.h?rev=301610=301609=301610=diff
> ==
> --- cfe/trunk/include/clang/Frontend/FrontendOptions.h (original)
> +++ cfe/trunk/include/clang/Frontend/FrontendOptions.h Thu Apr 27 20:49:42 
> 2017
> @@ -23,6 +23,7 @@ class MemoryBuffer;
>  }
>
>  namespace clang {
> +class FileEntry;
>
>  namespace frontend {
>enum ActionKind {
> @@ -100,9 +101,8 @@ public:
>  Precompiled
>};
>
> -  constexpr InputKind(Language L = Unknown, bool PP = false)
> -  : Lang(L), Fmt(Source), Preprocessed(PP) {}
> -  constexpr InputKind(Language L, Format F, bool PP = false)
> +  constexpr InputKind(Language L = Unknown, Format F = Source,
> +  bool PP = false)
>: Lang(L), Fmt(F), Preprocessed(PP) {}
>
>Language getLanguage() const { return static_cast(Lang); }
> @@ -118,6 +118,9 @@ public:
>InputKind getPreprocessed() const {
>  return InputKind(getLanguage(), getFormat(), true);
>}
> +  InputKind withFormat(Format F) const {
> +return InputKind(getLanguage(), F, isPreprocessed());
> +  }
>  };
>
>  /// \brief An input file for the front end.
> @@ -256,6 +259,10 @@ public:
>/// The input files and their types.
>std::vector Inputs;
>
> +  /// When the input is a module map, the original module map file from which
> +  /// that map was inferred, if any (for umbrella modules).
> +  std::string OriginalModuleMap;
> +
>/// The output file, if any.
>std::string OutputFile;
>
>
> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=301610=301609=301610=diff
> ==
> --- 

Re: r301597 - [Modules] Improve diagnostics for incomplete umbrella

2017-04-27 Thread Bruno Cardoso Lopes via cfe-commits
This is breaking a non related test in some windows bots.

Takumi & other with windows access, can you help me figure why?

For instance:
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/3846
http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/4379

On Thu, Apr 27, 2017 at 3:29 PM, Bruno Cardoso Lopes via cfe-commits
<cfe-commits@lists.llvm.org> wrote:
> Author: bruno
> Date: Thu Apr 27 17:29:14 2017
> New Revision: 301597
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301597=rev
> Log:
> [Modules] Improve diagnostics for incomplete umbrella
>
> One of the -Wincomplete-umbrella warnings diagnoses when a header is present 
> in
> the directory but it's not present in the umbrella header. Currently, this
> warning only happens on top level modules; any submodule using an umbrella
> header does not get this warning. Fix that by also considering the submodules.
>
> Differential Revision: https://reviews.llvm.org/D32576
>
> rdar://problem/22623686
>
> Added:
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/
> 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
> 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/
> 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
> 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap
> 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/
> 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h
> 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
> cfe/trunk/test/Modules/incomplete-umbrella.m
> Modified:
> cfe/trunk/lib/Lex/PPLexerChange.cpp
>
> Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301597=301596=301597=diff
> ==
> --- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
> +++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:14 2017
> @@ -287,6 +287,14 @@ const char *Preprocessor::getCurLexerEnd
>return EndPos;
>  }
>
> +static void collectAllSubModulesWithUmbrellaHeader(
> +const Module , SmallVectorImpl ) {
> +  if (Mod.getUmbrellaHeader())
> +SubMods.push_back();
> +  for (auto *M : Mod.submodules())
> +collectAllSubModulesWithUmbrellaHeader(*M, SubMods);
> +}
> +
>  void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module ) {
>assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
>SourceLocation StartLoc =
> @@ -507,10 +515,15 @@ bool Preprocessor::HandleEndOfFile(Token
>}
>
>// If we are building a module that has an umbrella header, make sure that
> -  // each of the headers within the directory covered by the umbrella header
> -  // was actually included by the umbrella header.
> -  if (Module *Mod = getCurrentModule())
> -diagnoseMissingHeaderInUmbrellaDir(*Mod);
> +  // each of the headers within the directory, including all submodules, is
> +  // covered by the umbrella header was actually included by the umbrella
> +  // header.
> +  if (Module *Mod = getCurrentModule()) {
> +llvm::SmallVector AllMods;
> +collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods);
> +for (auto *M : AllMods)
> +  diagnoseMissingHeaderInUmbrellaDir(*M);
> +  }
>
>return true;
>  }
>
> Added: 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h?rev=301597=auto
> ==
> --- 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h 
> (added)
> +++ 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h 
> Thu Apr 27 17:29:14 2017
> @@ -0,0 +1 @@
> +#define BAR_PUBLIC 1
>
> Added: 
> cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h?rev=301597=auto
> ==
> --- 

r301597 - [Modules] Improve diagnostics for incomplete umbrella

2017-04-27 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Apr 27 17:29:14 2017
New Revision: 301597

URL: http://llvm.org/viewvc/llvm-project?rev=301597=rev
Log:
[Modules] Improve diagnostics for incomplete umbrella

One of the -Wincomplete-umbrella warnings diagnoses when a header is present in
the directory but it's not present in the umbrella header. Currently, this
warning only happens on top level modules; any submodule using an umbrella
header does not get this warning. Fix that by also considering the submodules.

Differential Revision: https://reviews.llvm.org/D32576

rdar://problem/22623686

Added:
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/

cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h

cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/

cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.private.modulemap

cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Baz.h

cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/PrivateHeaders/Foo.h
cfe/trunk/test/Modules/incomplete-umbrella.m
Modified:
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301597=301596=301597=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:14 2017
@@ -287,6 +287,14 @@ const char *Preprocessor::getCurLexerEnd
   return EndPos;
 }
 
+static void collectAllSubModulesWithUmbrellaHeader(
+const Module , SmallVectorImpl ) {
+  if (Mod.getUmbrellaHeader())
+SubMods.push_back();
+  for (auto *M : Mod.submodules())
+collectAllSubModulesWithUmbrellaHeader(*M, SubMods);
+}
+
 void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module ) {
   assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
   SourceLocation StartLoc =
@@ -507,10 +515,15 @@ bool Preprocessor::HandleEndOfFile(Token
   }
 
   // If we are building a module that has an umbrella header, make sure that
-  // each of the headers within the directory covered by the umbrella header
-  // was actually included by the umbrella header.
-  if (Module *Mod = getCurrentModule())
-diagnoseMissingHeaderInUmbrellaDir(*Mod);
+  // each of the headers within the directory, including all submodules, is
+  // covered by the umbrella header was actually included by the umbrella
+  // header.
+  if (Module *Mod = getCurrentModule()) {
+llvm::SmallVector AllMods;
+collectAllSubModulesWithUmbrellaHeader(*Mod, AllMods);
+for (auto *M : AllMods)
+  diagnoseMissingHeaderInUmbrellaDir(*M);
+  }
 
   return true;
 }

Added: 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h?rev=301597=auto
==
--- 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/Bar.h 
Thu Apr 27 17:29:14 2017
@@ -0,0 +1 @@
+#define BAR_PUBLIC 1

Added: 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h?rev=301597=auto
==
--- 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Headers/FooPublic.h
 Thu Apr 27 17:29:14 2017
@@ -0,0 +1 @@
+// FooPublic.h

Added: 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap?rev=301597=auto
==
--- 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/incomplete-umbrella/Foo.framework/Modules/module.modulemap
 Thu Apr 27 17:29:14 2017
@@ -0,0 +1,5 @@
+framework module Foo {
+umbrella header "FooPublic.h"
+requires objc
+export *
+}

Added: 

r301596 - [Modules] Refactor logic for incomplete umbrella warnings. NFC

2017-04-27 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Apr 27 17:29:10 2017
New Revision: 301596

URL: http://llvm.org/viewvc/llvm-project?rev=301596=rev
Log:
[Modules] Refactor logic for incomplete umbrella warnings. NFC

Modified:
cfe/trunk/include/clang/Lex/Preprocessor.h
cfe/trunk/lib/Lex/PPLexerChange.cpp

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=301596=301595=301596=diff
==
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Apr 27 17:29:10 2017
@@ -1602,6 +1602,7 @@ private:
  *Ident_AbnormalTermination;
 
   const char *getCurLexerEndPos();
+  void diagnoseMissingHeaderInUmbrellaDir(const Module );
 
 public:
   void PoisonSEHIdentifiers(bool Poison = true); // Borland

Modified: cfe/trunk/lib/Lex/PPLexerChange.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/PPLexerChange.cpp?rev=301596=301595=301596=diff
==
--- cfe/trunk/lib/Lex/PPLexerChange.cpp (original)
+++ cfe/trunk/lib/Lex/PPLexerChange.cpp Thu Apr 27 17:29:10 2017
@@ -287,6 +287,40 @@ const char *Preprocessor::getCurLexerEnd
   return EndPos;
 }
 
+void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module ) {
+  assert(Mod.getUmbrellaHeader() && "Module must use umbrella header");
+  SourceLocation StartLoc =
+  SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
+  if (getDiagnostics().isIgnored(diag::warn_uncovered_module_header, StartLoc))
+return;
+
+  ModuleMap  = getHeaderSearchInfo().getModuleMap();
+  const DirectoryEntry *Dir = Mod.getUmbrellaDir().Entry;
+  vfs::FileSystem  = *FileMgr.getVirtualFileSystem();
+  std::error_code EC;
+  for (vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC), End;
+   Entry != End && !EC; Entry.increment(EC)) {
+using llvm::StringSwitch;
+
+// Check whether this entry has an extension typically associated with
+// headers.
+if (!StringSwitch(llvm::sys::path::extension(Entry->getName()))
+ .Cases(".h", ".H", ".hh", ".hpp", true)
+ .Default(false))
+  continue;
+
+if (const FileEntry *Header = getFileManager().getFile(Entry->getName()))
+  if (!getSourceManager().hasFileInfo(Header)) {
+if (!ModMap.isHeaderInUnavailableModule(Header)) {
+  // Find the relative path that would access this header.
+  SmallString<128> RelativePath;
+  computeRelativePath(FileMgr, Dir, Header, RelativePath);
+  Diag(StartLoc, diag::warn_uncovered_module_header)
+  << Mod.getFullModuleName() << RelativePath;
+}
+  }
+  }
+}
 
 /// HandleEndOfFile - This callback is invoked when the lexer hits the end of
 /// the current file.  This either returns the EOF token or pops a level off
@@ -475,43 +509,8 @@ bool Preprocessor::HandleEndOfFile(Token
   // If we are building a module that has an umbrella header, make sure that
   // each of the headers within the directory covered by the umbrella header
   // was actually included by the umbrella header.
-  if (Module *Mod = getCurrentModule()) {
-if (Mod->getUmbrellaHeader()) {
-  SourceLocation StartLoc
-= SourceMgr.getLocForStartOfFile(SourceMgr.getMainFileID());
-
-  if (!getDiagnostics().isIgnored(diag::warn_uncovered_module_header,
-  StartLoc)) {
-ModuleMap  = getHeaderSearchInfo().getModuleMap();
-const DirectoryEntry *Dir = Mod->getUmbrellaDir().Entry;
-vfs::FileSystem  = *FileMgr.getVirtualFileSystem();
-std::error_code EC;
-for (vfs::recursive_directory_iterator Entry(FS, Dir->getName(), EC), 
End;
- Entry != End && !EC; Entry.increment(EC)) {
-  using llvm::StringSwitch;
-  
-  // Check whether this entry has an extension typically associated 
with
-  // headers.
-  if (!StringSwitch(llvm::sys::path::extension(Entry->getName()))
- .Cases(".h", ".H", ".hh", ".hpp", true)
- .Default(false))
-continue;
-
-  if (const FileEntry *Header =
-  getFileManager().getFile(Entry->getName()))
-if (!getSourceManager().hasFileInfo(Header)) {
-  if (!ModMap.isHeaderInUnavailableModule(Header)) {
-// Find the relative path that would access this header.
-SmallString<128> RelativePath;
-computeRelativePath(FileMgr, Dir, Header, RelativePath);   
   
-Diag(StartLoc, diag::warn_uncovered_module_header)
-  << Mod->getFullModuleName() << RelativePath;
-  }
-}
-}
-  }
-}
-  }
+  if (Module *Mod = getCurrentModule())
+diagnoseMissingHeaderInUmbrellaDir(*Mod);
 
  

r301453 - [Modules] Fix a crash-on-invalid with overloaded functions

2017-04-26 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 26 15:13:45 2017
New Revision: 301453

URL: http://llvm.org/viewvc/llvm-project?rev=301453=rev
Log:
[Modules] Fix a crash-on-invalid with overloaded functions

Do not add an overload if the function doesn't have a prototype; this
can happen if, for instance, a misplaced/malformed call site is
considered like a declaration for recovery purposes.

rdar://problem/31306325

Added:
cfe/trunk/test/Modules/Inputs/malformed-overload/
cfe/trunk/test/Modules/Inputs/malformed-overload/X.h
cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap
cfe/trunk/test/Modules/malformed-overload.m
Modified:
cfe/trunk/lib/Sema/SemaOverload.cpp

Modified: cfe/trunk/lib/Sema/SemaOverload.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOverload.cpp?rev=301453=301452=301453=diff
==
--- cfe/trunk/lib/Sema/SemaOverload.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOverload.cpp Wed Apr 26 15:13:45 2017
@@ -11426,6 +11426,10 @@ static void AddOverloadedCallCandidate(S
   assert(!KnownValid && "Explicit template arguments?");
   return;
 }
+// Prevent ill-formed function decls to be added as overload candidates.
+if (!dyn_cast(Func->getType()->getAs()))
+  return;
+
 S.AddOverloadCandidate(Func, FoundDecl, Args, CandidateSet,
/*SuppressUsedConversions=*/false,
PartialOverloading);

Added: cfe/trunk/test/Modules/Inputs/malformed-overload/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/malformed-overload/X.h?rev=301453=auto
==
--- cfe/trunk/test/Modules/Inputs/malformed-overload/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/malformed-overload/X.h Wed Apr 26 15:13:45 
2017
@@ -0,0 +1,2 @@
+@class NSString;
+extern void NSLog(NSString *format, ...) __attribute__((format(__NSString__, 
1, 2))) __attribute__((not_tail_called));

Added: cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap?rev=301453=auto
==
--- cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/malformed-overload/module.modulemap Wed Apr 
26 15:13:45 2017
@@ -0,0 +1,4 @@
+module X {
+  header "X.h"
+  export *
+}

Added: cfe/trunk/test/Modules/malformed-overload.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/malformed-overload.m?rev=301453=auto
==
--- cfe/trunk/test/Modules/malformed-overload.m (added)
+++ cfe/trunk/test/Modules/malformed-overload.m Wed Apr 26 15:13:45 2017
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -fsyntax-only -I%S/Inputs/malformed-overload -fmodules 
-fimplicit-module-maps -fmodules-cache-path=tmp -verify %s
+NSLog(@"%@", path); // expected-error {{expected parameter declarator}} 
expected-error {{expected ')'}} expected-warning {{type specifier missing}} 
expected-warning {{incompatible redeclaration}} expected-note {{to match this 
'('}} expected-note {{'NSLog' is a builtin with type}}
+#import "X.h"
+
+@class NSString;
+void f(NSString *a) {
+ NSLog(@"* failed to get URL for %@", a);
+}


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r301382 - [Modules][ObjC] Check definition from canonical decl on designated initializers

2017-04-25 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 26 00:06:20 2017
New Revision: 301382

URL: http://llvm.org/viewvc/llvm-project?rev=301382=rev
Log:
[Modules][ObjC] Check definition from canonical decl on designated initializers

Use definition from canonical decl when checking for designated
initializers. This is necessary since deserialization of a interface
might reuse the definition from the canonical one (see r281119).

rdar://problem/29360655

Added:
cfe/trunk/test/Modules/Inputs/objc-desig-init/
cfe/trunk/test/Modules/Inputs/objc-desig-init/A.h
cfe/trunk/test/Modules/Inputs/objc-desig-init/A2.h
cfe/trunk/test/Modules/Inputs/objc-desig-init/Base.h
cfe/trunk/test/Modules/Inputs/objc-desig-init/X.h
cfe/trunk/test/Modules/Inputs/objc-desig-init/module.modulemap
cfe/trunk/test/Modules/objc-designated-init-mod.m
Modified:
cfe/trunk/lib/AST/DeclObjC.cpp

Modified: cfe/trunk/lib/AST/DeclObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/DeclObjC.cpp?rev=301382=301381=301382=diff
==
--- cfe/trunk/lib/AST/DeclObjC.cpp (original)
+++ cfe/trunk/lib/AST/DeclObjC.cpp Wed Apr 26 00:06:20 2017
@@ -539,9 +539,18 @@ void ObjCInterfaceDecl::getDesignatedIni
 
 bool ObjCInterfaceDecl::isDesignatedInitializer(Selector Sel,
   const ObjCMethodDecl **InitMethod) const 
{
+  bool HasCompleteDef = isThisDeclarationADefinition();
+  // During deserialization the data record for the ObjCInterfaceDecl could
+  // be made invariant by reusing the canonical decl. Take this into account
+  // when checking for the complete definition.
+  if (!HasCompleteDef && getCanonicalDecl()->hasDefinition() &&
+  getCanonicalDecl()->getDefinition() == getDefinition())
+HasCompleteDef = true;
+
   // Check for a complete definition and recover if not so.
-  if (!isThisDeclarationADefinition())
+  if (!HasCompleteDef)
 return false;
+
   if (data().ExternallyCompleted)
 LoadExternalDefinition();
 

Added: cfe/trunk/test/Modules/Inputs/objc-desig-init/A.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-desig-init/A.h?rev=301382=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-desig-init/A.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-desig-init/A.h Wed Apr 26 00:06:20 2017
@@ -0,0 +1 @@
+#import "A2.h"

Added: cfe/trunk/test/Modules/Inputs/objc-desig-init/A2.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-desig-init/A2.h?rev=301382=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-desig-init/A2.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-desig-init/A2.h Wed Apr 26 00:06:20 2017
@@ -0,0 +1,4 @@
+#import "Base.h"
+
+@interface A2 : Base
+@end

Added: cfe/trunk/test/Modules/Inputs/objc-desig-init/Base.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-desig-init/Base.h?rev=301382=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-desig-init/Base.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-desig-init/Base.h Wed Apr 26 00:06:20 
2017
@@ -0,0 +1,4 @@
+@class NSString;
+@interface Base
+- (id)initWithNibName:(NSString *)nibNameOrNil 
__attribute__((objc_designated_initializer));
+@end

Added: cfe/trunk/test/Modules/Inputs/objc-desig-init/X.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-desig-init/X.h?rev=301382=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-desig-init/X.h (added)
+++ cfe/trunk/test/Modules/Inputs/objc-desig-init/X.h Wed Apr 26 00:06:20 2017
@@ -0,0 +1,4 @@
+#import "A2.h"
+
+@interface X : A2
+@end

Added: cfe/trunk/test/Modules/Inputs/objc-desig-init/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/objc-desig-init/module.modulemap?rev=301382=auto
==
--- cfe/trunk/test/Modules/Inputs/objc-desig-init/module.modulemap (added)
+++ cfe/trunk/test/Modules/Inputs/objc-desig-init/module.modulemap Wed Apr 26 
00:06:20 2017
@@ -0,0 +1,9 @@
+module Base {
+  header "Base.h"
+  export *
+}
+
+module A {
+  header "A.h"
+  export *
+}

Added: cfe/trunk/test/Modules/objc-designated-init-mod.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/objc-designated-init-mod.m?rev=301382=auto
==
--- cfe/trunk/test/Modules/objc-designated-init-mod.m (added)
+++ cfe/trunk/test/Modules/objc-designated-init-mod.m Wed Apr 26 00:06:20 2017
@@ -0,0 +1,17 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I 
%S/Inputs/objc-desig-init %s 

Re: r289018 - [Headers] Enable #include_next on Darwin

2017-04-25 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Apr 25, 2017 at 2:34 PM, Aaron Ballman <aa...@aaronballman.com> wrote:
> On Tue, Apr 25, 2017 at 5:33 PM, Bruno Cardoso Lopes
> <bruno.card...@gmail.com> wrote:
>> On Tue, Apr 25, 2017 at 6:29 AM, Aaron Ballman <aa...@aaronballman.com> 
>> wrote:
>>> On Wed, Dec 7, 2016 at 9:13 PM, Bruno Cardoso Lopes via cfe-commits
>>> <cfe-commits@lists.llvm.org> wrote:
>>>> Author: bruno
>>>> Date: Wed Dec  7 20:13:56 2016
>>>> New Revision: 289018
>>>>
>>>> URL: http://llvm.org/viewvc/llvm-project?rev=289018=rev
>>>> Log:
>>>> [Headers] Enable #include_next on Darwin
>>>>
>>>> Allows darwin targets to provide additional definitions and
>>>> implementation specifc values for float.h
>>>>
>>>> rdar://problem/21961491
>>>>
>>>> Added:
>>>> cfe/trunk/test/Headers/Inputs/usr/
>>>> cfe/trunk/test/Headers/Inputs/usr/include/
>>>> cfe/trunk/test/Headers/Inputs/usr/include/float.h
>>>> cfe/trunk/test/Headers/float-darwin.c
>>>> Modified:
>>>> cfe/trunk/lib/Headers/float.h
>>>
>>> This commit appears to have caused a regression:
>>> https://bugs.llvm.org//show_bug.cgi?id=31504
>>>
>>> I am running into this on a Snow Leopard system as well, where the
>>> Integration tests are now failing because float.h cannot be found by
>>> the system #include_next.
>>
>> What's actually happening here is that Snow Leopard (or any < 10.7)
>> used to ship a /usr/include/float.h, which has by itself another
>> include_next (which is the one failing), see:
>>
>> --
>> /* This file exists soley to keep Metrowerks' compilers happy.  The version
>>used by GCC can be found in /usr/lib/gcc, although it's
>>not very informative.  */
>>
>> #ifndef _FLOAT_H_
>>
>> #if defined(__GNUC__)
>> #include_next 
>> --
>>
>> We don't have any reliable way to check for the SDK version at this
>> level, the current macros we have tell a history about deployment
>> target, but that won't always solve the issue here. Can you try this
>> workaround below and let me know if works?
>>
>> --
>> #if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
>>__STDC_HOSTED__ && __has_include_next()
>>
>> #ifdef __APPLE__
>> #define _FLOAT_H_ // Avoid #include_next'ing float.h content on MacOSX < 10.7
>> #endif
>>
>> #  include_next 
>> --
>>
>>> I was thinking of modifying lib/Headers/float.h to use the SDK version as 
>>> mentioned in the bug report, but I share the reporter's question: why was 
>>> this change needed in the first place? I couldn't find a review for the 
>>> commit, and don't have access to the rdar link.
>>
>> We need it to have flexibility to implement additional stuff for
>> float.h on future SDKs. There was no good reason for not upstreaming
>> it. I never got to the point of dealing with this specific issue
>> though, thanks for pinging.
>
> What good timing. I was about to post this as a possible fix:
>
> Index: lib/Headers/float.h
> ===
> --- lib/Headers/float.h (revision 135915)
> +++ lib/Headers/float.h (working copy)
> @@ -31 +31 @@
> - * Also fall back on Darwin to allow additional definitions and
> + * Also fall back on Darwin 10.7 or later to allow additional definitions and
> @@ -34 +34,4 @@
> -#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
> +#if ((defined(__APPLE__) &&
>  \
> +  defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__) &&
>  \
> +  __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 1070) ||
>  \
> + (defined(__MINGW32__) || defined(_MSC_VER))) &&
>  \
>
> Would this be an improvement over your suggestion?

This would be fine for most cases I believe, but if you're trying to
deploy to a target >= 1070 while using Snow Leopard you would still
get the error.

> ~Aaron
>
>>
>> --
>> Bruno Cardoso Lopes
>> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r289018 - [Headers] Enable #include_next on Darwin

2017-04-25 Thread Bruno Cardoso Lopes via cfe-commits
On Tue, Apr 25, 2017 at 6:29 AM, Aaron Ballman <aa...@aaronballman.com> wrote:
> On Wed, Dec 7, 2016 at 9:13 PM, Bruno Cardoso Lopes via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
>> Author: bruno
>> Date: Wed Dec  7 20:13:56 2016
>> New Revision: 289018
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=289018=rev
>> Log:
>> [Headers] Enable #include_next on Darwin
>>
>> Allows darwin targets to provide additional definitions and
>> implementation specifc values for float.h
>>
>> rdar://problem/21961491
>>
>> Added:
>> cfe/trunk/test/Headers/Inputs/usr/
>> cfe/trunk/test/Headers/Inputs/usr/include/
>> cfe/trunk/test/Headers/Inputs/usr/include/float.h
>> cfe/trunk/test/Headers/float-darwin.c
>> Modified:
>> cfe/trunk/lib/Headers/float.h
>
> This commit appears to have caused a regression:
> https://bugs.llvm.org//show_bug.cgi?id=31504
>
> I am running into this on a Snow Leopard system as well, where the
> Integration tests are now failing because float.h cannot be found by
> the system #include_next.

What's actually happening here is that Snow Leopard (or any < 10.7)
used to ship a /usr/include/float.h, which has by itself another
include_next (which is the one failing), see:

--
/* This file exists soley to keep Metrowerks' compilers happy.  The version
   used by GCC can be found in /usr/lib/gcc, although it's
   not very informative.  */

#ifndef _FLOAT_H_

#if defined(__GNUC__)
#include_next 
--

We don't have any reliable way to check for the SDK version at this
level, the current macros we have tell a history about deployment
target, but that won't always solve the issue here. Can you try this
workaround below and let me know if works?

--
#if (defined(__APPLE__) || (defined(__MINGW32__) || defined(_MSC_VER))) && \
   __STDC_HOSTED__ && __has_include_next()

#ifdef __APPLE__
#define _FLOAT_H_ // Avoid #include_next'ing float.h content on MacOSX < 10.7
#endif

#  include_next 
--

> I was thinking of modifying lib/Headers/float.h to use the SDK version as 
> mentioned in the bug report, but I share the reporter's question: why was 
> this change needed in the first place? I couldn't find a review for the 
> commit, and don't have access to the rdar link.

We need it to have flexibility to implement additional stuff for
float.h on future SDKs. There was no good reason for not upstreaming
it. I never got to the point of dealing with this specific issue
though, thanks for pinging.

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r301261 - [Modules] Fix test to wipe out the cache before using it

2017-04-24 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Apr 24 16:58:13 2017
New Revision: 301261

URL: http://llvm.org/viewvc/llvm-project?rev=301261=rev
Log:
[Modules] Fix test to wipe out the cache before using it

This should appease bots:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental_check/35914

rdar://problem/31796737

Modified:
cfe/trunk/test/Modules/localsubmodulevis.m

Modified: cfe/trunk/test/Modules/localsubmodulevis.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/localsubmodulevis.m?rev=301261=301260=301261=diff
==
--- cfe/trunk/test/Modules/localsubmodulevis.m (original)
+++ cfe/trunk/test/Modules/localsubmodulevis.m Mon Apr 24 16:58:13 2017
@@ -1,4 +1,4 @@
-// RUN: rm -rf %t
+// RUN: rm -rf %t.a %t.b
 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.a -I %S/Inputs/preprocess 
-verify %s
 // RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.b -I %S/Inputs/preprocess -x c 
-verify -x c %s
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r259901 - [modules] Separately track whether an identifier's preprocessor information and

2017-04-18 Thread Bruno Cardoso Lopes via cfe-commits
Hi Richard,

FTR, this caused http://bugs.llvm.org/show_bug.cgi?id=32693

Any suggestions on how to approach this?

On Fri, Feb 5, 2016 at 11:03 AM, Richard Smith via cfe-commits
 wrote:
> Author: rsmith
> Date: Fri Feb  5 13:03:40 2016
> New Revision: 259901
>
> URL: http://llvm.org/viewvc/llvm-project?rev=259901=rev
> Log:
> [modules] Separately track whether an identifier's preprocessor information 
> and
> name lookup information have changed since deserialization. For a C++ modules
> build, we do not need to re-emit the identifier into the serialized identifier
> table if only the name lookup information has changed (and in all cases, we
> don't need to re-emit the macro information if only the name lookup 
> information
> has changed).
>
> Added:
> cfe/trunk/test/Modules/minimal-identifier-tables.cpp
> Modified:
> cfe/trunk/include/clang/Basic/IdentifierTable.h
> cfe/trunk/lib/Basic/IdentifierTable.cpp
> cfe/trunk/lib/Sema/IdentifierResolver.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
>
> Modified: cfe/trunk/include/clang/Basic/IdentifierTable.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/IdentifierTable.h?rev=259901=259900=259901=diff
> ==
> --- cfe/trunk/include/clang/Basic/IdentifierTable.h (original)
> +++ cfe/trunk/include/clang/Basic/IdentifierTable.h Fri Feb  5 13:03:40 2016
> @@ -62,6 +62,9 @@ class IdentifierInfo {
> // partially) from an AST file.
>bool ChangedAfterLoad   : 1; // True if identifier has changed from the
> // definition loaded from an AST file.
> +  bool FEChangedAfterLoad : 1; // True if identifier's frontend 
> information
> +   // has changed from the definition loaded
> +   // from an AST file.
>bool RevertedTokenID: 1; // True if revertTokenIDToIdentifier was
> // called.
>bool OutOfDate  : 1; // True if there may be additional
> @@ -69,7 +72,7 @@ class IdentifierInfo {
> // stored externally.
>bool IsModulesImport: 1; // True if this is the 'import' contextual
> // keyword.
> -  // 30 bit left in 64-bit word.
> +  // 29 bit left in 64-bit word.
>
>void *FETokenInfo;   // Managed by the language front-end.
>llvm::StringMapEntry *Entry;
> @@ -303,6 +306,18 @@ public:
>  ChangedAfterLoad = true;
>}
>
> +  /// \brief Determine whether the frontend token information for this
> +  /// identifier has changed since it was loaded from an AST file.
> +  bool hasFETokenInfoChangedSinceDeserialization() const {
> +return FEChangedAfterLoad;
> +  }
> +
> +  /// \brief Note that the frontend token information for this identifier has
> +  /// changed since it was loaded from an AST file.
> +  void setFETokenInfoChangedSinceDeserialization() {
> +FEChangedAfterLoad = true;
> +  }
> +
>/// \brief Determine whether the information for this identifier is out of
>/// date with respect to the external source.
>bool isOutOfDate() const { return OutOfDate; }
>
> Modified: cfe/trunk/lib/Basic/IdentifierTable.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/IdentifierTable.cpp?rev=259901=259900=259901=diff
> ==
> --- cfe/trunk/lib/Basic/IdentifierTable.cpp (original)
> +++ cfe/trunk/lib/Basic/IdentifierTable.cpp Fri Feb  5 13:03:40 2016
> @@ -42,6 +42,7 @@ IdentifierInfo::IdentifierInfo() {
>NeedsHandleIdentifier = false;
>IsFromAST = false;
>ChangedAfterLoad = false;
> +  FEChangedAfterLoad = false;
>RevertedTokenID = false;
>OutOfDate = false;
>IsModulesImport = false;
>
> Modified: cfe/trunk/lib/Sema/IdentifierResolver.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/IdentifierResolver.cpp?rev=259901=259900=259901=diff
> ==
> --- cfe/trunk/lib/Sema/IdentifierResolver.cpp (original)
> +++ cfe/trunk/lib/Sema/IdentifierResolver.cpp Fri Feb  5 13:03:40 2016
> @@ -381,7 +381,7 @@ void IdentifierResolver::updatingIdentif
>  PP.getExternalSource()->updateOutOfDateIdentifier(II);
>
>if (II.isFromAST())
> -II.setChangedSinceDeserialization();
> +II.setFETokenInfoChangedSinceDeserialization();
>  }
>
>  
> //===--===//
>
> Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=259901=259900=259901=diff
> ==
> --- 

r300108 - [Modules] Enable local submodule visibility for ObjC/C

2017-04-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 12 16:46:16 2017
New Revision: 300108

URL: http://llvm.org/viewvc/llvm-project?rev=300108=rev
Log:
[Modules] Enable local submodule visibility for ObjC/C

Remove the restriction where this is only valid with C++

rdar://problem/29055656

Differential Revision: https://reviews.llvm.org/D31781

Added:
cfe/trunk/test/Modules/localsubmodulevis.m
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=300108=300107=300108=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Wed Apr 12 16:46:16 2017
@@ -2117,12 +2117,6 @@ static void ParseLangArgs(LangOptions 
   Args.hasFlag(OPT_fdeclspec, OPT_fno_declspec,
(Opts.MicrosoftExt || Opts.Borland || Opts.CUDA));
 
-  // For now, we only support local submodule visibility in C++ (because we
-  // heavily depend on the ODR for merging redefinitions).
-  if (Opts.ModulesLocalVisibility && !Opts.CPlusPlus)
-Diags.Report(diag::err_drv_argument_not_allowed_with)
-<< "-fmodules-local-submodule-visibility" << "C";
-
   if (Arg *A = Args.getLastArg(OPT_faddress_space_map_mangling_EQ)) {
 switch (llvm::StringSwitch(A->getValue())
   .Case("target", LangOptions::ASMM_Target)

Added: cfe/trunk/test/Modules/localsubmodulevis.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/localsubmodulevis.m?rev=300108=auto
==
--- cfe/trunk/test/Modules/localsubmodulevis.m (added)
+++ cfe/trunk/test/Modules/localsubmodulevis.m Wed Apr 12 16:46:16 2017
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.a -I %S/Inputs/preprocess 
-verify %s
+// RUN: %clang_cc1 -fmodules -fmodules-local-submodule-visibility 
-fimplicit-module-maps -fmodules-cache-path=%t.b -I %S/Inputs/preprocess -x c 
-verify -x c %s
+
+// expected-no-diagnostics
+
+#include "file.h"
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r300109 - [Driver] Add compiler option to generate a reproducer

2017-04-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 12 16:46:20 2017
New Revision: 300109

URL: http://llvm.org/viewvc/llvm-project?rev=300109=rev
Log:
[Driver] Add compiler option to generate a reproducer

One way to currently test the reproducers is to setup
"FORCE_CLANG_DIAGNOSTICS_CRASH=1" before invoking clang. This simulates
a crash and produces the same contents needed by the reproducers.  The
reproducers are specially useful when triaging Modules issues, not only
on crashes, but also for reproducing misleading warnings, errors, etc.

Add a '-gen-reproducer' driver option to clang (or any similar name) and
give users a flag option.

Note that clang already has a -fno-crash-diagnostics, which disables the
crash reproducers. I've decided not to propose "-fcrash-diagnostics"
since it doesn't convey the ideia of reproduction despite a crash.

rdar://problem/24114619

Differential Revision: https://reviews.llvm.org/D27604

Modified:
cfe/trunk/docs/UsersManual.rst
cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/crash-report-crashfile.m
cfe/trunk/tools/driver/driver.cpp

Modified: cfe/trunk/docs/UsersManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/UsersManual.rst?rev=300109=300108=300109=diff
==
--- cfe/trunk/docs/UsersManual.rst (original)
+++ cfe/trunk/docs/UsersManual.rst Wed Apr 12 16:46:20 2017
@@ -562,6 +562,16 @@ control the crash diagnostics.
 The -fno-crash-diagnostics flag can be helpful for speeding the process
 of generating a delta reduced test case.
 
+Clang is also capable of generating preprocessed source file(s) and associated
+run script(s) even without a crash. This is specially useful when trying to
+generate a reproducer for warnings or errors while using modules.
+
+.. option:: -gen-reproducer
+
+  Generates preprocessed source files, a reproducer script and if relevant, a
+  cache containing: built module pcm's and all headers needed to rebuilt the
+  same modules.
+
 .. _rpass:
 
 Options to Emit Optimization Reports

Modified: cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td?rev=300109=300108=300109=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticDriverKinds.td Wed Apr 12 16:46:20 
2017
@@ -94,7 +94,7 @@ def err_drv_compilationdatabase : Error<
 def err_drv_command_signalled : Error<
   "%0 command failed due to signal (use -v to see invocation)">;
 def err_drv_force_crash : Error<
-  "failing because environment variable '%0' is set">;
+  "failing because %select{environment variable 
'FORCE_CLANG_DIAGNOSTICS_CRASH' is set|'-gen-reproducer' is used}0">;
 def err_drv_invalid_mfloat_abi : Error<
   "invalid float ABI '%0'">;
 def err_drv_invalid_libcxx_deployment : Error<

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=300109=300108=300109=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Wed Apr 12 16:46:20 2017
@@ -216,6 +216,11 @@ public:
   /// Use lazy precompiled headers for PCH support.
   unsigned CCCUsePCH : 1;
 
+  /// Force clang to emit reproducer for driver invocation. This is enabled
+  /// indirectly by setting FORCE_CLANG_DIAGNOSTICS_CRASH environment variable
+  /// or when using the -gen-reproducer driver flag.
+  unsigned GenReproducer : 1;
+
 private:
   /// Certain options suppress the 'no input files' warning.
   unsigned SuppressMissingInputWarning : 1;

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=300109=300108=300109=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Apr 12 16:46:20 2017
@@ -265,6 +265,8 @@ def arcmt_migrate_report_output : Separa
 def arcmt_migrate_emit_arc_errors : Flag<["-"], "arcmt-migrate-emit-errors">,
   HelpText<"Emit ARC errors even if the migrator can fix them">,
   Flags<[CC1Option]>;
+def gen_reproducer: Flag<["-"], "gen-reproducer">, InternalDebugOpt,
+  HelpText<"Auto-generates preprocessed source files and a reproduction 
script">;
 
 def _migrate : Flag<["--"], "migrate">, Flags<[DriverOption]>,
   HelpText<"Run the migrator">;
@@ -701,7 +703,8 @@ def fconstexpr_depth_EQ : Joined<["-"],
 def fconstexpr_steps_EQ : Joined<["-"], "fconstexpr-steps=">, Group;
 def fconstexpr_backtrace_limit_EQ 

r300027 - [Modules] Remove darwin specific code to check for SystemVersion.plist

2017-04-11 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Apr 11 23:49:00 2017
New Revision: 300027

URL: http://llvm.org/viewvc/llvm-project?rev=300027=rev
Log:
[Modules] Remove darwin specific code to check for SystemVersion.plist

This isn't need anymore and modules options -fbuild-session-file and
-fmodules-validate-once-per-build-session already provide a sane
mechanism to validate the system headers.

rdar://problem/19767523

Removed:
cfe/trunk/test/Modules/system_version.m
Modified:
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=300027=300026=300027=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue Apr 11 23:49:00 2017
@@ -2660,29 +2660,6 @@ std::string CompilerInvocation::getModul
 code = ext->hashExtension(code);
   }
 
-  // Darwin-specific hack: if we have a sysroot, use the contents and
-  // modification time of
-  //   $sysroot/System/Library/CoreServices/SystemVersion.plist
-  // as part of the module hash.
-  if (!hsOpts.Sysroot.empty()) {
-SmallString<128> systemVersionFile;
-systemVersionFile += hsOpts.Sysroot;
-llvm::sys::path::append(systemVersionFile, "System");
-llvm::sys::path::append(systemVersionFile, "Library");
-llvm::sys::path::append(systemVersionFile, "CoreServices");
-llvm::sys::path::append(systemVersionFile, "SystemVersion.plist");
-
-llvm::ErrorOr buffer =
-llvm::MemoryBuffer::getFile(systemVersionFile);
-if (buffer) {
-  code = hash_combine(code, buffer.get()->getBuffer());
-
-  struct stat statBuf;
-  if (stat(systemVersionFile.c_str(), ) == 0)
-code = hash_combine(code, statBuf.st_mtime);
-}
-  }
-
   return llvm::APInt(64, code).toString(36, /*Signed=*/false);
 }
 

Removed: cfe/trunk/test/Modules/system_version.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/system_version.m?rev=300026=auto
==
--- cfe/trunk/test/Modules/system_version.m (original)
+++ cfe/trunk/test/Modules/system_version.m (removed)
@@ -1,31 +0,0 @@
-// Test checking that we're hashing a system version file in the
-// module hash.
-
-// First, build a system root.
-// RUN: rm -rf %t
-// RUN: mkdir -p %t/usr/include
-// RUN: cp %S/Inputs/Modified/A.h %t/usr/include
-// RUN: cp %S/Inputs/Modified/B.h %t/usr/include
-// RUN: cp %S/Inputs/Modified/module.map %t/usr/include
-
-// Run once with no system version file. We should end up with one module.
-// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules 
-fimplicit-module-maps -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 1
-
-// Add a system version file and run again. We should now have two
-// module variants.
-// RUN: mkdir -p %t/System/Library/CoreServices
-// RUN: echo "hello" > %t/System/Library/CoreServices/SystemVersion.plist
-// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules 
-fimplicit-module-maps -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 2
-
-// Change the system version file and run again. We should now have three
-// module variants.
-// RUN: mkdir -p %t/System/Library/CoreServices
-// RUN: echo "modules" > %t/System/Library/CoreServices/SystemVersion.plist
-// RUN: %clang_cc1 -fmodules-cache-path=%t/cache -fmodules 
-fimplicit-module-maps -isysroot %t -I %t/usr/include %s -verify
-// RUN: ls -R %t | grep -c "ModA.*pcm" | grep 3
-
-// expected-no-diagnostics
-@import ModA;
-


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298464 - [Modules] Rebuild modules on umbrella header mismatch

2017-03-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 21 19:11:21 2017
New Revision: 298464

URL: http://llvm.org/viewvc/llvm-project?rev=298464=rev
Log:
[Modules] Rebuild modules on umbrella header mismatch

This restores behavior pre-r230064 since after PCMCache work (r298278)
we don't reload PCMs from disk within the same compiler invocation.

Testcases from r230064 are still left around since they still guarantee
the correct behavior we're expecting.

rdar://problem/19889777

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=298464=298463=298464=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Mar 21 19:11:21 2017
@@ -4890,13 +4890,9 @@ ASTReader::ReadSubmoduleBlock(ModuleFile
 if (!CurrentModule->getUmbrellaHeader())
   ModMap.setUmbrellaHeader(CurrentModule, Umbrella, Blob);
 else if (CurrentModule->getUmbrellaHeader().Entry != Umbrella) {
-  // This can be a spurious difference caused by changing the VFS to
-  // point to a different copy of the file, and it is too late to
-  // to rebuild safely.
-  // FIXME: If we wrote the virtual paths instead of the 'real' paths,
-  // after input file validation only real problems would remain and we
-  // could just error. For now, assume it's okay.
-  break;
+  if ((ClientLoadCapabilities & ARR_OutOfDate) == 0)
+Error("mismatched umbrella headers in submodule");
+  return OutOfDate;
 }
   }
   break;


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298391 - [Modules] Find PrivateHeaders when looking into subframeworks

2017-03-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Mar 21 11:43:51 2017
New Revision: 298391

URL: http://llvm.org/viewvc/llvm-project?rev=298391=rev
Log:
[Modules] Find PrivateHeaders when looking into subframeworks

Fix the current parsing of subframeworks in modulemaps to lookup for
headers based on whether they are frameworks.

rdar://problem/30563982

Added:
cfe/trunk/test/Modules/Inputs/Main.framework/
cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/
cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/

cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/

cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/B.h

cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/Sub.h

cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/PrivateHeaders/BPriv.h

cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/PrivateHeaders/SubPriv.h
cfe/trunk/test/Modules/Inputs/Main.framework/Headers/
cfe/trunk/test/Modules/Inputs/Main.framework/Headers/A.h
cfe/trunk/test/Modules/Inputs/Main.framework/Headers/Main.h
cfe/trunk/test/Modules/Inputs/Main.framework/Modules/
cfe/trunk/test/Modules/Inputs/Main.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/Main.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/Main.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/Main.framework/PrivateHeaders/APriv.h
cfe/trunk/test/Modules/Inputs/Main.framework/PrivateHeaders/MainPriv.h
cfe/trunk/test/Modules/find-privateheaders.m
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=298391=298390=298391=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Tue Mar 21 11:43:51 2017
@@ -1841,7 +1841,7 @@ void ModuleMapParser::parseHeaderDecl(MM
   Module::UnresolvedHeaderDirective Header;
   Header.FileName = Tok.getString();
   Header.FileNameLoc = consumeToken();
-  
+
   // Check whether we already have an umbrella.
   if (LeadingToken == MMToken::UmbrellaKeyword && ActiveModule->Umbrella) {
 Diags.Report(Header.FileNameLoc, diag::err_mmap_umbrella_clash)
@@ -1861,19 +1861,25 @@ void ModuleMapParser::parseHeaderDecl(MM
 // Search for the header file within the search directory.
 SmallString<128> FullPathName(Directory->getName());
 unsigned FullPathLength = FullPathName.size();
-
+
 if (ActiveModule->isPartOfFramework()) {
   appendSubframeworkPaths(ActiveModule, RelativePathName);
-  
+  unsigned RelativePathLength = RelativePathName.size();
+
   // Check whether this file is in the public headers.
   llvm::sys::path::append(RelativePathName, "Headers", Header.FileName);
   llvm::sys::path::append(FullPathName, RelativePathName);
   File = SourceMgr.getFileManager().getFile(FullPathName);
-  
+
+  // Check whether this file is in the private headers.
   if (!File) {
-// Check whether this file is in the private headers.
-// FIXME: Should we retain the subframework paths here?
-RelativePathName.clear();
+// Ideally, private modules in the form 'FrameworkName.Private' should
+// be defined as 'module FrameworkName.Private', and not as
+// 'framework module FrameworkName.Private', since a 
'Private.Framework'
+// does not usually exist. However, since both are currently widely 
used
+// for private modules, make sure we find the right path in both cases.
+RelativePathName.resize(ActiveModule->IsFramework ? 0
+  : 
RelativePathLength);
 FullPathName.resize(FullPathLength);
 llvm::sys::path::append(RelativePathName, "PrivateHeaders",
 Header.FileName);

Added: 
cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/B.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/B.h?rev=298391=auto
==
--- 
cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/B.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/B.h
 Tue Mar 21 11:43:51 2017
@@ -0,0 +1 @@
+// B.h

Added: 
cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/Sub.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/Main.framework/Frameworks/Sub.framework/Headers/Sub.h?rev=298391=auto

r298175 - [Modules] In case of lock timeout, fallback and build module

2017-03-17 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Mar 17 19:26:18 2017
New Revision: 298175

URL: http://llvm.org/viewvc/llvm-project?rev=298175=rev
Log:
[Modules] In case of lock timeout, fallback and build module

Duncan's r298165 introduced the PCMCache mechanism, which guarantees
that locks aren't necessary anymore for correctness but only for
performance, by avoiding building it twice when possible.

Change the logic to avoid an error but actually build the module in case
the timeout happens. Instead of an error, still emit a remark for
debugging purposes.

rdar://problem/30297862

Modified:
cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
cfe/trunk/lib/Frontend/CompilerInstance.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td?rev=298175=298174=298175=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticCommonKinds.td Fri Mar 17 19:26:18 
2017
@@ -90,10 +90,10 @@ def err_module_unavailable : Error<
   "module '%0' %select{is incompatible with|requires}1 feature '%2'">;
 def err_module_header_missing : Error<
   "%select{|umbrella }0header '%1' not found">;
-def err_module_lock_failure : Error<
-  "could not acquire lock file for module '%0': %1">, DefaultFatal;
-def err_module_lock_timeout : Error<
-  "timed out waiting to acquire lock file for module '%0'">, DefaultFatal;
+def remark_module_lock_failure : Remark<
+  "could not acquire lock file for module '%0': %1">, InGroup;
+def remark_module_lock_timeout : Remark<
+  "timed out waiting to acquire lock file for module '%0'">, 
InGroup;
 def err_module_cycle : Error<"cyclic dependency in module '%0': %1">, 
   DefaultFatal;
 def err_module_prebuilt : Error<

Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=298175=298174=298175=diff
==
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Fri Mar 17 19:26:18 2017
@@ -1190,10 +1190,14 @@ static bool compileAndLoadModule(Compile
 llvm::LockFileManager Locked(ModuleFileName);
 switch (Locked) {
 case llvm::LockFileManager::LFS_Error:
-  Diags.Report(ModuleNameLoc, diag::err_module_lock_failure)
+  // PCMCache takes care of correctness and locks are only necessary for
+  // performance. Fallback to building the module in case of any lock
+  // related errors.
+  Diags.Report(ModuleNameLoc, diag::remark_module_lock_failure)
   << Module->Name << Locked.getErrorMessage();
-  return false;
-
+  // Clear out any potential leftover.
+  Locked.unsafeRemoveLockFile();
+  // FALLTHROUGH
 case llvm::LockFileManager::LFS_Owned:
   // We're responsible for building the module ourselves.
   if (!compileModuleImpl(ImportingInstance, ModuleNameLoc, Module,
@@ -1213,11 +1217,14 @@ static bool compileAndLoadModule(Compile
   case llvm::LockFileManager::Res_OwnerDied:
 continue; // try again to get the lock.
   case llvm::LockFileManager::Res_Timeout:
-Diags.Report(ModuleNameLoc, diag::err_module_lock_timeout)
+// Since PCMCache takes care of correctness, we try waiting for another
+// process to complete the build so clang does not do it done twice. If
+// case of timeout, build it ourselves.
+Diags.Report(ModuleNameLoc, diag::remark_module_lock_timeout)
 << Module->Name;
 // Clear the lock file so that future invokations can make progress.
 Locked.unsafeRemoveLockFile();
-return false;
+continue;
   }
   break;
 }


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298012 - [Modules] Add documentation on private frameworks

2017-03-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Mar 16 18:18:55 2017
New Revision: 298012

URL: http://llvm.org/viewvc/llvm-project?rev=298012=rev
Log:
[Modules] Add documentation on private frameworks

Expand a bit on private modules with some guidance on how to write
them in the context of frameworks.

rdar://problem/24758771

Modified:
cfe/trunk/docs/Modules.rst

Modified: cfe/trunk/docs/Modules.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.rst?rev=298012=298011=298012=diff
==
--- cfe/trunk/docs/Modules.rst (original)
+++ cfe/trunk/docs/Modules.rst Thu Mar 16 18:18:55 2017
@@ -360,6 +360,7 @@ The ``framework`` qualifier specifies th
   Name.framework/
 Modules/module.modulemap  Module map for the framework
 Headers/  Subdirectory containing framework headers
+PrivateHeaders/   Subdirectory containing framework private headers
 Frameworks/   Subdirectory containing embedded frameworks
 Resources/Subdirectory containing additional resources
 Name  Symbolic link to the shared library for the 
framework
@@ -842,6 +843,16 @@ would be available when ``Foo_Private.h`
 easier to split a library's public and private APIs along header
 boundaries.
 
+When writing a private module as part of a *framework*, it's recommended that:
+
+* Headers for this module are present in the ``PrivateHeaders``
+  framework subdirectory.
+* The private module is defined as a *submodule* of the public framework (if
+  there's one), similar to how ``Foo.Private`` is defined in the example above.
+* The ``explicit`` keyword should be used to guarantee that its content will
+  only be available when the submodule itself is explicitly named (through a
+  ``@import`` for example).
+
 Modularizing a Platform
 ===
 To get any benefit out of modules, one needs to introduce module maps for 
software libraries starting at the bottom of the stack. This typically means 
introducing a module map covering the operating system's headers and the C 
standard library headers (in ``/usr/include``, for a Unix system). 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r298013 - [Headers] Reapply: Add #include_next for tgmath.h on Darwin

2017-03-16 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Mar 16 18:19:00 2017
New Revision: 298013

URL: http://llvm.org/viewvc/llvm-project?rev=298013=rev
Log:
[Headers] Reapply: Add #include_next for tgmath.h on Darwin

Reapply r289181 but rename the include guard to avoid
conflict with the one from Darwin.

Allow darwin to provide additional definitions and implementation
specifc values for tgmath.h on Apple platforms.

rdar://problem/19019845

Added:
cfe/trunk/test/Headers/Inputs/usr/include/math.h
cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h
cfe/trunk/test/Headers/tgmath-darwin.c
Modified:
cfe/trunk/lib/Headers/tgmath.h

Modified: cfe/trunk/lib/Headers/tgmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/tgmath.h?rev=298013=298012=298013=diff
==
--- cfe/trunk/lib/Headers/tgmath.h (original)
+++ cfe/trunk/lib/Headers/tgmath.h Thu Mar 16 18:19:00 2017
@@ -22,12 +22,21 @@
  *
 
\*===--===*/
 
-#ifndef __TGMATH_H
-#define __TGMATH_H
+#ifndef __CLANG_TGMATH_H
+#define __CLANG_TGMATH_H
 
 /* C99 7.22 Type-generic math . */
 #include 
 
+/*
+ * Allow additional definitions and implementation-defined values on Apple
+ * platforms. This is done after #include  to avoid depcycle conflicts
+ * between libcxx and darwin in C++ modules builds.
+ */
+#if defined(__APPLE__) && __STDC_HOSTED__ && __has_include_next()
+#  include_next 
+#else
+
 /* C++ handles type genericity with overloading in math.h. */
 #ifndef __cplusplus
 #include 
@@ -1371,4 +1380,5 @@ static long double
 #undef _TG_ATTRS
 
 #endif /* __cplusplus */
-#endif /* __TGMATH_H */
+#endif /* __has_include_next */
+#endif /* __CLANG_TGMATH_H */

Added: cfe/trunk/test/Headers/Inputs/usr/include/math.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/usr/include/math.h?rev=298013=auto
==
--- cfe/trunk/test/Headers/Inputs/usr/include/math.h (added)
+++ cfe/trunk/test/Headers/Inputs/usr/include/math.h Thu Mar 16 18:19:00 2017
@@ -0,0 +1 @@
+// math.h

Added: cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h?rev=298013=auto
==
--- cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h (added)
+++ cfe/trunk/test/Headers/Inputs/usr/include/tgmath.h Thu Mar 16 18:19:00 2017
@@ -0,0 +1,4 @@
+#ifndef SYS_TGMATH_H
+#define SYS_TGMATH_H
+
+#endif /* SYS_TGMATH_H */

Added: cfe/trunk/test/Headers/tgmath-darwin.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Headers/tgmath-darwin.c?rev=298013=auto
==
--- cfe/trunk/test/Headers/tgmath-darwin.c (added)
+++ cfe/trunk/test/Headers/tgmath-darwin.c Thu Mar 16 18:19:00 2017
@@ -0,0 +1,12 @@
+// REQUIRES: system-darwin
+// RUN: %clang -target x86_64-apple-darwin10 -fsyntax-only -std=c11 -isysroot 
%S/Inputs %s
+#include 
+
+// Test the #include_next of tgmath.h works on Darwin.
+#ifndef SYS_TGMATH_H
+  #error "SYS_TGMATH_H not defined"
+#endif
+
+#ifndef __CLANG_TGMATH_H
+  #error "__CLANG_TGMATH_H not defined"
+#endif


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r297553 - Change test coverage generation to use llvm-cov instead of gcov.

2017-03-13 Thread Bruno Cardoso Lopes via cfe-commits
Hi Eric,

I fixed the build for darwin in r297703, let me know if you have any comments.

Thanks,

On Mon, Mar 13, 2017 at 3:04 PM, Bruno Cardoso Lopes
 wrote:
> Hi Eric,
>
>>  if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
>> @@ -62,12 +66,7 @@ if (APPLE AND LLVM_USE_SANITIZER)
>>  message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not 
>> supported on OS X")
>>endif()
>>if (LIBFILE)
>> -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=lib 
>> OUTPUT_VARIABLE LIBDIR RESULT_VARIABLE Result)
>> -if (NOT ${Result} EQUAL "0")
>> -  message(FATAL "Failed to find library resource directory")
>> -endif()
>> -string(STRIP "${LIBDIR}" LIBDIR)
>> -set(LIBDIR "${LIBDIR}/darwin/")
>> +find_compiler_rt_dir(LIBDIR)
>
> Seems like this broke ASAN+UBSAN bot in green-dragon:
> http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_build/3812
>
> Perhaps it's missing the "${LIBDIR}/darwin/" part from above?
>
> --
> Bruno Cardoso Lopes
> http://www.brunocardoso.cc



-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r297703 - Fix cmake to find the compiler-rt libs on darwin

2017-03-13 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Mar 13 23:12:29 2017
New Revision: 297703

URL: http://llvm.org/viewvc/llvm-project?rev=297703=rev
Log:
Fix cmake to find the compiler-rt libs on darwin

Followup for r297553, which left darwin in a broken state
http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_build/3812

rdar://problem/31011980

Modified:
libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake

Modified: libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake?rev=297703=297702=297703=diff
==
--- libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleCompilerRT.cmake Mon Mar 13 23:12:29 2017
@@ -25,15 +25,27 @@ function(find_compiler_rt_dir dest)
 message(FATAL_ERROR "LIBCXX_COMPILE_FLAGS must be defined when using this 
function")
   endif()
   set(dest "" PARENT_SCOPE)
-  set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
-  "--rtlib=compiler-rt" "--print-libgcc-file-name")
-  execute_process(
-  COMMAND ${CLANG_COMMAND}
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE LIBRARY_FILE
-  )
-  string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
-  get_filename_component(LIBRARY_DIR "${LIBRARY_FILE}" DIRECTORY)
+  if (APPLE)
+set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
+"-print-file-name=lib")
+execute_process(
+COMMAND ${CLANG_COMMAND}
+RESULT_VARIABLE HAD_ERROR
+OUTPUT_VARIABLE LIBRARY_DIR
+)
+string(STRIP "${LIBRARY_DIR}" LIBRARY_DIR)
+set(LIBRARY_DIR "${LIBRARY_DIR}/darwin")
+  else()
+set(CLANG_COMMAND ${CMAKE_CXX_COMPILER} ${LIBCXX_COMPILE_FLAGS}
+"--rtlib=compiler-rt" "--print-libgcc-file-name")
+execute_process(
+COMMAND ${CLANG_COMMAND}
+RESULT_VARIABLE HAD_ERROR
+OUTPUT_VARIABLE LIBRARY_FILE
+)
+string(STRIP "${LIBRARY_FILE}" LIBRARY_FILE)
+get_filename_component(LIBRARY_DIR "${LIBRARY_FILE}" DIRECTORY)
+  endif()
   if (NOT HAD_ERROR AND EXISTS "${LIBRARY_DIR}")
 message(STATUS "Found compiler-rt directory: ${LIBRARY_DIR}")
 set(${dest} "${LIBRARY_DIR}" PARENT_SCOPE)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [libcxx] r297553 - Change test coverage generation to use llvm-cov instead of gcov.

2017-03-13 Thread Bruno Cardoso Lopes via cfe-commits
Hi Eric,

>  if (APPLE AND (LIBCXX_CXX_ABI_LIBNAME STREQUAL "libcxxabi" OR
> @@ -62,12 +66,7 @@ if (APPLE AND LLVM_USE_SANITIZER)
>  message(WARNING "LLVM_USE_SANITIZER=${LLVM_USE_SANITIZER} is not 
> supported on OS X")
>endif()
>if (LIBFILE)
> -execute_process(COMMAND ${CMAKE_CXX_COMPILER} -print-file-name=lib 
> OUTPUT_VARIABLE LIBDIR RESULT_VARIABLE Result)
> -if (NOT ${Result} EQUAL "0")
> -  message(FATAL "Failed to find library resource directory")
> -endif()
> -string(STRIP "${LIBDIR}" LIBDIR)
> -set(LIBDIR "${LIBDIR}/darwin/")
> +find_compiler_rt_dir(LIBDIR)

Seems like this broke ASAN+UBSAN bot in green-dragon:
http://green.lab.llvm.org/green/job/clang-stage2-cmake-RgSan_build/3812

Perhaps it's missing the "${LIBDIR}/darwin/" part from above?

-- 
Bruno Cardoso Lopes
http://www.brunocardoso.cc
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r296656 - [PCH] Avoid VarDecl emission attempt if no owning module avaiable

2017-03-01 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Mar  1 13:18:42 2017
New Revision: 296656

URL: http://llvm.org/viewvc/llvm-project?rev=296656=rev
Log:
[PCH] Avoid VarDecl emission attempt if no owning module avaiable

This is a stopgap fix for PR31863, a regression introduced in r276159.

Consider this snippet:

struct FVector;
struct FVector {};
struct FBox {
  FVector Min;
  FBox(int);
};
namespace {
FBox InvalidBoundingBox(0);
}

While parsing the DECL_VAR for 'struct FBox', clang recursively read all the
dep decls until it finds the DECL_CXX_RECORD forward declaration for 'struct
FVector'. Then, it resumes all the way up back to DECL_VAR handling in
`ReadDeclRecord`, where it checks if `isConsumerInterestedIn` for the decl.

One of the condition for `isConsumerInterestedIn` to return false is if the
VarDecl is imported from a module `D->getImportedOwningModule()`, because it
will get emitted when we import the relevant module. However, before checking
if it comes from a module, clang checks if `Ctx.DeclMustBeEmitted(D)`, which
triggers the emission of 'struct FBox'. Since one of its fields is still
incomplete, it crashes.

Instead, check if `D->getImportedOwningModule()` is true before calling
`Ctx.DeclMustBeEmitted(D)`.

Differential Revision: https://reviews.llvm.org/D29753

rdar://problem/30173654

Added:
cfe/trunk/test/PCH/empty-def-fwd-struct.h
Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=296656=296655=296656=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Wed Mar  1 13:18:42 2017
@@ -2530,8 +2530,8 @@ static bool isConsumerInterestedIn(ASTCo
 
   // An ImportDecl or VarDecl imported from a module will get emitted when
   // we import the relevant module.
-  if ((isa(D) || isa(D)) && Ctx.DeclMustBeEmitted(D) &&
-  D->getImportedOwningModule())
+  if ((isa(D) || isa(D)) && D->getImportedOwningModule() 
&&
+  Ctx.DeclMustBeEmitted(D))
 return false;
 
   if (isa(D) || 

Added: cfe/trunk/test/PCH/empty-def-fwd-struct.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/empty-def-fwd-struct.h?rev=296656=auto
==
--- cfe/trunk/test/PCH/empty-def-fwd-struct.h (added)
+++ cfe/trunk/test/PCH/empty-def-fwd-struct.h Wed Mar  1 13:18:42 2017
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -emit-pch -x c++-header %s -std=c++14 -o %t.pch
+// RUN: %clang_cc1 -emit-llvm-only -x c++ /dev/null -std=c++14 -include-pch 
%t.pch -o %t.o
+struct FVector;
+struct FVector {};
+struct FBox {
+  FVector Min;
+  FBox(int);
+};
+namespace {
+FBox InvalidBoundingBox(0);
+}
+


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r294362 - [ASTReader] Improve ReadASTBlock error message when module not available

2017-02-07 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Feb  7 15:55:02 2017
New Revision: 294362

URL: http://llvm.org/viewvc/llvm-project?rev=294362=rev
Log:
[ASTReader] Improve ReadASTBlock error message when module not available

Point to the PCM file that could not be found.

rdar://problem/30381981

Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=294362=294361=294362=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue Feb  7 15:55:02 2017
@@ -2965,7 +2965,10 @@ ASTReader::ReadASTBlock(ModuleFile , u
 Data += Len;
 ModuleFile *OM = ModuleMgr.lookup(Name);
 if (!OM) {
-  Error("SourceLocation remap refers to unknown module");
+  std::string Msg =
+  "SourceLocation remap refers to unknown module, cannot find ";
+  Msg.append(Name);
+  Error(Msg);
   return Failure;
 }
 


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r294361 - [PCH] Fix a regression when PCH is used with -fmodules

2017-02-07 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Feb  7 15:54:57 2017
New Revision: 294361

URL: http://llvm.org/viewvc/llvm-project?rev=294361=rev
Log:
[PCH] Fix a regression when PCH is used with -fmodules

Following up on r291465 after a regression in r276159. When we use
-fmodule-name=X while building a PCH, modular headers in X will be
textually included and the compiler knows that we are not building
module X, so don't serialize such headers in the PCH as being part of a
module, because at this point they are not.

This was causing subtle bugs and malformed AST crashes, for instance,
when using the PCH in subsequent compiler invocation with -fmodules, the
HFI for a modular header would map to the PCH, which would force a
module load of and unexistent module ID.

rdar://problem/30171164

Added:
cfe/trunk/test/Modules/Inputs/invalid-module-id/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h

cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h

cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/

cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.modulemap

cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.private.modulemap
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/

cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NUAssert.h

cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/PrivateHeaders/NULog.h
cfe/trunk/test/Modules/invalid-pch-module-id.m
Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=294361=294360=294361=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Tue Feb  7 15:54:57 2017
@@ -2544,7 +2544,8 @@ unsigned ASTWriter::getLocalOrImportedSu
 
   auto *Top = Mod->getTopLevelModule();
   if (Top != WritingModule &&
-  !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule)))
+  (getLangOpts().CompilingPCH ||
+   !Top->fullModuleNameIs(StringRef(getLangOpts().CurrentModule
 return 0;
 
   return SubmoduleIDs[Mod] = NextSubmoduleID++;

Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch?rev=294361=auto
==
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch (added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC-Prefix.pch Tue Feb  7 
15:54:57 2017
@@ -0,0 +1,3 @@
+#ifdef __OBJC__
+  #import 
+#endif

Added: cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h?rev=294361=auto
==
--- cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NC.h 
Tue Feb  7 15:54:57 2017
@@ -0,0 +1 @@
+#import 

Added: 
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h?rev=294361=auto
==
--- 
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NU-Visibility.h
 Tue Feb  7 15:54:57 2017
@@ -0,0 +1 @@
+// NU-Visibility.h

Added: 
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h?rev=294361=auto
==
--- 
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Headers/NUGeometry.h
 Tue Feb  7 15:54:57 2017
@@ -0,0 +1 @@
+#import 

Added: 
cfe/trunk/test/Modules/Inputs/invalid-module-id/NC.framework/Modules/module.modulemap
URL: 

r292635 - [Sema] Remove dead typedef

2017-01-20 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Fri Jan 20 13:04:01 2017
New Revision: 292635

URL: http://llvm.org/viewvc/llvm-project?rev=292635=rev
Log:
[Sema] Remove dead typedef

Modified:
cfe/trunk/include/clang/Sema/Sema.h

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=292635=292634=292635=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Jan 20 13:04:01 2017
@@ -3207,7 +3207,6 @@ public:
  bool IsProtocolMethodDecl);
 
   typedef llvm::SmallPtrSet SelectorSet;
-  typedef llvm::DenseMap ProtocolsMethodsMap;
 
   /// CheckImplementationIvars - This routine checks if the instance variables
   /// listed in the implelementation match those listed in the interface.


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r291794 - [Modules] Fix misleading warning about missing textual header in umbrella header

2017-01-12 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Jan 12 13:15:33 2017
New Revision: 291794

URL: http://llvm.org/viewvc/llvm-project?rev=291794=rev
Log:
[Modules] Fix misleading warning about missing textual header in umbrella header

When a textual header is present inside a umbrella dir but not in the
header, we get the misleading warning:

warning: umbrella header for module 'FooFramework' does not include
header 'Baz_Private.h'

The module map in question:

framework module FooFramework {
umbrella header "FooUmbrella.h"

export *
module * { export * }

module Private {
textual header "Baz_Private.h"
}
}

Fix this by taking textual headers into account.

Added:
cfe/trunk/test/Modules/Inputs/FooFramework.framework/
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/

cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h

cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h

cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/FooUmbrella.h
cfe/trunk/test/Modules/textual-hdr-in-umbrella-hdr.m
Modified:
cfe/trunk/lib/Lex/ModuleMap.cpp

Modified: cfe/trunk/lib/Lex/ModuleMap.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/ModuleMap.cpp?rev=291794=291793=291794=diff
==
--- cfe/trunk/lib/Lex/ModuleMap.cpp (original)
+++ cfe/trunk/lib/Lex/ModuleMap.cpp Thu Jan 12 13:15:33 2017
@@ -446,9 +446,19 @@ ModuleMap::isHeaderUnavailableInModule(c
  I = Known->second.begin(),
  E = Known->second.end();
  I != E; ++I) {
-  if (I->isAvailable() && (!RequestingModule ||
-   
I->getModule()->isSubModuleOf(RequestingModule)))
+
+  if (I->isAvailable() &&
+  (!RequestingModule ||
+   I->getModule()->isSubModuleOf(RequestingModule))) {
+// When no requesting module is available, the caller is looking if a
+// header is part a module by only looking into the module map. This is
+// done by warn_uncovered_module_header checks; don't consider textual
+// headers part of it in this mode, otherwise we get misleading 
warnings
+// that a umbrella header is not including a textual header.
+if (!RequestingModule && I->getRole() == ModuleMap::TextualHeader)
+  continue;
 return false;
+  }
 }
 return true;
   }

Added: 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap?rev=291794=auto
==
--- 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap 
(added)
+++ 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/Modules/module.modulemap 
Thu Jan 12 13:15:33 2017
@@ -0,0 +1,12 @@
+framework module FooFramework {
+umbrella header "FooUmbrella.h"
+
+export *
+module * {
+export *
+}
+
+explicit module Private {
+textual header "Baz_Private.h"
+}
+}

Added: cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h?rev=291794=auto
==
--- cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h 
(added)
+++ cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Bar.h 
Thu Jan 12 13:15:33 2017
@@ -0,0 +1,2 @@
+@interface Bar
+@end

Added: 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h?rev=291794=auto
==
--- 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
 (added)
+++ 
cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Baz_Private.h
 Thu Jan 12 13:15:33 2017
@@ -0,0 +1,3 @@
+#ifndef Baz_h
+#define Baz_h
+#endif /* Baz_h */

Added: cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h?rev=291794=auto
==
--- cfe/trunk/test/Modules/Inputs/FooFramework.framework/PrivateHeaders/Foo.h 
(added)
+++ 

r291644 - [Modules] Support #import when entering files with modules

2017-01-10 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Tue Jan 10 20:14:51 2017
New Revision: 291644

URL: http://llvm.org/viewvc/llvm-project?rev=291644=rev
Log:
[Modules] Support #import when entering files with modules

Textual headers and builtins that are #import'd from different
modules should get re-entered when these modules are independent
from each other.

Differential Revision: https://reviews.llvm.org/D26267

rdar://problem/25881934

Added:
cfe/trunk/test/Modules/Inputs/import-textual/
cfe/trunk/test/Modules/Inputs/import-textual/M/
cfe/trunk/test/Modules/Inputs/import-textual/M/A/
cfe/trunk/test/Modules/Inputs/import-textual/M/A/A.h
cfe/trunk/test/Modules/Inputs/import-textual/M/B/
cfe/trunk/test/Modules/Inputs/import-textual/M/B/B.h
cfe/trunk/test/Modules/Inputs/import-textual/M/module.modulemap
cfe/trunk/test/Modules/Inputs/import-textual/M/someheader.h
cfe/trunk/test/Modules/Inputs/import-textual/M2/
cfe/trunk/test/Modules/Inputs/import-textual/M2/A/
cfe/trunk/test/Modules/Inputs/import-textual/M2/A/A.h
cfe/trunk/test/Modules/Inputs/import-textual/M2/B/
cfe/trunk/test/Modules/Inputs/import-textual/M2/B/B.h
cfe/trunk/test/Modules/Inputs/import-textual/M2/module.modulemap
cfe/trunk/test/Modules/Inputs/import-textual/M2/someheader.h
cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/cstddef

cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/type_traits
cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/
cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/

cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_ptrdiff_t.h

cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/sys/_types/_types.h
cfe/trunk/test/Modules/builtin-import.mm
cfe/trunk/test/Modules/import-textual-noguard.mm
cfe/trunk/test/Modules/import-textual.mm
Modified:
cfe/trunk/include/clang/Lex/HeaderSearch.h
cfe/trunk/include/clang/Lex/ModuleMap.h
cfe/trunk/lib/Lex/HeaderSearch.cpp
cfe/trunk/lib/Lex/ModuleMap.cpp
cfe/trunk/lib/Lex/PPDirectives.cpp
cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/math.h

cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/module.modulemap

cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/c++/v1/stddef.h

cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/module.modulemap
cfe/trunk/test/Modules/Inputs/libc-libcxx/sysroot/usr/include/stddef.h

Modified: cfe/trunk/include/clang/Lex/HeaderSearch.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/HeaderSearch.h?rev=291644=291643=291644=diff
==
--- cfe/trunk/include/clang/Lex/HeaderSearch.h (original)
+++ cfe/trunk/include/clang/Lex/HeaderSearch.h Tue Jan 10 20:14:51 2017
@@ -406,7 +406,8 @@ public:
   /// \return false if \#including the file will have no effect or true
   /// if we should include it.
   bool ShouldEnterIncludeFile(Preprocessor , const FileEntry *File,
-  bool isImport, Module *CorrespondingModule);
+  bool isImport, bool ModulesEnabled,
+  Module *CorrespondingModule);
 
   /// \brief Return whether the specified file is a normal header,
   /// a system header, or a C++ friendly system header.

Modified: cfe/trunk/include/clang/Lex/ModuleMap.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/ModuleMap.h?rev=291644=291643=291644=diff
==
--- cfe/trunk/include/clang/Lex/ModuleMap.h (original)
+++ cfe/trunk/include/clang/Lex/ModuleMap.h Tue Jan 10 20:14:51 2017
@@ -316,6 +316,14 @@ public:
 BuiltinIncludeDir = Dir;
   }
 
+  /// \brief Get the directory that contains Clang-supplied include files.
+  const DirectoryEntry *getBuiltinDir() const {
+return BuiltinIncludeDir;
+  }
+
+  /// \brief Is this a compiler builtin header?
+  static bool isBuiltinHeader(StringRef FileName);
+
   /// \brief Add a module map callback.
   void addModuleMapCallbacks(std::unique_ptr Callback) {
 Callbacks.push_back(std::move(Callback));

Modified: cfe/trunk/lib/Lex/HeaderSearch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/HeaderSearch.cpp?rev=291644=291643=291644=diff
==
--- cfe/trunk/lib/Lex/HeaderSearch.cpp (original)
+++ cfe/trunk/lib/Lex/HeaderSearch.cpp Tue Jan 10 20:14:51 2017
@@ -1092,13 +1092,51 @@ void HeaderSearch::MarkFileModuleHeader(
 }
 
 bool HeaderSearch::ShouldEnterIncludeFile(Preprocessor ,
-  const FileEntry *File,
-  bool isImport, Module *M) {
+  const FileEntry *File, bool 

Re: [libcxx] r291466 - [Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW

2017-01-09 Thread Bruno Cardoso Lopes via cfe-commits
Ops. Fixed in r291517!

On Mon, Jan 9, 2017 at 2:13 PM, Reid Kleckner <r...@google.com> wrote:
> This appears to have broken the Chromium build:
> https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac/builds/12620/steps/gclient%20runhooks/logs/stdio
> FAILED: projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o
> /Applications/Xcode8.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
> -D_DEBUG -D_LIBCPP_BUILDING_LIBRARY -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Iprojects/libcxx/lib
> -I/b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/lib -Iinclude
> -I/b/c/b/ClangToTMac/src/third_party/llvm/include
> -I/b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/include
> -DLLVM_FORCE_HEAD_REVISION -fPIC -fvisibility-inlines-hidden -Wall -W
> -Wno-unused-parameter -Wwrite-strings -Wcast-qual
> -Wmissing-field-initializers  -Wno-long-long -Wcovered-switch-default
> -Wnon-virtual-dtor -Wdelete-non-virtual-dtor -Wstring-conversion
> -Werror=date-time -std=c++11 -fcolor-diagnostics -O3  -isysroot
> /Applications/Xcode8.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.12.sdk
> -mmacosx-version-min=10.11-UNDEBUG -std=c++11 -nostdinc++
> -fvisibility-inlines-hidden -Wall -Wextra -W -Wwrite-strings
> -Wno-unused-parameter -Wno-long-long -Werror=return-type
> -Wno-user-defined-literals -Wno-covered-switch-default -Wno-error -fPIC -MMD
> -MT projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o -MF
> projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o.d -o
> projects/libcxx/lib/CMakeFiles/cxx_objects.dir/__/src/chrono.cpp.o -c
> /b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/src/chrono.cpp
> /b/c/b/ClangToTMac/src/third_party/llvm/projects/libcxx/src/chrono.cpp:102:5:
> error: use of undeclared identifier 'gettimeofday'
> gettimeofday(, 0);
> ^
>
> The interesting flag in there is probably -mmacosx-version-min=10.11. Any
> thoughts on what's going wrong?
>
> On Mon, Jan 9, 2017 at 11:21 AM, Bruno Cardoso Lopes via cfe-commits
> <cfe-commits@lists.llvm.org> wrote:
>>
>> Author: bruno
>> Date: Mon Jan  9 13:21:48 2017
>> New Revision: 291466
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=291466=rev
>> Log:
>> [Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW
>>
>> Use CLOCK_UPTIME_RAW in case clock_gettime is available on Darwin.
>>
>> On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able
>> to time functions in the nanosecond range. Thus, they are the only
>> acceptable implementations of steady_clock.
>>
>> Differential Revision: https://reviews.llvm.org/D27429
>>
>> rdar://problem/29449467
>>
>> Modified:
>> libcxx/trunk/src/chrono.cpp
>>
>> Modified: libcxx/trunk/src/chrono.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=291466=291465=291466=diff
>>
>> ==
>> --- libcxx/trunk/src/chrono.cpp (original)
>> +++ libcxx/trunk/src/chrono.cpp Mon Jan  9 13:21:48 2017
>> @@ -12,6 +12,28 @@
>>  #include "system_error"  // __throw_system_error
>>  #include // clock_gettime, CLOCK_MONOTONIC and
>> CLOCK_REALTIME
>>
>> +#if (__APPLE__)
>> +#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
>> +#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
>> +#define _LIBCXX_USE_CLOCK_GETTIME
>> +#endif
>> +#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
>> +#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 10
>> +#define _LIBCXX_USE_CLOCK_GETTIME
>> +#endif
>> +#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
>> +#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 10
>> +#define _LIBCXX_USE_CLOCK_GETTIME
>> +#endif
>> +#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
>> +#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 3
>> +#define _LIBCXX_USE_CLOCK_GETTIME
>> +#endif
>> +#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
>> +#else
>> +#define _LIBCXX_USE_CLOCK_GETTIME
>> +#endif // __APPLE__
>> +
>>  #if defined(_LIBCPP_WIN32API)
>>  #define WIN32_LEAN_AND_MEAN
>>  #define VC_EXTRA_LEAN
>> @@ -70,16 +92,16 @@ system_clock::now() _NOEXCEPT
>> static_cast<__int64>(ft.dwLowDateTime)};
>>return time_point(duration_cast(d - nt_to_unix_epoch));
>>  #else
>> -#ifdef CLOCK_

[libcxx] r291517 - [Chrono][Darwin] Include header for gettimeofday

2017-01-09 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Jan  9 18:51:02 2017
New Revision: 291517

URL: http://llvm.org/viewvc/llvm-project?rev=291517=rev
Log:
[Chrono][Darwin] Include header for gettimeofday

Followup on r291466 and include the proper header. This fixes:
https://build.chromium.org/p/chromium.fyi/builders/ClangToTMac/builds/12620/steps/gclient%20runhooks/logs/stdio

Modified:
libcxx/trunk/src/chrono.cpp

Modified: libcxx/trunk/src/chrono.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=291517=291516=291517=diff
==
--- libcxx/trunk/src/chrono.cpp (original)
+++ libcxx/trunk/src/chrono.cpp Mon Jan  9 18:51:02 2017
@@ -42,7 +42,7 @@
 #include 
 #endif
 #else
-#if !defined(CLOCK_REALTIME)
+#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME)
 #include // for gettimeofday and timeval
 #endif // !defined(CLOCK_REALTIME)
 #endif // defined(_LIBCPP_WIN32API)


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r291466 - [Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW

2017-01-09 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Jan  9 13:21:48 2017
New Revision: 291466

URL: http://llvm.org/viewvc/llvm-project?rev=291466=rev
Log:
[Chrono][Darwin] Make steady_clock use CLOCK_UPTIME_RAW

Use CLOCK_UPTIME_RAW in case clock_gettime is available on Darwin.

On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able
to time functions in the nanosecond range. Thus, they are the only
acceptable implementations of steady_clock.

Differential Revision: https://reviews.llvm.org/D27429

rdar://problem/29449467

Modified:
libcxx/trunk/src/chrono.cpp

Modified: libcxx/trunk/src/chrono.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/chrono.cpp?rev=291466=291465=291466=diff
==
--- libcxx/trunk/src/chrono.cpp (original)
+++ libcxx/trunk/src/chrono.cpp Mon Jan  9 13:21:48 2017
@@ -12,6 +12,28 @@
 #include "system_error"  // __throw_system_error
 #include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
 
+#if (__APPLE__)
+#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
+#define _LIBCXX_USE_CLOCK_GETTIME
+#endif
+#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 10
+#define _LIBCXX_USE_CLOCK_GETTIME
+#endif
+#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 10
+#define _LIBCXX_USE_CLOCK_GETTIME
+#endif
+#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
+#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 3
+#define _LIBCXX_USE_CLOCK_GETTIME
+#endif
+#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
+#else
+#define _LIBCXX_USE_CLOCK_GETTIME
+#endif // __APPLE__
+
 #if defined(_LIBCPP_WIN32API)
 #define WIN32_LEAN_AND_MEAN
 #define VC_EXTRA_LEAN
@@ -70,16 +92,16 @@ system_clock::now() _NOEXCEPT
static_cast<__int64>(ft.dwLowDateTime)};
   return time_point(duration_cast(d - nt_to_unix_epoch));
 #else
-#ifdef CLOCK_REALTIME
+#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
 struct timespec tp;
 if (0 != clock_gettime(CLOCK_REALTIME, ))
 __throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
 return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
-#else  // !CLOCK_REALTIME
+#else
 timeval tv;
 gettimeofday(, 0);
 return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
-#endif  // CLOCK_REALTIME
+#endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
 #endif
 }
 
@@ -106,6 +128,18 @@ const bool steady_clock::is_steady;
 
 #if defined(__APPLE__)
 
+// Darwin libc versions >= 1133 provide ns precision via CLOCK_UPTIME_RAW
+#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
+steady_clock::time_point
+steady_clock::now() _NOEXCEPT
+{
+struct timespec tp;
+if (0 != clock_gettime(CLOCK_UPTIME_RAW, ))
+__throw_system_error(errno, "clock_gettime(CLOCK_UPTIME_RAW) failed");
+return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_nsec));
+}
+
+#else
 //   mach_absolute_time() * MachInfo.numer / MachInfo.denom is the number of
 //   nanoseconds since the computer booted up.  MachInfo.numer and 
MachInfo.denom
 //   are run time constants supplied by the OS.  This clock has no relationship
@@ -157,6 +191,7 @@ steady_clock::now() _NOEXCEPT
 static FP fp = init_steady_clock();
 return time_point(duration(fp()));
 }
+#endif // defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
 
 #elif defined(_LIBCPP_WIN32API)
 
@@ -175,6 +210,13 @@ steady_clock::now() _NOEXCEPT
 
 #elif defined(CLOCK_MONOTONIC)
 
+// On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to
+// time functions in the nanosecond range. Thus, they are the only acceptable
+// implementations of steady_clock.
+#ifdef __APPLE__
+#error "Never use CLOCK_MONOTONIC for steady_clock::now on Apple platforms"
+#endif
+
 steady_clock::time_point
 steady_clock::now() _NOEXCEPT
 {


___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r290326 - [CrashReproducer] Add support for merging -ivfsoverlay

2016-12-21 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Thu Dec 22 01:06:03 2016
New Revision: 290326

URL: http://llvm.org/viewvc/llvm-project?rev=290326=rev
Log:
[CrashReproducer] Add support for merging -ivfsoverlay

Merge all VFS mapped files inside -ivfsoverlay inputs into the vfs
overlay provided by the crash reproducer. This is the last missing piece
to allow crash reproducers to fully work with user frameworks; when
combined with headermaps, it allows clang to find additional frameworks.

rdar://problem/27913709

Added:
cfe/trunk/test/Modules/crash-vfs-ivfsoverlay.m
Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/include/clang/Frontend/Utils.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=290326=290325=290326=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Thu Dec 22 01:06:03 2016
@@ -362,6 +362,16 @@ struct YAMLVFSEntry {
   std::string RPath;
 };
 
+/// \brief Collect all pairs of  entries from the
+/// \p YAMLFilePath. This is used by the module dependency collector to forward
+/// the entries into the reproducer output VFS YAML file.
+void collectVFSFromYAML(
+std::unique_ptr Buffer,
+llvm::SourceMgr::DiagHandlerTy DiagHandler, StringRef YAMLFilePath,
+SmallVectorImpl ,
+void *DiagContext = nullptr,
+IntrusiveRefCntPtr ExternalFS = getRealFileSystem());
+
 class YAMLVFSWriter {
   std::vector Mappings;
   Optional IsCaseSensitive;

Modified: cfe/trunk/include/clang/Frontend/Utils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/Utils.h?rev=290326=290325=290326=diff
==
--- cfe/trunk/include/clang/Frontend/Utils.h (original)
+++ cfe/trunk/include/clang/Frontend/Utils.h Thu Dec 22 01:06:03 2016
@@ -128,11 +128,11 @@ class ModuleDependencyCollector : public
   llvm::StringMap SymLinkMap;
 
   bool getRealPath(StringRef SrcPath, SmallVectorImpl );
-  std::error_code copyToRoot(StringRef Src);
+  std::error_code copyToRoot(StringRef Src, StringRef Dst = "");
 public:
   StringRef getDest() { return DestDir; }
   bool insertSeen(StringRef Filename) { return Seen.insert(Filename).second; }
-  void addFile(StringRef Filename);
+  void addFile(StringRef Filename, StringRef FileDst = "");
   void addFileMapping(StringRef VPath, StringRef RPath) {
 VFSWriter.addFileMapping(VPath, RPath);
   }

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=290326=290325=290326=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Thu Dec 22 01:06:03 2016
@@ -887,9 +887,6 @@ private:
   RedirectingFileSystem(IntrusiveRefCntPtr ExternalFS)
   : ExternalFS(std::move(ExternalFS)) {}
 
-  /// \brief Looks up \p Path in \c Roots.
-  ErrorOr lookupPath(const Twine );
-
   /// \brief Looks up the path [Start, End) in \p From, possibly
   /// recursing into the contents of \p From if it is a directory.
   ErrorOr lookupPath(sys::path::const_iterator Start,
@@ -899,6 +896,9 @@ private:
   ErrorOr status(const Twine , Entry *E);
 
 public:
+  /// \brief Looks up \p Path in \c Roots.
+  ErrorOr lookupPath(const Twine );
+
   /// \brief Parses \p Buffer, which is expected to be in YAML format and
   /// returns a virtual file system representing its contents.
   static RedirectingFileSystem *
@@ -1606,6 +1606,47 @@ vfs::getVFSFromYAML(std::unique_ptr ,
+  SmallVectorImpl ) {
+  auto Kind = SrcE->getKind();
+  if (Kind == EK_Directory) {
+auto *DE = dyn_cast(SrcE);
+assert(DE && "Must be a directory");
+for (std::unique_ptr  :
+ llvm::make_range(DE->contents_begin(), DE->contents_end())) {
+  Path.push_back(SubEntry->getName());
+  getVFSEntries(SubEntry.get(), Path, Entries);
+  Path.pop_back();
+}
+return;
+  }
+
+  assert(Kind == EK_File && "Must be a EK_File");
+  auto *FE = dyn_cast(SrcE);
+  assert(FE && "Must be a file");
+  SmallString<128> VPath;
+  for (auto  : Path)
+llvm::sys::path::append(VPath, Comp);
+  Entries.push_back(YAMLVFSEntry(VPath.c_str(), 
FE->getExternalContentsPath()));
+}
+
+void vfs::collectVFSFromYAML(std::unique_ptr Buffer,
+ SourceMgr::DiagHandlerTy DiagHandler,
+ StringRef YAMLFilePath,
+ SmallVectorImpl ,
+ void *DiagContext,
+ 

<    1   2   3   4   5   6   >