[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

2019-01-09 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Good point :)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54996/new/

https://reviews.llvm.org/D54996



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


[PATCH] D54996: [libclang] Fix clang_Cursor_isAnonymous

2019-01-09 Thread Nikolai Kosjar via Phabricator via cfe-commits
nik requested changes to this revision.
nik added inline comments.
This revision now requires changes to proceed.



Comment at: test/Index/print-type.cpp:202
 // CHECK: CallExpr=Bar:17:3 [type=outer::inner::Bar] [typekind=Elaborated] 
[canonicaltype=outer::inner::Bar] [canonicaltypekind=Record] [args= 
[outer::Foo *] [Pointer]] [isPOD=0] [nbFields=3]
+// CHECK: StructDecl=:84:3 (Definition) [type=X::(anonymous struct at 
D:\code\qt_llvm\tools\clang\test\Index\print-type.cpp:84:3)] [typekind=Record] 
[isPOD=1] [nbFields=1] [isAnon=1]
+// CHECK: ClassDecl=:85:3 (Definition) [type=X::(anonymous class at 
D:\code\qt_llvm\tools\clang\test\Index\print-type.cpp:85:3)] [typekind=Record] 
[isPOD=1] [nbFields=1] [isAnon=1]

Hard coded paths will probably only work on your machine ;)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54996/new/

https://reviews.llvm.org/D54996



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


[PATCH] D56504: [WebAssembly] Add simd128-unimplemented feature, gate builtins

2019-01-09 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:53
 // Saturating fp-to-int conversions
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc")
-
-// Floating point min/max
-BUILTIN(__builtin_wasm_min_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_max_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_min_f64, "ddd", "nc")
-BUILTIN(__builtin_wasm_max_f64, "ddd", "nc")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc", 
"nontrapping-fptoint")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc", 
"nontrapping-fptoint")

aheejin wrote:
> clang-format this file
This file still does not look like clang-formatted; I guess your script misses 
this file because its extension is `def`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

This patch still doesn't make any sense.  You don't need to do any special 
validation when passing a function as a template argument.  When Sema 
instantiates the template definition, it'll rebuild the expressions that refer 
to the template parameter, which will trigger the normal checking for whether 
those expressions are illegally referencing a host function from the device, 
etc.  All you need to do is suppress that checking (whether it happens in a 
template definition or not) for references from non-potentially-evaluated 
contexts.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D55662: [Sema] If CheckPlaceholderExpr rewrites a placeholder expression when the type of an auto variable is being deduced, use the rewritten expression when performing initialization of the

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Sounds good.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55662/new/

https://reviews.llvm.org/D55662



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


[PATCH] D55662: [Sema] If CheckPlaceholderExpr rewrites a placeholder expression when the type of an auto variable is being deduced, use the rewritten expression when performing initialization of the

2019-01-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak marked an inline comment as done.
ahatanak added a comment.

In D55662#1349329 , @rjmccall wrote:

> Oh, and please update the commit message to primarily talk about the changes 
> to placeholder checking.  You can discuss the impact on the 
> repeated-use-of-weak warning in a follow-up paragraph.


This patch has three parts:

1. Use the expression that was rewritten during auto type deduction to perform 
auto variable initialization.
2. Call `CheckPlaceholderExpr` while an unevaluated context is still on the 
stack.
3. Check whether we are in an unevaluated context before calling 
`recordUseOfWeak` in `Sema::BuildInstanceMessage`.

I think I should commit 1 separately from 2 and 3.




Comment at: lib/Sema/SemaLambda.cpp:793
+  else
+Args = Init;
+

rjmccall wrote:
> Please maintain the original order here, even though I suspect it doesn't 
> matter: if this is direct-initialization, use the arguments, otherwise use 
> either `DeducedAutoInit` or `Init`.  Although really, consider just 
> reassigning `Init` immediately after the `deduceVarType...` call.
The code that assigns `CXXDirectInit`'s expressions to `Arg` is no longer 
needed since `Sema::deduceVarTypeFromInitializer` removes the `ParenListExpr`.

If we move the code that declares the `InitializedEntity` variable up, we can 
reassign `Init` immediately after the call to `deduceVarTypeFromInitializer`.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55662/new/

https://reviews.llvm.org/D55662



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


[PATCH] D55662: [Sema] If CheckPlaceholderExpr rewrites a placeholder expression when the type of an auto variable is being deduced, use the rewritten expression when performing initialization of the

2019-01-09 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak updated this revision to Diff 180993.
ahatanak retitled this revision from "[Sema][ObjC] Do not warn about repeated 
uses of weak variables when the variables are accessed in an unevaluated 
context." to "[Sema] If CheckPlaceholderExpr rewrites a placeholder expression 
when the type of an auto variable is being deduced, use the rewritten 
expression when performing initialization of the variable.".
ahatanak edited the summary of this revision.
ahatanak added a comment.

Pass `Init` by reference and use the rewritten expression returned in it to 
perform variable initialization. Add a test case that tests new expression with 
auto types.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55662/new/

https://reviews.llvm.org/D55662

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaType.cpp
  test/SemaObjC/arc-repeated-weak.mm

