Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On 21.11.2017, at 03:54, Volodymyr Sapsai  wrote:
> 
>> If (exceptions()) != 0 then the exception is rethrown.
> And looks like libstdc++ rethrows exception even if badbit is not set.

Thanks for looking all that up, I was in a hurry.

> If you feel comfortable, I can finish exception tests myself and commit the 
> patch. How does it sound?

That would be very welcome if you don't mind.
I don't have much time over to spend on this most days.

Thanks,
Reimar Döffinger___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r318722 - Re-revert "Refactor debuginfo-tests."

2017-11-20 Thread Don Hinton via cfe-commits
On Mon, Nov 20, 2017 at 5:20 PM, Zachary Turner via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: zturner
> Date: Mon Nov 20 17:20:28 2017
> New Revision: 318722
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318722=rev
> Log:
> Re-revert "Refactor debuginfo-tests."
>
> This is still breaking greendragon.
>
> At this point I give up until someone can fix the greendragon
> bots, and I will probably abandon this effort in favor of using
> a private github repository.
>
> Modified:
> cfe/trunk/test/CMakeLists.txt
> cfe/trunk/test/lit.cfg.py
>
> Modified: cfe/trunk/test/CMakeLists.txt
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CMakeLists.txt?rev=318722=318721=318722=diff
> 
> ==
> --- cfe/trunk/test/CMakeLists.txt (original)
> +++ cfe/trunk/test/CMakeLists.txt Mon Nov 20 17:20:28 2017
> @@ -88,14 +88,6 @@ set(CLANG_TEST_PARAMS
>clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
>)
>
> -if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt")
> -  # This is a hack to keep existing build build infrastructure working
> while we
> -  # can migrate to the new standard workflow of checking out
> debuginfo-tests into
> -  # llvm/projects or using it in a mono-repo
> -  set(DEBUGINFO_TESTS_EXCLUDE_FROM_ALL ON)
> -  add_subdirectory(debuginfo-tests)
> -endif()
> -
>

I think this is your problem.  Essentially, you are adding the tests twice,
once by recursing tree (this is the original behavior and picks up all the
tests in the new test subdir), and once explicitly by including the
debuginfo-tests subdirectory, which has a CMakeLists.txt file that adds the
tests again.


