[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-29 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs added inline comments.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1249
+bool Z3ConstraintManager::isModelFeasible() {
+  return Solver.check() != Z3_L_FALSE;
+}

george.karpenkov wrote:
> solver can also return "unknown", what happens then?
If it returns `Z3_L_UNDEF`, e.g. in case of a timeout, this assumes that the 
state was feasible because we couldn't prove the opposite. In that case the 
report won't be invalidated.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1259
+return;
+  ConstraintRangeTy CR = OnlyPurged ? PrevCR : SuccCR;
+

george.karpenkov wrote:
> TBH I'm really confused here. Why does the method take two constraint ranges? 
> What's `OnlyPurged`? From reading the code it seems it's set by seeing 
> whether the program point only purges dead symbols, but at least a comment 
> should be added as to why this affects behavior.
The logic was:
  - add every constraint from the last node (first visited),
  - for other nodes on the path, only add those that disappear in the next step.

So `OnlyPurged` is meant to signal that we only want to add those symbols to 
the solver that are getting purged from the program state.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1278
+  // a valid APSIntType.
+  if (RangeTy.isNull())
+continue;

george.karpenkov wrote:
> I'm really curious where does it happen and why.
I encountered some 1-bit `APSInt`s that wouldn't work together with any other 
integer-handling logic. As @ddcc mentioned, he has a fix for that in D35450 
(`Z3ConstraintManager::fixAPSInt()`).


https://reviews.llvm.org/D45517



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


r333509 - [X86] Remove masking from the AVX512VNNI builtins. Use a select in IR instead.

2018-05-29 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 29 22:26:04 2018
New Revision: 333509

URL: http://llvm.org/viewvc/llvm-project?rev=333509=rev
Log:
[X86] Remove masking from the AVX512VNNI builtins. Use a select in IR instead.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlvnniintrin.h
cfe/trunk/lib/Headers/avx512vnniintrin.h
cfe/trunk/test/CodeGen/avx512vlvnni-builtins.c
cfe/trunk/test/CodeGen/avx512vnni-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=333509=333508=333509=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue May 29 22:26:04 2018
@@ -970,30 +970,18 @@ TARGET_BUILTIN(__builtin_ia32_storeapd51
 TARGET_BUILTIN(__builtin_ia32_storeups512_mask, "vf*V16fUs", "n", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_storeaps512_mask, "vV16f*V16fUs", "n", "avx512f")
 
-TARGET_BUILTIN(__builtin_ia32_vpdpbusd128_mask, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusd256_mask, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusd512_mask, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusds128_mask, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusds256_mask, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusds512_mask, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssd128_mask, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssd256_mask, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssd512_mask, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssds128_mask, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssds256_mask, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssds512_mask, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusd128_maskz, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusd256_maskz, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusd512_maskz, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusds128_maskz, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusds256_maskz, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpbusds512_maskz, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssd128_maskz, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssd256_maskz, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssd512_maskz, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssds128_maskz, "V4iV4iV4iV4iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssds256_maskz, "V8iV8iV8iV8iUc", "nc", 
"avx512vl,avx512vnni")
-TARGET_BUILTIN(__builtin_ia32_vpdpwssds512_maskz, "V16iV16iV16iV16iUs", "nc", 
"avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpbusd128, "V4iV4iV4iV4i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpbusd256, "V8iV8iV8iV8i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpbusd512, "V16iV16iV16iV16i", "nc", 
"avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpbusds128, "V4iV4iV4iV4i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpbusds256, "V8iV8iV8iV8i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpbusds512, "V16iV16iV16iV16i", "nc", 
"avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpwssd128, "V4iV4iV4iV4i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpwssd256, "V8iV8iV8iV8i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpwssd512, "V16iV16iV16iV16i", "nc", 
"avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpwssds128, "V4iV4iV4iV4i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpwssds256, "V8iV8iV8iV8i", "nc", 
"avx512vl,avx512vnni")
+TARGET_BUILTIN(__builtin_ia32_vpdpwssds512, "V16iV16iV16iV16i", "nc", 
"avx512vnni")
 
 TARGET_BUILTIN(__builtin_ia32_gather3div2df, "V2dV2ddC*V2LLiUcIi", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_gather3div2di, "V2LLiV2LLiLLiC*V2LLiUcIi", "n", 
"avx512vl")

Modified: cfe/trunk/lib/Headers/avx512vlvnniintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlvnniintrin.h?rev=333509=333508=333509=diff
==
--- cfe/trunk/lib/Headers/avx512vlvnniintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlvnniintrin.h Tue May 29 

Re: r333498 - Sema: Add a flag for rejecting member pointers with incomplete base types.

2018-05-29 Thread Mike Edwards via cfe-commits
Ah, sorry I just saw 333501 and this already passed on the bot.  All green
again.  Thanks for the quick patch, sorry for the noise.

-Mike

On Tue, May 29, 2018 at 9:33 PM, Mike Edwards  wrote:

> Hi Peter,
> Would you please have a look at:
> http://green.lab.llvm.org/green/job/clang-stage1-cmake-
> RA-incremental/48945/
>
> It looks like this commit cause a test failure on the Green Dragon
> Incremental Builder.
>
> Thanks,
> Mike
>
> On Tue, May 29, 2018 at 8:40 PM, Peter Collingbourne via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: pcc
>> Date: Tue May 29 20:40:04 2018
>> New Revision: 333498
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=333498=rev
>> Log:
>> Sema: Add a flag for rejecting member pointers with incomplete base types.
>>
>> Codebases that need to be compatible with the Microsoft ABI can pass
>> this flag to avoid issues caused by the lack of a fixed ABI for
>> incomplete member pointers.
>>
>> Differential Revision: https://reviews.llvm.org/D47503
>>
>> Added:
>> cfe/trunk/test/Driver/complete-member-pointers.cpp
>> cfe/trunk/test/SemaCXX/complete-member-pointers.cpp
>> Modified:
>> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
>> cfe/trunk/include/clang/Basic/LangOptions.def
>> cfe/trunk/include/clang/Driver/Options.td
>> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> cfe/trunk/lib/Frontend/CompilerInvocation.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=333498=333497=333498=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
>> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 29
>> 20:40:04 2018
>> @@ -6350,6 +6350,8 @@ def err_bad_memptr_rhs : Error<
>>  def err_bad_memptr_lhs : Error<
>>"left hand operand to %0 must be a %select{|pointer to }1class "
>>"compatible with the right hand operand, but is %2">;
>> +def err_memptr_incomplete : Error<
>> +  "member pointer has incomplete base type %0">;
>>  def warn_exception_caught_by_earlier_handler : Warning<
>>"exception of type %0 will be caught by earlier handler">,
>>InGroup;
>>
>> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Basic/LangOptions.def?rev=333498=333497=333498=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
>> +++ cfe/trunk/include/clang/Basic/LangOptions.def Tue May 29 20:40:04
>> 2018
>> @@ -247,6 +247,10 @@ ENUM_LANGOPT(AddressSpaceMapMangling , A
>>  LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for
>> OpenCL")
>>  BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template
>> parsing")
>>  LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
>> +LANGOPT(
>> +CompleteMemberPointers, 1, 0,
>> +"Require member pointer base types to be complete at the point where
>> the "
>> +"type's inheritance model would be determined under the Microsoft
>> ABI")
>>
>>  ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
>>  ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
>>
>> Modified: cfe/trunk/include/clang/Driver/Options.td
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>> Driver/Options.td?rev=333498=333497=333498=diff
>> 
>> ==
>> --- cfe/trunk/include/clang/Driver/Options.td (original)
>> +++ cfe/trunk/include/clang/Driver/Options.td Tue May 29 20:40:04 2018
>> @@ -782,6 +782,12 @@ def fcomment_block_commands : CommaJoine
>>  def fparse_all_comments : Flag<["-"], "fparse-all-comments">,
>> Group, Flags<[CC1Option]>;
>>  def fcommon : Flag<["-"], "fcommon">, Group;
>>  def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">,
>> Group;
>> +def fcomplete_member_pointers : Flag<["-"],
>> "fcomplete-member-pointers">, Group,
>> +   Flags<[CoreOption, CC1Option]>,
>> +   HelpText<"Require member pointer base types to be complete if they
>> would be significant under the Microsoft ABI">;
>> +def fno_complete_member_pointers : Flag<["-"],
>> "fno-complete-member-pointers">, Group,
>> +   Flags<[CoreOption]>,
>> +   HelpText<"Do not require member pointer base types to be complete if
>> they would be significant under the Microsoft ABI">;
>>  def fconstant_cfstrings : Flag<["-"], "fconstant-cfstrings">,
>> Group;
>>  def fconstant_string_class_EQ : Joined<["-"],
>> "fconstant-string-class=">, Group;
>>  def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">,
>> Group;
>>
>> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
>> URL: 

Re: r333498 - Sema: Add a flag for rejecting member pointers with incomplete base types.

2018-05-29 Thread Mike Edwards via cfe-commits
Hi Peter,
Would you please have a look at:
http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-incremental/48945/

It looks like this commit cause a test failure on the Green Dragon
Incremental Builder.

Thanks,
Mike

On Tue, May 29, 2018 at 8:40 PM, Peter Collingbourne via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: pcc
> Date: Tue May 29 20:40:04 2018
> New Revision: 333498
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333498=rev
> Log:
> Sema: Add a flag for rejecting member pointers with incomplete base types.
>
> Codebases that need to be compatible with the Microsoft ABI can pass
> this flag to avoid issues caused by the lack of a fixed ABI for
> incomplete member pointers.
>
> Differential Revision: https://reviews.llvm.org/D47503
>
> Added:
> cfe/trunk/test/Driver/complete-member-pointers.cpp
> cfe/trunk/test/SemaCXX/complete-member-pointers.cpp
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Basic/LangOptions.def
> cfe/trunk/include/clang/Driver/Options.td
> cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> cfe/trunk/lib/Frontend/CompilerInvocation.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=333498=333497=333498=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 29
> 20:40:04 2018
> @@ -6350,6 +6350,8 @@ def err_bad_memptr_rhs : Error<
>  def err_bad_memptr_lhs : Error<
>"left hand operand to %0 must be a %select{|pointer to }1class "
>"compatible with the right hand operand, but is %2">;
> +def err_memptr_incomplete : Error<
> +  "member pointer has incomplete base type %0">;
>  def warn_exception_caught_by_earlier_handler : Warning<
>"exception of type %0 will be caught by earlier handler">,
>InGroup;
>
> Modified: cfe/trunk/include/clang/Basic/LangOptions.def
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/LangOptions.def?rev=333498=333497=333498=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/LangOptions.def (original)
> +++ cfe/trunk/include/clang/Basic/LangOptions.def Tue May 29 20:40:04 2018
> @@ -247,6 +247,10 @@ ENUM_LANGOPT(AddressSpaceMapMangling , A
>  LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for
> OpenCL")
>  BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
>  LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
> +LANGOPT(
> +CompleteMemberPointers, 1, 0,
> +"Require member pointer base types to be complete at the point where
> the "
> +"type's inheritance model would be determined under the Microsoft
> ABI")
>
>  ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
>  ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
>
> Modified: cfe/trunk/include/clang/Driver/Options.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Driver/Options.td?rev=333498=333497=333498=diff
> 
> ==
> --- cfe/trunk/include/clang/Driver/Options.td (original)
> +++ cfe/trunk/include/clang/Driver/Options.td Tue May 29 20:40:04 2018
> @@ -782,6 +782,12 @@ def fcomment_block_commands : CommaJoine
>  def fparse_all_comments : Flag<["-"], "fparse-all-comments">,
> Group, Flags<[CC1Option]>;
>  def fcommon : Flag<["-"], "fcommon">, Group;
>  def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">,
> Group;
> +def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">,
> Group,
> +   Flags<[CoreOption, CC1Option]>,
> +   HelpText<"Require member pointer base types to be complete if they
> would be significant under the Microsoft ABI">;
> +def fno_complete_member_pointers : Flag<["-"],
> "fno-complete-member-pointers">, Group,
> +   Flags<[CoreOption]>,
> +   HelpText<"Do not require member pointer base types to be complete if
> they would be significant under the Microsoft ABI">;
>  def fconstant_cfstrings : Flag<["-"], "fconstant-cfstrings">,
> Group;
>  def fconstant_string_class_EQ : Joined<["-"], "fconstant-string-class=">,
> Group;
>  def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">,
> Group;
>
> Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/
> ToolChains/Clang.cpp?rev=333498=333497=333498=diff
> 
> ==
> --- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
> +++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue May 29 20:40:04 2018
> @@ -4784,6 +4784,10 @@ void 

r333501 - Protect a clang-cl file path with --.

2018-05-29 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue May 29 21:08:34 2018
New Revision: 333501

URL: http://llvm.org/viewvc/llvm-project?rev=333501=rev
Log:
Protect a clang-cl file path with --.

Modified:
cfe/trunk/test/Driver/complete-member-pointers.cpp

Modified: cfe/trunk/test/Driver/complete-member-pointers.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/complete-member-pointers.cpp?rev=333501=333500=333501=diff
==
--- cfe/trunk/test/Driver/complete-member-pointers.cpp (original)
+++ cfe/trunk/test/Driver/complete-member-pointers.cpp Tue May 29 21:08:34 2018
@@ -1,7 +1,7 @@
 // RUN: %clangxx -### -c %s -o %t.o -target x86_64-unknown-linux 2>&1 | 
FileCheck --check-prefix=NOFLAG %s
 // RUN: %clangxx -### -c %s -o %t.o -target x86_64-unknown-linux 
-fcomplete-member-pointers 2>&1 | FileCheck %s
 // RUN: %clangxx -### -c %s -o %t.o -target x86_64-unknown-linux 
-fcomplete-member-pointers -fno-complete-member-pointers 2>&1 | FileCheck 
--check-prefix=NOFLAG %s
-// RUN: %clang_cl -### /c %s /Fo%t.o -target x86_64-pc-win32 
-fcomplete-member-pointers 2>&1 | FileCheck %s
+// RUN: %clang_cl -### /c /Fo%t.o -target x86_64-pc-win32 
-fcomplete-member-pointers -- %s 2>&1 | FileCheck %s
 
 // CHECK: "-fcomplete-member-pointers"
 // NOFLAG-NOT: "-fcomplete-member-pointers"


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


[PATCH] D47067: Update NRVO logic to support early return

2018-05-29 Thread Taiju Tsuiki via Phabricator via cfe-commits
tzik added a comment.

In https://reviews.llvm.org/D47067#1115566, @rsmith wrote:

> Thank you, do you need someone to commit this for you?


No, I recently got the commit access to the repository.


Repository:
  rC Clang

https://reviews.llvm.org/D47067



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


[PATCH] D47067: Update NRVO logic to support early return

2018-05-29 Thread Taiju Tsuiki via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333500: Update NRVO logic to support early return (authored 
by tzik, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47067?vs=148603=149035#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47067

Files:
  include/clang/AST/Decl.h
  include/clang/Sema/Scope.h
  lib/Sema/Scope.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaStmt.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CodeGenCXX/nrvo-noopt.cpp
  test/CodeGenCXX/nrvo.cpp
  test/SemaCXX/nrvo-ast.cpp

Index: include/clang/AST/Decl.h
===
--- include/clang/AST/Decl.h
+++ include/clang/AST/Decl.h
@@ -879,6 +879,12 @@
 DAK_Normal
   };
 
+  enum NRVOMode {
+NRVO_Candidate,
+NRVO_Disabled,
+NRVO_Enabled,
+  };
+
   class ParmVarDeclBitfields {
 friend class ASTDeclReader;
 friend class ParmVarDecl;
@@ -931,7 +937,7 @@
 /// Whether this local variable could be allocated in the return
 /// slot of its function, enabling the named return value optimization
 /// (NRVO).
-unsigned NRVOVariable : 1;
+unsigned NRVOMode : 2;
 
 /// Whether this variable is the for-range-declaration in a C++0x
 /// for-range statement.
@@ -1319,12 +1325,20 @@
   /// return slot when returning from the function. Within the function body,
   /// each return that returns the NRVO object will have this variable as its
   /// NRVO candidate.
+  NRVOMode getNRVOMode() const {
+if (isa(this))
+  return NRVO_Disabled;
+return static_cast(NonParmVarDeclBits.NRVOMode);
+  }
+  bool isNRVOCandidate() const {
+return isa(this) ? false : NonParmVarDeclBits.NRVOMode == NRVO_Candidate;
+  }
   bool isNRVOVariable() const {
-return isa(this) ? false : NonParmVarDeclBits.NRVOVariable;
+return isa(this) ? false : NonParmVarDeclBits.NRVOMode == NRVO_Enabled;
   }
   void setNRVOVariable(bool NRVO) {
 assert(!isa(this));
-NonParmVarDeclBits.NRVOVariable = NRVO;
+NonParmVarDeclBits.NRVOMode = NRVO ? NRVO_Enabled : NRVO_Disabled;
   }
 
   /// Determine whether this variable is the for-range-declaration in
Index: include/clang/Sema/Scope.h
===
--- include/clang/Sema/Scope.h
+++ include/clang/Sema/Scope.h
@@ -201,10 +201,6 @@
   /// Used to determine if errors occurred in this scope.
   DiagnosticErrorTrap ErrorTrap;
 
-  /// A lattice consisting of undefined, a single NRVO candidate variable in
-  /// this scope, or over-defined. The bit is true when over-defined.
-  llvm::PointerIntPair NRVO;
-
   void setFlags(Scope *Parent, unsigned F);
 
 public:
@@ -466,23 +462,7 @@
   UsingDirectives.end());
   }
 
-  void addNRVOCandidate(VarDecl *VD) {
-if (NRVO.getInt())
-  return;
-if (NRVO.getPointer() == nullptr) {
-  NRVO.setPointer(VD);
-  return;
-}
-if (NRVO.getPointer() != VD)
-  setNoNRVO();
-  }
-
-  void setNoNRVO() {
-NRVO.setInt(true);
-NRVO.setPointer(nullptr);
-  }
-
-  void mergeNRVOIntoParent();
+  void setNRVOCandidate(VarDecl *Candidate);
 
   /// Init - This is used by the parser to implement scope caching.
   void Init(Scope *parent, unsigned flags);
Index: test/SemaCXX/nrvo-ast.cpp
===
--- test/SemaCXX/nrvo-ast.cpp
+++ test/SemaCXX/nrvo-ast.cpp
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -fcxx-exceptions -fsyntax-only -ast-dump -o - %s | FileCheck %s
+
+struct X {
+  X();
+  X(const X&);
+  X(X&&);
+};
+
+// CHECK-LABEL: FunctionDecl {{.*}} test_00
+X test_00() {
+  // CHECK: VarDecl {{.*}} x {{.*}} nrvo
+  X x;
+  return x;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} test_01
+X test_01(bool b) {
+  // CHECK: VarDecl {{.*}} x {{.*}} nrvo
+  X x;
+  if (b)
+return x;
+  return x;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} test_02
+X test_02(bool b) {
+  // CHECK-NOT: VarDecl {{.*}} x {{.*}} nrvo
+  X x;
+  // CHECK-NOT: VarDecl {{.*}} y {{.*}} nrvo
+  X y;
+  if (b)
+return y;
+  return x;
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} test_03
+X test_03(bool b) {
+  if (b) {
+// CHECK: VarDecl {{.*}} y {{.*}} nrvo
+X y;
+return y;
+  }
+  // CHECK: VarDecl {{.*}} x {{.*}} nrvo
+  X x;
+  return x;
+}
+
+extern "C" _Noreturn void exit(int) throw();
+
+// CHECK-LABEL: FunctionDecl {{.*}} test_04
+X test_04(bool b) {
+  {
+// CHECK: VarDecl {{.*}} x {{.*}} nrvo
+X x;
+if (b)
+  return x;
+  }
+  exit(1);
+}
+
+void may_throw();
+// CHECK-LABEL: FunctionDecl {{.*}} test_05
+X test_05() {
+  try {
+may_throw();
+return X();
+  } catch (X x) {
+// CHECK-NOT: VarDecl {{.*}} x {{.*}} nrvo
+return x;
+  }
+}
+
+// CHECK-LABEL: FunctionDecl {{.*}} test_06
+X test_06() {
+  // CHECK-NOT: VarDecl {{.*}} x {{.*}} nrvo
+  X x 

r333500 - Update NRVO logic to support early return

2018-05-29 Thread Taiju Tsuiki via cfe-commits
Author: tzik
Date: Tue May 29 20:53:16 2018
New Revision: 333500

URL: http://llvm.org/viewvc/llvm-project?rev=333500=rev
Log:
Update NRVO logic to support early return

Summary:
The previous implementation misses an opportunity to apply NRVO (Named Return 
Value
Optimization) below. That discourages user to write early return code.

```
struct Foo {};

Foo f(bool b) {
  if (b)
return Foo();
  Foo oo;
  return oo;
}
```
That is, we can/should apply RVO for a local variable if:
 * It's directly returned by at least one return statement.
 * And, all reachable return statements in its scope returns the variable 
directly.
While, the previous implementation disables the RVO in a scope if there are 
multiple return
statements that refers different variables.

On the new algorithm, local variables are in NRVO_Candidate state at first, and 
a return
statement changes it to NRVO_Disabled for all visible variables but the return 
statement refers.
Then, at the end of the function AST traversal, NRVO is enabled for variables 
in NRVO_Candidate
state and refers from at least one return statement.

Reviewers: rsmith

Reviewed By: rsmith

Subscribers: xbolva00, Quuxplusone, arthur.j.odwyer, cfe-commits

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

Added:
cfe/trunk/test/CodeGenCXX/nrvo-noopt.cpp
cfe/trunk/test/SemaCXX/nrvo-ast.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/Sema/Scope.h
cfe/trunk/lib/Sema/Scope.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
cfe/trunk/test/CodeGenCXX/nrvo.cpp

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=333500=333499=333500=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Tue May 29 20:53:16 2018
@@ -879,6 +879,12 @@ protected:
 DAK_Normal
   };
 
+  enum NRVOMode {
+NRVO_Candidate,
+NRVO_Disabled,
+NRVO_Enabled,
+  };
+
   class ParmVarDeclBitfields {
 friend class ASTDeclReader;
 friend class ParmVarDecl;
@@ -931,7 +937,7 @@ protected:
 /// Whether this local variable could be allocated in the return
 /// slot of its function, enabling the named return value optimization
 /// (NRVO).
-unsigned NRVOVariable : 1;
+unsigned NRVOMode : 2;
 
 /// Whether this variable is the for-range-declaration in a C++0x
 /// for-range statement.
@@ -1319,12 +1325,20 @@ public:
   /// return slot when returning from the function. Within the function body,
   /// each return that returns the NRVO object will have this variable as its
   /// NRVO candidate.
+  NRVOMode getNRVOMode() const {
+if (isa(this))
+  return NRVO_Disabled;
+return static_cast(NonParmVarDeclBits.NRVOMode);
+  }
+  bool isNRVOCandidate() const {
+return isa(this) ? false : NonParmVarDeclBits.NRVOMode == 
NRVO_Candidate;
+  }
   bool isNRVOVariable() const {
-return isa(this) ? false : NonParmVarDeclBits.NRVOVariable;
+return isa(this) ? false : NonParmVarDeclBits.NRVOMode == 
NRVO_Enabled;
   }
   void setNRVOVariable(bool NRVO) {
 assert(!isa(this));
-NonParmVarDeclBits.NRVOVariable = NRVO;
+NonParmVarDeclBits.NRVOMode = NRVO ? NRVO_Enabled : NRVO_Disabled;
   }
 
   /// Determine whether this variable is the for-range-declaration in

Modified: cfe/trunk/include/clang/Sema/Scope.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Scope.h?rev=333500=333499=333500=diff
==
--- cfe/trunk/include/clang/Sema/Scope.h (original)
+++ cfe/trunk/include/clang/Sema/Scope.h Tue May 29 20:53:16 2018
@@ -201,10 +201,6 @@ private:
   /// Used to determine if errors occurred in this scope.
   DiagnosticErrorTrap ErrorTrap;
 
-  /// A lattice consisting of undefined, a single NRVO candidate variable in
-  /// this scope, or over-defined. The bit is true when over-defined.
-  llvm::PointerIntPair NRVO;
-
   void setFlags(Scope *Parent, unsigned F);
 
 public:
@@ -466,23 +462,7 @@ public:
   UsingDirectives.end());
   }
 
-  void addNRVOCandidate(VarDecl *VD) {
-if (NRVO.getInt())
-  return;
-if (NRVO.getPointer() == nullptr) {
-  NRVO.setPointer(VD);
-  return;
-}
-if (NRVO.getPointer() != VD)
-  setNoNRVO();
-  }
-
-  void setNoNRVO() {
-NRVO.setInt(true);
-NRVO.setPointer(nullptr);
-  }
-
-  void mergeNRVOIntoParent();
+  void setNRVOCandidate(VarDecl *Candidate);
 
   /// Init - This is used by the parser to implement scope caching.
   void Init(Scope *parent, unsigned flags);

Modified: cfe/trunk/lib/Sema/Scope.cpp
URL: 

Buildbot numbers for the week of 5/20/2018 - 5/26/2018

2018-05-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the last week of 5/20/2018 - 5/26/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername   | was_red
-+-
 lldb-windows7-android   | 88:18:35
 sanitizer-x86_64-linux-bootstrap| 42:19:42
 sanitizer-x86_64-linux-bootstrap-ubsan  | 40:11:15
 sanitizer-x86_64-linux-bootstrap-msan   | 37:01:18
 sanitizer-x86_64-linux-fuzzer   | 36:31:37
 sanitizer-x86_64-linux  | 35:39:35
 sanitizer-x86_64-linux-autoconf | 34:33:59
 clang-cmake-aarch64-full| 30:32:57
 clang-x64-ninja-win7| 21:45:19
 clang-x86-windows-msvc2015  | 21:36:08
 clang-with-lto-ubuntu   | 20:30:52
 clang-with-thin-lto-windows | 19:12:19
 clang-cuda-build| 18:11:05
 llvm-clang-x86_64-expensive-checks-win  | 14:44:02
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std | 14:20:06
 clang-lld-x86_64-2stage | 12:46:27
 clang-with-thin-lto-ubuntu  | 12:24:16
 clang-cmake-armv7-full  | 09:16:42
 clang-cmake-armv8-selfhost-neon | 08:00:50
 clang-cmake-x86_64-avx2-linux   | 07:23:53
 clang-cmake-aarch64-lld | 06:29:20
 clang-cmake-thumbv7-full-sh | 06:24:29
 clang-ppc64be-linux-lnt | 05:53:46
 clang-cmake-armv7-selfhost  | 05:45:06
 clang-cmake-armv7-selfhost-neon | 05:44:49
 clang-s390x-linux-lnt   | 05:44:03
 clang-ppc64le-linux-lnt | 05:42:16
 clang-ppc64le-linux-multistage  | 05:20:55
 clang-cmake-x86_64-avx2-linux-perf  | 04:56:05
 clang-s390x-linux-multistage| 04:45:24
 clang-s390x-linux   | 04:15:50
 clang-cmake-armv7-quick | 04:12:40
 clang-bpf-build | 04:03:49
 clang-cmake-armv8-full  | 03:58:15
 clang-cmake-aarch64-global-isel | 03:55:28
 clang-cmake-aarch64-quick   | 03:43:07
 clang-cmake-armv8-global-isel   | 03:34:07
 clang-x86_64-debian-fast| 03:21:57
 clang-hexagon-elf   | 03:18:37
 sanitizer-ppc64le-linux | 03:18:32
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast| 03:14:10
 lldb-amd64-ninja-netbsd8| 03:12:52
 sanitizer-ppc64be-linux | 03:07:52
 clang-ppc64le-linux | 03:07:00
 clang-ppc64be-linux-multistage  | 03:02:41
 reverse-iteration   | 03:01:56
 clang-cmake-armv7-global-isel   | 03:01:26
 polly-amd64-linux   | 02:52:55
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast  | 02:52:38
 clang-ppc64be-linux | 02:52:21
 polly-arm-linux | 02:50:35
 clang-cmake-armv8-quick | 02:46:57
 lldb-x86_64-ubuntu-14.04-buildserver| 02:46:02
 clang-cmake-armv8-lnt   | 02:44:20
 sanitizer-x86_64-linux-fast | 02:37:46
 lldb-x86_64-ubuntu-14.04-cmake  | 02:28:33
 lldb-x86-windows-msvc2015   | 02:27:26
 sanitizer-windows   | 02:18:54
 clang-x86_64-linux-abi-test | 02:16:23
 clang-cmake-armv7-lnt   | 01:55:49
 lld-x86_64-win7 | 01:48:35
 lldb-x86_64-darwin-13.4 | 01:38:46
 

Buildbot numbers for the week of 5/13/2018 - 5/19/2018

2018-05-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 5/13/2018 - 5/19/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 aosp-O3-polly-before-vectorizer-unprofitable | 96:20:38
 clang-x64-ninja-win7 | 91:00:52
 clang-cmake-x86_64-avx2-linux-perf   | 65:10:57
 clang-sphinx-docs| 62:01:06
 lldb-windows7-android| 57:13:19
 clang-x86_64-linux-abi-test  | 39:06:31
 clang-with-lto-ubuntu| 31:07:33
 clang-hexagon-elf| 30:03:02
 clang-cmake-armv8-global-isel| 28:45:16
 clang-cmake-armv8-full   | 28:34:08
 clang-cmake-armv7-selfhost   | 28:28:58
 clang-cmake-armv7-selfhost-neon  | 28:27:16
 clang-cmake-armv8-quick  | 28:22:10
 clang-cmake-armv7-quick  | 28:14:45
 clang-cmake-armv7-global-isel| 27:35:57
 llvm-clang-x86_64-expensive-checks-win   | 27:28:16
 clang-cmake-armv8-selfhost-neon  | 27:15:05
 clang-cmake-thumbv7-full-sh  | 25:41:41
 clang-lld-x86_64-2stage  | 23:31:47
 lld-x86_64-darwin13  | 22:57:07
 clang-cmake-armv7-full   | 22:40:27
 clang-with-thin-lto-ubuntu   | 22:40:21
 clang-ppc64le-linux-multistage   | 22:05:03
 clang-cmake-aarch64-lld  | 21:47:54
 clang-cmake-aarch64-quick| 21:45:53
 clang-cmake-aarch64-global-isel  | 21:38:41
 clang-ppc64be-linux-lnt  | 19:01:10
 clang-ppc64le-linux-lnt  | 18:40:50
 clang-with-thin-lto-windows  | 16:35:53
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 15:55:02
 clang-cmake-x86_64-avx2-linux| 15:17:30
 clang-bpf-build  | 09:40:20
 reverse-iteration| 09:31:09
 clang-x86-windows-msvc2015   | 09:28:39
 polly-amd64-linux| 09:09:23
 clang-cuda-build | 09:02:35
 sanitizer-x86_64-linux-fast  | 09:01:02
 clang-ppc64be-linux  | 08:53:50
 sanitizer-x86_64-linux-bootstrap | 08:53:37
 clang-ppc64be-linux-multistage   | 08:42:39
 sanitizer-x86_64-linux-bootstrap-ubsan   | 08:36:00
 clang-ppc64le-linux  | 08:26:13
 clang-s390x-linux| 08:25:55
 clang-s390x-linux-lnt| 08:22:08
 sanitizer-x86_64-linux-bootstrap-msan| 08:15:08
 clang-s390x-linux-multistage | 07:22:16
 clang-x86_64-debian-fast | 07:16:20
 clang-cmake-aarch64-full | 06:46:56
 polly-arm-linux  | 05:28:20
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 05:27:39
 sanitizer-x86_64-linux   | 05:02:02
 lldb-x86_64-darwin-13.4  | 03:21:04
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan| 03:09:12
 sanitizer-ppc64le-linux  | 02:55:30
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit   | 02:36:10
 sanitizer-ppc64be-linux  | 02:05:00
 lldb-amd64-ninja-netbsd8 | 01:54:12
 lld-perf-testsuite   | 01:44:08
 lldb-x86_64-ubuntu-14.04-android | 01:40:19
 lldb-x86_64-ubuntu-14.04-buildserver | 01:37:43
 sanitizer-x86_64-linux-autoconf  | 01:36:33
 lldb-x86_64-ubuntu-14.04-cmake   | 01:07:43
 llvm-sphinx-docs | 01:02:08
 llvm-hexagon-elf | 00:56:46
 lldb-x86-windows-msvc2015| 00:45:33
 sanitizer-x86_64-linux-fuzzer| 00:39:04
 sanitizer-x86_64-linux-android   | 00:38:12
 sanitizer-windows| 00:28:37
 lld-x86_64-freebsd   | 00:28:19
 lldb-amd64-ninja-freebsd11

Buildbot numbers for the week of 5/6/2018 - 5/12/2018

2018-05-29 Thread Galina Kistanova via cfe-commits
Hello everyone,

Below are some buildbot numbers for the week of 5/6/2018 - 5/12/2018.

Please see the same data in attached csv files:

The longest time each builder was red during the week;
"Status change ratio" by active builder (percent of builds that changed the
builder status from greed to red or from red to green);
Count of commits by project;
Number of completed builds, failed builds and average build time for
successful builds per active builder;
Average waiting time for a revision to get build result per active builder
(response time).

Thanks

Galina


The longest time each builder was red during the week:
   buildername| was_red
--+-
 lldb-x86_64-ubuntu-14.04-android | 55:37:38
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17   | 34:11:32
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a   | 33:59:13
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11   | 33:58:46
 libcxx-libcxxabi-x86_64-linux-ubuntu-32bit   | 33:55:55
 libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu   | 33:48:37
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14   | 33:39:48
 libcxx-libcxxabi-x86_64-linux-ubuntu-tsan| 33:17:07
 libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03   | 32:32:48
 clang-with-lto-ubuntu| 31:04:23
 polly-arm-linux  | 28:04:17
 reverse-iteration| 27:41:09
 polly-amd64-linux| 25:54:37
 clang-cmake-thumbv7-full-sh  | 22:37:58
 clang-s390x-linux-multistage | 18:51:29
 clang-cmake-aarch64-full | 17:33:43
 clang-cmake-armv7-full   | 15:46:51
 clang-cmake-armv8-full   | 15:14:20
 clang-cmake-armv8-selfhost-neon  | 14:46:53
 sanitizer-ppc64le-linux  | 14:18:30
 clang-ppc64le-linux-multistage   | 14:16:59
 clang-cmake-aarch64-lld  | 14:08:35
 clang-s390x-linux-lnt| 14:07:43
 clang-s390x-linux| 14:06:59
 clang-ppc64be-linux  | 13:31:52
 clang-ppc64le-linux  | 13:30:58
 clang-ppc64be-linux-lnt  | 13:27:15
 clang-ppc64be-linux-multistage   | 13:18:01
 clang-ppc64le-linux-lnt  | 13:09:01
 sanitizer-x86_64-linux-bootstrap-ubsan   | 13:01:12
 sanitizer-x86_64-linux-bootstrap-msan| 12:40:56
 sanitizer-ppc64be-linux  | 12:28:09
 sanitizer-x86_64-linux-fast  | 11:59:31
 llvm-clang-x86_64-expensive-checks-win   | 11:46:40
 lld-x86_64-darwin13  | 11:23:38
 lld-x86_64-freebsd   | 11:23:34
 clang-with-thin-lto-windows  | 11:19:51
 llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast | 10:54:58
 clang-lld-x86_64-2stage  | 10:41:47
 sanitizer-x86_64-linux-bootstrap | 10:18:18
 clang-cmake-armv8-global-isel| 09:57:08
 clang-cmake-armv7-global-isel| 09:55:02
 clang-cmake-armv8-quick  | 09:52:07
 clang-cmake-aarch64-quick| 09:47:06
 clang-with-thin-lto-ubuntu   | 09:46:49
 clang-cmake-aarch64-global-isel  | 09:36:54
 clang-cmake-armv7-quick  | 09:28:31
 clang-x86-windows-msvc2015   | 07:28:19
 llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast   | 07:25:59
 sanitizer-x86_64-linux-fuzzer| 06:33:59
 sanitizer-x86_64-linux-autoconf  | 06:06:25
 clang-x64-ninja-win7 | 05:30:24
 libcxx-libcxxabi-x86_64-linux-ubuntu-asan| 05:28:19
 clang-cmake-armv7-selfhost   | 05:18:47
 clang-cmake-armv7-selfhost-neon  | 05:18:38
 llvm-hexagon-elf | 04:58:55
 clang-bpf-build  | 04:40:12
 clang-hexagon-elf| 03:16:12
 libcxx-libcxxabi-x86_64-linux-ubuntu-gcc49-cxx11 | 03:09:09
 lldb-x86_64-ubuntu-14.04-cmake   | 03:06:11
 lldb-x86_64-darwin-13.4  | 02:34:36
 lldb-amd64-ninja-netbsd8 | 01:36:37
 sanitizer-x86_64-linux   | 01:30:34
 lld-perf-testsuite   | 01:18:09
 lldb-x86_64-ubuntu-14.04-buildserver | 00:50:49
 lldb-x86-windows-msvc2015| 00:49:02
 clang-cmake-x86_64-avx2-linux| 00:45:52
 sanitizer-x86_64-linux-android   | 00:28:41
 clang-cuda-build | 00:23:56
 clang-x86_64-linux-abi-test

r333498 - Sema: Add a flag for rejecting member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Tue May 29 20:40:04 2018
New Revision: 333498

URL: http://llvm.org/viewvc/llvm-project?rev=333498=rev
Log:
Sema: Add a flag for rejecting member pointers with incomplete base types.

Codebases that need to be compatible with the Microsoft ABI can pass
this flag to avoid issues caused by the lack of a fixed ABI for
incomplete member pointers.

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

Added:
cfe/trunk/test/Driver/complete-member-pointers.cpp
cfe/trunk/test/SemaCXX/complete-member-pointers.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.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=333498=333497=333498=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 29 20:40:04 
2018
@@ -6350,6 +6350,8 @@ def err_bad_memptr_rhs : Error<
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def err_memptr_incomplete : Error<
+  "member pointer has incomplete base type %0">;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=333498=333497=333498=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue May 29 20:40:04 2018
@@ -247,6 +247,10 @@ ENUM_LANGOPT(AddressSpaceMapMangling , A
 LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for OpenCL")
 BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
 LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
+LANGOPT(
+CompleteMemberPointers, 1, 0,
+"Require member pointer base types to be complete at the point where the "
+"type's inheritance model would be determined under the Microsoft ABI")
 
 ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
 ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=333498=333497=333498=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 29 20:40:04 2018
@@ -782,6 +782,12 @@ def fcomment_block_commands : CommaJoine
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, 
Group, Flags<[CC1Option]>;
 def fcommon : Flag<["-"], "fcommon">, Group;
 def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group;
+def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">, 
Group,
+   Flags<[CoreOption, CC1Option]>,
+   HelpText<"Require member pointer base types to be complete if they would be 
significant under the Microsoft ABI">;
+def fno_complete_member_pointers : Flag<["-"], 
"fno-complete-member-pointers">, Group,
+   Flags<[CoreOption]>,
+   HelpText<"Do not require member pointer base types to be complete if they 
would be significant under the Microsoft ABI">;
 def fconstant_cfstrings : Flag<["-"], "fconstant-cfstrings">, Group;
 def fconstant_string_class_EQ : Joined<["-"], "fconstant-string-class=">, 
Group;
 def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">, Group;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=333498=333497=333498=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Tue May 29 20:40:04 2018
@@ -4784,6 +4784,10 @@ void Clang::ConstructJob(Compilation ,
   CmdArgs.push_back("-fforce-enable-int128");
   }
 
+  if (Args.hasFlag(options::OPT_fcomplete_member_pointers,
+   options::OPT_fno_complete_member_pointers, false))
+CmdArgs.push_back("-fcomplete-member-pointers");
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 

[PATCH] D47503: Sema: Add a flag for rejecting member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333498: Sema: Add a flag for rejecting member pointers with 
incomplete base types. (authored by pcc, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47503?vs=149029=149031#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47503

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaType.cpp
  test/Driver/complete-member-pointers.cpp
  test/SemaCXX/complete-member-pointers.cpp

Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4784,6 +4784,10 @@
   CmdArgs.push_back("-fforce-enable-int128");
   }
 
+  if (Args.hasFlag(options::OPT_fcomplete_member_pointers,
+   options::OPT_fno_complete_member_pointers, false))
+CmdArgs.push_back("-fcomplete-member-pointers");
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7585,11 +7585,17 @@
   //  assert(!T->isDependentType() &&
   // "Can't ask whether a dependent type is complete");
 
-  // We lock in the inheritance model once somebody has asked us to ensure
-  // that a pointer-to-member type is complete.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-if (const MemberPointerType *MPTy = T->getAs()) {
-  if (!MPTy->getClass()->isDependentType()) {
+  if (const MemberPointerType *MPTy = T->getAs()) {
+if (!MPTy->getClass()->isDependentType()) {
+  if (getLangOpts().CompleteMemberPointers &&
+  !MPTy->getClass()->getAsCXXRecordDecl()->isBeingDefined() &&
+  RequireCompleteType(Loc, QualType(MPTy->getClass(), 0),
+  diag::err_memptr_incomplete))
+return true;
+
+  // We lock in the inheritance model once somebody has asked us to ensure
+  // that a pointer-to-member type is complete.
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 (void)isCompleteType(Loc, QualType(MPTy->getClass(), 0));
 assignInheritanceModel(*this, MPTy->getMostRecentCXXRecordDecl());
   }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2754,6 +2754,8 @@
   << A->getAsString(Args) << A->getValue();
 }
   }
+
+  Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -782,6 +782,12 @@
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>;
 def fcommon : Flag<["-"], "fcommon">, Group;
 def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group;
+def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">, Group,
+   Flags<[CoreOption, CC1Option]>,
+   HelpText<"Require member pointer base types to be complete if they would be significant under the Microsoft ABI">;
+def fno_complete_member_pointers : Flag<["-"], "fno-complete-member-pointers">, Group,
+   Flags<[CoreOption]>,
+   HelpText<"Do not require member pointer base types to be complete if they would be significant under the Microsoft ABI">;
 def fconstant_cfstrings : Flag<["-"], "fconstant-cfstrings">, Group;
 def fconstant_string_class_EQ : Joined<["-"], "fconstant-string-class=">, Group;
 def fconstexpr_depth_EQ : Joined<["-"], "fconstexpr-depth=">, Group;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -247,6 +247,10 @@
 LANGOPT(IncludeDefaultHeader, 1, 0, "Include default header file for OpenCL")
 BENIGN_LANGOPT(DelayedTemplateParsing , 1, 0, "delayed template parsing")
 LANGOPT(BlocksRuntimeOptional , 1, 0, "optional blocks runtime")
+LANGOPT(
+CompleteMemberPointers, 1, 0,
+"Require member pointer base types to be complete at the point where the "
+"type's inheritance model would be determined under the Microsoft ABI")
 
 ENUM_LANGOPT(GC, GCMode, 2, NonGC, "Objective-C Garbage Collection mode")
 ENUM_LANGOPT(ValueVisibilityMode, Visibility, 3, DefaultVisibility,
Index: include/clang/Basic/DiagnosticSemaKinds.td
===

r333497 - [X86] Fix the names of a bunch of icelake intrinsics.

2018-05-29 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 29 20:38:15 2018
New Revision: 333497

URL: http://llvm.org/viewvc/llvm-project?rev=333497=rev
Log:
[X86] Fix the names of a bunch of icelake intrinsics.

Mostly this fixes the names of all the 128-bit intrinsics to start with _mm_ 
instead of _mm128_ as is the convention and what the Intel docs say.

This also fixes the name of the bitshuffle intrinsics to say epi64 for 128 and 
256 bit versions.

Modified:
cfe/trunk/lib/Headers/avx512vlbitalgintrin.h
cfe/trunk/lib/Headers/avx512vlvbmi2intrin.h
cfe/trunk/lib/Headers/avx512vlvnniintrin.h
cfe/trunk/test/CodeGen/avx512vlbitalg-builtins.c
cfe/trunk/test/CodeGen/avx512vlvbmi2-builtins.c
cfe/trunk/test/CodeGen/avx512vlvnni-builtins.c

Modified: cfe/trunk/lib/Headers/avx512vlbitalgintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbitalgintrin.h?rev=333497=333496=333497=diff
==
--- cfe/trunk/lib/Headers/avx512vlbitalgintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbitalgintrin.h Tue May 29 20:38:15 2018
@@ -54,23 +54,23 @@ _mm256_maskz_popcnt_epi16(__mmask16 __U,
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm128_popcnt_epi16(__m128i __A)
+_mm_popcnt_epi16(__m128i __A)
 {
   return (__m128i) __builtin_ia32_vpopcntw_128((__v8hi) __A);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm128_mask_popcnt_epi16(__m128i __A, __mmask8 __U, __m128i __B)
+_mm_mask_popcnt_epi16(__m128i __A, __mmask8 __U, __m128i __B)
 {
   return (__m128i) __builtin_ia32_selectw_128((__mmask8) __U,
-  (__v8hi) _mm128_popcnt_epi16(__B),
+  (__v8hi) _mm_popcnt_epi16(__B),
   (__v8hi) __A);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm128_maskz_popcnt_epi16(__mmask8 __U, __m128i __B)
+_mm_maskz_popcnt_epi16(__mmask8 __U, __m128i __B)
 {
-  return _mm128_mask_popcnt_epi16((__m128i) _mm_setzero_si128(),
+  return _mm_mask_popcnt_epi16((__m128i) _mm_setzero_si128(),
   __U,
   __B);
 }
@@ -98,29 +98,29 @@ _mm256_maskz_popcnt_epi8(__mmask32 __U,
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm128_popcnt_epi8(__m128i __A)
+_mm_popcnt_epi8(__m128i __A)
 {
   return (__m128i) __builtin_ia32_vpopcntb_128((__v16qi) __A);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm128_mask_popcnt_epi8(__m128i __A, __mmask16 __U, __m128i __B)
+_mm_mask_popcnt_epi8(__m128i __A, __mmask16 __U, __m128i __B)
 {
   return (__m128i) __builtin_ia32_selectb_128((__mmask16) __U,
-  (__v16qi) _mm128_popcnt_epi8(__B),
+  (__v16qi) _mm_popcnt_epi8(__B),
   (__v16qi) __A);
 }
 
 static __inline__ __m128i __DEFAULT_FN_ATTRS
-_mm128_maskz_popcnt_epi8(__mmask16 __U, __m128i __B)
+_mm_maskz_popcnt_epi8(__mmask16 __U, __m128i __B)
 {
-  return _mm128_mask_popcnt_epi8((__m128i) _mm_setzero_si128(),
+  return _mm_mask_popcnt_epi8((__m128i) _mm_setzero_si128(),
   __U,
   __B);
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_mask_bitshuffle_epi32_mask(__mmask32 __U, __m256i __A, __m256i __B)
+_mm256_mask_bitshuffle_epi64_mask(__mmask32 __U, __m256i __A, __m256i __B)
 {
   return (__mmask32) __builtin_ia32_vpshufbitqmb256_mask((__v32qi) __A,
   (__v32qi) __B,
@@ -128,15 +128,15 @@ _mm256_mask_bitshuffle_epi32_mask(__mmas
 }
 
 static __inline__ __mmask32 __DEFAULT_FN_ATTRS
-_mm256_bitshuffle_epi32_mask(__m256i __A, __m256i __B)
+_mm256_bitshuffle_epi64_mask(__m256i __A, __m256i __B)
 {
-  return _mm256_mask_bitshuffle_epi32_mask((__mmask32) -1,
+  return _mm256_mask_bitshuffle_epi64_mask((__mmask32) -1,
   __A,
   __B);
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm128_mask_bitshuffle_epi16_mask(__mmask16 __U, __m128i __A, __m128i __B)
+_mm_mask_bitshuffle_epi64_mask(__mmask16 __U, __m128i __A, __m128i __B)
 {
   return (__mmask16) __builtin_ia32_vpshufbitqmb128_mask((__v16qi) __A,
   (__v16qi) __B,
@@ -144,9 +144,9 @@ _mm128_mask_bitshuffle_epi16_mask(__mmas
 }
 
 static __inline__ __mmask16 __DEFAULT_FN_ATTRS
-_mm128_bitshuffle_epi16_mask(__m128i __A, __m128i __B)
+_mm_bitshuffle_epi64_mask(__m128i __A, __m128i __B)
 {
-  return _mm128_mask_bitshuffle_epi16_mask((__mmask16) -1,
+  return _mm_mask_bitshuffle_epi64_mask((__mmask16) -1,
   __A,
   __B);
 }

Modified: cfe/trunk/lib/Headers/avx512vlvbmi2intrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlvbmi2intrin.h?rev=333497=333496=333497=diff
==
--- cfe/trunk/lib/Headers/avx512vlvbmi2intrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlvbmi2intrin.h Tue May 29 20:38:15 2018
@@ -31,13 +31,8 @@
 /* Define the default attributes for the functions in this file. */
 #define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, 

[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc updated this revision to Diff 149029.
pcc added a comment.

- Implement as -f flag


https://reviews.llvm.org/D47503

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Driver/complete-member-pointers.cpp
  clang/test/SemaCXX/complete-member-pointers.cpp

Index: clang/test/SemaCXX/complete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/complete-member-pointers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -fcomplete-member-pointers %s
+
+struct S; // expected-note {{forward declaration of 'S'}}
+typedef int S::*t;
+t foo; // expected-error {{member pointer has incomplete base type 'S'}}
+
+struct S2 {
+  int S2::*foo;
+};
+int S2::*bar;
+
+template 
+struct S3 {
+  int T::*foo;
+};
Index: clang/test/Driver/complete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/Driver/complete-member-pointers.cpp
@@ -0,0 +1,7 @@
+// RUN: %clangxx -### -c %s -o %t.o -target x86_64-unknown-linux 2>&1 | FileCheck --check-prefix=NOFLAG %s
+// RUN: %clangxx -### -c %s -o %t.o -target x86_64-unknown-linux -fcomplete-member-pointers 2>&1 | FileCheck %s
+// RUN: %clangxx -### -c %s -o %t.o -target x86_64-unknown-linux -fcomplete-member-pointers -fno-complete-member-pointers 2>&1 | FileCheck --check-prefix=NOFLAG %s
+// RUN: %clang_cl -### /c %s /Fo%t.o -target x86_64-pc-win32 -fcomplete-member-pointers 2>&1 | FileCheck %s
+
+// CHECK: "-fcomplete-member-pointers"
+// NOFLAG-NOT: "-fcomplete-member-pointers"
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7585,11 +7585,17 @@
   //  assert(!T->isDependentType() &&
   // "Can't ask whether a dependent type is complete");
 
-  // We lock in the inheritance model once somebody has asked us to ensure
-  // that a pointer-to-member type is complete.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-if (const MemberPointerType *MPTy = T->getAs()) {
-  if (!MPTy->getClass()->isDependentType()) {
+  if (const MemberPointerType *MPTy = T->getAs()) {
+if (!MPTy->getClass()->isDependentType()) {
+  if (getLangOpts().CompleteMemberPointers &&
+  !MPTy->getClass()->getAsCXXRecordDecl()->isBeingDefined() &&
+  RequireCompleteType(Loc, QualType(MPTy->getClass(), 0),
+  diag::err_memptr_incomplete))
+return true;
+
+  // We lock in the inheritance model once somebody has asked us to ensure
+  // that a pointer-to-member type is complete.
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 (void)isCompleteType(Loc, QualType(MPTy->getClass(), 0));
 assignInheritanceModel(*this, MPTy->getMostRecentCXXRecordDecl());
   }
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2754,6 +2754,8 @@
   << A->getAsString(Args) << A->getValue();
 }
   }
+
+  Opts.CompleteMemberPointers = Args.hasArg(OPT_fcomplete_member_pointers);
 }
 
 static bool isStrictlyPreprocessorAction(frontend::ActionKind Action) {
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -4784,6 +4784,10 @@
   CmdArgs.push_back("-fforce-enable-int128");
   }
 
+  if (Args.hasFlag(options::OPT_fcomplete_member_pointers,
+   options::OPT_fno_complete_member_pointers, false))
+CmdArgs.push_back("-fcomplete-member-pointers");
+
   // Finally add the compile command to the compilation.
   if (Args.hasArg(options::OPT__SLASH_fallback) &&
   Output.getType() == types::TY_Object &&
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -776,6 +776,12 @@
 def fparse_all_comments : Flag<["-"], "fparse-all-comments">, Group, Flags<[CC1Option]>;
 def fcommon : Flag<["-"], "fcommon">, Group;
 def fcompile_resource_EQ : Joined<["-"], "fcompile-resource=">, Group;
+def fcomplete_member_pointers : Flag<["-"], "fcomplete-member-pointers">, Group,
+   Flags<[CoreOption, CC1Option]>,
+   HelpText<"Require member pointer base types to be complete if they would be significant under the Microsoft ABI">;
+def fno_complete_member_pointers : Flag<["-"], "fno-complete-member-pointers">, Group,
+   Flags<[CoreOption]>,
+   HelpText<"Do not require member 

[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-29 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

Oh no, sorry, it actually depends on https://reviews.llvm.org/D43746; but not 
others on the chain. I changed the signatures of `wasm.get.exception` and 
`wasm.get.ehselector` intrinsics to take a token argument, and the intrinsic 
signature change is added in https://reviews.llvm.org/D43746. By the way I 
added one more line (setting the personality function wrapper as nothrow) to 
https://reviews.llvm.org/D43746 just now, so if you are ok with that, I'll land 
that and then this.


Repository:
  rC Clang

https://reviews.llvm.org/D44931



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


[PATCH] D46971: [DWARF] Get RA from RA register even if it appears unused

2018-05-29 Thread whitequark via Phabricator via cfe-commits
whitequark added a comment.

> It would be nice if we had a test case added for this

This is inherently architecture and platform specific, and libunwind currently 
doesn't have any provisions for this... In principle, would a x86-only 
Linux-only test suffice? I'm not sure if I can spend time making it more 
portable.




Comment at: src/DwarfInstructions.hpp:195
 }
+else if (i == (int)cieInfo.returnAddressRegister)
+  returnAddress = registers.getRegister(i);

compnerd wrote:
> I think that we should stick to LLVM style (coddled braces) and use C++ style 
> casts.
Ack re braces.

I was copying that cast from ten lines above. Should I change that too? This 
should be a static_cast, right?


Repository:
  rUNW libunwind

https://reviews.llvm.org/D46971



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


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-29 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added a comment.

Thanks! No, it does not depend on the other CL chain on the llvm side.


Repository:
  rC Clang

https://reviews.llvm.org/D44931



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


[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:7599-7604
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete,
+  Loc) &&
+  !MPTy->getClass()->getAsCXXRecordDecl()->isBeingDefined() &&
+  !isCompleteType(Loc, QualType(MPTy->getClass(), 0)))
+Diag(Loc, diag::warn_memptr_incomplete)
+<< QualType(MPTy->getClass(), 0);

rsmith wrote:
> It's not reasonable to call `isCompleteType` here; this is non-conforming 
> behavior, and it's not reasonable for a warning flag to change the semantics 
> or interpretation of the program. (We actually rely on this in several ways 
> -- `-Weverything` is not supposed to change the validity of programs, and 
> reuse of implicit modules with different warning flags relies on the property 
> that the compiler behavior is as if we compile with `-Weverything` and then 
> filter the warnings after the fact.)
> 
> It seems fine to do this in the MS ABI case, since we will attempt to 
> complete the type anyway in that mode. If you want to apply this more 
> generally, I think there are two options: either add a `-f` flag to carry 
> this semantic change, or figure out whether the type is completable without 
> actually completing it (for example, check whether it's a templated class 
> whose pattern is a definition).
That all seems reasonable. I think the right thing to do here is to add a 
`-fcomplete-member-pointers` flag then -- couple of reasons:
- a user of this feature would probably expect to see diagnostics in the case 
where `RequireCompleteType` would fail in MS mode;
- I'm planning to use the extra semantic information that would result from 
turning this on in IRgen when a new `-fsanitize=cfi-*` flag is enabled, which 
would mean that we would actually need to call `RequireCompleteType` at Sema 
time. I was thinking about tying the extra `RequireCompleteType` calls to the 
new `-fsanitize=cfi-*` flag, but that seems somewhat questionable as well (one 
of the main reasons is that it would be part of the `-fsanitize=cfi` group, and 
I don't want to make `-fsanitize=cfi` non-conforming), so we can probably get 
away with just a recommendation that `-fcomplete-member-pointers` is used with 
`-fsanitize=cfi`.


https://reviews.llvm.org/D47503



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


[PATCH] D46846: [AST] Fix loss of enum forward decl from decl context

2018-05-29 Thread Joel E. Denny via Phabricator via cfe-commits
jdenny updated this revision to Diff 149021.
jdenny added a comment.

Rebased.  Ping.


https://reviews.llvm.org/D46846

Files:
  lib/Sema/SemaDecl.cpp
  test/Sema/ast-print.c
  test/SemaCXX/MicrosoftCompatibility.cpp


Index: test/SemaCXX/MicrosoftCompatibility.cpp
===
--- test/SemaCXX/MicrosoftCompatibility.cpp
+++ test/SemaCXX/MicrosoftCompatibility.cpp
@@ -239,6 +239,15 @@
ENUM2_c = 0x1 // expected-warning {{enumerator value is not 
representable in the underlying type 'int'}}
 };
 
+namespace NsEnumForwardDecl {
+  enum E *p; // expected-warning {{forward references to 'enum' types are a 
Microsoft extension}}
+  extern E e;
+}
+// Clang used to complain that NsEnumForwardDecl::E was undeclared below.
+NsEnumForwardDecl::E NsEnumForwardDecl_e;
+namespace NsEnumForwardDecl {
+  extern E e;
+}
 
 namespace PR11791 {
   template
Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -4,6 +4,8 @@
 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field 
designator extension}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been 
explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is 
deprecated}}"
+// RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes2' has been 
explicitly marked deprecated here}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes3' is 
deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes3' has been 
explicitly marked deprecated here}}"
 // RUN: %clang_cc1 -fsyntax-only %t.c -verify
@@ -86,8 +88,7 @@
   // CHECK-NEXT: } *EnumWithAttributesPtr;
 } __attribute__((deprecated)) *EnumWithAttributesPtr; // expected-note 
{{'EnumWithAttributes' has been explicitly marked deprecated here}}
 
-// FIXME: If enum is forward-declared at file scope, attributes are lost.
-// CHECK-LABEL: enum EnumWithAttributes2 *EnumWithAttributes2Ptr;
+// CHECK-LABEL: enum __attribute__((deprecated(""))) EnumWithAttributes2 
*EnumWithAttributes2Ptr;
 // expected-warning@+2 {{'EnumWithAttributes2' is deprecated}}
 // expected-note@+1 {{'EnumWithAttributes2' has been explicitly marked 
deprecated here}}
 enum __attribute__((deprecated)) EnumWithAttributes2 *EnumWithAttributes2Ptr;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -14280,7 +14280,6 @@
   // PrevDecl.
   TagDecl *New;
 
-  bool IsForwardReference = false;
   if (Kind == TTK_Enum) {
 // FIXME: Tag decls should be chained to any simultaneous vardecls, e.g.:
 // enum X { A, B, C } D;D should chain to X.
@@ -14310,12 +14309,6 @@
 else if (getLangOpts().CPlusPlus)
   DiagID = diag::err_forward_ref_enum;
 Diag(Loc, DiagID);
-
-// If this is a forward-declared reference to an enumeration, make a
-// note of it; we won't actually be introducing the declaration into
-// the declaration context.
-if (TUK == TUK_Reference)
-  IsForwardReference = true;
   }
 }
 
@@ -14473,9 +14466,7 @@
 PushOnScopeChains(New, EnclosingScope, /* AddToContext = */ false);
   } else if (Name) {
 S = getNonFieldDeclScope(S);
-PushOnScopeChains(New, S, !IsForwardReference);
-if (IsForwardReference)
-  SearchDC->makeDeclVisibleInContext(New);
+PushOnScopeChains(New, S, true);
   } else {
 CurContext->addDecl(New);
   }


Index: test/SemaCXX/MicrosoftCompatibility.cpp
===
--- test/SemaCXX/MicrosoftCompatibility.cpp
+++ test/SemaCXX/MicrosoftCompatibility.cpp
@@ -239,6 +239,15 @@
 	ENUM2_c = 0x1 // expected-warning {{enumerator value is not representable in the underlying type 'int'}}
 };
 
+namespace NsEnumForwardDecl {
+  enum E *p; // expected-warning {{forward references to 'enum' types are a Microsoft extension}}
+  extern E e;
+}
+// Clang used to complain that NsEnumForwardDecl::E was undeclared below.
+NsEnumForwardDecl::E NsEnumForwardDecl_e;
+namespace NsEnumForwardDecl {
+  extern E e;
+}
 
 namespace PR11791 {
   template
Index: test/Sema/ast-print.c
===
--- test/Sema/ast-print.c
+++ test/Sema/ast-print.c
@@ -4,6 +4,8 @@
 // RUN: echo >> %t.c "// expected""-warning@* {{use of GNU old-style field designator extension}}"
 // RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes' is deprecated}}"
 // RUN: echo >> %t.c "// expected""-note@* {{'EnumWithAttributes' has been explicitly marked deprecated here}}"
+// RUN: echo >> %t.c "// expected""-warning@* {{'EnumWithAttributes2' is deprecated}}"
+// RUN: echo 

[PATCH] D46805: If some platforms do not support an attribute, we should exclude the platform

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D46805#1113358, @aaron.ballman wrote:

> @rsmith -- do the object file formats listed look correct to you?


They look at least plausible. We should be able to test whether LLVM can 
actually emit aliases on each of these targets easily enough...

However, I get this error for any WAsm compilation I try:

  fatal error: error in backend: section size does not fit in a uint32_t

... so I have no idea if aliases are/will be supported there. Perhaps @sunfish 
can tell us :)


Repository:
  rC Clang

https://reviews.llvm.org/D46805



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


r333491 - Fix test failure after r333485. Try 2.

2018-05-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May 29 19:20:40 2018
New Revision: 333491

URL: http://llvm.org/viewvc/llvm-project?rev=333491=rev
Log:
Fix test failure after r333485. Try 2.

Sorry for the breakage.

Modified:
cfe/trunk/test/Misc/diag-template-diffing.cpp

Modified: cfe/trunk/test/Misc/diag-template-diffing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing.cpp?rev=333491=333490=333491=diff
==
--- cfe/trunk/test/Misc/diag-template-diffing.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing.cpp Tue May 29 19:20:40 2018
@@ -1401,7 +1401,7 @@ void run() {
   f(1, integral_constant{});
 }
 // CHECK-ELIDE-NOTREE: error: no matching function for call to 'f'
-// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known 
conversion from 'integral_constant<[...], true>' to 'integral_constant<[...], 
false>' for 2nd argument
+// CHECK-ELIDE-NOTREE: note: candidate function template not viable: no known 
conversion from 'integral_constant<[...], true>' to 'integral_constant<[...], 
false>' for 2nd argument
 }
 
 namespace ZeroArgs {
@@ -1454,7 +1454,7 @@ void run() {
   D(VectorType());
 }
 // CHECK-ELIDE-NOTREE: error: no matching function for call to 'D'
-// CHECK-ELIDE-NOTREE: note: candidate function not viable: no known 
conversion from 'VectorType' to 'const VectorType<(TypeAlias::X)0>' for 
1st argument
+// CHECK-ELIDE-NOTREE: note: candidate function template not viable: no known 
conversion from 'VectorType' to 'const VectorType<(TypeAlias::X)0>' for 
1st argument
 }
 
 namespace TypeAlias2 {


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


Re: r333485 - [Sema] Use %sub to cleanup overload diagnostics

2018-05-29 Thread Eric Fiselier via cfe-commits
Sorry for the breakage. Fix incoming as soon as my test suite run completes.

On Tue, May 29, 2018 at 7:00 PM, Eric Fiselier via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ericwf
> Date: Tue May 29 18:00:41 2018
> New Revision: 333485
>
> URL: http://llvm.org/viewvc/llvm-project?rev=333485=rev
> Log:
> [Sema] Use %sub to cleanup overload diagnostics
>
> Summary:
> This patch adds the newly added `%sub` diagnostic modifier to cleanup
> repetition in the overload candidate diagnostics.
>
> I think this should be good to go.
>
> @rsmith: Some of the notes now emit `function template` where they only
> said `function` previously. It seems OK to me, but I would like your sign
> off on it.
>
>
> Reviewers: rsmith, EricWF
>
> Reviewed By: EricWF
>
> Subscribers: cfe-commits, rsmith
>
> Differential Revision: https://reviews.llvm.org/D47101
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/lib/Sema/SemaOverload.cpp
> cfe/trunk/test/CXX/drs/dr4xx.cpp
> cfe/trunk/test/CXX/special/class.inhctor/p1.cpp
> cfe/trunk/test/SemaCXX/attr-noreturn.cpp
> cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp
> cfe/trunk/test/SemaCXX/overload-call.cpp
> cfe/trunk/test/SemaCXX/overload-member-call.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=333485=333484=333485=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 29
> 18:00:41 2018
> @@ -3525,27 +3525,29 @@ def err_ovl_deleted_member_call : Error<
>  def note_ovl_too_many_candidates : Note<
>  "remaining %0 candidate%s0 omitted; "
>  "pass -fshow-overloads=all to show them">;
> -def note_ovl_candidate : Note<"candidate "
> -"%select{function|function|constructor|"
> -"function |function |constructor |"
> -"is the implicit default constructor|"
> -"is the implicit copy constructor|"
> -"is the implicit move constructor|"
> -"is the implicit copy assignment operator|"
> -"is the implicit move assignment operator|"
> -"inherited constructor|"
> -"inherited constructor }0%2"
> -"%select{| has different class%diff{ (expected $ but has $)|}4,5"
> -"| has different number of parameters (expected %4 but has %5)"
> -"| has type mismatch at %ordinal4 parameter"
> -"%diff{ (expected $ but has $)|}5,6"
> -"| has different return type%diff{ ($ expected but has $)|}4,5"
> +
> +def select_ovl_candidate_kind : TextSubstitution<
> +  "%select{function|function|constructor|"
> +"constructor (the implicit default constructor)|"
> +"constructor (the implicit copy constructor)|"
> +"constructor (the implicit move constructor)|"
> +"function (the implicit copy assignment operator)|"
> +"function (the implicit move assignment operator)|"
> +"inherited constructor}0%select{| template| %2}1">;
> +
> +def note_ovl_candidate : Note<
> +"candidate %sub{select_ovl_candidate_kind}0,1,3"
> +"%select{| has different class%diff{ (expected $ but has $)|}5,6"
> +"| has different number of parameters (expected %5 but has %6)"
> +"| has type mismatch at %ordinal5 parameter"
> +"%diff{ (expected $ but has $)|}6,7"
> +"| has different return type%diff{ ($ expected but has $)|}5,6"
>  "| has different qualifiers (expected "
>  "%select{none|const|restrict|const and restrict|volatile|const and
> volatile"
> -"|volatile and restrict|const, volatile, and restrict}4 but found "
> +"|volatile and restrict|const, volatile, and restrict}5 but found "
>  "%select{none|const|restrict|const and restrict|volatile|const and
> volatile"
> -"|volatile and restrict|const, volatile, and restrict}5)"
> -"| has different exception specification}3">;
> +"|volatile and restrict|const, volatile, and restrict}6)"
> +"| has different exception specification}4">;
>
>  def note_ovl_candidate_inherited_constructor : Note<
>  "constructor from base class %0 inherited here">;
> @@ -3615,225 +3617,97 @@ def note_ovl_candidate_non_deduced_misma
>
>  // Note that we don't treat templates differently for this diagnostic.
>  def note_ovl_candidate_arity : Note<"candidate "
> -"%select{function|function|constructor|function|function|
> constructor|"
> -"constructor (the implicit default constructor)|"
> -"constructor (the implicit copy constructor)|"
> -"constructor (the implicit move constructor)|"
> -"function (the implicit copy assignment operator)|"
> -"function (the implicit move assignment operator)|"
> -"inherited constructor|"
> -"inherited constructor}0 %select{|template }1"
> -"not viable: requires%select{ at least| at most|}2 %3 argument%s3,
> but %4 "
> -"%plural{1:was|:were}4 

r333489 - Make the mangled name collision diagnostic a bit more useful by listing the mangling.

2018-05-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 29 18:52:16 2018
New Revision: 333489

URL: http://llvm.org/viewvc/llvm-project?rev=333489=rev
Log:
Make the mangled name collision diagnostic a bit more useful by listing the 
mangling.

This helps especially when the collision is for a template specialization,
where the template arguments are not available from anywhere else in the
diagnostic, and are likely relevant to the problem.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
cfe/trunk/test/Sema/attr-ifunc.c

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=333489=333488=333489=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 29 18:52:16 
2018
@@ -2820,7 +2820,7 @@ def warn_alias_with_section : Warning<
   "%select{alias|ifunc}1 will not be in section '%0' but in the same section 
as the %select{aliasee|resolver}2">,
   InGroup;
 def err_duplicate_mangled_name : Error<
-  "definition with same mangled name as another definition">;
+  "definition with same mangled name '%0' as another definition">;
 def err_cyclic_alias : Error<
   "%select{alias|ifunc}0 definition is part of a cycle">;
 def err_ifunc_resolver_return : Error<

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=333489=333488=333489=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Tue May 29 18:52:16 2018
@@ -2445,8 +2445,8 @@ llvm::Constant *CodeGenModule::GetOrCrea
   (GD.getCanonicalDecl().getDecl() !=
OtherGD.getCanonicalDecl().getDecl()) &&
   DiagnosedConflictingDefinitions.insert(GD).second) {
-getDiags().Report(D->getLocation(),
-  diag::err_duplicate_mangled_name);
+getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name)
+<< MangledName;
 getDiags().Report(OtherGD.getDecl()->getLocation(),
   diag::note_previous_definition);
   }
@@ -2744,8 +2744,8 @@ CodeGenModule::GetOrCreateLLVMGlobal(Str
   (OtherD = dyn_cast(OtherGD.getDecl())) &&
   OtherD->hasInit() &&
   DiagnosedConflictingDefinitions.insert(D).second) {
-getDiags().Report(D->getLocation(),
-  diag::err_duplicate_mangled_name);
+getDiags().Report(D->getLocation(), diag::err_duplicate_mangled_name)
+<< MangledName;
 getDiags().Report(OtherGD.getDecl()->getLocation(),
   diag::note_previous_definition);
   }
@@ -3783,7 +3783,8 @@ void CodeGenModule::emitIFuncDefinition(
 GlobalDecl OtherGD;
 if (lookupRepresentativeDecl(MangledName, OtherGD) &&
 DiagnosedConflictingDefinitions.insert(GD).second) {
-  Diags.Report(D->getLocation(), diag::err_duplicate_mangled_name);
+  Diags.Report(D->getLocation(), diag::err_duplicate_mangled_name)
+  << MangledName;
   Diags.Report(OtherGD.getDecl()->getLocation(),
diag::note_previous_definition);
 }

Modified: cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp?rev=333489=333488=333489=diff
==
--- cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/duplicate-mangled-name.cpp Tue May 29 18:52:16 
2018
@@ -11,7 +11,7 @@ class MyClass {
 };
 void MyClass::meth() { } // expected-note {{previous}}
 extern "C" {
-  void _ZN7MyClass4methEv() { } // expected-error {{definition with same 
mangled name as another definition}}
+  void _ZN7MyClass4methEv() { } // expected-error {{definition with same 
mangled name '_ZN7MyClass4methEv' as another definition}}
 }
 
 #elif TEST2
@@ -49,7 +49,7 @@ float foo() {
 extern "C" void _ZN2T2D2Ev() {}; // expected-note {{previous definition is 
here}}
 
 struct T2 {
-  ~T2() {} // expected-error {{definition with same mangled name as another 
definition}}
+  ~T2() {} // expected-error {{definition with same mangled name '_ZN2T2D2Ev' 
as another definition}}
 };
 
 void foo() {
@@ -64,7 +64,7 @@ extern "C" {
 }
 
 namespace nm {
-  float abc = 2; // expected-error {{definition with same mangled name as 
another definition}}
+  float abc = 2; // expected-error {{definition with same mangled name 
'_ZN2nm3abcE' as another definition}}
 }
 
 float foo() {

Modified: cfe/trunk/test/Sema/attr-ifunc.c
URL: 

[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:7599-7604
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete,
+  Loc) &&
+  !MPTy->getClass()->getAsCXXRecordDecl()->isBeingDefined() &&
+  !isCompleteType(Loc, QualType(MPTy->getClass(), 0)))
+Diag(Loc, diag::warn_memptr_incomplete)
+<< QualType(MPTy->getClass(), 0);