Index: test/SemaObjC/arc-repeated-weak.mm
===
--- test/SemaObjC/arc-repeated-weak.mm
+++ test/SemaObjC/arc-repeated-weak.mm
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
-// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-arc -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -std=c++14 -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fobjc-runtime-has-weak -fobjc-weak -fblocks -Wno-objc-root-class -std=c++11 -Warc-repeated-use-of-weak -std=c++14 -verify %s
 
 @interface Test {
 @public
@@ -462,6 +462,21 @@
   NSString * t2 = NSBundle.foo2.prop;
   use(NSBundle.foo2.weakProp); // expected-warning{{weak property 'weakProp' may be accessed multiple times}}
   use(NSBundle2.foo2.weakProp); // expected-note{{also accessed here}}
+  decltype([NSBundle2.foo2 weakProp]) t3;
+  decltype(NSBundle2.foo2.weakProp) t4;
+  __typeof__(NSBundle2.foo2.weakProp) t5;
+}
+
+void testAuto() {
+  auto __weak wp = NSBundle2.foo2.weakProp;
+}
+
+void testLambdaCaptureInit() {
+  [capture(NSBundle2.foo2.weakProp)] {} ();
+}
+
+void testAutoNew() {
+  auto p = new auto(NSBundle2.foo2.weakProp);
 }
 
 // This used to crash in the constructor of WeakObjectProfileTy when a
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -8056,9 +8056,7 @@
 }
 
 QualType Sema::BuildTypeofExprType(Expr *E, SourceLocation Loc) {
-  ExprResult ER = CheckPlaceholderExpr(E);
-  if (ER.isInvalid()) return QualType();
-  E = ER.get();
+  assert(!E->hasPlaceholderType() && "unexpected placeholder");
 
   if (!getLangOpts().CPlusPlus && E->refersToBitField())
 Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 2;
@@ -8143,9 +8141,7 @@
 
 QualType Sema::BuildDecltypeType(Expr *E, SourceLocation Loc,
  bool AsUnevaluated) {
-  ExprResult ER = CheckPlaceholderExpr(E);
-  if (ER.isInvalid()) return QualType();
-  E = ER.get();
+  assert(!E->hasPlaceholderType() && "unexpected placeholder");
 
   if (AsUnevaluated && CodeSynthesisContexts.empty() &&
   E->HasSideEffects(Context, false)) {
Index: lib/Sema/SemaTemplateDeduction.cpp
===
--- lib/Sema/SemaTemplateDeduction.cpp
+++ lib/Sema/SemaTemplateDeduction.cpp
@@ -4429,6 +4429,10 @@
 return DAR_FailedAlreadyDiagnosed;
   }
 
+  ExprResult ER = CheckPlaceholderExpr(Init);
+  if (ER.isInvalid())
+return DAR_FailedAlreadyDiagnosed;
+  Init = ER.get();
   QualType Deduced = BuildDecltypeType(Init, Init->getBeginLoc(), false);
   if (Deduced.isNull())
 return DAR_FailedAlreadyDiagnosed;
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -759,14 +759,15 @@
   TypeSourceInfo *TSI = TLB.getTypeSourceInfo(Context, DeductType);
 
   // Deduce the type of the init capture.
+  Expr *DeduceInit = Init;
   QualType DeducedType = deduceVarTypeFromInitializer(
   /*VarDecl*/nullptr, DeclarationName(Id), DeductType, TSI,
-  SourceRange(Loc, Loc), IsDirectInit, Init);
+  SourceRange(Loc, Loc), IsDirectInit, DeduceInit);
   if (DeducedType.isNull())
 return QualType();
 
   // Are we a non-list direct initialization?
-  ParenListExpr *CXXDirectInit = dyn_cast(Init);
+  bool CXXDirectInit = isa(Init);
 
   // Perform initialization analysis and ensure any implicit conversions
   // (such as lvalue-to-rvalue) are enforced.
@@ -779,10 +780,7 @@
: I

[clang-tools-extra] r350797 - Remove unnecessary include.

2019-01-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan  9 20:53:10 2019
New Revision: 350797

URL: http://llvm.org/viewvc/llvm-project?rev=350797&view=rev
Log:
Remove unnecessary include.

QuerySession.h does not need anything from Query.h, so it does not need to
include it.

Modified:
clang-tools-extra/trunk/clang-query/QuerySession.h

Modified: clang-tools-extra/trunk/clang-query/QuerySession.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-query/QuerySession.h?rev=350797&r1=350796&r2=350797&view=diff
==
--- clang-tools-extra/trunk/clang-query/QuerySession.h (original)
+++ clang-tools-extra/trunk/clang-query/QuerySession.h Wed Jan  9 20:53:10 2019
@@ -10,7 +10,6 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANG_QUERY_QUERY_SESSION_H
 
-#include "Query.h"
 #include "clang/ASTMatchers/Dynamic/VariantValue.h"
 #include "llvm/ADT/ArrayRef.h"
 #include "llvm/ADT/StringMap.h"


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


r350794 - [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Stanislav Mekhanoshin via cfe-commits
Author: rampitec
Date: Wed Jan  9 19:25:47 2019
New Revision: 350794

URL: http://llvm.org/viewvc/llvm-project?rev=350794&view=rev
Log:
[AMDGPU] Separate feature dot-insts

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=350794&r1=350793&r2=350794&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Wed Jan  9 19:25:47 2019
@@ -135,13 +135,13 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h,
 // Deep learning builtins.
 
//===--===//
 
-TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot-insts")
 
 
//===--===//
 // Special builtins.

Modified: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/AMDGPU.cpp?rev=350794&r1=350793&r2=350794&view=diff
==
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp Wed Jan  9 19:25:47 2019
@@ -137,6 +137,7 @@ bool AMDGPUTargetInfo::initFeatureMap(
 switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
 case GK_GFX906:
   Features["dl-insts"] = true;
+  Features["dot-insts"] = true;
   LLVM_FALLTHROUGH;
 case GK_GFX909:
 case GK_GFX904:

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl?rev=350794&r1=350793&r2=350794&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl Wed Jan  9 19:25:47 2019
@@ -11,7 +11,7 @@
 // RUN: %clang_cc1 -triple amdgcn -target-cpu gfx601 -S -emit-llvm -o - %s | 
FileCheck --check-prefix=GFX601 %s
 
 // GFX904: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
-// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
+// GFX906: 
"target-features"="+16-bit-insts,+ci-insts,+dl-insts,+dot-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+gfx9-insts,+s-memrealtime,+vi-insts"
 // GFX801: 
"target-features"="+16-bit-insts,+ci-insts,+dpp,+fp32-denormals,+fp64-fp16-denormals,+s-memrealtime,+vi-insts"
 // GFX700: "target-features"="+ci-insts,+fp64-fp16-denormals,-fp32-denormals"
 // GFX600: "target-features"="+fp64-fp16-denormals,-fp32-denormals"

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl?rev=350794&r1=350793&r2=350794&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl Wed Jan  9 
19:25:47 2019
@@ -12,24 +12,24 @@ kernel void builtins_amdgcn_dl_insts_err
 half2 v2hA, half2 v2hB, float fC,
 short2 v2ssA, short2 v2ssB, int siA, int siB, int siC,
 ushort2 v2usA, ushort2 v2usB, uint uiA, uint uiB, uint uiC) {
-  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
-  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__buil

[PATCH] D47819: [compiler-rt] [test] Support using libtirpc on Linux

2019-01-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny planned changes to this revision.
mgorny added a comment.

Need to update this for the new idea of not using libtirpc at all.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47819/new/

https://reviews.llvm.org/D47819



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


[PATCH] D56525: [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350794: [AMDGPU] Separate feature dot-insts (authored by 
rampitec, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56525?vs=180969&id=180991#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56525/new/

https://reviews.llvm.org/D56525

Files:
  cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
  cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
  cfe/trunk/test/CodeGenOpenCL/amdgpu-features.cl
  cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl


Index: cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
===
--- cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
+++ cfe/trunk/lib/Basic/Targets/AMDGPU.cpp
@@ -137,6 +137,7 @@
 switch (llvm::AMDGPU::parseArchAMDGCN(CPU)) {
 case GK_GFX906:
   Features["dl-insts"] = true;
+  Features["dot-insts"] = true;
   LLVM_FALLTHROUGH;
 case GK_GFX909:
 case GK_GFX904:
Index: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
===
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
@@ -135,13 +135,13 @@
 // Deep learning builtins.
 
//===--===//
 
-TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dot-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dot-insts")
 
 
//===--===//
 // Special builtins.
Index: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
===
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
@@ -12,24 +12,24 @@
 half2 v2hA, half2 v2hB, float fC,
 short2 v2ssA, short2 v2ssB, int siA, int siB, int siC,
 ushort2 v2usA, ushort2 v2usB, uint uiA, uint uiB, uint uiC) {
-  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
-  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
+  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
+  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
 
-  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
-  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
+  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
+  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
 
-  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
-  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
+  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
+  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
 
-  siOut[2] = __builtin_amdgcn_sdot4(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
-  siOut[3] = __builtin_amdgcn_sdot4(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
+  siOut[2] = 

r350792 - Refactor declarations of ASTContext allocate functions into its own header.

2019-01-09 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Wed Jan  9 19:23:25 2019
New Revision: 350792

URL: http://llvm.org/viewvc/llvm-project?rev=350792&view=rev
Log:
Refactor declarations of ASTContext allocate functions into its own header.

Forward declarations of the allocate functions combine with the forward
declaration of the ASTContext class is enough information for some headers
without pulling in ASTContext.h in its entirety.  Pull the existing
declarations from AttrIterator.h into a new header.  Also place the default
alignment size into this header.  Previously, new had its default in
AttrIterator.h while new[] had its default in ASTContext.h.  Add new header
includes where it is needed.  Specifically to ASTVector.h to make it a
standalone header, unlike previously which it was standalone as long as
none of its functions were called.

Added:
cfe/trunk/include/clang/AST/ASTContextAllocate.h
  - copied, changed from r350683, cfe/trunk/include/clang/AST/AttrIterator.h
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/ASTVector.h
cfe/trunk/include/clang/AST/Attr.h
cfe/trunk/include/clang/AST/AttrIterator.h
cfe/trunk/include/clang/AST/Decl.h

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=350792&r1=350791&r2=350792&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Jan  9 19:23:25 2019
@@ -15,6 +15,7 @@
 #ifndef LLVM_CLANG_AST_ASTCONTEXT_H
 #define LLVM_CLANG_AST_ASTCONTEXT_H
 
+#include "clang/AST/ASTContextAllocate.h"
 #include "clang/AST/ASTTypeTraits.h"
 #include "clang/AST/CanonicalType.h"
 #include "clang/AST/CommentCommandTraits.h"
@@ -2969,8 +2970,8 @@ inline Selector GetUnarySelector(StringR
 /// This placement form of operator new uses the ASTContext's allocator for
 /// obtaining memory.
 ///
-/// IMPORTANT: These are also declared in clang/AST/AttrIterator.h! Any changes
-/// here need to also be made there.
+/// IMPORTANT: These are also declared in clang/AST/ASTContextAllocate.h!
+/// Any changes here need to also be made there.
 ///
 /// We intentionally avoid using a nothrow specification here so that the calls
 /// to this operator will not perform a null check on the result -- the
@@ -2993,7 +2994,7 @@ inline Selector GetUnarySelector(StringR
 ///  allocator supports it).
 /// @return The allocated memory. Could be nullptr.
 inline void *operator new(size_t Bytes, const clang::ASTContext &C,
-  size_t Alignment) {
+  size_t Alignment /* = 8 */) {
   return C.Allocate(Bytes, Alignment);
 }
 
@@ -3031,7 +3032,7 @@ inline void operator delete(void *Ptr, c
 ///  allocator supports it).
 /// @return The allocated memory. Could be nullptr.
 inline void *operator new[](size_t Bytes, const clang::ASTContext& C,
-size_t Alignment = 8) {
+size_t Alignment /* = 8 */) {
   return C.Allocate(Bytes, Alignment);
 }
 

Copied: cfe/trunk/include/clang/AST/ASTContextAllocate.h (from r350683, 
cfe/trunk/include/clang/AST/AttrIterator.h)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContextAllocate.h?p2=cfe/trunk/include/clang/AST/ASTContextAllocate.h&p1=cfe/trunk/include/clang/AST/AttrIterator.h&r1=350683&r2=350792&rev=350792&view=diff
==
--- cfe/trunk/include/clang/AST/AttrIterator.h (original)
+++ cfe/trunk/include/clang/AST/ASTContextAllocate.h Wed Jan  9 19:23:25 2019
@@ -1,4 +1,4 @@
-//===- AttrIterator.h - Classes for attribute iteration -*- C++ 
-*-===//
+//===- ASTContextAllocate.h - ASTContext allocate functions -*- C++ 
-*-===//
 //
 // The LLVM Compiler Infrastructure
 //
@@ -7,35 +7,27 @@
 //
 
//===--===//
 //
-//  This file defines the Attr vector and specific_attr_iterator interfaces.
+//  This file declares ASTContext allocation functions separate from the main
+//  code in ASTContext.h.
 //
 
//===--===//
 
-#ifndef LLVM_CLANG_AST_ATTRITERATOR_H
-#define LLVM_CLANG_AST_ATTRITERATOR_H
+#ifndef LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H
+#define LLVM_CLANG_AST_ASTCONTEXTALLOCATE_H
 
-#include "clang/Basic/LLVM.h"
-#include "llvm/ADT/SmallVector.h"
-#include "llvm/Support/Casting.h"
-#include 
 #include 
-#include 
 
 namespace clang {
 
 class ASTContext;
-class Attr;
 
 } // namespace clang
 
 // Defined in ASTContext.h
 void *operator new(size_t Bytes, const clang::ASTContext &C,
size_t Alignment = 8);
-
-// FIXME: Being forced to not have a default argument here due to redeclaration
-//rules on default argumen

[PATCH] D56504: [WebAssembly] Add simd128-unimplemented feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 180989.
tlively marked 3 inline comments as done.
tlively added a comment.

- Fix formatting, fix and test macro name


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h
  test/CodeGen/builtins-wasm.c
  test/Preprocessor/wasm-target-features.c

Index: test/Preprocessor/wasm-target-features.c
===
--- test/Preprocessor/wasm-target-features.c
+++ test/Preprocessor/wasm-target-features.c
@@ -8,6 +8,15 @@
 // SIMD128:#define __wasm_simd128__ 1{{$}}
 //
 // RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm32-unknown-unknown -msimd128-unimplemented \
+// RUN:   | FileCheck %s -check-prefix=SIMD128-UNIMPLEMENTED
+// RUN: %clang -E -dM %s -o - 2>&1 \
+// RUN: -target wasm64-unknown-unknown -msimd128-unimplemented \
+// RUN:   | FileCheck %s -check-prefix=SIMD128-UNIMPLEMENTED
+//
+// SIMD128-UNIMPLEMENTED:#define __wasm_simd128_unimplemented__ 1{{$}}
+//
+// RUN: %clang -E -dM %s -o - 2>&1 \
 // RUN: -target wasm32-unknown-unknown -mcpu=mvp \
 // RUN:   | FileCheck %s -check-prefix=MVP
 // RUN: %clang -E -dM %s -o - 2>&1 \
Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -1,9 +1,6 @@
-// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
-// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: not %clang_cc1 -triple wasm64-unknown-unknown -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefixes MISSING-SIMD
 
 // SIMD convenience types
 typedef char i8x16 __attribute((vector_size(16)));
@@ -158,6 +155,7 @@
 
 int extract_lane_s_i8x16(i8x16 v) {
   return __builtin_wasm_extract_lane_s_i8x16(v, 13);
+  // MISSING-SIMD: error: '__builtin_wasm_extract_lane_s_i8x16' needs target feature simd128
   // WEBASSEMBLY: extractelement <16 x i8> %v, i32 13
   // WEBASSEMBLY-NEXT: sext
   // WEBASSEMBLY-NEXT: ret
Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -28,7 +28,8 @@
   enum SIMDEnum {
 NoSIMD,
 SIMD128,
-  } SIMDLevel;
+SIMD128Unimplemented,
+  } SIMDLevel = NoSIMD;
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
@@ -59,18 +60,12 @@
 MacroBuilder &Builder) const override;
 
 private:
+  static void setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level);
+
   bool
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
- const std::vector &FeaturesVec) const override {
-if (CPU == "bleeding-edge") {
-  Features["simd128"] = true;
-  Features["nontrapping-fptoint"] = true;
-  Features["sign-ext"] = true;
-}
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
-  }
-
+ const std::vector &FeaturesVec) const override;
   bool hasFeature(StringRef Feature) const final;
 
   bool handleTargetFeatures(std::vector &Features,
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -24,6 +24,8 @@
 const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)\
   {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
 #include "clang/Basic/BuiltinsWebAssembly.def"
@@ -35,6 +37,7 @@
 bool WebAssemblyTarget

[PATCH] D56504: [WebAssembly] Add simd128-unimplemented feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively added inline comments.



Comment at: lib/Basic/Targets/WebAssembly.cpp:89
+// features control availability of builtins
+setSIMDLevel(Features, SIMDLevel);
+if (HasNontrappingFPToInt)

aheejin wrote:
> Minor thing, but should we extract this as a function? It is gonna be a 
> couple line anyway, like
> 
> ```
> if (CPU == "bleeding-edge") {
>   ...
>   Features["unimplemented-simd128"] = Features["simd128"] = true;
> }
> 
> if (SIMDLevel >= SIMD128)
>   Features["simd128"] = true;
> if (SIMDLevel >= UnimplementedSIMD128)
>   Features["unimplemented-simd128"] = true;
> ...
> 
> And to me it is more readable to see all `Features` setting in one place. But 
> I'm not too opinionated either.
The structure of basically all this code is pulled from X86.cpp, which is 
obviously has a lot more features to wrangle. This particular function is 
similar to `setSSELevel` in X86.cpp. I agree that it probably doesn't need to 
be separate now, but as we explore possible extensions to the SIMD proposal in 
the future I think it will be useful to have this function.



Comment at: lib/Basic/Targets/WebAssembly.cpp:98
+return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+  }
+

aheejin wrote:
> The indentation of these functions looks weird and there are lines that 
> exceeds 80 cols. clang-format?
Done, and copied my pre-commit git hooks from the main LLVM repo so it won't be 
an issue again.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504



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


[PATCH] D56532: [clang-tidy] Add the abseil-duration-conversion-cast check

2019-01-09 Thread Hyrum Wright via Phabricator via cfe-commits
hwright created this revision.
hwright added reviewers: hokein, aaron.ballman.
hwright added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.

This suggests simplifying expressions which are casting conversion functions, 
such as `static_cast(absl::ToDoubleSeconds(...))`


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D56532

Files:
  clang-tidy/abseil/AbseilTidyModule.cpp
  clang-tidy/abseil/CMakeLists.txt
  clang-tidy/abseil/DurationComparisonCheck.cpp
  clang-tidy/abseil/DurationConversionCastCheck.cpp
  clang-tidy/abseil/DurationConversionCastCheck.h
  clang-tidy/abseil/DurationRewriter.cpp
  clang-tidy/abseil/DurationRewriter.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/abseil-duration-conversion-cast.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/abseil-duration-conversion-cast.cpp

Index: test/clang-tidy/abseil-duration-conversion-cast.cpp
===
--- /dev/null
+++ test/clang-tidy/abseil-duration-conversion-cast.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s abseil-duration-conversion-cast %t -- -- -I%S/Inputs
+
+#include "absl/time/time.h"
+
+void f() {
+  absl::Duration d1;
+  double x;
+  int i;
+
+  i = static_cast(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = static_cast(absl::ToInt64Hours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleHours(d1);
+  i = static_cast(absl::ToDoubleMinutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Minutes(d1);
+  x = static_cast(absl::ToInt64Minutes(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMinutes(d1);
+  i = static_cast(absl::ToDoubleSeconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Seconds(d1);
+  x = static_cast(absl::ToInt64Seconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleSeconds(d1);
+  i = static_cast(absl::ToDoubleMilliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Milliseconds(d1);
+  x = static_cast(absl::ToInt64Milliseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMilliseconds(d1);
+  i = static_cast(absl::ToDoubleMicroseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Microseconds(d1);
+  x = static_cast(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+  i = static_cast(absl::ToDoubleNanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Nanoseconds(d1);
+  x = static_cast(absl::ToInt64Nanoseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleNanoseconds(d1);
+
+  // Functional-style casts
+  i = int(absl::ToDoubleHours(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = float(absl::ToInt64Microseconds(d1));
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+
+  // C-style casts
+  i = (int) absl::ToDoubleHours(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToInt64Hours(d1);
+  x = (float) absl::ToInt64Microseconds(d1);
+  // CHECK-MESSAGES: [[@LINE-1]]:7: warning: convert duration directly to double [abseil-duration-conversion-cast]
+  // CHECK-FIXES: absl::ToDoubleMicroseconds(d1);
+
+  // Macro handling
+  // We want to transform things in macro arguments
+#define EXTERNAL(x) (x) + 5
+  i = EXTERNAL(static_cast(absl::ToDoubleSeconds(d1)));
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: convert duration directly to integer [abseil-duration-conversion-cast]
+  // CHECK-FIXES: EXTERNAL(absl::To

[PATCH] D56504: [WebAssembly] Add unimplemented-simd128 feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 180984.
tlively added a comment.

- Match the new naming scheme from rL350791 


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h
  test/CodeGen/builtins-wasm.c

Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -1,9 +1,5 @@
-// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
-// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +simd128-unimplemented -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
 
 // SIMD convenience types
 typedef char i8x16 __attribute((vector_size(16)));
Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -28,7 +28,8 @@
   enum SIMDEnum {
 NoSIMD,
 SIMD128,
-  } SIMDLevel;
+SIMD128Unimplemented,
+  } SIMDLevel = NoSIMD;
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
@@ -59,18 +60,12 @@
 MacroBuilder &Builder) const override;
 
 private:
+  static void setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level);
+
   bool
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
- const std::vector &FeaturesVec) const override {
-if (CPU == "bleeding-edge") {
-  Features["simd128"] = true;
-  Features["nontrapping-fptoint"] = true;
-  Features["sign-ext"] = true;
-}
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
-  }
-
+ const std::vector &FeaturesVec) const override;
   bool hasFeature(StringRef Feature) const final;
 
   bool handleTargetFeatures(std::vector &Features,
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -24,6 +24,8 @@
 const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)\
   {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
 #include "clang/Basic/BuiltinsWebAssembly.def"
@@ -35,6 +37,7 @@
 bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
   return llvm::StringSwitch(Feature)
   .Case("simd128", SIMDLevel >= SIMD128)
+  .Case("simd128-unimplemented", SIMDLevel >= SIMD128Unimplemented)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
   .Case("exception-handling", HasExceptionHandling)
@@ -55,8 +58,46 @@
   defineCPUMacros(Builder, "wasm", /*Tuning=*/false);
   if (SIMDLevel >= SIMD128)
 Builder.defineMacro("__wasm_simd128__");
+  if (SIMDLevel >= SIMD128Unimplemented)
+Builder.defineMacro("__wasm_unimplemented_simd128__");
 }
 
+void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level) {
+  switch (Level) {
+  case SIMD128Unimplemented:
+Features["simd128-unimplemented"] = true;
+LLVM_FALLTHROUGH;
+  case SIMD128:
+Features["simd128"] = true;
+LLVM_FALLTHROUGH;
+  case NoSIMD:
+break;
+  }
+}
+
+bool WebAssemblyTargetInfo::initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
+ StringRef CPU,
+ const std::vector &FeaturesVec) const {
+if (CPU == "bleeding-edge") {
+  Features["nontrapping-fptoint"] = true;
+  Features["sign-ext"] = true;
+  setSIMDLevel(Features, SIMD128);
+}
+// Other targets do not consider user-configured features here, but while we
+// are actively developing new features it is useful to let user-configured
+// features 

[PATCH] D56530: [X86] Add versions of the avx512 gather intrinsics that take the mask as a vXi1 vector instead of a scalar (clang side)

2019-01-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper marked an inline comment as done.
craig.topper added inline comments.



Comment at: include/clang/Basic/BuiltinsX86.def:988
 TARGET_BUILTIN(__builtin_ia32_gathersiv8df, "V8dV8dvC*V8iUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*V16fUsIi", "nV:512:", 
"avx512f")
+TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16fvC*V16iUsIi", "nV:512:", 
"avx512f")
 TARGET_BUILTIN(__builtin_ia32_gatherdiv8df, "V8dV8dvC*V8LLiUcIi", "nV:512:", 
"avx512f")

This was a bug that seems to have been hidden because generic builtin to 
intrinsic handling blindly inserted a bitcast to match the type. I'll probably 
pre-commit this


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56530/new/

https://reviews.llvm.org/D56530



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


[PATCH] D56529: [X86] Add versions of the avx512 gather intrinsics that take the mask as a vXi1 vector instead of a scalar (clang side)

2019-01-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper abandoned this revision.
craig.topper added a comment.

Abandoning because i sent it to llvm-commits instead of cfe-commits. Will redo 
to get the right mailing list


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56529/new/

https://reviews.llvm.org/D56529



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


[PATCH] D56530: [X86] Add versions of the avx512 gather intrinsics that take the mask as a vXi1 vector instead of a scalar (clang side)

2019-01-09 Thread Craig Topper via Phabricator via cfe-commits
craig.topper created this revision.
craig.topper added reviewers: spatel, RKSimon.

This is the clang equivalent of D56527 


https://reviews.llvm.org/D56530

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/avx512f-builtins.c
  test/CodeGen/avx512vl-builtins.c

Index: test/CodeGen/avx512vl-builtins.c
===
--- test/CodeGen/avx512vl-builtins.c
+++ test/CodeGen/avx512vl-builtins.c
@@ -9280,97 +9280,97 @@
 
 __m128d test_mm_mmask_i64gather_pd(__m128d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_pd
-  // CHECK: @llvm.x86.avx512.gather3div2.df
+  // CHECK: @llvm.x86.avx512.mask.gather3div2.df
   return _mm_mmask_i64gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mmask_i64gather_epi64(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3div2.di
+  // CHECK: @llvm.x86.avx512.mask.gather3div2.di
   return _mm_mmask_i64gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256d test_mm256_mmask_i64gather_pd(__m256d __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_pd
-  // CHECK: @llvm.x86.avx512.gather3div4.df
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.df
   return _mm256_mmask_i64gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256i test_mm256_mmask_i64gather_epi64(__m256i __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3div4.di
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.di
   return _mm256_mmask_i64gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128 test_mm_mmask_i64gather_ps(__m128 __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_ps
-  // CHECK: @llvm.x86.avx512.gather3div4.sf
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.sf
   return _mm_mmask_i64gather_ps(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mmask_i64gather_epi32(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mmask_i64gather_epi32
-  // CHECK: @llvm.x86.avx512.gather3div4.si
+  // CHECK: @llvm.x86.avx512.mask.gather3div4.si
   return _mm_mmask_i64gather_epi32(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128 test_mm256_mmask_i64gather_ps(__m128 __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_ps
-  // CHECK: @llvm.x86.avx512.gather3div8.sf
+  // CHECK: @llvm.x86.avx512.mask.gather3div8.sf
   return _mm256_mmask_i64gather_ps(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm256_mmask_i64gather_epi32(__m128i __v1_old, __mmask8 __mask, __m256i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mmask_i64gather_epi32
-  // CHECK: @llvm.x86.avx512.gather3div8.si
+  // CHECK: @llvm.x86.avx512.mask.gather3div8.si
   return _mm256_mmask_i64gather_epi32(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128d test_mm_mask_i32gather_pd(__m128d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mask_i32gather_pd
-  // CHECK: @llvm.x86.avx512.gather3siv2.df
+  // CHECK: @llvm.x86.avx512.mask.gather3siv2.df
   return _mm_mmask_i32gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mask_i32gather_epi64(__m128i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mask_i32gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3siv2.di
+  // CHECK: @llvm.x86.avx512.mask.gather3siv2.di
   return _mm_mmask_i32gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256d test_mm256_mask_i32gather_pd(__m256d __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mask_i32gather_pd
-  // CHECK: @llvm.x86.avx512.gather3siv4.df
+  // CHECK: @llvm.x86.avx512.mask.gather3siv4.df
   return _mm256_mmask_i32gather_pd(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m256i test_mm256_mask_i32gather_epi64(__m256i __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm256_mask_i32gather_epi64
-  // CHECK: @llvm.x86.avx512.gather3siv4.di
+  // CHECK: @llvm.x86.avx512.mask.gather3siv4.di
   return _mm256_mmask_i32gather_epi64(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128 test_mm_mask_i32gather_ps(__m128 __v1_old, __mmask8 __mask, __m128i __index, void const *__addr) {
   // CHECK-LABEL: @test_mm_mask_i32gather_ps
-  // CHECK: @llvm.x86.avx512.gather3siv4.sf
+  // CHECK: @llvm.x86.avx512.mask.gather3siv4.sf
   return _mm_mmask_i32gather_ps(__v1_old, __mask, __index, __addr, 2); 
 }
 
 __m128i test_mm_mask_i32gather_epi32(__m128i __v1_old, __mmask8 __mask, _

[PATCH] D56525: [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56525/new/

https://reviews.llvm.org/D56525



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


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber added a comment.

I am satisfied with the proposed feature set for now. I will try to run the 
check on LLVM itself in the next days as a final test. Are there anymore 
feature requests or changes from your sides?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160



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


[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber added inline comments.



Comment at: clang-tidy/modernize/UseTrailingReturnCheck.cpp:45
+std::string(Message) +
+" (no FixIt provided, function argument list end is inside 
macro)");
+return {};

Eugene.Zelenko wrote:
> MyDeveloperDay wrote:
> > bernhardmgruber wrote:
> > > JonasToth wrote:
> > > > I think you can ellide that extra message. Not emitting the fixit is 
> > > > clear already.
> > > I actually like having a reason why my check could not provide a FixIt. 
> > > Especially because there are multiple reasons why this might happen.
> > @bernhardmgruber I had the same comment given to me on a review recently 
> > with regard to diag message, let me try and help you with what I though was 
> > the rational... I think the premise is something like:
> > 
> > 1) "no FixIt provided" is implied by the fact it isn't fixed
> > 2) "function type source info is missing"  doesn't tell the developer what 
> > they have to do to have it be fixed
> > 
> > sure it helps you as the checker developer but probably that isn't much use 
> > to a developer using the checker on their code and so might confuse them.
> > 
> > It also makes grepping for messages in a log file difficult because it 
> > means multiple messages coming from your checker have a different pattern 
> > (although there might be a common sub pattern)
> > 
> > For the most part where a fixit is not supplied where it should someone 
> > would create a test case which you could consume in your tests
> > 
> > To be honest as a general observation as a newbie myself, what I've noticed 
> > is that a lot of checker review comments are very similar, 
> > 
> > 
> > 
> >   - 80 characters in rst files
> >   - clang-format
> >   - alphabetic order
> >   - Comments with proper puncuation
> >   - code in comments in ``XXX``
> >   - don't overly use auto
> >   - don't use anonymous namespace functions use static functions
> >   - run it on a big C++ project
> >   - run it over all of LLVM
> >   - consistency of coding style (elide unnecessary const)
> >   - elide unnecessary braces/brackets/code/etc..
> > 
> > 
> > 
> > We really should try and write a "Writing a clang checker, and getting it 
> > though review" primer, because I really feel for these "gaints" that we ask 
> > to review all this code, they must go over the same thing and have to 
> > present the same reasons time and time again...
> > 
> > which is why If you don't mind I'd like to try to help give something back 
> > by filling in some of the reasoning gaps here to a fellow new starter
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> > 
> I would say that we should eat own dog food :-)
> 
> I'd love to see your documentation validation scripts as part of build!
> 
> We also should regularly run Clang-tidy on BuildBot. But first we must fix 
> existing warnings and no everybody happy if such cleanups performed by 
> outsiders.
> 
> See PR27267 for anonymous namespaces usage.
> 
> Clang-tidy has modernize-use-auto, but not check for LLVM guidelines 
> conformance.
> 
> Braces should be checked by readability-braces-around-statements, but proper 
> setup is needed.
> 
> Conformance to readability-else-after-return is another typical newbies 
> problem.
Thank you @MyDeveloperDay for the list of tips and rational behind the 
diagnostic messages. I will check this list in the future before I send new 
patches. Maybe it is really a good idea to put this list somewhere!



Comment at: test/clang-tidy/modernize-use-trailing-return.cpp:1
+// RUN: %check_clang_tidy %s modernize-use-trailing-return %t -- -- --std=c++14
+

MyDeveloperDay wrote:
> bernhardmgruber wrote:
> > MyDeveloperDay wrote:
> > > nit: is there a reason here why you say C++14 when the code checks for 
> > > C++11? 
> > Yes. The tests contain functions with deduced return types, such as `auto 
> > f();`. Those require C++14. The check itself is fine with C++11.
> I kind of half guessed it would be something like that after I hit submit,  I 
> noticed some checks add secondary test files which test the various versions 
> of C++, to be honest I found this useful for the checker I'm developing, 
> especially as the checker has some slightly different behavior with C++11 to 
> C++17, but maybe yours doesn't
> 
> to be honest i'm also fairly new here so don't know exactly the convention
> 
> examples where this is already done in other peoples checkers
> 
> modernize-deprecated-headers-cxx03.cpp
> modernize-deprecated-headers-cxx11.cpp
> 
> ```
> // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- 
> -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers -- 
> -std=c++03 -v
> 
> // RUN: %check_clang_tidy %s modernize-deprecated-headers %t -- 
> -extra-arg-before=-isystem%S/Inputs/modernize-deprecated-headers -- 
> -std=c++11 -v
> 
> ```
> 
Thank you for the hint! I just split my tests into C++11 and C++14 versions, 
but then I r

[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber updated this revision to Diff 180973.
bernhardmgruber marked 8 inline comments as done.
bernhardmgruber added a comment.

- Removed detailed diagnostic messages why FixIts could not be generated
- Excluded functions returning member pointers for now
- All tests run now


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160

Files:
  clang-tidy/modernize/CMakeLists.txt
  clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.cpp
  clang-tidy/modernize/UseTrailingReturnCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/modernize-use-trailing-return.rst
  test/clang-tidy/modernize-use-trailing-return.cpp

Index: test/clang-tidy/modernize-use-trailing-return.cpp
===
--- /dev/null
+++ test/clang-tidy/modernize-use-trailing-return.cpp
@@ -0,0 +1,269 @@
+// RUN: %check_clang_tidy %s modernize-use-trailing-return %t -- -- --std=c++14
+
+namespace std {
+template 
+class vector;
+
+class string;
+}
+
+//
+// Functions
+//
+
+int f();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f() -> int;{{$}}
+int f(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int) -> int;{{$}}
+int f(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg) -> int;{{$}}
+int f(int arg1, int arg2, int arg3);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3) -> int;{{$}}
+int f(int arg1, int arg2, int arg3, ...);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto f(int arg1, int arg2, int arg3, ...) -> int;{{$}}
+template  int f(T t);
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}template  auto f(T t) -> int;{{$}}
+
+//
+// Functions with formatting
+//
+
+int a1() { return 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a1() -> int { return 42; }{{$}}
+int a2() {
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a2() -> int {{{$}}
+int a3()
+{
+return 42;
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a3() -> int{{$}}
+int a4(int   arg   )   ;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a4(int   arg   ) -> int   ;{{$}}
+int a5
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto a5{{$}}
+(int arg);
+// CHECK-FIXES: {{^}}(int arg) -> int;{{$}}
+
+//
+// Functions with qualifiers and specifiers
+//
+
+inline int d1(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d1(int arg) -> int;{{$}}
+extern "C" int d2(int arg);
+// CHECK-MESSAGES: :[[@LINE-1]]:16: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}extern "C" auto d2(int arg) -> int;{{$}}
+inline int d3(int arg) noexcept(true);
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d3(int arg) -> int noexcept(true);{{$}}
+inline int d4(int arg) try { } catch(...) { }
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}inline auto d4(int arg) -> int try { } catch(...) { }{{$}}
+
+//
+// Functions in namespaces
+//
+
+namespace N {
+int e1();
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:9: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto e1() -> int;{{$}}
+int N::e1() {}
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: use a trailing return type for this function [modernize-use-trailing-return]
+// CHECK-FIXES: {{^}}auto N::e1() -> int {}{{$}}
+
+//
+// Functions with complex return types
+//
+
+inline volatile const std::vector e2();
+// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: use a trailing retu

[PATCH] D55483: Introduce the callback attribute and emit !callback metadata

2019-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert marked 3 inline comments as done.
jdoerfert added inline comments.



Comment at: include/clang/Basic/Attr.td:1204
+  VariadicUnsignedArgument<"PayloadIndices">];
+  let Subjects = SubjectList<[Function]>;
+  let Documentation = [Undocumented];

jdoerfert wrote:
> aaron.ballman wrote:
> > jdoerfert wrote:
> > > aaron.ballman wrote:
> > > > Should this also apply to Objective-C methods?
> > > > 
> > > > Why should the user specify this attribute on the function as opposed 
> > > > to on the parameter? e.g.,
> > > > ```
> > > > // Why this:
> > > > __attribute__((callback (1, 2, 3)))
> > > > void* broker0(void* (*callee)(void *), void *payload, int otherPayload) 
> > > > {
> > > >   return callee(payload);
> > > > }
> > > > 
> > > > // Instead of this:
> > > > void* broker0(void* (*callee)(void *) __attribute__((callback (2, 3))), 
> > > > void *payload, int otherPayload) {
> > > >   return callee(payload);
> > > > }
> > > > 
> > > > // Or this:
> > > > void* broker0(void* (*callee)(void *) __attribute__((callback (payload, 
> > > > otherPayload))), void *payload, int otherPayload) {
> > > >   return callee(payload);
> > > > }
> > > > ```
> > > > I ask because these "use an index" attributes are really hard for users 
> > > > to use in practice. They have to account for 0-vs-1 based indexing, 
> > > > implicit this parameters, etc and if we can avoid that, it may be worth 
> > > > the effort.
> > > > Should this also apply to Objective-C methods?
> > > 
> > > I don't need it to and unless somebody does, I'd say no.
> > > 
> > > 
> > > > I ask because these "use an index" attributes are really hard for users 
> > > > to use in practice. They have to account for 0-vs-1 based indexing, 
> > > > implicit this parameters, etc and if we can avoid that, it may be worth 
> > > > the effort.
> > > 
> > > I was thinking that the function notation makes it clear that there is 
> > > *only one callback per function* allowed right now. I don't expect many 
> > > manual users of this feature until we improve the middle-end support, so 
> > > it is unclear to me if this requirement needs to be removed as well.
> > > 
> > > Other than that, some thoughts: 
> > > - I do not feel strongly about this.
> > > - The middle requirement seems not much better n the first, we would 
> > > still need to deal with index numbers (callbacks without arguments are 
> > > not really interesting for now). 
> > > - The last encoding requires us to define a symbol for "unknown argument" 
> > > (maybe _ or ?).
> > > I was thinking that the function notation makes it clear that there is 
> > > *only one callback per function* allowed right now.
> > 
> > I don't see how that follows. Users may still try writing:
> > ```
> > __attribute__((callback (1, 3, 4)))
> > __attribute__((callback (2, 3, 4)))
> > void broker0(void (*cb1)(void *, int), void (*cb2)(void *, int), void 
> > *payload, int otherPayload) {
> >   cb1(payload, otherPayload);
> >   cb2(payload, otherPayload);
> > }
> > ```
> > and reasonably expect that to work (we should have this as a test case, and 
> > probably warn on it).
> > 
> > I'm not strongly opposed to the current way this is exposed to users, just 
> > wondering if we can find a better way to surface the feature.
> > 
> > > The last encoding requires us to define a symbol for "unknown argument" 
> > > (maybe _ or ?).
> > 
> > Ah, I wasn't aware that this was part of the feature, but the documentation 
> > you wrote helped to clarify for me. Personal preference is for `?`, but any 
> > symbol will do (so long as we aren't hoping users can count commas, e.g., 
> > `callback(frobble,,,foo)`).
> > and reasonably expect that to work (we should have this as a test case, and 
> > probably warn on it).
> 
> We have a test case and we'll spit out an error. (Sema/attr-callback-broken.c 
> line 21 & 22)
> 
> 
> > I'm not strongly opposed to the current way this is exposed to users, just 
> > wondering if we can find a better way to surface the feature.
> 
> I can change it to the inlined style if nobody disagrees:
> 
> ```
>void broker(int foo, void (*callback)(int, int, int, int) 
> __attribute__((callback(foo, ?, bar, ?))), int bar);
> 
> ```
> 
> As I mentioned, I don't have a strong opinion on this but I just don't want 
> to change it back and forth :)
> 
You can now use parameter names or indices in the callback attribute. The 
special identifiers "__" (double underscore) and "__this" can be used to 
specify an unknown (-1 in the index notation) and the implicit "this" (0 in the 
index notation) argument.



Comment at: test/CodeGen/callback_qsort_r.c:1
+// RUN: %clang %s -fsyntax-only 2>&1 | FileCheck %s
+// RUN: %clang -D_GNU_SOURCE %s -S -c -emit-llvm -o - -O1 | FileCheck %s 
--check-prefix=IR

arichardson wrote:
> This should use a linux triple otherwise the qsort_r declaration is wrong. 
> Ideally it should also handle macos+Fre

[PATCH] D55483: Introduce the callback attribute and emit !callback metadata

2019-01-09 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 180971.
jdoerfert added a comment.

Allow to use names in the callback metadata


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55483/new/

https://reviews.llvm.org/D55483

Files:
  include/clang/AST/ASTContext.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ASTContext.cpp
  lib/Basic/Builtins.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Analysis/retain-release.m
  test/CodeGen/attr-callback.c
  test/CodeGen/callback_annotated.c
  test/CodeGen/callback_openmp.c
  test/CodeGen/callback_pthread_create.c
  test/CodeGenCXX/attr-callback.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/OpenMP/parallel_codegen.cpp
  test/Sema/attr-callback-broken.c
  test/Sema/attr-callback.c
  test/SemaCXX/attr-callback-broken.cpp
  test/SemaCXX/attr-callback.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -775,6 +775,11 @@
 }
   };
 
+  struct VariadicParamOrParamIdxArgument : public VariadicArgument {
+VariadicParamOrParamIdxArgument(const Record &Arg, StringRef Attr)
+: VariadicArgument(Arg, Attr, "int") {}
+  };
+
   // Unique the enums, but maintain the original declaration ordering.
   std::vector
   uniqueEnumsInOrder(const std::vector &enums) {
@@ -1283,6 +1288,8 @@
 Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "VariadicParamIdxArgument")
 Ptr = llvm::make_unique(Arg, Attr);
+  else if (ArgName == "VariadicParamOrParamIdxArgument")
+Ptr = llvm::make_unique(Arg, Attr);
   else if (ArgName == "ParamIdxArgument")
 Ptr = llvm::make_unique(Arg, Attr, "ParamIdx");
   else if (ArgName == "VariadicIdentifierArgument")
@@ -2116,6 +2123,7 @@
  llvm::StringSwitch(
  Arg->getSuperClasses().back().first->getName())
  .Case("VariadicIdentifierArgument", true)
+ .Case("VariadicParamOrParamIdxArgument", true)
  .Default(false);
 }
 
Index: test/SemaCXX/attr-callback.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback.cpp
@@ -0,0 +1,67 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+class C_in_class {
+#include "../Sema/attr-callback.c"
+};
+
+struct Base {
+
+  void no_args_1(void (*callback)(void));
+  __attribute__((callback(1))) void no_args_2(void (*callback)(void));
+  __attribute__((callback(callback))) void no_args_3(void (*callback)(void)) {}
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *));
+
+  __attribute__((callback(1, __this, __, __this))) virtual void
+  this_unknown_this(void (*callback)(Base *, Base *, Base *));
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void));
+
+  __attribute__((callback(callback))) virtual void
+  virtual_2(void (*callback)(void));
+
+  __attribute__((callback(1))) virtual void
+  virtual_3(void (*callback)(void));
+};
+
+__attribute__((callback(1))) void
+Base::no_args_1(void (*callback)(void)) {
+}
+
+void Base::no_args_2(void (*callback)(void)) {
+}
+
+struct Derived_1 : public Base {
+
+  __attribute__((callback(1, 0))) virtual void
+  this_tr(void (*callback)(Base *)) override;
+
+  __attribute__((callback(1))) virtual void
+  virtual_1(void (*callback)(void)) override {}
+
+  virtual void
+  virtual_3(void (*callback)(void)) override {}
+};
+
+struct Derived_2 : public Base {
+
+  __attribute__((callback(callback))) virtual void
+  virtual_1(void (*callback)(void)) override;
+
+  virtual void
+  virtual_2(void (*callback)(void)) override;
+
+  virtual void
+  virtual_3(void (*callback)(void)) override;
+};
+
+void Derived_2::virtual_1(void (*callback)(void)) {}
+
+__attribute__((callback(1))) void
+Derived_2::virtual_2(void (*callback)(void)) {}
+
+void Derived_2::virtual_3(void (*callback)(void)) {}
Index: test/SemaCXX/attr-callback-broken.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-callback-broken.cpp
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+class C_in_class {
+#define HAS_THIS
+#include "../Sema/attr-callback-broken.c"
+#undef HAS_THIS
+};
Index: test/Sema/attr-callback.c
===
--- /dev/null
+++ test/Sema/attr-callback.c
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 %s -verify -fsyntax-only
+
+// expected-no-diagnostics
+
+__attribute__((callback(1))) void no_args(void (*callback)(void));
+__attribute__((callback(1, 2, 3)))   void args_1(void (*callback)(int, double), int a, doubl

[PATCH] D56160: [clang-tidy] modernize-use-trailing-return check

2019-01-09 Thread Bernhard Manfred Gruber via Phabricator via cfe-commits
bernhardmgruber marked an inline comment as done.
bernhardmgruber added a comment.

I spent some time now to get member pointers as return values working and I am 
afraid but it seems there is a problem with the clang AST. Given the following 
code in my check (where `F` is a `FunctionDecl`):

  const TypeSourceInfo *TSI = F.getTypeSourceInfo();
  const FunctionTypeLoc FTL = 
TSI->getTypeLoc().IgnoreParens().getAs();
  auto rl = FTL.getReturnLoc();
  rl.getSourceRange().dump(SM);
  rl.getLocalSourceRange().dump(SM);
  rl.castAs().getSourceRange().dump(SM);
  rl.castAs().getLocalSourceRange().dump(SM);
  rl.castAs().getBeginLoc().dump(SM);
  rl.castAs().getStarLoc().dump(SM);

with the following input:

  namespace std {
  template 
  class vector;
  
  class string;
  }
  
  int std::vector::* e6();
  }

yields these source locations:

  <...\aa.cpp:8:1, col:5>
  <...\aa.cpp:8:5>
  <...\aa.cpp:8:1, col:5>
  <...\aa.cpp:8:5>
  ...\aa.cpp:8:1
  ...\aa.cpp:8:5

The first is the value I usually obtain via `F.getReturnTypeSourceRange()`. The 
following lines are what I saw in my debugger when I stepped into the 
implementation. I believe that `getStarLoc()` should point at the asterisk at 
column 31, not at std at column 5.

I did not find an easy workaround and I would like to avoid manual lexing 
because of the interference with macros. For now, I will just disable the check 
for member pointers.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56160/new/

https://reviews.llvm.org/D56160



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


[PATCH] D56522: [SemaCXX] add -Woverride-init alias to -Winitializer-overrides

2019-01-09 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: include/clang/Basic/DiagnosticGroups.td:364
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;

Please note that this is for GCC compatibility in this comment.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56522/new/

https://reviews.llvm.org/D56522



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


[libunwind] r350787 - Revert "[Sparc] Add Sparc V8 support"

2019-01-09 Thread Jorge Gorbe Moya via cfe-commits
Author: jgorbe
Date: Wed Jan  9 17:08:31 2019
New Revision: 350787

URL: http://llvm.org/viewvc/llvm-project?rev=350787&view=rev
Log:
Revert "[Sparc] Add Sparc V8 support"

This reverts commit r350705.

Modified:
libunwind/trunk/include/__libunwind_config.h
libunwind/trunk/include/libunwind.h
libunwind/trunk/src/DwarfInstructions.hpp
libunwind/trunk/src/DwarfParser.hpp
libunwind/trunk/src/Registers.hpp
libunwind/trunk/src/UnwindCursor.hpp
libunwind/trunk/src/UnwindRegistersRestore.S
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/assembly.h
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/include/__libunwind_config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/__libunwind_config.h?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/include/__libunwind_config.h (original)
+++ libunwind/trunk/include/__libunwind_config.h Wed Jan  9 17:08:31 2019
@@ -23,7 +23,6 @@
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_ARM   287
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_OR1K  32
 #define _LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS  65
-#define _LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC 31
 
 #if defined(_LIBUNWIND_IS_NATIVE_ONLY)
 # if defined(__i386__)
@@ -114,11 +113,6 @@
 #error "Unsupported MIPS ABI and/or environment"
 #  endif
 #  define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_MIPS
-# elif defined(__sparc__)
-  #define _LIBUNWIND_TARGET_SPARC 1
-  #define _LIBUNWIND_HIGHEST_DWARF_REGISTER 
_LIBUNWIND_HIGHEST_DWARF_REGISTER_SPARC
-  #define _LIBUNWIND_CONTEXT_SIZE 16
-  #define _LIBUNWIND_CURSOR_SIZE 23
 # else
 #  error "Unsupported architecture."
 # endif
@@ -132,7 +126,6 @@
 # define _LIBUNWIND_TARGET_OR1K 1
 # define _LIBUNWIND_TARGET_MIPS_O32 1
 # define _LIBUNWIND_TARGET_MIPS_NEWABI 1
-# define _LIBUNWIND_TARGET_SPARC 1
 # define _LIBUNWIND_CONTEXT_SIZE 167
 # define _LIBUNWIND_CURSOR_SIZE 179
 # define _LIBUNWIND_HIGHEST_DWARF_REGISTER 287

Modified: libunwind/trunk/include/libunwind.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/include/libunwind.h?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/include/libunwind.h (original)
+++ libunwind/trunk/include/libunwind.h Wed Jan  9 17:08:31 2019
@@ -823,40 +823,4 @@ enum {
   UNW_MIPS_LO = 65,
 };
 
-// SPARC registers
-enum {
-  UNW_SPARC_G0 = 0,
-  UNW_SPARC_G1 = 1,
-  UNW_SPARC_G2 = 2,
-  UNW_SPARC_G3 = 3,
-  UNW_SPARC_G4 = 4,
-  UNW_SPARC_G5 = 5,
-  UNW_SPARC_G6 = 6,
-  UNW_SPARC_G7 = 7,
-  UNW_SPARC_O0 = 8,
-  UNW_SPARC_O1 = 9,
-  UNW_SPARC_O2 = 10,
-  UNW_SPARC_O3 = 11,
-  UNW_SPARC_O4 = 12,
-  UNW_SPARC_O5 = 13,
-  UNW_SPARC_O6 = 14,
-  UNW_SPARC_O7 = 15,
-  UNW_SPARC_L0 = 16,
-  UNW_SPARC_L1 = 17,
-  UNW_SPARC_L2 = 18,
-  UNW_SPARC_L3 = 19,
-  UNW_SPARC_L4 = 20,
-  UNW_SPARC_L5 = 21,
-  UNW_SPARC_L6 = 22,
-  UNW_SPARC_L7 = 23,
-  UNW_SPARC_I0 = 24,
-  UNW_SPARC_I1 = 25,
-  UNW_SPARC_I2 = 26,
-  UNW_SPARC_I3 = 27,
-  UNW_SPARC_I4 = 28,
-  UNW_SPARC_I5 = 29,
-  UNW_SPARC_I6 = 30,
-  UNW_SPARC_I7 = 31,
-};
-
 #endif

Modified: libunwind/trunk/src/DwarfInstructions.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfInstructions.hpp?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/src/DwarfInstructions.hpp (original)
+++ libunwind/trunk/src/DwarfInstructions.hpp Wed Jan  9 17:08:31 2019
@@ -223,14 +223,6 @@ int DwarfInstructions::stepWithDwa
   }
 #endif
 
-#if defined(_LIBUNWIND_TARGET_SPARC)
-  // Skip call site instruction and delay slot
-  returnAddress += 8;
-  // Skip unimp instruction if function returns a struct
-  if ((addressSpace.get32(returnAddress) & 0xC1C0) == 0)
-returnAddress += 4;
-#endif
-
   // Return address is address after call site instruction, so setting IP 
to
   // that does simualates a return.
   newRegisters.setIP(returnAddress);

Modified: libunwind/trunk/src/DwarfParser.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/DwarfParser.hpp?rev=350787&r1=350786&r2=350787&view=diff
==
--- libunwind/trunk/src/DwarfParser.hpp (original)
+++ libunwind/trunk/src/DwarfParser.hpp Wed Jan  9 17:08:31 2019
@@ -685,22 +685,6 @@ bool CFI_Parser::parseInstructions(A
   break;
 #endif
 
-#if defined(_LIBUNWIND_TARGET_SPARC)
-case DW_CFA_GNU_window_save:
-  _LIBUNWIND_TRACE_DWARF("DW_CFA_GNU_window_save()\n");
-  for (reg = UNW_SPARC_O0; reg <= UNW_SPARC_O7; reg++) {
-results->savedRegisters[reg].location = kRegisterInRegister;
-results->savedRegisters[reg].value =
-(reg - UNW_SPARC_O0) + UNW_SPARC_I0;
-  }
-
-  for (reg = UNW_SPARC_L0; reg 

[PATCH] D50106: [libc++] Fix tuple assignment from type derived from a tuple-like

2019-01-09 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.
Herald added subscribers: libcxx-commits, jkorous.

Ping! It would be nice to land this in LLVM 8


Repository:
  rCXX libc++

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50106/new/

https://reviews.llvm.org/D50106



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


[PATCH] D56525: [AMDGPU] Separate feature dot-insts

2019-01-09 Thread Stanislav Mekhanoshin via Phabricator via cfe-commits
rampitec created this revision.
rampitec added reviewers: b-sumner, kzhuravl, msearles.
Herald added subscribers: cfe-commits, t-tye, tpr, dstuttard, yaxunl, nhaehnle, 
wdng, jvesely.

clang part


Repository:
  rC Clang

https://reviews.llvm.org/D56525

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/Basic/Targets/AMDGPU.cpp
  test/CodeGenOpenCL/amdgpu-features.cl
  test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl


Index: test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
+++ test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
@@ -12,24 +12,24 @@
 half2 v2hA, half2 v2hB, float fC,
 short2 v2ssA, short2 v2ssB, int siA, int siB, int siC,
 ushort2 v2usA, ushort2 v2usB, uint uiA, uint uiB, uint uiC) {
-  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
-  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dl-insts}}
+  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, false); // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
+  fOut[1] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, true);  // 
expected-error {{'__builtin_amdgcn_fdot2' needs target feature dot-insts}}
 
-  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
-  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dl-insts}}
+  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
+  siOut[1] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot2' needs target feature dot-insts}}
 
-  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
-  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dl-insts}}
+  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
+  uiOut[1] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot2' needs target feature dot-insts}}
 
-  siOut[2] = __builtin_amdgcn_sdot4(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
-  siOut[3] = __builtin_amdgcn_sdot4(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dl-insts}}
+  siOut[2] = __builtin_amdgcn_sdot4(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dot-insts}}
+  siOut[3] = __builtin_amdgcn_sdot4(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot4' needs target feature dot-insts}}
 
-  uiOut[2] = __builtin_amdgcn_udot4(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dl-insts}}
-  uiOut[3] = __builtin_amdgcn_udot4(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dl-insts}}
+  uiOut[2] = __builtin_amdgcn_udot4(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dot-insts}}
+  uiOut[3] = __builtin_amdgcn_udot4(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot4' needs target feature dot-insts}}
 
-  siOut[4] = __builtin_amdgcn_sdot8(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dl-insts}}
-  siOut[5] = __builtin_amdgcn_sdot8(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dl-insts}}
+  siOut[4] = __builtin_amdgcn_sdot8(siA, siB, siC, false); // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dot-insts}}
+  siOut[5] = __builtin_amdgcn_sdot8(siA, siB, siC, true);  // 
expected-error {{'__builtin_amdgcn_sdot8' needs target feature dot-insts}}
 
-  uiOut[4] = __builtin_amdgcn_udot8(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dl-insts}}
-  uiOut[5] = __builtin_amdgcn_udot8(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dl-insts}}
+  uiOut[4] = __builtin_amdgcn_udot8(uiA, uiB, uiC, false); // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dot-insts}}
+  uiOut[5] = __builtin_amdgcn_udot8(uiA, uiB, uiC, true);  // 
expected-error {{'__builtin_amdgcn_udot8' needs target feature dot-insts}}
 }
Index: test/CodeGenOpenCL/amdgpu-features.cl
===
--- test/CodeGenOpenCL/amdgpu-

[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1351824 , @rjmccall wrote:

> But why?  Why do you want to limit this to just template arguments instead of 
> all sorts of similar contexts?


I updated the patch to disable the check for unevaluated expr context and const 
evaluated context, except the deferred check.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D56523: Improve a -Wunguarded-availability note

2019-01-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: arphaman.
Herald added subscribers: dexonsmith, jkorous.

Mention the deployment target, and don't say "partial" which doesn't really 
mean anything to users.

rdar://problem/33601513


Repository:
  rC Clang

https://reviews.llvm.org/D56523

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/attr-availability.c
  clang/test/Sema/availability-guard-format.mm
  clang/test/SemaObjC/attr-availability.m
  clang/test/SemaObjC/property-deprecated-warning.m
  clang/test/SemaObjC/unguarded-availability-new.m
  clang/test/SemaObjC/unguarded-availability.m

Index: clang/test/SemaObjC/unguarded-availability.m
===
--- clang/test/SemaObjC/unguarded-availability.m
+++ clang/test/SemaObjC/unguarded-availability.m
@@ -5,14 +5,14 @@
 #define AVAILABLE_10_11 __attribute__((availability(macos, introduced = 10.11)))
 #define AVAILABLE_10_12 __attribute__((availability(macos, introduced = 10.12)))
 
-typedef int AVAILABLE_10_12 new_int; // expected-note + {{marked partial here}}
+typedef int AVAILABLE_10_12 new_int; // expected-note + {{'new_int' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
-int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been explicitly marked partial here}}
+int func_10_11() AVAILABLE_10_11; // expected-note 8 {{'func_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.4.0}}
 
 #ifdef OBJCPP
-// expected-note@+2 6 {{marked partial here}}
+// expected-note@+2 6 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 #endif
-int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been explicitly marked partial here}}
+int func_10_12() AVAILABLE_10_12; // expected-note 7 {{'func_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
 int func_10_0() AVAILABLE_10_0;
 
@@ -61,11 +61,11 @@
   }
 }
 
-typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been explicitly marked partial here}}
+typedef int int_10_11 AVAILABLE_10_11; // expected-note {{'int_10_11' has been marked as being introduced in macOS 10.11 here, but the deployment target is macOS 10.4.0}}
 #ifdef OBJCPP
-// expected-note@+2 {{marked partial here}}
+// expected-note@+2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 #endif
-typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been explicitly marked partial here}}
+typedef int int_10_12 AVAILABLE_10_12; // expected-note 2 {{'int_10_12' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
 void use_typedef() {
   int_10_11 x; // expected-warning{{'int_10_11' is only available on macOS 10.11 or newer}} expected-note{{enclose 'int_10_11' in an @available check to silence this warning}}
@@ -106,10 +106,10 @@
 
 struct S {
   int m1;
-  int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{marked partial here}}
+  int m2 __attribute__((availability(macos, introduced = 10.12))); // expected-note{{has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 
   struct Nested {
-int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{marked partial here}}
+int nested_member __attribute__((availability(macos, introduced = 10.12))); // expected-note{{'nested_member' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
   } n;
 };
 
@@ -139,9 +139,9 @@
 
 AVAILABLE_10_12
 __attribute__((objc_root_class))
-@interface InterWithProp // expected-note 2 {{marked partial here}}
+@interface InterWithProp // expected-note 2 {{'InterWithProp' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 @property(class) int x;
-+ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{marked partial here}}
++ (void) setX: (int)newX AVAILABLE_10_12; // expected-note{{'setX:' has been marked as being introduced in macOS 10.12 here, but the deployment target is macOS 10.4.0}}
 @end
 void test_property(void) {
   int y = InterWithProp.x; // expected-warning{{'InterWithProp' is only available on macOS 10.12 or newer}} expected-note{{@available}}
@@ -150,7 +150,7 @@
 
 __attribute__((objc_root_class))
 @interface Subscriptable
-- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{marked partial here}}
+- (id)objectAtIndexedSubscript:(int)sub AVAILABLE_10_12; // expected-note{{'objectAtIndexedSubscript:' has been marked as being introduced in macOS 10.12 here,

r350785 - [X86] Really make the pointer arguments to avx512 gather/scatter intrinsics 'void*' to match gcc and Intel's documentation.

2019-01-09 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jan  9 16:47:25 2019
New Revision: 350785

URL: http://llvm.org/viewvc/llvm-project?rev=350785&view=rev
Log:
[X86] Really make the pointer arguments to avx512 gather/scatter intrinsics 
'void*' to match gcc and Intel's documentation.

The avx2 gather intrinsics are documented to use 'int', 'long long', 'float', 
or 'double' *. So I'm leaving those. This matches gcc.

I tried to do this in r350696, but I only updated the header not the builtin 
definition.

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=350785&r1=350784&r2=350785&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jan  9 16:47:25 2019
@@ -968,47 +968,47 @@ TARGET_BUILTIN(__builtin_ia32_vpdpwssds1
 TARGET_BUILTIN(__builtin_ia32_vpdpwssds256, "V8iV8iV8iV8i", "ncV:256:", 
"avx512vl,avx512vnni")
 TARGET_BUILTIN(__builtin_ia32_vpdpwssds512, "V16iV16iV16iV16i", "ncV:512:", 
"avx512vnni")
 
-TARGET_BUILTIN(__builtin_ia32_gather3div2df, "V2dV2ddC*V2LLiUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div2di, "V2LLiV2LLiLLiC*V2LLiUcIi", 
"nV:128:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4df, "V4dV4ddC*V4LLiUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4di, "V4LLiV4LLiLLiC*V4LLiUcIi", 
"nV:256:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4sf, "V4fV4ffC*V2LLiUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div4si, "V4iV4iiC*V2LLiUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div8sf, "V4fV4ffC*V4LLiUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3div8si, "V4iV4iiC*V4LLiUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv2df, "V2dV2ddC*V4iUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv2di, "V2LLiV2LLiLLiC*V4iUcIi", 
"nV:128:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4df, "V4dV4ddC*V4iUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4di, "V4LLiV4LLiLLiC*V4iUcIi", 
"nV:256:", "avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4sf, "V4fV4ffC*V4iUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv4si, "V4iV4iiC*V4iUcIi", "nV:128:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv8sf, "V8fV8ffC*V8iUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gather3siv8si, "V8iV8iiC*V8iUcIi", "nV:256:", 
"avx512vl")
-TARGET_BUILTIN(__builtin_ia32_gathersiv8df, "V8dV8ddC*V8iUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16sf, "V16fV16ffC*V16fUsIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv8df, "V8dV8ddC*V8LLiUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv16sf, "V8fV8ffC*V8LLiUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv8di, "V8LLiV8LLiLLiC*V8iUcIi", 
"nV:512:", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_gathersiv16si, "V16iV16iiC*V16iUsIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv8di, "V8LLiV8LLiLLiC*V8LLiUcIi", 
"nV:512:", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_gatherdiv16si, "V8iV8iiC*V8LLiUcIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv8df, "vd*UcV8iV8dIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv16sf, "vf*UsV16iV16fIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv8df,  "vd*UcV8LLiV8dIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv16sf, "vf*UcV8LLiV8fIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv8di,  "vLLi*UcV8iV8LLiIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scattersiv16si, "vi*UsV16iV16iIi", "nV:512:", 
"avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv8di,  "vLLi*UcV8LLiV8LLiIi", 
"nV:512:", "avx512f")
-TARGET_BUILTIN(__builtin_ia32_scatterdiv16si, "vi*UcV8LLiV8iIi", "nV:512:", 
"avx512f")
-
-TARGET_BUILTIN(__builtin_ia32_gatherpfdpd,  "vUcV8iLLiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_gatherpfdps,  "vUsV16iiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_gatherpfqpd,  "vUcV8LLiLLiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_gatherpfqps,  "vUcV8LLiiC*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfdpd, "vUcV8iLLi*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfdps, "vUsV16ii*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfqpd, "vUcV8LLiLLi*IiIi", "nV:512:", 
"avx512pf")
-TARGET_BUILTIN(__builtin_ia32_scatterpfqps, "vUcV8LLii*IiIi", "nV:512:", 
"avx512pf")
+TARGET_BUILTIN(__builtin_ia32_gather3div2df, "V2dV2dvC*V2LLiUcIi", "nV:128:", 
"avx512vl")
+TARGET_BUILTIN(__builtin_ia32_gather3div2di, "V2LLiV2LLivC*V2LLiUcIi", 

[PATCH] D56522: [SemaCXX] add -Woverride-init alias to -Winitializer-overrides

2019-01-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers created this revision.
nickdesaulniers added a reviewer: rsmith.
Herald added a subscriber: cfe-commits.

https://bugs.llvm.org/show_bug.cgi?id=40251
https://github.com/ClangBuiltLinux/linux/issues/307


Repository:
  rC Clang

https://reviews.llvm.org/D56522

Files:
  docs/DiagnosticsReference.rst
  include/clang/Basic/DiagnosticGroups.td
  test/SemaCXX/designated-initializers.cpp


Index: test/SemaCXX/designated-initializers.cpp
===
--- test/SemaCXX/designated-initializers.cpp
+++ test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -361,6 +361,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: docs/DiagnosticsReference.rst
===
--- docs/DiagnosticsReference.rst
+++ docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |  
 |+-+|
 
+---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -


Index: test/SemaCXX/designated-initializers.cpp
===
--- test/SemaCXX/designated-initializers.cpp
+++ test/SemaCXX/designated-initializers.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Winitializer-overrides %s
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify -Woverride-init %s
 
 template  struct Foo {
   struct SubFoo {
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -361,6 +361,8 @@
 def NullCharacter : DiagGroup<"null-character">;
 def NullDereference : DiagGroup<"null-dereference">;
 def InitializerOverrides : DiagGroup<"initializer-overrides">;
+// -Woverride-init = -Winitializer-overrides
+def : DiagGroup<"override-init", [InitializerOverrides]>;
 def NonNull : DiagGroup<"nonnull">;
 def NonPODVarargs : DiagGroup<"non-pod-varargs">;
 def ClassVarargs : DiagGroup<"class-varargs", [NonPODVarargs]>;
Index: docs/DiagnosticsReference.rst
===
--- docs/DiagnosticsReference.rst
+++ docs/DiagnosticsReference.rst
@@ -7885,6 +7885,10 @@
 |   |+-+|
 +---+---+
 
+-Woverride-init
+--
+Synonym for `-Winitializer-overrides`_.
+
 
 -Woverride-module
 -
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 180960.
yaxunl added a comment.

disable the check for more general cases.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCUDA/kernel-template-with-func-arg.cu

Index: test/SemaCUDA/kernel-template-with-func-arg.cu
===
--- /dev/null
+++ test/SemaCUDA/kernel-template-with-func-arg.cu
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+struct C {
+  __device__ void devfun() {}
+  void hostfun() {}
+  template __device__ void devtempfun() {}
+  __device__ __host__ void devhostfun() {}
+};
+
+__device__ void devfun() {}
+__host__ void hostfun() {}
+template __device__ void devtempfun() {}
+__device__ __host__ void devhostfun() {}
+
+template  __global__ void kernel() { devF();}
+template  __global__ void kernel2(T *p) { (p->*devF)(); }
+
+template<> __global__ void kernel();
+template<> __global__ void kernel(); // expected-error {{no function template matches function template specialization 'kernel'}}
+  // expected-note@-5 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel >();
+template<> __global__ void kernel();
+
+template<> __global__ void kernel<&devfun>();
+template<> __global__ void kernel<&hostfun>(); // expected-error {{no function template matches function template specialization 'kernel'}}
+   // expected-note@-11 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel<&devtempfun >();
+template<> __global__ void kernel<&devhostfun>();
+
+template<> __global__ void kernel2(C *p);
+template<> __global__ void kernel2(C *p); // expected-error {{no function template matches function template specialization 'kernel2'}}
+  // expected-note@-16 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel2 >(C *p);
+template<> __global__ void kernel2(C *p);
+
+void fun() {
+  kernel<&devfun><<<1,1>>>();
+  kernel<&hostfun><<<1,1>>>(); // expected-error {{no matching function for call to 'kernel'}}
+   // expected-note@-24 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel<&devtempfun ><<<1,1>>>();
+  kernel<&devhostfun><<<1,1>>>();
+
+  kernel<<<1,1>>>();
+  kernel<<<1,1>>>(); // expected-error {{no matching function for call to 'kernel'}}
+  // expected-note@-30 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel ><<<1,1>>>();
+  kernel<<<1,1>>>();
+
+  C a;
+  kernel2<<<1,1>>>(&a);
+  kernel2<<<1,1>>>(&a); // expected-error {{no matching function for call to 'kernel2'}}
+// expected-note@-36 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel2 ><<<1,1>>>(&a);
+  kernel2<<<1,1>>>(&a);
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -4534,6 +4534,7 @@
 
   EnterExpressionEvaluationContext ConstantEvaluated(
   SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+  SemaRef.ExprEvalContexts.back().Template = Template;
   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
 }
 
@@ -4784,8 +4785,8 @@
   TemplateArgument Result;
   unsigned CurSFINAEErrors = NumSFINAEErrors;
   ExprResult Res =
-CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
-  Result, CTAK);
+  CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
+Result, CTAK, dyn_cast(Template));
   if (Res.isInvalid())
 return true;
   // If the current template argument causes an error, give up now.
@@ -6154,6 +6155,22 @@
   return true;
 }
 
+namespace {
+FunctionDecl *GetFunctionDecl(Expr *Arg) {
+  Expr *E = Arg;
+  if (UnaryOperator *UO = dyn_cast(E)) {
+E = UO ? UO->getSubExpr() : nullptr;
+  }
+  if (DeclRefExpr *DRE = dyn_cast_or_null(E)) {
+ValueDecl *Entity = DRE ? DRE->getDecl() : nullptr;
+if (Entity) {
+  if (auto Callee = dyn_cast(Entity))
+return Callee;
+}
+  }
+  return nullptr;
+}
+} // namespace
 /// Check a template argument against its corresponding
 /// non-type template parameter.
 ///
@@ -6164,7 +6181,8 @@
 ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmDecl *Param,
  

[PATCH] D55844: [Fixed Point Arithmetic] Fixed Point Subtraction

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/CGExprScalar.cpp:3451
+  case BO_Comma:
+llvm_unreachable("Found unimplemented fixed point binary operation");
   }

Please create a separate case for the non-arithmetic operators 
(pointer-to-member, assignment, comma) that will obviously never end up in this 
function.

Otherwise, LGTM.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55844/new/

https://reviews.llvm.org/D55844



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


r350779 - In nothrow new-expressions, null-check the result if we're going to

2019-01-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Jan  9 16:03:29 2019
New Revision: 350779

URL: http://llvm.org/viewvc/llvm-project?rev=350779&view=rev
Log:
In nothrow new-expressions, null-check the result if we're going to
apply sanitizers to it.

This avoids a sanitizer false positive that we are initializing a null
pointer.

Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=350779&r1=350778&r2=350779&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Wed Jan  9 16:03:29 2019
@@ -1656,9 +1656,10 @@ llvm::Value *CodeGenFunction::EmitCXXNew
   // Emit a null check on the allocation result if the allocation
   // function is allowed to return null (because it has a non-throwing
   // exception spec or is the reserved placement new) and we have an
-  // interesting initializer.
+  // interesting initializer will be running sanitizers on the initialization.
   bool nullCheck = E->shouldNullCheckAllocation() &&
-   (!allocType.isPODType(getContext()) || E->hasInitializer());
+   (!allocType.isPODType(getContext()) || E->hasInitializer() 
||
+sanitizePerformTypeCheck());
 
   llvm::BasicBlock *nullCheckBB = nullptr;
   llvm::BasicBlock *contBB = nullptr;

Modified: cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp?rev=350779&r1=350778&r2=350779&view=diff
==
--- cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/catch-undef-behavior.cpp Wed Jan  9 16:03:29 2019
@@ -520,6 +520,49 @@ void upcast_to_vbase() {
 }
 }
 
+struct nothrow {};
+void *operator new[](__SIZE_TYPE__, nothrow) noexcept;
+
+namespace NothrowNew {
+  struct X { X(); };
+
+  // CHECK-LABEL: define{{.*}}nothrow_new_trivial
+  void *nothrow_new_trivial() {
+// CHECK: %[[is_null:.*]] = icmp eq i8*{{.*}}, null
+// CHECK: br i1 %[[is_null]], label %[[null:.*]], label %[[nonnull:.*]]
+
+// CHECK: [[nonnull]]:
+// CHECK: llvm.objectsize
+// CHECK: br i1
+//
+// CHECK: call {{.*}}__ubsan_handle_type_mismatch
+//
+// CHECK: [[null]]:
+// CHECK-NOT: {{ }}br{{ }}
+// CHECK: ret
+return new (nothrow{}) char[123456];
+  }
+
+  // CHECK-LABEL: define{{.*}}nothrow_new_nontrivial
+  void *nothrow_new_nontrivial() {
+// CHECK: %[[is_null:.*]] = icmp eq i8*{{.*}}, null
+// CHECK: br i1 %[[is_null]], label %[[null:.*]], label %[[nonnull:.*]]
+
+// CHECK: [[nonnull]]:
+// CHECK: llvm.objectsize
+// CHECK: br i1
+//
+// CHECK: call {{.*}}__ubsan_handle_type_mismatch
+//
+// CHECK: call {{.*}}_ZN10NothrowNew1XC1Ev
+//
+// CHECK: [[null]]:
+// CHECK-NOT: {{ }}br{{ }}
+// CHECK: ret
+return new (nothrow{}) X[123456];
+  }
+}
+
 struct ThisAlign {
   void this_align_lambda();
   void this_align_lambda_2();


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


[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Don't worry, that's a familiar mistake. :)

LGTM.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188



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


r350776 - [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread Nick Desaulniers via cfe-commits
Author: nickdesaulniers
Date: Wed Jan  9 15:54:55 2019
New Revision: 350776

URL: http://llvm.org/viewvc/llvm-project?rev=350776&view=rev
Log:
[Sema] Mark target of __attribute__((alias("target"))) used for C

Summary:
Prevents -Wunneeded-internal-delcaration warnings when the target has no
other references. This occurs frequently in device drivers in the Linux
kernel.

Sema would need to invoke the demangler on the target, since in C++ the
target name is mangled:

int f() { return 42; }
int g() __attribute__((alias("_Z1fv")));

Sema does not have the ability to demangle names at this time.

https://bugs.llvm.org/show_bug.cgi?id=39088
https://github.com/ClangBuiltLinux/linux/issues/232

Reviewers: rsmith, rjmccall

Reviewed By: rsmith

Subscribers: erik.pilkington, cfe-commits, pirama, srhines

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

Added:
cfe/trunk/test/Sema/alias-unused.c
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=350776&r1=350775&r2=350776&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan  9 15:54:55 2019
@@ -1898,7 +1898,16 @@ static void handleAliasAttr(Sema &S, Dec
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));

Added: cfe/trunk/test/Sema/alias-unused.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/alias-unused.c?rev=350776&view=auto
==
--- cfe/trunk/test/Sema/alias-unused.c (added)
+++ cfe/trunk/test/Sema/alias-unused.c Wed Jan  9 15:54:55 2019
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x 
c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));


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


[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread Nick Desaulniers via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
nickdesaulniers marked an inline comment as done.
Closed by commit rL350776: [Sema] Mark target of 
__attribute__((alias("target"))) used for C (authored by 
nickdesaulniers, committed by ).
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188

Files:
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/Sema/alias-unused.c


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1898,7 +1898,16 @@
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));
Index: cfe/trunk/test/Sema/alias-unused.c
===
--- cfe/trunk/test/Sema/alias-unused.c
+++ cfe/trunk/test/Sema/alias-unused.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x 
c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));


Index: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp
@@ -1898,7 +1898,16 @@
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));
Index: cfe/trunk/test/Sema/alias-unused.c
===
--- cfe/trunk/test/Sema/alias-unused.c
+++ cfe/trunk/test/Sema/alias-unused.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56518: Change the symbol for the default Swift CFString class.

2019-01-09 Thread Lily Vulcano via Phabricator via cfe-commits
millenomi created this revision.
Herald added a subscriber: cfe-commits.

Required for the work in 
https://github.com/apple/swift-corelibs-foundation/pull/1799


Repository:
  rC Clang

https://reviews.llvm.org/D56518

Files:
  lib/CodeGen/CodeGenModule.cpp


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4235,8 +4235,8 @@
 case LangOptions::CoreFoundationABI::Swift: LLVM_FALLTHROUGH;
 case LangOptions::CoreFoundationABI::Swift5_0:
   CFConstantStringClassName =
-  Triple.isOSDarwin() ? "$s15SwiftFoundation19_NSCFConstantStringCN"
-  : "$s10Foundation19_NSCFConstantStringCN";
+  Triple.isOSDarwin() ? 
"$s19SwiftFoundationBase19_NSCFConstantStringCN"
+  : "$s14FoundationBase19_NSCFConstantStringCN";
   Ty = IntPtrTy;
   break;
 case LangOptions::CoreFoundationABI::Swift4_2:


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -4235,8 +4235,8 @@
 case LangOptions::CoreFoundationABI::Swift: LLVM_FALLTHROUGH;
 case LangOptions::CoreFoundationABI::Swift5_0:
   CFConstantStringClassName =
-  Triple.isOSDarwin() ? "$s15SwiftFoundation19_NSCFConstantStringCN"
-  : "$s10Foundation19_NSCFConstantStringCN";
+  Triple.isOSDarwin() ? "$s19SwiftFoundationBase19_NSCFConstantStringCN"
+  : "$s14FoundationBase19_NSCFConstantStringCN";
   Ty = IntPtrTy;
   break;
 case LangOptions::CoreFoundationABI::Swift4_2:
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55491: Implement TemplateArgument dumping in terms of Visitor

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 180947.
steveire added a comment.

Rebase


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55491/new/

https://reviews.llvm.org/D55491

Files:
  include/clang/AST/TemplateArgumentVisitor.h
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp

Index: lib/AST/TextNodeDumper.cpp
===
--- lib/AST/TextNodeDumper.cpp
+++ lib/AST/TextNodeDumper.cpp
@@ -64,6 +64,19 @@
   ConstAttrVisitor::Visit(A);
 }
 
+void TextNodeDumper::Visit(const TemplateArgument &TA, SourceRange R,
+   const Decl *From, const char *label) {
+  OS << "TemplateArgument";
+  if (R.isValid())
+dumpSourceRange(R);
+
+  if (From) {
+dumpDeclRef(From, label);
+  }
+
+  ConstTemplateArgumentVisitor::Visit(TA);
+}
+
 void TextNodeDumper::dumpPointer(const void *Ptr) {
   ColorScope Color(OS, ShowColors, AddressColor);
   OS << ' ' << Ptr;
@@ -317,3 +330,45 @@
 const comments::VerbatimLineComment *C, const comments::FullComment *) {
   OS << " Text=\"" << C->getText() << "\"";
 }
+
+void TextNodeDumper::VisitNullTemplateArgument(const TemplateArgument &) {
+  OS << " null";
+}
+
+void TextNodeDumper::VisitTypeTemplateArgument(const TemplateArgument &TA) {
+  OS << " type";
+  dumpType(TA.getAsType());
+}
+
+void TextNodeDumper::VisitDeclarationTemplateArgument(
+const TemplateArgument &TA) {
+  OS << " decl";
+  dumpDeclRef(TA.getAsDecl());
+}
+
+void TextNodeDumper::VisitNullPtrTemplateArgument(const TemplateArgument &) {
+  OS << " nullptr";
+}
+
+void TextNodeDumper::VisitIntegralTemplateArgument(const TemplateArgument &TA) {
+  OS << " integral " << TA.getAsIntegral();
+}
+
+void TextNodeDumper::VisitTemplateTemplateArgument(const TemplateArgument &TA) {
+  OS << " template ";
+  TA.getAsTemplate().dump(OS);
+}
+
+void TextNodeDumper::VisitTemplateExpansionTemplateArgument(
+const TemplateArgument &TA) {
+  OS << " template expansion ";
+  TA.getAsTemplateOrTemplatePattern().dump(OS);
+}
+
+void TextNodeDumper::VisitExpressionTemplateArgument(const TemplateArgument &) {
+  OS << " expr";
+}
+
+void TextNodeDumper::VisitPackTemplateArgument(const TemplateArgument &) {
+  OS << " pack";
+}
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -24,6 +24,7 @@
 #include "clang/AST/DeclVisitor.h"
 #include "clang/AST/LocInfoType.h"
 #include "clang/AST/StmtVisitor.h"
+#include "clang/AST/TemplateArgumentVisitor.h"
 #include "clang/AST/TextNodeDumper.h"
 #include "clang/AST/TypeVisitor.h"
 #include "clang/Basic/Builtins.h"
@@ -44,7 +45,8 @@
 public ConstStmtVisitor,
 public ConstCommentVisitor,
 public TypeVisitor,
-public ConstAttrVisitor {
+public ConstAttrVisitor,
+public ConstTemplateArgumentVisitor {
 
 TextNodeDumper NodeDumper;
 
@@ -440,6 +442,16 @@
 // Comments.
 void dumpComment(const Comment *C, const FullComment *FC);
 
+void VisitExpressionTemplateArgument(const TemplateArgument &TA) {
+  dumpStmt(TA.getAsExpr());
+}
+void VisitPackTemplateArgument(const TemplateArgument &TA) {
+  for (TemplateArgument::pack_iterator I = TA.pack_begin(),
+   E = TA.pack_end();
+   I != E; ++I)
+dumpTemplateArgument(*I);
+}
+
 // Implements Visit methods for Attrs
 #include "clang/AST/AttrNodeTraverse.inc"
   };
@@ -670,50 +682,8 @@
 void ASTDumper::dumpTemplateArgument(const TemplateArgument &A, SourceRange R,
  const Decl *From, const char *Label) {
   dumpChild([=] {
-OS << "TemplateArgument";
-if (R.isValid())
-  NodeDumper.dumpSourceRange(R);
-
-if (From)
-  NodeDumper.dumpDeclRef(From, Label);
-
-switch (A.getKind()) {
-case TemplateArgument::Null:
-  OS << " null";
-  break;
-case TemplateArgument::Type:
-  OS << " type";
-  NodeDumper.dumpType(A.getAsType());
-  break;
-case TemplateArgument::Declaration:
-  OS << " decl";
-  NodeDumper.dumpDeclRef(A.getAsDecl());
-  break;
-case TemplateArgument::NullPtr:
-  OS << " nullptr";
-  break;
-case TemplateArgument::Integral:
-  OS << " integral " << A.getAsIntegral();
-  break;
-case TemplateArgument::Template:
-  OS << " template ";
-  A.getAsTemplate().dump(OS);
-  break;
-case TemplateArgument::TemplateExpansion:
-  OS << " template expansion ";
-  A.getAsTemplateOrTemplatePattern().dump(OS);
-  break;
-case TemplateArgument::Expression:
-  OS << " expr";
-  dumpStmt(A.getAsExpr());
-  break;
-case TemplateArgument::Pack:
-  OS << " pack";
-  for (TemplateArgument::pack_iterator I = A.pack_begin(), E = A.pack_end();
-   I != E; ++I)
-dumpTemplateArgument(*I)

[PATCH] D55492: Implement Attr dumping in terms of visitors

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire marked an inline comment as done.
steveire added inline comments.



Comment at: utils/TableGen/ClangAttrEmitter.cpp:3726
+functionContent = SS.str();
+if (SS.tell()) {
+  OS << "  void Visit" << R.getName() << "Attr(const " << R.getName()

aaron.ballman wrote:
> Wouldn't this be `!FunctionContent.empty()`?
I would have thought so, but apparently that's not how `raw_string_ostream` 
works. I get an empty file from this if I do that.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55492/new/

https://reviews.llvm.org/D55492



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


[PATCH] D55492: Implement Attr dumping in terms of visitors

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 180943.
steveire added a comment.

Updates


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55492/new/

https://reviews.llvm.org/D55492

Files:
  include/clang/AST/AttrVisitor.h
  include/clang/AST/CMakeLists.txt
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  lib/AST/TextNodeDumper.cpp
  utils/TableGen/ClangAttrEmitter.cpp
  utils/TableGen/TableGen.cpp
  utils/TableGen/TableGenBackends.h

Index: utils/TableGen/TableGenBackends.h
===
--- utils/TableGen/TableGenBackends.h
+++ utils/TableGen/TableGenBackends.h
@@ -45,7 +45,10 @@
 void EmitClangAttrParsedAttrList(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangAttrParsedAttrImpl(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
 void EmitClangAttrParsedAttrKinds(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
-void EmitClangAttrDump(llvm::RecordKeeper &Records, llvm::raw_ostream &OS);
+void EmitClangAttrTextNodeDump(llvm::RecordKeeper &Records,
+   llvm::raw_ostream &OS);
+void EmitClangAttrNodeTraverse(llvm::RecordKeeper &Records,
+   llvm::raw_ostream &OS);
 
 void EmitClangDiagsDefs(llvm::RecordKeeper &Records, llvm::raw_ostream &OS,
 const std::string &Component);
Index: utils/TableGen/TableGen.cpp
===
--- utils/TableGen/TableGen.cpp
+++ utils/TableGen/TableGen.cpp
@@ -40,7 +40,8 @@
   GenClangAttrParsedAttrList,
   GenClangAttrParsedAttrImpl,
   GenClangAttrParsedAttrKinds,
-  GenClangAttrDump,
+  GenClangAttrTextNodeDump,
+  GenClangAttrNodeTraverse,
   GenClangDiagsDefs,
   GenClangDiagGroups,
   GenClangDiagsIndexName,
@@ -112,8 +113,10 @@
 clEnumValN(GenClangAttrParsedAttrKinds,
"gen-clang-attr-parsed-attr-kinds",
"Generate a clang parsed attribute kinds"),
-clEnumValN(GenClangAttrDump, "gen-clang-attr-dump",
-   "Generate clang attribute dumper"),
+clEnumValN(GenClangAttrTextNodeDump, "gen-clang-attr-text-node-dump",
+   "Generate clang attribute text node dumper"),
+clEnumValN(GenClangAttrNodeTraverse, "gen-clang-attr-node-traverse",
+   "Generate clang attribute traverser"),
 clEnumValN(GenClangDiagsDefs, "gen-clang-diags-defs",
"Generate Clang diagnostics definitions"),
 clEnumValN(GenClangDiagGroups, "gen-clang-diag-groups",
@@ -221,8 +224,11 @@
   case GenClangAttrParsedAttrKinds:
 EmitClangAttrParsedAttrKinds(Records, OS);
 break;
-  case GenClangAttrDump:
-EmitClangAttrDump(Records, OS);
+  case GenClangAttrTextNodeDump:
+EmitClangAttrTextNodeDump(Records, OS);
+break;
+  case GenClangAttrNodeTraverse:
+EmitClangAttrNodeTraverse(Records, OS);
 break;
   case GenClangDiagsDefs:
 EmitClangDiagsDefs(Records, OS, ClangComponent);
Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -603,14 +603,15 @@
   OS << "OS << \"";
 }
 
-void writeDump(raw_ostream &OS) const override {}
+void writeDump(raw_ostream &OS) const override {
+  OS << "if (!SA->is" << getUpperName() << "Expr())\n";
+  OS << "  dumpType(SA->get" << getUpperName()
+ << "Type()->getType());\n";
+}
 
 void writeDumpChildren(raw_ostream &OS) const override {
   OS << "if (SA->is" << getUpperName() << "Expr())\n";
   OS << "  dumpStmt(SA->get" << getUpperName() << "Expr());\n";
-  OS << "else\n";
-  OS << "  dumpType(SA->get" << getUpperName()
- << "Type()->getType());\n";
 }
 
 void writeHasChildren(raw_ostream &OS) const override {
@@ -2932,15 +2933,15 @@
 OS << "case AttrSyntax::" << Variety << ": {\n";
 // C++11-style attributes are further split out based on the Scope.
 for (auto I = List.cbegin(), E = List.cend(); I != E; ++I) {
-  if (I != List.cbegin())
-OS << " else ";
-  if (I->first.empty())
-OS << "if (ScopeName == \"\") {\n";
-  else
-OS << "if (ScopeName == \"" << I->first << "\") {\n";
-  OS << "  return llvm::StringSwitch(Name)\n";
-  GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first);
-  OS << "}";
+  if (I != List.cbegin())
+OS << " else ";
+  if (I->first.empty())
+OS << "if (ScopeName == \"\") {\n";
+  else
+OS << "if (ScopeName == \"" << I->first << "\") {\n";
+  OS << "  return llvm::StringSwitch(Name)\n";
+  GenerateHasAttrSpellingStringSwitch(I->second, OS, Spelling, I->first);
+  OS << "}";
 }
 OS << "\n} break;\n";
   };
@@ -3697,39 +3698,67 @@
 }
 
 // Emits the code to dump an attribute.
-v

[PATCH] D56504: [WebAssembly] Add unimplemented-simd128 feature, gate builtins

2019-01-09 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:53
 // Saturating fp-to-int conversions
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f64, "id", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f32, "LLif", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_s_i64_f64, "LLid", "nc")
-BUILTIN(__builtin_wasm_trunc_saturate_u_i64_f64, "LLid", "nc")
-
-// Floating point min/max
-BUILTIN(__builtin_wasm_min_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_max_f32, "fff", "nc")
-BUILTIN(__builtin_wasm_min_f64, "ddd", "nc")
-BUILTIN(__builtin_wasm_max_f64, "ddd", "nc")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_s_i32_f32, "if", "nc", 
"nontrapping-fptoint")
+TARGET_BUILTIN(__builtin_wasm_trunc_saturate_u_i32_f32, "if", "nc", 
"nontrapping-fptoint")

clang-format this file



Comment at: lib/Basic/Targets/WebAssembly.cpp:89
+// features control availability of builtins
+setSIMDLevel(Features, SIMDLevel);
+if (HasNontrappingFPToInt)

Minor thing, but should we extract this as a function? It is gonna be a couple 
line anyway, like

```
if (CPU == "bleeding-edge") {
  ...
  Features["unimplemented-simd128"] = Features["simd128"] = true;
}

if (SIMDLevel >= SIMD128)
  Features["simd128"] = true;
if (SIMDLevel >= UnimplementedSIMD128)
  Features["unimplemented-simd128"] = true;
...

And to me it is more readable to see all `Features` setting in one place. But 
I'm not too opinionated either.



Comment at: lib/Basic/Targets/WebAssembly.cpp:98
+return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
+  }
+

The indentation of these functions looks weird and there are lines that exceeds 
80 cols. clang-format?



Comment at: test/CodeGen/builtins-wasm.c:2
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature 
+unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature 
+exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature 
+unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature 
+exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | 
FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
 

Maybe we can add a line that disables one of the target features and make sure 
it fails? You can do something like
```
RUN: not %clang_cc1 ...
```
to see if it fails.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504



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


[PATCH] D55488: Add utility for dumping a label with child nodes

2019-01-09 Thread Stephen Kelly via Phabricator via cfe-commits
steveire updated this revision to Diff 180935.
steveire added a comment.

Nits


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55488/new/

https://reviews.llvm.org/D55488

Files:
  include/clang/AST/TextNodeDumper.h
  lib/AST/ASTDumper.cpp
  test/AST/ast-dump-stmt.cpp

Index: test/AST/ast-dump-stmt.cpp
===
--- test/AST/ast-dump-stmt.cpp
+++ test/AST/ast-dump-stmt.cpp
@@ -91,8 +91,7 @@
   U us[3] = {1};
 // CHECK: VarDecl {{.+}}  col:5 us 'U [3]' cinit
 // CHECK-NEXT: `-InitListExpr {{.+}}  'U [3]'
-// CHECK-NEXT:   |-array filler
-// CHECK-NEXT:   | `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
+// CHECK-NEXT:   |-array_filler: InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
 // CHECK-NEXT:   `-InitListExpr {{.+}}  'U' field Field {{.+}} 'i' 'int'
 // CHECK-NEXT: `-IntegerLiteral {{.+}}  'int' 1
 }
Index: lib/AST/ASTDumper.cpp
===
--- lib/AST/ASTDumper.cpp
+++ lib/AST/ASTDumper.cpp
@@ -61,6 +61,9 @@
 template void dumpChild(Fn doDumpChild) {
   NodeDumper.addChild(doDumpChild);
 }
+template  void dumpChild(StringRef Label, Fn doDumpChild) {
+  NodeDumper.addChild(Label, doDumpChild);
+}
 
   public:
 ASTDumper(raw_ostream &OS, const CommandTraits *Traits,
@@ -80,7 +83,7 @@
 void setDeserialize(bool D) { Deserialize = D; }
 
 void dumpDecl(const Decl *D);
-void dumpStmt(const Stmt *S);
+void dumpStmt(const Stmt *S, StringRef Label = {});
 
 // Utilities
 void dumpType(QualType T) { NodeDumper.dumpType(T); }
@@ -1685,8 +1688,8 @@
 //  Stmt dumping methods.
 //===--===//
 
-void ASTDumper::dumpStmt(const Stmt *S) {
-  dumpChild([=] {
+void ASTDumper::dumpStmt(const Stmt *S, StringRef Label) {
+  dumpChild(Label, [=] {
 if (!S) {
   ColorScope Color(OS, ShowColors, NullColor);
   OS << "<<>>";
@@ -1957,10 +1960,7 @@
 NodeDumper.dumpBareDeclRef(Field);
   }
   if (auto *Filler = ILE->getArrayFiller()) {
-dumpChild([=] {
-  OS << "array filler";
-  dumpStmt(Filler);
-});
+dumpStmt(Filler, "array_filler");
   }
 }
 
Index: include/clang/AST/TextNodeDumper.h
===
--- include/clang/AST/TextNodeDumper.h
+++ include/clang/AST/TextNodeDumper.h
@@ -27,7 +27,7 @@
   const bool ShowColors;
 
   /// Pending[i] is an action to dump an entity at level i.
-  llvm::SmallVector, 32> Pending;
+  llvm::SmallVector, 32> Pending;
 
   /// Indicates whether we're at the top level.
   bool TopLevel = true;
@@ -39,13 +39,19 @@
   std::string Prefix;
 
 public:
-  /// Add a child of the current node.  Calls doAddChild without arguments
-  template  void addChild(Fn doAddChild) {
+  /// Add a child of the current node. Calls DoAddChild without arguments.
+  template  void addChild(Fn DoAddChild) {
+return addChild("", DoAddChild);
+  }
+
+  /// Add a child of the current node with an optional label.
+  /// Calls DoAddChild without arguments.
+  template  void addChild(StringRef Label, Fn DoAddChild) {
 // If we're at the top level, there's nothing interesting to do; just
 // run the dumper.
 if (TopLevel) {
   TopLevel = false;
-  doAddChild();
+  DoAddChild();
   while (!Pending.empty()) {
 Pending.back()(true);
 Pending.pop_back();
@@ -56,7 +62,10 @@
   return;
 }
 
-auto dumpWithIndent = [this, doAddChild](bool isLastChild) {
+// We need to capture an owning-string in the lambda because the lambda
+// is invoked in a deferred manner.
+std::string LabelStr = Label;
+auto DumpWithIndent = [this, DoAddChild, LabelStr](bool IsLastChild) {
   // Print out the appropriate tree structure and work out the prefix for
   // children of this node. For instance:
   //
@@ -72,15 +81,18 @@
   {
 OS << '\n';
 ColorScope Color(OS, ShowColors, IndentColor);
-OS << Prefix << (isLastChild ? '`' : '|') << '-';
-this->Prefix.push_back(isLastChild ? ' ' : '|');
+OS << Prefix << (IsLastChild ? '`' : '|') << '-';
+if (!LabelStr.empty())
+  OS << LabelStr << ": ";
+
+this->Prefix.push_back(IsLastChild ? ' ' : '|');
 this->Prefix.push_back(' ');
   }
 
   FirstChild = true;
   unsigned Depth = Pending.size();
 
-  doAddChild();
+  DoAddChild();
 
   // If any children are left, they're the last at their nesting level.
   // Dump those ones out now.
@@ -94,10 +106,10 @@
 };
 
 if (FirstChild) {
-  Pending.push_back(std::move(dumpWithIndent));
+  Pending.push_back(std::move(DumpWithIndent));
 } else {
   Pending.back()(false);
-  Pending.back() = std::move(dumpWithIndent);
+  Pending.back() = std::move(DumpWithIndent);
 }
 FirstChild = false

[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-09 Thread Alex Lorenz via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350768: [ObjC] Allow the use of implemented unavailable 
methods from within (authored by arphaman, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56469/new/

https://reviews.llvm.org/D56469

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/call-unavailable-init-in-self.m

Index: test/SemaObjC/call-unavailable-init-in-self.m
===
--- test/SemaObjC/call-unavailable-init-in-self.m
+++ test/SemaObjC/call-unavailable-init-in-self.m
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s
+
+@interface NSObject
+
++ (instancetype)new;
++ (instancetype)alloc;
+
+@end
+
+@interface Sub: NSObject
+
+- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}
+
+- (void)notImplemented __attribute__((unavailable)); // expected-note {{'notImplemented' has been explicitly marked unavailable here}}
+
+@end
+
+@implementation Sub
+
++ (Sub *)create {
+  return [[self alloc] init];
+}
+
++ (Sub *)create2 {
+  return [self new];
+}
+
++ (Sub *)create3 {
+  return [Sub new];
+}
+
+- (instancetype) init {
+  return self;
+}
+
+- (void)reportUseOfUnimplemented {
+  [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}
+}
+
+@end
+
+@interface SubClassContext: Sub
+@end
+
+@implementation SubClassContext
+
+- (void)subClassContext {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
+
+@end
+
+void unrelatedContext() {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
+
+@interface X @end
+
+@interface X (Foo)
+-(void)meth __attribute__((unavailable));
+@end
+
+@implementation X (Foo)
+-(void)meth {}
+-(void)call_it { [self meth]; }
+@end
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7269,9 +7269,10 @@
 /// whether we should emit a diagnostic for \c K and \c DeclVersion in
 /// the context of \c Ctx. For example, we should emit an unavailable diagnostic
 /// in a deprecated context, but not the other way around.
-static bool ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K,
-VersionTuple DeclVersion,
-Decl *Ctx) {
+static bool
+ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K,
+VersionTuple DeclVersion, Decl *Ctx,
+const NamedDecl *OffendingDecl) {
   assert(K != AR_Available && "Expected an unavailable declaration here!");
 
   // Checks if we should emit the availability diagnostic in the context of C.
@@ -7280,9 +7281,22 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, C))
 if (AA->getIntroduced() >= DeclVersion)
   return true;
-} else if (K == AR_Deprecated)
+} else if (K == AR_Deprecated) {
   if (C->isDeprecated())
 return true;
+} else if (K == AR_Unavailable) {
+  // It is perfectly fine to refer to an 'unavailable' Objective-C method
+  // when it's actually defined and is referenced from within the
+  // @implementation itself. In this context, we interpret unavailable as a
+  // form of access control.
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(C)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&
+  MD->isDefined())
+return true;
+}
+  }
+}
 
 if (C->isUnavailable())
   return true;
@@ -7471,7 +7485,8 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, OffendingDecl))
 DeclVersion = AA->getIntroduced();
 
-  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx))
+  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx,
+   OffendingDecl))
 return;
 
   SourceLocation Loc = Locs.front();
@@ -7955,7 +7970,8 @@
 
 // If the context of this function is less available than D, we should not
 // emit a diagnostic.
-if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx))
+if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx,
+ OffendingDecl))
   return;
 
 // We would like to emit the diagnostic even if -Wunguarded-availability is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350768 - [ObjC] Allow the use of implemented unavailable methods from within

2019-01-09 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Wed Jan  9 14:31:37 2019
New Revision: 350768

URL: http://llvm.org/viewvc/llvm-project?rev=350768&view=rev
Log:
[ObjC] Allow the use of implemented unavailable methods from within
the @implementation context

In Objective-C, it's common for some frameworks to mark some methods like init
as unavailable in the @interface to prohibit their usage. However, these
frameworks then often implemented said method and refer to it in another method
that acts as a factory for that object. The recent change to how messages to
self are type checked in clang (r349841) introduced a regression which started
to prohibit this pattern with an X is unavailable error. This commit addresses
the aforementioned regression.

rdar://47134898

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

Added:
cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
Modified:
cfe/trunk/lib/Sema/SemaDeclAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=350768&r1=350767&r2=350768&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Wed Jan  9 14:31:37 2019
@@ -7269,9 +7269,10 @@ ShouldDiagnoseAvailabilityOfDecl(Sema &S
 /// whether we should emit a diagnostic for \c K and \c DeclVersion in
 /// the context of \c Ctx. For example, we should emit an unavailable 
diagnostic
 /// in a deprecated context, but not the other way around.
-static bool ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K,
-VersionTuple DeclVersion,
-Decl *Ctx) {
+static bool
+ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K,
+VersionTuple DeclVersion, Decl *Ctx,
+const NamedDecl *OffendingDecl) {
   assert(K != AR_Available && "Expected an unavailable declaration here!");
 
   // Checks if we should emit the availability diagnostic in the context of C.
@@ -7280,9 +7281,22 @@ static bool ShouldDiagnoseAvailabilityIn
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, C))
 if (AA->getIntroduced() >= DeclVersion)
   return true;
-} else if (K == AR_Deprecated)
+} else if (K == AR_Deprecated) {
   if (C->isDeprecated())
 return true;
+} else if (K == AR_Unavailable) {
+  // It is perfectly fine to refer to an 'unavailable' Objective-C method
+  // when it's actually defined and is referenced from within the
+  // @implementation itself. In this context, we interpret unavailable as a
+  // form of access control.
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(C)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&
+  MD->isDefined())
+return true;
+}
+  }
+}
 
 if (C->isUnavailable())
   return true;