>  if( NOT CLANG_BUILT_STANDALONE )
>list(APPEND CLANG_TEST_DEPS
>  llvm-config
>
> Modified: cfe/trunk/test/lit.cfg.py
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.
> cfg.py?rev=318722=318721=318722=diff
> 
> ==
> --- cfe/trunk/test/lit.cfg.py (original)
> +++ cfe/trunk/test/lit.cfg.py Mon Nov 20 17:20:28 2017
> @@ -58,6 +58,8 @@ tool_dirs = [config.clang_tools_dir, con
>
>  tools = [
>  'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt',
> +ToolSubst('%test_debuginfo', command=os.path.join(
> +config.llvm_src_root, 'utils', 'test_debuginfo.pl')),
>  ToolSubst('%clang_func_map', command=FindTool(
>  'clang-func-mapping'), unresolved='ignore'),
>  ]
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart updated this revision to Diff 123720.
ogoffart added a comment.
Herald added a subscriber: klimek.

I added a test.
I did not add such test before because i know that calling Reset() on the 
diagnostics is kind of a hack.

This change does not have any behavioral difference normally, it is just an 
optimization that skips the computation of the CFG if all warnings are ignored.


https://reviews.llvm.org/D40242

Files:
  lib/Sema/AnalysisBasedWarnings.cpp
  unittests/Tooling/ToolingTest.cpp


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -533,5 +533,31 @@
 }
 #endif
 
+TEST(runToolOnCode, TestResetDiagnostics) {
+  // This is a tool that resets the diagnostic during the compilation.
+  struct ResetDiagnosticAction : public clang::ASTFrontendAction {
+std::unique_ptr CreateASTConsumer(CompilerInstance ,
+   StringRef) override {
+  struct Consumer : public clang::ASTConsumer {
+bool HandleTopLevelDecl(clang::DeclGroupRef D) override {
+  auto  = (*D.begin())->getASTContext().getDiagnostics();
+  // Ignore any error
+  Diags.Reset();
+  // Disable warnings because computing the CFG might crash.
+  Diags.setIgnoreAllWarnings(true);
+  return true;
+}
+  };
+  return llvm::make_unique();
+}
+  };
+
+  // Should not crash
+  EXPECT_FALSE(
+  runToolOnCode(new ResetDiagnosticAction,
+"struct Foo { Foo(int); ~Foo(); struct Fwd _fwd; };"
+"void func() { long x; Foo f(x); }"));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -2080,10 +2080,10 @@
   // time.
   DiagnosticsEngine  = S.getDiagnostics();
 
-  // Do not do any analysis for declarations in system headers if we are
-  // going to just ignore them.
-  if (Diags.getSuppressSystemWarnings() &&
-  S.SourceMgr.isInSystemHeader(D->getLocation()))
+  // Do not do any analysis if we are going to just ignore them.
+  if (Diags.getIgnoreAllWarnings() ||
+  (Diags.getSuppressSystemWarnings() &&
+   S.SourceMgr.isInSystemHeader(D->getLocation(
 return;
 
   // For code in dependent contexts, we'll do this at instantiation time.


Index: unittests/Tooling/ToolingTest.cpp
===
--- unittests/Tooling/ToolingTest.cpp
+++ unittests/Tooling/ToolingTest.cpp
@@ -533,5 +533,31 @@
 }
 #endif
 
+TEST(runToolOnCode, TestResetDiagnostics) {
+  // This is a tool that resets the diagnostic during the compilation.
+  struct ResetDiagnosticAction : public clang::ASTFrontendAction {
+std::unique_ptr CreateASTConsumer(CompilerInstance ,
+   StringRef) override {
+  struct Consumer : public clang::ASTConsumer {
+bool HandleTopLevelDecl(clang::DeclGroupRef D) override {
+  auto  = (*D.begin())->getASTContext().getDiagnostics();
+  // Ignore any error
+  Diags.Reset();
+  // Disable warnings because computing the CFG might crash.
+  Diags.setIgnoreAllWarnings(true);
+  return true;
+}
+  };
+  return llvm::make_unique();
+}
+  };
+
+  // Should not crash
+  EXPECT_FALSE(
+  runToolOnCode(new ResetDiagnosticAction,
+"struct Foo { Foo(int); ~Foo(); struct Fwd _fwd; };"
+"void func() { long x; Foo f(x); }"));
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Sema/AnalysisBasedWarnings.cpp
===
--- lib/Sema/AnalysisBasedWarnings.cpp
+++ lib/Sema/AnalysisBasedWarnings.cpp
@@ -2080,10 +2080,10 @@
   // time.
   DiagnosticsEngine  = S.getDiagnostics();
 
-  // Do not do any analysis for declarations in system headers if we are
-  // going to just ignore them.
-  if (Diags.getSuppressSystemWarnings() &&
-  S.SourceMgr.isInSystemHeader(D->getLocation()))
+  // Do not do any analysis if we are going to just ignore them.
+  if (Diags.getIgnoreAllWarnings() ||
+  (Diags.getSuppressSystemWarnings() &&
+   S.SourceMgr.isInSystemHeader(D->getLocation(
 return;
 
   // For code in dependent contexts, we'll do this at instantiation time.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D39936: [OpenCL] Add extensions cl_intel_subgroups and cl_intel_subgroups_short

2017-11-20 Thread Alexey Sotkin via Phabricator via cfe-commits
AlexeySotkin updated this revision to Diff 123716.
AlexeySotkin added a comment.

Replacing #define macros with explicit declarations


https://reviews.llvm.org/D39936

Files:
  include/clang/Basic/OpenCLExtensions.def
  lib/Headers/opencl-c.h
  test/SemaOpenCL/extension-version.cl

Index: test/SemaOpenCL/extension-version.cl
===
--- test/SemaOpenCL/extension-version.cl
+++ test/SemaOpenCL/extension-version.cl
@@ -273,3 +273,21 @@
 #endif
 #pragma OPENCL EXTENSION cl_amd_media_ops2: enable
 
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_intel_subgroups
+#error "Missing cl_intel_subgroups define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_intel_subgroups : enable
+
+#if (__OPENCL_C_VERSION__ >= 120)
+#ifndef cl_intel_subgroups_short
+#error "Missing cl_intel_subgroups_short define"
+#endif
+#else
+// expected-warning@+2{{unsupported OpenCL extension 'cl_intel_subgroups_short' - ignoring}}
+#endif
+#pragma OPENCL EXTENSION cl_intel_subgroups_short : enable
+
Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -15886,6 +15886,313 @@
 
 #endif //cl_khr_subgroups cl_intel_subgroups
 
+#if defined(cl_intel_subgroups)
+// Intel-Specific Sub Group Functions
+float   __ovld __conv intel_sub_group_shuffle( float  x, uint c );
+float2  __ovld __conv intel_sub_group_shuffle( float2 x, uint c );
+float3  __ovld __conv intel_sub_group_shuffle( float3 x, uint c );
+float4  __ovld __conv intel_sub_group_shuffle( float4 x, uint c );
+float8  __ovld __conv intel_sub_group_shuffle( float8 x, uint c );
+float16 __ovld __conv intel_sub_group_shuffle( float16 x, uint c );
+
+int __ovld __conv intel_sub_group_shuffle( int  x, uint c );
+int2__ovld __conv intel_sub_group_shuffle( int2 x, uint c );
+int3__ovld __conv intel_sub_group_shuffle( int3 x, uint c );
+int4__ovld __conv intel_sub_group_shuffle( int4 x, uint c );
+int8__ovld __conv intel_sub_group_shuffle( int8 x, uint c );
+int16   __ovld __conv intel_sub_group_shuffle( int16 x, uint c );
+
+uint__ovld __conv intel_sub_group_shuffle( uint  x, uint c );
+uint2   __ovld __conv intel_sub_group_shuffle( uint2 x, uint c );
+uint3   __ovld __conv intel_sub_group_shuffle( uint3 x, uint c );
+uint4   __ovld __conv intel_sub_group_shuffle( uint4 x, uint c );
+uint8   __ovld __conv intel_sub_group_shuffle( uint8 x, uint c );
+uint16  __ovld __conv intel_sub_group_shuffle( uint16 x, uint c );
+
+long__ovld __conv intel_sub_group_shuffle( long x, uint c );
+ulong   __ovld __conv intel_sub_group_shuffle( ulong x, uint c );
+
+float   __ovld __conv intel_sub_group_shuffle_down( float  cur, float  next, uint c );
+float2  __ovld __conv intel_sub_group_shuffle_down( float2 cur, float2 next, uint c );
+float3  __ovld __conv intel_sub_group_shuffle_down( float3 cur, float3 next, uint c );
+float4  __ovld __conv intel_sub_group_shuffle_down( float4 cur, float4 next, uint c );
+float8  __ovld __conv intel_sub_group_shuffle_down( float8 cur, float8 next, uint c );
+float16 __ovld __conv intel_sub_group_shuffle_down( float16 cur, float16 next, uint c );
+
+int __ovld __conv intel_sub_group_shuffle_down( int  cur, int  next, uint c );
+int2__ovld __conv intel_sub_group_shuffle_down( int2 cur, int2 next, uint c );
+int3__ovld __conv intel_sub_group_shuffle_down( int3 cur, int3 next, uint c );
+int4__ovld __conv intel_sub_group_shuffle_down( int4 cur, int4 next, uint c );
+int8__ovld __conv intel_sub_group_shuffle_down( int8 cur, int8 next, uint c );
+int16   __ovld __conv intel_sub_group_shuffle_down( int16 cur, int16 next, uint c );
+
+uint__ovld __conv intel_sub_group_shuffle_down( uint  cur, uint  next, uint c );
+uint2   __ovld __conv intel_sub_group_shuffle_down( uint2 cur, uint2 next, uint c );
+uint3   __ovld __conv intel_sub_group_shuffle_down( uint3 cur, uint3 next, uint c );
+uint4   __ovld __conv intel_sub_group_shuffle_down( uint4 cur, uint4 next, uint c );
+uint8   __ovld __conv intel_sub_group_shuffle_down( uint8 cur, uint8 next, uint c );
+uint16  __ovld __conv intel_sub_group_shuffle_down( uint16 cur, uint16 next, uint c );
+
+long__ovld __conv intel_sub_group_shuffle_down( long prev, long cur, uint c );
+ulong   __ovld __conv intel_sub_group_shuffle_down( ulong prev, ulong cur, uint c );
+
+float   __ovld __conv intel_sub_group_shuffle_up( float  prev, float  cur, uint c );
+float2  __ovld __conv intel_sub_group_shuffle_up( float2 prev, float2 cur, uint c );
+float3  __ovld __conv intel_sub_group_shuffle_up( float3 prev, float3 cur, uint c );
+float4  __ovld __conv intel_sub_group_shuffle_up( float4 prev, float4 cur, uint c );
+float8  __ovld __conv intel_sub_group_shuffle_up( float8 prev, float8 cur, uint c );
+float16 __ovld __conv intel_sub_group_shuffle_up( 

[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D40242#931173, @ogoffart wrote:

> > You should add a test case that demonstrates code which would otherwise 
> > trigger an analysis-based warning but doesn't due to disabling all warnings.
>
> No warnings are triggered. Because the diagnostic engine ignores them.
>  This just optimize the code so no analysis are preformed when no warning can 
> be triggered.


Correct -- I'm asking for a test that ensures we don't regress the intended 
behavior of this patch by accident at some point (behavioral changes should 
always have at least one accompanying test).


https://reviews.llvm.org/D40242



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


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Olivier Goffart via Phabricator via cfe-commits
ogoffart marked an inline comment as done.
ogoffart added a comment.

> You should add a test case that demonstrates code which would otherwise 
> trigger an analysis-based warning but doesn't due to disabling all warnings.

No warnings are triggered. Because the diagnostic engine ignores them.
This just optimize the code so no analysis are preformed when no warning can be 
triggered.


https://reviews.llvm.org/D40242



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


[PATCH] D40270: [Modules TS] Added re-export support

2017-11-20 Thread Boris Kolpackov via Phabricator via cfe-commits
boris added a comment.

LGTM. Will be happy to also run our re-export tests in build2 once this is 
merged.


https://reviews.llvm.org/D40270



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


[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Did you decide on fuchsia instead of zircon for the module name, or is that 
decision still up in the air?




Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:22
+  // Calling a function which uses default arguments is disallowed.
+  Finder->addMatcher(cxxDefaultArgExpr().bind("stmt"), this);
+  // Declaring default parameters is disallowed.

juliehockett wrote:
> aaron.ballman wrote:
> > Isn't this case already covered by the other matcher? Or do you have system 
> > header files which have default arguments and those functions are 
> > disallowed by the style guide, but cannot be removed from the system header?
> The latter -- there's a bunch of third-party code and the like that could 
> have default arguments, but shouldn't be used like that in the project.
Ah, that makes sense. Thanks!



Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:29
+diag(S->getUsedLocation(),
+ "calling functions which use default arguments are disallowed");
+diag(S->getParam()->getLocStart(), 

I think the diagnostic should be in singular form. How about: `calling a 
function that uses a default argument is disallowed`?



Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:35-38
+SourceRange RemovalRange(
+  Lexer::getLocForEndOfToken(D->getLocation(), 0, 
+*Result.SourceManager, Result.Context->getLangOpts()),
+  D->getDefaultArgRange().getEnd()

Does `getDefaultArgRange()` not provide the correct range already (so you don't 
need to go back to the original source)? Or does that range miss the `=`?

You might want to disable the fix-it in the case `getDefaultArgRange()` returns 
an empty range, or in case the default arg expression comes from a macro (and 
add a test for the latter case). e.g.,
```
#define DERP(val)  = val

void f(int i DERP);
```
Additionally, a test where the identifier is elided would be good as well: 
`void f(int = 12);`



Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:41
+diag(D->getLocStart(),
+ "declaring functions which use default arguments are disallowed")
+ << D

This diagnostic could be similarly tightened -- the function isn't the issue, 
the parameter with the default argument is. Perhaps: `declaring a parameter 
with a default value is disallowed`?



Comment at: docs/clang-tidy/checks/fuchsia-default-arguments.rst:16-17
+
+If a function with default arguments is already defined, calling it with no
+arguments will also cause a warning. Calling it without defaults will not cause
+a warning:

The wording here is a bit confusing; it's not that calling it with no arguments 
causes the warning, it's that calling it such that the default argument value 
is used that's the problem. Perhaps: `A function call expression that uses a 
default argument will be diagnosed.` or something along those lines.


https://reviews.llvm.org/D40108



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


[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-11-20 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

In https://reviews.llvm.org/D35755#930789, @fedor.sergeev wrote:

> In https://reviews.llvm.org/D35755#930030, @ro wrote:
>
> > What's the status here?  This patch is required for my WIP 
> > sanitizers-on-Solaris work.
>
>
> since @tstellar just resolved the only remaining question I will go change 
> the questionable part to linux-only and then I consider this ready to go.
>  Then we just have to find somebody who is willing to press the green 
> button...
>  Thanks for keeping this topic alive, I kinda stopped pinging it.


Do we still target Oracle Solaris or SmartOS? Just wondering and noted the 
domain change in e-mail.


https://reviews.llvm.org/D35755



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


[PATCH] D40280: [CMake][libcxx] Include AddLLVM needed for tests in the right context

2017-11-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
Herald added a subscriber: mgorny.

AddLLVM is needed for several functions that are used in tests and
as such needs to be included from the right context which previously
wasn't the case.


Repository:
  rL LLVM

https://reviews.llvm.org/D40280

Files:
  CMakeLists.txt
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -49,10 +49,6 @@
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not 
edit!")
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-
 set(LIBCXX_TEST_DEPS "")
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
@@ -64,7 +60,12 @@
 endif()
 
 if (LIBCXX_INCLUDE_TESTS)
-  include(AddLLVM) # for add_lit_testsuite
+  include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+
   add_lit_testsuite(check-cxx
 "Running libcxx tests"
 ${CMAKE_CURRENT_BINARY_DIR}
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -684,6 +684,7 @@
 endif()
 
 if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
+  include(AddLLVM) # for get_llvm_lit_path
   # Make sure the llvm-lit script is generated into the bin directory, and do
   # it after adding all tests, since the generated script will only work
   # correctly discovered tests against test locations from the source tree that


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -49,10 +49,6 @@
 
 set(AUTO_GEN_COMMENT "## Autogenerated by libcxx configuration.\n# Do not edit!")
 
-configure_lit_site_cfg(
-  ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
-  ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
-
 set(LIBCXX_TEST_DEPS "")
 
 if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
@@ -64,7 +60,12 @@
 endif()
 
 if (LIBCXX_INCLUDE_TESTS)
-  include(AddLLVM) # for add_lit_testsuite
+  include(AddLLVM) # for configure_lit_site_cfg and add_lit_testsuit
+
+  configure_lit_site_cfg(
+${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in
+${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg)
+
   add_lit_testsuite(check-cxx
 "Running libcxx tests"
 ${CMAKE_CURRENT_BINARY_DIR}
Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -684,6 +684,7 @@
 endif()
 
 if (LIBCXX_STANDALONE_BUILD AND EXISTS "${LLVM_MAIN_SRC_DIR}/utils/llvm-lit")
+  include(AddLLVM) # for get_llvm_lit_path
   # Make sure the llvm-lit script is generated into the bin directory, and do
   # it after adding all tests, since the generated script will only work
   # correctly discovered tests against test locations from the source tree that
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40257: [CMake] Use LIST_SEPARATOR rather than escaping in ExternalProject_Add

2017-11-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 123710.

Repository:
  rL LLVM

https://reviews.llvm.org/D40257

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -653,7 +653,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "\;" value "${${variableName}}")
+  string(REPLACE ";" "," value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value "${${variableName}}")
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -653,7 +653,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "\;" value "${${variableName}}")
+  string(REPLACE ";" "," value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value "${${variableName}}")
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40230: Add -mprefer-vector-width driver option and attribute during CodeGen.

2017-11-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 123709.
craig.topper added a comment.

Still pass the attribute the backend if the value is 'none'.

We actually need this to know if the user specified the command line option at 
all. The value of 'none' should disable limits and prevents needing to pick a 
specific value.


https://reviews.llvm.org/D40230

Files:
  docs/ClangCommandLineReference.rst
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.h
  lib/CodeGen/CGCall.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/attr-mprefer-vector-width.c
  test/Driver/mprefer-vector-width.c

Index: test/Driver/mprefer-vector-width.c
===
--- /dev/null
+++ test/Driver/mprefer-vector-width.c
@@ -0,0 +1,24 @@
+
+ Verify that valid options for the -mprefer-vector-width flag are passed through and invalid options cause an error.
+
+
+ If there are no options, convert to 'all'.
+
+// RUN: %clang -### -S %s -mprefer-vector-width=none  2>&1 | FileCheck --check-prefix=WIDTHNONE %s
+// WIDTHNONE: "-mprefer-vector-width=none"
+
+ Check options that cover all types.
+
+// RUN: %clang -### -S %s -mprefer-vector-width=128  2>&1 | FileCheck --check-prefix=WIDTH128 %s
+// WIDTH128: "-mprefer-vector-width=128"
+
+ Check invalid parameters.
+
+// RUN: %clang -### -S %s -mprefer-vector-width=one  2>&1 | FileCheck --check-prefix=WIDTHONE %s
+// WIDTHONE: invalid value 'one' in 'mprefer-vector-width='
+
+// RUN: %clang -### -S %s -mprefer-vector-width=128.5  2>&1 | FileCheck --check-prefix=WIDTH128p5 %s
+// WIDTH128p5: invalue value '128.5' in 'mprefer-vector-width='
+
+// RUN: %clang -### -S %s -mprefer-vector-width=-128  2>&1 | FileCheck --check-prefix=WIDTHNEG128 %s
+// WIDTHNEG128: invalid value '-128' in 'mprefer-vector-width='
Index: test/CodeGen/attr-mprefer-vector-width.c
===
--- /dev/null
+++ test/CodeGen/attr-mprefer-vector-width.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -mprefer-vector-width=128 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK128
+// RUN: %clang_cc1 -mprefer-vector-width=256 -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK256
+// RUN: %clang_cc1 -mprefer-vector-width=none -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECKNONE
+
+int baz(int a) { return 4; }
+
+// CHECK128: baz{{.*}} #0
+// CHECK128: #0 = {{.*}}"prefer-vector-width"="128"
+
+// CHECK256: baz{{.*}} #0
+// CHECK256: #0 = {{.*}}"prefer-vector-width"="256"
+
+// CHECKNONE: baz{{.*}} #0
+// CHECKNONE-NOT: #0 = {{.*}}"prefer-vector-width"="none"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -713,6 +713,8 @@
   Opts.VectorizeLoop = Args.hasArg(OPT_vectorize_loops);
   Opts.VectorizeSLP = Args.hasArg(OPT_vectorize_slp);
 
+  Opts.PreferVectorWidth = Args.getLastArgValue(OPT_mprefer_vector_width_EQ);
+
   Opts.MainFileName = Args.getLastArgValue(OPT_main_file_name);
   Opts.VerifyModule = !Args.hasArg(OPT_disable_llvm_verifier);
 
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -274,6 +274,27 @@
   OutStrings.push_back(Args.MakeArgString(Out));
 }
 
+/// The -mprefer-vector-width option accepts either a positive integer
+/// or the string "none".
+static void ParseMPreferVectorWidth(const Driver , const ArgList ,
+ArgStringList ) {
+  Arg *A = Args.getLastArg(options::OPT_mprefer_vector_width_EQ);
+  if (!A)
+return;
+
+  StringRef Value = A->getValue();
+  if (Value == "none") {
+CmdArgs.push_back("-mprefer-vector-width=none");
+  } else {
+unsigned Width;
+if (Value.getAsInteger(10, Width)) {
+  D.Diag(diag::err_drv_invalid_value) << A->getOption().getName() << Value;
+  return;
+}
+CmdArgs.push_back(Args.MakeArgString("-mprefer-vector-width=" + Value));
+  }
+}
+
 static void getWebAssemblyTargetFeatures(const ArgList ,
  std::vector ) {
   handleTargetFeaturesGroup(Args, Features, options::OPT_m_wasm_Features_Group);
@@ -4306,6 +4327,8 @@
options::OPT_fno_slp_vectorize, EnableSLPVec))
 CmdArgs.push_back("-vectorize-slp");
 
+  ParseMPreferVectorWidth(D, Args, CmdArgs);
+
   if (Arg *A = Args.getLastArg(options::OPT_fshow_overloads_EQ))
 A->render(Args, CmdArgs);
 
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1744,6 +1744,10 @@
   FuncAttrs.addAttribute("reciprocal-estimates",
  llvm::join(Recips, ","));
 
+if (!CodeGenOpts.PreferVectorWidth.empty())
+  

[PATCH] D40259: [libcxx] LWG2993: reference_wrapper conversion from T&

2017-11-20 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: include/__functional_base:396
+!is_same<__uncvref_t<_Up>, reference_wrapper>::value
+>::type, bool _IsNothrow = noexcept(__bind(_VSTD::declval<_Up>()))>
+_LIBCPP_INLINE_VISIBILITY reference_wrapper(_Up&& __u) 
_NOEXCEPT_(_IsNothrow)

Is it safe to do this when we are using `_NOEXCEPT_` in the next line?


https://reviews.llvm.org/D40259



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


[PATCH] D40267: WG14 DR496

2017-11-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks!


https://reviews.llvm.org/D40267



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


[PATCH] D40279: [libcxxabi][demangler] Add demangling for __attribute__((abi_tag))

2017-11-20 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

This patch adds demangling support for `__attribute__((abi_tag))`. I.e, the 
following function: `__attribute__((abi_tag("foo"))) void f() {}` mangles to 
`_Z1fB3foov`, and now demangles to `f[abi:foo]()` (this syntax is the same as 
GCC's demangler). This patch parses the attribute everywhere in the grammer 
ItaniumMangle emits it.

While looking through ItaniumMangle, I noticed a couple of features that it 
supports that this file doesn't, so I added them to a list of them to the top. 
I'm going to submit some more patches for those as well.

https://bugs.llvm.org/show_bug.cgi?id=35310

Thanks for taking a look!


https://reviews.llvm.org/D40279

Files:
  src/cxa_demangle.cpp
  test/test_demangle.pass.cpp

Index: test/test_demangle.pass.cpp
===
--- test/test_demangle.pass.cpp
+++ test/test_demangle.pass.cpp
@@ -29605,6 +29605,12 @@
 {"_ZTW1x", "thread-local wrapper routine for x"},
 {"_ZTHN3fooE", "thread-local initialization routine for foo"},
 {"_Z4algoIJiiiEEvZ1gEUlT_E_", "void algo(g::'lambda'(int, int, int))"},
+
+{"_Z1fB3foov", "f[abi:foo]()"},
+{"_Z1fB3fooB3barv", "f[abi:foo][abi:bar]()"},
+{"_ZN1SB5outer1fB5innerEv", "S[abi:outer]::f[abi:inner]()"},
+{"_ZN1SC2B8ctor_tagEv", "S::S[abi:ctor_tag]()"},
+{"_ZplB4MERP1SS_", "operator+[abi:MERP](S, S)"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
Index: src/cxa_demangle.cpp
===
--- src/cxa_demangle.cpp
+++ src/cxa_demangle.cpp
@@ -7,6 +7,12 @@
 //
 //===--===//
 
+// FIXME: (possibly) incomplete list of features that clang mangles that this
+// file does not yet support:
+//   - enable_if attribute
+//   - decomposition declarations
+//   - C++ modules TS
+
 #define _LIBCPP_NO_EXCEPTIONS
 
 #include "__cxxabi_config.h"
@@ -178,6 +184,7 @@
 KConversionOperatorType,
 KPostfixQualifiedType,
 KNameType,
+KAbiTagAttr,
 KObjCProtoName,
 KPointerType,
 KLValueReferenceType,
@@ -384,6 +391,21 @@
   void printLeft(OutputStream ) const override { s += Name; }
 };
 
+class AbiTagAttr final : public Node {
+  const Node* Base;
+  StringView Tag;
+public:
+  AbiTagAttr(const Node* Base_, StringView Tag_)
+  : Node(KAbiTagAttr), Base(Base_), Tag(Tag_) {}
+
+  void printLeft(OutputStream ) const override {
+Base->printLeft(S);
+S += "[abi:";
+S += Tag;
+S += "]";
+  }
+};
+
 class ObjCProtoName : public Node {
   Node *Ty;
   Node *Protocol;
@@ -1795,10 +1817,10 @@
 return first;
 }
 
-//  ::=  
+//  ::= [0-9]*
 
 const char*
-parse_source_name(const char* first, const char* last, Db& db)
+parse_positive_integer(const char* first, const char* last, size_t* out)
 {
 if (first != last)
 {
@@ -1813,15 +1835,55 @@
 if (++t == last)
 return first;
 }
-if (static_cast(last - t) >= n)
-{
-StringView r(t, t + n);
-if (r.substr(0, 10) == "_GLOBAL__N")
-db.Names.push_back(db.make("(anonymous namespace)"));
-else
-db.Names.push_back(db.make(r));
-first = t + n;
-}
+*out = n;
+first = t;
+}
+}
+return first;
+}
+
+// extension
+//  ::= *
+//  ::= B  
+
+const char*
+parse_abi_tag_seq(const char* first, const char* last, Db& db)
+{
+while (first != last && *first == 'B' && first+1 != last)
+{
+size_t length;
+const char* t = parse_positive_integer(first+1, last, );
+if (t == first+1)
+return first;
+if (static_cast(last - t) < length || db.Names.empty())
+return first;
+db.Names.back() = db.make(
+db.Names.back(), StringView(t, t + length));
+first = t + length;
+}
+return first;
+}
+
+//  ::=  
+
+const char*
+parse_source_name(const char* first, const char* last, Db& db)
+{
+if (first != last)
+{
+size_t length;
+const char* t = parse_positive_integer(first, last, );
+if (t == first)
+return first;
+if (static_cast(last - t) >= length)
+{
+StringView r(t, t + length);
+if (r.substr(0, 10) == "_GLOBAL__N")
+db.Names.push_back(db.make("(anonymous namespace)"));
+else
+db.Names.push_back(db.make(r));
+first = t + length;
+first = parse_abi_tag_seq(first, last, db);
 }
 }
 return first;
@@ -4315,6 +4377,7 @@
 db.Names.push_back(
 db.make(db.Names.back(), false));
 first += 2;
+first = parse_abi_tag_seq(first, last, db);
 db.ParsedCtorDtorCV = true;

Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Volodymyr Sapsai via cfe-commits
On Nov 20, 2017, at 16:33, Reimar Döffinger  wrote:
> 
> On 20 November 2017 22:19:04 CET, Volodymyr Sapsai  > wrote:
>> On Nov 20, 2017, at 11:32, Reimar Döffinger 
>> wrote:
>>> 
>>> On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote:
>catch (...)
>{
> +if (__n > 0)
> +*__s = char_type();
>this->__set_badbit_and_consider_rethrow();
>}
 
 or maybe something else?
>>> 
>>> That one (note that the __set_badbit_and_consider_rethrow
>>> will never re-throw in this case).
>> 
>> But by #define _LIBCPP_NO_EXCEPTIONS 1 you exclude this block at
>> preprocessing step
>> 
>>> #ifndef _LIBCPP_NO_EXCEPTIONS
>>> }
>>> catch (...)
>>> {
>>> +if (__n > 0)
>>> +*__s = char_type();
>>> this->__set_badbit_and_consider_rethrow();
>>> }
>>> #endif  // _LIBCPP_NO_EXCEPTIONS
>> 
>> And looks like getline_pointer_size_exception.pass.cpp doesn’t execute
>> this code.
> 
> Yes, that was complete nonsense, I somehow always read #ifdef where there was 
> an #ifndef...
> Not sure then if that 0 termination should be there (and be tested) or better 
> to not have it in the exception case at all (I haven't checked if the 
> exception is always re-thrown or not, which might be relevant).
> I am a bit unclear about that whole code there that catches exceptions and 
> sets the bad bit and how it maps to the specification.

Standard mentions

> Otherwise, if the sentry constructor exits by throwing an exception or if the 
> sentry object returns false, when converted to a value of type bool, the 
> function returns without attempting to obtain any input. In either case the 
> number of extracted characters is set to 0; unformatted input functions 
> taking a character array of non-zero size as an argument shall also store a 
> null character (using charT()) in the first location of the array.

My understanding is that if sentry constructor throws an exception we need to 
null-terminate a character array. Null-termination isn’t specified explicitly 
for exceptions thrown in other cases but I think it would be more cumbersome to 
perform null-termination only for sentry exceptions and not for others. 
Regarding the safety, we control __s, don’t pass it anywhere, it never points 
beyond __n - I think null-termination should be safe. Also libstdc++ does 
null-termination when exceptions are thrown.

As for rethrowing exception, looks like exceptions flag std::istream::eofbit 
causes exception to be thrown and std::istream::badbit to be rethrown according 
to
> If (exceptions()) != 0 then the exception is rethrown.
And looks like libstdc++ rethrows exception even if badbit is not set.

If you feel comfortable, I can finish exception tests myself and commit the 
patch. How does it sound?___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35894: [clangd] Code hover for Clangd

2017-11-20 Thread William Enright via Phabricator via cfe-commits
Nebiroth added a comment.

Forgot to mention this last patch also added support for displaying function 
comments above the function definition displayed.


https://reviews.llvm.org/D35894



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added a comment.

It'd be great if you could commit it -- I don't have commit privileges. Much 
appreciated!


https://reviews.llvm.org/D40261



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 123701.
juliehockett marked an inline comment as done.

https://reviews.llvm.org/D40261

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {}", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {}",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {}
+/// void y(int val = 0) {}
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a 
declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {}
+void y(int val = 0) {}
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypeasStringstd::string Name
 Matches if the matched 
type is represented by the given string.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {}", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {}",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {}
+/// void y(int val = 0) {}
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {}
+void y(int val = 0) {}
+
+
+
 

[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:2188
+   !Context.getTargetInfo().isVLASupported() &&
+   shouldDiagnoseTargetSupportFromOpenMP()) {
+  // Some targets don't support VLAs.

Please write this check so that it trips in an "ordinary" build on a target 
that just happens to not support VLAs, something like:

  else if (!Context.getTargetInfo().isVLASupported() && 
shouldDiagnoseTargetSupportFromOpenMP())

If you want to include the explicit OpenMP check there, it would need to be:

  else if (!Context.getTargetInfo().isVLASupported() && (!getLangOpts().OpenMP 
|| shouldDiagnoseTargetSupportFromOpenMP()))

but I think the first looks better.

The CUDA and OpenMP paths here seem to be trying to achieve analogous things; 
it's unfortunate that we can't find a way to unify their approaches, even if 
we'd eventually want to use different diagnostic text.  I imagine that the 
target-environment language restrictions are basically the same, since they 
arise for the same fundamental reasons, so all the places using 
CUDADiagIfDeviceCode are likely to have a check for 
shouldDiagnoseTargetSupportFromOpenMP() and vice-versa.


https://reviews.llvm.org/D40275



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


[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-20 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:419
+Features.push_back("-fullfp16");
+
+const bool HasNeon  = (std::find(ItBegin, ItEnd, "+neon") != ItEnd);

It would be nice to not have these explicitly listed.  But at the very least, I 
think that having a list and looping through it would be better:

for (const auto Feature : {"vfpv2", "vfpv3", "vfpv4", "fp-armv8", 
"fullfp16"})
  if (std::find(std::begin(Features), std::end(Features), "+" + Feature) == 
std::end(Features))
continue;
  else
Features.push_back("-" + Feature);



Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:429
+if (HasDotProd)
+Features.push_back("-dotprod");
   }

Similar.


https://reviews.llvm.org/D40256



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


r318723 - [MS] Increase default new alignment for win64 and test it

2017-11-20 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Mon Nov 20 17:25:56 2017
New Revision: 318723

URL: http://llvm.org/viewvc/llvm-project?rev=318723=rev
Log:
[MS] Increase default new alignment for win64 and test it

Summary:
This raises __STDCPP_DEFAULT_NEW_ALIGNMENT__ from 8 to 16 on Win64.
This matches platforms that follow the usual `2 * sizeof(void*)`
alignment requirement for malloc. We might want to consider making that
the default rather than relying on long double alignment.

Fixes PR35356

Reviewers: STL_MSFT, rsmith

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
cfe/trunk/test/Preprocessor/init.c

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=318723=318722=318723=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Mon Nov 20 17:25:56 2017
@@ -45,7 +45,7 @@ TargetInfo::TargetInfo(const llvm::Tripl
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment())
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.

Modified: cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp?rev=318723=318722=318723=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp Mon Nov 20 17:25:56 
2017
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -std=c++14 -fexceptions -fsized-deallocation 
-faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
 // RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm 
-triple x86_64-linux-gnu -o - | FileCheck %s
 
+// RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm 
-triple x86_64-windows-msvc -o - | FileCheck %s --check-prefix=CHECK-MS
+
 // Check that we don't used aligned (de)allocation without 
-faligned-allocation or C++1z.
 // RUN: %clang_cc1 -std=c++14 -DUNALIGNED -fexceptions %s -emit-llvm -triple 
x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNALIGNED
 // RUN: %clang_cc1 -std=c++1z -DUNALIGNED -fexceptions -fno-aligned-allocation 
%s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s 
--check-prefix=CHECK-UNALIGNED
@@ -27,14 +29,28 @@ struct OVERALIGNED A { A(); int n[128];
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
 // CHECK: %[[ALLOC:.*]] = call i8* @_ZnwmSt11align_val_t(i64 512, i64 32)
 // CHECK: call void @_ZdlPvSt11align_val_t(i8* %[[ALLOC]], i64 32)
+// CHECK-MS-LABEL: define {{.*}} @"\01?a0@@YAPEAXXZ"()
+// CHECK-MS: %[[ALLOC:.*]] = call i8* 
@"\01??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 512, i64 32)
+// CHECK-MS: cleanuppad
+// CHECK-MS: call void @"\01??3@YAXPEAXW4align_val_t@std@@@Z"(i8* %[[ALLOC]], 
i64 32)
 void *a0() { return new A; }
 
+// FIXME: Why don't we call the sized array deallocation overload in this case?
+// The size is known.
+//
 // CHECK-LABEL: define {{.*}} @_Z2a1l(
 // CHECK: %[[ALLOC:.*]] = call i8* @_ZnamSt11align_val_t(i64 %{{.*}}, i64 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
 // CHECK: call void @_ZdaPvSt11align_val_t(i8* %[[ALLOC]], i64 32)
+// CHECK-MS-LABEL: define {{.*}} @"\01?a1@@YAPEAXJ@Z"(
+// CHECK-MS: %[[ALLOC:.*]] = call i8* 
@"\01??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 %{{.*}}, i64 32)
+// No array cookie.
+// CHECK-MS-NOT: store
+// CHECK-MS: invoke %struct.A* @"\01??0A@@QEAA@XZ"(
+// CHECK-MS: cleanuppad
+// CHECK-MS: call void @"\01??_V@YAXPEAXW4align_val_t@std@@@Z"(i8* %[[ALLOC]], 
i64 32)
 void *a1(long n) { return new A[n]; }
 
 // CHECK-LABEL: define {{.*}} @_Z2a2P1A(

Modified: cfe/trunk/test/Preprocessor/init.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/init.c?rev=318723=318722=318723=diff
==
--- cfe/trunk/test/Preprocessor/init.c (original)
+++ cfe/trunk/test/Preprocessor/init.c Mon Nov 20 17:25:56 2017
@@ -9890,11 +9890,11 @@
 
 
 // RUN: %clang_cc1 -E -dM -ffreestanding \
-// RUN:-triple i686-windows-msvc -fms-compatibility < /dev/null \
+// RUN:-triple i686-windows-msvc -fms-compatibility -x c++ < /dev/null \
 // RUN:  | FileCheck -match-full-lines -check-prefix MSVC-X32 %s
 
 // RUN: %clang_cc1 -E -dM -ffreestanding \
-// RUN:-triple x86_64-windows-msvc -fms-compatibility < /dev/null \

[PATCH] D40277: [MS] Increase default new alignment for win64 and test it

2017-11-20 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318723: [MS] Increase default new alignment for win64 and 
test it (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D40277?vs=123692=123698#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D40277

Files:
  cfe/trunk/lib/Basic/TargetInfo.cpp
  cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  cfe/trunk/test/Preprocessor/init.c


Index: cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
===
--- cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
+++ cfe/trunk/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -std=c++14 -fexceptions -fsized-deallocation 
-faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
 // RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm 
-triple x86_64-linux-gnu -o - | FileCheck %s
 
+// RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm 
-triple x86_64-windows-msvc -o - | FileCheck %s --check-prefix=CHECK-MS
+
 // Check that we don't used aligned (de)allocation without 
-faligned-allocation or C++1z.
 // RUN: %clang_cc1 -std=c++14 -DUNALIGNED -fexceptions %s -emit-llvm -triple 
x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNALIGNED
 // RUN: %clang_cc1 -std=c++1z -DUNALIGNED -fexceptions -fno-aligned-allocation 
%s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s 
--check-prefix=CHECK-UNALIGNED
@@ -27,14 +29,28 @@
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
 // CHECK: %[[ALLOC:.*]] = call i8* @_ZnwmSt11align_val_t(i64 512, i64 32)
 // CHECK: call void @_ZdlPvSt11align_val_t(i8* %[[ALLOC]], i64 32)
+// CHECK-MS-LABEL: define {{.*}} @"\01?a0@@YAPEAXXZ"()
+// CHECK-MS: %[[ALLOC:.*]] = call i8* 
@"\01??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 512, i64 32)
+// CHECK-MS: cleanuppad
+// CHECK-MS: call void @"\01??3@YAXPEAXW4align_val_t@std@@@Z"(i8* %[[ALLOC]], 
i64 32)
 void *a0() { return new A; }
 
+// FIXME: Why don't we call the sized array deallocation overload in this case?
+// The size is known.
+//
 // CHECK-LABEL: define {{.*}} @_Z2a1l(
 // CHECK: %[[ALLOC:.*]] = call i8* @_ZnamSt11align_val_t(i64 %{{.*}}, i64 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
 // CHECK: call void @_ZdaPvSt11align_val_t(i8* %[[ALLOC]], i64 32)
+// CHECK-MS-LABEL: define {{.*}} @"\01?a1@@YAPEAXJ@Z"(
+// CHECK-MS: %[[ALLOC:.*]] = call i8* 
@"\01??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 %{{.*}}, i64 32)
+// No array cookie.
+// CHECK-MS-NOT: store
+// CHECK-MS: invoke %struct.A* @"\01??0A@@QEAA@XZ"(
+// CHECK-MS: cleanuppad
+// CHECK-MS: call void @"\01??_V@YAXPEAXW4align_val_t@std@@@Z"(i8* %[[ALLOC]], 
i64 32)
 void *a1(long n) { return new A[n]; }
 
 // CHECK-LABEL: define {{.*}} @_Z2a2P1A(
Index: cfe/trunk/test/Preprocessor/init.c
===
--- cfe/trunk/test/Preprocessor/init.c
+++ cfe/trunk/test/Preprocessor/init.c
@@ -9890,11 +9890,11 @@
 
 
 // RUN: %clang_cc1 -E -dM -ffreestanding \
-// RUN:-triple i686-windows-msvc -fms-compatibility < /dev/null \
+// RUN:-triple i686-windows-msvc -fms-compatibility -x c++ < /dev/null \
 // RUN:  | FileCheck -match-full-lines -check-prefix MSVC-X32 %s
 
 // RUN: %clang_cc1 -E -dM -ffreestanding \
-// RUN:-triple x86_64-windows-msvc -fms-compatibility < /dev/null \
+// RUN:-triple x86_64-windows-msvc -fms-compatibility -x c++ < /dev/null \
 // RUN:  | FileCheck -match-full-lines -check-prefix MSVC-X64 %s
 
 // MSVC-X32:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
@@ -9908,6 +9908,7 @@
 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
 // MSVC-X32-NOT:#define __GCC_ATOMIC{{.*}}
+// MSVC-X32:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 
 // MSVC-X64:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2
@@ -9919,7 +9920,8 @@
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
-// MSVC-X86-NOT:#define __GCC_ATOMIC{{.*}}
+// MSVC-X64-NOT:#define __GCC_ATOMIC{{.*}}
+// MSVC-X64:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16ULL
 
 // RUN: %clang_cc1 -E -dM -ffreestanding\
 // RUN:   -triple=aarch64-apple-ios9 < /dev/null\
Index: cfe/trunk/lib/Basic/TargetInfo.cpp
===
--- cfe/trunk/lib/Basic/TargetInfo.cpp
+++ cfe/trunk/lib/Basic/TargetInfo.cpp
@@ -45,7 +45,7 @@
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment())
+  if 

[PATCH] D40270: [Modules TS] Added re-export support

2017-11-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Thanks, looks great.




Comment at: test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp:22
+}
+#endif
+

Maybe consider adding one more module to this test: a module that is imported 
into this module but *not* re-exported.


https://reviews.llvm.org/D40270



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


[PATCH] D39963: [RISCV][RFC] Add initial RISC-V target and driver support

2017-11-20 Thread Ana Pazos via Phabricator via cfe-commits
apazos added a comment.

Can you push this as a patch to review/commit instead of RFC? It has received a 
lot of comments/corrections already and I think it is getting in a shape we can 
merge.




Comment at: lib/Driver/ToolChains/RISCV.cpp:86
+CmdArgs.push_back("-lc");
+CmdArgs.push_back("-lgloss");
+CmdArgs.push_back("--end-group");

asb wrote:
> apazos wrote:
> > mgrang wrote:
> > > How about if our sysroot is linux (as opposed to elf)? There won't be any 
> > > libgloss.a, right? Also there won't be a crt0.o (instead there will be 
> > > crt1.o).
> > Supporting linux target is desirable early on because most of us will be 
> > using Qemu for running tests.
> Linux targets are not currently supported, as they require the ilp32d or 
> lp64d (hard double precision) ABI. The only fiddly part is actually in the 
> Clang frontend, handling structs composed of two reals or one integer + one 
> real. This is obviously high up on the todo list.
I meant user code compiled with target=riscv32-unknown-linux march=rv32imafdc 
and mabi=ilp32. This would run fine on qemu.



Comment at: test/Preprocessor/init.c:9991
+// RUN: %clang_cc1 -E -dM -ffreestanding -triple=riscv32 < /dev/null \
+// RUN:   | FileCheck -match-full-lines -check-prefix=RISCV32 %s
+// RISCV32: #define _ILP32 1

Shouldn't we just check for the target specific defines  in these tests?


https://reviews.llvm.org/D39963



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


r318722 - Re-revert "Refactor debuginfo-tests."

2017-11-20 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Mon Nov 20 17:20:28 2017
New Revision: 318722

URL: http://llvm.org/viewvc/llvm-project?rev=318722=rev
Log:
Re-revert "Refactor debuginfo-tests."

This is still breaking greendragon.

At this point I give up until someone can fix the greendragon
bots, and I will probably abandon this effort in favor of using
a private github repository.

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

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=318722=318721=318722=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Mon Nov 20 17:20:28 2017
@@ -88,14 +88,6 @@ set(CLANG_TEST_PARAMS
   clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
   )
 
-if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt")
-  # This is a hack to keep existing build build infrastructure working while we
-  # can migrate to the new standard workflow of checking out debuginfo-tests 
into
-  # llvm/projects or using it in a mono-repo
-  set(DEBUGINFO_TESTS_EXCLUDE_FROM_ALL ON)
-  add_subdirectory(debuginfo-tests)
-endif()
-
 if( NOT CLANG_BUILT_STANDALONE )
   list(APPEND CLANG_TEST_DEPS
 llvm-config

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=318722=318721=318722=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Mon Nov 20 17:20:28 2017
@@ -58,6 +58,8 @@ tool_dirs = [config.clang_tools_dir, con
 
 tools = [
 'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt',
+ToolSubst('%test_debuginfo', command=os.path.join(
+config.llvm_src_root, 'utils', 'test_debuginfo.pl')),
 ToolSubst('%clang_func_map', command=FindTool(
 'clang-func-mapping'), unresolved='ignore'),
 ]


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


[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 123694.
tra added a comment.

Updates CUDA's VLA test to use nvptx triple.


https://reviews.llvm.org/D40275

Files:
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCUDA/vla.cu


Index: clang/test/SemaCUDA/vla.cu
===
--- clang/test/SemaCUDA/vla.cu
+++ clang/test/SemaCUDA/vla.cu
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify -DHOST %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -verify -DHOST %s
 
 #include "Inputs/cuda.h"
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2175,19 +2175,21 @@
 T = Context.getConstantArrayType(T, ConstVal, ASM, Quals);
   }
 
-  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
-  if (getLangOpts().OpenCL && T->isVariableArrayType()) {
-Diag(Loc, diag::err_opencl_vla);
-return QualType();
-  }
-  // CUDA device code doesn't support VLAs.
-  if (getLangOpts().CUDA && T->isVariableArrayType())
-CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
-  // Some targets don't support VLAs.
-  if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported() &&
-  shouldDiagnoseTargetSupportFromOpenMP()) {
-Diag(Loc, diag::err_vla_unsupported);
-return QualType();
+  if (T->isVariableArrayType()) {
+if (getLangOpts().OpenCL) {
+  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
+  Diag(Loc, diag::err_opencl_vla);
+  return QualType();
+} else if (getLangOpts().CUDA) {
+  // CUDA device code doesn't support VLAs.
+  CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+} else if (getLangOpts().OpenMP &&
+   !Context.getTargetInfo().isVLASupported() &&
+   shouldDiagnoseTargetSupportFromOpenMP()) {
+  // Some targets don't support VLAs.
+  Diag(Loc, diag::err_vla_unsupported);
+  return QualType();
+}
   }
 
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.


Index: clang/test/SemaCUDA/vla.cu
===
--- clang/test/SemaCUDA/vla.cu
+++ clang/test/SemaCUDA/vla.cu
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fcuda-is-device -fsyntax-only -verify %s
-// RUN: %clang_cc1 -fsyntax-only -verify -DHOST %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -fcuda-is-device -verify %s
+// RUN: %clang_cc1 -triple nvptx64-nvidia-cuda -verify -DHOST %s
 
 #include "Inputs/cuda.h"
 
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2175,19 +2175,21 @@
 T = Context.getConstantArrayType(T, ConstVal, ASM, Quals);
   }
 
-  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
-  if (getLangOpts().OpenCL && T->isVariableArrayType()) {
-Diag(Loc, diag::err_opencl_vla);
-return QualType();
-  }
-  // CUDA device code doesn't support VLAs.
-  if (getLangOpts().CUDA && T->isVariableArrayType())
-CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
-  // Some targets don't support VLAs.
-  if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported() &&
-  shouldDiagnoseTargetSupportFromOpenMP()) {
-Diag(Loc, diag::err_vla_unsupported);
-return QualType();
+  if (T->isVariableArrayType()) {
+if (getLangOpts().OpenCL) {
+  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
+  Diag(Loc, diag::err_opencl_vla);
+  return QualType();
+} else if (getLangOpts().CUDA) {
+  // CUDA device code doesn't support VLAs.
+  CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+} else if (getLangOpts().OpenMP &&
+   !Context.getTargetInfo().isVLASupported() &&
+   shouldDiagnoseTargetSupportFromOpenMP()) {
+  // Some targets don't support VLAs.
+  Diag(Loc, diag::err_vla_unsupported);
+  return QualType();
+}
   }
 
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40277: [MS] Increase default new alignment for win64 and test it

2017-11-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

Looks fine to me, but I think the alignment numbers in your summary are off by 
a factor of two.


https://reviews.llvm.org/D40277



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


r318719 - FormatInternal.h: Add missing includes.

2017-11-20 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Nov 20 17:09:17 2017
New Revision: 318719

URL: http://llvm.org/viewvc/llvm-project?rev=318719=rev
Log:
FormatInternal.h: Add missing includes.

Modified:
cfe/trunk/lib/Format/FormatInternal.h

Modified: cfe/trunk/lib/Format/FormatInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatInternal.h?rev=318719=318718=318719=diff
==
--- cfe/trunk/lib/Format/FormatInternal.h (original)
+++ cfe/trunk/lib/Format/FormatInternal.h Mon Nov 20 17:09:17 2017
@@ -16,6 +16,10 @@
 #ifndef LLVM_CLANG_LIB_FORMAT_FORMATINTERNAL_H
 #define LLVM_CLANG_LIB_FORMAT_FORMATINTERNAL_H
 
+#include "BreakableToken.h"
+#include "clang/Tooling/Core/Lookup.h"
+#include 
+
 namespace clang {
 namespace format {
 namespace internal {


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


r318720 - ASTMatchers{, Macros}.h: Add some extra macros to use for decl/def of matchers

2017-11-20 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Nov 20 17:09:18 2017
New Revision: 318720

URL: http://llvm.org/viewvc/llvm-project?rev=318720=rev
Log:
ASTMatchers{,Macros}.h: Add some extra macros to use for decl/def of matchers

Fix ODR violations caused by using internal linkage variables in
non-internal inline functions. (also removes duplicate definitions, etc)

Modified:
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h
cfe/trunk/lib/ASTMatchers/ASTMatchersInternal.cpp

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=318720=318719=318720=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Mon Nov 20 17:09:18 2017
@@ -4803,9 +4803,9 @@ AST_MATCHER(Type, realFloatingPointType)
 ///   matches "int b[7]"
 ///
 /// Usable as: Matcher, Matcher
-AST_TYPELOC_TRAVERSE_MATCHER(hasElementType, getElement,
- AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
- ComplexType));
+AST_TYPELOC_TRAVERSE_MATCHER_DECL(hasElementType, getElement,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(ArrayType,
+  
ComplexType));
 
 /// \brief Matches C arrays with a specified constant size.
 ///
@@ -4921,8 +4921,8 @@ extern const AstTypeMatcher
 ///  matches "_Atomic(int) i"
 ///
 /// Usable as: Matcher
-AST_TYPELOC_TRAVERSE_MATCHER(hasValueType, getValue,
- AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType));
+AST_TYPELOC_TRAVERSE_MATCHER_DECL(hasValueType, getValue,
+  AST_POLYMORPHIC_SUPPORTED_TYPES(AtomicType));
 
 /// \brief Matches types nodes representing C++11 auto types.
 ///
@@ -5115,11 +5115,10 @@ extern const AstTypeMatcher, Matcher,
 ///   Matcher, Matcher
-AST_TYPELOC_TRAVERSE_MATCHER(pointee, getPointee,
- AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType,
- MemberPointerType,
- PointerType,
- ReferenceType));
+AST_TYPELOC_TRAVERSE_MATCHER_DECL(
+pointee, getPointee,
+AST_POLYMORPHIC_SUPPORTED_TYPES(BlockPointerType, MemberPointerType,
+PointerType, ReferenceType));
 
 /// \brief Matches typedef types.
 ///

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h?rev=318720=318719=318720=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersMacros.h Mon Nov 20 17:09:18 
2017
@@ -367,6 +367,27 @@
 // FIXME: add a matcher for TypeLoc derived classes using its custom casting
 // API (no longer dyn_cast) if/when we need such matching
 
+#define AST_TYPE_TRAVERSE_MATCHER_DECL(MatcherName, FunctionName,  
\
+   ReturnTypesF)   
\
+  namespace internal { 
\
+  template  struct TypeMatcher##MatcherName##Getter {  
\
+static QualType (T::*value())() const { return ::FunctionName; } 
\
+  };   
\
+  }
\
+  extern const ::clang::ast_matchers::internal::   
\
+  TypeTraversePolymorphicMatcher<  
\
+  QualType,
\
+  ::clang::ast_matchers::internal::TypeMatcher##MatcherName##Getter,   
\
+  ::clang::ast_matchers::internal::TypeTraverseMatcher,
\
+  ReturnTypesF>::Func MatcherName
+
+#define AST_TYPE_TRAVERSE_MATCHER_DEF(MatcherName, ReturnTypesF)   
\
+  const ::clang::ast_matchers::internal::TypeTraversePolymorphicMatcher<   
\
+  QualType,
\
+  ::clang::ast_matchers::internal::TypeMatcher##MatcherName##Getter,   
\
+  ::clang::ast_matchers::internal::TypeTraverseMatcher,
\
+  ReturnTypesF>::Func MatcherName
+
 /// \brief AST_TYPE_TRAVERSE_MATCHER(MatcherName, FunctionName) defines
 /// the matcher \c MatcherName that can be used to traverse from one \c Type
 /// to another.
@@ -386,6 +407,30 @@
   

[PATCH] D39953: [CodeGen] Generate TBAA type descriptors in a more reliable manner

2017-11-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay, looks good.


https://reviews.llvm.org/D39953



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


[PATCH] D40023: [RISCV] Implement ABI lowering

2017-11-20 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:8790
+private:
+  unsigned XLen;
+  static const int NumArgGPRs = 8;

rjmccall wrote:
> Is "XLen" a term that anyone working with RISCV would recognize?  Because 
> even if it is, it feels like something you should document here — just 
> "standard pointer size in bits" would be fine.
+1



Comment at: lib/CodeGen/TargetInfo.cpp:8821
+  // rewrite the argument list and pass indirectly on RV32.
+  bool IsRetIndirect = FI.getReturnInfo().getKind() == ABIArgInfo::Indirect ||
+   getContext().getTypeSize(RetTy) > 2 * XLen;

I think it's better to use parenthesis here to aid readability and avoid 
ambiguity?



Comment at: lib/CodeGen/TargetInfo.cpp:8824
+
+  // We must track the number of GPRs used in order to conform to the RISC-V
+  // ABI, as integer scalars passed in registers should have signext/zeroext

I observed that you use RISCV and RISC-V interchangeably in comments. This is 
not a problem,  per se but can make this uniform if we want to be *really* 
particular about this :)


https://reviews.llvm.org/D40023



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


[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D40275#930981, @tra wrote:

> In https://reviews.llvm.org/D40275#930948, @Hahnfeld wrote:
>
> > In https://reviews.llvm.org/D39505 @rjmccall requested that the check 
> > should be made independent of the language. To preserve this, I think the 
> > CUDA specific checks should be added to the generic case instead of 
> > restricting its evaluation.
>
>
> I'm not sure what exactly you or @rjmccall  have in mind. Specifically - what 
> is the 'generic case' CUDA checks should be added to? Could you give me an 
> example?


Not supporting VLAs is a property of the target we are compiling for, see newly 
added `Context.getTargetInfo().isVLASupported()`. So neither CUDA nor OpenMP 
are special cases in general, it's rather that the targeted architecture 
doesn't support that feature. What is a special case though is that both CUDA 
and OpenMP analyze the complete host code again and we need to suppress the 
diagnostic if the VLA is encountered in the host code that is never codegen'd 
for the device. For OpenMP, this special case is encoded in 
`shouldDiagnoseTargetSupportFromOpenMP` (a horrible name - suggestions 
welcome!) and I think you should add a similar check for CUDA.


https://reviews.llvm.org/D40275



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


[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D40275#930982, @Hahnfeld wrote:

> And please add a regression test which is apparently missing for the case 
> that a VLA is **NOT** diagnosed in CUDA mode


Hmm. We do have test/SemaCUDA/vla.cu which should've triggered the error. Let 
me see why it didn't happen.


https://reviews.llvm.org/D40275



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


[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

2017-11-20 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:4567
 
-  if (Kind <= BTT_Last)
+  // Evaluate BTT_ReferenceBindsToTemporary along side the IsConstructible
+  // traits to avoid duplication.

"alongside" is a single word.



Comment at: test/SemaCXX/type-traits.cpp:2102-2116
+  using LRef = ConvertsToRef;
+  using RRef = ConvertsToRef;
+  using CLRef = ConvertsToRef;
+  using LongRef = ConvertsToRef;
+  { int arr[T((__is_constructible(int&, LRef)))]; }
+  { int arr[F((__reference_binds_to_temporary(int&, LRef)))]; }
+

Please also check things like:

  `__reference_binds_to_temporary(const int&, ConvertsToRef)`

(That is, a user-defined conversion to a reference type followed by converting 
and materializing a temporary.)


https://reviews.llvm.org/D29930



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


[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In https://reviews.llvm.org/D40275#930948, @Hahnfeld wrote:

> In https://reviews.llvm.org/D39505 @rjmccall requested that the check should 
> be made independent of the language. To preserve this, I think the CUDA 
> specific checks should be added to the generic case instead of restricting 
> its evaluation.


I'm not sure what exactly you or @rjmccall  have in mind. Specifically - what 
is the 'generic case' CUDA checks should be added to? Could you give me an 
example?


https://reviews.llvm.org/D40275



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


[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

And please add a regression test which is apparently missing for the case that 
a VLA is **NOT** diagnosed in CUDA mode


https://reviews.llvm.org/D40275



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


[PATCH] D40277: [MS] Increase default new alignment for win64 and test it

2017-11-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk created this revision.

This raises __STDCPP_DEFAULT_NEW_ALIGNMENT__ from 16 to 32 on Win64.
This matches platforms that follow the usual `2 * sizeof(void*)`
alignment requirement for malloc. We might want to consider making that
the default rather than relying on long double alignment.

Fixes PR35356


https://reviews.llvm.org/D40277

Files:
  clang/lib/Basic/TargetInfo.cpp
  clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
  clang/test/Preprocessor/init.c


Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -9890,11 +9890,11 @@
 
 
 // RUN: %clang_cc1 -E -dM -ffreestanding \
-// RUN:-triple i686-windows-msvc -fms-compatibility < /dev/null \
+// RUN:-triple i686-windows-msvc -fms-compatibility -x c++ < /dev/null \
 // RUN:  | FileCheck -match-full-lines -check-prefix MSVC-X32 %s
 
 // RUN: %clang_cc1 -E -dM -ffreestanding \
-// RUN:-triple x86_64-windows-msvc -fms-compatibility < /dev/null \
+// RUN:-triple x86_64-windows-msvc -fms-compatibility -x c++ < /dev/null \
 // RUN:  | FileCheck -match-full-lines -check-prefix MSVC-X64 %s
 
 // MSVC-X32:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
@@ -9908,6 +9908,7 @@
 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
 // MSVC-X32-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
 // MSVC-X32-NOT:#define __GCC_ATOMIC{{.*}}
+// MSVC-X32:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 
 // MSVC-X64:#define __CLANG_ATOMIC_BOOL_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_CHAR16_T_LOCK_FREE 2
@@ -9919,7 +9920,8 @@
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_POINTER_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_SHORT_LOCK_FREE 2
 // MSVC-X64-NEXT:#define __CLANG_ATOMIC_WCHAR_T_LOCK_FREE 2
-// MSVC-X86-NOT:#define __GCC_ATOMIC{{.*}}
+// MSVC-X64-NOT:#define __GCC_ATOMIC{{.*}}
+// MSVC-X64:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16ULL
 
 // RUN: %clang_cc1 -E -dM -ffreestanding\
 // RUN:   -triple=aarch64-apple-ios9 < /dev/null\
Index: clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
===
--- clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
+++ clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
@@ -4,6 +4,8 @@
 // RUN: %clang_cc1 -std=c++14 -fexceptions -fsized-deallocation 
-faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
 // RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm 
-triple x86_64-linux-gnu -o - | FileCheck %s
 
+// RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm 
-triple x86_64-windows-msvc -o - | FileCheck %s --check-prefix=CHECK-MS
+
 // Check that we don't used aligned (de)allocation without 
-faligned-allocation or C++1z.
 // RUN: %clang_cc1 -std=c++14 -DUNALIGNED -fexceptions %s -emit-llvm -triple 
x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNALIGNED
 // RUN: %clang_cc1 -std=c++1z -DUNALIGNED -fexceptions -fno-aligned-allocation 
%s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s 
--check-prefix=CHECK-UNALIGNED
@@ -27,14 +29,28 @@
 // CHECK-LABEL: define {{.*}} @_Z2a0v()
 // CHECK: %[[ALLOC:.*]] = call i8* @_ZnwmSt11align_val_t(i64 512, i64 32)
 // CHECK: call void @_ZdlPvSt11align_val_t(i8* %[[ALLOC]], i64 32)
+// CHECK-MS-LABEL: define {{.*}} @"\01?a0@@YAPEAXXZ"()
+// CHECK-MS: %[[ALLOC:.*]] = call i8* 
@"\01??2@YAPEAX_KW4align_val_t@std@@@Z"(i64 512, i64 32)
+// CHECK-MS: cleanuppad
+// CHECK-MS: call void @"\01??3@YAXPEAXW4align_val_t@std@@@Z"(i8* %[[ALLOC]], 
i64 32)
 void *a0() { return new A; }
 
+// FIXME: Why don't we call the sized array deallocation overload in this case?
+// The size is known.
+//
 // CHECK-LABEL: define {{.*}} @_Z2a1l(
 // CHECK: %[[ALLOC:.*]] = call i8* @_ZnamSt11align_val_t(i64 %{{.*}}, i64 32)
 // No array cookie.
 // CHECK-NOT: store
 // CHECK: invoke void @_ZN1AC1Ev(
 // CHECK: call void @_ZdaPvSt11align_val_t(i8* %[[ALLOC]], i64 32)
+// CHECK-MS-LABEL: define {{.*}} @"\01?a1@@YAPEAXJ@Z"(
+// CHECK-MS: %[[ALLOC:.*]] = call i8* 
@"\01??_U@YAPEAX_KW4align_val_t@std@@@Z"(i64 %{{.*}}, i64 32)
+// No array cookie.
+// CHECK-MS-NOT: store
+// CHECK-MS: invoke %struct.A* @"\01??0A@@QEAA@XZ"(
+// CHECK-MS: cleanuppad
+// CHECK-MS: call void @"\01??_V@YAXPEAXW4align_val_t@std@@@Z"(i8* %[[ALLOC]], 
i64 32)
 void *a1(long n) { return new A[n]; }
 
 // CHECK-LABEL: define {{.*}} @_Z2a2P1A(
Index: clang/lib/Basic/TargetInfo.cpp
===
--- clang/lib/Basic/TargetInfo.cpp
+++ clang/lib/Basic/TargetInfo.cpp
@@ -45,7 +45,7 @@
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
   // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment())
+  if (T.isGNUEnvironment() || 

[PATCH] D40276: Add -finstrument-function-entry-bare flag

2017-11-20 Thread Hans Wennborg via Phabricator via cfe-commits
hans created this revision.

This is an instrumentation flag, similar to -finstrument-functions, but it only 
inserts calls on function entry, the calls are inserted post-inlining, and they 
don't take any arugments.

This is intended for users who want to instrument function entry with minimal 
overhead.

(-pg would be another alternative, but foces frame pointer emission and affects 
linking, so is probably best left alone to be used for generating gcov data.)


https://reviews.llvm.org/D40276

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CodeGenFunction.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/instrument-functions.c

Index: test/CodeGen/instrument-functions.c
===
--- test/CodeGen/instrument-functions.c
+++ test/CodeGen/instrument-functions.c
@@ -1,21 +1,34 @@
 // RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-functions -disable-llvm-passes | FileCheck %s
+// RUN: %clang_cc1 -S -debug-info-kind=standalone -emit-llvm -o - %s -finstrument-function-entry-bare -disable-llvm-passes | FileCheck -check-prefix=BARE %s
 
 int test1(int x) {
 // CHECK: @test1(i32 {{.*}}%x) #[[ATTR1:[0-9]+]]
 // CHECK: ret
+
+// BARE: @test1(i32 {{.*}}%x) #[[ATTR1:[0-9]+]]
+// BARE: ret
   return x;
 }
 
 int test2(int) __attribute__((no_instrument_function));
 int test2(int x) {
 // CHECK: @test2(i32 {{.*}}%x) #[[ATTR2:[0-9]+]]
 // CHECK: ret
+
+// BARE: @test2(i32 {{.*}}%x) #[[ATTR2:[0-9]+]]
+// BARE: ret
   return x;
 }
 
 // CHECK: attributes #[[ATTR1]] =
 // CHECK-SAME: "instrument-function-entry"="__cyg_profile_func_enter"
 // CHECK-SAME: "instrument-function-exit"="__cyg_profile_func_exit"
 
+// BARE: attributes #[[ATTR1]] =
+// BARE-SAME: "instrument-function-entry-inlined"="__cyg_profile_func_enter_bare"
+
 // CHECK: attributes #[[ATTR2]] =
 // CHECK-NOT: "instrument-function-entry"
+
+// BARE: attributes #[[ATTR2]] =
+// BARE-NOT: "instrument-function-entry"
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,8 @@
   Opts.InstrumentFunctions = Args.hasArg(OPT_finstrument_functions);
   Opts.InstrumentFunctionsAfterInlining =
   Args.hasArg(OPT_finstrument_functions_after_inlining);
+  Opts.InstrumentFunctionEntryBare =
+  Args.hasArg(OPT_finstrument_function_entry_bare);
   Opts.XRayInstrumentFunctions = Args.hasArg(OPT_fxray_instrument);
   Opts.XRayInstructionThreshold =
   getLastArgIntValue(Args, OPT_fxray_instruction_threshold_EQ, 200, Diags);
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -3554,8 +3554,11 @@
 options::OPT_fno_unique_section_names, true))
 CmdArgs.push_back("-fno-unique-section-names");
 
-  Args.AddLastArg(CmdArgs, options::OPT_finstrument_functions,
-  options::OPT_finstrument_functions_after_inlining);
+  if (auto *A = Args.getLastArg(
+  options::OPT_finstrument_functions,
+  options::OPT_finstrument_functions_after_inlining,
+  options::OPT_finstrument_function_entry_bare))
+A->render(Args, CmdArgs);
 
   addPGOAndCoverageFlags(C, D, Output, Args, CmdArgs);
 
Index: lib/CodeGen/CodeGenFunction.cpp
===
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -355,10 +355,11 @@
   llvm::DebugLoc Loc = EmitReturnBlock();
 
   if (ShouldInstrumentFunction()) {
-CurFn->addFnAttr(!CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining
- ? "instrument-function-exit"
- : "instrument-function-exit-inlined",
- "__cyg_profile_func_exit");
+if (CGM.getCodeGenOpts().InstrumentFunctions)
+  CurFn->addFnAttr("instrument-function-exit", "__cyg_profile_func_exit");
+if (CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining)
+  CurFn->addFnAttr("instrument-function-exit-inlined",
+   "__cyg_profile_func_exit");
   }
 
   // Emit debug descriptor for function end.
@@ -443,7 +444,8 @@
 /// instrumented with __cyg_profile_func_* calls
 bool CodeGenFunction::ShouldInstrumentFunction() {
   if (!CGM.getCodeGenOpts().InstrumentFunctions &&
-  !CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining)
+  !CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining &&
+  !CGM.getCodeGenOpts().InstrumentFunctionEntryBare)
 return false;
   if (!CurFuncDecl || CurFuncDecl->hasAttr())
 return false;
@@ -982,10 +984,14 @@
   }
 
   if (ShouldInstrumentFunction()) {
-Fn->addFnAttr(!CGM.getCodeGenOpts().InstrumentFunctionsAfterInlining
-  ? 

[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea accepted this revision.
gtbercea added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D40250



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


[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld requested changes to this revision.
Hahnfeld added a comment.
This revision now requires changes to proceed.

In https://reviews.llvm.org/D39505 @rjmccall requested that the check should be 
made independent of the language. To preserve this, I think the CUDA specific 
checks should be added to the generic case instead of restricting its 
evaluation.


https://reviews.llvm.org/D40275



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


[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 123690.
tra added a comment.

Folded OpenCL check under `if (T->isVariableArrayType())`


https://reviews.llvm.org/D40275

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2175,19 +2175,21 @@
 T = Context.getConstantArrayType(T, ConstVal, ASM, Quals);
   }
 
-  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
-  if (getLangOpts().OpenCL && T->isVariableArrayType()) {
-Diag(Loc, diag::err_opencl_vla);
-return QualType();
-  }
-  // CUDA device code doesn't support VLAs.
-  if (getLangOpts().CUDA && T->isVariableArrayType())
-CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
-  // Some targets don't support VLAs.
-  if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported() &&
-  shouldDiagnoseTargetSupportFromOpenMP()) {
-Diag(Loc, diag::err_vla_unsupported);
-return QualType();
+  if (T->isVariableArrayType()) {
+if (getLangOpts().OpenCL) {
+  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
+  Diag(Loc, diag::err_opencl_vla);
+  return QualType();
+} else if (getLangOpts().CUDA) {
+  // CUDA device code doesn't support VLAs.
+  CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+} else if (getLangOpts().OpenMP &&
+   !Context.getTargetInfo().isVLASupported() &&
+   shouldDiagnoseTargetSupportFromOpenMP()) {
+  // Some targets don't support VLAs.
+  Diag(Loc, diag::err_vla_unsupported);
+  return QualType();
+}
   }
 
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2175,19 +2175,21 @@
 T = Context.getConstantArrayType(T, ConstVal, ASM, Quals);
   }
 
-  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
-  if (getLangOpts().OpenCL && T->isVariableArrayType()) {
-Diag(Loc, diag::err_opencl_vla);
-return QualType();
-  }
-  // CUDA device code doesn't support VLAs.
-  if (getLangOpts().CUDA && T->isVariableArrayType())
-CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
-  // Some targets don't support VLAs.
-  if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported() &&
-  shouldDiagnoseTargetSupportFromOpenMP()) {
-Diag(Loc, diag::err_vla_unsupported);
-return QualType();
+  if (T->isVariableArrayType()) {
+if (getLangOpts().OpenCL) {
+  // OpenCL v1.2 s6.9.d: variable length arrays are not supported.
+  Diag(Loc, diag::err_opencl_vla);
+  return QualType();
+} else if (getLangOpts().CUDA) {
+  // CUDA device code doesn't support VLAs.
+  CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+} else if (getLangOpts().OpenMP &&
+   !Context.getTargetInfo().isVLASupported() &&
+   shouldDiagnoseTargetSupportFromOpenMP()) {
+  // Some targets don't support VLAs.
+  Diag(Loc, diag::err_vla_unsupported);
+  return QualType();
+}
   }
 
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r318601 - [OpenMP] Show error if VLAs are not supported

2017-11-20 Thread Jonas Hahnfeld via cfe-commits
I'm sorry, I didn't get a notification for that failure. I'll reply to 
the Phabricator.


Am 2017-11-20 19:37, schrieb Artem Belevich:

Proposed fix: https://reviews.llvm.org/D40275

On Mon, Nov 20, 2017 at 4:13 PM, Artem Belevich 
wrote:


This change breaks CUDA as clang now reports an error during
device-side compilation when VLA is used in the *host-side* code.


http://lab.llvm.org:8011/builders/clang-cuda-build/builds/15591/steps/ninja%20build%20simple%20CUDA%20tests/logs/stdio

[13]

E.g. I would expect this code to compile successfully, producing
empty device-side binary:

void host_func(int i) {
int vla[i];
}

However it currently fails:
#bin/clang++ --cuda-device-only --cuda-gpu-arch=sm_35 -o vla.o
vla.cu [14]

vla.cu:4:10: error: variable length arrays are not supported for the
current target
int vla[i];
^
1 error generated when compiling for sm_35.

On Sat, Nov 18, 2017 at 1:00 PM, Jonas Hahnfeld via cfe-commits
 wrote:


Author: hahnfeld
Date: Sat Nov 18 13:00:46 2017
New Revision: 318601

URL: http://llvm.org/viewvc/llvm-project?rev=318601=rev [1]
Log:
[OpenMP] Show error if VLAs are not supported

Some target devices (e.g. Nvidia GPUs) don't support dynamic stack
allocation and hence no VLAs. Print errors with description
instead
of failing in the backend or generating code that doesn't work.

This patch handles explicit uses of VLAs (local variable in target
or declare target region) or implicitly generated (private) VLAs
for reductions on VLAs or on array sections with non-constant
size.

Differential Revision: https://reviews.llvm.org/D39505 [2]

Added:
cfe/trunk/test/OpenMP/target_vla_messages.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets/NVPTX.cpp
cfe/trunk/lib/Basic/Targets/SPIR.h
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaType.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL:




http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=318601=318600=318601=diff

[3]




==

--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
(original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Nov
18 13:00:46 2017
@@ -141,6 +141,10 @@ def err_vla_decl_has_extern_linkage : Er
"variable length array declaration cannot have 'extern'
linkage">;
def ext_vla_folded_to_constant : Extension<
"variable length array folded to constant array as an
extension">, InGroup;
+def err_vla_unsupported : Error<
+  "variable length arrays are not supported for the current
target">;
+def note_vla_unsupported : Note<
+  "variable length arrays are not supported for the current
target">;

// C99 variably modified types
def err_variably_modified_template_arg : Error<
@@ -8985,6 +8989,8 @@ def err_omp_reduction_non_addressable_ex
"expected addressable reduction item for the task-based
directives">;
def err_omp_reduction_with_nogroup : Error<
"'reduction' clause cannot be used with 'nogroup' clause">;
+def err_omp_reduction_vla_unsupported : Error<
+  "cannot generate code for reduction on %select{|array section,
which requires a }0variable length array">;
} // end of OpenMP category

let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
URL:




http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/TargetInfo.h?rev=318601=318600=318601=diff

[4]




==

--- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
+++ cfe/trunk/include/clang/Basic/TargetInfo.h Sat Nov 18 13:00:46
2017
@@ -60,6 +60,7 @@ protected:
// values are specified by the TargetInfo constructor.
bool BigEndian;
bool TLSSupported;
+  bool VLASupported;
bool NoAsmVariants;  // True if {|} are normal characters.
bool HasFloat128;
unsigned char PointerWidth, PointerAlign;
@@ -939,6 +940,9 @@ public:
return MaxTLSAlign;
}

+  /// \brief Whether target supports variable-length arrays.
+  bool isVLASupported() const { return VLASupported; }
+
/// \brief Whether the target supports SEH __try.
bool isSEHTrySupported() const {
return getTriple().isOSWindows() &&

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




http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=318601=318600=318601=diff

[5]




==

--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Sat Nov 18 13:00:46 2017
@@ -8653,10 +8653,18 @@ public:
NamedDeclSetType
);
/// Check declaration inside target region.
void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D);
-  /// Return true inside OpenMP target region.
+  /// Return true inside OpenMP declare 

Re: r318601 - [OpenMP] Show error if VLAs are not supported

2017-11-20 Thread Artem Belevich via cfe-commits
Proposed fix: https://reviews.llvm.org/D40275

On Mon, Nov 20, 2017 at 4:13 PM, Artem Belevich  wrote:

> This change breaks CUDA as clang now reports an error during device-side
> compilation when VLA is used in the *host-side* code.
> http://lab.llvm.org:8011/builders/clang-cuda-build/
> builds/15591/steps/ninja%20build%20simple%20CUDA%20tests/logs/stdio
>
> E.g. I would expect this code to compile successfully, producing empty
> device-side binary:
>
> void host_func(int i) {
>   int vla[i];
> }
>
> However it currently fails:
> #bin/clang++ --cuda-device-only --cuda-gpu-arch=sm_35 -o vla.o vla.cu
> vla.cu:4:10: error: variable length arrays are not supported for the
> current target
>   int vla[i];
>  ^
> 1 error generated when compiling for sm_35.
>
>
>
>
> On Sat, Nov 18, 2017 at 1:00 PM, Jonas Hahnfeld via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: hahnfeld
>> Date: Sat Nov 18 13:00:46 2017
>> New Revision: 318601
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=318601=rev
>> Log:
>> [OpenMP] Show error if VLAs are not supported
>>
>> Some target devices (e.g. Nvidia GPUs) don't support dynamic stack
>> allocation and hence no VLAs. Print errors with description instead
>> of failing in the backend or generating code that doesn't work.
>>
>> This patch handles explicit uses of VLAs (local variable in target
>> or declare target region) or implicitly generated (private) VLAs
>> for reductions on VLAs or on array sections with non-constant size.
>>
>> Differential Revision: https://reviews.llvm.org/D39505
>>
>> Added:
>> cfe/trunk/test/OpenMP/target_vla_messages.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Basic/TargetInfo.h
>> cfe/trunk/include/clang/Sema/Sema.h
>> cfe/trunk/lib/Basic/TargetInfo.cpp
>> cfe/trunk/lib/Basic/Targets/NVPTX.cpp
>> cfe/trunk/lib/Basic/Targets/SPIR.h
>> cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> cfe/trunk/lib/Sema/SemaType.cpp
>>
>> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/DiagnosticSemaKinds.td?rev=318601=318600=318601=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Nov 18
>> 13:00:46 2017
>> @@ -141,6 +141,10 @@ def err_vla_decl_has_extern_linkage : Er
>>"variable length array declaration cannot have 'extern' linkage">;
>>  def ext_vla_folded_to_constant : Extension<
>>"variable length array folded to constant array as an extension">,
>> InGroup;
>> +def err_vla_unsupported : Error<
>> +  "variable length arrays are not supported for the current target">;
>> +def note_vla_unsupported : Note<
>> +  "variable length arrays are not supported for the current target">;
>>
>>  // C99 variably modified types
>>  def err_variably_modified_template_arg : Error<
>> @@ -8985,6 +8989,8 @@ def err_omp_reduction_non_addressable_ex
>>"expected addressable reduction item for the task-based directives">;
>>  def err_omp_reduction_with_nogroup : Error<
>>"'reduction' clause cannot be used with 'nogroup' clause">;
>> +def err_omp_reduction_vla_unsupported : Error<
>> +  "cannot generate code for reduction on %select{|array section, which
>> requires a }0variable length array">;
>>  } // end of OpenMP category
>>
>>  let CategoryName = "Related Result Type Issue" in {
>>
>> Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/TargetInfo.h?rev=318601=318600=318601=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
>> +++ cfe/trunk/include/clang/Basic/TargetInfo.h Sat Nov 18 13:00:46 2017
>> @@ -60,6 +60,7 @@ protected:
>>// values are specified by the TargetInfo constructor.
>>bool BigEndian;
>>bool TLSSupported;
>> +  bool VLASupported;
>>bool NoAsmVariants;  // True if {|} are normal characters.
>>bool HasFloat128;
>>unsigned char PointerWidth, PointerAlign;
>> @@ -939,6 +940,9 @@ public:
>>  return MaxTLSAlign;
>>}
>>
>> +  /// \brief Whether target supports variable-length arrays.
>> +  bool isVLASupported() const { return VLASupported; }
>> +
>>/// \brief Whether the target supports SEH __try.
>>bool isSEHTrySupported() const {
>>  return getTriple().isOSWindows() &&
>>
>> Modified: cfe/trunk/include/clang/Sema/Sema.h
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Sema/Sema.h?rev=318601=318600=318601=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Sema/Sema.h (original)
>> +++ cfe/trunk/include/clang/Sema/Sema.h Sat Nov 18 13:00:46 2017
>> @@ -8653,10 

[PATCH] D40275: [CUDA] Report "unsupported VLA" errors only on device side.

2017-11-20 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added a subscriber: sanjoy.

This fixes erroneously reported CUDA compilation errors in host-side code 
during device-side compilation.

I've also restricted OpenMP-specific checks to trigger only if we're compiling 
with OpenMP enabled.


https://reviews.llvm.org/D40275

Files:
  clang/lib/Sema/SemaType.cpp


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2180,14 +2180,17 @@
 Diag(Loc, diag::err_opencl_vla);
 return QualType();
   }
-  // CUDA device code doesn't support VLAs.
-  if (getLangOpts().CUDA && T->isVariableArrayType())
-CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
-  // Some targets don't support VLAs.
-  if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported() &&
-  shouldDiagnoseTargetSupportFromOpenMP()) {
-Diag(Loc, diag::err_vla_unsupported);
-return QualType();
+  if (T->isVariableArrayType()) {
+if (getLangOpts().CUDA) {
+  // CUDA device code doesn't support VLAs.
+  CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+} else if (getLangOpts().OpenMP &&
+   !Context.getTargetInfo().isVLASupported() &&
+   shouldDiagnoseTargetSupportFromOpenMP()) {
+  // Some targets don't support VLAs.
+  Diag(Loc, diag::err_vla_unsupported);
+  return QualType();
+}
   }
 
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.


Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2180,14 +2180,17 @@
 Diag(Loc, diag::err_opencl_vla);
 return QualType();
   }
-  // CUDA device code doesn't support VLAs.
-  if (getLangOpts().CUDA && T->isVariableArrayType())
-CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
-  // Some targets don't support VLAs.
-  if (T->isVariableArrayType() && !Context.getTargetInfo().isVLASupported() &&
-  shouldDiagnoseTargetSupportFromOpenMP()) {
-Diag(Loc, diag::err_vla_unsupported);
-return QualType();
+  if (T->isVariableArrayType()) {
+if (getLangOpts().CUDA) {
+  // CUDA device code doesn't support VLAs.
+  CUDADiagIfDeviceCode(Loc, diag::err_cuda_vla) << CurrentCUDATarget();
+} else if (getLangOpts().OpenMP &&
+   !Context.getTargetInfo().isVLASupported() &&
+   shouldDiagnoseTargetSupportFromOpenMP()) {
+  // Some targets don't support VLAs.
+  Diag(Loc, diag::err_vla_unsupported);
+  return QualType();
+}
   }
 
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On 20 November 2017 22:19:04 CET, Volodymyr Sapsai  wrote:
>On Nov 20, 2017, at 11:32, Reimar Döffinger 
>wrote:
>> 
>> On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote:
 catch (...)
 {
 +if (__n > 0)
 +*__s = char_type();
 this->__set_badbit_and_consider_rethrow();
 }
>>> 
>>> or maybe something else?
>> 
>> That one (note that the __set_badbit_and_consider_rethrow
>> will never re-throw in this case).
>
>But by #define _LIBCPP_NO_EXCEPTIONS 1 you exclude this block at
>preprocessing step
>
>>  #ifndef _LIBCPP_NO_EXCEPTIONS
>>  }
>>  catch (...)
>>  {
>> +if (__n > 0)
>> +*__s = char_type();
>>  this->__set_badbit_and_consider_rethrow();
>>  }
>>  #endif  // _LIBCPP_NO_EXCEPTIONS
>
>And looks like getline_pointer_size_exception.pass.cpp doesn’t execute
>this code.

Yes, that was complete nonsense, I somehow always read #ifdef where there was 
an #ifndef...
Not sure then if that 0 termination should be there (and be tested) or better 
to not have it in the exception case at all (I haven't checked if the exception 
is always re-thrown or not, which might be relevant).
I am a bit unclear about that whole code there that catches exceptions and sets 
the bad bit and how it maps to the specification.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r318716 - [X86] Remove 'mm3now' from isValidFeatureName.

2017-11-20 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Mon Nov 20 16:33:26 2017
New Revision: 318716

URL: http://llvm.org/viewvc/llvm-project?rev=318716=rev
Log:
[X86] Remove 'mm3now' from isValidFeatureName.

The correct spelling is '3dnow' which is already in the list.

Modified:
cfe/trunk/lib/Basic/Targets/X86.cpp

Modified: cfe/trunk/lib/Basic/Targets/X86.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/X86.cpp?rev=318716=318715=318716=diff
==
--- cfe/trunk/lib/Basic/Targets/X86.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/X86.cpp Mon Nov 20 16:33:26 2017
@@ -1150,8 +1150,6 @@ bool X86TargetInfo::isValidFeatureName(S
   .Case("fxsr", true)
   .Case("lwp", true)
   .Case("lzcnt", true)
-  .Case("mm3dnow", true)
-  .Case("mm3dnowa", true)
   .Case("mmx", true)
   .Case("movbe", true)
   .Case("mpx", true)


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


[PATCH] D40224: [X86] Control-Flow Enforcement Technology - Shadow Stack and Indirect Branch Tracking support (Clang side)

2017-11-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: include/clang/Basic/BuiltinsX86.def:642
+// SHSTK
+TARGET_BUILTIN(__builtin_ia32_incsspd, "vUi","u","shstk")
+TARGET_BUILTIN(__builtin_ia32_rdsspd, "UiUi","Un","shstk")

Space after commas to match the rest of the file



Comment at: include/clang/Driver/Options.td:1801
 def mno_stackrealign : Flag<["-"], "mno-stackrealign">, Group;
+def mno_cet : Flag<["-"], "mno-cet">, Group;
+def mno_shstk : Flag<["-"], "mno-shstk">, Group;

erichkeane wrote:
> Since CET is a union of the other two, how do we handle conflicting 
> configurations?  Is -mcet -mno-ibt an error, or the same as mno-shstk?  
> Repeat question for all combinations.
All the flags should go in the "X86 feature flags" section later in this file.



Comment at: lib/Basic/Targets/X86.cpp:619
   Features["xsave"] = true;
+  } else if (Name == "cet") {
+if (Enabled)

It looks like "cet" is meant to be a alias for two features? Should you avoid 
putting it in Features map at line 545 lke we do with "sse4"? Then it will 
never get sent to the backend and you can remove FeatureCET from X86.td



Comment at: lib/Basic/Targets/X86.cpp:620
+  } else if (Name == "cet") {
+if (Enabled)
+  Features["shstk"] = Features["ibt"] = true;

Is -mno-cet intended to disable both features? Cause that doesn't happen with 
the way this is written.



Comment at: lib/Basic/Targets/X86.cpp:687
   HasMPX = true;
+} else if (Feature == "+cet") {
+  HasSHSTK = true;

This shouldn't be needed. "+cet" implies +shstk and +ibt. Those should be added 
to feature map before we call this method



Comment at: lib/Basic/Targets/X86.cpp:1230
   .Case("mpx", HasMPX)
+  .Case("cet", HasSHSTK && HasIBT)
+  .Case("shstk", HasSHSTK)

I'm not sure what hasFeature is really used for, but I doubt "cet" needs to be 
in it.



Comment at: test/CodeGen/builtins-x86.c:260
 
+  __builtin_ia32_incsspd(tmp_Ui);
+  __builtin_ia32_incsspq(tmp_ULLi);

I don't think you need to update this test. The intrinsic header test should be 
enough. I don't know why this test exists.



Comment at: test/Driver/x86-target-features.c:75
+// RUN: %clang -target i386-unknown-linux-gnu -march=i386 -mno-cet %s -### -o 
%t.o 2>&1 | FileCheck -check-prefix=NO-CET %s
+// CET: "-target-feature" "+cet"
+// NO-CET: "-target-feature" "-cet"

Should this check that +shstk and +ibt got added. That seems like the more 
important thing to check.


Repository:
  rL LLVM

https://reviews.llvm.org/D40224



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


Re: r318601 - [OpenMP] Show error if VLAs are not supported

2017-11-20 Thread Artem Belevich via cfe-commits
This change breaks CUDA as clang now reports an error during device-side
compilation when VLA is used in the *host-side* code.
http://lab.llvm.org:8011/builders/clang-cuda-build/builds/15591/steps/ninja%20build%20simple%20CUDA%20tests/logs/stdio

E.g. I would expect this code to compile successfully, producing empty
device-side binary:

void host_func(int i) {
  int vla[i];
}

However it currently fails:
#bin/clang++ --cuda-device-only --cuda-gpu-arch=sm_35 -o vla.o vla.cu
vla.cu:4:10: error: variable length arrays are not supported for the
current target
  int vla[i];
 ^
1 error generated when compiling for sm_35.




On Sat, Nov 18, 2017 at 1:00 PM, Jonas Hahnfeld via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: hahnfeld
> Date: Sat Nov 18 13:00:46 2017
> New Revision: 318601
>
> URL: http://llvm.org/viewvc/llvm-project?rev=318601=rev
> Log:
> [OpenMP] Show error if VLAs are not supported
>
> Some target devices (e.g. Nvidia GPUs) don't support dynamic stack
> allocation and hence no VLAs. Print errors with description instead
> of failing in the backend or generating code that doesn't work.
>
> This patch handles explicit uses of VLAs (local variable in target
> or declare target region) or implicitly generated (private) VLAs
> for reductions on VLAs or on array sections with non-constant size.
>
> Differential Revision: https://reviews.llvm.org/D39505
>
> Added:
> cfe/trunk/test/OpenMP/target_vla_messages.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Basic/TargetInfo.h
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Basic/TargetInfo.cpp
> cfe/trunk/lib/Basic/Targets/NVPTX.cpp
> cfe/trunk/lib/Basic/Targets/SPIR.h
> cfe/trunk/lib/Sema/SemaOpenMP.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=318601=318600=318601=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Sat Nov 18
> 13:00:46 2017
> @@ -141,6 +141,10 @@ def err_vla_decl_has_extern_linkage : Er
>"variable length array declaration cannot have 'extern' linkage">;
>  def ext_vla_folded_to_constant : Extension<
>"variable length array folded to constant array as an extension">,
> InGroup;
> +def err_vla_unsupported : Error<
> +  "variable length arrays are not supported for the current target">;
> +def note_vla_unsupported : Note<
> +  "variable length arrays are not supported for the current target">;
>
>  // C99 variably modified types
>  def err_variably_modified_template_arg : Error<
> @@ -8985,6 +8989,8 @@ def err_omp_reduction_non_addressable_ex
>"expected addressable reduction item for the task-based directives">;
>  def err_omp_reduction_with_nogroup : Error<
>"'reduction' clause cannot be used with 'nogroup' clause">;
> +def err_omp_reduction_vla_unsupported : Error<
> +  "cannot generate code for reduction on %select{|array section, which
> requires a }0variable length array">;
>  } // end of OpenMP category
>
>  let CategoryName = "Related Result Type Issue" in {
>
> Modified: cfe/trunk/include/clang/Basic/TargetInfo.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/TargetInfo.h?rev=318601=318600=318601=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/TargetInfo.h (original)
> +++ cfe/trunk/include/clang/Basic/TargetInfo.h Sat Nov 18 13:00:46 2017
> @@ -60,6 +60,7 @@ protected:
>// values are specified by the TargetInfo constructor.
>bool BigEndian;
>bool TLSSupported;
> +  bool VLASupported;
>bool NoAsmVariants;  // True if {|} are normal characters.
>bool HasFloat128;
>unsigned char PointerWidth, PointerAlign;
> @@ -939,6 +940,9 @@ public:
>  return MaxTLSAlign;
>}
>
> +  /// \brief Whether target supports variable-length arrays.
> +  bool isVLASupported() const { return VLASupported; }
> +
>/// \brief Whether the target supports SEH __try.
>bool isSEHTrySupported() const {
>  return getTriple().isOSWindows() &&
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Sema.h?rev=318601=318600=318601=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Sat Nov 18 13:00:46 2017
> @@ -8653,10 +8653,18 @@ public:
>  NamedDeclSetType );
>/// Check declaration inside target region.
>void checkDeclIsAllowedInOpenMPTarget(Expr *E, Decl *D);
> -  /// Return true inside OpenMP target region.
> +  /// Return true 

[PATCH] D40259: [libcxx] LWG2993: reference_wrapper conversion from T&

2017-11-20 Thread Agustín Bergé via Phabricator via cfe-commits
K-ballo updated this revision to Diff 123679.
K-ballo added a comment.

Addressed review comments. Added tests for SFINAE, noexcept, deduction guide.


https://reviews.llvm.org/D40259

Files:
  include/__functional_base
  include/functional
  
test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
  
test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
  
test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
  test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp

Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
===
--- test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_ctor.pass.cpp
@@ -15,6 +15,7 @@
 
 #include 
 #include 
+#include 
 
 class functor1
 {
@@ -41,4 +42,19 @@
 test(i);
 const int j = 0;
 test(j);
+
+{
+using Ref = std::reference_wrapper;
+static_assert((std::is_constructible::value), "");
+static_assert((!std::is_constructible::value), "");
+static_assert((!std::is_constructible::value), "");
+}
+
+#if TEST_STD_VER >= 11
+{
+using Ref = std::reference_wrapper;
+static_assert((std::is_nothrow_constructible::value), "");
+static_assert((!std::is_nothrow_constructible::value), "");
+}
+#endif
 }
Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
===
--- /dev/null
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.pass.cpp
@@ -0,0 +1,82 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// reference_wrapper
+
+// template 
+//   reference_wrapper(U&&) noexcept(see below);
+
+// XFAIL: c++98, c++03
+
+#include 
+#include 
+
+struct convertible_to_int_ref {
+int val = 0;
+operator int&() { return val; }
+operator int const&() const { return val; }
+};
+
+template 
+struct nothrow_convertible {
+int val = 0;
+operator int&() noexcept(IsNothrow) { return val; }
+};
+
+struct convertible_from_int {
+convertible_from_int(int) {}
+};
+
+void meow(std::reference_wrapper) {}
+void meow(convertible_from_int) {}
+
+int gi;
+std::reference_wrapper purr() { return gi; };
+
+template 
+void
+test(T& t)
+{
+std::reference_wrapper r(t);
+assert(() == );
+}
+
+void f() {}
+
+int main()
+{
+convertible_to_int_ref convi;
+test(convi);
+convertible_to_int_ref const convic;
+test(convic);
+
+{
+using Ref = std::reference_wrapper;
+static_assert((std::is_nothrow_constructible::value), "");
+static_assert((!std::is_nothrow_constructible::value), "");
+}
+
+{
+meow(0);
+(true) ? purr() : 0;
+}
+
+#ifdef __cpp_deduction_guides
+{
+int i = 0;
+std::reference_wrapper ri(i);
+static_assert((std::is_same::value), "" );
+const int j = 0;
+std::reference_wrapper rj(j);
+static_assert((std::is_same::value), "" );
+}
+#endif
+}
Index: test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
===
--- /dev/null
+++ test/std/utilities/function.objects/refwrap/refwrap.const/type_conv_ctor.fail.cpp
@@ -0,0 +1,31 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// reference_wrapper
+
+// template 
+//   reference_wrapper(U&&) noexcept(see below);
+
+// XFAIL: c++98, c++03
+
+#include 
+#include 
+
+struct convertible_to_float_ref {
+float val = 0;
+operator float const&() const { return val; }
+};
+
+int main()
+{
+convertible_to_float_ref convf;
+std::reference_wrapper r(convf);
+}
Index: test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
===
--- test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
+++ test/std/utilities/function.objects/refwrap/refwrap.assign/copy_assign.pass.cpp
@@ -15,11 +15,18 @@
 
 

[PATCH] D40187: [OpenMP] Initial implementation of code generation for pragma 'teams distribute parallel for' on host

2017-11-20 Thread Carlo Bertolli via Phabricator via cfe-commits
carlo.bertolli closed this revision.
carlo.bertolli added a comment.

Committed revision 318692.


Repository:
  rL LLVM

https://reviews.llvm.org/D40187



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


[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 123677.
juliehockett marked 8 inline comments as done.
juliehockett added a comment.

Moved AST matcher out to ASTMatchers.h (see D40261 
), fixing comments


https://reviews.llvm.org/D40108

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/fuchsia/CMakeLists.txt
  clang-tidy/fuchsia/DefaultArgumentsCheck.cpp
  clang-tidy/fuchsia/DefaultArgumentsCheck.h
  clang-tidy/fuchsia/FuchsiaTidyModule.cpp
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/fuchsia-default-arguments.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/index.rst
  test/clang-tidy/fuchsia-default-arguments.cpp

Index: test/clang-tidy/fuchsia-default-arguments.cpp
===
--- /dev/null
+++ test/clang-tidy/fuchsia-default-arguments.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s fuchsia-default-arguments %t
+
+int foo(int value = 5) { return value; }
+// CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring functions which use default arguments are disallowed [fuchsia-default-arguments]
+// CHECK-FIXES: int foo(int value) { return value; }
+
+int f() {
+  foo();
+  // CHECK-MESSAGES: [[@LINE-1]]:3: warning: calling functions which use default arguments are disallowed [fuchsia-default-arguments]
+  // CHECK-NEXT: note: the default parameter was declared here:
+  // CHECK-NEXT: int foo(int value = 5) { return value; }
+}
+
+// Negatives.
+int bar(int value) { return value; }
+
+int n() {
+  foo(0);
+  bar(0);
+}
+
+class Baz {
+public:
+  int a(int value = 5) { return value; }
+  // CHECK-MESSAGES: [[@LINE-1]]:9: warning: declaring functions which use default arguments are disallowed [fuchsia-default-arguments]
+  // CHECK-FIXES: int a(int value) { return value; }
+  
+  int b(int value) { return value; }
+};
Index: docs/clang-tidy/index.rst
===
--- docs/clang-tidy/index.rst
+++ docs/clang-tidy/index.rst
@@ -61,6 +61,7 @@
 ``cert-``  Checks related to CERT Secure Coding Guidelines.
 ``cppcoreguidelines-`` Checks related to C++ Core Guidelines.
 ``clang-analyzer-``Clang Static Analyzer checks.
+``fuchsia-``   Checks related to Fuchsia coding conventions.
 ``google-``Checks related to Google coding conventions.
 ``hicpp-`` Checks related to High Integrity C++ Coding Standard.
 ``llvm-``  Checks related to the LLVM coding conventions.
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -55,6 +55,7 @@
cppcoreguidelines-pro-type-vararg
cppcoreguidelines-slicing
cppcoreguidelines-special-member-functions
+   fuchsia-default-arguments
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
Index: docs/clang-tidy/checks/fuchsia-default-arguments.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/fuchsia-default-arguments.rst
@@ -0,0 +1,25 @@
+.. title:: clang-tidy - fuchsia-default-arguments
+
+fuchsia-default-arguments
+=
+
+Warns if a function is declared or called with default arguments.
+
+For example, the declaration:
+
+.. code-block:: c++
+
+  int foo(int value = 5) { return value; }
+
+will cause a warning.
+
+If a function with default arguments is already defined, calling it with no
+arguments will also cause a warning. Calling it without defaults will not cause
+a warning:
+
+.. code-block:: c++
+
+  foo();  // warning
+  foo(0); // no warning
+
+See the features disallowed in Fuchsia at https://fuchsia.googlesource.com/zircon/+/master/docs/cxx.md
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `fuchsia-default-arguments
+  `_ check
+
+  Warns if a function or method is declared or called with default arguments.
+
 - New `google-avoid-throwing-objc-exception
   `_ check
 
Index: clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tidy/tool/ClangTidyMain.cpp
@@ -482,6 +482,11 @@
 static int LLVM_ATTRIBUTE_UNUSED CppCoreGuidelinesModuleAnchorDestination =
 CppCoreGuidelinesModuleAnchorSource;
 
+// This anchor is used to force the linker to link the GoogleModule.
+extern volatile int FuchsiaModuleAnchorSource;
+static int LLVM_ATTRIBUTE_UNUSED FuchsiaModuleAnchorDestination =
+FuchsiaModuleAnchorSource;

[PATCH] D40108: [clang-tidy] Adding Fuchsia checkers to clang-tidy

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tidy/fuchsia/DefaultArgumentsCheck.cpp:22
+  // Calling a function which uses default arguments is disallowed.
+  Finder->addMatcher(cxxDefaultArgExpr().bind("stmt"), this);
+  // Declaring default parameters is disallowed.

aaron.ballman wrote:
> Isn't this case already covered by the other matcher? Or do you have system 
> header files which have default arguments and those functions are disallowed 
> by the style guide, but cannot be removed from the system header?
The latter -- there's a bunch of third-party code and the like that could have 
default arguments, but shouldn't be used like that in the project.


https://reviews.llvm.org/D40108



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


[PATCH] D40228: [Target] Keep the TargetOptions feature list sorted instead of sorting during CodeGen

2017-11-20 Thread Eric Christopher via Phabricator via cfe-commits
echristo added a comment.

No strong opinion. I think I like that one more though.


https://reviews.llvm.org/D40228



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


[PATCH] D40228: [Target] Keep the TargetOptions feature list sorted instead of sorting during CodeGen

2017-11-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Yeah don't like it either, but was surprised to find that CodeGen even had a 
non-const reference to TargetOptions. Would it be better to make a copy and 
sort the copy during CodeGen?


https://reviews.llvm.org/D40228



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


[PATCH] D40228: [Target] Keep the TargetOptions feature list sorted instead of sorting during CodeGen

2017-11-20 Thread Eric Christopher via Phabricator via cfe-commits
echristo accepted this revision.
echristo added a comment.
This revision is now accepted and ready to land.

This seems strictly more difficult to keep under control? Though I guess the 
assert helps.

Feel free to go ahead, but...


https://reviews.llvm.org/D40228



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


[PATCH] D40270: [Modules TS] Added re-export support

2017-11-20 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.

This patch adds support for re-exporting modules as described in 
`[dcl.modules.export]`


https://reviews.llvm.org/D40270

Files:
  include/clang/Parse/Parser.h
  lib/Parse/ParseObjc.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDecl.cpp
  test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp
  test/SemaCXX/modules-ts.cppm

Index: test/SemaCXX/modules-ts.cppm
===
--- test/SemaCXX/modules-ts.cppm
+++ test/SemaCXX/modules-ts.cppm
@@ -52,10 +52,6 @@
 export { ; }
 export { static_assert(true); }
 
-// FIXME: These diagnostics are not very good.
-export import foo; // expected-error {{expected unqualified-id}}
-export { import foo; } // expected-error {{expected unqualified-id}}
-
 int use_b = b;
 int use_n = n; // FIXME: this should not be visible, because it is not exported
 
Index: test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp
===
--- test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp
+++ test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.export/p1.cpp
@@ -0,0 +1,40 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+//
+// RUN: echo 'export module a; export class A{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/a.pcm
+// RUN: echo 'export module b; export class B{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/b.pcm
+// RUN: echo 'export module c; export class C{};' | %clang_cc1 -x c++ -fmodules-ts -emit-module-interface - -o %t/c.pcm
+//
+// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.internal.pcm -DAGGREGATE_INTERNAL
+// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t -emit-module-interface %s -o %t/aggregate.pcm -DAGGREGATE
+//
+// RUN: %clang_cc1 -fmodules-ts -fprebuilt-module-path=%t %s -verify -DTEST
+// expected-no-diagnostics
+
+
+#ifdef AGGREGATE_INTERNAL
+export module aggregate.internal;
+export import a;
+export {
+  import b;
+  import c;
+}
+#endif
+
+
+// Export the above aggregate module.
+// This is done to ensure that re-exports are transitive.
+#ifdef AGGREGATE
+export module aggregate;
+export import aggregate.internal;
+#endif
+
+
+// For the actual test, just try using the classes from the exported modules
+// and hope that they're accessible.
+#ifdef TEST
+import aggregate;
+A a;
+B b;
+C c;
+#endif
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -16171,7 +16171,7 @@
 DC = LSD->getParent();
   }
 
-  while (isa(DC))
+  while (isa(DC) || isa(DC))
 DC = DC->getParent();
 
   if (!isa(DC)) {
@@ -16349,12 +16349,17 @@
 IdentifierLocs.push_back(Path[I].second);
   }
 
-  TranslationUnitDecl *TU = getASTContext().getTranslationUnitDecl();
-  ImportDecl *Import = ImportDecl::Create(Context, TU, StartLoc,
+  ImportDecl *Import = ImportDecl::Create(Context, CurContext, StartLoc,
   Mod, IdentifierLocs);
   if (!ModuleScopes.empty())
 Context.addModuleInitializer(ModuleScopes.back().Module, Import);
-  TU->addDecl(Import);
+  CurContext->addDecl(Import);
+
+  // Re-export the module if needed.
+  if (Import->isExported() &&
+  !ModuleScopes.empty() && ModuleScopes.back().ModuleInterface)
+getCurrentModule()->Exports.emplace_back(Mod, false);
+
   return Import;
 }
 
Index: lib/Parse/Parser.cpp
===
--- lib/Parse/Parser.cpp
+++ lib/Parse/Parser.cpp
@@ -556,10 +556,6 @@
 HandlePragmaUnused();
 return false;
 
-  case tok::kw_import:
-Result = ParseModuleImport(SourceLocation());
-return false;
-
   case tok::kw_export:
 if (NextToken().isNot(tok::kw_module))
   break;
@@ -637,6 +633,9 @@
 ///   ';'
 ///
 /// [C++0x/GNU] 'extern' 'template' declaration
+///
+/// [Modules-TS] module-import-declaration
+///
 Parser::DeclGroupPtrTy
 Parser::ParseExternalDeclaration(ParsedAttributesWithRange ,
  ParsingDeclSpec *DS) {
@@ -764,6 +763,9 @@
 CurParsedObjCImpl ? Sema::PCC_ObjCImplementation : Sema::PCC_Namespace);
 cutOffParsing();
 return nullptr;
+  case tok::kw_import:
+SingleDecl = ParseModuleImport(SourceLocation());
+break;
   case tok::kw_export:
 if (getLangOpts().ModulesTS) {
   SingleDecl = ParseExportDeclaration();
@@ -2092,7 +2094,7 @@
 ///   '@' 'import' module-name ';'
 /// [ModTS] module-import-declaration:
 ///   'import' module-name attribute-specifier-seq[opt] ';'
-Parser::DeclGroupPtrTy Parser::ParseModuleImport(SourceLocation AtLoc) {
+Decl *Parser::ParseModuleImport(SourceLocation AtLoc) {
   assert((AtLoc.isInvalid() ? Tok.is(tok::kw_import)
 : Tok.isObjCAtKeyword(tok::objc_import)) &&
  "Improper start to module import");

[PATCH] D39438: [analyzer] Diagnose stack leaks via block captures

2017-11-20 Thread Alexander Shaposhnikov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL318705: [analyzer] Diagnose stack leaks via block captures 
(authored by alexshap).

Changed prior to commit:
  https://reviews.llvm.org/D39438?vs=123392=123664#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D39438

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  cfe/trunk/test/Analysis/stack-capture-leak-arc.mm
  cfe/trunk/test/Analysis/stack-capture-leak-no-arc.mm

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -18,104 +18,223 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "llvm/ADT/SmallString.h"
 #include "llvm/Support/raw_ostream.h"
 using namespace clang;
 using namespace ento;
 
 namespace {
-class StackAddrEscapeChecker : public Checker< check::PreStmt,
-   check::EndFunction > {
+class StackAddrEscapeChecker
+: public Checker {
+  mutable IdentifierInfo *dispatch_semaphore_tII;
   mutable std::unique_ptr BT_stackleak;
   mutable std::unique_ptr BT_returnstack;
+  mutable std::unique_ptr BT_capturedstackasync;
+  mutable std::unique_ptr BT_capturedstackret;
 
 public:
+  void checkPreCall(const CallEvent , CheckerContext ) const;
   void checkPreStmt(const ReturnStmt *RS, CheckerContext ) const;
   void checkEndFunction(CheckerContext ) const;
+
 private:
+  void checkReturnedBlockCaptures(const BlockDataRegion ,
+  CheckerContext ) const;
+  void checkAsyncExecutedBlockCaptures(const BlockDataRegion ,
+   CheckerContext ) const;
   void EmitStackError(CheckerContext , const MemRegion *R,
   const Expr *RetE) const;
+  bool isSemaphoreCaptured(const BlockDecl ) const;
   static SourceRange genName(raw_ostream , const MemRegion *R,
  ASTContext );
+  static SmallVector
+  getCapturedStackRegions(const BlockDataRegion , CheckerContext );
+  static bool isArcManagedBlock(const MemRegion *R, CheckerContext );
+  static bool isNotInCurrentFrame(const MemRegion *R, CheckerContext );
 };
-}
+} // namespace
 
 SourceRange StackAddrEscapeChecker::genName(raw_ostream , const MemRegion *R,
 ASTContext ) {
-// Get the base region, stripping away fields and elements.
+  // Get the base region, stripping away fields and elements.
   R = R->getBaseRegion();
   SourceManager  = Ctx.getSourceManager();
   SourceRange range;
   os << "Address of ";
 
   // Check if the region is a compound literal.
-  if (const CompoundLiteralRegion* CR = dyn_cast(R)) {
+  if (const auto *CR = dyn_cast(R)) {
 const CompoundLiteralExpr *CL = CR->getLiteralExpr();
 os << "stack memory associated with a compound literal "
   "declared on line "
-<< SM.getExpansionLineNumber(CL->getLocStart())
-<< " returned to caller";
+   << SM.getExpansionLineNumber(CL->getLocStart()) << " returned to caller";
 range = CL->getSourceRange();
-  }
-  else if (const AllocaRegion* AR = dyn_cast(R)) {
+  } else if (const auto *AR = dyn_cast(R)) {
 const Expr *ARE = AR->getExpr();
 SourceLocation L = ARE->getLocStart();
 range = ARE->getSourceRange();
 os << "stack memory allocated by call to alloca() on line "
<< SM.getExpansionLineNumber(L);
-  }
-  else if (const BlockDataRegion *BR = dyn_cast(R)) {
+  } else if (const auto *BR = dyn_cast(R)) {
 const BlockDecl *BD = BR->getCodeRegion()->getDecl();
 SourceLocation L = BD->getLocStart();
 range = BD->getSourceRange();
 os << "stack-allocated block declared on line "
<< SM.getExpansionLineNumber(L);
-  }
-  else if (const VarRegion *VR = dyn_cast(R)) {
-os << "stack memory associated with local variable '"
-   << VR->getString() << '\'';
+  } else if (const auto *VR = dyn_cast(R)) {
+os << "stack memory associated with local variable '" << VR->getString()
+   << '\'';
 range = VR->getDecl()->getSourceRange();
-  }
-  else if (const CXXTempObjectRegion *TOR = dyn_cast(R)) {
+  } else if (const auto *TOR = dyn_cast(R)) {
 QualType Ty = TOR->getValueType().getLocalUnqualifiedType();
 os << "stack memory associated with temporary object of type '";
 Ty.print(os, Ctx.getPrintingPolicy());
 os << "'";
 range = 

r318705 - [analyzer] Diagnose stack leaks via block captures

2017-11-20 Thread Alexander Shaposhnikov via cfe-commits
Author: alexshap
Date: Mon Nov 20 14:53:30 2017
New Revision: 318705

URL: http://llvm.org/viewvc/llvm-project?rev=318705=rev
Log:
[analyzer] Diagnose stack leaks via block captures

This diff extends StackAddrEscapeChecker
to catch stack addresses leaks via block captures
if the block is executed asynchronously or
returned from a function.

Differential revision: https://reviews.llvm.org/D39438

Added:
cfe/trunk/test/Analysis/stack-capture-leak-arc.mm
cfe/trunk/test/Analysis/stack-capture-leak-no-arc.mm
Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp?rev=318705=318704=318705=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp Mon Nov 20 
14:53:30 2017
@@ -18,6 +18,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "llvm/ADT/SmallString.h"
@@ -26,85 +27,131 @@ using namespace clang;
 using namespace ento;
 
 namespace {
-class StackAddrEscapeChecker : public Checker< check::PreStmt,
-   check::EndFunction > {
+class StackAddrEscapeChecker
+: public Checker {
+  mutable IdentifierInfo *dispatch_semaphore_tII;
   mutable std::unique_ptr BT_stackleak;
   mutable std::unique_ptr BT_returnstack;
+  mutable std::unique_ptr BT_capturedstackasync;
+  mutable std::unique_ptr BT_capturedstackret;
 
 public:
+  void checkPreCall(const CallEvent , CheckerContext ) const;
   void checkPreStmt(const ReturnStmt *RS, CheckerContext ) const;
   void checkEndFunction(CheckerContext ) const;
+
 private:
+  void checkReturnedBlockCaptures(const BlockDataRegion ,
+  CheckerContext ) const;
+  void checkAsyncExecutedBlockCaptures(const BlockDataRegion ,
+   CheckerContext ) const;
   void EmitStackError(CheckerContext , const MemRegion *R,
   const Expr *RetE) const;
+  bool isSemaphoreCaptured(const BlockDecl ) const;
   static SourceRange genName(raw_ostream , const MemRegion *R,
  ASTContext );
+  static SmallVector
+  getCapturedStackRegions(const BlockDataRegion , CheckerContext );
+  static bool isArcManagedBlock(const MemRegion *R, CheckerContext );
+  static bool isNotInCurrentFrame(const MemRegion *R, CheckerContext );
 };
-}
+} // namespace
 
 SourceRange StackAddrEscapeChecker::genName(raw_ostream , const MemRegion 
*R,
 ASTContext ) {
-// Get the base region, stripping away fields and elements.
+  // Get the base region, stripping away fields and elements.
   R = R->getBaseRegion();
   SourceManager  = Ctx.getSourceManager();
   SourceRange range;
   os << "Address of ";
 
   // Check if the region is a compound literal.
-  if (const CompoundLiteralRegion* CR = dyn_cast(R)) {
+  if (const auto *CR = dyn_cast(R)) {
 const CompoundLiteralExpr *CL = CR->getLiteralExpr();
 os << "stack memory associated with a compound literal "
   "declared on line "
-<< SM.getExpansionLineNumber(CL->getLocStart())
-<< " returned to caller";
+   << SM.getExpansionLineNumber(CL->getLocStart()) << " returned to 
caller";
 range = CL->getSourceRange();
-  }
-  else if (const AllocaRegion* AR = dyn_cast(R)) {
+  } else if (const auto *AR = dyn_cast(R)) {
 const Expr *ARE = AR->getExpr();
 SourceLocation L = ARE->getLocStart();
 range = ARE->getSourceRange();
 os << "stack memory allocated by call to alloca() on line "
<< SM.getExpansionLineNumber(L);
-  }
-  else if (const BlockDataRegion *BR = dyn_cast(R)) {
+  } else if (const auto *BR = dyn_cast(R)) {
 const BlockDecl *BD = BR->getCodeRegion()->getDecl();
 SourceLocation L = BD->getLocStart();
 range = BD->getSourceRange();
 os << "stack-allocated block declared on line "
<< SM.getExpansionLineNumber(L);
-  }
-  else if (const VarRegion *VR = dyn_cast(R)) {
-os << "stack memory associated with local variable '"
-   << VR->getString() << '\'';
+  } else if (const auto *VR = dyn_cast(R)) {
+os << "stack memory associated with local variable '" << VR->getString()
+   << '\'';
 range = VR->getDecl()->getSourceRange();
-  }
-  else if (const CXXTempObjectRegion *TOR = dyn_cast(R)) {
+  } 

[PATCH] D40144: Implement `std::launder`

2017-11-20 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 123663.
mclow.lists added a comment.

Un-c++17'ed the internal function `__launder`


https://reviews.llvm.org/D40144

Files:
  include/__config
  include/new
  
test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
  test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
  test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -104,6 +104,7 @@
 	https://wg21.link/p0083r3;>p0083r3LWGSplicing Maps and SetsOulu
 	https://wg21.link/p0084r2;>p0084r2LWGEmplace Return TypeOuluComplete4.0
 	https://wg21.link/p0088r3;>p0088r3LWGVariant: a type-safe union for C++17OuluComplete4.0
+	https://wg21.link/p0137r1;>p0137r1CWGCore Issue 1776: Replacement of class objects containing reference membersOuluComplete6.0
 	https://wg21.link/p0163r0;>p0163r0LWGshared_ptr::weak_typeOuluComplete3.9
 	https://wg21.link/p0174r2;>p0174r2LWGDeprecating Vestigial Library Parts in C++17Oulu
 	https://wg21.link/p0175r1;>p0175r1LWGSynopses for the C libraryOulu
Index: test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexcept;
+// The program is ill-formed if T is a function type or cv void.
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+void foo() {}
+
+int main ()
+{
+void *p = nullptr;
+(void) std::launder((   void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((const  void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((  volatile void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((const volatile void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+
+(void) std::launder(foo);  // expected-error-re@new:* 1 {{static_assert failed{{.*}} "can't launder functions"}}
+}
Index: test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr int gi = 5;
+constexpr float gf = 8.f;
+
+int main() {
+	static_assert(std::launder() == , "" );
+	static_assert(std::launder() == , "" );
+
+  	const int *i = 
+  	const float *f = 
+static_assert(std::is_same::value, "");
+static_assert(std::is_same::value, "");
+
+	assert(std::launder(i) == i);
+	assert(std::launder(f) == f);
+}
Index: test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexcept;
+
+// 

[PATCH] D35894: [clangd] Code hover for Clangd

2017-11-20 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 123662.
Nebiroth marked 10 inline comments as done.
Nebiroth added a comment.

Removed all std::pair objects
Fixed and updated all tests
findHover doesn't call findDefinitions anymore
DeclarationLocationsFinder fills two Decl and MacroInfos vectors instead of 
giving out Location objects
Removed constructors for structs MarkedString and Hover
Moved code modifying SourceRange for hover into getHover()


https://reviews.llvm.org/D35894

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ClangdUnit.cpp
  clangd/ClangdUnit.h
  clangd/MyClass.cpp
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  clangd/impl.cpp
  test/clangd/hover.test
  test/clangd/initialize-params-invalid.test
  test/clangd/initialize-params.test

Index: test/clangd/initialize-params.test
===
--- test/clangd/initialize-params.test
+++ test/clangd/initialize-params.test
@@ -5,6 +5,7 @@
 Content-Length: 143
 
 {"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootUri":"file:///path/to/workspace","capabilities":{},"trace":"off"}}
+
 #  CHECK:  "id": 0,
 # CHECK-NEXT:  "jsonrpc": "2.0",
 # CHECK-NEXT:  "result": {
@@ -30,6 +31,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
Index: test/clangd/initialize-params-invalid.test
===
--- test/clangd/initialize-params-invalid.test
+++ test/clangd/initialize-params-invalid.test
@@ -30,6 +30,7 @@
 # CHECK-NEXT:  "clangd.applyFix"
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
+# CHECK-NEXT:	   "hoverProvider": true,
 # CHECK-NEXT:  "renameProvider": true,
 # CHECK-NEXT:  "signatureHelpProvider": {
 # CHECK-NEXT:"triggerCharacters": [
@@ -40,6 +41,7 @@
 # CHECK-NEXT:  "textDocumentSync": 1
 # CHECK-NEXT:}
 # CHECK-NEXT:  }
+
 Content-Length: 44
 
 {"jsonrpc":"2.0","id":3,"method":"shutdown"}
Index: test/clangd/hover.test
===
--- /dev/null
+++ test/clangd/hover.test
@@ -0,0 +1,52 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 407
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#define MACRO 1\nnamespace ns1 {\nint test = 5;\nstruct MyClass {\nint xasd;\nvoid anotherOperation() {\n}\nstatic int foo(MyClass*) {\nreturn 0;\n}\n\n};}\nint main() {\nint a;\na;\nint b = ns1::test;\nns1::MyClass* Params;\nParams->anotherOperation();\nMACRO;}\n"}}}
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":0,"character":12}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"#define MACRO 1"}],"range":{"end":{"character":15,"line":0},"start":{"character":8,"line":0
+
+Content-Length: 144
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":14,"character":1}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"int a"}],"range":{"end":{"character":5,"line":13},"start":{"character":0,"line":13
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":15,"character":15}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"int test = 5"}],"range":{"end":{"character":12,"line":2},"start":{"character":0,"line":2
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":16,"character":10}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In ns1"},{"language":"C++","value":"struct MyClass {"}],"range":{"end":{"character":16,"line":3},"start":{"character":0,"line":3
+
+Content-Length: 145
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/hover","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":13}}}
+# Go to local variable
+# CHECK: {"id":1,"jsonrpc":"2.0","result":{"contents":[{"language":"C++","value":"In 

[PATCH] D40144: Implement `std::launder`

2017-11-20 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: include/new:260
+static_assert (!is_function<_Tp>::value, "can't launder functions" );
+static_assert (!is_same_v>, "can't launder cv-void" 
);
+#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER

tcanens wrote:
> Technically, the attempt is to launder //pointers to// //cv// 
> `void`/functions. :)
> 
> Also, since `__launder` is non-C++17-specific, I guess it can't use `_t` and 
> `_v` after all... - and I suppose it'll also need to parens-protect the 
> `is_same` check for the fallback `static_assert` macro?
Oh, *bother* (and yes, you're correct)


https://reviews.llvm.org/D40144



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


[PATCH] D39947: [OpenMP] Stable sort Privates to remove non-deterministic ordering

2017-11-20 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.

Yes, LGTM.


Repository:
  rL LLVM

https://reviews.llvm.org/D39947



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


[PATCH] D39279: Stringizing raw string literals containing newline

2017-11-20 Thread Taewook Oh via Phabricator via cfe-commits
twoh updated this revision to Diff 123658.
twoh added a comment.

Addressing @vsapsai's comments. Thank you for the suggestion! Added test case 
actually finds an off-by-one error in the original patch. I improved the 
comments as well.


https://reviews.llvm.org/D39279

Files:
  include/clang/Lex/Lexer.h
  lib/Lex/Lexer.cpp
  test/Preprocessor/macro_raw_string.cpp
  unittests/Lex/LexerTest.cpp

Index: unittests/Lex/LexerTest.cpp
===
--- unittests/Lex/LexerTest.cpp
+++ unittests/Lex/LexerTest.cpp
@@ -37,7 +37,7 @@
   DiagID(new DiagnosticIDs()),
   Diags(DiagID, new DiagnosticOptions, new IgnoringDiagConsumer()),
   SourceMgr(Diags, FileMgr),
-  TargetOpts(new TargetOptions) 
+  TargetOpts(new TargetOptions)
   {
 TargetOpts->Triple = "x86_64-apple-darwin11.1.0";
 Target = TargetInfo::CreateTargetInfo(Diags, TargetOpts);
@@ -478,4 +478,42 @@
   EXPECT_TRUE(LexedTokens.empty());
 }
 
+TEST_F(LexerTest, StringizingRasString) {
+  // For "std::string Lexer::Stringify(StringRef Str, bool Charify)".
+  std::string String1 = R"(foo
+{"bar":[]}
+baz)";
+  // For "void Lexer::Stringify(SmallVectorImpl )".
+  SmallString<128> String2;
+  String2 += String1.c_str();
+
+  // Corner cases.
+  std::string String3 = R"(\
+\n
+\\n
+\\)";
+  SmallString<128> String4;
+  String4 += String3.c_str();
+  std::string String5 = R"(a\
+
+
+\\b)";
+  SmallString<128> String6;
+  String6 += String5.c_str();
+
+  String1 = Lexer::Stringify(StringRef(String1));
+  Lexer::Stringify(String2);
+  String3 = Lexer::Stringify(StringRef(String3));
+  Lexer::Stringify(String4);
+  String5 = Lexer::Stringify(StringRef(String5));
+  Lexer::Stringify(String6);
+
+  EXPECT_EQ(String1, R"(foo\n{\"bar\":[]}\nbaz)");
+  EXPECT_EQ(String2, R"(foo\n{\"bar\":[]}\nbaz)");
+  EXPECT_EQ(String3, R"(\\\n\\n\nn\n)");
+  EXPECT_EQ(String4, R"(\\\n\\n\nn\n)");
+  EXPECT_EQ(String5, R"(a\\\n\n\nb)");
+  EXPECT_EQ(String6, R"(a\\\n\n\nb)");
+}
+
 } // anonymous namespace
Index: test/Preprocessor/macro_raw_string.cpp
===
--- /dev/null
+++ test/Preprocessor/macro_raw_string.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -E -std=c++11 %s -o %t
+// RUN: %clang_cc1 %t
+
+#define FOO(str) foo(#str)
+
+extern void foo(const char *str);
+
+void bar() {
+  FOO(R"(foo
+bar)");
+}
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -209,29 +209,43 @@
   return L;
 }
 
-/// Stringify - Convert the specified string into a C string, with surrounding
-/// ""'s, and with escaped \ and " characters.
+/// StringifyImpl - Implementation of Stringify functions. Convert the
+/// specified string into a C string by i) escaping '\' and " characters and
+/// ii) replacing newline character(s) with "\n".
+template 
+void StringifyImpl(T& Str, char Quote) {
+  unsigned i = 0, e = Str.size();
+  while (i < e) {
+if (Str[i] == '\\' || Str[i] == Quote) {
+  Str.insert(Str.begin() + i, '\\');
+  i += 2;
+  ++e;
+} else if (Str[i] == '\n' || Str[i] == '\r') {
+  // Replace '\n', '\r', '\r\n', and '\n\r' to '\\' followed by 'n'.
+  unsigned Size = 1;
+  if ((i < e - 1) && (Str[i + 1] == '\n' || Str[i + 1] == '\r') &&
+  Str[i] != Str[i + 1])
+Size += 1;
+
+  Str.erase(Str.begin() + i, Str.begin() + i + Size);
+  Str.insert(Str.begin() + i, '\\');
+  Str.insert(Str.begin() + i + 1, 'n');
+  i += 2;
+  e += (2 - Size);
+} else
+  ++i;
+  }
+}
+
 std::string Lexer::Stringify(StringRef Str, bool Charify) {
   std::string Result = Str;
   char Quote = Charify ? '\'' : '"';
-  for (unsigned i = 0, e = Result.size(); i != e; ++i) {
-if (Result[i] == '\\' || Result[i] == Quote) {
-  Result.insert(Result.begin()+i, '\\');
-  ++i; ++e;
-}
-  }
+  StringifyImpl(Result, Quote);
   return Result;
 }
 
-/// Stringify - Convert the specified string into a C string by escaping '\'
-/// and " characters.  This does not add surrounding ""'s to the string.
 void Lexer::Stringify(SmallVectorImpl ) {
-  for (unsigned i = 0, e = Str.size(); i != e; ++i) {
-if (Str[i] == '\\' || Str[i] == '"') {
-  Str.insert(Str.begin()+i, '\\');
-  ++i; ++e;
-}
-  }
+  StringifyImpl(Str, '"');
 }
 
 //===--===//
@@ -367,7 +381,7 @@
 /// to point to a constant buffer with the data already in it (avoiding a
 /// copy).  The caller is not allowed to modify the returned buffer pointer
 /// if an internal buffer is returned.
-unsigned Lexer::getSpelling(const Token , const char *, 
+unsigned Lexer::getSpelling(const Token , const char *,
 const SourceManager ,
 const 

[PATCH] D35755: [Solaris] gcc toolchain handling revamp

2017-11-20 Thread Fedor Sergeev via Phabricator via cfe-commits
fedor.sergeev marked an inline comment as not done.
fedor.sergeev added a comment.

In https://reviews.llvm.org/D35755#930030, @ro wrote:

> What's the status here?  This patch is required for my WIP 
> sanitizers-on-Solaris work.


since @tstellar just resolved the only remaining question I will go change the 
questionable part to linux-only and then I consider this ready to go.
Then we just have to find somebody who is willing to press the green button...
Thanks for keeping this topic alive, I kinda stopped pinging it.


https://reviews.llvm.org/D35755



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 123654.
juliehockett added a comment.

Removed spurious semicolons


https://reviews.llvm.org/D40261

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {}
+/// void y(int val = 0) {}
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a 
declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {}
+void y(int val = 0) {}
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypeasStringstd::string Name
 Matches if the matched 
type is represented by the given string.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {}
+/// void y(int val = 0) {}
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {}
+void y(int val = 0) {}
+
+
+
 

[clang-tools-extra] r318702 - Revert 318668, which is associated with a broken patch

2017-11-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Nov 20 14:10:28 2017
New Revision: 318702

URL: http://llvm.org/viewvc/llvm-project?rev=318702=rev
Log:
Revert 318668, which is associated with a broken patch

Modified:
clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp

Modified: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp?rev=318702=318701=318702=diff
==
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp (original)
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-general.cpp Mon Nov 
20 14:10:28 2017
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding | 
FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s | FileCheck 
--strict-whitespace %s
 
 #pragma clang diagnostic push
 #pragma clang diagnostic pop

Modified: clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp?rev=318702=318701=318702=diff
==
--- clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp (original)
+++ clang-tools-extra/trunk/test/pp-trace/pp-trace-pragma-opencl.cpp Mon Nov 20 
14:10:28 2017
@@ -1,4 +1,4 @@
-// RUN: pp-trace -ignore FileChanged,MacroDefined %s -ffreestanding -x cl | 
FileCheck --strict-whitespace %s
+// RUN: pp-trace -ignore FileChanged,MacroDefined %s -x cl | FileCheck 
--strict-whitespace %s
 
 #pragma OPENCL EXTENSION all : disable
 #pragma OPENCL EXTENSION cl_khr_int64_base_atomics : disable


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


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In order to make this work with MinGW (more or less), I had to change the 
`_LIBCPP_MSVCRT` into `_LIBCPP_MSVCRT_LIKE` both in `include/__locale` and in 
`include/__config` (where `_LIBCPP_LOCALE__L_EXTENSIONS` is defined). Normal 
mingw that uses msvcrt.dll doesn't have per-thread locales so it won't really 
work in any case (but I think it does define some sort of dummy functions that 
at least will allow it to build). Nowadays, mingw can be built to target 
ucrtbase.dll as well though, and there it should be possible to make it work 
just like for MSVC although it might need some patches.




Comment at: include/__locale:72
+__status(_configthreadlocale(_ENABLE_PER_THREAD_LOCALE)),
+__locale_str{
+setlocale(LC_COLLATE, __l.__get_locale()),

This syntax only seems to work if the code using this is built in C++11 mode; 
this breaks building C++98 code.



Comment at: include/support/win32/locale_win32.h:57
+
+friend bool operator==(nullptr_t, const locale_t& __right) {
+return nullptr == __right.__locale;

In my testing, I had to change all these `nullptr_t` into `std::nullptr_t` in 
order to build it successfully.


https://reviews.llvm.org/D40181



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


[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Oh, I see, for some silly reason there are actually *three* -mfloat-abi 
options: hard, soft, and softfp.  hard means float instructions and a 
hard-float calling convention, soft means no floating-point and a soft-float 
convention, and softfp means float instructions and a soft-float convention.  
This is probably worth clarifying with a comment.




Comment at: lib/Driver/ToolChains/Arch/ARM.cpp:406
+const bool HasVFPv4  = (std::find(ItBegin, ItEnd, "+vfpv4") != ItEnd);
+const bool HasFParmv8  = (std::find(ItBegin, ItEnd, "+fp-armv8") != ItEnd);
+const bool HasFullFP16  = (std::find(ItBegin, ItEnd, "+fullfp16") != 
ItEnd);

I don't like explicitly enumerating the features like this; it'll mess up if 
there's ever a new feature which isn't explicitly enumerated here.  Can we just 
do `Features.push_back("-vfpv2")` and depend on that to implicitly disable all 
the other vfp features?


https://reviews.llvm.org/D40256



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


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

Looks OK to me.  I'll defer to gtbercea@ for the final stamp.




Comment at: test/Driver/openmp-offload-gpu.c:34
+/// Check cubin file generation and usage by nvlink when toolchain has 
BindArchAction
+// RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 
-fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s

Please split long RUN lines. here and below. 


https://reviews.llvm.org/D40250



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


[PATCH] D35470: [libcxx] Implement std::to_address for C++20

2017-11-20 Thread Glen Fernandes via Phabricator via cfe-commits
glenjofe added inline comments.



Comment at: test/std/utilities/memory/pointer.conversion/to_address.pass.cpp:119
+ASSERT_NOEXCEPT(std::to_address(p4));
+assert(std::to_address(p4) == );
+}

EricWF wrote:
> Shouldn't one of these tests hit a non-noexcept function?
Both overloads of to_address are unconditionally noexcept.


https://reviews.llvm.org/D35470



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


r318698 - Revert r318669/318694

2017-11-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Nov 20 13:46:29 2017
New Revision: 318698

URL: http://llvm.org/viewvc/llvm-project?rev=318698=rev
Log:
Revert r318669/318694

Broke some libclang tests, so reverting for now.

Removed:
cfe/trunk/test/Driver/Inputs/stdc-predef/
cfe/trunk/test/Driver/stdc-predef.c
cfe/trunk/test/Driver/stdc-predef.i
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Driver/Job.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.cpp
cfe/trunk/lib/Driver/ToolChains/Linux.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/Frontend/InitPreprocessor.cpp
cfe/trunk/test/Driver/crash-report-header.h
cfe/trunk/test/Driver/crash-report-spaces.c
cfe/trunk/test/Driver/crash-report.c
cfe/trunk/test/Driver/rewrite-map-in-diagnostics.c
cfe/trunk/test/Index/IBOutletCollection.m
cfe/trunk/test/Index/annotate-macro-args.m
cfe/trunk/test/Index/annotate-tokens-pp.c
cfe/trunk/test/Index/annotate-tokens.c
cfe/trunk/test/Index/c-index-getCursor-test.m
cfe/trunk/test/Index/get-cursor-macro-args.m
cfe/trunk/test/Index/get-cursor.cpp
cfe/trunk/test/Preprocessor/ignore-pragmas.c
cfe/trunk/unittests/Tooling/TestVisitor.h

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=318698=318697=318698=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Mon Nov 20 13:46:29 2017
@@ -769,8 +769,6 @@ def token_cache : Separate<["-"], "token
   HelpText<"Use specified token cache file">;
 def detailed_preprocessing_record : Flag<["-"], 
"detailed-preprocessing-record">,
   HelpText<"include a detailed record of preprocessing actions">;
-def fsystem_include_if_exists : Separate<["-"], "fsystem-include-if-exists">, 
MetaVarName<"">,
-  HelpText<"Include system file before parsing if file exists">;
 
 
//===--===//
 // OpenCL Options

Modified: cfe/trunk/include/clang/Lex/PreprocessorOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/PreprocessorOptions.h?rev=318698=318697=318698=diff
==
--- cfe/trunk/include/clang/Lex/PreprocessorOptions.h (original)
+++ cfe/trunk/include/clang/Lex/PreprocessorOptions.h Mon Nov 20 13:46:29 2017
@@ -60,9 +60,6 @@ public:
   /// \brief Headers that will be converted to chained PCHs in memory.
   std::vector ChainedIncludes;
 
-  /// \brief System Headers that are pre-included if they exist.
-  std::vector FSystemIncludeIfExists;
-
   /// \brief When true, disables most of the normal validation performed on
   /// precompiled headers.
   bool DisablePCHValidation;
@@ -193,7 +190,6 @@ public:
 DumpDeserializedPCHDecls = false;
 ImplicitPCHInclude.clear();
 ImplicitPTHInclude.clear();
-FSystemIncludeIfExists.clear();
 TokenCache.clear();
 SingleFileParseMode = false;
 LexEditorPlaceholders = true;

Modified: cfe/trunk/lib/Driver/Job.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Job.cpp?rev=318698=318697=318698=diff
==
--- cfe/trunk/lib/Driver/Job.cpp (original)
+++ cfe/trunk/lib/Driver/Job.cpp Mon Nov 20 13:46:29 2017
@@ -64,7 +64,7 @@ static bool skipArgs(const char *Flag, b
 .Cases("-internal-externc-isystem", "-iprefix", true)
 .Cases("-iwithprefixbefore", "-isystem", "-iquote", true)
 .Cases("-isysroot", "-I", "-F", "-resource-dir", true)
-.Cases("-iframework", "-include-pch", "-fsystem-include-if-exists", true)
+.Cases("-iframework", "-include-pch", true)
 .Default(false);
   if (IsInclude)
 return HaveCrashVFS ? false : true;

Modified: cfe/trunk/lib/Driver/ToolChains/Linux.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Linux.cpp?rev=318698=318697=318698=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Linux.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Linux.cpp Mon Nov 20 13:46:29 2017
@@ -710,8 +710,6 @@ void Linux::AddClangSystemIncludeArgs(co
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/include");
 
   addExternCSystemInclude(DriverArgs, CC1Args, SysRoot + "/usr/include");
-
-  AddGnuIncludeArgs(DriverArgs, CC1Args);
 }
 
 static std::string DetectLibcxxIncludePath(StringRef base) {
@@ -750,17 +748,6 @@ std::string Linux::findLibCxxIncludePath
   return "";
 }
 
-void Linux::AddGnuIncludeArgs(const llvm::opt::ArgList ,
-  llvm::opt::ArgStringList ) const {
-  if (!DriverArgs.hasArg(options::OPT_ffreestanding)) {
-// For gcc compatibility, 

[PATCH] D38445: [x86][inline-asm] allow recognition of MPX regs inside ms inline-asm blob

2017-11-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Looks good, thanks for the heads up


Repository:
  rL LLVM

https://reviews.llvm.org/D38445



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


[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld updated this revision to Diff 123649.
Hahnfeld marked 13 inline comments as done.
Hahnfeld added a comment.

Address reviewers' comments.


https://reviews.llvm.org/D40250

Files:
  include/clang/Driver/ToolChain.h
  lib/Driver/ToolChain.cpp
  lib/Driver/ToolChains/Clang.cpp
  lib/Driver/ToolChains/Cuda.cpp
  lib/Driver/ToolChains/Cuda.h
  test/Driver/openmp-offload-gpu.c

Index: test/Driver/openmp-offload-gpu.c
===
--- test/Driver/openmp-offload-gpu.c
+++ test/Driver/openmp-offload-gpu.c
@@ -28,43 +28,61 @@
 /// ###
 
 /// Check cubin file generation and usage by nvlink
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-CUBIN %s
+// RUN:   %clang -### -no-canonical-prefixes -target powerpc64le-unknown-linux-gnu -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
+/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
+// RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN-NVLINK %s
+
+// CHK-CUBIN-NVLINK: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
+// CHK-CUBIN-NVLINK-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
+// CHK-CUBIN-NVLINK-NEXT: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
+
+/// ###
 
-// CHK-CUBIN: clang{{.*}}" "-o" "{{.*}}.s"
-// CHK-CUBIN-NEXT: ptxas{{.*}}" "--output-file" {{.*}}.cubin" {{.*}}.s"
-// CHK-CUBIN-NEXT: nvlink" {{.*}}.cubin"
+/// Check unbundlink of assembly file, cubin file generation and usage by nvlink
+// RUN:   touch %t.s
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %t.s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK %s
 
+/// Use DAG to ensure that assembly file has been unbundled.
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX:.*\.s]]"
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=s" {{.*}}"-outputs={{.*}}[[PTX]]{{.*}} "-unbundle"
+// CHK-UNBUNDLING-PTXAS-CUBIN-NVLINK: nvlink{{.*}}" {{.*}}"[[CUBIN]]"
 
 /// ###
 
-/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
-// RUN:   %clang -### -no-canonical-prefixes -target x86_64-apple-darwin17.0.0 -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %s 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-CUBIN-DARWIN %s
+/// Check cubin file generation and bundling
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %s -c 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-PTXAS-CUBIN-BUNDLING %s
 
-// CHK-CUBIN-DARWIN: clang{{.*}}" "-o" "{{.*}}.s"
-// CHK-CUBIN-DARWIN-NEXT: ptxas{{.*}}" "--output-file" {{.*}}.cubin" {{.*}}.s"
-// CHK-CUBIN-DARWIN-NEXT: nvlink" {{.*}}.cubin"
+// CHK-PTXAS-CUBIN-BUNDLING: clang{{.*}}" "-o" "[[PTX:.*\.s]]"
+// CHK-PTXAS-CUBIN-BUNDLING-NEXT: ptxas{{.*}}" "--output-file" "[[CUBIN:.*\.cubin]]" {{.*}}"[[PTX]]"
+// CHK-PTXAS-CUBIN-BUNDLING: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-inputs={{.*}}[[CUBIN]]
 
 /// ###
 
-/// Check cubin file generation and usage by nvlink
-// RUN:   touch %t1.o
-// RUN:   touch %t2.o
-// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
-// RUN:   | FileCheck -check-prefix=CHK-TWOCUBIN %s
+/// Check cubin file unbundling and usage by nvlink
+// RUN:   touch %t.o
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda -save-temps %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-CUBIN-UNBUNDLING-NVLINK %s
 
-// CHK-TWOCUBIN: nvlink{{.*}}openmp-offload-{{.*}}.cubin" "{{.*}}openmp-offload-{{.*}}.cubin"
+/// Use DAG to ensure that cubin file has been unbundled.
+// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: nvlink{{.*}}" {{.*}}"[[CUBIN:.*\.cubin]]"
+// CHK-CUBIN-UNBUNDLING-NVLINK-DAG: clang-offload-bundler{{.*}}" "-type=o" {{.*}}"-outputs={{.*}}[[CUBIN]]{{.*}} "-unbundle"
 
 /// ###
 
-/// Check cubin file generation and usage by nvlink when toolchain has BindArchAction
+/// Check cubin file generation and usage by nvlink
 // RUN:   touch %t1.o
 // RUN:   touch %t2.o
+// RUN:   %clang -### -no-canonical-prefixes -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda %t1.o %t2.o 2>&1 \
+// RUN:   | FileCheck 

[PATCH] D40250: [OpenMP] Consistently use cubin extension for nvlink

2017-11-20 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:5341-5344
+if (const auto *OA = dyn_cast(JA.getInputs()[I])) {
+  OA->doOnEachDependence(
+  [&](Action *, const ToolChain *TC, const char *) { CurTC = TC; });
+}

tra wrote:
> Can we ever have more than one dependence? If not, perhaps add an assert.
> Otherwise, can dependencies have different toolchains? 
> If so, which one do we really want?
> 
> 
> 
No, there should only be one for inputs to the bundler. I've added the assert 
and all tests pass.



Comment at: lib/Driver/ToolChains/Cuda.h:144
 
+  virtual std::string getInputFilename(const InputInfo ) const override;
+

tra wrote:
> `virtual` is redundant here.
(I've also changed this for `getAuxTriple` above.)


https://reviews.llvm.org/D40250



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


r318697 - Resubmit "Refactor debuginfo-tests" again.

2017-11-20 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Mon Nov 20 13:41:36 2017
New Revision: 318697

URL: http://llvm.org/viewvc/llvm-project?rev=318697=rev
Log:
Resubmit "Refactor debuginfo-tests" again.

This was reverted due to the tests being run twice on some
build bots.  Each run had a slightly different configuration
due to the way in which it was being invoked.  This fixes
the problem (albeit in a somewhat hacky way).  Hopefully in
the future we can get rid of the workflow of running
debuginfo-tests as part of clang, and then this hack can
go away.

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

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=318697=318696=318697=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Mon Nov 20 13:41:36 2017
@@ -88,6 +88,14 @@ set(CLANG_TEST_PARAMS
   clang_site_config=${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
   )
 
+if (EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/debuginfo-tests/CMakeLists.txt")
+  # This is a hack to keep existing build build infrastructure working while we
+  # can migrate to the new standard workflow of checking out debuginfo-tests 
into
+  # llvm/projects or using it in a mono-repo
+  set(DEBUGINFO_TESTS_EXCLUDE_FROM_ALL ON)
+  add_subdirectory(debuginfo-tests)
+endif()
+
 if( NOT CLANG_BUILT_STANDALONE )
   list(APPEND CLANG_TEST_DEPS
 llvm-config

Modified: cfe/trunk/test/lit.cfg.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/lit.cfg.py?rev=318697=318696=318697=diff
==
--- cfe/trunk/test/lit.cfg.py (original)
+++ cfe/trunk/test/lit.cfg.py Mon Nov 20 13:41:36 2017
@@ -58,8 +58,6 @@ tool_dirs = [config.clang_tools_dir, con
 
 tools = [
 'c-index-test', 'clang-check', 'clang-diff', 'clang-format', 'opt',
-ToolSubst('%test_debuginfo', command=os.path.join(
-config.llvm_src_root, 'utils', 'test_debuginfo.pl')),
 ToolSubst('%clang_func_map', command=FindTool(
 'clang-func-mapping'), unresolved='ignore'),
 ]


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


[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-20 Thread Alex Bradbury via Phabricator via cfe-commits
asb added subscribers: llvm-commits, asb.
asb added a comment.

It would have been much cleaner if it worked as @efriedma suggests and 
-mfloat-abi was only concerned with the ABI (as its name would suggest), but 
sadly the -mfloat-abi=soft option seems to be defined in GCC to control more 
than just the ABI.

Adding llvm-commits to the subscriber list.


https://reviews.llvm.org/D40256



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


[PATCH] D40267: WG14 DR496

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.

This DR was discussed at the WG14 meeting in Albuquerque and the outcome was 
that member-designator wording could safely be replaced by "subobject", which 
will be the Proposed Technical Corrigendum coming out of that meeting. This 
patch removes the extension warning we were issuing in these situations.


https://reviews.llvm.org/D40267

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaExpr.cpp
  test/CXX/drs/dr4xx.cpp


Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -593,10 +593,10 @@
 U<__builtin_offsetof(A, n)>::type a;
 U<__builtin_offsetof(T, n)>::type b; // expected-error +{{}} 
expected-warning 0+{{}}
 // as an extension, we allow the member-designator to include array indices
-g(__builtin_offsetof(A, a[0])).h(); // expected-error {{extension}}
-g(__builtin_offsetof(A, a[N])).h(); // expected-error {{extension}}
-U<__builtin_offsetof(A, a[0])>::type c; // expected-error {{extension}}
-U<__builtin_offsetof(A, a[N])>::type d; // expected-error {{extension}} 
expected-error +{{}} expected-warning 0+{{}}
+g(__builtin_offsetof(A, a[0])).h();
+g(__builtin_offsetof(A, a[N])).h();
+U<__builtin_offsetof(A, a[0])>::type c;
+U<__builtin_offsetof(A, a[N])>::type d; // expected-error +{{}} 
expected-warning 0+{{}}
   }
 }
 
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -12588,15 +12588,7 @@
   && RequireCompleteType(BuiltinLoc, ArgTy,
  diag::err_offsetof_incomplete_type, TypeRange))
 return ExprError();
-  
-  // offsetof with non-identifier designators (e.g. "offsetof(x, a.b[c])") are 
a
-  // GCC extension, diagnose them.
-  // FIXME: This diagnostic isn't actually visible because the location is in
-  // a system header!
-  if (Components.size() != 1)
-Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator)
-  << SourceRange(Components[1].LocStart, Components.back().LocEnd);
-  
+
   bool DidWarnAboutNonPOD = false;
   QualType CurrentType = ArgTy;
   SmallVector Comps;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5546,9 +5546,6 @@
 def err_offsetof_record_type : Error<
   "offsetof requires struct, union, or class type, %0 invalid">;
 def err_offsetof_array_type : Error<"offsetof requires array type, %0 
invalid">;
-def ext_offsetof_extended_field_designator : Extension<
-  "using extended field designator is an extension">,
-  InGroup>;
 def ext_offsetof_non_pod_type : ExtWarn<"offset of on non-POD type %0">,
   InGroup;
 def ext_offsetof_non_standardlayout_type : ExtWarn<


Index: test/CXX/drs/dr4xx.cpp
===
--- test/CXX/drs/dr4xx.cpp
+++ test/CXX/drs/dr4xx.cpp
@@ -593,10 +593,10 @@
 U<__builtin_offsetof(A, n)>::type a;
 U<__builtin_offsetof(T, n)>::type b; // expected-error +{{}} expected-warning 0+{{}}
 // as an extension, we allow the member-designator to include array indices
-g(__builtin_offsetof(A, a[0])).h(); // expected-error {{extension}}
-g(__builtin_offsetof(A, a[N])).h(); // expected-error {{extension}}
-U<__builtin_offsetof(A, a[0])>::type c; // expected-error {{extension}}
-U<__builtin_offsetof(A, a[N])>::type d; // expected-error {{extension}} expected-error +{{}} expected-warning 0+{{}}
+g(__builtin_offsetof(A, a[0])).h();
+g(__builtin_offsetof(A, a[N])).h();
+U<__builtin_offsetof(A, a[0])>::type c;
+U<__builtin_offsetof(A, a[N])>::type d; // expected-error +{{}} expected-warning 0+{{}}
   }
 }
 
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -12588,15 +12588,7 @@
   && RequireCompleteType(BuiltinLoc, ArgTy,
  diag::err_offsetof_incomplete_type, TypeRange))
 return ExprError();
-  
-  // offsetof with non-identifier designators (e.g. "offsetof(x, a.b[c])") are a
-  // GCC extension, diagnose them.
-  // FIXME: This diagnostic isn't actually visible because the location is in
-  // a system header!
-  if (Components.size() != 1)
-Diag(BuiltinLoc, diag::ext_offsetof_extended_field_designator)
-  << SourceRange(Components[1].LocStart, Components.back().LocEnd);
-  
+
   bool DidWarnAboutNonPOD = false;
   QualType CurrentType = ArgTy;
   SmallVector Comps;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ 

[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from a minor nit with the comments leading to the public docs, LGTM!




Comment at: include/clang/ASTMatchers/ASTMatchers.h:5825-5826
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode

Remove the spurious semicolons (and regen the HTML docs).


https://reviews.llvm.org/D40261



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


[PATCH] D40144: Implement `std::launder`

2017-11-20 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: include/new:260
+static_assert (!is_function<_Tp>::value, "can't launder functions" );
+static_assert (!is_same_v>, "can't launder cv-void" 
);
+#ifdef _LIBCPP_COMPILER_HAS_BUILTIN_LAUNDER

Technically, the attempt is to launder //pointers to// //cv// `void`/functions. 
:)

Also, since `__launder` is non-C++17-specific, I guess it can't use `_t` and 
`_v` after all... - and I suppose it'll also need to parens-protect the 
`is_same` check for the fallback `static_assert` macro?


https://reviews.llvm.org/D40144



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett updated this revision to Diff 123646.
juliehockett added a comment.

Updated Registry.cpp to include new matcher.


https://reviews.llvm.org/D40261

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a 
declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypeasStringstd::string Name
 Matches if the matched 
type is represented by the given string.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -248,6 +248,7 @@
   REGISTER_MATCHER(hasDeclaration);
   REGISTER_MATCHER(hasDeclContext);
   REGISTER_MATCHER(hasDeducedType);
+  REGISTER_MATCHER(hasDefaultArgument);
   REGISTER_MATCHER(hasDescendant);
   REGISTER_MATCHER(hasDestinationType);
   REGISTER_MATCHER(hasDynamicExceptionSpec);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+
+
+
 

[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-20 Thread Renato Golin via Phabricator via cfe-commits
rengolin added a comment.

Wasn't that the mess about -mfpu=softfp?


https://reviews.llvm.org/D40256



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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Volodymyr Sapsai via cfe-commits
On Nov 20, 2017, at 11:32, Reimar Döffinger  wrote:
> 
> On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote:
>>> catch (...)
>>> {
>>> +if (__n > 0)
>>> +*__s = char_type();
>>> this->__set_badbit_and_consider_rethrow();
>>> }
>> 
>> or maybe something else?
> 
> That one (note that the __set_badbit_and_consider_rethrow
> will never re-throw in this case).

But by #define _LIBCPP_NO_EXCEPTIONS 1 you exclude this block at preprocessing 
step

>  #ifndef _LIBCPP_NO_EXCEPTIONS
>  }
>  catch (...)
>  {
> +if (__n > 0)
> +*__s = char_type();
>  this->__set_badbit_and_consider_rethrow();
>  }
>  #endif  // _LIBCPP_NO_EXCEPTIONS

And looks like getline_pointer_size_exception.pass.cpp doesn’t execute this 
code.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r318694 - Include test files for rL318668

2017-11-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Mon Nov 20 13:15:01 2017
New Revision: 318694

URL: http://llvm.org/viewvc/llvm-project?rev=318694=rev
Log:
Include test files for  rL318668

Forgotten when doing my SVN commit.

Added:
cfe/trunk/test/Driver/Inputs/stdc-predef/
cfe/trunk/test/Driver/Inputs/stdc-predef/usr/
cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/
cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h   (with 
props)
cfe/trunk/test/Driver/stdc-predef.c   (with props)
cfe/trunk/test/Driver/stdc-predef.i

Added: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h?rev=318694=auto
==
--- cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h (added)
+++ cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h Mon Nov 
20 13:15:01 2017
@@ -0,0 +1,12 @@
+#ifndef_STDC_PREDEF_H
+#define_STDC_PREDEF_H  1
+
+#define DUMMY_STDC_PREDEF 1
+
+#endif
+#ifndef_STDC_PREDEF_H
+#define_STDC_PREDEF_H  1
+
+#define DUMMY_STDC_PREDEF 1
+
+#endif

Propchange: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
--
svn:eol-style = native

Propchange: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/Driver/Inputs/stdc-predef/usr/include/stdc-predef.h
--
svn:mime-type = text/plain

Added: cfe/trunk/test/Driver/stdc-predef.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stdc-predef.c?rev=318694=auto
==
--- cfe/trunk/test/Driver/stdc-predef.c (added)
+++ cfe/trunk/test/Driver/stdc-predef.c Mon Nov 20 13:15:01 2017
@@ -0,0 +1,25 @@
+// Test that clang preincludes stdc-predef.h, if the include file is available
+//
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck -check-prefix CHECK-PREDEF %s
+// RUN: %clang %s -### -c -ffreestanding 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+// RUN: %clang %s -c -E 2>&1 \
+// RUN: --sysroot=%S/Inputs/basic_linux_tree \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+// RUN: %clang -c %s -Xclang -verify -DCHECK_DUMMY=1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef
+// expected-no-diagnostics
+// RUN: %clang -x cpp-output %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+
+// CHECK-PREDEF: "-fsystem-include-if-exists" "stdc-predef.h"
+int i;
+#if CHECK_DUMMY
+#if !DUMMY_STDC_PREDEF 
+  #error "Expected macro symbol DUMMY_STDC_PREDEF is not defined."
+#endif
+#endif

Propchange: cfe/trunk/test/Driver/stdc-predef.c
--
svn:eol-style = native

Propchange: cfe/trunk/test/Driver/stdc-predef.c
--
svn:keywords = Author Date Id Rev URL

Propchange: cfe/trunk/test/Driver/stdc-predef.c
--
svn:mime-type = text/plain

Added: cfe/trunk/test/Driver/stdc-predef.i
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/stdc-predef.i?rev=318694=auto
==
--- cfe/trunk/test/Driver/stdc-predef.i (added)
+++ cfe/trunk/test/Driver/stdc-predef.i Mon Nov 20 13:15:01 2017
@@ -0,0 +1,16 @@
+// The automatic preinclude of stdc-predef.h should not occur if
+// the source filename indicates a preprocessed file.
+//
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+
+int i;
+// The automatic preinclude of stdc-predef.h should not occur if
+// the source filename indicates a preprocessed file.
+//
+// RUN: %clang %s -### -c 2>&1 \
+// RUN: --sysroot=%S/Inputs/stdc-predef \
+// RUN: | FileCheck --implicit-check-not "stdc-predef.h" %s
+
+int i;


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


[PATCH] D40144: Implement `std::launder`

2017-11-20 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists updated this revision to Diff 123644.
mclow.lists added a comment.

Made an internal function `__launder` which is not c++17 specific.
Fixed some wording for the standard asserts.


https://reviews.llvm.org/D40144

Files:
  include/__config
  include/new
  
test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
  test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
  test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
  www/cxx1z_status.html

Index: www/cxx1z_status.html
===
--- www/cxx1z_status.html
+++ www/cxx1z_status.html
@@ -104,6 +104,7 @@
 	https://wg21.link/p0083r3;>p0083r3LWGSplicing Maps and SetsOulu
 	https://wg21.link/p0084r2;>p0084r2LWGEmplace Return TypeOuluComplete4.0
 	https://wg21.link/p0088r3;>p0088r3LWGVariant: a type-safe union for C++17OuluComplete4.0
+	https://wg21.link/p0137r1;>p0137r1CWGCore Issue 1776: Replacement of class objects containing reference membersOuluComplete6.0
 	https://wg21.link/p0163r0;>p0163r0LWGshared_ptr::weak_typeOuluComplete3.9
 	https://wg21.link/p0174r2;>p0174r2LWGDeprecating Vestigial Library Parts in C++17Oulu
 	https://wg21.link/p0175r1;>p0175r1LWGSynopses for the C libraryOulu
Index: test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.types.fail.cpp
@@ -0,0 +1,34 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexcept;
+// The program is ill-formed if T is a function type or cv void.
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+void foo() {}
+
+int main ()
+{
+void *p = nullptr;
+(void) std::launder((   void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((const  void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((  volatile void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+(void) std::launder((const volatile void *) nullptr);  // expected-error-re@new:* {{static_assert failed{{.*}} "can't launder cv-void"}}
+
+(void) std::launder(foo);  // expected-error-re@new:* 1 {{static_assert failed{{.*}} "can't launder functions"}}
+}
Index: test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.pass.cpp
@@ -0,0 +1,35 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// 
+
+// template  constexpr T* launder(T* p) noexcept;
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+#include 
+#include 
+
+#include "test_macros.h"
+
+constexpr int gi = 5;
+constexpr float gf = 8.f;
+
+int main() {
+	static_assert(std::launder() == , "" );
+	static_assert(std::launder() == , "" );
+
+  	const int *i = 
+  	const float *f = 
+static_assert(std::is_same::value, "");
+static_assert(std::is_same::value, "");
+
+	assert(std::launder(i) == i);
+	assert(std::launder(f) == f);
+}
Index: test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
===
--- test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
+++ test/std/language.support/support.dynamic/ptr.launder/launder.nodiscard.fail.cpp
@@ -0,0 +1,27 @@
+// -*- C++ -*-
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+

[PATCH] D40256: [ARM] disable FPU features when using soft floating point.

2017-11-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

-mfpu controls what floating-point/vector instructions the compiler generates.  
-mfloat-abi controls whether floating-point arguments to functions are passed 
in floating-point registers.  These are completely independent, and we need to 
support using both of them together to generate NEON code with a soft-float 
ABI.  (Android is built like this.)


https://reviews.llvm.org/D40256



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


[PATCH] D40257: [CMake] Use LIST_SEPARATOR rather than escaping in ExternalProject_Add

2017-11-20 Thread Petr Hosek via Phabricator via cfe-commits
phosek updated this revision to Diff 123640.

Repository:
  rL LLVM

https://reviews.llvm.org/D40257

Files:
  CMakeLists.txt


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -653,7 +653,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "\;" value "${${variableName}}")
+  string(REPLACE ";" "," value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value ${${variableName}})
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target


Index: CMakeLists.txt
===
--- CMakeLists.txt
+++ CMakeLists.txt
@@ -653,7 +653,7 @@
   foreach(variableName ${variableNames})
 if(variableName MATCHES "^BOOTSTRAP_")
   string(SUBSTRING ${variableName} 10 -1 varName)
-  string(REPLACE ";" "\;" value "${${variableName}}")
+  string(REPLACE ";" "," value "${${variableName}}")
   list(APPEND PASSTHROUGH_VARIABLES
 -D${varName}=${value})
 endif()
@@ -669,7 +669,7 @@
   if("${${variableName}}" STREQUAL "")
 set(value "")
   else()
-string(REPLACE ";" "\;" value ${${variableName}})
+string(REPLACE ";" "," value ${${variableName}})
   endif()
   list(APPEND PASSTHROUGH_VARIABLES
 -D${variableName}=${value})
@@ -697,6 +697,7 @@
 USES_TERMINAL_CONFIGURE 1
 USES_TERMINAL_BUILD 1
 USES_TERMINAL_INSTALL 1
+LIST_SEPARATOR ,
 )
 
   # exclude really-install from main target
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40242: Do not perform the analysis based warning if all warnings are ignored

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

You should add a test case that demonstrates code which would otherwise trigger 
an analysis-based warning but doesn't due to disabling all warnings.


https://reviews.llvm.org/D40242



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

You should also update lib\ASTMatchers\Dynamic\Registry.cpp to have the new 
matcher (be sure to keep the new matcher alphabetized as well).


https://reviews.llvm.org/D40261



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


[PATCH] D29930: Add `__reference_binds_to_temporary` trait for checking safe reference initialization.

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@rsmith Ping.


https://reviews.llvm.org/D29930



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


[libcxx] r318690 - Fix std::string::data() symbol during library build.

2017-11-20 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Mon Nov 20 12:23:27 2017
New Revision: 318690

URL: http://llvm.org/viewvc/llvm-project?rev=318690=rev
Log:
Fix std::string::data() symbol during library build.

The non-const data() member of std::string is only exposed
in C++17 and beyond. However std::string is externally instantiated
and so the member function needs to be exposed to be externally instantiated.

On Linux and OS X this shouldn't cause a problem, because
_LIBCPP_INLINE_VISIBILITY ensures the symbol is always inlined.

However on Windows, the symbol gets marked dllimport, but
there is no definition to import, causing link errors.

Modified:
libcxx/trunk/include/string

Modified: libcxx/trunk/include/string
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/string?rev=318690=318689=318690=diff
==
--- libcxx/trunk/include/string (original)
+++ libcxx/trunk/include/string Mon Nov 20 12:23:27 2017
@@ -1128,7 +1128,7 @@ public:
 const value_type* c_str() const _NOEXCEPT {return data();}
 _LIBCPP_INLINE_VISIBILITY
 const value_type* data() const _NOEXCEPT  {return 
_VSTD::__to_raw_pointer(__get_pointer());}
-#if _LIBCPP_STD_VER > 14
+#if _LIBCPP_STD_VER > 14 || defined(_LIBCPP_BUILDING_LIBRARY)
 _LIBCPP_INLINE_VISIBILITY
 value_type* data() _NOEXCEPT  {return 
_VSTD::__to_raw_pointer(__get_pointer());}
 #endif


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


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-20 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D40181#930602, @EricWF wrote:

> This LGTM. I would love if another party interested in Windows could review 
> it though.


I can test this in a MinGW context and see if what it uses happens to be 
available there or not.


https://reviews.llvm.org/D40181



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


[PATCH] D40259: [libcxx] LWG2993: reference_wrapper conversion from T&

2017-11-20 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: include/__functional_base:377
+inline _LIBCPP_INLINE_VISIBILITY
+_Tp& __lvref_bind(_Tp& r) _NOEXCEPT { return r; }
+

I'd make these member functions of a class template, to avoid having to reason 
about partial ordering in overload resolution.


https://reviews.llvm.org/D40259



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


[PATCH] D40181: [libcxx] Allow to set locale on Windows.

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

This LGTM. I would love if another party interested in Windows could review it 
though.


https://reviews.llvm.org/D40181



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


[PATCH] D40261: Add default argument AST matcher

2017-11-20 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett created this revision.
Herald added a subscriber: klimek.

Adds AST matcher for declarations with default arguments.


https://reviews.llvm.org/D40261

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a 
declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypeasStringstd::string Name
 Matches if the matched 
type is represented by the given string.
 


Index: unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
+++ unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
@@ -1991,5 +1991,12 @@
   namedDecl(hasExternalFormalLinkage(;
 }
 
+TEST(HasDefaultArgument, Basic) {
+  EXPECT_TRUE(matches("void x(int val = 0) {};", 
+  parmVarDecl(hasDefaultArgument(;
+  EXPECT_TRUE(notMatches("void x(int val) {};",
+  parmVarDecl(hasDefaultArgument(;
+}
+
 } // namespace ast_matchers
 } // namespace clang
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -5818,6 +5818,17 @@
   return Node.hasExternalFormalLinkage();
 }
 
+/// \brief Matches a declaration that has default arguments.
+///
+/// Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+/// \code
+/// void x(int val) {};
+/// void y(int val = 0) {};
+/// \endcode
+AST_MATCHER(ParmVarDecl, hasDefaultArgument) { 
+  return Node.hasDefaultArg(); 
+}
+
 } // namespace ast_matchers
 } // namespace clang
 
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -3183,6 +3183,15 @@
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1ParmVarDecl.html;>ParmVarDeclhasDefaultArgument
+Matches a declaration that has default arguments.
+
+Example matches y (matcher = parmVarDecl(hasDefaultArgument()))
+void x(int val) {};
+void y(int val = 0) {};
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualTypeasStringstd::string Name
 Matches if the matched type is represented by the given string.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35470: [libcxx] Implement std::to_address for C++20

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: test/std/utilities/memory/pointer.conversion/to_address.pass.cpp:119
+ASSERT_NOEXCEPT(std::to_address(p4));
+assert(std::to_address(p4) == );
+}

Shouldn't one of these tests hit a non-noexcept function?


https://reviews.llvm.org/D35470



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


[PATCH] D40259: [libcxx] LWG2993: reference_wrapper conversion from T&

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Also, you're lacking tests for `noexcept` and the deduction guide.


https://reviews.llvm.org/D40259



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


[PATCH] D40259: [libcxx] LWG2993: reference_wrapper conversion from T&

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

I would much rather take this change in all dialects except for C++03.




Comment at: include/__functional_base:398
+!is_same<__uncvref_t<_Up>, reference_wrapper>::value
+>, class = typename __void_t<
+decltype(_VSTD::__lvref_bind<_Tp>(_VSTD::declval<_Up>()))

The `__void_t` isn't necessary here. Plus I think we can be clever and write 
this condition as:

```
bool _IsNoexcept = noexcept()
```

And then we can re-use `_Noexcept` to make the function conditionally 
`noexcept` instead of duplicating the expression.


https://reviews.llvm.org/D40259



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


Re: [PATCH] Ensure std::getline always 0-terminates string.

2017-11-20 Thread Reimar Döffinger via cfe-commits
On Mon, Nov 20, 2017 at 11:02:13AM -0800, Volodymyr Sapsai wrote:
> >  catch (...)
> >  {
> > +if (__n > 0)
> > +*__s = char_type();
> >  this->__set_badbit_and_consider_rethrow();
> >  }
> 
> or maybe something else?

That one (note that the __set_badbit_and_consider_rethrow
will never re-throw in this case).
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40218: [Clang] Add __builtin_launder

2017-11-20 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 123627.
EricWF added a comment.

- Improve quality of tests.
- Format code.


https://reviews.llvm.org/D40218

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGBuiltin.cpp
  lib/Sema/SemaChecking.cpp
  test/CodeGen/builtins.c
  test/Preprocessor/feature_tests.c
  test/Sema/builtins.c
  test/SemaCXX/builtins.cpp

Index: test/SemaCXX/builtins.cpp
===
--- test/SemaCXX/builtins.cpp
+++ test/SemaCXX/builtins.cpp
@@ -53,3 +53,52 @@
 void synchronize_args() {
   __sync_synchronize(0); // expected-error {{too many arguments}}
 }
+
+namespace test_launder {
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip, const float *,
+  double *__restrict dp) {
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder'}}
+#define TEST_TYPE(Ptr, Type) \
+  static_assert(__is_same(decltype(__builtin_launder(Ptr)), Type), "expected same type")
+  TEST_TYPE(p, char*);
+  TEST_TYPE(vp, void*);
+  TEST_TYPE(ip, const volatile int*);
+  TEST_TYPE(fp, const float*);
+  TEST_TYPE(dp, double *__restrict);
+#undef TEST_TYPE
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-error {{cannot initialize a variable of type 'int *' with an rvalue of type 'const volatile int *'}}
+  const float* fd = __builtin_launder(fp);
+}
+
+template 
+constexpr Tp *test_constexpr_launder(Tp *tp) {
+  return __builtin_launder(tp);
+}
+constexpr int const_int = 42;
+constexpr int const_int2 = 101;
+constexpr const int *const_ptr = test_constexpr_launder(_int);
+static_assert(_int == const_ptr, "");
+static_assert(const_ptr != test_constexpr_launder(_int2), "");
+
+void test_non_constexpr() {
+  constexpr int i = 42;// expected-note {{declared here}}
+  constexpr const int *ip = __builtin_launder(); // expected-error {{constexpr variable 'ip' must be initialized by a constant expression}}
+  // expected-note@-1 {{pointer to 'i' is not a constant expression}}
+}
+
+constexpr bool test_in_constexpr(const int ) {
+  return (__builtin_launder() == );
+}
+static_assert(test_in_constexpr(const_int), "");
+void f() {
+  constexpr int i = 42;
+  // FIXME: Should this work? Since `` doesn't.
+  static_assert(test_in_constexpr(i), "");
+}
+
+} // end namespace test_launder
Index: test/Sema/builtins.c
===
--- test/Sema/builtins.c
+++ test/Sema/builtins.c
@@ -248,3 +248,15 @@
 
 return buf;
 }
+
+void test_builtin_launder(char *p, void *vp, const volatile int *ip, float *restrict fp) {
+  __builtin_launder(); // expected-error {{too few arguments to function call, expected 1, have 0}}
+  __builtin_launder(p, p); // expected-error {{too many arguments to function call, expected 1, have 2}}
+  int x;
+  __builtin_launder(x); // expected-error {{non-pointer argument to '__builtin_launder'}}
+  char *d = __builtin_launder(p);
+  void *vd = __builtin_launder(vp);
+  const volatile int *id = __builtin_launder(ip);
+  int *id2 = __builtin_launder(ip); // expected-warning {{discards qualifiers}}
+  float *fd = __builtin_launder(fp);
+}
Index: test/Preprocessor/feature_tests.c
===
--- test/Preprocessor/feature_tests.c
+++ test/Preprocessor/feature_tests.c
@@ -14,6 +14,7 @@
  !__has_builtin(__builtin_convertvector) || \
  !__has_builtin(__builtin_trap) || \
  !__has_builtin(__c11_atomic_init) || \
+ !__has_builtin(__builtin_launder) || \
  !__has_feature(attribute_analyzer_noreturn) || \
  !__has_feature(attribute_overloadable)
 #error Clang should have these
Index: test/CodeGen/builtins.c
===
--- test/CodeGen/builtins.c
+++ test/CodeGen/builtins.c
@@ -132,6 +132,8 @@
   R(extract_return_addr, ());
   P(signbit, (1.0));
 
+  R(launder, ());
+
   return 0;
 }
 
@@ -396,6 +398,20 @@
   return __builtin_readcyclecounter();
 }
 
+// CHECK-LABEL: define void @test_builtin_launder
+void test_builtin_launder(int *p) {
+  // CHECK: entry
+  // CHECK-NEXT: %p.addr = alloca i32*
+  // CHECK-NEXT: %d = alloca i32*
+  // CHECK-NEXT: store i32* %p, i32** %p.addr, align 8
+  // CHECK-NEXT: [[TMP:%.*]] = load i32*, i32** %p.addr
+  // CHECK-NEXT: [[TMP1:%.*]] = bitcast i32* [[TMP]] to i8*
+  // CHECK-NEXT: [[TMP2:%.*]] = call i8* @llvm.invariant.group.barrier.p0i8(i8* [[TMP1]])
+  // CHECK-NEXT: [[TMP3:%.*]] = bitcast i8* [[TMP2]] to i32*
+  // CHECK-NEXT: store i32* [[TMP3]], i32** %d
+  int *d = __builtin_launder(p);
+}
+
 // Behavior of __builtin_os_log differs between platforms, so only test on X86
 #ifdef __x86_64__
 
Index: lib/Sema/SemaChecking.cpp

  1   2   >