It's not reasonable to call `isCompleteType` here; this is non-conforming 
behavior, and it's not reasonable for a warning flag to change the semantics or 
interpretation of the program. (We actually rely on this in several ways -- 
`-Weverything` is not supposed to change the validity of programs, and reuse of 
implicit modules with different warning flags relies on the property that the 
compiler behavior is as if we compile with `-Weverything` and then filter the 
warnings after the fact.)

It seems fine to do this in the MS ABI case, since we will attempt to complete 
the type anyway in that mode. If you want to apply this more generally, I think 
there are two options: either add a `-f` flag to carry this semantic change, or 
figure out whether the type is completable without actually completing it (for 
example, check whether it's a templated class whose pattern is a definition).


https://reviews.llvm.org/D47503



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


[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc updated this revision to Diff 149017.
pcc added a comment.

- Move the warning to RequireCompleteTypeImpl


https://reviews.llvm.org/D47503

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/warn-incomplete-member-pointers.cpp


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S;
+typedef int S::*t;
+t foo; // expected-warning {{member pointer has incomplete base type 'S'}}
+
+struct S2 {
+  int S2::*foo;
+};
+int S2::*bar;
+
+template 
+struct S3 {
+  int T::*foo;
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7585,14 +7585,23 @@
   //  assert(!T->isDependentType() &&
   // "Can't ask whether a dependent type is complete");
 
-  // We lock in the inheritance model once somebody has asked us to ensure
-  // that a pointer-to-member type is complete.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-if (const MemberPointerType *MPTy = T->getAs()) {
-  if (!MPTy->getClass()->isDependentType()) {
+  if (const MemberPointerType *MPTy = T->getAs()) {
+if (!MPTy->getClass()->isDependentType()) {
+  // We lock in the inheritance model once somebody has asked us to ensure
+  // that a pointer-to-member type is complete.
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 (void)isCompleteType(Loc, QualType(MPTy->getClass(), 0));
 assignInheritanceModel(*this, MPTy->getMostRecentCXXRecordDecl());
   }
+
+  // We only test for this warning if enabled because testing whether a 
type
+  // is complete has side effects.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete,
+  Loc) &&
+  !MPTy->getClass()->getAsCXXRecordDecl()->isBeingDefined() &&
+  !isCompleteType(Loc, QualType(MPTy->getClass(), 0)))
+Diag(Loc, diag::warn_memptr_incomplete)
+<< QualType(MPTy->getClass(), 0);
 }
   }
 
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6476,6 +6476,9 @@
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def warn_memptr_incomplete : Warning<
+  "member pointer has incomplete base type %0">,
+  InGroup>, DefaultIgnore;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S;
+typedef int S::*t;
+t foo; // expected-warning {{member pointer has incomplete base type 'S'}}
+
+struct S2 {
+  int S2::*foo;
+};
+int S2::*bar;
+
+template 
+struct S3 {
+  int T::*foo;
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -7585,14 +7585,23 @@
   //  assert(!T->isDependentType() &&
   // "Can't ask whether a dependent type is complete");
 
-  // We lock in the inheritance model once somebody has asked us to ensure
-  // that a pointer-to-member type is complete.
-  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
-if (const MemberPointerType *MPTy = T->getAs()) {
-  if (!MPTy->getClass()->isDependentType()) {
+  if (const MemberPointerType *MPTy = T->getAs()) {
+if (!MPTy->getClass()->isDependentType()) {
+  // We lock in the inheritance model once somebody has asked us to ensure
+  // that a pointer-to-member type is complete.
+  if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
 (void)isCompleteType(Loc, QualType(MPTy->getClass(), 0));
 assignInheritanceModel(*this, MPTy->getMostRecentCXXRecordDecl());
   }
+
+  // We only test for this warning if enabled because testing whether a type
+  // is complete has side effects.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete,
+  Loc) &&
+  !MPTy->getClass()->getAsCXXRecordDecl()->isBeingDefined() &&
+  !isCompleteType(Loc, QualType(MPTy->getClass(), 0)))
+Diag(Loc, diag::warn_memptr_incomplete)
+<< 

r333488 - Fix test failure after r333485.

2018-05-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May 29 18:22:14 2018
New Revision: 333488

URL: http://llvm.org/viewvc/llvm-project?rev=333488=rev
Log:
Fix test failure after r333485.

I missed adjusting a test under Misc in the last commit.
This patch updates that test.

Modified:
cfe/trunk/test/Misc/diag-template-diffing.cpp

Modified: cfe/trunk/test/Misc/diag-template-diffing.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Misc/diag-template-diffing.cpp?rev=333488=333487=333488=diff
==
--- cfe/trunk/test/Misc/diag-template-diffing.cpp (original)
+++ cfe/trunk/test/Misc/diag-template-diffing.cpp Tue May 29 18:22:14 2018
@@ -1265,7 +1265,7 @@ void test() {
   foo>(X);
 }
 // CHECK-ELIDE-NOTREE: no matching function for call to 'foo'
-// CHECK-ELIDE-NOTREE: candidate function not viable: no known conversion from 
'BoolT' to 'BoolT' for 1st argument
+// CHECK-ELIDE-NOTREE: candidate function template not viable: no known 
conversion from 'BoolT' to 'BoolT' for 1st argument
 }
 
 namespace DifferentIntegralTypes {


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


[PATCH] D47233: [CodeGen] Emit MSVC RTTI for Obj-C EH types

2018-05-29 Thread Dustin L. Howett via Phabricator via cfe-commits
DHowett-MSFT accepted this revision.
DHowett-MSFT added a comment.
This revision is now accepted and ready to land.

This largely matches what we've done in the WinObjC clang patchset here 
,
 with the critical exception that we've chosen to mangle the EH names as though 
they were for structs named after their classes.

Is there some safe generalization that will apply well to all Objective-C 
runtimes, and that we could put in a common place?

Overall, the change seems reasonable to me, but my signoff cannot constitute 
strong-enough acceptance.


Repository:
  rC Clang

https://reviews.llvm.org/D47233



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


r333486 - [ODRHash] Support FunctionTemplateDecl in records.

2018-05-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue May 29 18:12:26 2018
New Revision: 333486

URL: http://llvm.org/viewvc/llvm-project?rev=333486=rev
Log:
[ODRHash] Support FunctionTemplateDecl in records.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
cfe/trunk/lib/AST/ODRHash.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/odr_hash.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td?rev=333486=333485=333486=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSerializationKinds.td Tue May 29 
18:12:26 2018
@@ -168,11 +168,11 @@ def err_module_odr_violation_mismatch_de
   "%select{definition in module '%2'|defined here}1 found "
   "%select{end of class|public access specifier|private access specifier|"
   "protected access specifier|static assert|field|method|type alias|typedef|"
-  "data member|friend declaration}3">;
+  "data member|friend declaration|function template}3">;
 def note_module_odr_violation_mismatch_decl : Note<"but in '%0' found "
   "%select{end of class|public access specifier|private access specifier|"
   "protected access specifier|static assert|field|method|type alias|typedef|"
-  "data member|friend declaration}1">;
+  "data member|friend declaration|function template}1">;
 
 def err_module_odr_violation_mismatch_decl_diff : Error<
   "%q0 has different definitions in different modules; first difference is "
@@ -227,6 +227,18 @@ def err_module_odr_violation_mismatch_de
   "friend %select{class|function}4|"
   "friend %4|"
   "friend function %4|"
+  "function template %4 with %5 template parameter%s5|"
+  "function template %4 with %ordinal5 template parameter being a "
+"%select{type|non-type|template}6 template parameter|"
+  "function template %4 with %ordinal5 template parameter "
+"%select{with no name|named %7}6|"
+  "function template %4 with %ordinal5 template parameter with "
+"%select{no |}6default argument|"
+  "function template %4 with %ordinal5 template parameter with "
+"default argument %6|"
+  "function template %4 with %ordinal5 template parameter with one type|"
+  "function template %4 with %ordinal5 template parameter %select{not |}6"
+"being a template parameter pack|"
   "}3">;
 
 def note_module_odr_violation_mismatch_decl_diff : Note<"but in '%0' found "
@@ -280,6 +292,18 @@ def note_module_odr_violation_mismatch_d
   "friend %select{class|function}2|"
   "friend %2|"
   "friend function %2|"
+  "function template %2 with %3 template parameter%s3|"
+  "function template %2 with %ordinal3 template paramter being a "
+"%select{type|non-type|template}4 template parameter|"
+  "function template %2 with %ordinal3 template parameter "
+"%select{with no name|named %5}4|"
+  "function template %2 with %ordinal3 template parameter with "
+"%select{no |}4default argument|"
+  "function template %2 with %ordinal3 template parameter with "
+"default argument %4|"
+  "function template %2 with %ordinal3 template parameter with different type|"
+  "function template %2 with %ordinal3 template parameter %select{not |}4"
+"being a template parameter pack|"
   "}1">;
 
 def err_module_odr_violation_function : Error<

Modified: cfe/trunk/lib/AST/ODRHash.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ODRHash.cpp?rev=333486=333485=333486=diff
==
--- cfe/trunk/lib/AST/ODRHash.cpp (original)
+++ cfe/trunk/lib/AST/ODRHash.cpp Tue May 29 18:12:26 2018
@@ -383,6 +383,7 @@ public:
 if (hasDefaultArgument) {
   AddTemplateArgument(D->getDefaultArgument());
 }
+Hash.AddBoolean(D->isParameterPack());
 
 Inherited::VisitTemplateTypeParmDecl(D);
   }
@@ -395,6 +396,7 @@ public:
 if (hasDefaultArgument) {
   AddStmt(D->getDefaultArgument());
 }
+Hash.AddBoolean(D->isParameterPack());
 
 Inherited::VisitNonTypeTemplateParmDecl(D);
   }
@@ -407,9 +409,27 @@ public:
 if (hasDefaultArgument) {
   AddTemplateArgument(D->getDefaultArgument().getArgument());
 }
+Hash.AddBoolean(D->isParameterPack());
 
 Inherited::VisitTemplateTemplateParmDecl(D);
   }