@@ -7471,7 +7485,8 @@ static void DoEmitAvailabilityWarning(Se
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, 
OffendingDecl))
 DeclVersion = AA->getIntroduced();
 
-  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx))
+  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx,
+   OffendingDecl))
 return;
 
   SourceLocation Loc = Locs.front();
@@ -7955,7 +7970,8 @@ void DiagnoseUnguardedAvailability::Diag
 
 // If the context of this function is less available than D, we should not
 // emit a diagnostic.
-if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx))
+if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx,
+ OffendingDecl))
   return;
 
 // We would like to emit the diagnostic even if -Wunguarded-availability is

Added: cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m?rev=350768&view=auto
==
--- cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m (added)
+++ cfe/trunk/test/SemaObjC/call-unavailable-init-in-self.m Wed Jan  9 14:31:37 
2019
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s
+
+@interface NSObject
+
++ (instancetype)new;
++ (instancetype)alloc;
+
+@end
+
+@interface Sub: NSObject
+
+- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' 
has been explicitly marked unavailable here}}
+
+- (void)notImplemented __attribute__((unavailable)); // expected-note 
{{'notImplemented' has been explicitly marked unavailable here}}
+
+@end
+
+@implementation Sub
+
++ (Sub *)create {
+  return [[self alloc] init];
+}
+
+

