[PATCH] D41558: [x86][icelake][vnni]

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

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D41558



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


[PATCH] D41248: [libcxx] Suppress unused warning on apple.

2017-12-24 Thread Don Hinton via Phabricator via cfe-commits
hintonda added a comment.

ping...


Repository:
  rCXX libc++

https://reviews.llvm.org/D41248



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


[PATCH] D41562: [CodeGen] Generate TBAA info on passing arguments and returning values

2017-12-24 Thread Ivan Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added reviewers: rjmccall, hfinkel.
kosarev added a project: clang.

We only do this for the new format as the old format does not allow to 
represent accesses to aggregates. This patch significantly improves TBAA 
coverage on -O1 builds.


Repository:
  rL LLVM

https://reviews.llvm.org/D41562

Files:
  lib/CodeGen/CGCall.cpp
  test/CodeGen/tbaa-call.cpp

Index: test/CodeGen/tbaa-call.cpp
===
--- test/CodeGen/tbaa-call.cpp
+++ test/CodeGen/tbaa-call.cpp
@@ -0,0 +1,110 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -O1 -disable-llvm-passes \
+// RUN: -new-struct-path-tbaa %s -emit-llvm -o - | FileCheck %s
+//
+// Check that we generate correct TBAA information for instructions that pass
+// function arguments and returning values.
+
+struct A { int : 0; };
+struct B { double d; };
+struct C { A a; B b; };
+struct D { int i; };
+struct E { double d; int i; };
+struct F { float _Complex c; int x; };
+struct G { E e; };
+
+B get_B();
+C get_C();
+D get_D();
+E get_E();
+F get_F();
+
+void set_E(E);
+
+C f1() {
+// CHECK-LABEL: _Z2f1v
+// CHECK: load double, {{.*}}, !tbaa [[TAG_C:!.*]]
+  return C();
+}
+
+D f2() {
+// CHECK-LABEL: _Z2f2v
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_D:!.*]]
+  return D();
+}
+
+E f3() {
+// CHECK-LABEL: _Z2f3v
+// CHECK: load { double, i32 }, {{.*}}, !tbaa [[TAG_E:!.*]]
+  return E();
+}
+
+E f4() {
+// CHECK-LABEL: _Z2f4v
+// CHECK: call { double, i32 } @_Z5get_Ev()
+// CHECK-DAG: store double {{.*}}, !tbaa [[TAG_E]]
+// CHECK-DAG: store i32 {{.*}}, !tbaa [[TAG_E]]
+// CHECK: load { double, i32 }, {{.*}}, !tbaa [[TAG_E]]
+  return get_E();
+}
+
+B f5() {
+// CHECK-LABEL: _Z2f5v
+// CHECK: call double @_Z5get_Bv()
+// CHECK: store double {{.*}}, !tbaa [[TAG_B:!.*]]
+// CHECK: load double, {{.*}}, !tbaa [[TAG_B]]
+  return get_B();
+}
+
+C f6() {
+// CHECK-LABEL: _Z2f6v
+// CHECK: call double @_Z5get_Cv()
+// CHECK: store double {{.*}}, !tbaa [[TAG_C]]
+// CHECK: load double, {{.*}}, !tbaa [[TAG_C]]
+  return get_C();
+}
+
+D f7() {
+// CHECK-LABEL: _Z2f7v
+// CHECK: call i32 @_Z5get_Dv()
+// CHECK: store i32 {{.*}}, !tbaa [[TAG_D]]
+// CHECK: load i32, {{.*}}, !tbaa [[TAG_D]]
+  return get_D();
+}
+
+F f8() {
+// CHECK-LABEL: _Z2f8v
+// CHECK: call { <2 x float>, i32 } @_Z5get_Fv()
+// CHECK: store { <2 x float>, i32 } {{.*}}, !tbaa [[TAG_F:!.*]]
+// CHECK: load { <2 x float>, i32 }, {{.*}}, !tbaa [[TAG_F]]
+  return get_F();
+}
+
+G f9(G g) {
+// CHECK-LABEL: _Z2f91G
+// CHECK-DAG: store double {{.*}}, !tbaa [[TAG_G:!.*]]
+// CHECK-DAG: store i32 {{.*}}, !tbaa [[TAG_G]]
+// CHECK: load { double, i32 }, {{.*}}, !tbaa [[TAG_G]]
+  return g;
+}
+
+void f10() {
+// CHECK-LABEL: _Z3f10v
+// CHECK-DAG: load double, {{.*}}, !tbaa [[TAG_E]]
+// CHECK-DAG: load i32, {{.*}}, !tbaa [[TAG_E]]
+// CHECK: call void @_Z5set_E1E
+  E e;
+  set_E(e);
+}
+
+// CHECK-DAG: [[TYPE_B:!.*]] = !{{{.*}}, !"_ZTS1B", {{.*}}}
+// CHECK-DAG: [[TAG_B]] = !{[[TYPE_B]], [[TYPE_B]], {{.*}}}
+// CHECK-DAG: [[TYPE_C:!.*]] = !{{{.*}}, !"_ZTS1C", {{.*}}}
+// CHECK-DAG: [[TAG_C]] = !{[[TYPE_C]], [[TYPE_C]], {{.*}}}
+// CHECK-DAG: [[TYPE_D:!.*]] = !{{{.*}}, !"_ZTS1D", {{.*}}}
+// CHECK-DAG: [[TAG_D]] = !{[[TYPE_D]], [[TYPE_D]], {{.*}}}
+// CHECK-DAG: [[TYPE_E:!.*]] = !{{{.*}}, !"_ZTS1E", {{.*}}}
+// CHECK-DAG: [[TAG_E]] = !{[[TYPE_E]], [[TYPE_E]], {{.*}}}
+// CHECK-DAG: [[TYPE_F:!.*]] = !{{{.*}}, !"_ZTS1F", {{.*}}}
+// CHECK-DAG: [[TAG_F]] = !{[[TYPE_F]], [[TYPE_F]], {{.*}}}
+// CHECK-DAG: [[TYPE_G:!.*]] = !{{{.*}}, !"_ZTS1G", {{.*}}}
+// CHECK-DAG: [[TAG_G]] = !{[[TYPE_G]], [[TYPE_G]], {{.*}}}
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1195,12 +1195,16 @@
 /// destination type; in this situation the values of bits which not
 /// present in the src are undefined.
 static llvm::Value *CreateCoercedLoad(Address Src, llvm::Type *Ty,
+  TBAAAccessInfo TBAAInfo,
   CodeGenFunction &CGF) {
   llvm::Type *SrcTy = Src.getElementType();
 
   // If SrcTy and Ty are the same, just do a load.
-  if (SrcTy == Ty)
-return CGF.Builder.CreateLoad(Src);
+  if (SrcTy == Ty) {
+auto *Load = CGF.Builder.CreateLoad(Src);
+CGF.CGM.DecorateInstructionWithTBAA(Load, TBAAInfo);
+return Load;
+  }
 
   uint64_t DstSize = CGF.CGM.getDataLayout().getTypeAllocSize(Ty);
 
@@ -1215,7 +1219,8 @@
   // extension or truncation to the desired type.
   if ((isa(Ty) || isa(Ty)) &&
   (isa(SrcTy) || isa(SrcTy))) {
-llvm::Value *Load = CGF.Builder.CreateLoad(Src);
+auto *Load = CGF.Builder.CreateLoad(Src);
+CGF.CGM.DecorateInstructionWithTBAA(Load, TBAAInfo);
 return CoerceIntOrPtrToIntOrPtr(Load, Ty, CGF);
   }
 
@@ -1229,7 +1234,9 @@
 // to that information.
 Src = CGF.Builder.CreateBitCast(Src,
 

r321425 - Make helpers static. No functionality change.

2017-12-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Dec 24 04:46:22 2017
New Revision: 321425

URL: http://llvm.org/viewvc/llvm-project?rev=321425&view=rev
Log:
Make helpers static. No functionality change.

Modified:
cfe/trunk/lib/AST/ASTContext.cpp

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=321425&r1=321424&r2=321425&view=diff
==
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Sun Dec 24 04:46:22 2017
@@ -2148,7 +2148,7 @@ static bool unionHasUniqueObjectRepresen
   return true;
 }
 
-bool isStructEmpty(QualType Ty) {
+static bool isStructEmpty(QualType Ty) {
   const RecordDecl *RD = Ty->castAs()->getDecl();
 
   if (!RD->field_empty())


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


Re: r321386 - [OPENMP] Captured arguments of the capturable clauses by value.

2017-12-24 Thread Alexey Bataev via cfe-commits
Sure, thanks for the report. 

Best regards,
Alexey Bataev

24 дек. 2017 г., в 8:27, Maxim Kuvyrkov  написал(а):

>> On Dec 23, 2017, at 12:01 AM, Alexey Bataev via cfe-commits 
>>  wrote:
>> 
>> Author: abataev
>> Date: Fri Dec 22 13:01:52 2017
>> New Revision: 321386
>> 
>> URL: 
>> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%3Frev%3D321386%26view%3Drev&data=02%7C01%7C%7C4bbee209c7424ec17ef908d54ad20f6c%7C84df9e7fe9f640afb435%7C1%7C0%7C636497188414868889&sdata=4uGGwkVO9vEMdod3ZJ2c9QrzPC2GZXRkOweo2jBkNvM%3D&reserved=0
>> Log:
>> [OPENMP] Captured arguments of the capturable clauses by value.
>> 
>> If the clause is applied to the combined construct and has captured
>> expression, try to capture this expression by value rather than by
>> reference.
>> 
>> Modified:
>>   cfe/trunk/lib/Sema/SemaOpenMP.cpp
>>   cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
>>   cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
>>   
>> cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
> 
> Hi Alexey,
> 
> Changes to the teams_distribute_parallel_* tests break 32-bit ARM buildbots, 
> e.g., 
> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Flab.llvm.org%3A8011%2Fbuilders%2Fclang-cmake-armv7-a15%2Fbuilds%2F14264&data=02%7C01%7C%7C4bbee209c7424ec17ef908d54ad20f6c%7C84df9e7fe9f640afb435%7C1%7C0%7C636497188414868889&sdata=vp2zxOQa%2B0t7WeKV4255eNXy9A3jewY2SlBMT0OGN18%3D&reserved=0
>  .  Would you please investigate?
> 
> Thanks,
> 
> --
> Maxim Kuvyrkov
> https://nam04.safelinks.protection.outlook.com/?url=www.linaro.org&data=02%7C01%7C%7C4bbee209c7424ec17ef908d54ad20f6c%7C84df9e7fe9f640afb435%7C1%7C0%7C636497188414868889&sdata=DzCf1pJo44ETXnttUW322oN40IwtK%2FNrxveBtOtAfT0%3D&reserved=0
> 
> 
>> 
>> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
>> URL: 
>> https://nam04.safelinks.protection.outlook.com/?url=http%3A%2F%2Fllvm.org%2Fviewvc%2Fllvm-project%2Fcfe%2Ftrunk%2Flib%2FSema%2FSemaOpenMP.cpp%3Frev%3D321386%26r1%3D321385%26r2%3D321386%26view%3Ddiff&data=02%7C01%7C%7C4bbee209c7424ec17ef908d54ad20f6c%7C84df9e7fe9f640afb435%7C1%7C0%7C636497188414868889&sdata=omvXI%2Fct%2B%2BsGN2SZxlfd33cCISW6RIMa2wF7BK1Q%2FEY%3D&reserved=0
>> ==
>> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Dec 22 13:01:52 2017
>> @@ -1290,9 +1290,14 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe
>>  }
>> 
>>  if (IsByRef && Ty.getNonReferenceType()->isScalarType()) {
>> -IsByRef = !DSAStack->hasExplicitDSA(
>> -D, [](OpenMPClauseKind K) -> bool { return K == OMPC_firstprivate; 
>> },
>> -Level, /*NotLastprivate=*/true);
>> +IsByRef =
>> +!DSAStack->hasExplicitDSA(
>> +D,
>> +[](OpenMPClauseKind K) -> bool { return K == OMPC_firstprivate; 
>> },
>> +Level, /*NotLastprivate=*/true) &&
>> +// If the variable is artificial and must be captured by value - 
>> try to
>> +// capture by value.
>> +!(isa(D) && D->hasAttr());
>>  }
>> 
>>  // When passing data by copy, we need to make sure it fits the uintptr size
>> @@ -2321,10 +2326,11 @@ static OMPCapturedExprDecl *buildCapture
>>  ASTContext &C = S.getASTContext();
>>  Expr *Init = AsExpression ? CaptureExpr : CaptureExpr->IgnoreImpCasts();
>>  QualType Ty = Init->getType();
>> +  Attr *OMPCaptureKind = nullptr;
>>  if (CaptureExpr->getObjectKind() == OK_Ordinary && 
>> CaptureExpr->isGLValue()) {
>> -if (S.getLangOpts().CPlusPlus)
>> +if (S.getLangOpts().CPlusPlus) {
>>  Ty = C.getLValueReferenceType(Ty);
>> -else {
>> +} else {
>>  Ty = C.getPointerType(Ty);
>>  ExprResult Res =
>>  S.CreateBuiltinUnaryOp(CaptureExpr->getExprLoc(), UO_AddrOf, Init);
>> @@ -2333,11 +2339,16 @@ static OMPCapturedExprDecl *buildCapture
>>  Init = Res.get();
>>}
>>WithInit = true;
>> +  } else if (AsExpression) {
>> +// This variable must be captured by value.
>> +OMPCaptureKind = OMPCaptureKindAttr::CreateImplicit(C, OMPC_unknown);
>>  }
>>  auto *CED = OMPCapturedExprDecl::Create(C, S.CurContext, Id, Ty,
>>  CaptureExpr->getLocStart());
>>  if (!WithInit)
>>CED->addAttr(OMPCaptureNoInitAttr::CreateImplicit(C, SourceRange()));
>> +  if (OMPCaptureKind)
>> +CED->addAttr(OMPCaptureKind);
>>  S.CurContext->addHiddenDecl(CED);
>>  S.AddInitializerToDecl(CED, Init, /*DirectInit=*/false);
>>  return CED;
>> @@ -2346,31 +2357,34 @@ static OMPCapturedExprDecl *buildCapture
>> static DeclRefExpr *buildCapture(Sema &S, ValueDecl *D, Expr *CaptureExpr,
>> bool WithInit) {
>>  OMPCapturedExprDecl *CD;
>> -  if (auto *VD = S.IsOpenMPCapturedDecl(D))
>> +  if (auto *VD = S.IsOpenMPCapturedDecl(D)) {
>>CD = cast(VD);
>> -  else
>>

r321427 - [OPENMP] Fix the tests for 32bits targets, NFC.

2017-12-24 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Sun Dec 24 06:18:33 2017
New Revision: 321427

URL: http://llvm.org/viewvc/llvm-project?rev=321427&view=rev
Log:
[OPENMP] Fix the tests for 32bits targets, NFC.

Modified:
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp

cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp?rev=321427&r1=321426&r2=321427&view=diff
==
--- cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp 
(original)
+++ cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp 
Sun Dec 24 06:18:33 2017
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-ibm-linux-gnu -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER

Modified: 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp?rev=321427&r1=321426&r2=321427&view=diff
==
--- 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
 (original)
+++ 
cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp
 Sun Dec 24 06:18:33 2017
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-emit-llvm %s -fexceptions -fcxx-exceptions -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
%itanium_abi_triple -fexceptions -fcxx-exceptions -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple %itanium_abi_triple 
-fexceptions -fcxx-exceptions -std=c++11 -include-pch %t -verify %s -emit-llvm 
-o - | FileCheck %s
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-ibm-linux-gnu -emit-llvm %s -fexceptions -fcxx-exceptions -o - | 
FileCheck %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple 
powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-version=45 
-fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple 
powerpc64le-ibm-linux-gnu -fexceptions -fcxx-exceptions -std=c++11 -include-pch 
%t -verify %s -emit-llvm -o - | FileCheck %s
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER


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


[PATCH] D41564: [x86][icelake][bitalg]

2017-12-24 Thread coby via Phabricator via cfe-commits
coby created this revision.
coby added a reviewer: craig.topper.
Herald added a subscriber: mgorny.

added intrinsics support for bitalg instructions, matching a similar work on 
the backend (https://reviews.llvm.org/D40222)


Repository:
  rC Clang

https://reviews.llvm.org/D41564

Files:
  include/clang/Basic/BuiltinsX86.def
  include/clang/Driver/Options.td
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/avx512bitalgintrin.h
  lib/Headers/avx512vlbitalgintrin.h
  lib/Headers/immintrin.h
  test/CodeGen/attr-target-x86.c
  test/CodeGen/avx512bitalg-builtins.c
  test/CodeGen/avx512vlbitalg-builtins.c
  test/Driver/x86-target-features.c
  test/Preprocessor/predefined-arch-macros.c
  test/Preprocessor/x86_target_features.c

Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -7,6 +7,8 @@
   arm64intr.h
   avx2intrin.h
   avx512bwintrin.h
+  avx512bitalgintrin.h
+  avx512vlbitalgintrin.h
   avx512cdintrin.h
   avx512vpopcntdqintrin.h
   avx512dqintrin.h
Index: lib/Headers/immintrin.h
===
--- lib/Headers/immintrin.h
+++ lib/Headers/immintrin.h
@@ -146,6 +146,10 @@
 #include 
 #endif
 
+#if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512BITALG__)
+#include 
+#endif
+
 #if !defined(_MSC_VER) || __has_feature(modules) || defined(__AVX512CD__)
 #include 
 #endif
@@ -164,6 +168,11 @@
 #endif
 
 #if !defined(_MSC_VER) || __has_feature(modules) || \
+(defined(__AVX512VL__) && defined(__AVX512BITALG__))
+#include 
+#endif
+
+#if !defined(_MSC_VER) || __has_feature(modules) || \
 (defined(__AVX512VL__) && defined(__AVX512BW__))
 #include 
 #endif
Index: lib/Headers/avx512bitalgintrin.h
===
--- lib/Headers/avx512bitalgintrin.h
+++ lib/Headers/avx512bitalgintrin.h
@@ -0,0 +1,97 @@
+/*===- avx512bitalgintrin.h - BITALG intrinsics --===
+ *
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+#ifndef __IMMINTRIN_H
+#error "Never use  directly; include  instead."
+#endif
+
+#ifndef __AVX512BITALGINTRIN_H
+#define __AVX512BITALGINTRIN_H
+
+/* Define the default attributes for the functions in this file. */
+#define __DEFAULT_FN_ATTRS __attribute__((__always_inline__, __nodebug__, __target__("avx512bitalg")))
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_popcnt_epi16(__m512i __A)
+{
+  return (__m512i) __builtin_ia32_vpopcntw_512((__v32hi) __A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_popcnt_epi16(__m512i __A, __mmask32 __U, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_selectw_512((__mmask32) __U,
+  (__v32hi) _mm512_popcnt_epi16(__B),
+  (__v32hi) __A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_popcnt_epi16(__mmask32 __U, __m512i __B)
+{
+  return _mm512_mask_popcnt_epi16((__m512i) _mm512_setzero_hi(),
+  __U,
+  __B);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_popcnt_epi8(__m512i __A)
+{
+  return (__m512i) __builtin_ia32_vpopcntb_512((__v64qi) __A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_popcnt_epi8(__m512i __A, __mmask64 __U, __m512i __B)
+{
+  return (__m512i) __builtin_ia32_selectb_512((__mmask64) __U,
+  (__v64qi) _mm512_popcnt_epi8(__B),
+  (__v64qi) __A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_maskz_popcnt_epi8(__mmask64 __U, __m512i __B)
+{
+  return _mm512_mask_popcnt_epi8((__m512i) _mm512_setzero_qi(),
+  __U,
+  __B);
+}
+
+static __inline__ __mmask64 __DEFAULT_FN_ATTRS
+_mm512_mask_bitshuffle_epi64_mask(__mmask64 __U, __m

[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-24 Thread Dimitry Andric via Phabricator via cfe-commits
dim accepted this revision.
dim added a comment.
This revision is now accepted and ready to land.

Yes, please.  Rather sooner than later, the warning itself can be fixed 
post-6.0.0.


Repository:
  rC Clang

https://reviews.llvm.org/D41512



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


r321429 - [AST] Inline CompoundStmt contents into the parent allocation.

2017-12-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Dec 24 08:24:20 2017
New Revision: 321429

URL: http://llvm.org/viewvc/llvm-project?rev=321429&view=rev
Log:
[AST] Inline CompoundStmt contents into the parent allocation.

Saves a pointer on every CompoundStmt.

Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaStmt.cpp
cfe/trunk/lib/Serialization/ASTReaderStmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=321429&r1=321428&r2=321429&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sun Dec 24 08:24:20 2017
@@ -592,15 +592,21 @@ public:
 };
 
 /// CompoundStmt - This represents a group of statements like { stmt stmt }.
-class CompoundStmt : public Stmt {
+class CompoundStmt final : public Stmt,
+   private llvm::TrailingObjects 
{
   friend class ASTStmtReader;
+  friend TrailingObjects;
 
-  Stmt** Body = nullptr;
   SourceLocation LBraceLoc, RBraceLoc;
 
+  CompoundStmt(ArrayRef Stmts, SourceLocation LB, SourceLocation RB);
+  explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {}
+
+  void setStmts(ArrayRef Stmts);
+
 public:
-  CompoundStmt(const ASTContext &C, ArrayRef Stmts,
-   SourceLocation LB, SourceLocation RB);
+  static CompoundStmt *Create(const ASTContext &C, ArrayRef Stmts,
+  SourceLocation LB, SourceLocation RB);
 
   // \brief Build an empty compound statement with a location.
   explicit CompoundStmt(SourceLocation Loc)
@@ -609,11 +615,7 @@ public:
   }
 
   // \brief Build an empty compound statement.
-  explicit CompoundStmt(EmptyShell Empty) : Stmt(CompoundStmtClass, Empty) {
-CompoundStmtBits.NumStmts = 0;
-  }
-
-  void setStmts(const ASTContext &C, ArrayRef Stmts);
+  static CompoundStmt *CreateEmpty(const ASTContext &C, unsigned NumStmts);
 
   bool body_empty() const { return CompoundStmtBits.NumStmts == 0; }
   unsigned size() const { return CompoundStmtBits.NumStmts; }
@@ -622,14 +624,16 @@ public:
   using body_range = llvm::iterator_range;
 
   body_range body() { return body_range(body_begin(), body_end()); }
-  body_iterator body_begin() { return Body; }
-  body_iterator body_end() { return Body + size(); }
-  Stmt *body_front() { return !body_empty() ? Body[0] : nullptr; }
-  Stmt *body_back() { return !body_empty() ? Body[size()-1] : nullptr; }
+  body_iterator body_begin() { return getTrailingObjects(); }
+  body_iterator body_end() { return body_begin() + size(); }
+  Stmt *body_front() { return !body_empty() ? body_begin()[0] : nullptr; }
+  Stmt *body_back() {
+return !body_empty() ? body_begin()[size() - 1] : nullptr;
+  }
 
   void setLastStmt(Stmt *S) {
 assert(!body_empty() && "setLastStmt");
-Body[size()-1] = S;
+body_begin()[size() - 1] = S;
   }
 
   using const_body_iterator = Stmt* const *;
@@ -639,15 +643,17 @@ public:
 return body_const_range(body_begin(), body_end());
   }
 
-  const_body_iterator body_begin() const { return Body; }
-  const_body_iterator body_end() const { return Body + size(); }
+  const_body_iterator body_begin() const {
+return getTrailingObjects();
+  }
+  const_body_iterator body_end() const { return body_begin() + size(); }
 
   const Stmt *body_front() const {
-return !body_empty() ? Body[0] : nullptr;
+return !body_empty() ? body_begin()[0] : nullptr;
   }
 
   const Stmt *body_back() const {
-return !body_empty() ? Body[size() - 1] : nullptr;
+return !body_empty() ? body_begin()[size() - 1] : nullptr;
   }
 
   using reverse_body_iterator = std::reverse_iterator;
@@ -682,13 +688,10 @@ public:
   }
 
   // Iterators
-  child_range children() {
-return child_range(Body, Body + CompoundStmtBits.NumStmts);
-  }
+  child_range children() { return child_range(body_begin(), body_end()); }
 
   const_child_range children() const {
-return const_child_range(child_iterator(Body),
- child_iterator(Body + CompoundStmtBits.NumStmts));
+return const_child_range(body_begin(), body_end());
   }
 };
 

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=321429&r1=321428&r2=321429&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Sun Dec 24 08:24:20 2017
@@ -4321,9 +4321,8 @@ Stmt *ASTNodeImporter::VisitCompoundStmt
 
   SourceLocation ToLBraceLoc = Importer.Import(S->getLBracLoc());
   SourceLocation ToRBraceLoc = Importer.Import(S->getRBracLoc());
-  return new (Importer.getToContext()) Comp

r321428 - [AST] Convert AttributedStmt to llvm::TrailingObjects.

2017-12-24 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Sun Dec 24 08:24:11 2017
New Revision: 321428

URL: http://llvm.org/viewvc/llvm-project?rev=321428&view=rev
Log:
[AST] Convert AttributedStmt to llvm::TrailingObjects.

No functionality change intended.

Modified:
cfe/trunk/include/clang/AST/Stmt.h
cfe/trunk/lib/AST/Stmt.cpp

Modified: cfe/trunk/include/clang/AST/Stmt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Stmt.h?rev=321428&r1=321427&r2=321428&view=diff
==
--- cfe/trunk/include/clang/AST/Stmt.h (original)
+++ cfe/trunk/include/clang/AST/Stmt.h Sun Dec 24 08:24:11 2017
@@ -875,8 +875,11 @@ public:
 ///
 /// Represents an attribute applied to a statement. For example:
 ///   [[omp::for(...)]] for (...) { ... }
-class AttributedStmt : public Stmt {
+class AttributedStmt final
+: public Stmt,
+  private llvm::TrailingObjects {
   friend class ASTStmtReader;
+  friend TrailingObjects;
 
   Stmt *SubStmt;
   SourceLocation AttrLoc;
@@ -894,11 +897,9 @@ class AttributedStmt : public Stmt {
   }
 
   const Attr *const *getAttrArrayPtr() const {
-return reinterpret_cast(this + 1);
-  }
-  const Attr **getAttrArrayPtr() {
-return reinterpret_cast(this + 1);
+return getTrailingObjects();
   }
+  const Attr **getAttrArrayPtr() { return getTrailingObjects(); }
 
 public:
   static AttributedStmt *Create(const ASTContext &C, SourceLocation Loc,

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=321428&r1=321427&r2=321428&view=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Sun Dec 24 08:24:11 2017
@@ -334,7 +334,7 @@ AttributedStmt *AttributedStmt::Create(c
ArrayRef Attrs,
Stmt *SubStmt) {
   assert(!Attrs.empty() && "Attrs should not be empty");
-  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * 
Attrs.size(),
+  void *Mem = C.Allocate(totalSizeToAlloc(Attrs.size()),
  alignof(AttributedStmt));
   return new (Mem) AttributedStmt(Loc, Attrs, SubStmt);
 }
@@ -342,7 +342,7 @@ AttributedStmt *AttributedStmt::Create(c
 AttributedStmt *AttributedStmt::CreateEmpty(const ASTContext &C,
 unsigned NumAttrs) {
   assert(NumAttrs > 0 && "NumAttrs should be greater than zero");
-  void *Mem = C.Allocate(sizeof(AttributedStmt) + sizeof(Attr *) * NumAttrs,
+  void *Mem = C.Allocate(totalSizeToAlloc(NumAttrs),
  alignof(AttributedStmt));
   return new (Mem) AttributedStmt(EmptyShell(), NumAttrs);
 }


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


[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D41512



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


[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-24 Thread Dimitry Andric via Phabricator via cfe-commits
dim added a comment.

Actually, having thought about it a little more, if the warning is "rather 
broken", or even "completely broken", depending on one's point of view, then 
maybe it is better not have it under `-Wextra` either?  E.g. somebody has to 
ask for the warning specifically, using `-Wtautological-constant-compare`, or 
use `-Weverything`?

I ask this, because in FreeBSD we have traditionally been using `-W`, which is 
(again, historically) an alias for `-Wextra`.  We now still have to explicitly 
use `-Wno-tautological-constant-compare` everywhere. :-(


Repository:
  rC Clang

https://reviews.llvm.org/D41512



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


[PATCH] D41326: [clang-tidy] Added diagnostics about incorrect usage of NOLINT comment

2017-12-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:161
+
+  const SmallVector& getCheckNames() const {
+assert(isNolintFound());

aaron.ballman wrote:
> The `&` should bind to the right. However, instead of returning the concrete 
> container, why not expose a range interface instead?
This could use a typedef to make the return type more readable. Also, the 
function should be `checkName()`, dropping the "get".



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:276
+
+  using NolintMap = std::unordered_map aaron.ballman wrote:
> > Is there a better LLVM ADT to use here?
> This data structure provides the fast lookup by check name+line number and 
> it's exactly what is necessary. What are the concerns about this data 
> structure?
Same as above.



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:381
 
+void ClangTidyContext::setPreprocessor(Preprocessor *preprocessor) {
+  if (preprocessor && isCheckEnabled(NolintCheckName)) {

aaron.ballman wrote:
> Name does not match coding standard.
Please do not name the parameter the same as a type name.



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:424
+// This method is not const, because it fills cache on first demand.
+// It is possible to fill cache in constructor or make cache volatile
+// and make this method const, but they seem like worse solutions.

xgsa wrote:
> aaron.ballman wrote:
> > Making the cache volatile will have no impact on this.
> > 
> > Any reason not to make the cache `mutable`, however? That's quite common 
> > for implementation details.
> Sorry, certainly, instead of "volatile" I meant "mutable".
> 
> Actually, using of "mutable" violates a constancy contract, as the field is 
> get modified in a const method. Thus I'd tend to avoid using `mutable`, if 
> possible, because e.g. in multi-threaded applications these fields require 
> additional protection/synchronization. Moreover, I see that using of  
> `mutable` is not very spread in clang-tidy. Thus as, currently, `hasCheck` is 
> called from the non-constant context, I'd prefer leaving it non-const instead 
> of making cache `mutable`. Please, let me know if you insist on the `mutable` 
> option.
Use of mutable does not violate constancy; the cache is not exposed via any 
interface; it is purely an implementation detail. Very little of our code base 
is concerned with multithreaded scenarios (we use bit-fields *everywhere*, for 
instance).

I won't insist on using `mutable` if you are set against it, but this is the 
exact scenario in which it is the correct solution.



Comment at: clang-tidy/ClangTidyDiagnosticConsumer.cpp:839-840
+case NolintCommentType::Nolint:
+  Message = "there is no diagnostics on this line, "
+"the NOLINT comment is redundant";
+  break;

xgsa wrote:
> aaron.ballman wrote:
> > I don't think the user is going to care about the distinction between no 
> > diagnostics being triggered and the expected diagnostic not being 
> > triggered. Also, it's dangerous to claim the lint comment is redundant 
> > because it's possible the user has NOLINT(foo, bar) and while foo is not 
> > triggered, bar still is. The NOLINT comment itself isn't redundant, it's 
> > that the check specified doesn't occur.
> > 
> > I would consolidate those scenarios into a single diagnostic: "expected 
> > diagnostic '%0' not generated" and "expected diagnostic '%0' not generated 
> > for the following line".
> > 
> > One concern I have with this functionality is: how should users silence a 
> > lint diagnostic that's target sensitive? e.g., a diagnostic that triggers 
> > based on the underlying type of size_t or the signedness of plain char. In 
> > that case, the diagnostic may trigger for some targets but not others, but 
> > on the targets where the diagnostic is not triggered, they now get a 
> > diagnostic they cannot silence. There should be a way to silence the "bad 
> > NOLINT" diagnostics.
> > I don't think the user is going to care about the distinction between no 
> > diagnostics being triggered and the expected diagnostic not being 
> > triggered. Also, it's dangerous to claim the lint comment is redundant 
> > because it's possible the user has NOLINT(foo, bar) and while foo is not 
> > triggered, bar still is. The NOLINT comment itself isn't redundant, it's 
> > that the check specified doesn't occur.
> > 
> > I would consolidate those scenarios into a single diagnostic: "expected 
> > diagnostic '%0' not generated" and "expected diagnostic '%0' not generated 
> > for the following line".
> 
> This branch of `if (NolintEntry.first.CheckName == 
> NolintCommentsCollector::AnyCheck)` reports only about 
> `NOLINT`/`NOLINTNEXTLINE` comments without check list, so I suppose it's fair 
> to claim that this comment is redundan

Re: [PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-24 Thread Aaron Ballman via cfe-commits
On Sun, Dec 24, 2017 at 11:45 AM, Dimitry Andric via Phabricator
 wrote:
> dim added a comment.
>
> Actually, having thought about it a little more, if the warning is "rather 
> broken", or even "completely broken", depending on one's point of view, then 
> maybe it is better not have it under `-Wextra` either?  E.g. somebody has to 
> ask for the warning specifically, using `-Wtautological-constant-compare`, or 
> use `-Weverything`?
>
> I ask this, because in FreeBSD we have traditionally been using `-W`, which 
> is (again, historically) an alias for `-Wextra`.  We now still have to 
> explicitly use `-Wno-tautological-constant-compare` everywhere. :-(

I think having it under -Wextra is reasonable -- I don't think it's
rather/completely broken, I think it's more strict at diagnosing
issues than some people would like to see by default (which can be a
subjective measure).

If we're talking about removing it from -Wextra such that you have to
enable it by name only, I'd say it should be removed entirely (at
least temporarily) -- "no one" enables diagnostics by name (and very
few use -Weverything) and it increases our maintenance burden to carry
around a feature no one will use.

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


Re: r321386 - [OPENMP] Captured arguments of the capturable clauses by value.

2017-12-24 Thread Maxim Kuvyrkov via cfe-commits
> On Dec 23, 2017, at 12:01 AM, Alexey Bataev via cfe-commits 
>  wrote:
> 
> Author: abataev
> Date: Fri Dec 22 13:01:52 2017
> New Revision: 321386
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=321386&view=rev
> Log:
> [OPENMP] Captured arguments of the capturable clauses by value.
> 
> If the clause is applied to the combined construct and has captured
> expression, try to capture this expression by value rather than by
> reference.
> 
> Modified:
>cfe/trunk/lib/Sema/SemaOpenMP.cpp
>cfe/trunk/test/OpenMP/parallel_for_codegen.cpp
>cfe/trunk/test/OpenMP/teams_distribute_parallel_for_num_threads_codegen.cpp
>
> cfe/trunk/test/OpenMP/teams_distribute_parallel_for_simd_num_threads_codegen.cpp

Hi Alexey,

Changes to the teams_distribute_parallel_* tests break 32-bit ARM buildbots, 
e.g., http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/14264 .  
Would you please investigate?

Thanks,

--
Maxim Kuvyrkov
www.linaro.org


> 
> Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=321386&r1=321385&r2=321386&view=diff
> ==
> --- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Fri Dec 22 13:01:52 2017
> @@ -1290,9 +1290,14 @@ bool Sema::IsOpenMPCapturedByRef(ValueDe
>   }
> 
>   if (IsByRef && Ty.getNonReferenceType()->isScalarType()) {
> -IsByRef = !DSAStack->hasExplicitDSA(
> -D, [](OpenMPClauseKind K) -> bool { return K == OMPC_firstprivate; },
> -Level, /*NotLastprivate=*/true);
> +IsByRef =
> +!DSAStack->hasExplicitDSA(
> +D,
> +[](OpenMPClauseKind K) -> bool { return K == OMPC_firstprivate; 
> },
> +Level, /*NotLastprivate=*/true) &&
> +// If the variable is artificial and must be captured by value - try 
> to
> +// capture by value.
> +!(isa(D) && D->hasAttr());
>   }
> 
>   // When passing data by copy, we need to make sure it fits the uintptr size
> @@ -2321,10 +2326,11 @@ static OMPCapturedExprDecl *buildCapture
>   ASTContext &C = S.getASTContext();
>   Expr *Init = AsExpression ? CaptureExpr : CaptureExpr->IgnoreImpCasts();
>   QualType Ty = Init->getType();
> +  Attr *OMPCaptureKind = nullptr;
>   if (CaptureExpr->getObjectKind() == OK_Ordinary && 
> CaptureExpr->isGLValue()) {
> -if (S.getLangOpts().CPlusPlus)
> +if (S.getLangOpts().CPlusPlus) {
>   Ty = C.getLValueReferenceType(Ty);
> -else {
> +} else {
>   Ty = C.getPointerType(Ty);
>   ExprResult Res =
>   S.CreateBuiltinUnaryOp(CaptureExpr->getExprLoc(), UO_AddrOf, Init);
> @@ -2333,11 +2339,16 @@ static OMPCapturedExprDecl *buildCapture
>   Init = Res.get();
> }
> WithInit = true;
> +  } else if (AsExpression) {
> +// This variable must be captured by value.
> +OMPCaptureKind = OMPCaptureKindAttr::CreateImplicit(C, OMPC_unknown);
>   }
>   auto *CED = OMPCapturedExprDecl::Create(C, S.CurContext, Id, Ty,
>   CaptureExpr->getLocStart());
>   if (!WithInit)
> CED->addAttr(OMPCaptureNoInitAttr::CreateImplicit(C, SourceRange()));
> +  if (OMPCaptureKind)
> +CED->addAttr(OMPCaptureKind);
>   S.CurContext->addHiddenDecl(CED);
>   S.AddInitializerToDecl(CED, Init, /*DirectInit=*/false);
>   return CED;
> @@ -2346,31 +2357,34 @@ static OMPCapturedExprDecl *buildCapture
> static DeclRefExpr *buildCapture(Sema &S, ValueDecl *D, Expr *CaptureExpr,
>  bool WithInit) {
>   OMPCapturedExprDecl *CD;
> -  if (auto *VD = S.IsOpenMPCapturedDecl(D))
> +  if (auto *VD = S.IsOpenMPCapturedDecl(D)) {
> CD = cast(VD);
> -  else
> +  } else {
> CD = buildCaptureDecl(S, D->getIdentifier(), CaptureExpr, WithInit,
>   /*AsExpression=*/false);
> +  }
>   return buildDeclRefExpr(S, CD, CD->getType().getNonReferenceType(),
>   CaptureExpr->getExprLoc());
> }
> 
> static ExprResult buildCapture(Sema &S, Expr *CaptureExpr, DeclRefExpr *&Ref) 
> {
> +  CaptureExpr = S.DefaultLvalueConversion(CaptureExpr).get();
>   if (!Ref) {
> -auto *CD =
> -buildCaptureDecl(S, &S.getASTContext().Idents.get(".capture_expr."),
> - CaptureExpr, /*WithInit=*/true, 
> /*AsExpression=*/true);
> +OMPCapturedExprDecl *CD = buildCaptureDecl(
> +S, &S.getASTContext().Idents.get(".capture_expr."), CaptureExpr,
> +/*WithInit=*/true, /*AsExpression=*/true);
> Ref = buildDeclRefExpr(S, CD, CD->getType().getNonReferenceType(),
>CaptureExpr->getExprLoc());
>   }
>   ExprResult Res = Ref;
>   if (!S.getLangOpts().CPlusPlus &&
>   CaptureExpr->getObjectKind() == OK_Ordinary && CaptureExpr->isGLValue() 
> &&
> -  Ref->getType()->isPointerType())
> +  Ref->getType()->isPointerType()) {
> Res = S.CreateBuiltinUnary

[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D41512#963743, @dim wrote:

> Actually, having thought about it a little more, if the warning is "rather 
> broken", or even "completely broken", depending on one's point of view, then 
> maybe it is better not have it under `-Wextra` either?


In it's current form, there has been zero false-positives. All the complaints
are because it is finding an **actual** issues in the people's code, and people
don't feel like fixing the code because in some other case (data model) the
issue would not be present.

Of course, everyone is welcomed to please do prove me wrong,
and report some actual false-positives that are not data-model-dependant.

> E.g. somebody has to ask for the warning specifically, using 
> `-Wtautological-constant-compare`, or use `-Weverything`?
> 
> I ask this, because in FreeBSD we have traditionally been using `-W`, which 
> is (again, historically) an alias for `-Wextra`.  We now still have to 
> explicitly use `-Wno-tautological-constant-compare` everywhere. :-(

What @aaron.ballman said in the mail. No one ever will enable it then.
And since it is not actually broken in the first place, i'm a *bit* hesitant to 
do that.

Though i totally understand the desire to not have bogus warnings,
and so far the clang/clang-analyzer/clang-tidy is the best at that :)


Repository:
  rC Clang

https://reviews.llvm.org/D41512



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


[PATCH] D41455: [ASTMatchers] Add isNoReturn() match narrower for FunctionDeclarations

2017-12-24 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a subscriber: dblaikie.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

Aside from a documentation nit, this LGTM. However, you should wait to commit 
until after you can safely regenerate the AST matcher documentation. The issue 
there is that dump_ast_matchers.py was not updated after r318304. I believe 
@dblaikie was looking into the Python script, but I'm not certain how far he 
got with it.




Comment at: include/clang/ASTMatchers/ASTMatchers.h:3579-3595
+///   struct b0 { [[noreturn]] b0(); };
+///   struct b1 { [[noreturn]] b1() {} };
+///   struct b2 { __attribute__((noreturn)) b2(); };
+///   struct b3 { __attribute__((noreturn)) b3() {} };
+///   struct c0 { [[noreturn]] int A(); };
+///   struct c1 { [[noreturn]] int A() {} };
+///   struct c2 { __attribute__((noreturn)) int A(); };

I don't think the documentation needs to list all of these -- it would be 
better to pick a representative few and just use those.


Repository:
  rC Clang

https://reviews.llvm.org/D41455



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


[PATCH] D40381: Parse concept definition

2017-12-24 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added a comment.

I think this looks good enough to commit - do you have commit privileges - or 
do you need one of us to commit it for you?
thank you!


https://reviews.llvm.org/D40381



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


[PATCH] D40381: Parse concept definition

2017-12-24 Thread changyu via Phabricator via cfe-commits
changyu added a comment.

I don't have commit privilege. And also there's one more problem we might want 
to address first.

Thank you.




Comment at: lib/Parse/ParseTemplate.cpp:181
+TemplateParameterList *TPL = ParamLists[0];
+if (TPL->getLAngleLoc().getLocWithOffset(1) == TPL->getRAngleLoc()) {
+  Diag(TPL->getTemplateLoc(),

There's one problem here.

​I added this `if` in attempt to catch the following case (but it's wrong)
```
​template<> concept D1 = true;  // expected-error {{expected template 
parameter}}
```
The problem is I'm not sure how to differentiate between the above situation 
and the following
```
​template concept D1 = true; // expected-error {{expected 
template parameter}}
```
Both have an empty template parameter list​. The latter case has diagnostic 
printed by `ParseNonTypeTemplateParameter` while the former has not (so we try 
to catch it here).

What should we do?



https://reviews.llvm.org/D40381



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


[PATCH] D41566: [Modules TS] Diagnose exported internal linkage declarations

2017-12-24 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood created this revision.
hamzasood added reviewers: rsmith, bruno, boris.

Diagnose attempts to export declarations with internal linkage, as mentioned in 
`[dcl.module.interface]p2` in the Modules TS.

I would've liked to add a FixIt hint to remove the static keyword if present, 
but I couldn't work out how to get the `SourceRange` that covers it (it's 
accessible from the `Declarator`, but seemingly not after the actual node has 
been created).
I've left a fixme comment in there in case anyone else can figure it out.


https://reviews.llvm.org/D41566

Files:
  include/clang/AST/DeclBase.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/DeclBase.cpp
  lib/Sema/SemaDecl.cpp
  test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
  test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
  test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
  test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p2.cpp

Index: test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p2.cpp
===
--- test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p2.cpp
+++ test/CXX/modules-ts/dcl.dcl/dcl.module/dcl.module.interface/p2.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fmodules-ts %s -emit-module-interface -verify
+
+export module A;
+
+export namespace { } // expected-error {{unnamed namespace}}
+
+export static int n = 5; // expected-error {{internal linkage}}
+
+namespace { // expected-note 3{{in this}}
+  export {
+int a = 1;   // expected-error {{internal linkage}}
+void f() { } // expected-error {{internal linkage}}
+class B { }; // expected-error {{internal linkage}}
+  }
+}
+
+export namespace a {
+  namespace b {
+namespace c {
+  static int i = 3; // expected-error {{internal linkage}}
+}
+  }
+}
Index: test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
===
--- test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
+++ test/CXX/modules-ts/basic/basic.def.odr/p4/user.cpp
@@ -3,7 +3,6 @@
 
 // CHECK-DAG: @extern_var_exported = external global
 // CHECK-DAG: @inline_var_exported = linkonce_odr global
-// CHECK-DAG: @_ZW6ModuleE19static_var_exported = available_externally global i32 0
 // CHECK-DAG: @const_var_exported = available_externally constant i32 3
 
 import Module;
@@ -16,7 +15,6 @@
 
   (void)&extern_var_exported;
   (void)&inline_var_exported;
-  (void)&static_var_exported;
   (void)&const_var_exported;
 
   // Module-linkage declarations are not visible here.
Index: test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
===
--- test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
+++ test/CXX/modules-ts/basic/basic.def.odr/p4/module.cppm
@@ -11,7 +11,6 @@
 // can discard this global and its initializer (if any), and other TUs are not
 // permitted to run the initializer for this variable.
 // CHECK-DAG: @inline_var_exported = linkonce_odr global
-// CHECK-DAG: @_ZW6ModuleE19static_var_exported = global
 // CHECK-DAG: @const_var_exported = constant
 //
 // CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external global
@@ -58,32 +57,20 @@
 export module Module;
 
 export {
-  // FIXME: These should be ill-formed: you can't export an internal linkage
-  // symbol, per [dcl.module.interface]p2.
-  // CHECK: define void {{.*}}@_ZW6ModuleE22unused_static_exportedv
-  static void unused_static_exported() {}
-  // CHECK: define void {{.*}}@_ZW6ModuleE20used_static_exportedv
-  static void used_static_exported() {}
-
   inline void unused_inline_exported() {}
   inline void used_inline_exported() {}
 
   extern int extern_var_exported;
   inline int inline_var_exported;
-  // FIXME: This should be ill-formed: you can't export an internal linkage
-  // symbol.
-  static int static_var_exported;
   const int const_var_exported = 3;
 
   // CHECK: define void {{.*}}@_Z18noninline_exportedv
   void noninline_exported() {
-used_static_exported();
 // CHECK: define linkonce_odr {{.*}}@_Z20used_inline_exportedv
 used_inline_exported();
 
 (void)&extern_var_exported;
 (void)&inline_var_exported;
-(void)&static_var_exported;
 (void)&const_var_exported;
   }
 }
Index: test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
===
--- test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
+++ test/CXX/modules-ts/basic/basic.def.odr/p4/module.cpp
@@ -3,12 +3,10 @@
 
 // CHECK-DAG: @extern_var_exported = external global
 // CHECK-DAG: @inline_var_exported = linkonce_odr global
-// CHECK-DAG: @_ZW6ModuleE19static_var_exported = available_externally global i32 0,
 // CHECK-DAG: @const_var_exported = available_externally constant i32 3,
 //
 // CHECK-DAG: @_ZW6ModuleE25extern_var_module_linkage = external global
 // CHECK-DAG: @_ZW6ModuleE25inline_var_module_linkage = linkonce_odr global
-// CHECK-DAG: @_Z

[PATCH] D40381: Parse concept definition

2017-12-24 Thread Faisal Vali via Phabricator via cfe-commits
faisalv added inline comments.



Comment at: lib/Parse/ParseTemplate.cpp:181
+TemplateParameterList *TPL = ParamLists[0];
+if (TPL->getLAngleLoc().getLocWithOffset(1) == TPL->getRAngleLoc()) {
+  Diag(TPL->getTemplateLoc(),

changyu wrote:
> There's one problem here.
> 
> ​I added this `if` in attempt to catch the following case (but it's wrong)
> ```
>   ​template<> concept D1 = true;  // expected-error {{expected template 
> parameter}}
> ```
> The problem is I'm not sure how to differentiate between the above situation 
> and the following
> ```
>   ​template concept D1 = true; // expected-error {{expected 
> template parameter}}
> ```
> Both have an empty template parameter list​. The latter case has diagnostic 
> printed by `ParseNonTypeTemplateParameter` while the former has not (so we 
> try to catch it here).
> 
> What should we do?
> 

I was thinking that we would just emit a (redundant in the case of a bad 
template parameter) message in Sema if the template-parameters are empty that 
explicit specializations are not allowed here.  while it would be a little 
misleading in the invalid template parameter case - to fix this robustly would 
require some fine-tuning and correcting some of the 
handshaking/error-propagation between the parsing of the template parameters 
and the code that calls it, I think.  I would vote for not holding up this 
patch for that, unless you feel strongly you'd like to fix that behavior - then 
we can try and work on that first?

Thoughts?




https://reviews.llvm.org/D40381



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


[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 128113.
lebedev.ri edited the summary of this revision.
lebedev.ri added a comment.

In https://reviews.llvm.org/D41512#963743, @dim wrote:

> We now still have to explicitly use `-Wno-tautological-constant-compare` 
> everywhere. :-(


OTOH, thank you for bringing this up once again. I did thought previously about
moving this specific warning into it's own flag, but never really looked into 
it.
But now i did, so hopefully this should be even better now :)


Repository:
  rC Clang

https://reviews.llvm.org/D41512

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  test/Sema/tautological-constant-compare.c
  test/Sema/tautological-constant-enum-compare.c
  test/SemaCXX/compare.cpp

Index: test/SemaCXX/compare.cpp
===
--- test/SemaCXX/compare.cpp
+++ test/SemaCXX/compare.cpp
@@ -1,7 +1,7 @@
 // Force x86-64 because some of our heuristics are actually based
 // on integer sizes.
 
-// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -std=c++11 %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -fsyntax-only -pedantic -verify -Wsign-compare -Wtautological-constant-range-compare -std=c++11 %s
 
 int test0(long a, unsigned long b) {
   enum EnumA {A};
Index: test/Sema/tautological-constant-enum-compare.c
===
--- test/Sema/tautological-constant-enum-compare.c
+++ test/Sema/tautological-constant-enum-compare.c
@@ -1,5 +1,5 @@
-// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -verify %s
-// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -Wtautological-constant-range-compare -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -Wtautological-constant-range-compare -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DUNSIGNED -DSILENCE -Wno-tautological-constant-compare -verify %s
 // RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGNED -DSILENCE -Wno-tautological-constant-compare -verify %s
 
Index: test/Sema/tautological-constant-compare.c
===
--- test/Sema/tautological-constant-compare.c
+++ test/Sema/tautological-constant-compare.c
@@ -1,7 +1,11 @@
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wno-tautological-constant-compare -verify %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -DTEST -verify -x c++ %s
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wno-tautological-constant-compare -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-constant-range-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wtautological-constant-range-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -DTEST -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wextra -Wno-sign-compare -DTEST -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -Wall -verify -x c++ %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify %s
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -x c++ %s
 
 int value(void);
 
@@ -498,7 +502,7 @@
 return 0;
 
 #if __SIZEOF_INT128__
-  __int128 i128;
+  __int128 i128 = value();
   if (i128 == -1) // used to crash
   return 0;
 #endif
@@ -509,7 +513,7 @@
   no,
   maybe
   };
-  enum E e;
+  enum E e = (enum E)value();
 
   if (e == yes)
   return 0;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -5950,7 +5950,7 @@
 def warn_tautological_constant_compare : Warning<
   "result of comparison %select{%3|%1}0 %2 "
   "%select{%1|%3}0 is always %4">,
-  InGroup;
+  InGroup, DefaultIgnore;
 
 def warn_mixed_sign_comparison : Warning<
   "comparison of integers of different signs: %0 and %1">,
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -437,10 +437,12 @@
 def StrncatSize : DiagGroup<"strncat-size">;
 def TautologicalUnsignedZeroCompare : DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : DiagGroup<"tautological-unsigned-enum-zero-compare">;
+def TautologicalRangeCompare : DiagGroup<"tautological-constant-range-compare">;
 def TautologicalOutOfRangeC

[PATCH] D36836: [clang-tidy] Implement sonarsource-function-cognitive-complexity check

2017-12-24 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 128114.
lebedev.ri added a comment.

Rebased.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D36836

Files:
  LICENSE.TXT
  clang-tidy/CMakeLists.txt
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/sonarsource/CMakeLists.txt
  clang-tidy/sonarsource/FunctionCognitiveComplexityCheck.cpp
  clang-tidy/sonarsource/FunctionCognitiveComplexityCheck.h
  clang-tidy/sonarsource/LICENSE.TXT
  clang-tidy/sonarsource/SONARSOURCETidyModule.cpp
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/sonarsource-function-cognitive-complexity.rst
  test/clang-tidy/sonarsource-function-cognitive-complexity.cpp

Index: test/clang-tidy/sonarsource-function-cognitive-complexity.cpp
===
--- /dev/null
+++ test/clang-tidy/sonarsource-function-cognitive-complexity.cpp
@@ -0,0 +1,954 @@
+// RUN: %check_clang_tidy %s sonarsource-function-cognitive-complexity %t -- -config='{CheckOptions: [{key: sonarsource-function-cognitive-complexity.Threshold, value: 0}]}' -- -std=c++11 -w
+
+// any function should be checked.
+
+extern int ext_func(int x = 0);
+
+int some_func(int x = 0);
+
+static int some_other_func(int x = 0) {}
+
+template void some_templ_func(T x = 0) {}
+
+class SomeClass {
+public:
+  int *begin(int x = 0);
+  int *end(int x = 0);
+  static int func(int x = 0);
+  template void some_templ_func(T x = 0) {}
+  SomeClass() = default;
+  SomeClass(SomeClass&) = delete;
+};
+
+// nothing ever decreases cognitive complexity, so we can check all the things
+// in one go. none of the following should increase cognitive complexity:
+void unittest_false() {
+  {};
+  ext_func();
+  some_func();
+  some_other_func();
+  some_templ_func();
+  some_templ_func();
+  SomeClass::func();
+  SomeClass C;
+  C.some_templ_func();
+  C.some_templ_func();
+  C.func();
+  C.end();
+  int i = some_func();
+  i = i;
+  i++;
+  --i;
+  i < 0;
+  int j = 0 ?: 1;
+  auto k = new int;
+  delete k;
+  throw i;
+  {
+throw i;
+  }
+end:
+  return;
+}
+
+#if 1
+#define CC100
+#else
+// this macro has cognitive complexity of 100.
+// it is needed to be able to compare the testcases with the
+// reference Sonar implementation. please place it right after the first
+// CHECK-NOTES in each function
+#define CC100 if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){if(1){}if(1){}
+#endif
+
+////
+//-- B1. Increments --//
+////
+// Check that every thing listed in B1 of the specification does indeed   //
+// recieve the base increment, and that not-body does not increase nesting//
+////
+
+// break does not increase cognitive complexity.
+// only  break LABEL  does, but it is unavaliable in C or C++
+
+// continue does not increase cognitive complexity.
+// only  continue LABEL  does, but it is unavaliable in C or C++
+
+void unittest_b1_00() {
+// CHECK-NOTES: :[[@LINE-1]]:6: warning: function 'unittest_b1_00' has cognitive complexity of 33 (threshold 0) [sonarsource-function-cognitive-complexity]
+  CC100;
+
+  if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:3: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:9: note: +1, including nesting penalty of 0, nesting level increased to 1{{$}}
+
+if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+} else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, nesting level increased to 3{{$}}
+} else {
+// CHECK-NOTES: :[[@LINE-1]]:7: note: +1, nesting level increased to 2{{$}}
+}
+  } else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:10: note: +1, nesting level increased to 1{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:16: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+
+if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:5: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:11: note: +2, including nesting penalty of 1, nesting level increased to 2{{$}}
+} else if (1 ? 1 : 0) {
+// CHECK-NOTES: :[[@LINE-1]]:12: note: +1, nesting level increased to 2{{$}}
+// CHECK-NOTES: :[[@LINE-2]]:18: note: +3, including nesting penalty of 2, nesting level increased to 3{{$}}
+} else {
+// CHECK-NOTES: :[[@LINE-1]]:7: note: +1, nesting level

[PATCH] D41564: [x86][icelake][bitalg]

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

LGTM


Repository:
  rC Clang

https://reviews.llvm.org/D41564



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


[PATCH] D41569: Summary:Constraint enforcement and diagnostics

2017-12-24 Thread Saar Raz via Phabricator via cfe-commits
saar.raz created this revision.
saar.raz added reviewers: hubert.reinterpretcast, rsmith, nwilson, changyu, 
faisalv.
Herald added a subscriber: cfe-commits.

- Associated constraints (requires clauses, currently) are now enforced when 
instantiating/specializing templates and when considering partial 
specializations and function overloads.
- Elaborated diagnostics give helpful insight as to why the constraints were 
not satisfied.

This patch depends upon https://reviews.llvm.org/D41284


Repository:
  rC Clang

https://reviews.llvm.org/D41569

Files:
  include/clang/AST/ExprCXX.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  include/clang/Sema/TemplateDeduction.h
  lib/AST/ExprCXX.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateDeduction.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  
test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/partial-specializations.cpp

Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/partial-specializations.cpp
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+namespace class_templates
+{
+  template requires sizeof(T) >= 4 // expected-note {{'sizeof(char) >= 4' (1 >= 4) evaluated to false}}
+  struct is_same { static constexpr bool value = false; };
+
+  template requires sizeof(T*) >= 4 && sizeof(T) >= 4
+  struct is_same { static constexpr bool value = true; };
+
+  static_assert(!is_same::value);
+  static_assert(!is_same::value);
+  static_assert(is_same::value);
+  static_assert(is_same::value); // expected-error {{constraints not satisfied for class template 'is_same' [with T = char, U = char], because:}}
+}
+
+namespace variable_templates
+{
+  template requires sizeof(T) >= 4
+  constexpr bool is_same_v = false;
+
+  template requires sizeof(T*) >= 4 && sizeof(T) >= 4
+  constexpr bool is_same_v = true;
+
+  static_assert(!is_same_v);
+  static_assert(!is_same_v);
+  static_assert(is_same_v);
+}
\ No newline at end of file
Index: test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
@@ -0,0 +1,42 @@
+// RUN: %clang_cc1 -std=c++2a -fconcepts-ts -x c++ -verify %s
+
+template requires sizeof(T) >= 2 // expected-note{{'sizeof(char) >= 2' (1 >= 2) evaluated to false}}
+struct A {
+  static constexpr int value = sizeof(T);
+};
+
+static_assert(A::value == 4);
+static_assert(A::value == 1); // expected-error{{constraints not satisfied for class template 'A' [with T = char], because:}}
+
+template
+  requires sizeof(T) != sizeof(U) // expected-note{{'sizeof(int) != sizeof(char [4])' (4 != 4) evaluated to false}}
+   && sizeof(T) >= 4 // expected-note{{'sizeof(char) >= 4' (1 >= 4) evaluated to false}}
+constexpr int SizeDiff = sizeof(T) > sizeof(U) ? sizeof(T) - sizeof(U) : sizeof(U) - sizeof(T);
+
+static_assert(SizeDiff == 3);
+static_assert(SizeDiff == 0); // expected-error{{constraints not satisfied for variable template 'SizeDiff' [with T = int, U = char [4]], because:}}
+static_assert(SizeDiff == 3); // expected-error{{constraints not satisfied for variable template 'SizeDiff' [with T = char, U = int], because:}}
+
+template
+  requires ((sizeof(Ts) == 4) || ...) // expected-note{{'sizeof(char) == 4' (1 == 4) evaluated to false}} expected-note{{'sizeof(long long) == 4' (8 == 4) evaluated to false}} expected-note{{'sizeof(int [20]) == 4' (80 == 4) evaluated to false}}
+constexpr auto SumSizes = (sizeof(Ts) + ...);
+
+static_assert(SumSizes == 13);
+static_assert(SumSizes == 89); // expected-error{{constraints not satisfied for variable template 'SumSizes' [with Ts = ], because:}}
+
+template
+concept IsBig = sizeof(T) > 100; // expected-note{{'sizeof(int) > 100' (4 > 100) evaluated to false}}
+
+template
+  requires IsBig // expected-note{{'int' does not satisfy 'IsBig', because:}}
+using BigPtr = T*;
+
+static_assert(sizeof(BigPtr)); // expected-error{{constraints not satisfied for alias template 'BigPtr' [with T = int], because:
+
+template requires T::value // expected-note{{substituted constraint expression is ill-formed: type 'int' cannot be used prior to '::' because it has no members}}
+struct S { static constexpr bool value = true; };
+
+struct S2 { static constexpr bool value = true; };
+
+static_assert(S::value); // expected-error{{constraints not satisfied for class te

[PATCH] D41217: [Concepts] Concept Specialization Expressions

2017-12-24 Thread Saar Raz via Phabricator via cfe-commits
saar.raz updated this revision to Diff 128121.
saar.raz added a comment.

Reverted to original constraint parsing code.


https://reviews.llvm.org/D41217

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/StmtNodes.td
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ExprClassification.cpp
  lib/AST/ExprConstant.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/StmtProfile.cpp
  lib/CodeGen/CGExprScalar.cpp
  lib/Parse/ParseExpr.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaExceptionSpec.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/Parser/cxx-concept-declaration.cpp
  tools/libclang/CXCursor.cpp

Index: tools/libclang/CXCursor.cpp
===
--- tools/libclang/CXCursor.cpp
+++ tools/libclang/CXCursor.cpp
@@ -231,6 +231,7 @@
   case Stmt::TypeTraitExprClass:
   case Stmt::CoroutineBodyStmtClass:
   case Stmt::CoawaitExprClass:
+  case Stmt::ConceptSpecializationExprClass:
   case Stmt::DependentCoawaitExprClass:
   case Stmt::CoreturnStmtClass:
   case Stmt::CoyieldExprClass:
Index: test/Parser/cxx-concept-declaration.cpp
===
--- test/Parser/cxx-concept-declaration.cpp
+++ test/Parser/cxx-concept-declaration.cpp
@@ -9,8 +9,6 @@
 
 template concept D1 = true; // expected-error {{expected template parameter}}
 
-template concept C2 = 0.f; // expected-error {{constraint expression must be 'bool'}}
-
 struct S1 {
   template concept C1 = true; // expected-error {{concept declarations may only appear in global or namespace scope}}
 };
@@ -29,3 +27,12 @@
 
 // TODO: Add test to prevent explicit specialization, partial specialization
 // and explicit instantiation of concepts.
+
+template concept C7 = 2; // expected-error {{atomic constraint '2' must be of type 'bool' (found 'int')}}
+template concept C8 = 2 && x; // expected-error {{atomic constraint '2' must be of type 'bool' (found 'int')}}
+template concept C9 = x || 2 || x; // expected-error {{atomic constraint '2' must be of type 'bool' (found 'int')}}
+template concept C10 = 8ull && x || x; // expected-error {{atomic constraint '8ULL' must be of type 'bool' (found 'unsigned long long')}}
+template concept C11 = sizeof(T); // expected-error {{atomic constraint 'sizeof(T)' must be of type 'bool' (found 'unsigned long')}}
+template concept C12 = T{};
+template concept C13 = (bool&&)true;
+template concept C14 = (const bool&)true;
Index: test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
===
--- test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
+++ test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
@@ -1,5 +1,52 @@
 // RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
-// expected-no-diagnostics
 
-template concept C = true;
-static_assert(C);
+template concept C1 = true;
+static_assert(C1);
+
+template concept C2 = sizeof(T) == 4;
+static_assert(C2);
+static_assert(!C2);
+static_assert(C2);
+static_assert(!C2);
+
+template concept C3 = sizeof(*T{}) == 4;
+static_assert(C3);
+static_assert(!C3);
+
+struct A {
+static constexpr int add(int a, int b) {
+return a + b;
+}
+};
+struct B {
+static int add(int a, int b) {
+return a + b;
+}
+};
+template
+concept C4 = U::add(1, 2) == 3;
+static_assert(C4);
+static_assert(!C4); // expected-error {{concept specialization 'C4' resulted in a non-constant expression 'B::add(1, 2) == 3'}}
+
+template
+constexpr bool is_same_v = false;
+
+template
+constexpr bool is_same_v = true;
+
+template
+concept Same = is_same_v;
+
+static_assert(Same);
+static_assert(Same);
+static_assert(!Same);
+static_assert(!Same);
+static_assert(Same);
+
+static_assert(Same)>);
+static_assert(Same)>);
+static_assert(Same)>);
+static_assert(Same)>);
+
+template concept C5 = T{}; // expected-error {{atomic constraint 'int{}' must be of type 'bool' (found 'int')}}
+constexpr bool x = C5; // expected-note {{in concept specialization 'C5'}}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1018,6 +1018,7 @@
 case Stmt::CUDAKernelCallExprClass:
 case Stmt::OpaqueValueExprClass:
 case Stmt::AsTypeExprClass:
+case Stmt::ConceptSpecializationExprClass:
   // Fall through.
 
 // Cases we intentionally don't evaluate, since they don't need
Index: lib/Serialization/ASTWriterStmt.cpp
===

[PATCH] D41512: [Sema] -Wtautological-constant-compare is too good. Cripple it.

2017-12-24 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Basic/DiagnosticGroups.td:439
 def TautologicalUnsignedZeroCompare : 
DiagGroup<"tautological-unsigned-zero-compare">;
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
+def TautologicalRangeCompare : 
DiagGroup<"tautological-constant-range-compare">;

I forget, are these in-range-compare warnings new too, or just the 
non-unsigned-enum form? It would make sense to me for these two to be subgroups 
of `TautologicalRangeCompare`.



Comment at: include/clang/Basic/DiagnosticGroups.td:440
 def TautologicalUnsignedEnumZeroCompare : 
DiagGroup<"tautological-unsigned-enum-zero-compare">;
+def TautologicalRangeCompare : 
DiagGroup<"tautological-constant-range-compare">;
 def TautologicalOutOfRangeCompare : 
DiagGroup<"tautological-constant-out-of-range-compare">;

"tautological-constant-in-range-compare" would make more sense to me, as the 
complement of "tautological-constant-out-of-range-compare".


Repository:
  rC Clang

https://reviews.llvm.org/D41512



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


Re: r321099 - [driver][darwin] Take the OS version specified in "-target" as the target

2017-12-24 Thread Duncan Exon Smith via cfe-commits

> On Dec 21, 2017, at 16:39, Alex L  wrote:
> 
> 
> 
>> On 21 December 2017 at 12:34, James Y Knight  wrote:
>> I totally agree with moving towards eliminating the -m-version-min 
>> flags, it's much better to put it in the target, and will clean up a lot of 
>> cruft in the driver, eventually.
>> 
>> Now -- we (or anyone else who runs into this) can simply start specifying 
>> the version in both locations ("-target x86_64-apple-ios10 
>> -mios-simulator-version-min=10"), so as to work with both new and old clang, 
>> and be closer to the ultimate goal of having only -target. That's an overall 
>> nicer workaround to suggest than switching to -darwin. But, yea, there's no 
>> need for *temporary* patch to fix things just for us.
>> 
>> However, I do not understand why you're against committing the patch you 
>> mention as option #2 -- that seems like it'd be best for all users, by 
>> preserving compatibility with existing command-lines. So, I'd still like 
>> that change to be committed, permanently, not temporarily. I'm sure we can't 
>> be the only ones running clang like "-target x86_64-apple-ios 
>> -mios-simulator-version-min=10", and it seems unfortunate and unnecessary to 
>> break that, even if it can be worked around.
>> 
>> In the future, I'd hope the -m-version-min arguments can be deprecated 
>> more and more -- warning whenever you use them to modify the platform or 
>> version at all, rather just on specification conflict; then, warn anytime 
>> you use them at all; then, remove them. But in the meantime, it seems 
>> strictly better to preserve compatibility, don't you think?
> 
> + Duncan
> 
> Thanks, I think your argument is convincing. I think I will commit the change 
> that you're proposing in the near future if there are no further objections.

SGTM. 

> 
>  
>> 
>> 
>> 
>> On Dec 21, 2017 2:11 PM, "Alex L"  wrote:
>> Thanks for raising your concerns.
>> 
>> We decided to avoid -m-version-min flag in favor of -target to simplify 
>> the driver logic and to encourage the adoption of -target. Now after r321145 
>> we only warn about -m-version-min flag when the OS version specified in 
>> it is different to the OS version specified in target, or when target has no 
>> OS version.
>> 
>> There are two possible solutions here:
>> 1) You can still use -target with -mios-simulator-version-min as before but 
>> you'd have to use '-target=x86_64-apple-darwin' to ensure that the iOS 
>> version specified by  '-mios-simulator-version-min' is used.
>> 2) I also do have a patch that implements the logic that you propose (use 
>> the OS version in -m-version-min flag if target has none). If you 
>> believe that the first solution is not suitable for your code then I can 
>> commit it. At the same time I believe that we would rather not use this 
>> patch, but if it's urgent for your projects then maybe I can land it now and 
>> then we can establish some sort of timeline for when it can be reverted?
>> 
>> Thanks,
>> Alex
>> 
>> 
>>> On 21 December 2017 at 08:00, James Y Knight  wrote:
>>> I think if a version number isn't explicitly specified in the -target 
>>> value, the value from -m-version-min ought to still be used, as 
>>> it was before.
>>> 
>>> Currently, clang will ignore the -m-version-min version number if 
>>> the target has a particular OS specified, even if it has no version number 
>>> as part of it.
>>> 
>>> (We should be able to workaround this change backwards-compatibly by 
>>> specifying in both the -target argument and in the -m-version-min 
>>> arguments, but I do think the behavior should be fixed.)
> 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D40381: Parse concept definition

2017-12-24 Thread changyu via Phabricator via cfe-commits
changyu updated this revision to Diff 128123.
changyu marked 2 inline comments as done.

https://reviews.llvm.org/D40381

Files:
  include/clang/AST/DeclTemplate.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DeclNodes.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TemplateKinds.h
  include/clang/Parse/Parser.h
  include/clang/Sema/Sema.h
  include/clang/Serialization/ASTBitCodes.h
  lib/AST/ASTDumper.cpp
  lib/AST/DeclBase.cpp
  lib/AST/DeclTemplate.cpp
  lib/CodeGen/CGDecl.cpp
  lib/CodeGen/CodeGenModule.cpp
  lib/Parse/ParseTemplate.cpp
  lib/Sema/SemaTemplate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Serialization/ASTCommon.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
  test/Parser/cxx-concept-declaration.cpp
  test/Parser/cxx2a-concept-declaration.cpp
  tools/libclang/CIndex.cpp

Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -5906,6 +5906,7 @@
   case Decl::PragmaComment:
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
+  case Decl::Concept:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: test/Parser/cxx2a-concept-declaration.cpp
===
--- /dev/null
+++ test/Parser/cxx2a-concept-declaration.cpp
@@ -0,0 +1,43 @@
+
+// Support parsing of concepts
+
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+template concept C1 = true;
+
+template concept C1 = true; // expected-error {{redefinition of 'C1'}}
+
+// The following case shouldn't give error about explicit specialization.
+// But the way we parse template parameters in ParseTemplateParameters right
+// now doesn't allow us to distinguish between a template parameter list with
+// an invalid template parameter and a template parameter list with with no
+// parameters.
+// TODO: Fix that.
+template concept D1 = true; // expected-error {{expected template parameter}} expected-error {{concept maybe not be explicitly specialized}}
+
+template<> concept D1 = true;  // expected-error {{concept maybe not be explicitly specialized}}
+
+// TODO: Saar's patch should have this working.
+// template concept C2 = 0.f; // expected error {{constraint expression must be 'bool'}}
+
+struct S1 {
+  template concept C1 = true; // expected-error {{concept declarations may only appear in global or namespace scope}}
+};
+
+template
+template
+concept C4 = true; // expected-error {{extraneous template parameter list in concept definition}}
+
+template concept C5 = true; // expected-note {{previous}} expected-note {{previous}}
+int C5; // expected-error {{redefinition}}
+struct C5 {}; // expected-error {{redefinition}}
+
+struct C6 {};
+template concept C6 = true; // expected-error {{redefinition of 'C6' as different kind of symbol}}
+
+namespace thing {};
+
+template concept thing::C7 = true;  // expected-error {{concepts must be defined within their namespace}}
+
+
+// TODO: Add test to prevent explicit specialization, partial specialization
+// and explicit instantiation of concepts.
Index: test/Parser/cxx-concept-declaration.cpp
===
--- test/Parser/cxx-concept-declaration.cpp
+++ /dev/null
@@ -1,7 +0,0 @@
-
-// Support parsing of concepts
-// Disabled for now.
-// expected-no-diagnostics
-
-// RUN:  %clang_cc1 -std=c++14 -fconcepts-ts -x c++ -verify %s
-// template concept C1 = true;
Index: test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
===
--- /dev/null
+++ test/CXX/concepts-ts/expr/expr.prim/expr.prim.id/p3.cpp
@@ -0,0 +1,6 @@
+// RUN:  %clang_cc1 -std=c++2a -fconcepts-ts -verify %s
+// expected-no-diagnostics
+
+// TODO: Make this work.
+// template concept C = true;
+// static_assert(C);
Index: lib/Serialization/ASTWriterDecl.cpp
===
--- lib/Serialization/ASTWriterDecl.cpp
+++ lib/Serialization/ASTWriterDecl.cpp
@@ -101,6 +101,7 @@
 void VisitBindingDecl(BindingDecl *D);
 void VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D);
 void VisitTemplateDecl(TemplateDecl *D);
+void VisitConceptDecl(ConceptDecl *D);
 void VisitRedeclarableTemplateDecl(RedeclarableTemplateDecl *D);
 void VisitClassTemplateDecl(ClassTemplateDecl *D);
 void VisitVarTemplateDecl(VarTemplateDecl *D);
@@ -1385,6 +1386,12 @@
   Record.AddTemplateParameterList(D->getTemplateParameters());
 }
 
+void ASTDeclWriter::VisitConceptDecl(ConceptDecl *D) {
+  VisitTemplateDecl(D);
+  Record.AddStmt(D->getConstraintExpr());
+  Code = serialization::DECL_CONCEPT;
+}
+
 void ASTDeclWriter::VisitRedeclarableTemplateDecl(Rede

[PATCH] D40381: Parse concept definition

2017-12-24 Thread changyu via Phabricator via cfe-commits
changyu added a comment.

I moved some template param checks from 
`Parser::ParseTemplateDeclarationOrSpecialization` to 
`Parser::ParseConceptDefinition` and `Sema::ActOnConceptDefinition`.




Comment at: lib/Parse/ParseTemplate.cpp:181
+TemplateParameterList *TPL = ParamLists[0];
+if (TPL->getLAngleLoc().getLocWithOffset(1) == TPL->getRAngleLoc()) {
+  Diag(TPL->getTemplateLoc(),

faisalv wrote:
> changyu wrote:
> > There's one problem here.
> > 
> > ​I added this `if` in attempt to catch the following case (but it's wrong)
> > ```
> > ​template<> concept D1 = true;  // expected-error {{expected template 
> > parameter}}
> > ```
> > The problem is I'm not sure how to differentiate between the above 
> > situation and the following
> > ```
> > ​template concept D1 = true; // expected-error {{expected 
> > template parameter}}
> > ```
> > Both have an empty template parameter list​. The latter case has diagnostic 
> > printed by `ParseNonTypeTemplateParameter` while the former has not (so we 
> > try to catch it here).
> > 
> > What should we do?
> > 
> 
> I was thinking that we would just emit a (redundant in the case of a bad 
> template parameter) message in Sema if the template-parameters are empty that 
> explicit specializations are not allowed here.  while it would be a little 
> misleading in the invalid template parameter case - to fix this robustly 
> would require some fine-tuning and correcting some of the 
> handshaking/error-propagation between the parsing of the template parameters 
> and the code that calls it, I think.  I would vote for not holding up this 
> patch for that, unless you feel strongly you'd like to fix that behavior - 
> then we can try and work on that first?
> 
> Thoughts?
> 
> 
Sure, let's fix that in another patch. I added a note for this in 
cxx2a-concept-declaration.cpp.


https://reviews.llvm.org/D40381



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


[PATCH] D41248: [libcxx] Suppress unused warning on apple.

2017-12-24 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL321435: [libcxx] Suppress unused warning on apple. (authored 
by dhinton, committed by ).

Repository:
  rL LLVM

https://reviews.llvm.org/D41248

Files:
  libcxx/trunk/src/experimental/filesystem/operations.cpp


Index: libcxx/trunk/src/experimental/filesystem/operations.cpp
===
--- libcxx/trunk/src/experimental/filesystem/operations.cpp
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp
@@ -512,6 +512,7 @@
 
 #if defined(__APPLE__)
 TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
+__attribute__((unused)) // Suppress warning
 TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
 #else
 TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }


Index: libcxx/trunk/src/experimental/filesystem/operations.cpp
===
--- libcxx/trunk/src/experimental/filesystem/operations.cpp
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp
@@ -512,6 +512,7 @@
 
 #if defined(__APPLE__)
 TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
+__attribute__((unused)) // Suppress warning
 TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
 #else
 TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r321435 - [libcxx] Suppress unused warning on apple.

2017-12-24 Thread Don Hinton via cfe-commits
Author: dhinton
Date: Sun Dec 24 21:33:42 2017
New Revision: 321435

URL: http://llvm.org/viewvc/llvm-project?rev=321435&view=rev
Log:
[libcxx] Suppress unused warning on apple.

Summary:
This warning is already suppressed on non-apple platforms, so
this change just suppresses it on apple as well.

Reviewers: EricWF, lichray

Reviewed By: lichray

Subscribers: cfe-commits

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

Modified:
libcxx/trunk/src/experimental/filesystem/operations.cpp

Modified: libcxx/trunk/src/experimental/filesystem/operations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/experimental/filesystem/operations.cpp?rev=321435&r1=321434&r2=321435&view=diff
==
--- libcxx/trunk/src/experimental/filesystem/operations.cpp (original)
+++ libcxx/trunk/src/experimental/filesystem/operations.cpp Sun Dec 24 21:33:42 
2017
@@ -512,6 +512,7 @@ using StatT =  struct stat;
 
 #if defined(__APPLE__)
 TimeSpec extract_mtime(StatT const& st) { return st.st_mtimespec; }
+__attribute__((unused)) // Suppress warning
 TimeSpec extract_atime(StatT const& st) { return st.st_atimespec; }
 #else
 TimeSpec extract_mtime(StatT const& st) { return st.st_mtim; }


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


[PATCH] D41535: Add -vfsoverlay option for Clang-Tidy

2017-12-24 Thread Vladimir Plyashkun via Phabricator via cfe-commits
vladimir.plyashkun added a comment.

@ilya-biryukov 
Yes, this is exactly what i need.
Unfortunately, `-ivfsoverlay` in the compile commands works for the compiler 
invocation, but it doesn't work for tooling.
E.g. this call:

  clang-tidy -checks=*  -- -ivfsoverlay=

has no effect.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D41535



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