+
+  void VisitTemplateDecl(const TemplateDecl *D) {
+Hash.AddTemplateParameterList(D->getTemplateParameters());
+
+Inherited::VisitTemplateDecl(D);
+  }
+
+  void VisitRedeclarableTemplateDecl(const RedeclarableTemplateDecl *D) {
+Hash.AddBoolean(D->isMemberSpecialization());
+Inherited::VisitRedeclarableTemplateDecl(D);
+  }
+
+  void VisitFunctionTemplateDecl(const FunctionTemplateDecl *D) {
+Visit(D->getTemplatedDecl());
+ID.AddInteger(D->getTemplatedDecl()->getODRHash());
+

[PATCH] D47101: [Sema] Use %sub to cleanup overload diagnostics

2018-05-29 Thread Eric Fiselier via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333485: [Sema] Use %sub to cleanup overload diagnostics 
(authored by EricWF, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47101?vs=147649=149014#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47101

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaOverload.cpp
  cfe/trunk/test/CXX/drs/dr4xx.cpp
  cfe/trunk/test/CXX/special/class.inhctor/p1.cpp
  cfe/trunk/test/SemaCXX/attr-noreturn.cpp
  cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp
  cfe/trunk/test/SemaCXX/overload-call.cpp
  cfe/trunk/test/SemaCXX/overload-member-call.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -3525,27 +3525,29 @@
 def note_ovl_too_many_candidates : Note<
 "remaining %0 candidate%s0 omitted; "
 "pass -fshow-overloads=all to show them">;
-def note_ovl_candidate : Note<"candidate "
-"%select{function|function|constructor|"
-"function |function |constructor |"
-"is the implicit default constructor|"
-"is the implicit copy constructor|"
-"is the implicit move constructor|"
-"is the implicit copy assignment operator|"
-"is the implicit move assignment operator|"
-"inherited constructor|"
-"inherited constructor }0%2"
-"%select{| has different class%diff{ (expected $ but has $)|}4,5"
-"| has different number of parameters (expected %4 but has %5)"
-"| has type mismatch at %ordinal4 parameter"
-"%diff{ (expected $ but has $)|}5,6"
-"| has different return type%diff{ ($ expected but has $)|}4,5"
+
+def select_ovl_candidate_kind : TextSubstitution<
+  "%select{function|function|constructor|"
+"constructor (the implicit default constructor)|"
+"constructor (the implicit copy constructor)|"
+"constructor (the implicit move constructor)|"
+"function (the implicit copy assignment operator)|"
+"function (the implicit move assignment operator)|"
+"inherited constructor}0%select{| template| %2}1">;
+
+def note_ovl_candidate : Note<
+"candidate %sub{select_ovl_candidate_kind}0,1,3"
+"%select{| has different class%diff{ (expected $ but has $)|}5,6"
+"| has different number of parameters (expected %5 but has %6)"
+"| has type mismatch at %ordinal5 parameter"
+"%diff{ (expected $ but has $)|}6,7"
+"| has different return type%diff{ ($ expected but has $)|}5,6"
 "| has different qualifiers (expected "
 "%select{none|const|restrict|const and restrict|volatile|const and volatile"
-"|volatile and restrict|const, volatile, and restrict}4 but found "
+"|volatile and restrict|const, volatile, and restrict}5 but found "
 "%select{none|const|restrict|const and restrict|volatile|const and volatile"
-"|volatile and restrict|const, volatile, and restrict}5)"
-"| has different exception specification}3">;
+"|volatile and restrict|const, volatile, and restrict}6)"
+"| has different exception specification}4">;
 
 def note_ovl_candidate_inherited_constructor : Note<
 "constructor from base class %0 inherited here">;
@@ -3615,225 +3617,97 @@
 
 // Note that we don't treat templates differently for this diagnostic.
 def note_ovl_candidate_arity : Note<"candidate "
-"%select{function|function|constructor|function|function|constructor|"
-"constructor (the implicit default constructor)|"
-"constructor (the implicit copy constructor)|"
-"constructor (the implicit move constructor)|"
-"function (the implicit copy assignment operator)|"
-"function (the implicit move assignment operator)|"
-"inherited constructor|"
-"inherited constructor}0 %select{|template }1"
-"not viable: requires%select{ at least| at most|}2 %3 argument%s3, but %4 "
-"%plural{1:was|:were}4 provided">;
+"%sub{select_ovl_candidate_kind}0,1,2 not viable: "
+"requires%select{ at least| at most|}3 %4 argument%s4, but %5 "
+"%plural{1:was|:were}5 provided">;
 
 def note_ovl_candidate_arity_one : Note<"candidate "
-"%select{function|function|constructor|function|function|constructor|"
-"constructor (the implicit default constructor)|"
-"constructor (the implicit copy constructor)|"
-"constructor (the implicit move constructor)|"
-"function (the implicit copy assignment operator)|"
-"function (the implicit move assignment operator)|"
-"inherited constructor|"
-"inherited constructor}0 %select{|template }1not viable: "
-"%select{requires at least|allows at most single|requires single}2 "
-"argument %3, but %plural{0:no|:%4}4 arguments were provided">;
+"%sub{select_ovl_candidate_kind}0,1,2 not viable: "
+"%select{requires at least|allows at most single|requires 

r333485 - [Sema] Use %sub to cleanup overload diagnostics

2018-05-29 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May 29 18:00:41 2018
New Revision: 333485

URL: http://llvm.org/viewvc/llvm-project?rev=333485=rev
Log:
[Sema] Use %sub to cleanup overload diagnostics

Summary:
This patch adds the newly added `%sub` diagnostic modifier to cleanup 
repetition in the overload candidate diagnostics.

I think this should be good to go.

@rsmith: Some of the notes now emit `function template` where they only said 
`function` previously. It seems OK to me, but I would like your sign off on it.


Reviewers: rsmith, EricWF

Reviewed By: EricWF

Subscribers: cfe-commits, rsmith

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/test/CXX/drs/dr4xx.cpp
cfe/trunk/test/CXX/special/class.inhctor/p1.cpp
cfe/trunk/test/SemaCXX/attr-noreturn.cpp
cfe/trunk/test/SemaCXX/cxx1y-generic-lambdas.cpp
cfe/trunk/test/SemaCXX/overload-call.cpp
cfe/trunk/test/SemaCXX/overload-member-call.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=333485=333484=333485=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue May 29 18:00:41 
2018
@@ -3525,27 +3525,29 @@ def err_ovl_deleted_member_call : Error<
 def note_ovl_too_many_candidates : Note<
 "remaining %0 candidate%s0 omitted; "
 "pass -fshow-overloads=all to show them">;
-def note_ovl_candidate : Note<"candidate "
-"%select{function|function|constructor|"
-"function |function |constructor |"
-"is the implicit default constructor|"
-"is the implicit copy constructor|"
-"is the implicit move constructor|"
-"is the implicit copy assignment operator|"
-"is the implicit move assignment operator|"
-"inherited constructor|"
-"inherited constructor }0%2"
-"%select{| has different class%diff{ (expected $ but has $)|}4,5"
-"| has different number of parameters (expected %4 but has %5)"
-"| has type mismatch at %ordinal4 parameter"
-"%diff{ (expected $ but has $)|}5,6"
-"| has different return type%diff{ ($ expected but has $)|}4,5"
+
+def select_ovl_candidate_kind : TextSubstitution<
+  "%select{function|function|constructor|"
+"constructor (the implicit default constructor)|"
+"constructor (the implicit copy constructor)|"
+"constructor (the implicit move constructor)|"
+"function (the implicit copy assignment operator)|"
+"function (the implicit move assignment operator)|"
+"inherited constructor}0%select{| template| %2}1">;
+
+def note_ovl_candidate : Note<
+"candidate %sub{select_ovl_candidate_kind}0,1,3"
+"%select{| has different class%diff{ (expected $ but has $)|}5,6"
+"| has different number of parameters (expected %5 but has %6)"
+"| has type mismatch at %ordinal5 parameter"
+"%diff{ (expected $ but has $)|}6,7"
+"| has different return type%diff{ ($ expected but has $)|}5,6"
 "| has different qualifiers (expected "
 "%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
-"|volatile and restrict|const, volatile, and restrict}4 but found "
+"|volatile and restrict|const, volatile, and restrict}5 but found "
 "%select{none|const|restrict|const and restrict|volatile|const and 
volatile"
-"|volatile and restrict|const, volatile, and restrict}5)"
-"| has different exception specification}3">;
+"|volatile and restrict|const, volatile, and restrict}6)"
+"| has different exception specification}4">;
 
 def note_ovl_candidate_inherited_constructor : Note<
 "constructor from base class %0 inherited here">;
@@ -3615,225 +3617,97 @@ def note_ovl_candidate_non_deduced_misma
 
 // Note that we don't treat templates differently for this diagnostic.
 def note_ovl_candidate_arity : Note<"candidate "
-"%select{function|function|constructor|function|function|constructor|"
-"constructor (the implicit default constructor)|"
-"constructor (the implicit copy constructor)|"
-"constructor (the implicit move constructor)|"
-"function (the implicit copy assignment operator)|"
-"function (the implicit move assignment operator)|"
-"inherited constructor|"
-"inherited constructor}0 %select{|template }1"
-"not viable: requires%select{ at least| at most|}2 %3 argument%s3, but %4 "
-"%plural{1:was|:were}4 provided">;
+"%sub{select_ovl_candidate_kind}0,1,2 not viable: "
+"requires%select{ at least| at most|}3 %4 argument%s4, but %5 "
+"%plural{1:was|:were}5 provided">;
 
 def note_ovl_candidate_arity_one : Note<"candidate "
-"%select{function|function|constructor|function|function|constructor|"
-"constructor (the implicit default constructor)|"
-"constructor 

[PATCH] D45212: Add HIP toolchain

2018-05-29 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rC333484: Add HIP toolchain (authored by yaxunl, committed by 
).

Changed prior to commit:
  https://reviews.llvm.org/D45212?vs=148277=149013#toc

Repository:
  rC Clang

https://reviews.llvm.org/D45212

Files:
  include/clang/Driver/Options.td
  lib/Driver/CMakeLists.txt
  lib/Driver/Driver.cpp
  lib/Driver/ToolChains/HIP.cpp
  lib/Driver/ToolChains/HIP.h
  test/Driver/Inputs/hip_multiple_inputs/lib1/lib1.bc
  test/Driver/Inputs/hip_multiple_inputs/lib2/lib2.bc
  test/Driver/hip-toolchain.hip

Index: lib/Driver/CMakeLists.txt
===
--- lib/Driver/CMakeLists.txt
+++ lib/Driver/CMakeLists.txt
@@ -45,6 +45,7 @@
   ToolChains/Fuchsia.cpp
   ToolChains/Gnu.cpp
   ToolChains/Haiku.cpp
+  ToolChains/HIP.cpp
   ToolChains/Hexagon.cpp
   ToolChains/Linux.cpp
   ToolChains/MipsLinux.cpp
Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -12,6 +12,7 @@
 #include "ToolChains/AMDGPU.h"
 #include "ToolChains/AVR.h"
 #include "ToolChains/Ananas.h"
+#include "ToolChains/BareMetal.h"
 #include "ToolChains/Clang.h"
 #include "ToolChains/CloudABI.h"
 #include "ToolChains/Contiki.h"
@@ -22,15 +23,15 @@
 #include "ToolChains/FreeBSD.h"
 #include "ToolChains/Fuchsia.h"
 #include "ToolChains/Gnu.h"
-#include "ToolChains/BareMetal.h"
+#include "ToolChains/HIP.h"
 #include "ToolChains/Haiku.h"
 #include "ToolChains/Hexagon.h"
 #include "ToolChains/Lanai.h"
 #include "ToolChains/Linux.h"
+#include "ToolChains/MSVC.h"
 #include "ToolChains/MinGW.h"
 #include "ToolChains/Minix.h"
 #include "ToolChains/MipsLinux.h"
-#include "ToolChains/MSVC.h"
 #include "ToolChains/Myriad.h"
 #include "ToolChains/NaCl.h"
 #include "ToolChains/NetBSD.h"
@@ -70,9 +71,9 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/StringSaver.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/StringSaver.h"
 #include 
 #include 
 #include 
@@ -540,7 +541,7 @@
   //
   // CUDA/HIP
   //
-  // We need to generate a CUDA toolchain if any of the inputs has a CUDA
+  // We need to generate a CUDA/HIP toolchain if any of the inputs has a CUDA
   // or HIP type. However, mixed CUDA/HIP compilation is not supported.
   bool IsCuda =
   llvm::any_of(Inputs, [](std::pair ) {
@@ -556,28 +557,37 @@
 Diag(clang::diag::err_drv_mix_cuda_hip);
 return;
   }
-  if (IsCuda || IsHIP) {
+  if (IsCuda) {
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple  = HostTC->getTriple();
 StringRef DeviceTripleStr;
-auto OFK = IsHIP ? Action::OFK_HIP : Action::OFK_Cuda;
-if (IsHIP) {
-  // HIP is only supported on amdgcn.
-  DeviceTripleStr = "amdgcn-amd-amdhsa";
-} else {
-  // CUDA is only supported on nvptx.
-  DeviceTripleStr = HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda"
- : "nvptx-nvidia-cuda";
-}
+auto OFK = Action::OFK_Cuda;
+DeviceTripleStr =
+HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda" : "nvptx-nvidia-cuda";
 llvm::Triple CudaTriple(DeviceTripleStr);
-// Use the CUDA/HIP and host triples as the key into the ToolChains map,
+// Use the CUDA and host triples as the key into the ToolChains map,
 // because the device toolchain we create depends on both.
 auto  = ToolChains[CudaTriple.str() + "/" + HostTriple.str()];
 if (!CudaTC) {
   CudaTC = llvm::make_unique(
   *this, CudaTriple, *HostTC, C.getInputArgs(), OFK);
 }
 C.addOffloadDeviceToolChain(CudaTC.get(), OFK);
+  } else if (IsHIP) {
+const ToolChain *HostTC = C.getSingleOffloadToolChain();
+const llvm::Triple  = HostTC->getTriple();
+StringRef DeviceTripleStr;
+auto OFK = Action::OFK_HIP;
+DeviceTripleStr = "amdgcn-amd-amdhsa";
+llvm::Triple HIPTriple(DeviceTripleStr);
+// Use the HIP and host triples as the key into the ToolChains map,
+// because the device toolchain we create depends on both.
+auto  = ToolChains[HIPTriple.str() + "/" + HostTriple.str()];
+if (!HIPTC) {
+  HIPTC = llvm::make_unique(
+  *this, HIPTriple, *HostTC, C.getInputArgs());
+}
+C.addOffloadDeviceToolChain(HIPTC.get(), OFK);
   }
 
   //
Index: lib/Driver/ToolChains/HIP.cpp
===
--- lib/Driver/ToolChains/HIP.cpp
+++ lib/Driver/ToolChains/HIP.cpp
@@ -0,0 +1,343 @@
+//===--- HIP.cpp - HIP Tool and ToolChain Implementations ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See 

r333484 - Add HIP toolchain

2018-05-29 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue May 29 17:53:50 2018
New Revision: 333484

URL: http://llvm.org/viewvc/llvm-project?rev=333484=rev
Log:
Add HIP toolchain

This patch adds HIP toolchain to support HIP language mode. It includes:

Create specific compiler jobs for HIP.

Choose specific libraries for HIP.

With contribution from Greg Rodgers.

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

Added:
cfe/trunk/lib/Driver/ToolChains/HIP.cpp
cfe/trunk/lib/Driver/ToolChains/HIP.h
cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/lib1/
cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/lib1/lib1.bc
cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/lib2/
cfe/trunk/test/Driver/Inputs/hip_multiple_inputs/lib2/lib2.bc
cfe/trunk/test/Driver/hip-toolchain.hip
Modified:
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Driver/CMakeLists.txt
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=333484=333483=333484=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May 29 17:53:50 2018
@@ -588,6 +588,10 @@ def fno_cuda_rdc : Flag<["-"], "fno-cuda
 def fcuda_short_ptr : Flag<["-"], "fcuda-short-ptr">, Flags<[CC1Option]>,
   HelpText<"Use 32-bit pointers for accessing const/local/shared address 
spaces.">;
 def fno_cuda_short_ptr : Flag<["-"], "fno-cuda-short-ptr">;
+def hip_device_lib_path_EQ : Joined<["--"], "hip-device-lib-path=">, 
Group,
+  HelpText<"HIP device library path">;
+def hip_device_lib_EQ : Joined<["--"], "hip-device-lib=">, Group,
+  HelpText<"HIP device library">;
 def fhip_dump_offload_linker_script : Flag<["-"], 
"fhip-dump-offload-linker-script">,
   Group, Flags<[NoArgumentUnused, HelpHidden]>;
 def dA : Flag<["-"], "dA">, Group;

Modified: cfe/trunk/lib/Driver/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/CMakeLists.txt?rev=333484=333483=333484=diff
==
--- cfe/trunk/lib/Driver/CMakeLists.txt (original)
+++ cfe/trunk/lib/Driver/CMakeLists.txt Tue May 29 17:53:50 2018
@@ -45,6 +45,7 @@ add_clang_library(clangDriver
   ToolChains/Fuchsia.cpp
   ToolChains/Gnu.cpp
   ToolChains/Haiku.cpp
+  ToolChains/HIP.cpp
   ToolChains/Hexagon.cpp
   ToolChains/Linux.cpp
   ToolChains/MipsLinux.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=333484=333483=333484=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue May 29 17:53:50 2018
@@ -12,6 +12,7 @@
 #include "ToolChains/AMDGPU.h"
 #include "ToolChains/AVR.h"
 #include "ToolChains/Ananas.h"
+#include "ToolChains/BareMetal.h"
 #include "ToolChains/Clang.h"
 #include "ToolChains/CloudABI.h"
 #include "ToolChains/Contiki.h"
@@ -22,15 +23,15 @@
 #include "ToolChains/FreeBSD.h"
 #include "ToolChains/Fuchsia.h"
 #include "ToolChains/Gnu.h"
-#include "ToolChains/BareMetal.h"
+#include "ToolChains/HIP.h"
 #include "ToolChains/Haiku.h"
 #include "ToolChains/Hexagon.h"
 #include "ToolChains/Lanai.h"
 #include "ToolChains/Linux.h"
+#include "ToolChains/MSVC.h"
 #include "ToolChains/MinGW.h"
 #include "ToolChains/Minix.h"
 #include "ToolChains/MipsLinux.h"
-#include "ToolChains/MSVC.h"
 #include "ToolChains/Myriad.h"
 #include "ToolChains/NaCl.h"
 #include "ToolChains/NetBSD.h"
@@ -70,9 +71,9 @@
 #include "llvm/Support/PrettyStackTrace.h"
 #include "llvm/Support/Process.h"
 #include "llvm/Support/Program.h"
+#include "llvm/Support/StringSaver.h"
 #include "llvm/Support/TargetRegistry.h"
 #include "llvm/Support/raw_ostream.h"
-#include "llvm/Support/StringSaver.h"
 #include 
 #include 
 #include 
@@ -540,7 +541,7 @@ void Driver::CreateOffloadingDeviceToolC
   //
   // CUDA/HIP
   //
-  // We need to generate a CUDA toolchain if any of the inputs has a CUDA
+  // We need to generate a CUDA/HIP toolchain if any of the inputs has a CUDA
   // or HIP type. However, mixed CUDA/HIP compilation is not supported.
   bool IsCuda =
   llvm::any_of(Inputs, [](std::pair ) 
{
@@ -556,21 +557,15 @@ void Driver::CreateOffloadingDeviceToolC
 Diag(clang::diag::err_drv_mix_cuda_hip);
 return;
   }
-  if (IsCuda || IsHIP) {
+  if (IsCuda) {
 const ToolChain *HostTC = C.getSingleOffloadToolChain();
 const llvm::Triple  = HostTC->getTriple();
 StringRef DeviceTripleStr;
-auto OFK = IsHIP ? Action::OFK_HIP : Action::OFK_Cuda;
-if (IsHIP) {
-  // HIP is only supported on amdgcn.
-  DeviceTripleStr = "amdgcn-amd-amdhsa";
-} else {
-  // CUDA is only supported on nvptx.
-  DeviceTripleStr = HostTriple.isArch64Bit() ? "nvptx64-nvidia-cuda"
-

[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/lib/Sema/SemaType.cpp:2451-2455
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);

rsmith wrote:
> This doesn't seem right. Calling `RequireCompleteType` will trigger 
> instantiation of the type if it's templated, which can affect the validity 
> (and rarely, the meaning) of the program. Also, passing a warning diagnostic 
> into `RequireCompleteType` doesn't actually work -- there are cases where it 
> will disregard your diagnostic and substitute one of its own, which will be 
> an error.
You're right, but I couldn't see a way of testing whether a type is complete 
without triggering those side effects. It does look like we can at least avoid 
some of them with `isCompleteType`, though. I guess the best we can do is to 
move the diagnostic into `RequireCompleteTypeImpl` and make it conditional on 
`isCompleteType` as @rnk suggested.


https://reviews.llvm.org/D47503



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


[PATCH] D46476: [HIP] Add action builder for HIP

2018-05-29 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
yaxunl marked an inline comment as done.
Closed by commit rC333483: Add action builder for HIP (authored by yaxunl, 
committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D46476?vs=148051=149012#toc

Repository:
  rC Clang

https://reviews.llvm.org/D46476

Files:
  lib/Driver/Driver.cpp
  test/Driver/cuda-phases.cu

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -2151,9 +2151,10 @@
 }
   };
 
-  /// CUDA action builder. It injects device code in the host backend
-  /// action.
-  class CudaActionBuilder final : public DeviceActionBuilder {
+  /// Base class for CUDA/HIP action builder. It injects device code in
+  /// the host backend action.
+  class CudaActionBuilderBase : public DeviceActionBuilder {
+  protected:
 /// Flags to signal if the user requested host-only or device-only
 /// compilation.
 bool CompileHostOnly = false;
@@ -2170,115 +2171,11 @@
 
 /// Flag that is set to true if this builder acted on the current input.
 bool IsActive = false;
-
   public:
-CudaActionBuilder(Compilation , DerivedArgList ,
-  const Driver::InputList )
-: DeviceActionBuilder(C, Args, Inputs, Action::OFK_Cuda) {}
-
-ActionBuilderReturnCode
-getDeviceDependences(OffloadAction::DeviceDependences ,
- phases::ID CurPhase, phases::ID FinalPhase,
- PhasesTy ) override {
-  if (!IsActive)
-return ABRT_Inactive;
-
-  // If we don't have more CUDA actions, we don't have any dependences to
-  // create for the host.
-  if (CudaDeviceActions.empty())
-return ABRT_Success;
-
-  assert(CudaDeviceActions.size() == GpuArchList.size() &&
- "Expecting one action per GPU architecture.");
-  assert(!CompileHostOnly &&
- "Not expecting CUDA actions in host-only compilation.");
-
-  // If we are generating code for the device or we are in a backend phase,
-  // we attempt to generate the fat binary. We compile each arch to ptx and
-  // assemble to cubin, then feed the cubin *and* the ptx into a device
-  // "link" action, which uses fatbinary to combine these cubins into one
-  // fatbin.  The fatbin is then an input to the host action if not in
-  // device-only mode.
-  if (CompileDeviceOnly || CurPhase == phases::Backend) {
-ActionList DeviceActions;
-for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-  // Produce the device action from the current phase up to the assemble
-  // phase.
-  for (auto Ph : Phases) {
-// Skip the phases that were already dealt with.
-if (Ph < CurPhase)
-  continue;
-// We have to be consistent with the host final phase.
-if (Ph > FinalPhase)
-  break;
-
-CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
-C, Args, Ph, CudaDeviceActions[I], Action::OFK_Cuda);
-
-if (Ph == phases::Assemble)
-  break;
-  }
-
-  // If we didn't reach the assemble phase, we can't generate the fat
-  // binary. We don't need to generate the fat binary if we are not in
-  // device-only mode.
-  if (!isa(CudaDeviceActions[I]) ||
-  CompileDeviceOnly)
-continue;
-
-  Action *AssembleAction = CudaDeviceActions[I];
-  assert(AssembleAction->getType() == types::TY_Object);
-  assert(AssembleAction->getInputs().size() == 1);
-
-  Action *BackendAction = AssembleAction->getInputs()[0];
-  assert(BackendAction->getType() == types::TY_PP_Asm);
-
-  for (auto  : {AssembleAction, BackendAction}) {
-OffloadAction::DeviceDependences DDep;
-DDep.add(*A, *ToolChains.front(), CudaArchToString(GpuArchList[I]),
- Action::OFK_Cuda);
-DeviceActions.push_back(
-C.MakeAction(DDep, A->getType()));
-  }
-}
-
-// We generate the fat binary if we have device input actions.
-if (!DeviceActions.empty()) {
-  CudaFatBinary =
-  C.MakeAction(DeviceActions, types::TY_CUDA_FATBIN);
-
-  if (!CompileDeviceOnly) {
-DA.add(*CudaFatBinary, *ToolChains.front(), /*BoundArch=*/nullptr,
-   Action::OFK_Cuda);
-// Clear the fat binary, it is already a dependence to an host
-// action.
-CudaFatBinary = nullptr;
-  }
-
-  // Remove the CUDA actions as they are already connected to an host
-  // action or fat binary.
-  CudaDeviceActions.clear();
-}
-
-// We avoid creating host action in device-only mode.
-return CompileDeviceOnly ? 

r333483 - Add action builder for HIP

2018-05-29 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue May 29 17:49:10 2018
New Revision: 333483

URL: http://llvm.org/viewvc/llvm-project?rev=333483=rev
Log:
Add action builder for HIP

To support separate compile/link and linking across device IR in different 
source files,
a new HIP action builder is introduced. Basically it compiles/links host and 
device
code separately, and embed fat binary in host linking stage through linker 
script.

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

Modified:
cfe/trunk/lib/Driver/Driver.cpp
cfe/trunk/test/Driver/cuda-phases.cu

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=333483=333482=333483=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue May 29 17:49:10 2018
@@ -2151,9 +2151,10 @@ class OffloadingActionBuilder final {
 }
   };
 
-  /// CUDA action builder. It injects device code in the host backend
-  /// action.
-  class CudaActionBuilder final : public DeviceActionBuilder {
+  /// Base class for CUDA/HIP action builder. It injects device code in
+  /// the host backend action.
+  class CudaActionBuilderBase : public DeviceActionBuilder {
+  protected:
 /// Flags to signal if the user requested host-only or device-only
 /// compilation.
 bool CompileHostOnly = false;
@@ -2170,115 +2171,11 @@ class OffloadingActionBuilder final {
 
 /// Flag that is set to true if this builder acted on the current input.
 bool IsActive = false;
-
   public:
-CudaActionBuilder(Compilation , DerivedArgList ,
-  const Driver::InputList )
-: DeviceActionBuilder(C, Args, Inputs, Action::OFK_Cuda) {}
-
-ActionBuilderReturnCode
-getDeviceDependences(OffloadAction::DeviceDependences ,
- phases::ID CurPhase, phases::ID FinalPhase,
- PhasesTy ) override {
-  if (!IsActive)
-return ABRT_Inactive;
-
-  // If we don't have more CUDA actions, we don't have any dependences to
-  // create for the host.
-  if (CudaDeviceActions.empty())
-return ABRT_Success;
-
-  assert(CudaDeviceActions.size() == GpuArchList.size() &&
- "Expecting one action per GPU architecture.");
-  assert(!CompileHostOnly &&
- "Not expecting CUDA actions in host-only compilation.");
-
-  // If we are generating code for the device or we are in a backend phase,
-  // we attempt to generate the fat binary. We compile each arch to ptx and
-  // assemble to cubin, then feed the cubin *and* the ptx into a device
-  // "link" action, which uses fatbinary to combine these cubins into one
-  // fatbin.  The fatbin is then an input to the host action if not in
-  // device-only mode.
-  if (CompileDeviceOnly || CurPhase == phases::Backend) {
-ActionList DeviceActions;
-for (unsigned I = 0, E = GpuArchList.size(); I != E; ++I) {
-  // Produce the device action from the current phase up to the 
assemble
-  // phase.
-  for (auto Ph : Phases) {
-// Skip the phases that were already dealt with.
-if (Ph < CurPhase)
-  continue;
-// We have to be consistent with the host final phase.
-if (Ph > FinalPhase)
-  break;
-
-CudaDeviceActions[I] = C.getDriver().ConstructPhaseAction(
-C, Args, Ph, CudaDeviceActions[I], Action::OFK_Cuda);
-
-if (Ph == phases::Assemble)
-  break;
-  }
-
-  // If we didn't reach the assemble phase, we can't generate the fat
-  // binary. We don't need to generate the fat binary if we are not in
-  // device-only mode.
-  if (!isa(CudaDeviceActions[I]) ||
-  CompileDeviceOnly)
-continue;
-
-  Action *AssembleAction = CudaDeviceActions[I];
-  assert(AssembleAction->getType() == types::TY_Object);
-  assert(AssembleAction->getInputs().size() == 1);
-
-  Action *BackendAction = AssembleAction->getInputs()[0];
-  assert(BackendAction->getType() == types::TY_PP_Asm);
-
-  for (auto  : {AssembleAction, BackendAction}) {
-OffloadAction::DeviceDependences DDep;
-DDep.add(*A, *ToolChains.front(), CudaArchToString(GpuArchList[I]),
- Action::OFK_Cuda);
-DeviceActions.push_back(
-C.MakeAction(DDep, A->getType()));
-  }
-}
-
-// We generate the fat binary if we have device input actions.
-if (!DeviceActions.empty()) {
-  CudaFatBinary =
-  C.MakeAction(DeviceActions, 
types::TY_CUDA_FATBIN);
-
-  if (!CompileDeviceOnly) {
-DA.add(*CudaFatBinary, *ToolChains.front(), /*BoundArch=*/nullptr,
-   Action::OFK_Cuda);
-  

Re: r332839 - [CodeGen] Disable aggressive structor optimizations at -O0, take 2

2018-05-29 Thread Richard Smith via cfe-commits
Sorry, this is still resulting in problems: we're seeing miscompiles and
"definition with same mangled name as another definition" errors after this
change. It seems plausible that this is a pre-existing issue that's just
being exposed by this change, but either way I've temporarily reverted this
in r333482. I'll get you more details, including steps to reproduce this,
offline.

On 21 May 2018 at 04:47, Pavel Labath via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: labath
> Date: Mon May 21 04:47:45 2018
> New Revision: 332839
>
> URL: http://llvm.org/viewvc/llvm-project?rev=332839=rev
> Log:
> [CodeGen] Disable aggressive structor optimizations at -O0, take 2
>
> The first version of the patch (r332228) was flawed because it was
> putting structors into C5/D5 comdats very eagerly. This is correct only
> if we can ensure the comdat contains all required versions of the
> structor (which wasn't the case). This version uses a more nuanced
> approach:
> - for local structor symbols we use an alias because we don't have to
>   worry about comdats or other compilation units.
> - linkonce symbols are emitted separately, as we cannot guarantee we
>   will have all symbols we need to form a comdat (they are emitted
>   lazily, only when referenced).
> - available_externally symbols are also emitted separately, as the code
>   seemed to be worried about emitting an alias in this case.
> - other linkage types are not affected by the optimization level. They
>   either get put into a comdat (weak) or get aliased (external).
>
> Reviewers: rjmccall, aprantl
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D46685
>
> Modified:
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
> cfe/trunk/test/CodeGenCXX/float16-declarations.cpp
>
> Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
> ItaniumCXXABI.cpp?rev=332839=332838=332839=diff
> 
> ==
> --- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
> +++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Mon May 21 04:47:45 2018
> @@ -3628,12 +3628,22 @@ static StructorCodegen getCodegenToUse(C
>}
>llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(
> AliasDecl);
>
> -  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
> -return StructorCodegen::RAUW;
> +  // All discardable structors can be RAUWed, but we don't want to do
> that in
> +  // unoptimized code, as that makes complete structor symbol disappear
> +  // completely, which degrades debugging experience.
> +  // Symbols with private linkage can be safely aliased, so we special
> case them
> +  // here.
> +  if (llvm::GlobalValue::isLocalLinkage(Linkage))
> +return CGM.getCodeGenOpts().OptimizationLevel > 0 ?
> StructorCodegen::RAUW
> +  :
> StructorCodegen::Alias;
>
> +  // Linkonce structors cannot be aliased nor placed in a comdat, so
> these need
> +  // to be emitted separately.
>// FIXME: Should we allow available_externally aliases?
> -  if (!llvm::GlobalAlias::isValidLinkage(Linkage))
> -return StructorCodegen::RAUW;
> +  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) ||
> +  !llvm::GlobalAlias::isValidLinkage(Linkage))
> +return CGM.getCodeGenOpts().OptimizationLevel > 0 ?
> StructorCodegen::RAUW
> +  :
> StructorCodegen::Emit;
>
>if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
>  // Only ELF and wasm support COMDATs with arbitrary names (C5/D5).
>
> Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/
> CodeGenCXX/ctor-dtor-alias.cpp?rev=332839=332838=332839=diff
> 
> ==
> --- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
> +++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Mon May 21 04:47:45 2018
> @@ -1,5 +1,7 @@
> -// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o -
> -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s
> -
> +// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o -
> -mconstructor-aliases > %t
> +// RUN: FileCheck --check-prefix=NOOPT1 --input-file=%t %s
> +// RUN: FileCheck --check-prefix=NOOPT2 --input-file=%t %s
> +// RUN: FileCheck --check-prefix=NOOPT3 --input-file=%t %s
>  // RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o -
> -mconstructor-aliases -O1 -disable-llvm-passes > %t
>  // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
>  // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
> @@ -21,6 +23,13 @@ namespace test1 {
>  // CHECK1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} comdat($_
> ZN5test16foobarIvED5Ev)
>  // CHECK1-NOT: comdat
>
> +// This should happen regardless of the opt level.
> +// 

r333482 - Revert r332839.

2018-05-29 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue May 29 17:45:10 2018
New Revision: 333482

URL: http://llvm.org/viewvc/llvm-project?rev=333482=rev
Log:
Revert r332839.

This is causing miscompiles and "definition with same mangled name as another
definition" errors.

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
cfe/trunk/test/CodeGenCXX/float16-declarations.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=333482=333481=333482=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue May 29 17:45:10 2018
@@ -3627,22 +3627,12 @@ static StructorCodegen getCodegenToUse(C
   }
   llvm::GlobalValue::LinkageTypes Linkage = CGM.getFunctionLinkage(AliasDecl);
 
-  // All discardable structors can be RAUWed, but we don't want to do that in
-  // unoptimized code, as that makes complete structor symbol disappear
-  // completely, which degrades debugging experience.
-  // Symbols with private linkage can be safely aliased, so we special case 
them
-  // here.
-  if (llvm::GlobalValue::isLocalLinkage(Linkage))
-return CGM.getCodeGenOpts().OptimizationLevel > 0 ? StructorCodegen::RAUW
-  : StructorCodegen::Alias;
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage))
+return StructorCodegen::RAUW;
 
-  // Linkonce structors cannot be aliased nor placed in a comdat, so these need
-  // to be emitted separately.
   // FIXME: Should we allow available_externally aliases?
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) ||
-  !llvm::GlobalAlias::isValidLinkage(Linkage))
-return CGM.getCodeGenOpts().OptimizationLevel > 0 ? StructorCodegen::RAUW
-  : StructorCodegen::Emit;
+  if (!llvm::GlobalAlias::isValidLinkage(Linkage))
+return StructorCodegen::RAUW;
 
   if (llvm::GlobalValue::isWeakForLinker(Linkage)) {
 // Only ELF and wasm support COMDATs with arbitrary names (C5/D5).

Modified: cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=333482=333481=333482=diff
==
--- cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/ctor-dtor-alias.cpp Tue May 29 17:45:10 2018
@@ -1,7 +1,5 @@
-// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
> %t
-// RUN: FileCheck --check-prefix=NOOPT1 --input-file=%t %s
-// RUN: FileCheck --check-prefix=NOOPT2 --input-file=%t %s
-// RUN: FileCheck --check-prefix=NOOPT3 --input-file=%t %s
+// RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
| FileCheck --check-prefix=NOOPT %s
+
 // RUN: %clang_cc1 %s -triple i686-linux -emit-llvm -o - -mconstructor-aliases 
-O1 -disable-llvm-passes > %t
 // RUN: FileCheck --check-prefix=CHECK1 --input-file=%t %s
 // RUN: FileCheck --check-prefix=CHECK2 --input-file=%t %s
@@ -23,13 +21,6 @@ namespace test1 {
 // CHECK1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
 // CHECK1-NOT: comdat
 
-// This should happen regardless of the opt level.
-// NOOPT1: @_ZN5test16foobarIvEC1Ev = weak_odr alias void {{.*}} 
@_ZN5test16foobarIvEC2Ev
-// NOOPT1: @_ZN5test16foobarIvED1Ev = weak_odr alias void 
(%"struct.test1::foobar"*), void (%"struct.test1::foobar"*)* 
@_ZN5test16foobarIvED2Ev
-// NOOPT1: define weak_odr void @_ZN5test16foobarIvEC2Ev({{.*}} 
comdat($_ZN5test16foobarIvEC5Ev)
-// NOOPT1: define weak_odr void @_ZN5test16foobarIvED2Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
-// NOOPT1: define weak_odr void @_ZN5test16foobarIvED0Ev({{.*}} 
comdat($_ZN5test16foobarIvED5Ev)
-
 // COFF doesn't support comdats with arbitrary names (C5/D5).
 // COFF: define weak_odr {{.*}} void @_ZN5test16foobarIvEC2Ev({{.*}} comdat 
align
 // COFF: define weak_odr {{.*}} void @_ZN5test16foobarIvEC1Ev({{.*}} comdat 
align
@@ -46,17 +37,12 @@ template struct foobar;
 }
 
 namespace test2 {
-// test that when the destructor is linkonce_odr we just replace every use of
+// test that when the destrucor is linkonce_odr we just replace every use of
 // C1 with C2.
 
 // CHECK1: define internal void @__cxx_global_var_init()
 // CHECK1: call void @_ZN5test26foobarIvEC2Ev
 // CHECK1: define linkonce_odr void @_ZN5test26foobarIvEC2Ev({{.*}} comdat 
align
-
-// At -O0, we should still emit the complete constructor.
-// NOOPT1: define internal void @__cxx_global_var_init()
-// NOOPT1: call void @_ZN5test26foobarIvEC1Ev
-// NOOPT1: define linkonce_odr void @_ZN5test26foobarIvEC1Ev({{.*}} comdat 
align
 void g();
 template  struct foobar {
   foobar() { g(); }
@@ -71,11 +57,6 @@ namespace test3 {
 // CHECK1: define internal 

[PATCH] D47480: clang-cl: Expose -no-canonical-prefixes

2018-05-29 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

GetExecutablePath is called here.
http://llvm-cs.pcc.me.uk/tools/clang/tools/driver/driver.cpp#427

You'll understand what I said if you see the behavior of clang-cl on windows.




Comment at: test/Driver/cl-options.c:595
+// RUN: -no-canonical-prefixes \
+// RUN: -fno-coverage-mapping \
 // RUN: --version \

Is this related to this change?


https://reviews.llvm.org/D47480



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


[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2018-05-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 149009.
EricWF added a comment.

- Fix merge conflicts.


https://reviews.llvm.org/D37035

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/SourceLocExprScope.h
  include/clang/AST/Stmt.h
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CodeGenCXX/builtin_FUNCTION.cpp
  test/CodeGenCXX/builtin_LINE.cpp
  test/CodeGenCXX/debug-info-line.cpp
  test/Parser/builtin_source_location.c
  test/Sema/source_location.c
  test/SemaCXX/Inputs/source-location-file.h
  test/SemaCXX/source_location.cpp

Index: test/SemaCXX/source_location.cpp
===
--- /dev/null
+++ test/SemaCXX/source_location.cpp
@@ -0,0 +1,475 @@
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// expected-no-diagnostics
+
+#define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
+#define CURRENT_FROM_MACRO() SL::current()
+#define FORWARD(...) __VA_ARGS__
+
+namespace std {
+namespace experimental {
+struct source_location {
+private:
+  unsigned int __m_line = 0;
+  unsigned int __m_col = 0;
+  const char *__m_file = nullptr;
+  const char *__m_func = nullptr;
+public:
+  static constexpr source_location current(
+  const char *__file = __builtin_FILE(),
+  const char *__func = __builtin_FUNCTION(),
+  unsigned int __line = __builtin_LINE(),
+  unsigned int __col = __builtin_COLUMN()) noexcept {
+source_location __loc;
+__loc.__m_line = __line;
+__loc.__m_col = __col;
+__loc.__m_file = __file;
+__loc.__m_func = __func;
+return __loc;
+  }
+  constexpr source_location() = default;
+  constexpr source_location(source_location const &) = default;
+  constexpr unsigned int line() const noexcept { return __m_line; }
+  constexpr unsigned int column() const noexcept { return __m_col; }
+  constexpr const char *file() const noexcept { return __m_file; }
+  constexpr const char *function() const noexcept { return __m_func; }
+};
+} // namespace experimental
+} // namespace std
+
+using SL = std::experimental::source_location;
+
+#include "Inputs/source-location-file.h"
+namespace SLF = source_location_file;
+
+constexpr bool is_equal(const char *LHS, const char *RHS) {
+  while (*LHS != 0 && *RHS != 0) {
+if (*LHS != *RHS)
+  return false;
+++LHS;
+++RHS;
+  }
+  return *LHS == 0 && *RHS == 0;
+}
+
+template 
+constexpr T identity(T t) {
+  return t;
+}
+
+template 
+struct Pair {
+  T first;
+  U second;
+};
+
+template 
+constexpr bool is_same = false;
+template 
+constexpr bool is_same = true;
+
+// test types
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+
+// test noexcept
+static_assert(noexcept(__builtin_LINE()));
+static_assert(noexcept(__builtin_COLUMN()));
+static_assert(noexcept(__builtin_FILE()));
+static_assert(noexcept(__builtin_FUNCTION()));
+
+//===--===//
+//__builtin_LINE()
+//===--===//
+
+namespace test_line {
+
+static_assert(SL::current().line() == __LINE__);
+static_assert(SL::current().line() == CURRENT_FROM_MACRO().line());
+
+static constexpr SL GlobalS = SL::current();
+
+static_assert(GlobalS.line() == __LINE__ - 2);
+
+// clang-format off
+constexpr bool test_line_fn() {
+  constexpr SL S = SL::current();
+  static_assert(S.line() == (__LINE__ - 1), "");
+  // The start of the call expression to `current()` begins at the token `SL`
+  constexpr int ExpectLine = __LINE__ + 3;
+  constexpr SL S2
+  =
+  SL // Call expression starts here
+  ::
+  current
+  (
+
+  )
+  ;
+  static_assert(S2.line() == ExpectLine, "");
+
+  static_assert(
+  FORWARD(
+ __builtin_LINE
+(
+)
+  )
+== __LINE__ - 1, "");
+  static_assert(\
+\
+  __builtin_LINE()\
+\
+  == __LINE__ - 2, "");
+  static_assert(\
+  _\
+_builtin_LINE()
+  == __LINE__ - 2, "");
+
+  return true;
+}
+// clang-format on
+static_assert(test_line_fn());
+
+static_assert(__builtin_LINE() == __LINE__, "");
+

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1267
+
+Z3Expr Constraints = Z3Expr::fromBoolean(false);
+

george.karpenkov wrote:
> almost certainly a bug, we shouldn't default to unfeasible when the list of 
> constraints is empty.
Ooops, sorry, now I see how the code is supposed to work.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1292
+  Constraints =
+  Z3Expr::fromBinOp(Constraints, BO_LOr, SymRange, IsSignedTy);
+}

NoQ wrote:
> george.karpenkov wrote:
> > I'm very confused as to why are we doing disjunctions here.
> I think this corresponds to RangeSet being a union of Ranges.
Ah, thanks, right! Then my previous comment regarding `false` is wrong.


https://reviews.llvm.org/D45517



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


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1292
+  Constraints =
+  Z3Expr::fromBinOp(Constraints, BO_LOr, SymRange, IsSignedTy);
+}

george.karpenkov wrote:
> I'm very confused as to why are we doing disjunctions here.
I think this corresponds to RangeSet being a union of Ranges.


https://reviews.llvm.org/D45517



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


[PATCH] D47101: [Sema] Use %sub to cleanup overload diagnostics

2018-05-29 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.

Actually I'm OK making this a post-commit review. @rsmith Please let me know if 
you have any thoughts in your own time.


Repository:
  rC Clang

https://reviews.llvm.org/D47101



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


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:496
   std::unique_ptr   ConstraintMgr;
+  std::unique_ptr   RefutationMgr;
 

See the comment below, I think we should not have this manager here. Just 
create one in the visitor constructor.



Comment at: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h:563
+
+  ConstraintManager& getRefutationManager() {
+return *RefutationMgr;

This should be deleted as well (see the comment above)



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2382
+// Reset the solver
+RefutationMgr.reset();
+  }

george.karpenkov wrote:
> (apologies in advance for nitpicking not on your code).
> 
> Currently, this is written in a stateful way: we have a solver, at each 
> iteration we add constraints, and at the end we reset it. To me it would make 
> considerably more sense to write the code in a functional style: as we go, 
> generate a vector of formulas, then once we reach the path end, create the 
> solver object, check satisfiability, and then destroy the entire solver.
Elaborating more: we are already forced to have visitor object state, let's use 
that. `RefutationMgr` is essentially a wrapper around a Z3 solver object, let's 
just create one when visitor is constructed (directly or in unique_ptr) and 
then rely on the destructor to destroy it.
Then no `reset` is necessary.



Comment at: lib/StaticAnalyzer/Core/ProgramState.cpp:83
   ConstraintMgr = (*CreateCMgr)(*this, SubEng);
+  AnalyzerOptions  = SubEng->getAnalysisManager().getAnalyzerOptions();
+  RefutationMgr = Opts.shouldCrosscheckWithZ3()

This could be removed as well (see the comment above)



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:919
 
+  void reset() override;
+

`reset` should be removed, see comments above.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1246
 
+void Z3ConstraintManager::reset() { Solver.reset(); }
+

I would remove this, see comments above.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1292
+  Constraints =
+  Z3Expr::fromBinOp(Constraints, BO_LOr, SymRange, IsSignedTy);
+}

I'm very confused as to why are we doing disjunctions here.


https://reviews.llvm.org/D45517



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


[PATCH] D47101: [Sema] Use %sub to cleanup overload diagnostics

2018-05-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

@rsmith Ping.

Do you have any objection to the addition of "template" to some of the overload 
diagnostics?


Repository:
  rC Clang

https://reviews.llvm.org/D47101



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


[PATCH] D47067: Update NRVO logic to support early return

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

Thank you, do you need someone to commit this for you?


Repository:
  rC Clang

https://reviews.llvm.org/D47067



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


[PATCH] D37035: Implement __builtin_LINE() et. al. to support source location capture.

2018-05-29 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF updated this revision to Diff 149007.
EricWF added a comment.

- Merge with upstream.

Ping.


https://reviews.llvm.org/D37035

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/AST/SourceLocExprScope.h
  include/clang/AST/Stmt.h
  include/clang/Basic/StmtNodes.td
  include/clang/Basic/TokenKinds.def
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTImporter.cpp
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprAgg.cpp
  lib/CodeGen/CGExprComplex.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CodeGenCXX/builtin_FUNCTION.cpp
  test/CodeGenCXX/builtin_LINE.cpp
  test/CodeGenCXX/debug-info-line.cpp
  test/Parser/builtin_source_location.c
  test/Sema/source_location.c
  test/SemaCXX/Inputs/source-location-file.h
  test/SemaCXX/source_location.cpp

Index: test/SemaCXX/source_location.cpp
===
--- /dev/null
+++ test/SemaCXX/source_location.cpp
@@ -0,0 +1,475 @@
+// RUN: %clang_cc1 -std=c++1z -fcxx-exceptions -fexceptions -verify %s
+// expected-no-diagnostics
+
+#define assert(...) ((__VA_ARGS__) ? ((void)0) : throw 42)
+#define CURRENT_FROM_MACRO() SL::current()
+#define FORWARD(...) __VA_ARGS__
+
+namespace std {
+namespace experimental {
+struct source_location {
+private:
+  unsigned int __m_line = 0;
+  unsigned int __m_col = 0;
+  const char *__m_file = nullptr;
+  const char *__m_func = nullptr;
+public:
+  static constexpr source_location current(
+  const char *__file = __builtin_FILE(),
+  const char *__func = __builtin_FUNCTION(),
+  unsigned int __line = __builtin_LINE(),
+  unsigned int __col = __builtin_COLUMN()) noexcept {
+source_location __loc;
+__loc.__m_line = __line;
+__loc.__m_col = __col;
+__loc.__m_file = __file;
+__loc.__m_func = __func;
+return __loc;
+  }
+  constexpr source_location() = default;
+  constexpr source_location(source_location const &) = default;
+  constexpr unsigned int line() const noexcept { return __m_line; }
+  constexpr unsigned int column() const noexcept { return __m_col; }
+  constexpr const char *file() const noexcept { return __m_file; }
+  constexpr const char *function() const noexcept { return __m_func; }
+};
+} // namespace experimental
+} // namespace std
+
+using SL = std::experimental::source_location;
+
+#include "Inputs/source-location-file.h"
+namespace SLF = source_location_file;
+
+constexpr bool is_equal(const char *LHS, const char *RHS) {
+  while (*LHS != 0 && *RHS != 0) {
+if (*LHS != *RHS)
+  return false;
+++LHS;
+++RHS;
+  }
+  return *LHS == 0 && *RHS == 0;
+}
+
+template 
+constexpr T identity(T t) {
+  return t;
+}
+
+template 
+struct Pair {
+  T first;
+  U second;
+};
+
+template 
+constexpr bool is_same = false;
+template 
+constexpr bool is_same = true;
+
+// test types
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+static_assert(is_same);
+
+// test noexcept
+static_assert(noexcept(__builtin_LINE()));
+static_assert(noexcept(__builtin_COLUMN()));
+static_assert(noexcept(__builtin_FILE()));
+static_assert(noexcept(__builtin_FUNCTION()));
+
+//===--===//
+//__builtin_LINE()
+//===--===//
+
+namespace test_line {
+
+static_assert(SL::current().line() == __LINE__);
+static_assert(SL::current().line() == CURRENT_FROM_MACRO().line());
+
+static constexpr SL GlobalS = SL::current();
+
+static_assert(GlobalS.line() == __LINE__ - 2);
+
+// clang-format off
+constexpr bool test_line_fn() {
+  constexpr SL S = SL::current();
+  static_assert(S.line() == (__LINE__ - 1), "");
+  // The start of the call expression to `current()` begins at the token `SL`
+  constexpr int ExpectLine = __LINE__ + 3;
+  constexpr SL S2
+  =
+  SL // Call expression starts here
+  ::
+  current
+  (
+
+  )
+  ;
+  static_assert(S2.line() == ExpectLine, "");
+
+  static_assert(
+  FORWARD(
+ __builtin_LINE
+(
+)
+  )
+== __LINE__ - 1, "");
+  static_assert(\
+\
+  __builtin_LINE()\
+\
+  == __LINE__ - 2, "");
+  static_assert(\
+  _\
+_builtin_LINE()
+  == __LINE__ - 2, "");
+
+  return true;
+}
+// clang-format on
+static_assert(test_line_fn());
+
+static_assert(__builtin_LINE() == __LINE__, "");
+

[PATCH] D47358: : Implement {un, }synchronized_pool_resource.

2018-05-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added inline comments.



Comment at: 
test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp:11
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+// UNSUPPORTED: apple-clang-7
+

This test comes from Eric's D27402. The default-initialization of a `const 
pool_options` object actually depends on a DR, so I needed to add `UNSUPPORTED: 
apple-clang-7`. I don't know how to determine the list of all unsupporty 
targets.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47358



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


[PATCH] D47358: : Implement {un, }synchronized_pool_resource.

2018-05-29 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone updated this revision to Diff 149006.
Quuxplusone added a comment.

Rebase and update the diff.


Repository:
  rCXX libc++

https://reviews.llvm.org/D47358

Files:
  include/experimental/memory_resource
  src/experimental/memory_resource.cpp
  test/std/experimental/memory/memory.resource.pool/pool_options.pass.cpp
  test/std/experimental/memory/memory.resource.pool/synchronized_pool.pass.cpp
  test/std/experimental/memory/memory.resource.pool/unsynchronized_pool.pass.cpp
  test/support/count_new.hpp

Index: test/support/count_new.hpp
===
--- test/support/count_new.hpp
+++ test/support/count_new.hpp
@@ -211,6 +211,11 @@
 return disable_checking || n != delete_called;
 }
 
+bool checkDeleteCalledGreaterThan(int n) const
+{
+return disable_checking || delete_called > n;
+}
+
 bool checkAlignedNewCalledEq(int n) const
 {
 return disable_checking || n == aligned_new_called;
Index: test/std/experimental/memory/memory.resource.pool/unsynchronized_pool.pass.cpp
===
--- /dev/null
+++ test/std/experimental/memory/memory.resource.pool/unsynchronized_pool.pass.cpp
@@ -0,0 +1,203 @@
+//===--===//
+//
+// 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.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03
+
+// 
+
+// class unsynchronized_pool_resource
+
+#include 
+#include 
+#include 
+#include 
+
+#include "count_new.hpp"
+
+struct assert_on_compare : public std::experimental::pmr::memory_resource
+{
+protected:
+virtual void * do_allocate(size_t, size_t)
+{ assert(false); }
+
+virtual void do_deallocate(void *, size_t, size_t)
+{ assert(false); }
+
+virtual bool do_is_equal(std::experimental::pmr::memory_resource const &) const noexcept
+{ assert(false); }
+};
+
+static bool is_aligned_to(void *p, size_t alignment)
+{
+void *p2 = p;
+size_t space = 1;
+void *result = std::align(alignment, 1, p2, space);
+return (result == p);
+}
+
+void test_construction_with_default_resource()
+{
+std::experimental::pmr::memory_resource *expected = std::experimental::pmr::null_memory_resource();
+std::experimental::pmr::set_default_resource(expected);
+{
+std::experimental::pmr::pool_options opts { 0, 0 };
+std::experimental::pmr::unsynchronized_pool_resource r1;
+std::experimental::pmr::unsynchronized_pool_resource r2(opts);
+assert(r1.upstream_resource() == expected);
+assert(r2.upstream_resource() == expected);
+}
+
+expected = std::experimental::pmr::new_delete_resource();
+std::experimental::pmr::set_default_resource(expected);
+{
+std::experimental::pmr::pool_options opts { 1024, 2048 };
+std::experimental::pmr::unsynchronized_pool_resource r1;
+std::experimental::pmr::unsynchronized_pool_resource r2(opts);
+assert(r1.upstream_resource() == expected);
+assert(r2.upstream_resource() == expected);
+}
+}
+
+void test_construction_does_not_allocate()
+{
+// Constructing a unsynchronized_pool_resource should not cause allocations
+// by itself; the resource should wait to allocate until an allocation is
+// requested.
+
+globalMemCounter.reset();
+std::experimental::pmr::set_default_resource(std::experimental::pmr::new_delete_resource());
+
+std::experimental::pmr::unsynchronized_pool_resource r1;
+assert(globalMemCounter.checkNewCalledEq(0));
+
+std::experimental::pmr::unsynchronized_pool_resource r2(std::experimental::pmr::pool_options{ 1024, 2048 });
+assert(globalMemCounter.checkNewCalledEq(0));
+
+std::experimental::pmr::unsynchronized_pool_resource r3(std::experimental::pmr::pool_options{ 1024, 2048 }, std::experimental::pmr::new_delete_resource());
+assert(globalMemCounter.checkNewCalledEq(0));
+}
+
+void test_equality()
+{
+// Same object
+{
+std::experimental::pmr::unsynchronized_pool_resource r1;
+std::experimental::pmr::unsynchronized_pool_resource r2;
+assert(r1 == r1);
+assert(r1 != r2);
+
+std::experimental::pmr::memory_resource & p1 = r1;
+std::experimental::pmr::memory_resource & p2 = r2;
+assert(p1 == p1);
+assert(p1 != p2);
+assert(p1 == r1);
+assert(r1 == p1);
+assert(p1 != r2);
+assert(r2 != p1);
+}
+// Different types
+{
+std::experimental::pmr::unsynchronized_pool_resource unsync1;
+std::experimental::pmr::memory_resource & r1 = unsync1;
+assert_on_compare c;
+std::experimental::pmr::memory_resource & r2 = c;
+

[PATCH] D45835: Add new driver mode for dumping compiler options

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

+@dlj, who had some more ambitious plans for expressing our configuration as 
JSON.

The part you have here seems fine. I share Eli's concerns about exposing our 
`LangOptions` with any kind of implied stability guarantee.


https://reviews.llvm.org/D45835



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


[PATCH] D44931: [WebAssembly] Use Windows EH instructions for Wasm EH

2018-05-29 Thread Derek Schuff via Phabricator via cfe-commits
dschuff accepted this revision.
dschuff added a comment.
This revision is now accepted and ready to land.

LGTM assuming we are convinced for now that finding the rethrow block from the 
CatchSwitch will work. Does this need to wait until after 
https://reviews.llvm.org/D43746 or other CLs from that chain, or does it matter?


Repository:
  rC Clang

https://reviews.llvm.org/D44931



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


[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In https://reviews.llvm.org/D47503#1115505, @rnk wrote:

> [...] And rewrite the side-effecting isCompleteType call to use 
> RequireCompleteType with the warning diagnostic.


We should keep the `isCompleteType` call and diagnose `if 
(!isCompleteType(...))`. `RequireCompleteType` needs an error diagnostic. (In 
particular, `RequireCompleteType` will produce an error suggesting a module 
import if a module containing the definition is known but not imported; 
`isCompleteType` will just treat the type as incomplete in that case. Don't 
`RequireCompleteType` unless you require a complete type :) )




Comment at: clang/lib/Sema/SemaType.cpp:2451-2455
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);

This doesn't seem right. Calling `RequireCompleteType` will trigger 
instantiation of the type if it's templated, which can affect the validity (and 
rarely, the meaning) of the program. Also, passing a warning diagnostic into 
`RequireCompleteType` doesn't actually work -- there are cases where it will 
disregard your diagnostic and substitute one of its own, which will be an error.


https://reviews.llvm.org/D47503



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


[libcxx] r333479 - Mark deduction guide tests as failing on apple-clang-9

2018-05-29 Thread JF Bastien via cfe-commits
Author: jfb
Date: Tue May 29 16:28:04 2018
New Revision: 333479

URL: http://llvm.org/viewvc/llvm-project?rev=333479=rev
Log:
Mark deduction guide tests as failing on apple-clang-9

As discussed here: http://lists.llvm.org/pipermail/cfe-dev/2018-May/058116.html
The tests fail on clang-5, as well as apple-clang-9. Mark them as such.

Modified:

libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp

libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp
libcxx/trunk/test/std/containers/sequences/array/array.cons/deduct.pass.cpp

libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp?rev=333479=333478=333479=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/queue/queue.cons/deduct.pass.cpp
 Tue May 29 16:28:04 2018
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// UNSUPPORTED: clang-5
+// UNSUPPORTED: clang-5, apple-clang-9
 // UNSUPPORTED: libcpp-no-deduction-guides
 // Clang 5 will generate bad implicit deduction guides
 //  Specifically, for the copy constructor.

Modified: 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp?rev=333479=333478=333479=diff
==
--- 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/containers/container.adaptors/stack/stack.cons/deduct.pass.cpp
 Tue May 29 16:28:04 2018
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// UNSUPPORTED: clang-5
+// UNSUPPORTED: clang-5, apple-clang-9
 // UNSUPPORTED: libcpp-no-deduction-guides
 // Clang 5 will generate bad implicit deduction guides
 // Specifically, for the copy constructor.

Modified: 
libcxx/trunk/test/std/containers/sequences/array/array.cons/deduct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/sequences/array/array.cons/deduct.pass.cpp?rev=333479=333478=333479=diff
==
--- libcxx/trunk/test/std/containers/sequences/array/array.cons/deduct.pass.cpp 
(original)
+++ libcxx/trunk/test/std/containers/sequences/array/array.cons/deduct.pass.cpp 
Tue May 29 16:28:04 2018
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// UNSUPPORTED: clang-5
+// UNSUPPORTED: clang-5, apple-clang-9
 // UNSUPPORTED: libcpp-no-deduction-guides
 // Clang 5 will generate bad implicit deduction guides
 // Specifically, for the copy constructor.

Modified: 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp?rev=333479=333478=333479=diff
==
--- 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/optional/optional.object/optional.object.ctor/deduct.pass.cpp
 Tue May 29 16:28:04 2018
@@ -9,7 +9,7 @@
 
 // 
 // UNSUPPORTED: c++98, c++03, c++11, c++14
-// UNSUPPORTED: clang-5
+// UNSUPPORTED: clang-5, apple-clang-9
 // UNSUPPORTED: libcpp-no-deduction-guides
 // Clang 5 will generate bad implicit deduction guides
 //  Specifically, for the copy constructor.


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


[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

Should we do this in exactly the places we would lock in an inheritance model 
in the MS ABI, i.e. when the member pointer type is required to be complete? I 
think we could take this code:

  bool Sema::RequireCompleteTypeImpl(SourceLocation Loc, QualType T,
 TypeDiagnoser *Diagnoser) {
// FIXME: Add this assertion to make sure we always get instantiation 
points.
//  assert(!Loc.isInvalid() && "Invalid location in RequireCompleteType");
// FIXME: Add this assertion to help us flush out problems with
// checking for dependent types and type-dependent expressions.
//
//  assert(!T->isDependentType() &&
// "Can't ask whether a dependent type is complete");
  
// We lock in the inheritance model once somebody has asked us to ensure
// that a pointer-to-member type is complete.
if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
  if (const MemberPointerType *MPTy = T->getAs()) {
if (!MPTy->getClass()->isDependentType()) {
  (void)isCompleteType(Loc, QualType(MPTy->getClass(), 0));
  assignInheritanceModel(*this, MPTy->getMostRecentCXXRecordDecl());
}
  }
}

And rewrite the side-effecting isCompleteType call to use RequireCompleteType 
with the warning diagnostic. I guess we would change the `isMicrosoft` check to 
alternatively check if the diagnostic is enabled. It still has the problem that 
enabling a warning can cause template instantiation errors, but oh well.


https://reviews.llvm.org/D47503



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


[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc updated this revision to Diff 149001.
pcc added a comment.

- One more negative test


https://reviews.llvm.org/D47503

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/warn-incomplete-member-pointers.cpp


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S; // expected-note {{forward declaration of 'S'}}
+typedef int S::*foo; // expected-warning {{member pointer has incomplete base 
type 'S'}}
+
+struct S2 {
+  typedef int S2::*foo;
+};
+typedef int S2::*bar;
+
+template 
+struct S3 {
+  typedef int T::*foo;
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2448,6 +2448,12 @@
 return QualType();
   }
 
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6476,6 +6476,9 @@
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def warn_memptr_incomplete : Warning<
+  "member pointer has incomplete base type %0">,
+  InGroup>, DefaultIgnore;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S; // expected-note {{forward declaration of 'S'}}
+typedef int S::*foo; // expected-warning {{member pointer has incomplete base type 'S'}}
+
+struct S2 {
+  typedef int S2::*foo;
+};
+typedef int S2::*bar;
+
+template 
+struct S3 {
+  typedef int T::*foo;
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2448,6 +2448,12 @@
 return QualType();
   }
 
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6476,6 +6476,9 @@
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def warn_memptr_incomplete : Warning<
+  "member pointer has incomplete base type %0">,
+  InGroup>, DefaultIgnore;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc updated this revision to Diff 149000.
pcc added a comment.

- Add some negative tests


https://reviews.llvm.org/D47503

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/warn-incomplete-member-pointers.cpp


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S; // expected-note {{forward declaration of 'S'}}
+typedef int S::*foo; // expected-warning {{member pointer has incomplete base 
type 'S'}}
+
+struct S2 {
+  typedef int S2::*foo;
+};
+
+template 
+struct S3 {
+  typedef int T::*foo;
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2448,6 +2448,12 @@
 return QualType();
   }
 
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6476,6 +6476,9 @@
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def warn_memptr_incomplete : Warning<
+  "member pointer has incomplete base type %0">,
+  InGroup>, DefaultIgnore;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S; // expected-note {{forward declaration of 'S'}}
+typedef int S::*foo; // expected-warning {{member pointer has incomplete base type 'S'}}
+
+struct S2 {
+  typedef int S2::*foo;
+};
+
+template 
+struct S3 {
+  typedef int T::*foo;
+};
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2448,6 +2448,12 @@
 return QualType();
   }
 
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6476,6 +6476,9 @@
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def warn_memptr_incomplete : Warning<
+  "member pointer has incomplete base type %0">,
+  InGroup>, DefaultIgnore;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D47503: Sema: Add a warning for member pointers with incomplete base types.

2018-05-29 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc created this revision.
pcc added reviewers: rnk, rsmith.

Codebases that need to be compatible with the Microsoft ABI can enable
this warning to avoid issues caused by the lack of a fixed ABI for
incomplete member pointers.


https://reviews.llvm.org/D47503

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaType.cpp
  clang/test/SemaCXX/warn-incomplete-member-pointers.cpp


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S; // expected-note {{forward declaration of 'S'}}
+typedef int S::*foo; // expected-warning {{member pointer has incomplete base 
type 'S'}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2448,6 +2448,12 @@
 return QualType();
   }
 
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6476,6 +6476,9 @@
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def warn_memptr_incomplete : Warning<
+  "member pointer has incomplete base type %0">,
+  InGroup>, DefaultIgnore;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;


Index: clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/warn-incomplete-member-pointers.cpp
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -verify -fsyntax-only -Wincomplete-member-pointers %s
+
+struct S; // expected-note {{forward declaration of 'S'}}
+typedef int S::*foo; // expected-warning {{member pointer has incomplete base type 'S'}}
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -2448,6 +2448,12 @@
 return QualType();
   }
 
+  // FIXME: This will cause errors if template instantiation fails.
+  if (!Context.getDiagnostics().isIgnored(diag::warn_memptr_incomplete, Loc) &&
+  !Class->isDependentType() &&
+  !Class->getAsCXXRecordDecl()->isBeingDefined())
+RequireCompleteType(Loc, Class, diag::warn_memptr_incomplete);
+
   // Adjust the default free function calling convention to the default method
   // calling convention.
   bool IsCtorOrDtor =
Index: clang/include/clang/Basic/DiagnosticSemaKinds.td
===
--- clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -6476,6 +6476,9 @@
 def err_bad_memptr_lhs : Error<
   "left hand operand to %0 must be a %select{|pointer to }1class "
   "compatible with the right hand operand, but is %2">;
+def warn_memptr_incomplete : Warning<
+  "member pointer has incomplete base type %0">,
+  InGroup>, DefaultIgnore;
 def warn_exception_caught_by_earlier_handler : Warning<
   "exception of type %0 will be caught by earlier handler">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46791: Make -gsplit-dwarf generally available

2018-05-29 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added inline comments.



Comment at: test/Driver/split-debug.c:23
 
+// Macosx
 // RUN: %clang -target x86_64-macosx -gsplit-dwarf -c -### %s 2> %t

NIT: macOS or the legacy spelling of Mac OS X.


https://reviews.llvm.org/D46791



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


[PATCH] D46971: [DWARF] Get RA from RA register even if it appears unused

2018-05-29 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

It would be nice if we had a test case added for this, but, seems correct to me.




Comment at: src/DwarfInstructions.hpp:195
 }
+else if (i == (int)cieInfo.returnAddressRegister)
+  returnAddress = registers.getRegister(i);

I think that we should stick to LLVM style (coddled braces) and use C++ style 
casts.


Repository:
  rUNW libunwind

https://reviews.llvm.org/D46971



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


[PATCH] D47480: clang-cl: Expose -no-canonical-prefixes

2018-05-29 Thread Nico Weber via Phabricator via cfe-commits
thakis added a subscriber: rnk.
thakis added a comment.

But GetExecutablePath isn't called if -no-canonical-prefixes is passed, is
it? (See the first link I pasted above)


https://reviews.llvm.org/D47480



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


Re: [PATCH] D47480: clang-cl: Expose -no-canonical-prefixes

2018-05-29 Thread Nico Weber via cfe-commits
But GetExecutablePath isn't called if -no-canonical-prefixes is passed, is
it? (See the first link I pasted above)

On Tue, May 29, 2018, 5:28 PM Takuto Ikuta via Phabricator via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> takuto.ikuta added a comment.
>
> On windows, argv0 is changed to absolute path before we call
> GetExecutablePath.
> That makes resource-dir absolute.
> I need clang-cl on windows has relative --resource-dir.
>
> See around heres.
>
> https://github.com/llvm-project/llvm-project-20170507/blob/83b39c10b1d7a9189b7ee646212eccf6e61dcfbf/clang/tools/driver/driver.cpp#L323
>
> https://github.com/llvm-project/llvm-project-20170507/blob/ca50c5d758541decdb59330fb15fe6b73ba6467d/llvm/lib/Support/InitLLVM.cpp#L28
>
>
> https://reviews.llvm.org/D47480
>
>
>
> ___
> 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


r333471 - Check pointer null-ness before dereferencing it.

2018-05-29 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Tue May 29 15:43:00 2018
New Revision: 333471

URL: http://llvm.org/viewvc/llvm-project?rev=333471=rev
Log:
Check pointer null-ness before dereferencing it.

-Warc-repeated-use-of-weak may trigger a segmentation fault when the Decl
being checked is outside of a function scope, leaving the current function
info pointer null.  This adds a check before using the function info.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaObjC/arc-repeated-weak.mm

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=333471=333470=333471=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue May 29 15:43:00 2018
@@ -10799,11 +10799,12 @@ void Sema::AddInitializerToDecl(Decl *Re
 // we do not warn to warn spuriously when 'x' and 'y' are on separate
 // paths through the function. This should be revisited if
 // -Wrepeated-use-of-weak is made flow-sensitive.
-if ((VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong ||
- VDecl->getType().isNonWeakInMRRWithObjCWeak(Context)) &&
-!Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
- Init->getLocStart()))
-  getCurFunction()->markSafeWeakUse(Init);
+if (FunctionScopeInfo *FSI = getCurFunction())
+  if ((VDecl->getType().getObjCLifetime() == Qualifiers::OCL_Strong ||
+   VDecl->getType().isNonWeakInMRRWithObjCWeak(Context)) &&
+  !Diags.isIgnored(diag::warn_arc_repeated_use_of_weak,
+   Init->getLocStart()))
+FSI->markSafeWeakUse(Init);
   }
 
   // The initialization is usually a full-expression.

Modified: cfe/trunk/test/SemaObjC/arc-repeated-weak.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/arc-repeated-weak.mm?rev=333471=333470=333471=diff
==
--- cfe/trunk/test/SemaObjC/arc-repeated-weak.mm (original)
+++ cfe/trunk/test/SemaObjC/arc-repeated-weak.mm Tue May 29 15:43:00 2018
@@ -479,3 +479,6 @@ void foo1() {
 // expected-error@-2{{cast of 'E' to 'INTFPtrTy' (aka 'INTF *') is disallowed 
with ARC}}
 #endif
 }
+
+@class NSString;
+static NSString* const kGlobal = @"";


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


[PATCH] D47357: [Driver] Rename DefaultTargetTriple to TargetTriple

2018-05-29 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC333468: [Driver] Rename DefaultTargetTriple to TargetTriple 
(authored by phosek, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D47357?vs=148539=148996#toc

Repository:
  rC Clang

https://reviews.llvm.org/D47357

Files:
  include/clang/Driver/Driver.h
  lib/Driver/Driver.cpp

Index: lib/Driver/Driver.cpp
===
--- lib/Driver/Driver.cpp
+++ lib/Driver/Driver.cpp
@@ -84,7 +84,7 @@
 using namespace clang;
 using namespace llvm::opt;
 
-Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
+Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine ,
IntrusiveRefCntPtr VFS)
 : Opts(createDriverOptTable()), Diags(Diags), VFS(std::move(VFS)),
@@ -94,7 +94,7 @@
   CCPrintOptionsFilename(nullptr), CCPrintHeadersFilename(nullptr),
   CCLogDiagnosticsFilename(nullptr), CCCPrintBindings(false),
   CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
-  CCGenDiagnostics(false), DefaultTargetTriple(DefaultTargetTriple),
+  CCGenDiagnostics(false), TargetTriple(TargetTriple),
   CCCGenericGCCName(""), Saver(Alloc), CheckInputsExist(true),
   CCCUsePCH(true), GenReproducer(false),
   SuppressMissingInputWarning(false) {
@@ -388,14 +388,14 @@
 /// This routine provides the logic to compute a target triple from various
 /// args passed to the driver and the default triple string.
 static llvm::Triple computeTargetTriple(const Driver ,
-StringRef DefaultTargetTriple,
+StringRef TargetTriple,
 const ArgList ,
 StringRef DarwinArchName = "") {
   // FIXME: Already done in Compilation *Driver::BuildCompilation
   if (const Arg *A = Args.getLastArg(options::OPT_target))
-DefaultTargetTriple = A->getValue();
+TargetTriple = A->getValue();
 
-  llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple));
+  llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
 
   // Handle Apple-specific options available here.
   if (Target.isOSBinFormatMachO()) {
@@ -941,19 +941,19 @@
   GenReproducer = Args.hasFlag(options::OPT_gen_reproducer,
options::OPT_fno_crash_diagnostics,
!!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"));
-  // FIXME: DefaultTargetTriple is used by the target-prefixed calls to as/ld
+  // FIXME: TargetTriple is used by the target-prefixed calls to as/ld
   // and getToolChain is const.
   if (IsCLMode()) {
 // clang-cl targets MSVC-style Win32.
-llvm::Triple T(DefaultTargetTriple);
+llvm::Triple T(TargetTriple);
 T.setOS(llvm::Triple::Win32);
 T.setVendor(llvm::Triple::PC);
 T.setEnvironment(llvm::Triple::MSVC);
 T.setObjectFormat(llvm::Triple::COFF);
-DefaultTargetTriple = T.str();
+TargetTriple = T.str();
   }
   if (const Arg *A = Args.getLastArg(options::OPT_target))
-DefaultTargetTriple = A->getValue();
+TargetTriple = A->getValue();
   if (const Arg *A = Args.getLastArg(options::OPT_ccc_install_dir))
 Dir = InstalledDir = A->getValue();
   for (const Arg *A : Args.filtered(options::OPT_B)) {
@@ -1001,7 +1001,7 @@
 
   // Owned by the host.
   const ToolChain  = getToolChain(
-  *UArgs, computeTargetTriple(*this, DefaultTargetTriple, *UArgs));
+  *UArgs, computeTargetTriple(*this, TargetTriple, *UArgs));
 
   // The compilation takes ownership of Args.
   Compilation *C = new Compilation(*this, TC, UArgs.release(), TranslatedArgs,
@@ -3665,7 +3665,7 @@
 
 if (!ArchName.empty())
   TC = (C.getArgs(),
- computeTargetTriple(*this, DefaultTargetTriple,
+ computeTargetTriple(*this, TargetTriple,
  C.getArgs(), ArchName));
 else
   TC = ();
@@ -3834,7 +3834,7 @@
 }
 
 const char *Driver::getDefaultImageName() const {
-  llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple));
+  llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
   return Target.isOSWindows() ? "a.exe" : "a.out";
 }
 
@@ -4073,14 +4073,14 @@
 void Driver::generatePrefixedToolNames(
 StringRef Tool, const ToolChain ,
 SmallVectorImpl ) const {
-  // FIXME: Needs a better variable than DefaultTargetTriple
-  Names.emplace_back((DefaultTargetTriple + "-" + Tool).str());
+  // FIXME: Needs a better variable than TargetTriple
+  Names.emplace_back((TargetTriple + "-" + Tool).str());
   Names.emplace_back(Tool);
 
   // Allow the discovery of tools prefixed with LLVM's default target triple.
-  std::string LLVMDefaultTargetTriple = llvm::sys::getDefaultTargetTriple();
-  if (LLVMDefaultTargetTriple != DefaultTargetTriple)
-

r333468 - [Driver] Rename DefaultTargetTriple to TargetTriple

2018-05-29 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue May 29 15:35:39 2018
New Revision: 333468

URL: http://llvm.org/viewvc/llvm-project?rev=333468=rev
Log:
[Driver] Rename DefaultTargetTriple to TargetTriple

While this value is initialized with the DefaultTargetTriple, it
can be later overriden using the -target flag so TargetTriple is
a more accurate name. This change also provides an accessor which
could be accessed from ToolChain implementations.

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

Modified:
cfe/trunk/include/clang/Driver/Driver.h
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=333468=333467=333468=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Tue May 29 15:35:39 2018
@@ -202,8 +202,8 @@ public:
   unsigned CCGenDiagnostics : 1;
 
 private:
-  /// Default target triple.
-  std::string DefaultTargetTriple;
+  /// Raw target triple.
+  std::string TargetTriple;
 
   /// Name to use when invoking gcc/g++.
   std::string CCCGenericGCCName;
@@ -282,7 +282,7 @@ private:
   SmallString<128> );
 
 public:
-  Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
+  Driver(StringRef ClangExecutable, StringRef TargetTriple,
  DiagnosticsEngine ,
  IntrusiveRefCntPtr VFS = nullptr);
 
@@ -309,6 +309,8 @@ public:
   const std::string () { return DriverTitle; }
   void setTitle(std::string Value) { DriverTitle = std::move(Value); }
 
+  std::string getTargetTriple() const { return TargetTriple; }
+
   /// Get the path to the main clang executable.
   const char *getClangProgramPath() const {
 return ClangExecutable.c_str();

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=333468=333467=333468=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Tue May 29 15:35:39 2018
@@ -84,7 +84,7 @@ using namespace clang::driver;
 using namespace clang;
 using namespace llvm::opt;
 
-Driver::Driver(StringRef ClangExecutable, StringRef DefaultTargetTriple,
+Driver::Driver(StringRef ClangExecutable, StringRef TargetTriple,
DiagnosticsEngine ,
IntrusiveRefCntPtr VFS)
 : Opts(createDriverOptTable()), Diags(Diags), VFS(std::move(VFS)),
@@ -94,7 +94,7 @@ Driver::Driver(StringRef ClangExecutable
   CCPrintOptionsFilename(nullptr), CCPrintHeadersFilename(nullptr),
   CCLogDiagnosticsFilename(nullptr), CCCPrintBindings(false),
   CCPrintOptions(false), CCPrintHeaders(false), CCLogDiagnostics(false),
-  CCGenDiagnostics(false), DefaultTargetTriple(DefaultTargetTriple),
+  CCGenDiagnostics(false), TargetTriple(TargetTriple),
   CCCGenericGCCName(""), Saver(Alloc), CheckInputsExist(true),
   CCCUsePCH(true), GenReproducer(false),
   SuppressMissingInputWarning(false) {
@@ -388,14 +388,14 @@ DerivedArgList *Driver::TranslateInputAr
 /// This routine provides the logic to compute a target triple from various
 /// args passed to the driver and the default triple string.
 static llvm::Triple computeTargetTriple(const Driver ,
-StringRef DefaultTargetTriple,
+StringRef TargetTriple,
 const ArgList ,
 StringRef DarwinArchName = "") {
   // FIXME: Already done in Compilation *Driver::BuildCompilation
   if (const Arg *A = Args.getLastArg(options::OPT_target))
-DefaultTargetTriple = A->getValue();
+TargetTriple = A->getValue();
 
-  llvm::Triple Target(llvm::Triple::normalize(DefaultTargetTriple));
+  llvm::Triple Target(llvm::Triple::normalize(TargetTriple));
 
   // Handle Apple-specific options available here.
   if (Target.isOSBinFormatMachO()) {
@@ -941,19 +941,19 @@ Compilation *Driver::BuildCompilation(Ar
   GenReproducer = Args.hasFlag(options::OPT_gen_reproducer,
options::OPT_fno_crash_diagnostics,
!!::getenv("FORCE_CLANG_DIAGNOSTICS_CRASH"));
-  // FIXME: DefaultTargetTriple is used by the target-prefixed calls to as/ld
+  // FIXME: TargetTriple is used by the target-prefixed calls to as/ld
   // and getToolChain is const.
   if (IsCLMode()) {
 // clang-cl targets MSVC-style Win32.
-llvm::Triple T(DefaultTargetTriple);
+llvm::Triple T(TargetTriple);
 T.setOS(llvm::Triple::Win32);
 T.setVendor(llvm::Triple::PC);
 T.setEnvironment(llvm::Triple::MSVC);
 T.setObjectFormat(llvm::Triple::COFF);
-DefaultTargetTriple = T.str();
+TargetTriple = T.str();
   }
   if (const Arg *A = Args.getLastArg(options::OPT_target))
-

[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-29 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: lib/Lex/HeaderSearch.cpp:753-754
+  IncluderAndDir.second->getName()))
+Diags.Report(IncludeLoc,
+ diag::warn_quoted_include_in_framework_header)
+<< Filename;

bruno wrote:
> aaron.ballman wrote:
> > This seems like a good place for a fix-it to switch the include style. Is 
> > there a reason to not do that work for the user?
> Like I explained above, we don't know which framework the header could be 
> part of, so a fix-it could be misleading.
Clang supports editor placeholders, which we use in some refactoring-style 
fix-its.  I think this would be spelled `<#framework-name#>`, or `#include 
<<#framework-name#>/Foo.h>`


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


[PATCH] D45012: [Modules] Skip adding unused module maps to the dependency file

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

This feature seems reasonable to me.




Comment at: lib/Frontend/DependencyFile.cpp:206-223
 class DFGMMCallback : public ModuleMapCallbacks {
   DFGImpl 
 public:
   DFGMMCallback(DFGImpl ) : Parent(Parent) {}
   void moduleMapFileRead(SourceLocation Loc, const FileEntry ,
  bool IsSystem) override {
+if (Parent.skipUnusedModuleMaps())

I wonder whether it'd be clearer to have two different callbacks for the two 
behaviors here, rather than one callback that essentially does one of two 
completely different things.



Comment at: lib/Lex/ModuleMap.cpp:728-735
+// Notify callbacks that we found a module map for the module.
+if (!M->DefinitionLoc.isInvalid())
+  for (const auto  : Callbacks)
+Cb->moduleMapFoundForModule(
+*getContainingModuleMapFile(M), M,
+SourceMgr.getFileCharacteristic(M->DefinitionLoc) ==
+SrcMgr::C_System_ModuleMap);

Does the right thing happen when we load module map information from a PCM file?

I'm also worried that this will fire at the wrong times (eg, more than once per 
module, or not at all if the module is only ever found by header lookup). 
Perhaps we should instead trigger the callback when the module is first 
imported?


Repository:
  rC Clang

https://reviews.llvm.org/D45012



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


[libcxx] r333467 - Fix embarrasing typo in uncaught_exceptions. Update tests to really test this. Thanks to Peter Klotz for calling my attention to this.

2018-05-29 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue May 29 15:25:42 2018
New Revision: 333467

URL: http://llvm.org/viewvc/llvm-project?rev=333467=rev
Log:
Fix embarrasing typo in uncaught_exceptions. Update tests to really test this. 
Thanks to Peter Klotz for calling my attention to this.

Modified:
libcxx/trunk/src/support/runtime/exception_libcxxabi.ipp

libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp

Modified: libcxx/trunk/src/support/runtime/exception_libcxxabi.ipp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/support/runtime/exception_libcxxabi.ipp?rev=333467=333466=333467=diff
==
--- libcxx/trunk/src/support/runtime/exception_libcxxabi.ipp (original)
+++ libcxx/trunk/src/support/runtime/exception_libcxxabi.ipp Tue May 29 
15:25:42 2018
@@ -18,7 +18,7 @@ bool uncaught_exception() _NOEXCEPT { re
 
 int uncaught_exceptions() _NOEXCEPT
 {
-# if _LIBCPPABI_VERSION > 1101
+# if _LIBCPPABI_VERSION > 1001
 return __cxa_uncaught_exceptions();
 # else
 return __cxa_uncaught_exception() ? 1 : 0;

Modified: 
libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp?rev=333467=333466=333467=diff
==
--- 
libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/language.support/support.exception/uncaught/uncaught_exceptions.pass.cpp
 Tue May 29 15:25:42 2018
@@ -15,40 +15,48 @@
 // XFAIL: availability=macosx10.9
 // XFAIL: availability=macosx10.10
 // XFAIL: availability=macosx10.11
+// XFAIL: with_system_cxx_lib=macosx10.12
+// XFAIL: with_system_cxx_lib=macosx10.13
 
 // test uncaught_exceptions
 
 #include 
 #include 
 
-struct A
-{
-~A()
-{
-assert(std::uncaught_exceptions() > 0);
-}
-};
+struct Uncaught {
+Uncaught(int depth) : d_(depth) {}
+~Uncaught() { assert(std::uncaught_exceptions() == d_); }
+int d_;
+};
 
-struct B
-{
-B()
-{
-// http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#475
-assert(std::uncaught_exceptions() == 0);
+struct Outer {
+Outer(int depth) : d_(depth) {}
+~Outer() {
+try {
+assert(std::uncaught_exceptions() == d_);
+Uncaught u(d_+1);
+throw 2;
 }
+catch (int) {}
+}
+int d_;
 };
 
-int main()
-{
-try
+int main () {
+assert(std::uncaught_exceptions() == 0);
 {
-A a;
-assert(std::uncaught_exceptions() == 0);
-throw B();
+Outer o(0);
 }
-catch (...)
+
+assert(std::uncaught_exceptions() == 0);
 {
-assert(std::uncaught_exception() == 0);
+try {
+Outer o(1);
+throw 1;
+}
+catch (int) {
+assert(std::uncaught_exceptions() == 0);
+}   
 }
 assert(std::uncaught_exceptions() == 0);
 }


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


[PATCH] D47157: Warning for framework headers using double quote includes

2018-05-29 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> Consistency would be nice, but at the same time, I don't see a good metric 
> for when we'd know it's time to switch it to being on by default. I'm worried 
> that it'll remain off by default forever simply because no one thinks to go 
> turn it on (because it's silent by default). Perhaps on-by-default here and 
> off-by-default downstream would be the better approach, or do you think this 
> would be too disruptive to enable by default anywhere?

I believe this could be too disruptive to enable now, since it's still very 
common to find quoted includes in framework headers. This is very important for 
Modules to properly work with frameworks (quoted headers are usually considered 
non-modular when modules builds kick in) and is actually very compelling for us 
to turn it on by default on Darwin as soon as we can, but we need to educate 
users first.




Comment at: include/clang/Basic/DiagnosticLexKinds.td:713
+def warn_quoted_include_in_framework_header : Warning<
+  "double-quoted include \"%0\" in framework header, expected system style 
 include"
+  >, InGroup, DefaultIgnore;

aaron.ballman wrote:
> 80-col limit?
> 
> Also, I'd probably drop "system style" and reword slightly to:
> 
> `"double-quoted include \"%0\" in framework header, expected angle-bracketed 
> include <%0> instead"`
Unfortunately this won't work because for framework style includes we use the 
angled-bracketed with the framework name. For example, if one wants to include 
`Foo.h` from `Foo.framework`, one should use `#include `, although 
on disk you actually have `Foo.framework/Headers/Foo.h`. Framework header 
lookup does this magic and other similar ones.

Since we don't know which framework the quoted header could be part of, it was 
not included in the warning (doing so would require extra header searches - 
which could be expensive for this specific warning). However it seems that I 
can do better to indicate that the framework name is desired here, perhaps:

`"double-quoted include \"%0\" in framework header, expected angle-bracketed 
include  instead"`

How does that sound to you? Other suggestions?



Comment at: lib/Lex/HeaderSearch.cpp:753-754
+  IncluderAndDir.second->getName()))
+Diags.Report(IncludeLoc,
+ diag::warn_quoted_include_in_framework_header)
+<< Filename;

aaron.ballman wrote:
> This seems like a good place for a fix-it to switch the include style. Is 
> there a reason to not do that work for the user?
Like I explained above, we don't know which framework the header could be part 
of, so a fix-it could be misleading.


Repository:
  rC Clang

https://reviews.llvm.org/D47157



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


[PATCH] D47499: [analyzer] Annotate program state update methods with LLVM_NODISCARD.

2018-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ created this revision.
NoQ added reviewers: dcoughlin, xazax.hun, a.sidorin, george.karpenkov, szepet, 
rnkovacs, baloghadamsoftware.
Herald added a subscriber: cfe-commits.

A follow-up to https://reviews.llvm.org/D47496.

This would warn the developer on the very common bug that consists in writing, 
eg., `State->set(Key, Value)` instead of `State = State->set(Key, 
Value)`. Because in the first snippet the updated `State` object is discarded 
while the original object remains unchanged (because it's, well, immutable), 
which isn't what you ever want to do.

For now no such bugs were found in the analyzer, but i made these mistakes 
myself knowingly and i see many such bugs during code review.


Repository:
  rC Clang

https://reviews.llvm.org/D47499

Files:
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h

Index: include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
===
--- include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
+++ include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
@@ -177,38 +177,38 @@
   ///
   /// This returns a new state with the added constraint on \p cond.
   /// If no new state is feasible, NULL is returned.
-  ProgramStateRef assume(DefinedOrUnknownSVal cond, bool assumption) const;
+  LLVM_NODISCARD ProgramStateRef assume(DefinedOrUnknownSVal cond,
+bool assumption) const;
 
   /// Assumes both "true" and "false" for \p cond, and returns both
   /// corresponding states (respectively).
   ///
   /// This is more efficient than calling assume() twice. Note that one (but not
   /// both) of the returned states may be NULL.
-  std::pair
+  LLVM_NODISCARD std::pair
   assume(DefinedOrUnknownSVal cond) const;
 
-  ProgramStateRef assumeInBound(DefinedOrUnknownSVal idx,
-   DefinedOrUnknownSVal upperBound,
-   bool assumption,
-   QualType IndexType = QualType()) const;
+  LLVM_NODISCARD ProgramStateRef
+  assumeInBound(DefinedOrUnknownSVal idx, DefinedOrUnknownSVal upperBound,
+bool assumption, QualType IndexType = QualType()) const;
 
   /// Assumes that the value of \p Val is bounded with [\p From; \p To]
   /// (if \p assumption is "true") or it is fully out of this range
   /// (if \p assumption is "false").
   ///
   /// This returns a new state with the added constraint on \p cond.
   /// If no new state is feasible, NULL is returned.
-  ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
-   const llvm::APSInt ,
-   const llvm::APSInt ,
-   bool assumption) const;
+  LLVM_NODISCARD ProgramStateRef assumeInclusiveRange(DefinedOrUnknownSVal Val,
+  const llvm::APSInt ,
+  const llvm::APSInt ,
+  bool assumption) const;
 
   /// Assumes given range both "true" and "false" for \p Val, and returns both
   /// corresponding states (respectively).
   ///
   /// This is more efficient than calling assume() twice. Note that one (but not
   /// both) of the returned states may be NULL.
-  std::pair
+  LLVM_NODISCARD std::pair
   assumeInclusiveRange(DefinedOrUnknownSVal Val, const llvm::APSInt ,
const llvm::APSInt ) const;
 
@@ -232,30 +232,32 @@
 
   /// Create a new state by binding the value 'V' to the statement 'S' in the
   /// state's environment.
-  ProgramStateRef BindExpr(const Stmt *S, const LocationContext *LCtx,
-   SVal V, bool Invalidate = true) const;
+  LLVM_NODISCARD ProgramStateRef BindExpr(const Stmt *S,
+  const LocationContext *LCtx, SVal V,
+  bool Invalidate = true) const;
 
-  ProgramStateRef bindLoc(Loc location,
-  SVal V,
-  const LocationContext *LCtx,
-  bool notifyChanges = true) const;
+  LLVM_NODISCARD ProgramStateRef bindLoc(Loc location, SVal V,
+ const LocationContext *LCtx,
+ bool notifyChanges = true) const;
 
-  ProgramStateRef bindLoc(SVal location, SVal V, const LocationContext *LCtx) const;
+  LLVM_NODISCARD ProgramStateRef bindLoc(SVal location, SVal V,
+ const LocationContext *LCtx) const;
 
   /// Initializes the region of memory represented by \p loc with an initial
   /// value. Once initialized, all values loaded from any sub-regions of that
   /// region will be equal to \p V, unless overwritten later by the program.
   /// This method should not be used on regions that are already initialized.
   /// 

[PATCH] D45012: [Modules] Skip adding unused module maps to the dependency file

2018-05-29 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping


Repository:
  rC Clang

https://reviews.llvm.org/D45012



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


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

2018-05-29 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.

Ping!


https://reviews.llvm.org/D46485



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


[PATCH] D47290: [Sema] -Wformat-pedantic only for NSInteger/NSUInteger %zu/%zi on Darwin

2018-05-29 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D47290#1113422, @aaron.ballman wrote:

> In https://reviews.llvm.org/D47290#1113412, @jfb wrote:
>
> > In https://reviews.llvm.org/D47290#1113365, @aaron.ballman wrote:
> >
> > > This is relaxing `-Wformat` and making users instead write 
> > > `-Wformat-pedantic` to get the strong guarantees, which is the opposite 
> > > of what I thought the consensus was. Have I misunderstood something?
> >
> >
> > From Shoaib's email:
> >
> > > Based on all the discussion so far, I think the consensus is that we 
> > > don't want to relax -Wformat by default, but an additional relaxed option 
> > > would be fine. That works for me (where I can just switch my codebases to 
> > > use the new warning option), but it wouldn't handle JF Bastien's use 
> > > case, so he would still want to pursue the relaxations specific to Apple 
> > > platforms.
> >
> > This patch is specific to the Darwin platform, as proposed in Alex' 
> > original patch and as I promised to do in the cfe-dev thread. Shoaib's 
> > follow-up would be different and do what I think you're referring to.
>
>
> There were several people on the thread asking to not relax -Wformat for any 
> target, but instead wanted a separate warning flag to perform a more relaxed 
> check.
>
> http://lists.llvm.org/pipermail/cfe-dev/2018-May/057938.html


I don't think this one is talking about platform-specific warnings, I therefore 
don't think it applies to this patch.

> http://lists.llvm.org/pipermail/cfe-dev/2018-May/058030.html
>  http://lists.llvm.org/pipermail/cfe-dev/2018-May/058039.html

Hans' comment and your +1 are on-topic here, and are the only ones AFAIK 
(others don't care or explicitly agree with this patch). What I'd like to 
emphasize is that the new stricter warnings are causing issues for developers 
on our platform. The warnings are new, and they don't help developers because 
the platform guarantees that their code is fine. That frustrates developers 
because they *know* that we know better (they might even find this discussion 
when searching! ), yet we chose to come in and warn them anyways. I have yet 
to hear a reason why we're doing them a service by warning in this case. It 
really has the feel of a pedantic warning, and that's what this patch makes it.

I'll quote James  
slightly out of context:

> No, this actually has been a thorn in the side of some people at google,
>  causing a good deal of angst (only for a very small number of people,
>  granted). I'd not truly put the blame on the warning, but rather on printf
>  itself -- and that we're still USING printf (and other functions that
>  ultimately wrap printf) all over the place. The long-term plan is certainly
>  to switch to better APIs. But, it'd be nice to be able to reduce the issue
>  in the meantime.
> 
> The problem we have is that Google has an internal "int64" typedef, which
>  predates the availability of C99 "int64_t". We'd like to eliminate this,
>  and switch everything over to using the standard int64_t. (Well, really
>  we'd've liked to have done that years ago...) However, "int64" is defined
>  as "long long", while "int64_t" is defined as "long" on 64-bit linux. A
>  bunch of printf specifiers all throughout the codebase use %lld. This
>  mismatching type-specifier makes it quite difficult to change the
>  type. Automatically updating all the format strings has not been found to
>  be easy.
> 
> If we could eliminate the warning on mismatch of "%lld" vs "long", on a
>  platform where they're the same, that could make things a whole lot easier.

It seems Hans' comment came from the sentiment "warning is the right thing to 
do, and from Google's vast experience it's not a problem". James provides a 
counter-point in line with ours: we receive exactly that feedback for NSInteger 
and `%z`. The code exists, it works fine, the platform guarantees it'll keep 
working fine, and now a tonne of "useless" warnings come in. That's frustrating 
because it means developers have these options:

- Useless code churn in code that otherwise won't change, ever
- Silence the warning, potentially silencing useful warnings later (because 
-Wformat-relaxed could start doing more things)

That's frustrating when you update compilers, especially if your update is 
incremental because only some developers see the warning. It means people are 
reluctant to update, because the first thing they see is us being pedants, not 
the cool new features we bring in. If they saw a flood of really useful 
warnings instead they'd be happy,  but even there they get drowned by these 
format warnings... Kind of a shit sandwich if you'll pardon the graphic 
description.

Hopefully this makes sense? I'm not sure I summarize my context very well. I'm 
happy to talk about it in-person next week too.


Repository:
  rC Clang

https://reviews.llvm.org/D47290




[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-05-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added inline comments.



Comment at: include/clang/Basic/X86Target.def:295
+CPU_SPECIFIC("pentium_iii", 'H',
+ (1ULL << FEATURE_CMOV | 1ULL << FEATURE_MMX | 1ULL << 
FEATURE_SSE))
+CPU_SPECIFIC("pentium_iii_no_xmm_regs", 'H',

Could we just make the features a comma separated string? Then we wouldn't need 
a third version of EmitX86CpuSupports? Yeah it would incur string processing 
costs, but is that a big deal?



Comment at: lib/Sema/SemaDecl.cpp:9214
+return MultiVersioning::Target;
+  else if (FD->hasAttr())
+return MultiVersioning::CpuDispatch;

No need for else after return.



Comment at: lib/Sema/SemaDeclAttr.cpp:1901
+const TargetInfo  = S.Context.getTargetInfo();
+if (llvm::find_if(Cpus, [CpuName, ](const IdentifierInfo *Cur) {
+  return Target.cpuSpecificManglingCharacter(CpuName) ==

Maybe use llvm::any_of since you don't actually care about the iterator 
returned.


https://reviews.llvm.org/D47474



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


[PATCH] D47480: clang-cl: Expose -no-canonical-prefixes

2018-05-29 Thread Takuto Ikuta via Phabricator via cfe-commits
takuto.ikuta added a comment.

On windows, argv0 is changed to absolute path before we call GetExecutablePath.
That makes resource-dir absolute.
I need clang-cl on windows has relative --resource-dir.

See around heres.
https://github.com/llvm-project/llvm-project-20170507/blob/83b39c10b1d7a9189b7ee646212eccf6e61dcfbf/clang/tools/driver/driver.cpp#L323
https://github.com/llvm-project/llvm-project-20170507/blob/ca50c5d758541decdb59330fb15fe6b73ba6467d/llvm/lib/Support/InitLLVM.cpp#L28


https://reviews.llvm.org/D47480



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


[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-05-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 148977.

https://reviews.llvm.org/D47474

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Basic/X86Target.def
  lib/AST/Decl.cpp
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Parse/ParseDecl.cpp
  lib/Sema/AnalysisBasedWarnings.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaOverload.cpp
  test/CodeGen/attr-cpuspecific.c
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/Sema/attr-cpuspecific.c
  test/SemaCXX/attr-cpuspecific.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -1173,6 +1173,13 @@
 }
   };
 
+  class VariadicIdentifierArgument : public VariadicArgument {
+  public:
+VariadicIdentifierArgument(const Record , StringRef Attr)
+  : VariadicArgument(Arg, Attr, "IdentifierInfo *")
+{}
+  };
+
   class VariadicStringArgument : public VariadicArgument {
   public:
 VariadicStringArgument(const Record , StringRef Attr)
@@ -1278,6 +1285,8 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "ParamIdxArgument")
 Ptr = llvm::make_unique(Arg, Attr, "ParamIdx");
+  else if (ArgName == "VariadicIdentifierArgument")
+Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VersionArgument")
 Ptr = llvm::make_unique(Arg, Attr);
 
@@ -2106,6 +2115,34 @@
 .Default(false);
 }
 
+static bool isVariadicIdentifierArgument(Record *Arg) {
+  return !Arg->getSuperClasses().empty() &&
+ llvm::StringSwitch(
+ Arg->getSuperClasses().back().first->getName())
+ .Case("VariadicIdentifierArgument", true)
+ .Default(false);
+}
+
+static void emitClangAttrVariadicIdentifierArgList(RecordKeeper ,
+   raw_ostream ) {
+  OS << "#if defined(CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST)\n";
+  std::vector Attrs = Records.getAllDerivedDefinitions("Attr");
+  for (const auto *Attr : Attrs) {
+// Determine whether the first argument is a variadic identifier.
+std::vector Args = Attr->getValueAsListOfDefs("Args");
+if (Args.empty() || !isVariadicIdentifierArgument(Args[0]))
+  continue;
+
+// All these spellings take an identifier argument.
+forEachUniqueSpelling(*Attr, [&](const FlattenedSpelling ) {
+  OS << ".Case(\"" << S.name() << "\", "
+ << "true"
+ << ")\n";
+});
+  }
+  OS << "#endif // CLANG_ATTR_VARIADIC_IDENTIFIER_ARG_LIST\n\n";
+}
+
 // Emits the first-argument-is-identifier property for attributes.
 static void emitClangAttrIdentifierArgList(RecordKeeper , raw_ostream ) {
   OS << "#if defined(CLANG_ATTR_IDENTIFIER_ARG_LIST)\n";
@@ -3696,6 +3733,7 @@
   emitSourceFileHeader("Parser-related llvm::StringSwitch cases", OS);
   emitClangAttrArgContextList(Records, OS);
   emitClangAttrIdentifierArgList(Records, OS);
+  emitClangAttrVariadicIdentifierArgList(Records, OS);
   emitClangAttrTypeArgList(Records, OS);
   emitClangAttrLateParsedList(Records, OS);
 }
Index: test/SemaCXX/attr-cpuspecific.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-cpuspecific.cpp
@@ -0,0 +1,108 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu  -fsyntax-only -verify -fexceptions -fcxx-exceptions %s -std=c++14
+
+// expected-error@+1{{invalid option 'invalid' for cpu_dispatch}}
+void __attribute__((cpu_dispatch(atom, invalid))) invalid_cpu();
+
+void __attribute__((cpu_specific(atom))) no_default(void);
+void __attribute__((cpu_specific(sandybridge)))  no_default(void);
+
+struct MVReference {
+  int __attribute__((cpu_specific(sandybridge))) bar(void);
+  int __attribute__((cpu_specific(ivybridge))) bar(void);
+  int __attribute__((cpu_specific(sandybridge))) foo(void);
+};
+
+void use1(void){
+  // OK, will fail in the linker, unless another TU provides the cpu_dispatch.
+  no_default();
+
+  // expected-error@+1 {{call to non-static member function without an object argument}}
+  +MVReference::bar;
+  // expected-error@+1 {{call to non-static member function without an object argument}}
+  +MVReference::foo;
+  // expected-error@+1 {{reference to multiversioned function could not be resolved; did you mean to call it?}}
+  ::bar;
+  // expected-error@+1 {{reference to multiversioned function could not be resolved; did you mean to call it?}}
+  ::foo;
+}
+
+//expected-error@+1 {{attribute 'cpu_specific' multiversioned functions do not yet support 

[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-05-29 Thread Erich Keane via Phabricator via cfe-commits
erichkeane marked 2 inline comments as done.
erichkeane added a comment.

Woops, looks like I lost those in the rebase.  Thanks for catching them!


Repository:
  rC Clang

https://reviews.llvm.org/D47474



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


[PATCH] D47474: Implement cpu_dispatch/cpu_specific Multiversioning

2018-05-29 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang added inline comments.



Comment at: lib/Sema/SemaDecl.cpp:9440
+  // Sort order doesn't matter, it just needs to be consistent.
+  std::sort(NewParsed.Features.begin(), NewParsed.Features.end());
 

Please use llvm::sort instead of std::sort. See 
https://llvm.org/docs/CodingStandards.html#beware-of-non-deterministic-sorting-order-of-equal-elements.



Comment at: lib/Sema/SemaDecl.cpp:9526
+NewParsed = NewTA->parse();
+std::sort(NewParsed.Features.begin(), NewParsed.Features.end());
   }

Please use llvm::sort instead of std::sort. See 
https://llvm.org/docs/CodingStandards.html#beware-of-non-deterministic-sorting-order-of-equal-elements.


Repository:
  rC Clang

https://reviews.llvm.org/D47474



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


Re: [libcxx] r333325 - Add nonnull; use it for atomics

2018-05-29 Thread JF Bastien via cfe-commits
Hi Marshall,

I’ve been thinking about this, and I propose we proceed the following way:

Add a new warning to clang, -Wnonnull-attribute (modulo name bikeshed), which 
is part of the nonnull group and on by default. That warning specifically 
controls warnings generated by usage of the nonnull attribute in code.
Wait a week or two so out-of-sync clang / libc++ codebases can catch up.
Un-revert r51, adding the nonnull attributes to non-member atomic functions.

That should address the concern you raised because library users can now 
silence the warning. In this case I think it’s fine to have the warning on by 
default because:

It’s hard to trigger, you need to directly pass null to the functions, copying 
a null into the function won’t warn.
The warning has zero false-positives. The code will definitely segfault when 
you call it.

What do you think?


Thanks,

JF


> On May 26, 2018, at 12:50 PM, JF Bastien via cfe-commits 
>  wrote:
> 
> 
> 
>> On May 26, 2018, at 12:36 PM, Marshall Clow > > wrote:
>> 
>> 
>> 
>> On Fri, May 25, 2018 at 4:43 PM, JF Bastien via cfe-commits 
>> mailto:cfe-commits@lists.llvm.org>> wrote:
>> Author: jfb
>> Date: Fri May 25 16:43:53 2018
>> New Revision: 25
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=25=rev 
>> 
>> Log:
>> Add nonnull; use it for atomics
>> 
>> 
>> JF - please revert this patch.
> 
> r51
> 
>> Let's have a discussion about how to implement this so that it is more 
>> friendly to people with installed code bases.
>> [ We've had *extremely* loud responses to unilaterally adding warnings - 
>> especially ones that can't be easily disabled - to the libc++ code base in 
>> the past. ] 
> 
> Ha! Interesting point which I hadn’t considered. I guess the clang warning 
> can be controlled, but this one cannot? Agreed that’s suboptimal and we 
> should figure out a way to make them controllable.
> 
> 
>> Also, please include both myself and EricWF on all libc++ reviews.
> 
> Sorry, will do. I assumed you’d all have Herald auto-add if you wanted to be 
> on a patch :-)
> 
> 
> ___
> 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] D45517: [analyzer] False positive refutation with Z3

2018-05-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: lib/StaticAnalyzer/Core/BugReporter.cpp:3153
+if (getAnalyzerOptions().shouldCrosscheckWithZ3())
+  R->addVisitor(llvm::make_unique());
+

Unless I'm mistaken, visitors are run in the order they are being declared.
It seems to me we would want to register our visitor first, as it does not make 
sense to run diagnostics-visitors if we have already deemed the path to be 
unfeasible.

Probably `LikelyFalsePositiveSuppressionBRVisitor` should be even before that.



Comment at: lib/StaticAnalyzer/Core/BugReporterVisitors.cpp:2382
+// Reset the solver
+RefutationMgr.reset();
+  }

(apologies in advance for nitpicking not on your code).

Currently, this is written in a stateful way: we have a solver, at each 
iteration we add constraints, and at the end we reset it. To me it would make 
considerably more sense to write the code in a functional style: as we go, 
generate a vector of formulas, then once we reach the path end, create the 
solver object, check satisfiability, and then destroy the entire solver.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:923
+
+  void addRangeConstraints(ConstraintRangeTy PrevCR, ConstraintRangeTy SuccCR,
+   bool OnlyPurged) override;

@mikhail.ramalho I know the first version was not yours, but could you write a 
doxygen comment explaining the semantics of all parameters? (I know we are 
guilty for not writing those often).

I am also quite confused by the semantics of `OnlyPurged` variable.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1249
+bool Z3ConstraintManager::isModelFeasible() {
+  return Solver.check() != Z3_L_FALSE;
+}

solver can also return "unknown", what happens then?



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1259
+return;
+  ConstraintRangeTy CR = OnlyPurged ? PrevCR : SuccCR;
+

TBH I'm really confused here. Why does the method take two constraint ranges? 
What's `OnlyPurged`? From reading the code it seems it's set by seeing whether 
the program point only purges dead symbols, but at least a comment should be 
added as to why this affects behavior.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1264
+
+if (OnlyPurged && SuccCR.contains(Sym))
+  continue;

I would guess that this is an optimization done in order not to re-add the 
constraints we already have.
I think we should really not bother doing that, as Z3 will do a much better job 
here then we can.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1267
+
+Z3Expr Constraints = Z3Expr::fromBoolean(false);
+

almost certainly a bug, we shouldn't default to unfeasible when the list of 
constraints is empty.



Comment at: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp:1278
+  // a valid APSIntType.
+  if (RangeTy.isNull())
+continue;

I'm really curious where does it happen and why.


https://reviews.llvm.org/D45517



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


[PATCH] D44480: [Sema] Don't skip function bodies with 'auto' without trailing return type

2018-05-29 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: test/CodeCompletion/skip-auto-funcs.cpp:9
+  if (x = 10) {}
+  // Check that this function is skipped.
+  // CHECK: 8:9: warning: using the result of an assignment as a condition 
without parentheses

is skipped -> is not skipped?



Comment at: test/CodeCompletion/skip-auto-funcs.cpp:18
+  if (x = 10) {}
+  // Check that this function is skipped.
+  // CHECK: 17:9: warning: using the result of an assignment as a condition 
without parentheses

is skipped -> is not skipped?


Repository:
  rC Clang

https://reviews.llvm.org/D44480



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


Re: r333141 - Use zeroinitializer for (trailing zero portion of) large array initializers

2018-05-29 Thread Richard Smith via cfe-commits
On 28 May 2018 at 15:34, David Blaikie via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Probably nice to mention in the commit message what the fix was (&
> if/where there was there a test added for it?) so readers don't have to try
> to eyeball diff this commit against the otherone.
>

Fair point. The bug was that we would sometimes use the wrong "common"
element type (when the type actually used for an array element differs from
the IR type that we prefer for that array element type -- this can happen
when emitting a union constant, for example). See the tests
in CodeGenCXX/cxx11-initializer-aggregate.cpp  in namespace PR37560 for
examples.


> On Wed, May 23, 2018 at 4:45 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed May 23 16:41:38 2018
>> New Revision: 333141
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=333141=rev
>> Log:
>> Use zeroinitializer for (trailing zero portion of) large array
>> initializers
>> more reliably.
>>
>> This re-commits r333044 with a fix for PR37560.
>>
>> Modified:
>> cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>> cfe/trunk/lib/Sema/SemaInit.cpp
>> cfe/trunk/test/CodeGen/init.c
>> cfe/trunk/test/CodeGenCXX/cxx11-initializer-aggregate.cpp
>> cfe/trunk/test/SemaCXX/aggregate-initialization.cpp
>>
>> Modified: cfe/trunk/lib/CodeGen/CGExprConstant.cpp
>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/
>> CGExprConstant.cpp?rev=333141=333140=333141=diff
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGExprConstant.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGExprConstant.cpp Wed May 23 16:41:38 2018
>> @@ -635,6 +635,60 @@ static ConstantAddress tryEmitGlobalComp
>>return ConstantAddress(GV, Align);
>>  }
>>
>> +static llvm::Constant *
>> +EmitArrayConstant(CodeGenModule , const ConstantArrayType *DestType,
>> +  llvm::Type *CommonElementType, unsigned ArrayBound,
>> +  SmallVectorImpl ,
>> +  llvm::Constant *Filler) {
>> +  // Figure out how long the initial prefix of non-zero elements is.
>> +  unsigned NonzeroLength = ArrayBound;
>> +  if (Elements.size() < NonzeroLength && Filler->isNullValue())
>> +NonzeroLength = Elements.size();
>> +  if (NonzeroLength == Elements.size()) {
>> +while (NonzeroLength > 0 && Elements[NonzeroLength -
>> 1]->isNullValue())
>> +  --NonzeroLength;
>> +  }
>> +
>> +  if (NonzeroLength == 0) {
>> +return llvm::ConstantAggregateZero::get(
>> +CGM.getTypes().ConvertType(QualType(DestType, 0)));
>> +  }
>> +
>> +  // Add a zeroinitializer array filler if we have lots of trailing
>> zeroes.
>> +  unsigned TrailingZeroes = ArrayBound - NonzeroLength;
>> +  if (TrailingZeroes >= 8) {
>> +assert(Elements.size() >= NonzeroLength &&
>> +   "missing initializer for non-zero element");
>> +Elements.resize(NonzeroLength + 1);
>> +auto *FillerType =
>> +CommonElementType
>> +? CommonElementType
>> +: CGM.getTypes().ConvertType(DestType->getElementType());
>> +FillerType = llvm::ArrayType::get(FillerType, TrailingZeroes);
>> +Elements.back() = llvm::ConstantAggregateZero::get(FillerType);
>> +CommonElementType = nullptr;
>> +  } else if (Elements.size() != ArrayBound) {
>> +// Otherwise pad to the right size with the filler if necessary.
>> +Elements.resize(ArrayBound, Filler);
>> +if (Filler->getType() != CommonElementType)
>> +  CommonElementType = nullptr;
>> +  }
>> +
>> +  // If all elements have the same type, just emit an array constant.
>> +  if (CommonElementType)
>> +return llvm::ConstantArray::get(
>> +llvm::ArrayType::get(CommonElementType, ArrayBound), Elements);
>> +
>> +  // We have mixed types. Use a packed struct.
>> +  llvm::SmallVector Types;
>> +  Types.reserve(Elements.size());
>> +  for (llvm::Constant *Elt : Elements)
>> +Types.push_back(Elt->getType());
>> +  llvm::StructType *SType =
>> +  llvm::StructType::get(CGM.getLLVMContext(), Types, true);
>> +  return llvm::ConstantStruct::get(SType, Elements);
>> +}
>> +
>>  /// This class only needs to handle two cases:
>>  /// 1) Literals (this is used by APValue emission to emit literals).
>>  /// 2) Arrays, structs and unions (outside C++11 mode, we don't currently
>> @@ -832,68 +886,47 @@ public:
>>}
>>
>>llvm::Constant *EmitArrayInitialization(InitListExpr *ILE, QualType
>> T) {
>> -llvm::ArrayType *AType =
>> -cast(ConvertType(ILE->getType()));
>> -llvm::Type *ElemTy = AType->getElementType();
>> +auto *CAT = CGM.getContext().getAsConstantArrayType(ILE->getType());
>> +assert(CAT && "can't emit array init for non-constant-bound array");
>>  unsigned NumInitElements = ILE->getNumInits();
>> -unsigned NumElements = AType->getNumElements();
>> +unsigned NumElements = CAT->getSize().getZExtValue();
>>
>> 

[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-29 Thread Mikhail Ramalho via Phabricator via cfe-commits
mikhail.ramalho updated this revision to Diff 148969.
mikhail.ramalho marked 6 inline comments as done.
mikhail.ramalho added a comment.

1. Moved FalsePositiveRefutationBRVisitor::Profile definition to 
BugReporterVisitor.cpp
2. Update test cases two run twice, with and without the crosscheck
3. Removed the FirstNodeVisited flag (the solver is being reset after checking 
the bug reachability)
4. Use ranged loop when adding the constraints


https://reviews.llvm.org/D45517

Files:
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Core/BugReporter/BugReporterVisitors.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ConstraintManager.h
  include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/BugReporter.cpp
  lib/StaticAnalyzer/Core/BugReporterVisitors.cpp
  lib/StaticAnalyzer/Core/ProgramState.cpp
  lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
  test/Analysis/analyzer-config.c
  test/Analysis/analyzer-config.cpp
  test/Analysis/z3-crosscheck.c

Index: test/Analysis/z3-crosscheck.c
===
--- /dev/null
+++ test/Analysis/z3-crosscheck.c
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -DNO_CROSSCHECK -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config crosscheck-with-z3=true -verify %s
+// REQUIRES: z3
+
+#ifndef NO_CROSSCHECK
+// expected-no-diagnostics
+#endif
+
+int foo(int x) 
+{
+  int *z = 0;
+  if ((x & 1) && ((x & 1) ^ 1))
+#ifdef NO_CROSSCHECK
+  return *z; // expected-warning {{Dereference of null pointer (loaded from variable 'z')}}
+#else
+  return *z; // no-warning
+#endif
+  return 0;
+}
+
+void g(int d);
+
+void f(int *a, int *b) {
+  int c = 5;
+  if ((a - b) == 0)
+c = 0;
+  if (a != b)
+#ifdef NO_CROSSCHECK
+g(3 / c); // expected-warning {{Division by zero}}
+#else
+g(3 / c); // no-warning
+#endif
+}
+
+_Bool nondet_bool();
+
+void h(int d) {
+  int x, y, k, z = 1;
+#ifdef NO_CROSSCHECK
+  while (z < k) { // expected-warning {{The right operand of '<' is a garbage value}}
+#else
+  // FIXME: Should warn about 'k' being a garbage value
+  while (z < k) { // no-warning
+#endif
+z = 2 * z;
+  }
+}
+
+void i() {
+  _Bool c = nondet_bool();
+  if (c) {
+h(1);
+  } else {
+h(2);
+  }
+}
+
Index: test/Analysis/analyzer-config.cpp
===
--- test/Analysis/analyzer-config.cpp
+++ test/Analysis/analyzer-config.cpp
@@ -32,6 +32,7 @@
 // CHECK-NEXT: cfg-rich-constructors = true
 // CHECK-NEXT: cfg-scopes = false
 // CHECK-NEXT: cfg-temporary-dtors = true
+// CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: experimental-enable-naive-ctu-analysis = false
 // CHECK-NEXT: exploration_strategy = unexplored_first_queue
 // CHECK-NEXT: faux-bodies = true
@@ -50,4 +51,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 30
+// CHECK-NEXT: num-entries = 31
Index: test/Analysis/analyzer-config.c
===
--- test/Analysis/analyzer-config.c
+++ test/Analysis/analyzer-config.c
@@ -18,6 +18,7 @@
 // CHECK-NEXT: cfg-rich-constructors = true
 // CHECK-NEXT: cfg-scopes = false
 // CHECK-NEXT: cfg-temporary-dtors = true
+// CHECK-NEXT: crosscheck-with-z3 = false
 // CHECK-NEXT: exploration_strategy = unexplored_first_queue
 // CHECK-NEXT: faux-bodies = true
 // CHECK-NEXT: graph-trim-interval = 1000
@@ -35,4 +36,4 @@
 // CHECK-NEXT: unroll-loops = false
 // CHECK-NEXT: widen-loops = false
 // CHECK-NEXT: [stats]
-// CHECK-NEXT: num-entries = 23
+// CHECK-NEXT: num-entries = 24
Index: lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
===
--- lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
+++ lib/StaticAnalyzer/Core/Z3ConstraintManager.cpp
@@ -7,6 +7,7 @@
 //
 //===--===//
 
+#include "RangedConstraintManager.h"
 #include "clang/Basic/TargetInfo.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -915,6 +916,13 @@
   void print(ProgramStateRef St, raw_ostream , const char *nl,
  const char *sep) override;
 
+  void reset() override;
+
+  bool isModelFeasible() override;
+
+  void addRangeConstraints(ConstraintRangeTy PrevCR, ConstraintRangeTy SuccCR,
+   bool OnlyPurged) override;
+
   //===--===//
   // Implementation for interface from SimpleConstraintManager.
   //===--===//
@@ -1235,6 +1243,58 @@
   return 

[PATCH] D47476: Support __iso_volatile_load8 etc on aarch64-win32.

2018-05-29 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo accepted this revision.
mstorsjo added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D47476



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


[PATCH] D46476: [HIP] Add action builder for HIP

2018-05-29 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl marked an inline comment as done.
yaxunl added inline comments.



Comment at: test/Driver/cuda-phases.cu:16
+// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s
+// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=gfx803 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s

tra wrote:
> Please wrap long RUN lines in all tests.
will do when commit. Thanks!


https://reviews.llvm.org/D46476



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


[PATCH] D44826: Add -Wunused-using, a warning that finds unused using declarations.

2018-05-29 Thread Carlos Alberto Enciso via Phabricator via cfe-commits
CarlosAlbertoEnciso added inline comments.



Comment at: include/clang/Basic/DiagnosticGroups.td:828-829
 // -Wunused-local-typedefs = -Wunused-local-typedef
+def : DiagGroup<"unused-usings", [UnusedUsing]>;
+// -Wunused-usings = -Wunused-using
 

lebedev.ri wrote:
> Why? gcc compatibility?
No particular reason. I just follow the 'unused-local-typedefs' model.
If there is not objection from others reviewers, I will drop the gcc 
compatibility.


https://reviews.llvm.org/D44826



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-29 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

In https://reviews.llvm.org/D47394#1115086, @tra wrote:

> On one hand I can see how being able to treat GPU-side binaries as any other 
> host files is convenient. On the other hand, this convenience comes with the 
> price of targeting only NVPTX. This seems contrary to OpenMP's goal of 
> supporting many different kinds of accelerators. I'm not sure what's the 
> consensus in the OpenMP community these days, but I vaguely recall that 
> generic bundling/unbundling was explicitly chosen over vendor-specific 
> encapsulation in host .o when the bundling was implemented. If the underlying 
> reasons have changed since then it would be great to hear more details about 
> that.


I second this statement, static linking might come handy for all targets and 
Clang should try to avoid vendor specific solutions as much as possible.

In a discussion off-list I proposed adding constructor functions to all object 
files and handle them like shared libraries are already handled today (ie 
register separately and let the runtime figure out how to relocate symbols in 
different translation units). I don't have an implementation of that approach 
so I can't claim that it works and doesn't have a huge performance impact 
(which we don't want either), but it should be agnostic of the offloading 
target so it may be worth investigating.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D46476: [HIP] Add action builder for HIP

2018-05-29 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

One nit. LGTM otherwise.




Comment at: test/Driver/cuda-phases.cu:16
+// RUN: | FileCheck -check-prefixes=BIN,BIN_NV %s
+// RUN: %clang -x hip -target powerpc64le-ibm-linux-gnu -ccc-print-phases 
--cuda-gpu-arch=gfx803 %s 2>&1 \
+// RUN: | FileCheck -check-prefixes=BIN,BIN_AMD %s

Please wrap long RUN lines in all tests.


https://reviews.llvm.org/D46476



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


[PATCH] D47450: [ASTImporter] Use InjectedClassNameType at import of templated record.

2018-05-29 Thread Aleksei Sidorin via Phabricator via cfe-commits
a.sidorin requested changes to this revision.
a.sidorin added a comment.
This revision now requires changes to proceed.

Hello, Balázs,

You can find my comments inline.




Comment at: lib/AST/ASTImporter.cpp:2131
 D2CXX->setDescribedClassTemplate(ToDescribed);
+if (!DCXX->isInjectedClassName()) {
+  // In a record describing a template the type should be a

Maybe we should fix it a bit upper (line 2100)?



Comment at: test/ASTMerge/injected-class-name-decl-1/Inputs/inject1.cpp:16
+} // namespace google
+namespace a {
+template  class g;

This looks like raw creduce output. Is there a way to simplify this or make 
human-readable? Do we really need nested namespaces, unused decls and other 
stuff not removed by creduce? I know that creduce is bad at reducing templates 
because we often meet similar output internally. But it is usually not a 
problem to resolve some redundancy manually to assist creduce. In this case, we 
can start by removing `k` and `n`.
We can leave this code as-is only if removing declarations or simplifying 
templates affects import order causing the bug to disappear. But even in this 
case we have to humanize the test.


Repository:
  rC Clang

https://reviews.llvm.org/D47450



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-29 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

"Interoperability with other compilers" is probably a statement that's a bit 
too strong. At best it's kind of compatible with CUDA tools and I don't think 
it's feasible for other compilers. I.e. it will be useless for AMD GPUs and 
whatever compiler they use.

In general it sounds like you're going back to what regular CUDA compilation 
pipeline does:

- [clang] C++->.ptx
- [ptxas] .ptx -> .cubin
- [fatbin] .cubin -> .fatbin
- [clang] C++ + .fatbin -> host .o

On one hand I can see how being able to treat GPU-side binaries as any other 
host files is convenient. On the other hand, this convenience comes with the 
price of targeting only NVPTX. This seems contrary to OpenMP's goal of 
supporting many different kinds of accelerators. I'm not sure what's the 
consensus in the OpenMP community these days, but I vaguely recall that generic 
bundling/unbundling was explicitly chosen over vendor-specific encapsulation in 
host .o when the bundling was implemented. If the underlying reasons have 
changed since then it would be great to hear more details about that.

Assuming we do proceed with back-to-CUDA approach, one thing I'd consider would 
be using clang's -fcuda-include-gpubinary option which CUDA uses to include GPU 
code into the host object. You may be able to use it to avoid compiling and 
partially linking .fatbin and host .o.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47354: [CodeGen][Darwin] Set the calling-convention of a thread-local variable initialization function to fix calling-convention mismatch

2018-05-29 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL333447: [CodeGen][Darwin] Set the calling-convention of 
thread-local variable (authored by ahatanak, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D47354?vs=148531=148954#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D47354

Files:
  cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
  cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp


Index: cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
+++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -166,7 +166,8 @@
 // DARWIN: call cxx_fast_tlscc void @_ZTHN1XIiE1mE()
 // CHECK: ret {{.*}}* @_ZN1XIiE1mE
 
-// CHECK: define internal {{.*}} @[[VF_M_INIT]]()
+// LINUX: define internal void @[[VF_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[VF_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1VIfE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIfE1mE to i8*)
@@ -178,7 +179,8 @@
 // CHECK: store i64 1, i64* @_ZGVN1VIfE1mE
 // CHECK: br label
 
-// CHECK: define internal {{.*}} @[[XF_M_INIT]]()
+// LINUX: define internal void @[[XF_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[XF_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1XIfE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIfE1mE to i8*)
@@ -268,7 +270,8 @@
 // LINUX-LABEL: define internal i32* @_ZTWN12_GLOBAL__N_16anon_iE()
 // DARWIN-LABEL: define internal cxx_fast_tlscc i32* 
@_ZTWN12_GLOBAL__N_16anon_iE()
 
-// CHECK: define internal {{.*}} @[[V_M_INIT]]()
+// LINUX: define internal void @[[V_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[V_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1VIiE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*)
@@ -280,7 +283,8 @@
 // CHECK: store i64 1, i64* @_ZGVN1VIiE1mE
 // CHECK: br label
 
-// CHECK: define internal {{.*}} @[[X_M_INIT]]()
+// LINUX: define internal void @[[X_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[X_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1XIiE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIiE1mE to i8*)
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
===
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
@@ -2450,8 +2450,12 @@
 if (InitIsInitFunc) {
   if (Init) {
 llvm::CallInst *CallVal = Builder.CreateCall(Init);
-if (isThreadWrapperReplaceable(VD, CGM))
+if (isThreadWrapperReplaceable(VD, CGM)) {
   CallVal->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
+  llvm::Function *Fn =
+  
cast(cast(Init)->getAliasee());
+  Fn->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
+}
   }
 } else {
   // Don't know whether we have an init function. Call it if it exists.


Index: cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
===
--- cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
+++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
@@ -166,7 +166,8 @@
 // DARWIN: call cxx_fast_tlscc void @_ZTHN1XIiE1mE()
 // CHECK: ret {{.*}}* @_ZN1XIiE1mE
 
-// CHECK: define internal {{.*}} @[[VF_M_INIT]]()
+// LINUX: define internal void @[[VF_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[VF_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1VIfE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIfE1mE to i8*)
@@ -178,7 +179,8 @@
 // CHECK: store i64 1, i64* @_ZGVN1VIfE1mE
 // CHECK: br label
 
-// CHECK: define internal {{.*}} @[[XF_M_INIT]]()
+// LINUX: define internal void @[[XF_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[XF_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1XIfE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIfE1mE to i8*)
@@ -268,7 +270,8 @@
 // LINUX-LABEL: define internal i32* @_ZTWN12_GLOBAL__N_16anon_iE()
 // DARWIN-LABEL: define internal cxx_fast_tlscc i32* @_ZTWN12_GLOBAL__N_16anon_iE()
 
-// CHECK: define internal {{.*}} @[[V_M_INIT]]()
+// LINUX: define internal void @[[V_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[V_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1VIiE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*)
@@ -280,7 +283,8 @@
 // CHECK: store i64 1, i64* @_ZGVN1VIiE1mE
 // CHECK: br label
 
-// CHECK: define internal {{.*}} @[[X_M_INIT]]()
+// LINUX: define internal void @[[X_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[X_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1XIiE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIiE1mE to i8*)
Index: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp

r333447 - [CodeGen][Darwin] Set the calling-convention of thread-local variable

2018-05-29 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Tue May 29 11:28:49 2018
New Revision: 333447

URL: http://llvm.org/viewvc/llvm-project?rev=333447=rev
Log:
[CodeGen][Darwin] Set the calling-convention of thread-local variable
initialization functions to 'cxx_fast_tlscc'.

This fixes a bug where instructions calling initialization functions for
thread-local static members of c++ template classes were using calling
convention 'cxx_fast_tlscc' while the called functions weren't annotated
with the calling convention.

rdar://problem/40447463

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

Modified:
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp

Modified: cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp?rev=333447=333446=333447=diff
==
--- cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp Tue May 29 11:28:49 2018
@@ -2450,8 +2450,12 @@ void ItaniumCXXABI::EmitThreadLocalInitF
 if (InitIsInitFunc) {
   if (Init) {
 llvm::CallInst *CallVal = Builder.CreateCall(Init);
-if (isThreadWrapperReplaceable(VD, CGM))
+if (isThreadWrapperReplaceable(VD, CGM)) {
   CallVal->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
+  llvm::Function *Fn =
+  
cast(cast(Init)->getAliasee());
+  Fn->setCallingConv(llvm::CallingConv::CXX_FAST_TLS);
+}
   }
 } else {
   // Don't know whether we have an init function. Call it if it exists.

Modified: cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp?rev=333447=333446=333447=diff
==
--- cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/cxx11-thread-local.cpp Tue May 29 11:28:49 2018
@@ -166,7 +166,8 @@ int f() {
 // DARWIN: call cxx_fast_tlscc void @_ZTHN1XIiE1mE()
 // CHECK: ret {{.*}}* @_ZN1XIiE1mE
 
-// CHECK: define internal {{.*}} @[[VF_M_INIT]]()
+// LINUX: define internal void @[[VF_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[VF_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1VIfE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIfE1mE to i8*)
@@ -178,7 +179,8 @@ int f() {
 // CHECK: store i64 1, i64* @_ZGVN1VIfE1mE
 // CHECK: br label
 
-// CHECK: define internal {{.*}} @[[XF_M_INIT]]()
+// LINUX: define internal void @[[XF_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[XF_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1XIfE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIfE1mE to i8*)
@@ -268,7 +270,8 @@ void set_anon_i() {
 // LINUX-LABEL: define internal i32* @_ZTWN12_GLOBAL__N_16anon_iE()
 // DARWIN-LABEL: define internal cxx_fast_tlscc i32* 
@_ZTWN12_GLOBAL__N_16anon_iE()
 
-// CHECK: define internal {{.*}} @[[V_M_INIT]]()
+// LINUX: define internal void @[[V_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[V_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1VIiE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1VIiE1mE to i8*)
@@ -280,7 +283,8 @@ void set_anon_i() {
 // CHECK: store i64 1, i64* @_ZGVN1VIiE1mE
 // CHECK: br label
 
-// CHECK: define internal {{.*}} @[[X_M_INIT]]()
+// LINUX: define internal void @[[X_M_INIT]]()
+// DARWIN: define internal cxx_fast_tlscc void @[[X_M_INIT]]()
 // LINUX-SAME: comdat($_ZN1XIiE1mE)
 // DARWIN-NOT: comdat
 // CHECK: load i8, i8* bitcast (i64* @_ZGVN1XIiE1mE to i8*)


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


r333446 - [X86] Tag some 128/256 load/store instructions as requiring avx512vl instead of avx512f.

2018-05-29 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Tue May 29 11:23:22 2018
New Revision: 333446

URL: http://llvm.org/viewvc/llvm-project?rev=333446=rev
Log:
[X86] Tag some 128/256 load/store instructions as requiring avx512vl instead of 
avx512f.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=333446=333445=333446=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue May 29 11:23:22 2018
@@ -1428,18 +1428,18 @@ TARGET_BUILTIN(__builtin_ia32_psraw512,
 TARGET_BUILTIN(__builtin_ia32_psrawi512, "V32sV32si", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlw512, "V32sV32sV8s", "nc", "avx512bw")
 TARGET_BUILTIN(__builtin_ia32_psrlwi512, "V32sV32si", "nc", "avx512bw")
-TARGET_BUILTIN(__builtin_ia32_movdqa32load128_mask, "V4iV4i*V4iUc", "n", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_movdqa32load256_mask, "V8iV8i*V8iUc", "n", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_movdqa32load128_mask, "V4iV4i*V4iUc", "n", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_movdqa32load256_mask, "V8iV8i*V8iUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa32load512_mask, "V16iV16iC*V16iUs", "n", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_movdqa32store512_mask, "vV16i*V16iUs", "n", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_movdqa64load512_mask, "V8LLiV8LLiC*V8LLiUc", 
"n", "avx512f")
 TARGET_BUILTIN(__builtin_ia32_movdqa64store512_mask, "vV8LLi*V8LLiUc", "n", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_movdqa32store128_mask, "vV4i*V4iUc", "n", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_movdqa32store256_mask, "vV8i*V8iUc", "n", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_movdqa32store128_mask, "vV4i*V4iUc", "n", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_movdqa32store256_mask, "vV8i*V8iUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa64load128_mask, "V2LLiV2LLiC*V2LLiUc", 
"n", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movdqa64load256_mask, "V4LLiV4LLiC*V4LLiUc", 
"n", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_movdqa64store128_mask, "vV2LLi*V2LLiUc", "n", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_movdqa64store256_mask, "vV4LLi*V4LLiUc", "n", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_movdqa64store128_mask, "vV2LLi*V2LLiUc", "n", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_movdqa64store256_mask, "vV4LLi*V4LLiUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vpmadd52huq512, "V8LLiV8LLiV8LLiV8LLi", "nc", 
"avx512ifma")
 TARGET_BUILTIN(__builtin_ia32_vpmadd52luq512, "V8LLiV8LLiV8LLiV8LLi", "nc", 
"avx512ifma")
 TARGET_BUILTIN(__builtin_ia32_vpmadd52huq128, "V2LLiV2LLiV2LLiV2LLi", "nc", 
"avx512ifma,avx512vl")
@@ -1484,8 +1484,8 @@ TARGET_BUILTIN(__builtin_ia32_loadss128_
 TARGET_BUILTIN(__builtin_ia32_loadaps256_mask, "V8fV8f*V8fUc", "n", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loaddqudi128_mask, "V2LLiV2LLi*V2LLiUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loaddqudi256_mask, "V4LLiV4LLi*V4LLiUc", "n", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_loaddqusi128_mask, "V4iV4i*V4iUc", "n", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_loaddqusi256_mask, "V8iV8i*V8iUc", "n", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_loaddqusi128_mask, "V4iV4i*V4iUc", "n", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_loaddqusi256_mask, "V8iV8i*V8iUc", "n", 
"avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loadupd128_mask, "V2dV2d*V2dUc", "n", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loadupd256_mask, "V4dV4d*V4dUc", "n", "avx512vl")
 TARGET_BUILTIN(__builtin_ia32_loadups128_mask, "V4fV4f*V4fUc", "n", "avx512vl")


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


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2018-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:192
+if (from.isMinSignedValue()) {
+  F.add(newRanges, Range(BV.getMinValue(from), BV.getMinValue(from)));
+}

NoQ wrote:
> Return value of `add` seems to be accidentally discarded here.
> 
> I guess i'll look into adding an `__attribute__((warn_unused_result))` to 
> these functions, because it's a super common bug.
Also tests would have saved us.


https://reviews.llvm.org/D35110



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


[PATCH] D35110: [Analyzer] Constraint Manager Negates Difference

2018-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:191
+}
+if (from.isMinSignedValue()) {
+  F.add(newRanges, Range(BV.getMinValue(from), BV.getMinValue(from)));

We'll also need to merge the two adjacent segments if the original range had 
both a [MinSingedValue, MinSignedValue] and a [X, MaxSignedValue]:

{F6287707}

Because our immutable sets are sorted, you can conduct the check for the first 
and the last segment separately.

I think this code needs comments because even though it's short it's pretty 
hard to get right.



Comment at: lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:192
+if (from.isMinSignedValue()) {
+  F.add(newRanges, Range(BV.getMinValue(from), BV.getMinValue(from)));
+}

Return value of `add` seems to be accidentally discarded here.

I guess i'll look into adding an `__attribute__((warn_unused_result))` to these 
functions, because it's a super common bug.


https://reviews.llvm.org/D35110



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added a comment.

In https://reviews.llvm.org/D47394#1114848, @sfantao wrote:

> Just to clarify one thing in my last comment:
>
> When I say that we didn't aim at having clang compatible with other 
> compilers, I mean the OpenMP offloading descriptors, where all the variables 
> and offloading entry points are. Of course we want to allow the resulting 
> binaries to be compatible with linkers taking inputs of other compilers, so 
> that you can have, e.g., OpenMP and CUDA supported in the same executable, 
> even though working independently.


Today you will have trouble linking against a Clang object file in another 
compiler that doesn't know anything about the clang-offload-bundler.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-05-29 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: lib/Driver/ToolChains/Cuda.cpp:536
+  }
 }
 

sfantao wrote:
> What prevents all this from being done in the bundler? If I understand it 
> correctly, if the bundler implements this wrapping all the checks for 
> librariers wouldn't be required and, only two changes would be required in 
> the driver:
> 
> - generate fatbin instead of cubin. This is straightforward to do by changing 
> the device assembling job. In terms of the loading of the kernels by the 
> device API, doing it through fatbin or cubin should be equivalent except that 
> fatbin enables storing the PTX format and JIT for newer GPUs.
> - Use NVIDIA linker as host linker.
> 
> This last requirement could be problematic if we get two targets attempting  
> to use different (incompatible linkers). If we get this kind of 
> incompatibility we should get the appropriate diagnostic.
What prevents it is the fact that the bundler is called AFTER the HOST and 
DEVICE object files have been produced. The creation of the fatbin (FATBINARY + 
CALNG++) needs to happen within the NVPTX toolchain.



Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D45517: [analyzer] False positive refutation with Z3

2018-05-29 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added inline comments.



Comment at: test/Analysis/z3-crosscheck.c:2
+// RUN: %clang_cc1 -analyze 
-analyzer-checker=core,unix.Malloc,debug.ExprInspection -analyzer-config 
crosscheck-with-z3=true -verify %s
+// REQUIRES: z3
+// expected-no-diagnostics

Could we also have a second RUN line without Z3, and then use ifdef's to 
differentiate between the two in tests?


https://reviews.llvm.org/D45517



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


[PATCH] D47444: [X86] Lowering FMA intrinsics to native IR (Clang part)

2018-05-29 Thread Craig Topper via Phabricator via cfe-commits
craig.topper accepted this revision.
craig.topper added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lib/CodeGen/CGBuiltin.cpp:8416
+static Value *EmitX86FMAExpr(CodeGenFunction , ArrayRef Ops,
+  unsigned BuiltinID) {
+

Please indent this to line up with the first argument on the previous line.


Repository:
  rC Clang

https://reviews.llvm.org/D47444



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


[PATCH] D41976: Low-hanging fruit optimization in string::__move_assign().

2018-05-29 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

Howard just pointed out to me that `__clear_and_shrink` should be noexcept - 
otherwise we get the generation of an exception table and a call to `terminate` 
in string's move assignment operator.  Fixed in revision 333435.


Repository:
  rCXX libc++

https://reviews.llvm.org/D41976



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


[PATCH] D47451: [analyzer] Remove the redundant check about same state transition in `ArrayBoundCheckerV2.cpp`.

2018-05-29 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Thx!


Repository:
  rC Clang

https://reviews.llvm.org/D47451



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


  1   2   >