[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked 2 inline comments as done.
nickdesaulniers added inline comments.



Comment at: test/Sema/alias-unused.c:3
+// expected-no-diagnostics
+int f() { return 42; }
+int g() __attribute__((alias("f")));

rjmccall wrote:
> nickdesaulniers wrote:
> > rjmccall wrote:
> > > Is this meant to be `static`?
> > It doesn't make a difference for this test.  Would you like me to add it 
> > before submitting?
> It's what you're trying to test, right?  `f()` is not otherwise an internal 
> declaration, so of course the warning won't fire for it.
sorry, you're right.  (I was testing with my locally patched version of clang, 
godbolt to the rescue to test "pre-my-change-clang." Done.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188



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


[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers updated this revision to Diff 180932.
nickdesaulniers added a comment.

- add static keyword to test case


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/alias-unused.c


Index: test/Sema/alias-unused.c
===
--- /dev/null
+++ test/Sema/alias-unused.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x 
c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1898,7 +1898,16 @@
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));


Index: test/Sema/alias-unused.c
===
--- /dev/null
+++ test/Sema/alias-unused.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -Wunneeded-internal-declaration -x c -verify %s
+// expected-no-diagnostics
+static int f() { return 42; }
+int g() __attribute__((alias("f")));
+
+static int foo [] = { 42, 0xDEAD };
+extern typeof(foo) bar __attribute__((unused, alias("foo")));
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -1898,7 +1898,16 @@
 }
   }
 
-  // FIXME: check if target symbol exists in current file
+  // Mark target used to prevent unneeded-internal-declaration warnings.
+  if (!S.LangOpts.CPlusPlus) {
+// FIXME: demangle Str for C++, as the attribute refers to the mangled
+// linkage name, not the pre-mangled identifier.
+const DeclarationNameInfo target(&S.Context.Idents.get(Str), AL.getLoc());
+LookupResult LR(S, target, Sema::LookupOrdinaryName);
+if (S.LookupQualifiedName(LR, S.getCurLexicalContext()))
+  for (NamedDecl *ND : LR)
+ND->markUsed(S.Context);
+  }
 
   D->addAttr(::new (S.Context) AliasAttr(AL.getRange(), S.Context, Str,
  AL.getAttributeSpellingListIndex()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D56066: [OpenCL] Address space for default class members

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaInit.cpp:4539
+  if (InitCategory.isPRValue() || InitCategory.isXValue())
+T1Quals.removeAddressSpace();
+

Anastasia wrote:
> rjmccall wrote:
> > ebevhan wrote:
> > > rjmccall wrote:
> > > > rjmccall wrote:
> > > > > I can understand why a pr-value wouldn't have an address space, but 
> > > > > an x-value's address space is surely important.
> > > > No, wait, I think this is more deeply wrong.  We're initializing a 
> > > > reference to type `cv1 T1`, and if we're initializing it with a 
> > > > temporary, we're dropping the address space from `cv1`?  That's 
> > > > definitely wrong.
> > > > 
> > > > If we're starting with a pr-value, reference-initialization normally 
> > > > has to start by initializing a temporary.  (The exception is it's a 
> > > > class type with a conversion operator to a reference type; C++ is 
> > > > abysmally complicated.  Let's ignore this for a moment.)  Temporaries 
> > > > are always in the default address space (the address space of local 
> > > > variables) because the language (neither OpenCL nor Embedded C) does 
> > > > not give us any facility for allocating temporary memory anywhere else. 
> > > >  So reference-initialization from a pr-value creates a temporary in the 
> > > > default address space and then attempts to initialize the destination 
> > > > reference type with that temporary.  That initialization should fail if 
> > > > there's no conversion from the default address space to the destination 
> > > > address space.  For example, consider initializing a `const int 
> > > > __global &` from a pr-value: this should clearly not succeed, because 
> > > > we have no way of putting a temporary in the global address space.  
> > > > That reference can only be initialized with a gl-value that's already 
> > > > in the `__global` address space.
> > > > 
> > > > On the other hand, we can successfully initialize a `const int &` with 
> > > > a gl-value of type `const int __global` not by direct reference 
> > > > initialization but by loading from the operand and then materializing 
> > > > the result into a new temporary.
> > > > 
> > > > I think what this means is:
> > > > 
> > > > - We need to be doing this checking as if pr-values were in 
> > > > `__private`.  This includes both (1) expressions that were originally 
> > > > pr-values and (2) expressions that have been converted to pr-values due 
> > > > to a failure to perform direct reference initialization.
> > > > 
> > > > - We need to make sure that reference compatibility correctly prevents 
> > > > references from being bound to gl-values in incompatible address spaces.
> > > > On the other hand, we can successfully initialize a `const int &` with 
> > > > a gl-value of type `const int __global` not by direct reference 
> > > > initialization but by loading from the operand and then materializing 
> > > > the result into a new temporary.
> > > 
> > > Is this the right thing to do? It means that initializing such a 
> > > reference would incur a cost under the hood that might be 
> > > unnoticed/unwanted by the user. 
> > Hmm.  I was going to say that it's consistent with the normal behavior of 
> > C++, but looking at the actual rule, it's more complicated than that: C++ 
> > will only do this if the types are not reference-related or if the gl-value 
> > is a bit-field.  So this would only be allowed if the reference type was 
> > e.g. `const long &`.  It's a strange rule, but it's straightforward to stay 
> > consistent with it.
> > 
> > I think we will eventually find ourselves needing a special-case rule for 
> > copy-initializing and copy-assigning trivially-copyable types, but we're 
> > not there yet.
> I need some help to understand what's the right way to fix this problem.
> 
> As far as I gathered from this particular example. The issues is caused by 
> the following statement of **addrspace-of-this.cl** line 47:
>   C c3 = c1 + c2;
> 
> If I remove this new `if` statement in **SemaInit.cpp** and disable some 
> asserts about the incorrect address space cast the AST that Clang is trying 
> to create is as follows:
> 
> 
> ```
> | | |-DeclStmt 0x9d6e70 
> | | | `-VarDecl 0x9d6b28  col:5 c3 'C' cinit
> | | |   `-ExprWithCleanups 0x9d6e58  'C'
> | | | `-CXXConstructExpr 0x9d6e20  'C' 'void (__generic C 
> &&) __generic' elidable
> | | |   `-MaterializeTemporaryExpr 0x9d6e08  '__generic 
> C' xvalue
> | | | `-ImplicitCastExpr 0x9d6df0  '__generic C' 
> 
> | | |   `-CXXOperatorCallExpr 0x9d6c90  'C'
> | | | |-ImplicitCastExpr 0x9d6c78  'C (*)(const __generic 
> C &) __generic' 
> | | | | `-DeclRefExpr 0x9d6bf8  'C (const __generic C &) 
> __generic' lvalue CXXMethod 0x9d4da0 'operator+' 'C (const __generic C &) 
> __generic'
> | | | |-ImplicitCastExpr 0x9d6be0  '__generic C' lvalue 
> 
> | | | | `-DeclRefExpr 0x9d6b88  'C' lvalue Var 0

[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: test/Sema/alias-unused.c:3
+// expected-no-diagnostics
+int f() { return 42; }
+int g() __attribute__((alias("f")));

nickdesaulniers wrote:
> rjmccall wrote:
> > Is this meant to be `static`?
> It doesn't make a difference for this test.  Would you like me to add it 
> before submitting?
It's what you're trying to test, right?  `f()` is not otherwise an internal 
declaration, so of course the warning won't fire for it.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

But why?  Why do you want to limit this to just template arguments instead of 
all sorts of similar contexts?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D56504: [WebAssembly] Add unimplemented-simd128 feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively updated this revision to Diff 180921.
tlively added a comment.

- Decouple sign-ext from simd128


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56504/new/

https://reviews.llvm.org/D56504

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h
  test/CodeGen/builtins-wasm.c

Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -1,9 +1,5 @@
-// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
-// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
 
 // SIMD convenience types
 typedef char i8x16 __attribute((vector_size(16)));
Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -28,7 +28,8 @@
   enum SIMDEnum {
 NoSIMD,
 SIMD128,
-  } SIMDLevel;
+UnimplementedSIMD128,
+  } SIMDLevel = NoSIMD;
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
@@ -59,18 +60,12 @@
 MacroBuilder &Builder) const override;
 
 private:
+  static void setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level);
+
   bool
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
- const std::vector &FeaturesVec) const override {
-if (CPU == "bleeding-edge") {
-  Features["simd128"] = true;
-  Features["nontrapping-fptoint"] = true;
-  Features["sign-ext"] = true;
-}
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
-  }
-
+ const std::vector &FeaturesVec) const override;
   bool hasFeature(StringRef Feature) const final;
 
   bool handleTargetFeatures(std::vector &Features,
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -24,6 +24,8 @@
 const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)\
   {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
 #include "clang/Basic/BuiltinsWebAssembly.def"
@@ -35,6 +37,7 @@
 bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
   return llvm::StringSwitch(Feature)
   .Case("simd128", SIMDLevel >= SIMD128)
+  .Case("unimplemented-simd128", SIMDLevel >= UnimplementedSIMD128)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
   .Case("exception-handling", HasExceptionHandling)
@@ -55,8 +58,46 @@
   defineCPUMacros(Builder, "wasm", /*Tuning=*/false);
   if (SIMDLevel >= SIMD128)
 Builder.defineMacro("__wasm_simd128__");
+  if (SIMDLevel >= UnimplementedSIMD128)
+Builder.defineMacro("__wasm_unimplemented_simd128__");
 }
 
+void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level) {
+  switch (Level) {
+  case UnimplementedSIMD128:
+Features["unimplemented-simd128"] = true;
+LLVM_FALLTHROUGH;
+  case SIMD128:
+Features["simd128"] = true;
+LLVM_FALLTHROUGH;
+  case NoSIMD:
+break;
+  }
+}
+
+bool WebAssemblyTargetInfo::initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
+ StringRef CPU,
+ const std::vector &FeaturesVec) const {
+if (CPU == "bleeding-edge") {
+  Features["nontrapping-fptoint"] = true;
+  Features["sign-ext"] = true;
+  setSIMDLevel(Features, SIMD128);
+}
+// Other targets do not consider user-configured features here, but while we
+// are actively developing new features it is useful to let user-configured
+// features control availability of builtins
+setSIMDLe

[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread Nick Desaulniers via Phabricator via cfe-commits
nickdesaulniers marked an inline comment as done.
nickdesaulniers added inline comments.



Comment at: test/Sema/alias-unused.c:3
+// expected-no-diagnostics
+int f() { return 42; }
+int g() __attribute__((alias("f")));

rjmccall wrote:
> Is this meant to be `static`?
It doesn't make a difference for this test.  Would you like me to add it before 
submitting?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188



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


[PATCH] D55844: [Fixed Point Arithmetic] Fixed Point Subtraction

2019-01-09 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 180920.
leonardchan marked an inline comment as done.

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55844/new/

https://reviews.llvm.org/D55844

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/Frontend/fixed_point_sub.c

Index: clang/test/Frontend/fixed_point_sub.c
===
--- /dev/null
+++ clang/test/Frontend/fixed_point_sub.c
@@ -0,0 +1,390 @@
+// RUN: %clang_cc1 -ffixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,SIGNED
+// RUN: %clang_cc1 -ffixed-point -fpadding-on-unsigned-fixed-point -S -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,UNSIGNED
+
+void SignedSubtraction() {
+  // CHECK-LABEL: SignedSubtraction
+  short _Accum sa;
+  _Accum a, b, c, d;
+  long _Accum la;
+  unsigned short _Accum usa;
+  unsigned _Accum ua;
+  unsigned long _Accum ula;
+
+  short _Fract sf;
+  _Fract f;
+  long _Fract lf;
+  unsigned short _Fract usf;
+  unsigned _Fract uf;
+  unsigned long _Fract ulf;
+
+  // Same type
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SA2:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i16 [[SA]], [[SA2]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa - sa;
+
+  // To larger scale and larger width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]] to i32
+  // CHECK-NEXT: [[SA:%[a-z0-9]+]] = shl i32 [[EXT_SA]], 8
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i32 [[SA]], [[A]]
+  // CHECK-NEXT: store i32 [[SUM]], i32* %a, align 4
+  a = sa - a;
+
+  // To same scale and smaller width
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[SF:%[0-9]+]] = load i8, i8* %sf, align 1
+  // CHECK-NEXT: [[EXT_SF:%[a-z0-9]+]] = sext i8 [[SF]] to i16
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i16 [[SA]], [[EXT_SF]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa - sf;
+
+  // To smaller scale and same width.
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[F:%[0-9]+]] = load i16, i16* %f, align 2
+  // CHECK-NEXT: [[EXT_SA:%[a-z0-9]+]] = sext i16 [[SA]] to i24
+  // CHECK-NEXT: [[SA:%[a-z0-9]+]] = shl i24 [[EXT_SA]], 8
+  // CHECK-NEXT: [[EXT_F:%[a-z0-9]+]] = sext i16 [[F]] to i24
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i24 [[SA]], [[EXT_F]]
+  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = ashr i24 [[SUM]], 8
+  // CHECK-NEXT: [[TRUNC_RES:%[a-z0-9]+]] = trunc i24 [[RES]] to i16
+  // CHECK-NEXT: store i16 [[TRUNC_RES]], i16* %sa, align 2
+  sa = sa - f;
+
+  // To smaller scale and smaller width
+  // CHECK:  [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[SF:%[0-9]+]] = load i8, i8* %sf, align 1
+  // CHECK-NEXT: [[EXT_SF:%[a-z0-9]+]] = sext i8 [[SF]] to i32
+  // CHECK-NEXT: [[SF:%[a-z0-9]+]] = shl i32 [[EXT_SF]], 8
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i32 [[A]], [[SF]]
+  // CHECK-NEXT: store i32 [[SUM]], i32* %a, align 4
+  a = a - sf;
+
+  // To larger scale and same width
+  // CHECK:  [[A:%[0-9]+]] = load i32, i32* %a, align 4
+  // CHECK-NEXT: [[LF:%[0-9]+]] = load i32, i32* %lf, align 4
+  // CHECK-NEXT: [[EXT_A:%[a-z0-9]+]] = sext i32 [[A]] to i48
+  // CHECK-NEXT: [[A:%[a-z0-9]+]] = shl i48 [[EXT_A]], 16
+  // CHECK-NEXT: [[EXT_LF:%[a-z0-9]+]] = sext i32 [[LF]] to i48
+  // CHECK-NEXT: [[SUM:%[0-9]+]] = sub i48 [[A]], [[EXT_LF]]
+  // CHECK-NEXT: [[RES:%[a-z0-9]+]] = ashr i48 [[SUM]], 16
+  // CHECK-NEXT: [[TRUNC_RES:%[a-z0-9]+]] = trunc i48 [[RES]] to i32
+  // CHECK-NEXT: store i32 [[TRUNC_RES]], i32* %a, align 4
+  a = a - lf;
+
+  // With corresponding unsigned type
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[USA:%[0-9]+]] = load i16, i16* %usa, align 2
+  // SIGNED-NEXT: [[SA_EXT:%[a-z0-9]+]] = sext i16 [[SA]] to i17
+  // SIGNED-NEXT: [[SA:%[a-z0-9]+]] = shl i17 [[SA_EXT]], 1
+  // SIGNED-NEXT: [[USA_EXT:%[a-z0-9]+]] = zext i16 [[USA]] to i17
+  // SIGNED-NEXT: [[SUM:%[0-9]+]] = sub i17 [[SA]], [[USA_EXT]]
+  // SIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = ashr i17 [[SUM]], 1
+  // SIGNED-NEXT: [[SUM:%[a-z0-9]+]] = trunc i17 [[RESULT]] to i16
+  // UNSIGNED-NEXT: [[SUM:%[0-9]+]] = sub i16 [[SA]], [[USA]]
+  // CHECK-NEXT: store i16 [[SUM]], i16* %sa, align 2
+  sa = sa - usa;
+
+  // With unsigned of larger scale
+  // CHECK:  [[SA:%[0-9]+]] = load i16, i16* %sa, align 2
+  // CHECK-NEXT: [[USA:%[0-9]+]] = load i32, i32* %ua, align 4
+  // SIGNED-NEXT: [[SA_EXT:%[a-z0-9]+]] = sext i16 [[SA]] to i33
+  // SIGNED-NEXT: [[SA:%[a-z0-9]+]] = shl i33 [[SA_EXT]], 9
+  // SIGNED-NEXT: [[USA_EXT:%[a-z0-9]+]] = zext i32 [[USA]] to i33
+  // SIGNED-NEXT: [[SUM:%[0-9]+]] = sub i33 [[SA]], [[USA_EXT]]
+  // SIGNED-NEXT: [[RESULT:%[a-z0-9]+]] = ashr i33 [[SUM]], 1
+  // SIGNED-NEXT: [[SUM:%[a

[clang-tools-extra] r350765 - [clang-tidy] another take at fixing doc

2019-01-09 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Jan  9 13:27:59 2019
New Revision: 350765

URL: http://llvm.org/viewvc/llvm-project?rev=350765&view=rev
Log:
[clang-tidy] another take at fixing doc

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst?rev=350765&r1=350764&r2=350765&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst 
Wed Jan  9 13:27:59 2019
@@ -9,7 +9,10 @@ order to highlight at compile time which
 Member functions need to satisfy the following conditions to be considered by
 this check:
 
- - no ``[[nodiscard]]``, ``[[noreturn]]``, 
``__attribute__((warn_unused_result))``, ``[[clang::warn_unused_result]]`` nor 
``[[gcc::warn_unused_result]]`` attribute,
+ - no ``[[nodiscard]]``, ``[[noreturn]]``,
+   ``__attribute__((warn_unused_result))``,
+   ``[[clang::warn_unused_result]]`` nor ``[[gcc::warn_unused_result]]``
+   attribute,
  - non-void return type,
  - non-template return types,
  - const member function,
@@ -46,8 +49,8 @@ Options
 
 .. option:: ReplacementString
 
-Specifies a macro to use instead of ``[[nodiscard]]``. This is useful when
-maintaining source code that needs to compile with a pre-C++17 compiler.
+Specifies a macro to use instead of ``[[nodiscard]]``. This is useful when
+maintaining source code that needs to compile with a pre-C++17 compiler.
 
 Example
 ^^^
@@ -68,11 +71,12 @@ if the :option:`ReplacementString` optio
 
 .. note::
 
-If the :option:`ReplacementString` is not a C++ attribute, but instead a macro,
-then that macro must be defined in scope or the fix-it will not be applied.
+If the :option:`ReplacementString` is not a C++ attribute, but instead a 
+macro, then that macro must be defined in scope or the fix-it will not be 
+applied.
 
 .. note::
 
-   For alternative ``__attribute__`` syntax options to mark functions as
-   ``[[nodiscard]]`` in non-c++17 source code.
-   See 
https://clang.llvm.org/docs/AttributeReference.html#nodiscard-warn-unused-result
+For alternative ``__attribute__`` syntax options to mark functions as
+``[[nodiscard]]`` in non-c++17 source code.
+See 
https://clang.llvm.org/docs/AttributeReference.html#nodiscard-warn-unused-result


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


[PATCH] D56109: [sanitizer_common] Define __sanitizer_FILE on NetBSD

2019-01-09 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a comment.

In D56109#1341967 , @mgorny wrote:

> We've been discussing this, and I think we're doing this the wrong way. Could 
> you help me a little understand this?
>
> In particular, what is the purpose of unpoisoning file? Is it in order to 
> account for stdio functions being implemented inline or as macros, and 
> therefore user code accessing internal `FILE` members? Or is there some other 
> use case for this?
>
> If only the former, then I think there is no purpose in definining 
> `__sanitizer_FILE` on NetBSD, as we support only reentrant interfaces which 
> are all implemented as libc routine calls.


Yes, AFAIR unpoisoning of struct FILE was done specifically to support inlined 
and _unlocked stdio functions.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56109/new/

https://reviews.llvm.org/D56109



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


[clang-tools-extra] r350763 - [clang-tidy] tryfix documentation build

2019-01-09 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Jan  9 13:19:44 2019
New Revision: 350763

URL: http://llvm.org/viewvc/llvm-project?rev=350763&view=rev
Log:
[clang-tidy] tryfix documentation build

Modified:
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst?rev=350763&r1=350762&r2=350763&view=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst 
Wed Jan  9 13:19:44 2019
@@ -8,18 +8,19 @@ order to highlight at compile time which
 
 Member functions need to satisfy the following conditions to be considered by
 this check:
-  - no ``[[nodiscard]]``, ``[[noreturn]]``, 
``__attribute__((warn_unused_result))``, ``[[clang::warn_unused_result]]`` nor 
``[[gcc::warn_unused_result]]`` attribute,
-  - non-void return type,
-  - non-template return types,
-  - const member function,
-  - non-variadic functions,
-  - no non-const reference parameters,
-  - no pointer parameters,
-  - no template parameters,
-  - no template function parameters,
-  - not be a member of a class with mutable member variables,
-  - no Lambdas,
-  - no conversion functions.
+
+ - no ``[[nodiscard]]``, ``[[noreturn]]``, 
``__attribute__((warn_unused_result))``, ``[[clang::warn_unused_result]]`` nor 
``[[gcc::warn_unused_result]]`` attribute,
+ - non-void return type,
+ - non-template return types,
+ - const member function,
+ - non-variadic functions,
+ - no non-const reference parameters,
+ - no pointer parameters,
+ - no template parameters,
+ - no template function parameters,
+ - not be a member of a class with mutable member variables,
+ - no Lambdas,
+ - no conversion functions.
 
 Such functions have no means of altering any state or passing values other than
 via the return type. Unless the member functions are altering state via some


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


[PATCH] D47817: [compiler-rt] [sanitizer_common] Remove support for tirpc/rpc/xdr.h

2019-01-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

Looks like no activity by @ygribov after September
LGTM


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D47817/new/

https://reviews.llvm.org/D47817



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


[PATCH] D54071: [Bug 39548][Clang] PGO bootstrap fails with python3: errors in perf-helper.py

2019-01-09 Thread Romain Geissler via Phabricator via cfe-commits
Romain-Geissler-1A added subscribers: michaelplatings, serge-sans-paille.
Romain-Geissler-1A added a comment.
Herald added a reviewer: serge-sans-paille.

Hi @serge-sans-paille @michaelplatings,

I saw you recently merged some Python 3 related stuff. Here is an older review 
from November still never reviewed. You fixed already the fix around the 
lambda, yet I still need to add "universal_newlines" on current trunk otherwise 
I have some bytes vs str objects error. Do you think you can land this small 
change too ?

Cheers,
Romain


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54071/new/

https://reviews.llvm.org/D54071



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


[clang-tools-extra] r350761 - [clang-tidy] fix-up failing tests

2019-01-09 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Jan  9 13:03:54 2019
New Revision: 350761

URL: http://llvm.org/viewvc/llvm-project?rev=350761&view=rev
Log:
[clang-tidy] fix-up failing tests

Removed:
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.h
Modified:
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp?rev=350761&r1=350760&r2=350761&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp 
Wed Jan  9 13:03:54 2019
@@ -1,6 +1,6 @@
 // RUN: %check_clang_tidy %s modernize-use-nodiscard %t -- \
 // RUN:   -config="{CheckOptions: [{key: 
modernize-use-nodiscard.ReplacementString, value: 
'__attribute__((warn_unused_result))'}]}" \
-// RUN: -- -std=c++11 \
+// RUN: -- -std=c++11
 
 class Foo
 {

Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp?rev=350761&r1=350760&r2=350761&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp Wed Jan 
 9 13:03:54 2019
@@ -2,14 +2,20 @@
 // RUN:   -config="{CheckOptions: [{key: 
modernize-use-nodiscard.ReplacementString, value: 'NO_DISCARD'}]}" \
 // RUN: -- -std=c++17
 
-#include 
+namespace std {
+template 
+class function;
+class string {};
+}
 
 namespace boost {
 template 
 class function;
 }
 
-#include "modernize-use-nodiscard.h"
+#define MUST_USE_RESULT __attribute__((warn_unused_result))
+#define NO_DISCARD [[nodiscard]]
+#define NO_RETURN [[noreturn]]
 
 #define BOOLEAN_FUNC bool f23() const
 
@@ -168,9 +174,9 @@ auto lambda1b = []()  { return true;};
 auto get_functor = [](bool check) {
 return  [&](const std::string& sr)->std::string {
 if(check){
-return "some string";
+return std::string();
 }
-return "another string";
+return std::string();
 };
 };
 

Removed: clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.h?rev=350760&view=auto
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.h (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.h (removed)
@@ -1,5 +0,0 @@
-
-#define MUST_USE_RESULT __attribute__((warn_unused_result))
-#define NO_DISCARD [[nodiscard]]
-#define NO_RETURN [[noreturn]]
-


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


[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-09 Thread Jonas Toth via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL350760: [clang-tidy] Adding a new modernize use nodiscard 
checker (authored by JonasToth, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D55433?vs=180687&id=180909#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433

Files:
  clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp
  clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst
  
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp
  
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp
  clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.h

Index: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
@@ -32,6 +32,7 @@
 #include "UseEmplaceCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
+#include "UseNodiscardCheck.h"
 #include "UseNoexceptCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
@@ -82,6 +83,8 @@
 CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
+CheckFactories.registerCheck(
+"modernize-use-nodiscard");
 CheckFactories.registerCheck("modernize-use-noexcept");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");
Index: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
@@ -26,6 +26,7 @@
   UseEmplaceCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
+  UseNodiscardCheck.cpp
   UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp
@@ -0,0 +1,145 @@
+//===--- UseNodiscardCheck.cpp - clang-tidy ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseNodiscardCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+static bool doesNoDiscardMacroExist(ASTContext &Context,
+const llvm::StringRef &MacroId) {
+  // Don't check for the Macro existence if we are using an attribute
+  // either a C++17 standard attribute or pre C++17 syntax
+  if (MacroId.startswith("[[") || MacroId.startswith("__attribute__"))
+return true;
+
+  // Otherwise look up the macro name in the context to see if its defined.
+  return Context.Idents.get(MacroId).hasMacroDefinition();
+}
+
+namespace {
+AST_MATCHER(CXXMethodDecl, isOverloadedOperator) {
+  // Don't put ``[[nodiscard]]`` in front of operators.
+  return Node.isOverloadedOperator();
+}
+AST_MATCHER(CXXMethodDecl, isConversionOperator) {
+  // Don't put ``[[nodiscard]]`` in front of a conversion decl
+  // like operator bool().
+  return isa(Node);
+}
+AST_MATCHER(CXXMethodDecl, hasClassMutableFields) {
+  // Don't put ``[[nodiscard]]`` on functions on classes with
+  // mutable member variables.
+  return Node.getParent()->hasMutableFields();
+}
+AST_MATCHER(ParmVarDecl, hasParameterPack) {
+  // Don't put ``[[nodiscard]]`` on functions with parameter pack arguments.
+  return Node.isParameterPack();
+}
+AST_MATCHER(CXXMet

[clang-tools-extra] r350760 - [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-09 Thread Jonas Toth via cfe-commits
Author: jonastoth
Date: Wed Jan  9 12:50:50 2019
New Revision: 350760

URL: http://llvm.org/viewvc/llvm-project?rev=350760&view=rev
Log:
[clang-tidy] Adding a new modernize use nodiscard checker

Summary: Adds a checker to clang-tidy to warn when a non void const member 
function, taking only parameters passed by value or const reference could be 
marked as '[[nodiscard]]'

Patch by MyDeveloperDay.

Reviewers: alexfh, stephenkelly, curdeius, aaron.ballman, hokein, JonasToth

Reviewed By: curdeius, JonasToth

Subscribers: Eugene.Zelenko, lefticus, lebedev.ri, mgorny, xazax.hun, 
cfe-commits

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nodiscard.rst

clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-clang-unused.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-cxx11.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-gcc-unused.cpp

clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro-inscope-cxx11.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard-no-macro.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-use-nodiscard.h
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt?rev=350760&r1=350759&r2=350760&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/CMakeLists.txt Wed Jan  9 
12:50:50 2019
@@ -26,6 +26,7 @@ add_clang_library(clangTidyModernizeModu
   UseEmplaceCheck.cpp
   UseEqualsDefaultCheck.cpp
   UseEqualsDeleteCheck.cpp
+  UseNodiscardCheck.cpp
   UseNoexceptCheck.cpp
   UseNullptrCheck.cpp
   UseOverrideCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp?rev=350760&r1=350759&r2=350760&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/ModernizeTidyModule.cpp Wed 
Jan  9 12:50:50 2019
@@ -32,6 +32,7 @@
 #include "UseEmplaceCheck.h"
 #include "UseEqualsDefaultCheck.h"
 #include "UseEqualsDeleteCheck.h"
+#include "UseNodiscardCheck.h"
 #include "UseNoexceptCheck.h"
 #include "UseNullptrCheck.h"
 #include "UseOverrideCheck.h"
@@ -82,6 +83,8 @@ public:
 
CheckFactories.registerCheck("modernize-use-equals-default");
 CheckFactories.registerCheck(
 "modernize-use-equals-delete");
+CheckFactories.registerCheck(
+"modernize-use-nodiscard");
 CheckFactories.registerCheck("modernize-use-noexcept");
 CheckFactories.registerCheck("modernize-use-nullptr");
 CheckFactories.registerCheck("modernize-use-override");

Added: clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp?rev=350760&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp (added)
+++ clang-tools-extra/trunk/clang-tidy/modernize/UseNodiscardCheck.cpp Wed Jan  
9 12:50:50 2019
@@ -0,0 +1,145 @@
+//===--- UseNodiscardCheck.cpp - clang-tidy 
---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "UseNodiscardCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/Type.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace modernize {
+
+static bool doesNoDiscardMacroExist(ASTContext &Context,
+const llvm::StringRef &MacroId) {
+  // Don't check for the Macro existence if we are using an attribute
+  // either a C++17 standard attribute or pre C++17 syntax
+  if (MacroId.startswith("[[") || MacroId.start

[PATCH] D56444: [AST] RecursiveASTVisitor visits lambda classes when implicit visitation is on.

2019-01-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

@sammccall I (hopefully) fixed the type-issue in my test-cases. They 
nevertheless fail both on me, on latest llvm+clang+your patch. Clang-tidy still 
the same, so maybe there is a difference in our builds?
Do you build with assertions on?
I work on linux, ubuntu 18.04, building with clang-6.0, maybe there is a 
difference?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56444/new/

https://reviews.llvm.org/D56444



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


r350759 - [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-09 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed Jan  9 12:45:26 2019
New Revision: 350759

URL: http://llvm.org/viewvc/llvm-project?rev=350759&view=rev
Log:
[OpenMP] Avoid remainder operations for loop index values on a collapsed loop 
nest.

Summary: Change the strategy for computing loop index variables after 
collapsing a loop nest via the collapse clause by replacing the expensive 
remainder operation with multiplications and additions.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: guansong, arphaman, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/for_codegen.cpp
cfe/trunk/test/OpenMP/for_simd_codegen.cpp
cfe/trunk/test/OpenMP/parallel_for_simd_codegen.cpp
cfe/trunk/test/OpenMP/simd_codegen.cpp

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=350759&r1=350758&r2=350759&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Jan  9 12:45:26 2019
@@ -5579,31 +5579,59 @@ checkOpenMPLoop(OpenMPDirectiveKind DKin
   Built.Updates.resize(NestedLoopCount);
   Built.Finals.resize(NestedLoopCount);
   {
-ExprResult Div;
-// Go from inner nested loop to outer.
-for (int Cnt = NestedLoopCount - 1; Cnt >= 0; --Cnt) {
+// We implement the following algorithm for obtaining the
+// original loop iteration variable values based on the
+// value of the collapsed loop iteration variable IV.
+//
+// Let n+1 be the number of collapsed loops in the nest.
+// Iteration variables (I0, I1,  In)
+// Iteration counts (N0, N1, ... Nn)
+//
+// Acc = IV;
+//
+// To compute Ik for loop k, 0 <= k <= n, generate:
+//Prod = N(k+1) * N(k+2) * ... * Nn;
+//Ik = Acc / Prod;
+//Acc -= Ik * Prod;
+//
+ExprResult Acc = IV;
+for (unsigned int Cnt = 0; Cnt < NestedLoopCount; ++Cnt) {
   LoopIterationSpace &IS = IterSpaces[Cnt];
   SourceLocation UpdLoc = IS.IncSrcRange.getBegin();
-  // Build: Iter = (IV / Div) % IS.NumIters
-  // where Div is product of previous iterations' IS.NumIters.
   ExprResult Iter;
-  if (Div.isUsable()) {
-Iter =
-SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Div, IV.get(), Div.get());
-  } else {
-Iter = IV;
-assert((Cnt == (int)NestedLoopCount - 1) &&
-   "unusable div expected on first iteration only");
-  }
 
-  if (Cnt != 0 && Iter.isUsable())
-Iter = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Rem, Iter.get(),
-  IS.NumIterations);
+  // Compute prod
+  ExprResult Prod =
+  SemaRef.ActOnIntegerConstant(SourceLocation(), 1).get();
+  for (unsigned int K = Cnt+1; K < NestedLoopCount; ++K)
+Prod = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Mul, Prod.get(),
+  IterSpaces[K].NumIterations);
+
+  // Iter = Acc / Prod
+  // If there is at least one more inner loop to avoid
+  // multiplication by 1.
+  if (Cnt + 1 < NestedLoopCount)
+Iter = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Div,
+  Acc.get(), Prod.get());
+  else
+Iter = Acc;
   if (!Iter.isUsable()) {
 HasErrors = true;
 break;
   }
 
+  // Update Acc:
+  // Acc -= Iter * Prod
+  // Check if there is at least one more inner loop to avoid
+  // multiplication by 1.
+  if (Cnt + 1 < NestedLoopCount)
+Prod = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Mul,
+  Iter.get(), Prod.get());
+  else
+Prod = Iter;
+  Acc = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Sub,
+   Acc.get(), Prod.get());
+
   // Build update: IS.CounterVar(Private) = IS.Start + Iter * IS.Step
   auto *VD = cast(cast(IS.CounterVar)->getDecl());
   DeclRefExpr *CounterVar = buildDeclRefExpr(
@@ -5632,22 +5660,6 @@ checkOpenMPLoop(OpenMPDirectiveKind DKin
 break;
   }
 
-  // Build Div for the next iteration: Div <- Div * IS.NumIters
-  if (Cnt != 0) {
-if (Div.isUnset())
-  Div = IS.NumIterations;
-else
-  Div = SemaRef.BuildBinOp(CurScope, UpdLoc, BO_Mul, Div.get(),
-   IS.NumIterations);
-
-// Add parentheses (for debugging purposes only).
-if (Div.isUsable())
-  Div = tryBuildCapture(SemaRef, Div.get(), Captures);
-if (!Div.isUsable()) {
-  HasErrors = true;
-  break;
-}
-  }
   if (!Update.isUsable() || !Final.isUsable()) {
 HasErrors = true;
 break;

Modified: cfe/trunk/test/OpenMP/for_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/for_codegen.c

[PATCH] D56413: [OpenMP] Avoid remainder operations for loop index values on a collapsed loop nest.

2019-01-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350759: [OpenMP] Avoid remainder operations for loop index 
values on a collapsed loop… (authored by gbercea, committed by ).

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56413/new/

https://reviews.llvm.org/D56413

Files:
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/for_codegen.cpp
  test/OpenMP/for_simd_codegen.cpp
  test/OpenMP/parallel_for_simd_codegen.cpp
  test/OpenMP/simd_codegen.cpp

Index: test/OpenMP/simd_codegen.cpp
===
--- test/OpenMP/simd_codegen.cpp
+++ test/OpenMP/simd_codegen.cpp
@@ -278,8 +278,11 @@
 // CHECK-NEXT: [[I_2:%.+]] = trunc i64 [[I_1_ADD0]] to i32
 // CHECK-NEXT: store i32 [[I_2]], i32* {{%.+}}{{.*}}!llvm.access.group
 // CHECK: [[IV2:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.access.group
-// CHECK-NEXT: [[J_1:%.+]] = srem i64 [[IV2]], 4
-// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1]], 2
+// CHECK: [[IV2_1:%.+]] = load i64, i64* [[T1_OMP_IV]]{{.*}}!llvm.access.group
+// CHECK-NEXT: [[J_1_DIV1:%.+]] = sdiv i64 [[IV2_1]], 4
+// CHECK-NEXT: [[J_1_MUL1:%.+]] = mul nsw i64 [[J_1_DIV1]], 4
+// CHECK-NEXT: [[J_1_SUB0:%.+]] = sub nsw i64 [[IV2]], [[J_1_MUL1]]
+// CHECK-NEXT: [[J_2:%.+]] = mul nsw i64 [[J_1_SUB0]], 2
 // CHECK-NEXT: [[J_2_ADD0:%.+]] = add nsw i64 0, [[J_2]]
 // CHECK-NEXT: store i64 [[J_2_ADD0]], i64* {{%.+}}{{.*}}!llvm.access.group
 // simd.for.inc:
@@ -393,22 +396,70 @@
 // CHECK-NEXT: [[CALC_I_1_MUL1:%.+]] = mul i32 [[CALC_I_1]], 1
 // CHECK-NEXT: [[CALC_I_2:%.+]] = add i32 1, [[CALC_I_1_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_I_2]], i32* [[LC_I:.+]]
+
 // CHECK: [[IV1_2:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
-// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2]], 20
-// CHECK-NEXT: [[CALC_J_2:%.+]] = urem i32 [[CALC_J_1]], 3
+// CHECK: [[IV1_2_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK-NEXT: [[CALC_J_1:%.+]] = udiv i32 [[IV1_2_1]], 60
+// CHECK-NEXT: [[MUL_1:%.+]] = mul i32 [[CALC_J_1]], 60
+// CHECK-NEXT: [[SUB_3:%.+]] = sub i32 [[IV1_2]], [[MUL_1]]
+// CHECK-NEXT: [[CALC_J_2:%.+]] = udiv i32 [[SUB_3]], 20
 // CHECK-NEXT: [[CALC_J_2_MUL1:%.+]] = mul i32 [[CALC_J_2]], 1
 // CHECK-NEXT: [[CALC_J_3:%.+]] = add i32 2, [[CALC_J_2_MUL1]]
 // CHECK-NEXT: store i32 [[CALC_J_3]], i32* [[LC_J:.+]]
+
 // CHECK: [[IV1_3:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
-// CHECK-NEXT: [[CALC_K_1:%.+]] = udiv i32 [[IV1_3]], 5
-// CHECK-NEXT: [[CALC_K_2:%.+]] = urem i32 [[CALC_K_1]], 4
-// CHECK-NEXT: [[CALC_K_2_MUL1:%.+]] = mul i32 [[CALC_K_2]], 1
-// CHECK-NEXT: [[CALC_K_3:%.+]] = add i32 3, [[CALC_K_2_MUL1]]
-// CHECK-NEXT: store i32 [[CALC_K_3]], i32* [[LC_K:.+]]
-// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
-// CHECK-NEXT: [[CALC_L_1:%.+]] = urem i32 [[IV1_4]], 5
-// CHECK-NEXT: [[CALC_L_1_MUL1:%.+]] = mul i32 [[CALC_L_1]], 1
-// CHECK-NEXT: [[CALC_L_2:%.+]] = add i32 4, [[CALC_L_1_MUL1]]
+// CHECK: [[IV1_3_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK-NEXT: [[DIV_1:%.+]] = udiv i32 [[IV1_3_1]], 60
+// CHECK-NEXT: [[MUL_2:%.+]] = mul i32 [[DIV_1]], 60
+// CHECK-NEXT: [[ADD_3:%.+]] = sub i32 [[IV1_3]], [[MUL_2]]
+
+// CHECK: [[IV1_4:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_4_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_2:%.+]] = udiv i32 [[IV1_4_1]], 60
+// CHECK-NEXT: [[MUL_3:%.+]] = mul i32 [[DIV_2]], 60
+// CHECK-NEXT: [[SUB_6:%.+]] = sub i32 [[IV1_4]], [[MUL_3]]
+// CHECK-NEXT: [[DIV_3:%.+]] = udiv i32 [[SUB_6]], 20
+// CHECK-NEXT: [[MUL_4:%.+]] = mul i32 [[DIV_3]], 20
+// CHECK-NEXT: [[ADD_5:%.+]] = sub i32 [[ADD_3]], [[MUL_4]]
+// CHECK-NEXT: [[DIV_4:%.+]] = udiv i32 [[ADD_5]], 5
+// CHECK-NEXT: [[MUL_5:%.+]] = mul i32 [[DIV_4]], 1
+// CHECK-NEXT: [[ADD_6:%.+]] = add i32 3, [[MUL_5]]
+// CHECK-NEXT: store i32 [[ADD_6]], i32* [[LC_K:.+]]
+
+// CHECK: [[IV1_5:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK: [[IV1_5_1:%.+]] = load i32, i32* [[OMP_IV]]{{.+}}!llvm.access.group
+// CHECK-NEXT: [[DIV_5:%.+]] = udiv i32 [[IV1_5_1]], 60
+// CHECK-NEXT: [[MUL_6:%.+]] = mul i32 [[DIV_5]], 60
+// CHECK-NEXT: [[SUB_7:%.+]] = sub i32 [[IV1_5]], [[MUL_6]]
+
+// CHECK: [[IV1_6:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_6_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_6:%.+]] = udiv i32 [[IV1_6_1]], 60
+// CHECK-NEXT: [[MUL_7:%.+]] = mul i32 [[DIV_6]], 60
+// CHECK-NEXT: [[SUB_10:%.+]] = sub i32 [[IV1_6]], [[MUL_7]]
+// CHECK-NEXT: [[DIV_7:%.+]] = udiv i32 [[SUB_10]], 20
+// CHECK-NEXT: [[MUL_8:%.+]] = mul i32 [[DIV_7]], 20
+// CHECK-NEXT: [[SUB_11:%.+]] = sub i32 [[SUB_7]], [[MUL_8]]
+
+// CHECK: [[IV1_7:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK: [[IV1_7_1:%.+]] = load i32, i32* [[OMP_IV]]
+// CHECK-NEXT: [[DIV_8:%.+]] = udiv i32 [[IV1_7_1]], 60
+// CHECK-NEXT: [[MUL_9:%.+]] = mul i32 [[DIV_8]], 60
+// CHECK-NEXT: [[SUB_12:%.+

[PATCH] D55433: [clang-tidy] Adding a new modernize use nodiscard checker

2019-01-09 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

> I do not have commit rights. I'm not sure what constitutes someone who can 
> commit, but let me contribute a little more before taking that step,  I have 
> another idea for a checker I'd like to try after this one, I just wanted to 
> get one under my belt first.

See this: https://llvm.org/docs/DeveloperPolicy.html#obtaining-commit-access

I will commit for you then. More patches always welcome ;)


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55433/new/

https://reviews.llvm.org/D55433



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


r350758 - [OpenMP] Add flag for preventing the extension to 64 bits for the collapse loop counter

2019-01-09 Thread Gheorghe-Teodor Bercea via cfe-commits
Author: gbercea
Date: Wed Jan  9 12:38:35 2019
New Revision: 350758

URL: http://llvm.org/viewvc/llvm-project?rev=350758&view=rev
Log:
[OpenMP] Add flag for preventing the extension to 64 bits for the collapse loop 
counter

Summary: Introduce a compiler flag for cases when the user knows that the 
collapsed loop counter can be safely represented using at most 32 bits. This 
will prevent the emission of expensive mathematical operations (such as the div 
operation) on the iteration variable using 64 bits where 32 bit operations are 
sufficient.

Reviewers: ABataev, caomhin

Reviewed By: ABataev

Subscribers: hfinkel, kkwli0, guansong, cfe-commits

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

Modified:
cfe/trunk/docs/OpenMPSupport.rst
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/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=350758&r1=350757&r2=350758&view=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Wed Jan  9 12:38:35 2019
@@ -108,6 +108,16 @@ are stored in the global memory. In `Cud
 between the threads and it is user responsibility to share the required data
 between the threads in the parallel regions.
 
+Collapsed loop nest counter
+---
+
+When using the collapse clause on a loop nest the default behaviour is to
+automatically extend the representation of the loop counter to 64 bits for
+the cases where the sizes of the collapsed loops are not known at compile
+time. To prevent this conservative choice and use at most 32 bits,
+compile your program with the `-fopenmp-optimistic-collapse`.
+
+
 Features not supported or with limited support for Cuda devices
 ---
 

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=350758&r1=350757&r2=350758&view=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Wed Jan  9 12:38:35 2019
@@ -207,6 +207,7 @@ LANGOPT(OpenMPCUDAForceFullRuntime , 1,
 LANGOPT(OpenMPHostCXXExceptions, 1, 0, "C++ exceptions handling in the 
host code.")
 LANGOPT(OpenMPCUDANumSMs  , 32, 0, "Number of SMs for CUDA devices.")
 LANGOPT(OpenMPCUDABlocksPerSM  , 32, 0, "Number of blocks per SM for CUDA 
devices.")
+LANGOPT(OpenMPOptimisticCollapse  , 1, 0, "Use at most 32 bits to represent 
the collapsed loop nest counter.")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 
 LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=350758&r1=350757&r2=350758&view=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Wed Jan  9 12:38:35 2019
@@ -1574,6 +1574,10 @@ def fopenmp_cuda_number_of_sm_EQ : Joine
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_cuda_blocks_per_sm_EQ : Joined<["-"], 
"fopenmp-cuda-blocks-per-sm=">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fopenmp_optimistic_collapse : Flag<["-"], "fopenmp-optimistic-collapse">, 
Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fno_openmp_optimistic_collapse : Flag<["-"], 
"fno-openmp-optimistic-collapse">, Group,
+  Flags<[NoArgumentUnused, HelpHidden]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, 
Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, 
Group;
 def fno_escaping_block_tail_calls : Flag<["-"], 
"fno-escaping-block-tail-calls">, Group, Flags<[CC1Option]>;

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=350758&r1=350757&r2=350758&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Wed Jan  9 12:38:35 2019
@@ -4434,6 +4434,10 @@ void Clang::ConstructJob(Compilation &C,
   Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_version_EQ);
   Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_cuda_number_of_sm_EQ);
   Args.AddAllArgs(CmdArgs, options::OPT_fopenmp_cuda_blocks_per_sm_EQ);
+  if (Args.hasFlag(options::OPT

[PATCH] D55928: [OpenMP] Add flag for preventing the extension to 64 bits for the collapse loop counter

2019-01-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350758: [OpenMP] Add flag for preventing the extension to 64 
bits for the collapse loop… (authored by gbercea, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D55928?vs=179078&id=180906#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55928/new/

https://reviews.llvm.org/D55928

Files:
  docs/OpenMPSupport.rst
  include/clang/Basic/LangOptions.def
  include/clang/Driver/Options.td
  lib/Driver/ToolChains/Clang.cpp
  lib/Frontend/CompilerInvocation.cpp
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp

Index: docs/OpenMPSupport.rst
===
--- docs/OpenMPSupport.rst
+++ docs/OpenMPSupport.rst
@@ -108,6 +108,16 @@
 between the threads and it is user responsibility to share the required data
 between the threads in the parallel regions.
 
+Collapsed loop nest counter
+---
+
+When using the collapse clause on a loop nest the default behaviour is to
+automatically extend the representation of the loop counter to 64 bits for
+the cases where the sizes of the collapsed loops are not known at compile
+time. To prevent this conservative choice and use at most 32 bits,
+compile your program with the `-fopenmp-optimistic-collapse`.
+
+
 Features not supported or with limited support for Cuda devices
 ---
 
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1574,6 +1574,10 @@
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
 def fopenmp_cuda_blocks_per_sm_EQ : Joined<["-"], "fopenmp-cuda-blocks-per-sm=">, Group,
   Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fopenmp_optimistic_collapse : Flag<["-"], "fopenmp-optimistic-collapse">, Group,
+  Flags<[CC1Option, NoArgumentUnused, HelpHidden]>;
+def fno_openmp_optimistic_collapse : Flag<["-"], "fno-openmp-optimistic-collapse">, Group,
+  Flags<[NoArgumentUnused, HelpHidden]>;
 def fno_optimize_sibling_calls : Flag<["-"], "fno-optimize-sibling-calls">, Group;
 def foptimize_sibling_calls : Flag<["-"], "foptimize-sibling-calls">, Group;
 def fno_escaping_block_tail_calls : Flag<["-"], "fno-escaping-block-tail-calls">, Group, Flags<[CC1Option]>;
Index: include/clang/Basic/LangOptions.def
===
--- include/clang/Basic/LangOptions.def
+++ include/clang/Basic/LangOptions.def
@@ -207,6 +207,7 @@
 LANGOPT(OpenMPHostCXXExceptions, 1, 0, "C++ exceptions handling in the host code.")
 LANGOPT(OpenMPCUDANumSMs  , 32, 0, "Number of SMs for CUDA devices.")
 LANGOPT(OpenMPCUDABlocksPerSM  , 32, 0, "Number of blocks per SM for CUDA devices.")
+LANGOPT(OpenMPOptimisticCollapse  , 1, 0, "Use at most 32 bits to represent the collapsed loop nest counter.")
 LANGOPT(RenderScript  , 1, 0, "RenderScript")
 
 LANGOPT(CUDAIsDevice  , 1, 0, "compiling for CUDA device")
Index: test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
===
--- test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
+++ test/OpenMP/nvptx_target_teams_distribute_parallel_for_codegen.cpp
@@ -1,6 +1,7 @@
 // Test target codegen - host bc file has to be created first.
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple powerpc64le-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm-bc %s -o %t-ppc-host.bc
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-64 --check-prefix CHECK-DIV64
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx64-unknown-unknown -fopenmp-targets=nvptx64-nvidia-cuda -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-ppc-host.bc -fopenmp-optimistic-collapse -o - | FileCheck %s --check-prefix CHECK --check-prefix CHECK-DIV32
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple i386-unknown-unknown -fopenmp-targets=nvptx-nvidia-cuda -emit-llvm-bc %s -o %t-x86-host.bc
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 -fopenmp-cuda-mode -x c++ -triple nvptx-unknown-unknown -fopenmp-targets=nvptx-nvidia-cu

r350757 - [OPENMP][DOCS]Release notes/OpenMP support updates, NFC.

2019-01-09 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Jan  9 12:32:56 2019
New Revision: 350757

URL: http://llvm.org/viewvc/llvm-project?rev=350757&view=rev
Log:
[OPENMP][DOCS]Release notes/OpenMP support updates, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst
cfe/trunk/docs/ReleaseNotes.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=350757&r1=350756&r2=350757&view=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Wed Jan  9 12:32:56 2019
@@ -66,12 +66,11 @@ Combined directives
 
 * #pragma omp target teams distribute parallel for [simd]: :good:`Complete`.
 
-Clang does not support any constructs/updates from upcoming OpenMP 5.0 except
+Clang does not support any constructs/updates from OpenMP 5.0 except
 for `reduction`-based clauses in the `task` and `target`-based directives.
 
 In addition, the LLVM OpenMP runtime `libomp` supports the OpenMP Tools
 Interface (OMPT) on x86, x86_64, AArch64, and PPC64 on Linux, Windows, and mac 
OS.
-ows, and mac OS.
 
 .. _basic support for Cuda devices:
 
@@ -112,8 +111,6 @@ between the threads in the parallel regi
 Features not supported or with limited support for Cuda devices
 ---
 
-- Reductions across the teams are not supported yet.
-
 - Cancellation constructs are not supported.
 
 - Doacross loop nest is not supported.

Modified: cfe/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ReleaseNotes.rst?rev=350757&r1=350756&r2=350757&view=diff
==
--- cfe/trunk/docs/ReleaseNotes.rst (original)
+++ cfe/trunk/docs/ReleaseNotes.rst Wed Jan  9 12:32:56 2019
@@ -233,6 +233,24 @@ ABI Changes in Clang
 OpenMP Support in Clang
 --
 
+- Support relational-op != (not-equal) as one of the canonical forms of random
+  access iterator.
+
+- Added support for mapping of the lambdas in target regions.
+
+- Added parsing/sema analysis for OpenMP 5.0 requires directive.
+
+- Various bugfixes and improvements.
+
+New features supported for Cuda devices:
+
+- Added support for the reductions across the teams.
+
+- Extended number of constructs that can be executed in SPMD mode.
+
+- Fixed support for lastprivate/reduction variables in SPMD constructs.
+
+- General performance improvement.
 
 CUDA Support in Clang
 -


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


[PATCH] D56243: [coroutines] Experimenting with __builtin_coro_frame_max_size

2019-01-09 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 180905.
modocache added a comment.

Remove obsoleted code I accidentally included.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56243/new/

https://reviews.llvm.org/D56243

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExpr.cpp

Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -3633,6 +3633,41 @@
   return false;
 }
 
+static bool CheckCoroFrameMaxSizeTraitOperandType(Sema &S, QualType T,
+  SourceLocation Loc,
+  SourceRange ArgRange) {
+  const RecordType *RTy = nullptr;
+  if (auto *TTy = dyn_cast(T.getTypePtr()))
+RTy = dyn_cast_or_null(TTy->getReplacementType().getTypePtr());
+  if (!RTy) {
+S.Diag(Loc, diag::err_coro_frame_max_size_non_lambda_type) << T << ArgRange;
+return true;
+  }
+
+  auto *RD = dyn_cast_or_null(RTy->getDecl());
+  if (!RD || !RD->isLambda()) {
+S.Diag(Loc, diag::err_coro_frame_max_size_non_lambda_type)
+<< T << ArgRange;
+return true;
+  }
+
+  CXXMethodDecl *MD = RD->getLambdaCallOperator();
+  if (!MD->doesThisDeclarationHaveABody()) {
+S.Diag(Loc, diag::err_coro_frame_max_size_lambda_missing_body)
+<< T << ArgRange;
+return true;
+  }
+
+  auto *CoroBody = dyn_cast_or_null(MD->getBody());
+  if (!CoroBody) {
+S.Diag(Loc, diag::err_coro_frame_max_size_not_coroutine_lambda)
+<< T << ArgRange;
+return true;
+  }
+
+  return false;
+}
+
 static bool CheckExtensionTraitOperandType(Sema &S, QualType T,
SourceLocation Loc,
SourceRange ArgRange,
@@ -3712,6 +3747,9 @@
   if (ExprKind == UETT_VecStep)
 return CheckVecStepTraitOperandType(*this, ExprTy, E->getExprLoc(),
 E->getSourceRange());
+  else if (ExprKind == UETT_CoroFrameMaxSize)
+return CheckCoroFrameMaxSizeTraitOperandType(*this, ExprTy, E->getExprLoc(),
+ E->getSourceRange());
 
   // Whitelist some types as extensions
   if (!CheckExtensionTraitOperandType(*this, ExprTy, E->getExprLoc(),
@@ -3817,11 +3855,15 @@
   //   When alignof or _Alignof is applied to an array type, the result
   //   is the alignment of the element type.
   if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
-  ExprKind == UETT_OpenMPRequiredSimdAlign)
+  ExprKind == UETT_OpenMPRequiredSimdAlign ||
+  ExprKind == UETT_CoroFrameMaxSize)
 ExprType = Context.getBaseElementType(ExprType);
 
   if (ExprKind == UETT_VecStep)
 return CheckVecStepTraitOperandType(*this, ExprType, OpLoc, ExprRange);
+  else if (ExprKind == UETT_CoroFrameMaxSize)
+return CheckCoroFrameMaxSizeTraitOperandType(*this, ExprType, OpLoc,
+ ExprRange);
 
   // Whitelist some types as extensions
   if (!CheckExtensionTraitOperandType(*this, ExprType, OpLoc, ExprRange,
@@ -4101,8 +4143,11 @@
   } else if (ExprKind == UETT_VecStep) {
 isInvalid = CheckVecStepExpr(E);
   } else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
-  Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
-  isInvalid = true;
+Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
+isInvalid = true;
+  } else if (ExprKind == UETT_CoroFrameMaxSize) {
+Diag(E->getExprLoc(), diag::err_coro_frame_max_size_expr);
+isInvalid = true;
   } else if (E->refersToBitField()) {  // C99 6.5.3.4p1.
 Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
 isInvalid = true;
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1185,6 +1185,8 @@
   case tok::kw_vec_step:   // unary-expression: OpenCL 'vec_step' expression
   // unary-expression: '__builtin_omp_required_simd_align' '(' type-name ')'
   case tok::kw___builtin_omp_required_simd_align:
+  // unary-exression: '__builtin_coro_frame_max_size' '(' type-name ')'
+  case tok::kw___builtin_coro_frame_max_size:
 return ParseUnaryExprOrTypeTraitExpression();
   case tok::ampamp: {  // unary-expression: '&&' identifier
 SourceLocation AmpAmpLoc = ConsumeToken();
@@ -1870,7 +1872,8 @@
 
   assert(OpTok.isOneOf(tok::kw_typeof, tok::kw_sizeof, tok::kw___alignof,
tok::kw_alignof, tok::kw__Alignof, tok::kw_vec_step,
-   tok::kw__

[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington accepted this revision.
erik.pilkington added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56469/new/

https://reviews.llvm.org/D56469



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


[PATCH] D56243: [coroutines] Experimenting with __builtin_coro_frame_max_size

2019-01-09 Thread Brian Gesiak via Phabricator via cfe-commits
modocache updated this revision to Diff 180903.
modocache added a comment.

Thanks for the offline review @GorNishanov! This revision allows constexpr 
usages of __builtin_coro_frame_max_size.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56243/new/

https://reviews.llvm.org/D56243

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/DeclCXX.h
  include/clang/Basic/Builtins.def
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  lib/AST/ASTContext.cpp
  lib/AST/ASTDumper.cpp
  lib/AST/DeclCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/CodeGen/CGCoroutine.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExpr.cpp

Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -3633,6 +3633,41 @@
   return false;
 }
 
+static bool CheckCoroFrameMaxSizeTraitOperandType(Sema &S, QualType T,
+  SourceLocation Loc,
+  SourceRange ArgRange) {
+  const RecordType *RTy = nullptr;
+  if (auto *TTy = dyn_cast(T.getTypePtr()))
+RTy = dyn_cast_or_null(TTy->getReplacementType().getTypePtr());
+  if (!RTy) {
+S.Diag(Loc, diag::err_coro_frame_max_size_non_lambda_type) << T << ArgRange;
+return true;
+  }
+
+  auto *RD = dyn_cast_or_null(RTy->getDecl());
+  if (!RD || !RD->isLambda()) {
+S.Diag(Loc, diag::err_coro_frame_max_size_non_lambda_type)
+<< T << ArgRange;
+return true;
+  }
+
+  CXXMethodDecl *MD = RD->getLambdaCallOperator();
+  if (!MD->doesThisDeclarationHaveABody()) {
+S.Diag(Loc, diag::err_coro_frame_max_size_lambda_missing_body)
+<< T << ArgRange;
+return true;
+  }
+
+  auto *CoroBody = dyn_cast_or_null(MD->getBody());
+  if (!CoroBody) {
+S.Diag(Loc, diag::err_coro_frame_max_size_not_coroutine_lambda)
+<< T << ArgRange;
+return true;
+  }
+
+  return false; // ok
+}
+
 static bool CheckExtensionTraitOperandType(Sema &S, QualType T,
SourceLocation Loc,
SourceRange ArgRange,
@@ -3712,6 +3747,9 @@
   if (ExprKind == UETT_VecStep)
 return CheckVecStepTraitOperandType(*this, ExprTy, E->getExprLoc(),
 E->getSourceRange());
+  else if (ExprKind == UETT_CoroFrameMaxSize)
+return CheckCoroFrameMaxSizeTraitOperandType(*this, ExprTy, E->getExprLoc(),
+ E->getSourceRange());
 
   // Whitelist some types as extensions
   if (!CheckExtensionTraitOperandType(*this, ExprTy, E->getExprLoc(),
@@ -3817,11 +3855,15 @@
   //   When alignof or _Alignof is applied to an array type, the result
   //   is the alignment of the element type.
   if (ExprKind == UETT_AlignOf || ExprKind == UETT_PreferredAlignOf ||
-  ExprKind == UETT_OpenMPRequiredSimdAlign)
+  ExprKind == UETT_OpenMPRequiredSimdAlign ||
+  ExprKind == UETT_CoroFrameMaxSize)
 ExprType = Context.getBaseElementType(ExprType);
 
   if (ExprKind == UETT_VecStep)
 return CheckVecStepTraitOperandType(*this, ExprType, OpLoc, ExprRange);
+  else if (ExprKind == UETT_CoroFrameMaxSize)
+return CheckCoroFrameMaxSizeTraitOperandType(*this, ExprType, OpLoc,
+ ExprRange);
 
   // Whitelist some types as extensions
   if (!CheckExtensionTraitOperandType(*this, ExprType, OpLoc, ExprRange,
@@ -4101,8 +4143,11 @@
   } else if (ExprKind == UETT_VecStep) {
 isInvalid = CheckVecStepExpr(E);
   } else if (ExprKind == UETT_OpenMPRequiredSimdAlign) {
-  Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
-  isInvalid = true;
+Diag(E->getExprLoc(), diag::err_openmp_default_simd_align_expr);
+isInvalid = true;
+  } else if (ExprKind == UETT_CoroFrameMaxSize) {
+Diag(E->getExprLoc(), diag::err_coro_frame_max_size_expr);
+isInvalid = true;
   } else if (E->refersToBitField()) {  // C99 6.5.3.4p1.
 Diag(E->getExprLoc(), diag::err_sizeof_alignof_typeof_bitfield) << 0;
 isInvalid = true;
Index: lib/Parse/ParseExpr.cpp
===
--- lib/Parse/ParseExpr.cpp
+++ lib/Parse/ParseExpr.cpp
@@ -1185,6 +1185,8 @@
   case tok::kw_vec_step:   // unary-expression: OpenCL 'vec_step' expression
   // unary-expression: '__builtin_omp_required_simd_align' '(' type-name ')'
   case tok::kw___builtin_omp_required_simd_align:
+  // unary-exression: '__builtin_coro_frame_max_size' '(' type-name ')'
+  case tok::kw___builtin_coro_frame_max_size:
 return ParseUnaryExprOrTypeTraitExpression();
   case tok::ampamp: {  // unary-expression: '&&' identifier
 SourceLocation AmpAmpLoc = ConsumeToken();
@@ -1870,7 +1872,8 @@
 
   assert(Op

[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 180901.
arphaman marked 3 inline comments as done.
arphaman added a comment.

Address review comments.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56469/new/

https://reviews.llvm.org/D56469

Files:
  lib/Sema/SemaDeclAttr.cpp
  test/SemaObjC/call-unavailable-init-in-self.m

Index: test/SemaObjC/call-unavailable-init-in-self.m
===
--- /dev/null
+++ test/SemaObjC/call-unavailable-init-in-self.m
@@ -0,0 +1,68 @@
+// RUN: %clang_cc1 -x objective-c -verify -fobjc-arc %s
+
+@interface NSObject
+
++ (instancetype)new;
++ (instancetype)alloc;
+
+@end
+
+@interface Sub: NSObject
+
+- (instancetype)init __attribute__((unavailable)); // expected-note 4 {{'init' has been explicitly marked unavailable here}}
+
+- (void)notImplemented __attribute__((unavailable)); // expected-note {{'notImplemented' has been explicitly marked unavailable here}}
+
+@end
+
+@implementation Sub
+
++ (Sub *)create {
+  return [[self alloc] init];
+}
+
++ (Sub *)create2 {
+  return [self new];
+}
+
++ (Sub *)create3 {
+  return [Sub new];
+}
+
+- (instancetype) init {
+  return self;
+}
+
+- (void)reportUseOfUnimplemented {
+  [self notImplemented]; // expected-error {{'notImplemented' is unavailable}}
+}
+
+@end
+
+@interface SubClassContext: Sub
+@end
+
+@implementation SubClassContext
+
+- (void)subClassContext {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
+
+@end
+
+void unrelatedContext() {
+  (void)[[Sub alloc] init]; // expected-error {{'init' is unavailable}}
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}
+
+@interface X @end
+
+@interface X (Foo)
+-(void)meth __attribute__((unavailable));
+@end
+
+@implementation X (Foo)
+-(void)meth {}
+-(void)call_it { [self meth]; }
+@end
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -7269,9 +7269,10 @@
 /// whether we should emit a diagnostic for \c K and \c DeclVersion in
 /// the context of \c Ctx. For example, we should emit an unavailable diagnostic
 /// in a deprecated context, but not the other way around.
-static bool ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K,
-VersionTuple DeclVersion,
-Decl *Ctx) {
+static bool
+ShouldDiagnoseAvailabilityInContext(Sema &S, AvailabilityResult K,
+VersionTuple DeclVersion, Decl *Ctx,
+const NamedDecl *OffendingDecl) {
   assert(K != AR_Available && "Expected an unavailable declaration here!");
 
   // Checks if we should emit the availability diagnostic in the context of C.
@@ -7280,9 +7281,22 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, C))
 if (AA->getIntroduced() >= DeclVersion)
   return true;
-} else if (K == AR_Deprecated)
+} else if (K == AR_Deprecated) {
   if (C->isDeprecated())
 return true;
+} else if (K == AR_Unavailable) {
+  // It is perfectly fine to refer to an 'unavailable' Objective-C method
+  // when it's actually defined and is referenced from within the
+  // @implementation itself. In this context, we interpret unavailable as a
+  // form of access control.
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(C)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&
+  MD->isDefined())
+return true;
+}
+  }
+}
 
 if (C->isUnavailable())
   return true;
@@ -7471,7 +7485,8 @@
   if (const AvailabilityAttr *AA = getAttrForPlatform(S.Context, OffendingDecl))
 DeclVersion = AA->getIntroduced();
 
-  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx))
+  if (!ShouldDiagnoseAvailabilityInContext(S, K, DeclVersion, Ctx,
+   OffendingDecl))
 return;
 
   SourceLocation Loc = Locs.front();
@@ -7955,7 +7970,8 @@
 
 // If the context of this function is less available than D, we should not
 // emit a diagnostic.
-if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx))
+if (!ShouldDiagnoseAvailabilityInContext(SemaRef, Result, Introduced, Ctx,
+ OffendingDecl))
   return;
 
 // We would like to emit the diagnostic even if -Wunguarded-availability is
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350756 - Removing an include that was not necessary; NFC.

2019-01-09 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Jan  9 12:15:10 2019
New Revision: 350756

URL: http://llvm.org/viewvc/llvm-project?rev=350756&view=rev
Log:
Removing an include that was not necessary; NFC.

The include also had a using namespace llvm in it, so this adds qualifiers 
where needed as well.

Modified:
cfe/trunk/include/clang/AST/ASTDumperUtils.h

Modified: cfe/trunk/include/clang/AST/ASTDumperUtils.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTDumperUtils.h?rev=350756&r1=350755&r2=350756&view=diff
==
--- cfe/trunk/include/clang/AST/ASTDumperUtils.h (original)
+++ cfe/trunk/include/clang/AST/ASTDumperUtils.h Wed Jan  9 12:15:10 2019
@@ -14,7 +14,6 @@
 #ifndef LLVM_CLANG_AST_ASTDUMPERUTILS_H
 #define LLVM_CLANG_AST_ASTDUMPERUTILS_H
 
-#include "clang/AST/ASTContext.h"
 #include "llvm/Support/raw_ostream.h"
 
 namespace clang {
@@ -23,7 +22,7 @@ namespace clang {
 // Do not use bold yellow for any text.  It is hard to read on white screens.
 
 struct TerminalColor {
-  raw_ostream::Colors Color;
+  llvm::raw_ostream::Colors Color;
   bool Bold;
 };
 
@@ -38,50 +37,51 @@ struct TerminalColor {
 // Bold Cyan - ValueColor, DeclNameColor
 
 // Decl kind names (VarDecl, FunctionDecl, etc)
-static const TerminalColor DeclKindNameColor = {raw_ostream::GREEN, true};
+static const TerminalColor DeclKindNameColor = {llvm::raw_ostream::GREEN, 
true};
 // Attr names (CleanupAttr, GuardedByAttr, etc)
-static const TerminalColor AttrColor = {raw_ostream::BLUE, true};
+static const TerminalColor AttrColor = {llvm::raw_ostream::BLUE, true};
 // Statement names (DeclStmt, ImplicitCastExpr, etc)
-static const TerminalColor StmtColor = {raw_ostream::MAGENTA, true};
+static const TerminalColor StmtColor = {llvm::raw_ostream::MAGENTA, true};
 // Comment names (FullComment, ParagraphComment, TextComment, etc)
-static const TerminalColor CommentColor = {raw_ostream::BLUE, false};
+static const TerminalColor CommentColor = {llvm::raw_ostream::BLUE, false};
 
 // Type names (int, float, etc, plus user defined types)
-static const TerminalColor TypeColor = {raw_ostream::GREEN, false};
+static const TerminalColor TypeColor = {llvm::raw_ostream::GREEN, false};
 
 // Pointer address
-static const TerminalColor AddressColor = {raw_ostream::YELLOW, false};
+static const TerminalColor AddressColor = {llvm::raw_ostream::YELLOW, false};
 // Source locations
-static const TerminalColor LocationColor = {raw_ostream::YELLOW, false};
+static const TerminalColor LocationColor = {llvm::raw_ostream::YELLOW, false};
 
 // lvalue/xvalue
-static const TerminalColor ValueKindColor = {raw_ostream::CYAN, false};
+static const TerminalColor ValueKindColor = {llvm::raw_ostream::CYAN, false};
 // bitfield/objcproperty/objcsubscript/vectorcomponent
-static const TerminalColor ObjectKindColor = {raw_ostream::CYAN, false};
+static const TerminalColor ObjectKindColor = {llvm::raw_ostream::CYAN, false};
 
 // Null statements
-static const TerminalColor NullColor = {raw_ostream::BLUE, false};
+static const TerminalColor NullColor = {llvm::raw_ostream::BLUE, false};
 
 // Undeserialized entities
-static const TerminalColor UndeserializedColor = {raw_ostream::GREEN, true};
+static const TerminalColor UndeserializedColor = {llvm::raw_ostream::GREEN,
+  true};
 
 // CastKind from CastExpr's
-static const TerminalColor CastColor = {raw_ostream::RED, false};
+static const TerminalColor CastColor = {llvm::raw_ostream::RED, false};
 
 // Value of the statement
-static const TerminalColor ValueColor = {raw_ostream::CYAN, true};
+static const TerminalColor ValueColor = {llvm::raw_ostream::CYAN, true};
 // Decl names
-static const TerminalColor DeclNameColor = {raw_ostream::CYAN, true};
+static const TerminalColor DeclNameColor = {llvm::raw_ostream::CYAN, true};
 
 // Indents ( `, -. | )
-static const TerminalColor IndentColor = {raw_ostream::BLUE, false};
+static const TerminalColor IndentColor = {llvm::raw_ostream::BLUE, false};
 
 class ColorScope {
-  raw_ostream &OS;
+  llvm::raw_ostream &OS;
   const bool ShowColors;
 
 public:
-  ColorScope(raw_ostream &OS, bool ShowColors, TerminalColor Color)
+  ColorScope(llvm::raw_ostream &OS, bool ShowColors, TerminalColor Color)
   : OS(OS), ShowColors(ShowColors) {
 if (ShowColors)
   OS.changeColor(Color.Color, Color.Bold);


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


[PATCH] D56463: [SEH] Pass the frame pointer from SEH finally to finally functions

2019-01-09 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

It's currently possible to write, in clang:

  void f() {
__try {
}
__except(({__try{}__finally{}; 3;})) {
}
  }

And the following currently crashes if you try to build it with clang:

  struct A { ~A(); };
  int f(const A&);
  void g() {
__try {
}
__except(f(A())) {
}
  }

But both of those should be rejected; it should be safe to assume it's 
impossible to have an __finally block inside a filter.

I think this looks fine, but I'd prefer if Reid could take a quick look.




Comment at: lib/CodeGen/CGException.cpp:1632
+// If CFG.IsOutlinedSEHHelper is true, then we are within a finally block.
+if (CGF.IsOutlinedSEHHelper)
+  FP = &CGF.CurFn->arg_begin()[1];

Please use braces consistently.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56463/new/

https://reviews.llvm.org/D56463



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


[PATCH] D55928: [OpenMP] Add flag for preventing the extension to 64 bits for the collapse loop counter

2019-01-09 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea marked an inline comment as done.
gtbercea added inline comments.



Comment at: docs/OpenMPSupport.rst:120
+compile your program with the `-fopenmp-optimistic-collapse`.
+
+

hfinkel wrote:
> Can you please clarify here what happens when the loop induction variables 
> are already 64 bits. If any of them are already 64 bits, then we still use 64 
> bits overall?
> 
This flag is for the user to guarantee that the total size of the collapsed 
loops can be represented using at most 32 bits (regardless of the actual width 
of the individual loop induction variables).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55928/new/

https://reviews.llvm.org/D55928



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


[PATCH] D56466: [CodeGen] Clarify comment about COFF common symbol alignment

2019-01-09 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC350754: [CodeGen] Clarify comment about COFF common symbol 
alignment (authored by smeenai, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D56466?vs=180771&id=180897#toc

Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56466/new/

https://reviews.llvm.org/D56466

Files:
  lib/CodeGen/CodeGenModule.cpp


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,8 +3761,12 @@
   }
 }
   }
-  // COFF doesn't support alignments greater than 32, so these cannot be
-  // in common.
+
+  // Microsoft's link.exe doesn't support alignments greater than 32 for common
+  // symbols, so symbols with greater alignment requirements cannot be common.
+  // Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
+  // alignments for common symbols via the aligncomm directive, so this
+  // restriction only applies to MSVC environments.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
   Context.getTypeAlignIfKnown(D->getType()) > 32)
 return true;


Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -3761,8 +3761,12 @@
   }
 }
   }
-  // COFF doesn't support alignments greater than 32, so these cannot be
-  // in common.
+
+  // Microsoft's link.exe doesn't support alignments greater than 32 for common
+  // symbols, so symbols with greater alignment requirements cannot be common.
+  // Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
+  // alignments for common symbols via the aligncomm directive, so this
+  // restriction only applies to MSVC environments.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
   Context.getTypeAlignIfKnown(D->getType()) > 32)
 return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r350754 - [CodeGen] Clarify comment about COFF common symbol alignment

2019-01-09 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Wed Jan  9 12:05:16 2019
New Revision: 350754

URL: http://llvm.org/viewvc/llvm-project?rev=350754&view=rev
Log:
[CodeGen] Clarify comment about COFF common symbol alignment

After a discussion on the commit thread, it seems the 32 byte alignment
limitation is an MSVC toolchain artifact, not an inherent COFF
restriction. Clarify the comment accordingly, since saying COFF in the
comment but using isKnownWindowsMSVCEnvironment in the conditional is
confusing. Also add a newline before the comment, which is consistent
with the local style.

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

Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=350754&r1=350753&r2=350754&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Wed Jan  9 12:05:16 2019
@@ -3761,8 +3761,12 @@ static bool isVarDeclStrongDefinition(co
   }
 }
   }
-  // COFF doesn't support alignments greater than 32, so these cannot be
-  // in common.
+
+  // Microsoft's link.exe doesn't support alignments greater than 32 for common
+  // symbols, so symbols with greater alignment requirements cannot be common.
+  // Other COFF linkers (ld.bfd and LLD) support arbitrary power-of-two
+  // alignments for common symbols via the aligncomm directive, so this
+  // restriction only applies to MSVC environments.
   if (Context.getTargetInfo().getTriple().isKnownWindowsMSVCEnvironment() &&
   Context.getTypeAlignIfKnown(D->getType()) > 32)
 return true;


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


[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

I really dislike this particular idiom.

This is probably the most reasonable short-term solution to this problem.  I do 
wonder if we should just shift to making Sema track a symbol-to-GD map, though, 
and maybe make Sema entirely responsible for pushing entities to IRGen to emit.




Comment at: test/Sema/alias-unused.c:3
+// expected-no-diagnostics
+int f() { return 42; }
+int g() __attribute__((alias("f")));

Is this meant to be `static`?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188



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


[PATCH] D56509: [AST] Remove ASTContext from getThisType (NFC)

2019-01-09 Thread Brian Gesiak via Phabricator via cfe-commits
modocache created this revision.
modocache added reviewers: akyrtzi, mikael.
Herald added subscribers: dexonsmith, mehdi_amini.

https://reviews.llvm.org/D54862 removed the usages of `ASTContext&` from
within the `CXXMethodDecl::getThisType` method. Remove the parameter
altogether, as well as all usages of it. This does not result in any
functional change because the parameter was unused since
https://reviews.llvm.org/D54862.

Test Plan: check-clang


Repository:
  rC Clang

https://reviews.llvm.org/D56509

Files:
  include/clang/AST/DeclCXX.h
  lib/AST/DeclCXX.cpp
  lib/AST/ExprConstant.cpp
  lib/Analysis/Consumed.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGCXXABI.cpp
  lib/CodeGen/CGClass.cpp
  lib/CodeGen/CGDebugInfo.cpp
  lib/CodeGen/CGVTables.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/MicrosoftCXXABI.cpp
  lib/Sema/SemaCoroutine.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  lib/StaticAnalyzer/Core/LoopWidening.cpp
  lib/StaticAnalyzer/Core/MemRegion.cpp
  lib/StaticAnalyzer/Core/SValBuilder.cpp

Index: lib/StaticAnalyzer/Core/SValBuilder.cpp
===
--- lib/StaticAnalyzer/Core/SValBuilder.cpp
+++ lib/StaticAnalyzer/Core/SValBuilder.cpp
@@ -271,8 +271,8 @@
 /// Return a memory region for the 'this' object reference.
 loc::MemRegionVal SValBuilder::getCXXThis(const CXXMethodDecl *D,
   const StackFrameContext *SFC) {
-  return loc::MemRegionVal(getRegionManager().
-   getCXXThisRegion(D->getThisType(getContext()), SFC));
+  return loc::MemRegionVal(
+  getRegionManager().getCXXThisRegion(D->getThisType(), SFC));
 }
 
 /// Return a memory region for the 'this' object reference.
Index: lib/StaticAnalyzer/Core/MemRegion.cpp
===
--- lib/StaticAnalyzer/Core/MemRegion.cpp
+++ lib/StaticAnalyzer/Core/MemRegion.cpp
@@ -1105,9 +1105,8 @@
   // FIXME: when operator() of lambda is analyzed as a top level function and
   // 'this' refers to a this to the enclosing scope, there is no right region to
   // return.
-  while (!LC->inTopFrame() &&
- (!D || D->isStatic() ||
-  PT != D->getThisType(getContext())->getAs())) {
+  while (!LC->inTopFrame() && (!D || D->isStatic() ||
+   PT != D->getThisType()->getAs())) {
 LC = LC->getParent();
 D = dyn_cast(LC->getDecl());
   }
Index: lib/StaticAnalyzer/Core/LoopWidening.cpp
===
--- lib/StaticAnalyzer/Core/LoopWidening.cpp
+++ lib/StaticAnalyzer/Core/LoopWidening.cpp
@@ -85,9 +85,8 @@
   // have 'this' pointers.
   const CXXMethodDecl *CXXMD = dyn_cast(STC->getDecl());
   if (CXXMD && !CXXMD->isStatic()) {
-const CXXThisRegion *ThisR = MRMgr.getCXXThisRegion(
-CXXMD->getThisType(STC->getAnalysisDeclContext()->getASTContext()),
-STC);
+const CXXThisRegion *ThisR =
+MRMgr.getCXXThisRegion(CXXMD->getThisType(), STC);
 ITraits.setTrait(ThisR,
  RegionAndSymbolInvalidationTraits::TK_PreserveContents);
   }
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -627,7 +627,7 @@
 
   if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
   isa(DC) && cast(DC)->isInstance()) {
-QualType ThisType = cast(DC)->getThisType(Context);
+QualType ThisType = cast(DC)->getThisType();
 
 // Since the 'this' expression is synthesized, we don't need to
 // perform the double-lookup check.
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -3277,7 +3277,7 @@
   case OR_Success: {
 // Record the standard conversion we used and the conversion function.
 CXXConstructorDecl *Constructor = cast(Best->Function);
-QualType ThisType = Constructor->getThisType(S.Context);
+QualType ThisType = Constructor->getThisType();
 // Initializer lists don't have conversions as such.
 User.Before.setAsIdentityConversion();
 User.HadMultipleCandidates = HadMultipleCandidates;
@@ -3458,7 +3458,7 @@
   //   sequence converts the source type to the type required by
   //   the argument of the constructor.
   //
-  QualType ThisType = Constructor->getThisType(S.Context);
+  QualType ThisType = Constructor->getThisType();
   if (isa(From)) {
 // Initializer lists don't have conversions as such.
 User.Before.setAsIdentityConversion();
@@ -5212,12 +5212,12 @@
   CXXMethodDecl *Method) {
   QualType FromRecordType, DestType;
   QualType ImplicitParamRecordType  =
-Method->getThisType(Context)->getAs()->g

[PATCH] D54188: [Sema] Mark target of __attribute__((alias("target"))) used for C

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

I don't like having a solution that doesn't work for C++ and can't reasonably 
be extended to a solution for C++ (we really don't want to be demangling the 
alias target here and trying to match it against the program, and ideally we 
don't want to delay the warning in question to codegen time), but this does 
reduce warning false-positives so it seems hard to object to. (We'll still need 
to tell people to mark declarations as `__attribute__((used))` when they're 
used in this way if their names are mangled.)

On balance I'm OK with this, but adding @rjmccall in case he has a different 
view or sees a better approach.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D54188/new/

https://reviews.llvm.org/D54188



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D56411#1349342 , @rjmccall wrote:

> Sema won't necessarily have resolved a template decl when parsing a template 
> argument list, so trying to propagate that decl down to indicate that we're 
> resolving a template argument is not a good approach.
>
> I was going to suggest recording that we're within a template argument in the 
> current `ExpressionEvaluationContextRecord`, but in fact there's an even 
> simpler and more general solution: there's no reason to enforce this 
> restriction in *any* unevaluated context.  If someone wants to refer to a 
> device function within a `decltype` or `sizeof` operand, that should be fine. 
>  So you should just conditionalize the diagnostic on whether this is within 
> an unevaluated context.


For the deferred device/host check I still need to know the template decl. I 
have updated the patch to pass it through ExpressionEvaluationContextRecord.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411



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


[PATCH] D56411: [CUDA][HIP][Sema] Fix template kernel with function as template parameter

2019-01-09 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl updated this revision to Diff 180888.
yaxunl added a comment.

Passing template decl by ExpressionEvaluationContextRecord.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56411/new/

https://reviews.llvm.org/D56411

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaCUDA.cpp
  lib/Sema/SemaTemplate.cpp
  test/SemaCUDA/kernel-template-with-func-arg.cu

Index: test/SemaCUDA/kernel-template-with-func-arg.cu
===
--- /dev/null
+++ test/SemaCUDA/kernel-template-with-func-arg.cu
@@ -0,0 +1,57 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+#include "Inputs/cuda.h"
+
+struct C {
+  __device__ void devfun() {}
+  void hostfun() {}
+  template __device__ void devtempfun() {}
+  __device__ __host__ void devhostfun() {}
+};
+
+__device__ void devfun() {}
+__host__ void hostfun() {}
+template __device__ void devtempfun() {}
+__device__ __host__ void devhostfun() {}
+
+template  __global__ void kernel() { devF();}
+template  __global__ void kernel2(T *p) { (p->*devF)(); }
+
+template<> __global__ void kernel();
+template<> __global__ void kernel(); // expected-error {{no function template matches function template specialization 'kernel'}}
+  // expected-note@-5 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel >();
+template<> __global__ void kernel();
+
+template<> __global__ void kernel<&devfun>();
+template<> __global__ void kernel<&hostfun>(); // expected-error {{no function template matches function template specialization 'kernel'}}
+   // expected-note@-11 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel<&devtempfun >();
+template<> __global__ void kernel<&devhostfun>();
+
+template<> __global__ void kernel2(C *p);
+template<> __global__ void kernel2(C *p); // expected-error {{no function template matches function template specialization 'kernel2'}}
+  // expected-note@-16 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+template<> __global__ void kernel2 >(C *p);
+template<> __global__ void kernel2(C *p);
+
+void fun() {
+  kernel<&devfun><<<1,1>>>();
+  kernel<&hostfun><<<1,1>>>(); // expected-error {{no matching function for call to 'kernel'}}
+   // expected-note@-24 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel<&devtempfun ><<<1,1>>>();
+  kernel<&devhostfun><<<1,1>>>();
+
+  kernel<<<1,1>>>();
+  kernel<<<1,1>>>(); // expected-error {{no matching function for call to 'kernel'}}
+  // expected-note@-30 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel ><<<1,1>>>();
+  kernel<<<1,1>>>();
+
+  C a;
+  kernel2<<<1,1>>>(&a);
+  kernel2<<<1,1>>>(&a); // expected-error {{no matching function for call to 'kernel2'}}
+// expected-note@-36 {{candidate template ignored: invalid explicitly-specified argument for template parameter 'devF'}}
+  kernel2 ><<<1,1>>>(&a);
+  kernel2<<<1,1>>>(&a);
+}
Index: lib/Sema/SemaTemplate.cpp
===
--- lib/Sema/SemaTemplate.cpp
+++ lib/Sema/SemaTemplate.cpp
@@ -4534,6 +4534,7 @@
 
   EnterExpressionEvaluationContext ConstantEvaluated(
   SemaRef, Sema::ExpressionEvaluationContext::ConstantEvaluated);
+  SemaRef.ExprEvalContexts.back().Template = Template;
   return SemaRef.SubstExpr(Param->getDefaultArgument(), TemplateArgLists);
 }
 
@@ -4784,8 +4785,8 @@
   TemplateArgument Result;
   unsigned CurSFINAEErrors = NumSFINAEErrors;
   ExprResult Res =
-CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
-  Result, CTAK);
+  CheckTemplateArgument(NTTP, NTTPType, Arg.getArgument().getAsExpr(),
+Result, CTAK, dyn_cast(Template));
   if (Res.isInvalid())
 return true;
   // If the current template argument causes an error, give up now.
@@ -6154,6 +6155,22 @@
   return true;
 }
 
+namespace {
+FunctionDecl *GetFunctionDecl(Expr *Arg) {
+  Expr *E = Arg;
+  if (UnaryOperator *UO = dyn_cast(E)) {
+E = UO ? UO->getSubExpr() : nullptr;
+  }
+  if (DeclRefExpr *DRE = dyn_cast_or_null(E)) {
+ValueDecl *Entity = DRE ? DRE->getDecl() : nullptr;
+if (Entity) {
+  if (auto Callee = dyn_cast(Entity))
+return Callee;
+}
+  }
+  return nullptr;
+}
+} // namespace
 /// Check a template argument against its corresponding
 /// non-type template parameter.
 ///
@@ -6164,7 +6181,8 @@
 ExprResult Sema::CheckTemplateArgument(NonTypeTemplateParmD

[PATCH] D55781: Make CC mangling conditional on the ABI version

2019-01-09 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

Okay.  In my opinion, then, we should just do this unconditionally.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55781/new/

https://reviews.llvm.org/D55781



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


[PATCH] D56215: [lld] [ELF] Include default search paths for NetBSD driver

2019-01-09 Thread Michał Górny via Phabricator via cfe-commits
mgorny updated this revision to Diff 180886.
mgorny added a comment.

Adjusted to make paths sysroot-relative.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56215/new/

https://reviews.llvm.org/D56215

Files:
  ELF/Config.h
  ELF/Driver.cpp
  ELF/Driver.h


Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,7 +31,9 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setDefaultTargetTriple(StringRef argv0);
   void readConfigs(llvm::opt::InputArgList &Args);
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
   template  void link(llvm::opt::InputArgList &Args);
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -365,6 +365,23 @@
   error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+// NetBSD driver relies on the linker knowing the default search paths.
+// Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+// (NetBSD::NetBSD constructor)
+switch (Config->EMachine) {
+  case EM_386:
+Config->SearchPaths.push_back("=/usr/lib/i386");
+break;
+  case EM_X86_64:
+break;
+  // TODO: support non-x86 architectures
+}
+Config->SearchPaths.push_back("=/usr/lib");
+  }
+}
+
 void LinkerDriver::main(ArrayRef ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -410,8 +427,10 @@
 }
   }
 
+  setDefaultTargetTriple(ArgsArr[0]);
   readConfigs(Args);
   checkZOptions(Args);
+  appendDefaultSearchPaths();
 
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.
@@ -746,6 +765,21 @@
   error(Msg + ": " + StringRef(Err).trim());
 }
 
+void LinkerDriver::setDefaultTargetTriple(StringRef argv0) {
+  // Start with a default initial triple
+  Config->TargetTriple = llvm::Triple(getDefaultTargetTriple());
+
+  // Try to override triple with program name prefix
+  std::string ProgName = llvm::sys::path::stem(argv0);
+  size_t LastComponent = ProgName.rfind('-');
+  if (LastComponent != std::string::npos) {
+std::string Prefix = ProgName.substr(0, LastComponent);
+std::string IgnoredError;
+// TODO: verify the triple somehow?
+Config->TargetTriple = llvm::Triple(Prefix);
+  }
+}
+
 // Initializes Config members by the command line options.
 void LinkerDriver::readConfigs(opt::InputArgList &Args) {
   errorHandler().Verbose = Args.hasArg(OPT_verbose);
Index: ELF/Config.h
===
--- ELF/Config.h
+++ ELF/Config.h
@@ -14,6 +14,7 @@
 #include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/ADT/StringSet.h"
+#include "llvm/ADT/Triple.h"
 #include "llvm/BinaryFormat/ELF.h"
 #include "llvm/Support/CachePruning.h"
 #include "llvm/Support/CodeGen.h"
@@ -276,6 +277,10 @@
 
   // 4 for ELF32, 8 for ELF64.
   int Wordsize;
+
+  // Target triple, inferred from program name or defaulted to LLVM
+  // default target.
+  llvm::Triple TargetTriple;
 };
 
 // The only instance of Configuration struct.


Index: ELF/Driver.h
===
--- ELF/Driver.h
+++ ELF/Driver.h
@@ -31,7 +31,9 @@
   void addLibrary(StringRef Name);
 
 private:
+  void setDefaultTargetTriple(StringRef argv0);
   void readConfigs(llvm::opt::InputArgList &Args);
+  void appendDefaultSearchPaths();
   void createFiles(llvm::opt::InputArgList &Args);
   void inferMachineType();
   template  void link(llvm::opt::InputArgList &Args);
Index: ELF/Driver.cpp
===
--- ELF/Driver.cpp
+++ ELF/Driver.cpp
@@ -365,6 +365,23 @@
   error("unknown -z value: " + StringRef(Arg->getValue()));
 }
 
+void LinkerDriver::appendDefaultSearchPaths() {
+  if (Config->TargetTriple.isOSNetBSD()) {
+// NetBSD driver relies on the linker knowing the default search paths.
+// Please keep this in sync with clang/lib/Driver/ToolChains/NetBSD.cpp
+// (NetBSD::NetBSD constructor)
+switch (Config->EMachine) {
+  case EM_386:
+Config->SearchPaths.push_back("=/usr/lib/i386");
+break;
+  case EM_X86_64:
+break;
+  // TODO: support non-x86 architectures
+}
+Config->SearchPaths.push_back("=/usr/lib");
+  }
+}
+
 void LinkerDriver::main(ArrayRef ArgsArr) {
   ELFOptTable Parser;
   opt::InputArgList Args = Parser.parse(ArgsArr.slice(1));
@@ -410,8 +427,10 @@
 }
   }
 
+  setDefaultTargetTriple(ArgsArr[0]);
   readConfigs(Args);
   checkZOptions(Args);
+  appendDefaultSearchPaths();
 
   // The behavior of -v or --version is a bit strange, but this is
   // needed for compatibility with GNU linkers.
@@ -746,6 +

[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman marked an inline comment as done.
arphaman added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:7292
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(Ctx)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&

erik.pilkington wrote:
> This should be `C` instead of `Ctx` right? Sorry, the naming here really 
> sucks.
right, I'll fix that.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56469/new/

https://reviews.llvm.org/D56469



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


[PATCH] D55964: [clang-format][TableGen] Don't add spaces around items in square braces.

2019-01-09 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht updated this revision to Diff 180882.
rupprecht added a comment.

Move TableGen language check to where SpacesInContainerLiterals is checked


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55964/new/

https://reviews.llvm.org/D55964

Files:
  lib/Format/TokenAnnotator.cpp
  unittests/Format/FormatTestTableGen.cpp


Index: unittests/Format/FormatTestTableGen.cpp
===
--- unittests/Format/FormatTestTableGen.cpp
+++ unittests/Format/FormatTestTableGen.cpp
@@ -52,5 +52,9 @@
"   \"very long help string\">;\n");
 }
 
+TEST_F(FormatTestTableGen, NoSpacesInSquareBracketLists) {
+  verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;\n");
+}
+
 } // namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2486,12 +2486,13 @@
 return false;
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {
-return Style.SpacesInContainerLiterals ||
-   ((Style.Language == FormatStyle::LK_Proto ||
- Style.Language == FormatStyle::LK_TextProto) &&
-!Style.Cpp11BracedListStyle &&
-LSquareTok.endsSequence(tok::l_square, tok::colon,
-TT_SelectorName));
+return Style.Language != FormatStyle::LK_TableGen &&
+   (Style.SpacesInContainerLiterals ||
+((Style.Language == FormatStyle::LK_Proto ||
+  Style.Language == FormatStyle::LK_TextProto) &&
+ !Style.Cpp11BracedListStyle &&
+ LSquareTok.endsSequence(tok::l_square, tok::colon,
+ TT_SelectorName)));
   };
   if (Left.is(tok::l_square))
 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) 
&&


Index: unittests/Format/FormatTestTableGen.cpp
===
--- unittests/Format/FormatTestTableGen.cpp
+++ unittests/Format/FormatTestTableGen.cpp
@@ -52,5 +52,9 @@
"   \"very long help string\">;\n");
 }
 
+TEST_F(FormatTestTableGen, NoSpacesInSquareBracketLists) {
+  verifyFormat("def flag : Flag<[\"-\", \"--\"], \"foo\">;\n");
+}
+
 } // namespace format
 } // end namespace clang
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2486,12 +2486,13 @@
 return false;
   const auto SpaceRequiredForArrayInitializerLSquare =
   [](const FormatToken &LSquareTok, const FormatStyle &Style) {
-return Style.SpacesInContainerLiterals ||
-   ((Style.Language == FormatStyle::LK_Proto ||
- Style.Language == FormatStyle::LK_TextProto) &&
-!Style.Cpp11BracedListStyle &&
-LSquareTok.endsSequence(tok::l_square, tok::colon,
-TT_SelectorName));
+return Style.Language != FormatStyle::LK_TableGen &&
+   (Style.SpacesInContainerLiterals ||
+((Style.Language == FormatStyle::LK_Proto ||
+  Style.Language == FormatStyle::LK_TextProto) &&
+ !Style.Cpp11BracedListStyle &&
+ LSquareTok.endsSequence(tok::l_square, tok::colon,
+ TT_SelectorName)));
   };
   if (Left.is(tok::l_square))
 return (Left.is(TT_ArrayInitializerLSquare) && Right.isNot(tok::r_square) &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D55964: [clang-format][TableGen] Don't add spaces around items in square braces.

2019-01-09 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

Right, but `getGoogleStyle()` has the inferred language passed in (i.e. 
`getGoogleStyle(FormatStyle::LanguageKind Language)`. Whereas `getLLVMStyle()` 
takes no args and assumes C++.
Would it be worthwhile to refactor getLLVMStyle to take in an optional language 
arg?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55964/new/

https://reviews.llvm.org/D55964



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


[PATCH] D55964: [clang-format][TableGen] Don't add spaces around items in square braces.

2019-01-09 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

Look at getGoogleStyle(). It has a bunch of language-specific configs at the 
bottom. You can do the same for TableGen in getLLVMStyle().


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55964/new/

https://reviews.llvm.org/D55964



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


[PATCH] D56504: [WebAssembly] Add unimplemented-simd128 feature, gate builtins

2019-01-09 Thread Thomas Lively via Phabricator via cfe-commits
tlively created this revision.
tlively added reviewers: aheejin, dschuff.
Herald added subscribers: cfe-commits, kristina, sunfish, jgravelle-google, 
sbc100.

Depends on D56501 . Also adds a macro define
__wasm_unimplemented_simd128__ for feature detection of unimplemented
SIMD builtins.


Repository:
  rC Clang

https://reviews.llvm.org/D56504

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/WebAssembly.cpp
  lib/Basic/Targets/WebAssembly.h
  test/CodeGen/builtins-wasm.c

Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -1,9 +1,5 @@
-// RUN: %clang_cc1 -triple wasm32-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
-// RUN: %clang_cc1 -triple wasm64-unknown-unknown -fno-lax-vector-conversions \
-// RUN:   -O3 -emit-llvm -o - %s \
-// RUN:   | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
+// RUN: %clang_cc1 -triple wasm32-unknown-unknown -target-feature +unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY32
+// RUN: %clang_cc1 -triple wasm64-unknown-unknown -target-feature +unimplemented-simd128 -target-feature +nontrapping-fptoint -target-feature +exception-handling -fno-lax-vector-conversions -O3 -emit-llvm -o - %s | FileCheck %s -check-prefixes WEBASSEMBLY,WEBASSEMBLY64
 
 // SIMD convenience types
 typedef char i8x16 __attribute((vector_size(16)));
Index: lib/Basic/Targets/WebAssembly.h
===
--- lib/Basic/Targets/WebAssembly.h
+++ lib/Basic/Targets/WebAssembly.h
@@ -28,7 +28,8 @@
   enum SIMDEnum {
 NoSIMD,
 SIMD128,
-  } SIMDLevel;
+UnimplementedSIMD128,
+  } SIMDLevel = NoSIMD;
 
   bool HasNontrappingFPToInt;
   bool HasSignExt;
@@ -59,18 +60,12 @@
 MacroBuilder &Builder) const override;
 
 private:
+  static void setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level);
+
   bool
   initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
  StringRef CPU,
- const std::vector &FeaturesVec) const override {
-if (CPU == "bleeding-edge") {
-  Features["simd128"] = true;
-  Features["nontrapping-fptoint"] = true;
-  Features["sign-ext"] = true;
-}
-return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
-  }
-
+ const std::vector &FeaturesVec) const override;
   bool hasFeature(StringRef Feature) const final;
 
   bool handleTargetFeatures(std::vector &Features,
Index: lib/Basic/Targets/WebAssembly.cpp
===
--- lib/Basic/Targets/WebAssembly.cpp
+++ lib/Basic/Targets/WebAssembly.cpp
@@ -24,6 +24,8 @@
 const Builtin::Info WebAssemblyTargetInfo::BuiltinInfo[] = {
 #define BUILTIN(ID, TYPE, ATTRS)   \
   {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, nullptr},
+#define TARGET_BUILTIN(ID, TYPE, ATTRS, FEATURE)   \
+  {#ID, TYPE, ATTRS, nullptr, ALL_LANGUAGES, FEATURE},
 #define LIBBUILTIN(ID, TYPE, ATTRS, HEADER)\
   {#ID, TYPE, ATTRS, HEADER, ALL_LANGUAGES, nullptr},
 #include "clang/Basic/BuiltinsWebAssembly.def"
@@ -35,6 +37,7 @@
 bool WebAssemblyTargetInfo::hasFeature(StringRef Feature) const {
   return llvm::StringSwitch(Feature)
   .Case("simd128", SIMDLevel >= SIMD128)
+  .Case("unimplemented-simd128", SIMDLevel >= UnimplementedSIMD128)
   .Case("nontrapping-fptoint", HasNontrappingFPToInt)
   .Case("sign-ext", HasSignExt)
   .Case("exception-handling", HasExceptionHandling)
@@ -55,8 +58,47 @@
   defineCPUMacros(Builder, "wasm", /*Tuning=*/false);
   if (SIMDLevel >= SIMD128)
 Builder.defineMacro("__wasm_simd128__");
+  if (SIMDLevel >= UnimplementedSIMD128)
+Builder.defineMacro("__wasm_unimplemented_simd128__");
 }
 
+void WebAssemblyTargetInfo::setSIMDLevel(llvm::StringMap &Features, SIMDEnum Level) {
+  switch (Level) {
+  case UnimplementedSIMD128:
+Features["unimplemented-simd128"] = true;
+LLVM_FALLTHROUGH;
+  case SIMD128:
+Features["simd128"] = true;
+Features["sign-ext"] = true;
+LLVM_FALLTHROUGH;
+  case NoSIMD:
+break;
+  }
+}
+
+bool WebAssemblyTargetInfo::initFeatureMap(llvm::StringMap &Features, DiagnosticsEngine &Diags,
+ StringRef CPU,
+ const std::vector &FeaturesVec) const {
+if (CPU == "bleeding-edge") {
+  Features["nontrapping-fptoint"] = true;
+  Features["sign-ext"] = true;
+  setSIMDLevel(Features, SIMD128);
+}
+// Other targets do not consider use

[PATCH] D56469: [ObjC] Allow the use of implemented unavailable methods from within the @implementation context

2019-01-09 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:7290
+  // when it's actually defined and is referenced from within the
+  // @implementation itself.
+  if (const auto *MD = dyn_cast(OffendingDecl)) {

Maybe add a sentence: In this context, we interpret unavailable as a form of 
access control.



Comment at: lib/Sema/SemaDeclAttr.cpp:7292
+  if (const auto *MD = dyn_cast(OffendingDecl)) {
+if (const auto *Impl = dyn_cast(Ctx)) {
+  if (MD->getClassInterface() == Impl->getClassInterface() &&

This should be `C` instead of `Ctx` right? Sorry, the naming here really sucks.



Comment at: test/SemaObjC/call-unavailable-init-in-self.m:57
+  (void)[Sub new]; // expected-error {{'new' is unavailable}}
+}

Can you add a test for category implementations:
```
@interface X @end

@interface X (Foo) 
-(void)meth __attribute__((unavailable))
@end

@implementation X (Foo)
-(void)meth {}
-(void)call_it { [self meth]; }
@end
```


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D56469/new/

https://reviews.llvm.org/D56469



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


[PATCH] D56066: [OpenCL] Address space for default class members

2019-01-09 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: lib/Sema/SemaInit.cpp:4539
+  if (InitCategory.isPRValue() || InitCategory.isXValue())
+T1Quals.removeAddressSpace();
+

rjmccall wrote:
> ebevhan wrote:
> > rjmccall wrote:
> > > rjmccall wrote:
> > > > I can understand why a pr-value wouldn't have an address space, but an 
> > > > x-value's address space is surely important.
> > > No, wait, I think this is more deeply wrong.  We're initializing a 
> > > reference to type `cv1 T1`, and if we're initializing it with a 
> > > temporary, we're dropping the address space from `cv1`?  That's 
> > > definitely wrong.
> > > 
> > > If we're starting with a pr-value, reference-initialization normally has 
> > > to start by initializing a temporary.  (The exception is it's a class 
> > > type with a conversion operator to a reference type; C++ is abysmally 
> > > complicated.  Let's ignore this for a moment.)  Temporaries are always in 
> > > the default address space (the address space of local variables) because 
> > > the language (neither OpenCL nor Embedded C) does not give us any 
> > > facility for allocating temporary memory anywhere else.  So 
> > > reference-initialization from a pr-value creates a temporary in the 
> > > default address space and then attempts to initialize the destination 
> > > reference type with that temporary.  That initialization should fail if 
> > > there's no conversion from the default address space to the destination 
> > > address space.  For example, consider initializing a `const int __global 
> > > &` from a pr-value: this should clearly not succeed, because we have no 
> > > way of putting a temporary in the global address space.  That reference 
> > > can only be initialized with a gl-value that's already in the `__global` 
> > > address space.
> > > 
> > > On the other hand, we can successfully initialize a `const int &` with a 
> > > gl-value of type `const int __global` not by direct reference 
> > > initialization but by loading from the operand and then materializing the 
> > > result into a new temporary.
> > > 
> > > I think what this means is:
> > > 
> > > - We need to be doing this checking as if pr-values were in `__private`.  
> > > This includes both (1) expressions that were originally pr-values and (2) 
> > > expressions that have been converted to pr-values due to a failure to 
> > > perform direct reference initialization.
> > > 
> > > - We need to make sure that reference compatibility correctly prevents 
> > > references from being bound to gl-values in incompatible address spaces.
> > > On the other hand, we can successfully initialize a `const int &` with a 
> > > gl-value of type `const int __global` not by direct reference 
> > > initialization but by loading from the operand and then materializing the 
> > > result into a new temporary.
> > 
> > Is this the right thing to do? It means that initializing such a reference 
> > would incur a cost under the hood that might be unnoticed/unwanted by the 
> > user. 
> Hmm.  I was going to say that it's consistent with the normal behavior of 
> C++, but looking at the actual rule, it's more complicated than that: C++ 
> will only do this if the types are not reference-related or if the gl-value 
> is a bit-field.  So this would only be allowed if the reference type was e.g. 
> `const long &`.  It's a strange rule, but it's straightforward to stay 
> consistent with it.
> 
> I think we will eventually find ourselves needing a special-case rule for 
> copy-initializing and copy-assigning trivially-copyable types, but we're not 
> there yet.
I need some help to understand what's the right way to fix this problem.

As far as I gathered from this particular example. The issues is caused by the 
following statement of **addrspace-of-this.cl** line 47:
  C c3 = c1 + c2;

If I remove this new `if` statement in **SemaInit.cpp** and disable some 
asserts about the incorrect address space cast the AST that Clang is trying to 
create is as follows:


```
| | |-DeclStmt 0x9d6e70 
| | | `-VarDecl 0x9d6b28  col:5 c3 'C' cinit
| | |   `-ExprWithCleanups 0x9d6e58  'C'
| | | `-CXXConstructExpr 0x9d6e20  'C' 'void (__generic C 
&&) __generic' elidable
| | |   `-MaterializeTemporaryExpr 0x9d6e08  '__generic C' 
xvalue
| | | `-ImplicitCastExpr 0x9d6df0  '__generic C' 

| | |   `-CXXOperatorCallExpr 0x9d6c90  'C'
| | | |-ImplicitCastExpr 0x9d6c78  'C (*)(const __generic C 
&) __generic' 
| | | | `-DeclRefExpr 0x9d6bf8  'C (const __generic C &) 
__generic' lvalue CXXMethod 0x9d4da0 'operator+' 'C (const __generic C &) 
__generic'
| | | |-ImplicitCastExpr 0x9d6be0  '__generic C' lvalue 

| | | | `-DeclRefExpr 0x9d6b88  'C' lvalue Var 0x9d6830 
'c1' 'C'
| | | `-ImplicitCastExpr 0x9d6bc8  'const __generic C' 
lvalue 
| | |   `-DeclRefExpr 0x9d6ba8  'C' lvalue Var

[PATCH] D55964: [clang-format][TableGen] Don't add spaces around items in square braces.

2019-01-09 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

In D55964#1351348 , @djasper wrote:

> This seem to conceptually be a list of things rather than an array subscript, 
> though, right?  Could we alternatively set SpacesInContainerLiterals to false 
> for LK_TableGen?


That seems to work, e.g. if I manually set the option in the test, but I can't 
seem to find a way to set a per-language default. `getLLVMStyle()`, which seems 
to be the default that every style is rooted from, assumes C++ (and does not 
have the language provided). Is there a good way to workaround that?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55964/new/

https://reviews.llvm.org/D55964



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


[PATCH] D55964: [clang-format][TableGen] Don't add spaces around items in square braces.

2019-01-09 Thread Daniel Jasper via Phabricator via cfe-commits
djasper added a comment.

This seem to conceptually be a list of things rather than an array subscript, 
though, right?  Could we alternatively set SpacesInContainerLiterals to false 
for LK_TableGen?


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55964/new/

https://reviews.llvm.org/D55964



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/index/Background.cpp:259
+  // if this thread sees the older version but finishes later. This should
+  // be rare in practice.
+  DigestIt.first->second = Hash;

ilya-biryukov wrote:
> kadircet wrote:
> > ilya-biryukov wrote:
> > > kadircet wrote:
> > > > ilya-biryukov wrote:
> > > > > kadircet wrote:
> > > > > > ilya-biryukov wrote:
> > > > > > > > "should be rare in practice"
> > > > > > > And yet, can we avoid this altogether?
> > > > > > > 
> > > > > > > Also, I believe it won't be rare. When processing multiple 
> > > > > > > different TUs, we can easily run into the same header multiple 
> > > > > > > times, possibly with the different contents.
> > > > > > > E.g. imagine the index for the whole of clang is being built and 
> > > > > > > the user is editing `Sema.h` at the same time. We'll definitely 
> > > > > > > be running into this case over and over again.
> > > > > > Well I am open to ideas, but currently there is no way of knowing 
> > > > > > whether this is the newer version for the file. Because only 
> > > > > > information we have is the digest is different than what we 
> > > > > > currently have and this doesn't yield any chronological information.
> > > > > Do we know which request is "newer" when scheduling it?
> > > > > If so, we could keep the map of the **latest** hashes of the files 
> > > > > we've seen (in addition to the `IndexedFileDigests`, which correspond 
> > > > > to the digest for which we built the index IIUC).
> > > > > 
> > > > > This would give us a simple invariant of the final state we want to 
> > > > > bring the index to: `IndexedFileDigests` should correspond to the 
> > > > > latest hashes seen so far. If not, we have to rebuild the index for 
> > > > > the corresponding files. That, in turn, gives us a way to resolve 
> > > > > conflicts: we should never replace with symbols built for the latest 
> > > > > version (hash) of the file we've seen.
> > > > > 
> > > > > Would that work?
> > > > I am not sure if it would work for non-main files. We update the Hash 
> > > > for the main files at each indexing action, so we can safely keep track 
> > > > of the latest versions. But we collect hashes for dependencies while 
> > > > performing the indexing which happens in parallel. Therefore an 
> > > > indexing action triggered earlier might get an up-to-date version of a 
> > > > dependency than an action triggered later-on.
> > > If updates for each TU are atomic (i.e. all files included in the TU are 
> > > updated in a single go) we would get the up-to-date index eventually, 
> > > assuming we rebuild the index when TU dependencies change (we don't 
> > > schedule rebuilds on changes to included header now, but we're planning 
> > > to do so at some point).
> > Sure, that assumption seems more relaxed than the previous one, just wanna 
> > make sure I got it right:
> > Your suggested solution assumes: Dependencies of a TU won't change during 
> > indexing of that TU
> > Whereas the previous assumption was: Files won't change between close 
> > indexing actions
> Exactly. The idea is that eventually we'll start tracking changes and will be 
> able to detect even those cases and rebuild the index accordingly. Just 
> trying to keep us from drifting away from that model too much.
> 
> > files won't change between close indexing actions
> This assumption worked fine for indexing actions running right away, but I 
> think the situation with loading shards is different: the shards we are 
> loading might be old and if we don't want a stale shard (which might be 
> arbitrarily old) to overwrite results of the fresh indexing action. Let me 
> know if I'm missing something here.
Nope, your point seems to be correct



Comment at: clangd/index/Background.cpp:312
+  // Skip if file is already up to date.
+  auto DigestIt = IndexedFileDigests.try_emplace(Path);
+  if (!DigestIt.second && DigestIt.first->second == Hash)

ilya-biryukov wrote:
> We still update digests and symbols non-atomically in that case. Could we do 
> both under the same lock, similar to how it's done in `loadShards`?
Moved update to the end of the loop, but now we might perform unnecessary work 
for building {symbol,ref}slabs for files that are already up-to-date. It 
shouldn't be too much of an issue, as a solution we can lock at the entrance 
and only check if the file was up-to-date, than we update at the exit. Or we 
can keep a snapshot.


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55224/new/

https://reviews.llvm.org/D55224



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


[PATCH] D55224: [clangd] Introduce loading of shards within auto-index

2019-01-09 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 180859.
kadircet marked 12 inline comments as done.
kadircet added a comment.

Address comments


Repository:
  rCTE Clang Tools Extra

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55224/new/

https://reviews.llvm.org/D55224

Files:
  clangd/URI.cpp
  clangd/URI.h
  clangd/index/Background.cpp
  clangd/index/Background.h
  clangd/index/SymbolCollector.cpp
  test/clangd/background-index.test
  unittests/clangd/BackgroundIndexTests.cpp

Index: unittests/clangd/BackgroundIndexTests.cpp
===
--- unittests/clangd/BackgroundIndexTests.cpp
+++ unittests/clangd/BackgroundIndexTests.cpp
@@ -9,6 +9,7 @@
 
 using testing::_;
 using testing::AllOf;
+using testing::Contains;
 using testing::ElementsAre;
 using testing::Not;
 using testing::UnorderedElementsAre;
@@ -146,7 +147,7 @@
FileURI("unittest:///root/B.cc")}));
 }
 
-TEST_F(BackgroundIndexTest, ShardStorageWriteTest) {
+TEST_F(BackgroundIndexTest, ShardStorageTest) {
   MockFSProvider FS;
   FS.Files[testPath("root/A.h")] = R"cpp(
   void common();
@@ -175,6 +176,16 @@
   EXPECT_EQ(CacheHits, 0U);
   EXPECT_EQ(Storage.size(), 2U);
 
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+  EXPECT_EQ(Storage.size(), 2U);
+
   auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
   EXPECT_NE(ShardHeader, nullptr);
   EXPECT_THAT(
@@ -278,5 +289,73 @@
   EXPECT_THAT(runFuzzyFind(Idx, ""), ElementsAre(Named("Y")));
 }
 
+TEST_F(BackgroundIndexTest, ShardStorageLoad) {
+  MockFSProvider FS;
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  )cpp";
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }";
+
+  llvm::StringMap Storage;
+  size_t CacheHits = 0;
+  MemoryShardStorage MSS(Storage, CacheHits);
+
+  tooling::CompileCommand Cmd;
+  Cmd.Filename = testPath("root/A.cc");
+  Cmd.Directory = testPath("root");
+  Cmd.CommandLine = {"clang++", testPath("root/A.cc")};
+  // Check nothing is loaded from Storage, but A.cc and A.h has been stored.
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root/A.cc"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+
+  // Change header.
+  FS.Files[testPath("root/A.h")] = R"cpp(
+  void common();
+  void f_b();
+  class A_CC {};
+  class A_CCnew {};
+  )cpp";
+  {
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardHeader = MSS.loadShard(testPath("root/A.h"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardHeader->Symbols, Contains(Named("A_CCnew")));
+
+  // Change source.
+  FS.Files[testPath("root/A.cc")] =
+  "#include \"A.h\"\nvoid g() { (void)common; }\nvoid f_b() {}";
+  {
+CacheHits = 0;
+OverlayCDB CDB(/*Base=*/nullptr);
+BackgroundIndex Idx(Context::empty(), "", FS, CDB,
+[&](llvm::StringRef) { return &MSS; });
+CDB.setCompileCommand(testPath("root"), Cmd);
+ASSERT_TRUE(Idx.blockUntilIdleForTest());
+  }
+  EXPECT_EQ(CacheHits, 2U); // Check both A.cc and A.h loaded from cache.
+
+  // Check if the new symbol has arrived.
+  auto ShardSource = MSS.loadShard(testPath("root/A.cc"));
+  EXPECT_NE(ShardHeader, nullptr);
+  EXPECT_THAT(*ShardSource->Symbols,
+  Contains(AllOf(Named("f_b"), Declared(), Defined(;
+}
+
 } // namespace clangd
 } // namespace clang
Index: test/clangd/background-index.test
===
--- test/clangd/background-index.test
+++ test/clangd/background-index.test
@@ -16,6 +16,5 @@
 # RUN: ls %t/.clangd-index/foo.cpp.*.idx
 
 # Test the index is read from disk: delete code and restart clangd.
-# FIXME: This test currently fails as we don't read the index yet.
 # RUN: rm %t/foo.cpp
-# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | not FileCheck %t/definition.jsonrpc
+# RUN: clangd -background-index -lit-test < %t/definition.jsonrpc | FileCheck %t/definition.jsonrpc
Index: clangd/index/SymbolCollector.cpp
===
--- clangd/index/SymbolCollector.cpp
+++ clangd/inde

[PATCH] D55964: [clang-format][TableGen] Don't add spaces around items in square braces.

2019-01-09 Thread Jordan Rupprecht via Phabricator via cfe-commits
rupprecht added a comment.

Post-holiday ping


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55964/new/

https://reviews.llvm.org/D55964



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


[PATCH] D51641: [VFS] Cache the current working directory for the real FS.

2019-01-09 Thread Pavel Labath via Phabricator via cfe-commits
labath added a comment.

I wholeheartedly support an openat(2) based VFS, as the current one falls short 
of the expectations you have of it and is pretty broken right now.

As for your assumption #2, I think that depends on what does one want to get 
out of the VFS. I can certainly see a use for having a  thread-local 
(VFS-local) CWD. In fact I remember seeing some code in LLDB, which used some 
darwin-only interface to create a real thread-local CWD in one function. 
However, I can also see a use for a VFS which is so "real" that it shares the 
notion of the CWD with the OS. What could happen in lldb is that a user sets 
the CWD in python (using the proper python api), and then passes a relative 
path to (lib)lldb. Since lldb never advertised to have any notion of a 
"lldb-local" CWD, the user would (righfully) expect that that path is resolved 
relative to the CWD he has just set. And that's what happened until we started 
using VFS. In fact, it still happens now, because the VFS is so bad at having a 
local CWD. So, the only reason we actually discovered this was because  
VFS->getCurrentWorkingDirectory returned an empty string if a it's CWD has 
never been set. This later translated to a null pointer and a crash.

So it almost sounds to me like we should have two implementations of the VFS. A 
"real" one, which shared the CWD with the OS, and an "almost real" one, which 
has a local CWD. Another position would be to just say that lldb was wrong to 
use the VFS in the first place, as it does not promise we want (and it should 
use a different abstraction instead). That view would be supported by the fact 
that there are other interface disconnects relating to the use of VFS in lldb 
(FILE* and friends). However, that's something you and Jonas will have to 
figure out (I'm just the peanut gallery here :P).


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D51641/new/

https://reviews.llvm.org/D51641



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


  1   2   >