RE: r274110 - [AVX512] Zero extend cmp intrinsic return value.

2016-07-03 Thread Breger, Igor via cfe-commits
Hello Craig,
Thanks a lot for pointing it out to me.  I familiar with this problem,  we are 
planning  to improve CodeGen to handle with this case in near future.

Regards,
Igor

From: Craig Topper [mailto:craig.top...@gmail.com]
Sent: Saturday, July 02, 2016 08:46
To: Breger, Igor; Eric Christopher via cfe-commits
Subject: Re: r274110 - [AVX512] Zero extend cmp intrinsic return value.

This change codgens to something really awful now. Can you take a look?

.section__TEXT,__text,regular,pure_instructions
.section__TEXT,__literal8,8byte_literals
.p2align   3
LCPI0_0:
.quad   -1
.section__TEXT,__const
.p2align   6
LCPI0_1:
.quad   0
.quad   1
.quad   2
.quad   3
.quad   8
.quad   8
.quad   8
.quad   8
.section__TEXT,__text,regular,pure_instructions
.globl   _test_mm_cmpeq_epu32_mask
.p2align   4, 0x90
_test_mm_cmpeq_epu32_mask:
vpcmpeqd   %xmm1, %xmm0, %k1
vpbroadcastq   LCPI0_0(%rip), %zmm0 {%k1} {z}
vpxord %zmm1, %zmm1, %zmm1
vmovdqa64 LCPI0_1(%rip), %zmm2
vpermt2q %zmm1, %zmm2, %zmm0
vpsllq   $63, %zmm0, %zmm0
vptestmq %zmm0, %zmm0, %k0
kmovw%k0, %eax
retq

~Craig

On Wed, Jun 29, 2016 at 1:14 AM, Igor Breger via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: ibreger
Date: Wed Jun 29 03:14:17 2016
New Revision: 274110

URL: http://llvm.org/viewvc/llvm-project?rev=274110&view=rev
Log:
[AVX512]  Zero extend cmp intrinsic return value.

Differential Revision: http://reviews.llvm.org/D21746

Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=274110&r1=274109&r2=274110&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jun 29 03:14:17 2016
@@ -6460,8 +6460,8 @@ static Value *EmitX86MaskedCompare(CodeG
   Indices[i] = i;
 for (unsigned i = NumElts; i != 8; ++i)
   Indices[i] = NumElts;
-Cmp = CGF.Builder.CreateShuffleVector(Cmp, UndefValue::get(Cmp->getType()),
-  Indices);
+Cmp = CGF.Builder.CreateShuffleVector(
+Cmp, llvm::Constant::getNullValue(Cmp->getType()), Indices);
   }
   return CGF.Builder.CreateBitCast(Cmp,
IntegerType::get(CGF.getLLVMContext(),

Modified: cfe/trunk/test/CodeGen/avx512vl-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vl-builtins.c?rev=274110&r1=274109&r2=274110&view=diff
==
--- cfe/trunk/test/CodeGen/avx512vl-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512vl-builtins.c Wed Jun 29 03:14:17 2016
@@ -8,6 +8,7 @@
 __mmask8 test_mm_cmpeq_epu32_mask(__m128i __a, __m128i __b) {
   // CHECK-LABEL: @test_mm_cmpeq_epu32_mask
   // CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}}
+  // CHECK: shufflevector <4 x i1> %{{.*}}, <4 x i1> zeroinitializer, <8 x 
i32> 
   return (__mmask8)_mm_cmpeq_epu32_mask(__a, __b);
 }



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

-
Intel Israel (74) Limited

This e-mail and any attachments may contain confidential material for
the sole use of the intended recipient(s). Any review or distribution
by others is strictly prohibited. If you are not the intended
recipient, please contact the sender and delete all copies.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r274110 - [AVX512] Zero extend cmp intrinsic return value.

2016-07-03 Thread Craig Topper via cfe-commits
Also should we change the AutoUpgrade code for the cmp intrinsics in the
backend to also use zero instead of undef?

~Craig

On Sun, Jul 3, 2016 at 12:11 AM, Breger, Igor  wrote:

> Hello Craig,
>
> Thanks a lot for pointing it out to me.  I familiar with this problem,  we
> are planning  to improve CodeGen to handle with this case in near future.
>
>
>
> Regards,
>
> Igor
>
>
>
> *From:* Craig Topper [mailto:craig.top...@gmail.com]
> *Sent:* Saturday, July 02, 2016 08:46
> *To:* Breger, Igor; Eric Christopher via cfe-commits
> *Subject:* Re: r274110 - [AVX512] Zero extend cmp intrinsic return value.
>
>
>
> This change codgens to something really awful now. Can you take a look?
>
>
>
> .section__TEXT,__text,regular,pure_instructions
>
> .section__TEXT,__literal8,8byte_literals
>
> .p2align   3
>
> LCPI0_0:
>
> .quad   -1
>
> .section__TEXT,__const
>
> .p2align   6
>
> LCPI0_1:
>
> .quad   0
>
> .quad   1
>
> .quad   2
>
> .quad   3
>
> .quad   8
>
> .quad   8
>
> .quad   8
>
> .quad   8
>
> .section__TEXT,__text,regular,pure_instructions
>
> .globl   _test_mm_cmpeq_epu32_mask
>
> .p2align   4, 0x90
>
> _test_mm_cmpeq_epu32_mask:
>
> vpcmpeqd   %xmm1, %xmm0, %k1
>
> vpbroadcastq   LCPI0_0(%rip), %zmm0 {%k1} {z}
>
> vpxord %zmm1, %zmm1, %zmm1
>
> vmovdqa64 LCPI0_1(%rip), %zmm2
>
> vpermt2q %zmm1, %zmm2, %zmm0
>
> vpsllq   $63, %zmm0, %zmm0
>
> vptestmq %zmm0, %zmm0, %k0
>
> kmovw%k0, %eax
>
> retq
>
>
> ~Craig
>
>
>
> On Wed, Jun 29, 2016 at 1:14 AM, Igor Breger via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Author: ibreger
> Date: Wed Jun 29 03:14:17 2016
> New Revision: 274110
>
> URL: http://llvm.org/viewvc/llvm-project?rev=274110&view=rev
> Log:
> [AVX512]  Zero extend cmp intrinsic return value.
>
> Differential Revision: http://reviews.llvm.org/D21746
>
> Modified:
> cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> cfe/trunk/test/CodeGen/avx512vl-builtins.c
>
> Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=274110&r1=274109&r2=274110&view=diff
>
> ==
> --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
> +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jun 29 03:14:17 2016
> @@ -6460,8 +6460,8 @@ static Value *EmitX86MaskedCompare(CodeG
>Indices[i] = i;
>  for (unsigned i = NumElts; i != 8; ++i)
>Indices[i] = NumElts;
> -Cmp = CGF.Builder.CreateShuffleVector(Cmp,
> UndefValue::get(Cmp->getType()),
> -  Indices);
> +Cmp = CGF.Builder.CreateShuffleVector(
> +Cmp, llvm::Constant::getNullValue(Cmp->getType()), Indices);
>}
>return CGF.Builder.CreateBitCast(Cmp,
> IntegerType::get(CGF.getLLVMContext(),
>
> Modified: cfe/trunk/test/CodeGen/avx512vl-builtins.c
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vl-builtins.c?rev=274110&r1=274109&r2=274110&view=diff
>
> ==
> --- cfe/trunk/test/CodeGen/avx512vl-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/avx512vl-builtins.c Wed Jun 29 03:14:17 2016
> @@ -8,6 +8,7 @@
>  __mmask8 test_mm_cmpeq_epu32_mask(__m128i __a, __m128i __b) {
>// CHECK-LABEL: @test_mm_cmpeq_epu32_mask
>// CHECK: icmp eq <4 x i32> %{{.*}}, %{{.*}}
> +  // CHECK: shufflevector <4 x i1> %{{.*}}, <4 x i1> zeroinitializer, <8
> x i32> 
>return (__mmask8)_mm_cmpeq_epu32_mask(__a, __b);
>  }
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
> -
> Intel Israel (74) Limited
>
> This e-mail and any attachments may contain confidential material for
> the sole use of the intended recipient(s). Any review or distribution
> by others is strictly prohibited. If you are not the intended
> recipient, please contact the sender and delete all copies.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics

2016-07-03 Thread Guy Blank via cfe-commits
guyblank created this revision.
guyblank added reviewers: aaboud, delena, craig.topper, AsafBadouh, 
m_zuckerman, igorb.
guyblank added a subscriber: cfe-commits.

[X86] Add xgetbv xsetbv intrinsics


http://reviews.llvm.org/D21959

Files:
  include/clang/Basic/BuiltinsX86.def
  lib/CodeGen/CGBuiltin.cpp
  lib/Headers/intrin.h
  lib/Headers/xsaveintrin.h
  test/CodeGen/builtins-x86.c
  test/CodeGen/x86_32-xsave.c
  test/CodeGen/x86_64-xsave.c

Index: test/CodeGen/x86_64-xsave.c
===
--- test/CodeGen/x86_64-xsave.c
+++ test/CodeGen/x86_64-xsave.c
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVE
 // RUN: %clang_cc1 %s -DTEST_XSAVE -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVE
 
+// RUN: %clang_cc1 %s -DTEST_XGETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XGETBV
+// RUN: %clang_cc1 %s -DTEST_XSETBV -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSETBV
+
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVEOPT
 // RUN: %clang_cc1 %s -DTEST_XSAVEOPT -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaveopt -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVEOPT
 
@@ -10,8 +13,14 @@
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVES
 // RUN: %clang_cc1 %s -DTEST_XSAVES -O0 -triple=x86_64-unknown-unknown -target-feature +xsave -target-feature +xsaves -fno-signed-char -emit-llvm -o - -Werror | FileCheck %s --check-prefix=XSAVES
 
+// Don't include mm_malloc.h, it's system specific.
+#define __MM_MALLOC_H
+#include 
+
+
 void test() {
   unsigned long long tmp_ULLi;
+  unsigned int   tmp_Ui;
   void*  tmp_vp;
 
 #ifdef TEST_XSAVE
@@ -46,6 +55,18 @@
 // XSAVE: [[low32_4:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_4]] to i32
 // XSAVE: call void @llvm.x86.xrstor64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]])
   (void)__builtin_ia32_xrstor64(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xsave
+  (void)_xsave(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xsave64
+  (void)_xsave64(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xrstor
+  (void)_xrstor(tmp_vp, tmp_ULLi);
+  
+// XSAVE: call void @llvm.x86.xrstor64
+  (void)_xrstor64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEOPT
@@ -64,6 +85,12 @@
 // XSAVEOPT: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32
 // XSAVEOPT: call void @llvm.x86.xsaveopt64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]])
   (void)__builtin_ia32_xsaveopt64(tmp_vp, tmp_ULLi);
+  
+// XSAVEOPT: call void @llvm.x86.xsaveopt
+  (void)_xsaveopt(tmp_vp, tmp_ULLi);
+  
+// XSAVEOPT: call void @llvm.x86.xsaveopt64
+  (void)_xsaveopt64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVEC
@@ -82,6 +109,12 @@
 // XSAVEC: [[low32_2:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_2]] to i32
 // XSAVEC: call void @llvm.x86.xsavec64(i8* [[tmp_vp_2]], i32 [[high32_2]], i32 [[low32_2]])
   (void)__builtin_ia32_xsavec64(tmp_vp, tmp_ULLi);
+  
+// XSAVEC: call void @llvm.x86.xsavec 
+  (void)_xsavec(tmp_vp, tmp_ULLi);
+  
+// XSAVEC: call void @llvm.x86.xsavec64
+  (void)_xsavec64(tmp_vp, tmp_ULLi);
 #endif
 
 #ifdef TEST_XSAVES
@@ -116,5 +149,39 @@
 // XSAVES: [[low32_4:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_4]] to i32
 // XSAVES: call void @llvm.x86.xrstors64(i8* [[tmp_vp_4]], i32 [[high32_4]], i32 [[low32_4]])
   (void)__builtin_ia32_xrstors64(tmp_vp, tmp_ULLi);
+  
+// XSAVES: call void @llvm.x86.xsaves
+  (void)_xsaves(tmp_vp, tmp_ULLi); 
+  
+// XSAVES: call void @llvm.x86.xsaves64
+  (void)_xsaves64(tmp_vp, tmp_ULLi); 
+
+// XSAVES: call void @llvm.x86.xrstors
+  (void)_xrstors(tmp_vp, tmp_ULLi);
+  
+// XSAVES: call void @llvm.x86.xrstors64
+  (void)_xrstors64(tmp_vp, tmp_ULLi);
+#endif
+
+#ifdef TEST_XGETBV
+// XGETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4
+// XGETBV: call i64 @llvm.x86.xgetbv(i32 [[tmp_Ui]])
+  tmp_ULLi = __builtin_ia32_xgetbv(tmp_Ui);
+  
+// XGETBV: call i64 @llvm.x86.xgetbv
+  tmp_ULLi = _xgetbv(tmp_Ui);
+#endif
+
+#ifdef TEST_XSETBV
+// XSETBV: [[tmp_Ui:%[0-9a-zA-z]+]] = load i32, i32* %tmp_Ui, align 4
+// XSETBV: [[tmp_ULLi_3:%[0-9a-zA-z]+]] = load i64, i64* %tmp_ULLi, align 8
+// XSETBV: [[high64_3:%[0-9a-zA-z]+]] = lshr i64 [[tmp_ULLi_3]], 32
+// XSETBV: [[high32_3:%[0-9a-zA-z]+]] = trunc i64 [[high64_3]] to i32
+// XSETBV: [[low32_3:%[0-9a-zA-z]+]] = trunc i64 [[tmp_ULLi_3]] to i32
+// XSE

Re: [PATCH] D21823: [Driver] Add flags for enabling both types of PGO Instrumentation

2016-07-03 Thread Sean Silva via cfe-commits
On Sat, Jul 2, 2016 at 7:38 PM, Xinliang David Li 
wrote:

> Sanitizers are different IMO. Different santizers are rather independent,
> and there is no such thing as -fsantize to mean -fsantize=all
>
> For PGO, in most of the cases, users do not need to care about the
> sub-options implied -- by default they should just get the best profiling
> (whatever that is). Fine-grained control is more useful for savvy users.
> Besides, any flavor of value profiling usually does not make sense to be
> used standalone and need to be used with edge profiling for max benefit
> (also not supported in our implementation) - so I don't see why pgo control
> needs to be done in a way similar to sanitizers.
>

Thanks for the explanation. So I think we can start by reducing this patch
to just `-fpgo-train` (enables IRPGO), `-fpgo-train-file=`, and
`-fpgo-apply=`.

While -fpgo-apply= is technically redundant with -fprofile-instr-use, I
think it is useful for consistency.

I'm also indifferent to adding `-fpgo-train=source`/`-fpgo-train=optimizer`
in this patch.

btw, I don't understand the intuition for calling IRPGO "cfg"; maybe you
could explain?
I like "optimizer" because it is easy to document to users, as users
generally understand the difference between the "optimizer" and
source-level analysis of their program. For example, we could document:
"-fpgo-train=source instruments at source-level similar to code coverage
instrumentation. -fpgo-train=optimizer applies the instrumentation inside
the optimizer and has freedom to do sophisticated analyses and
transformations as part of the instrumentation process; these analyses and
transformations allow it to reduce instrumentation overhead and increase
profile accuracy."


-- Sean Silva


>
>  In other words, I don't think the primary option -fpgo-train should be
> used for fine-grain suboption control.   If we have a different option to
> do fine-grain control for PGO, using sanitize like syntax is fine with me:
>
> -fpgo-xxx=y:z  turn on y and z for pgo
> -fno-pgo-xxx=y:z  turn off y and z for pgo
> or
> -fpgo-xxx=no-w:no-y:z   turn on z but turn off w, and y
>
>
> David
>
>
> On Sat, Jul 2, 2016 at 6:45 PM, Sean Silva  wrote:
>
>>
>>
>> On Sat, Jul 2, 2016 at 1:57 PM, Xinliang David Li 
>> wrote:
>>
>>>
>>>
>>> On Fri, Jul 1, 2016 at 4:32 PM, Sean Silva 
>>> wrote:
>>>
 silvas added inline comments.

 
 Comment at: lib/Driver/Tools.cpp:3560
 @@ +3559,3 @@
 +if (PGOTrainArg->getOption().matches(options::OPT_fpgo_train_EQ)) {
 +  if (StringRef(PGOTrainArg->getValue()) == "source-cfg")
 +CmdArgs.push_back("-fprofile-instrument=clang");
 
 davidxl wrote:
 > I think it is better to make the selector  'source' vs 'cfg'.
 >
 > -fpgo-train=source
 > -fpgo-train=cfg
 So would `-fpgo-train=cfg` enable icall instrumentation or not?

 My thinking is that down the road we will have one flag for each
 independent instrumentation capability (and of course some are mutually
 incompatible). This mirrors what the sanitizers do. For example, we would
 have:
 `-fpgo-train=optimizer-cfg` --> IR edge profiling
 `-fpgo-train=optimizer-icall` --> IR icall value profiling
 `-fpgo-train=optimizer-...` --> other independent instrumentation we
 can do in IR instrumentation.
 `-fpgo-train=source-cfg` --> FE edge profiling
 `-fpgo-train=source-icall` --> FE icall profiling (if that even exists;
 I see some code but there is no user-visible flag)
 `-fpgo-train=source-...` --> other FE instrumentation.

 We can then have `-fpgo-train=optimizer` enable e.g.
 `-fpgo-train=optimizer-cfg,optimizer-icall`.
 We can also have `-fpgo-train=source` enable e.g.
 `-fpgo-train=source-cfg`.

 Since instrumentation can have different overheads or different runtime
 requirements, users may want to disable some instrumentation.


>>>
>>> -fpgo-train is the new umbrella option that turn on at least edge
>>> profiling and some other flavor of value profiling (icall, or stringop, etc
>>> in the the future). There is a default setting for source or cfg based PGO.
>>> The fine grain control of each sub-option should be done via a different
>>> flag -- otherwise we will have to introduce 2 x N sub-options if used with
>>> -fpgo-train.  In other words, -fpgo-train=cfg turns on edge and icall
>>> profiling as of today.
>>>
>>> To summarize, I think the following behavior will be nice to users:
>>>
>>> 1) -fpgo-train when used without any option, it defaults to IR pgo
>>> (since it is new option)
>>> 2) -fpgo-train=cfg (or some other name) turns on IR pgo
>>> 3) -fpgo-train=source turns on FE pgo
>>>
>>> 4) -fpgo-control=edge:icall to turn on edge profiling and icall
>>> profiling. Edge will be turn on by default always, so it is redundant to
>>> specify. To turn icall off:
>>> -fpgo-control=^icall
>>>
>>
>> We have a precedent fr

[PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-07-03 Thread Alexander Droste via cfe-commits
Alexander_Droste created this revision.
Alexander_Droste added a reviewer: alexfh.
Alexander_Droste added a subscriber: cfe-commits.

This check verifies if buffer type and MPI (Message Passing Interface)
datatype pairs match. All MPI datatypes defined by the MPI standard (3.1)
are verified by this check. User defined typedefs, custom MPI datatypes and
null pointer constants are skipped, in the course of verification.


http://reviews.llvm.org/D21962

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-mpi-type-mismatch.rst
  test/clang-tidy/misc-mpi-type-mismatch.cpp

Index: test/clang-tidy/misc-mpi-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-mpi-type-mismatch.cpp
@@ -0,0 +1,249 @@
+// RUN: %check_clang_tidy %s misc-mpi-type-mismatch %t
+
+// #include "clang/../../test/Analysis/MPIMock.h"
+#include "/Users/lx/Documents/Text/Code/Open_Source/llvm_trunk_git/repo/tools/clang/test/Analysis/MPIMock.h"
+
+void charNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int buf2;
+  MPI_Send(&buf2, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+}
+
+void intNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+}
+
+void longNegativeTest() {
+  char buf;
+  MPI_Send(&buf, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'char' does not match the MPI datatype 'MPI_LONG'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+ 

Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-07-03 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

Hi Alexander,

this is the check that verifies buffer type / MPI datatype inconsistencies
that was originally part of http://reviews.llvm.org/D12761.



Comment at: docs/clang-tidy/checks/list.rst:63
@@ -62,2 +62,3 @@
misc-inefficient-algorithm
+   misc-m-p-i-type-mismatch
misc-macro-parentheses

Will be removed.


Comment at: test/clang-tidy/misc-mpi-type-mismatch.cpp:3
@@ +2,3 @@
+
+// #include "clang/../../test/Analysis/MPIMock.h"
+#include 
"/Users/lx/Documents/Text/Code/Open_Source/llvm_trunk_git/repo/tools/clang/test/Analysis/MPIMock.h"

This header needs to moved but I need some guidance where to put it so that the 
test file can access it. Using relative paths within the `include` seems not to 
be possible.


http://reviews.llvm.org/D21962



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


r274475 - [AST] Use ArrayRef in more interfaces

2016-07-03 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sun Jul  3 16:17:51 2016
New Revision: 274475

URL: http://llvm.org/viewvc/llvm-project?rev=274475&view=rev
Log:
[AST] Use ArrayRef in more interfaces

ArrayRef is a little better than passing around a pointer/length pair.

No functional change is intended.

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=274475&r1=274474&r2=274475&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Sun Jul  3 16:17:51 2016
@@ -184,7 +184,7 @@ class TemplateArgumentList final
 
   // Constructs an instance with an internal Argument list, containing
   // a copy of the Args array. (Called by CreateCopy)
-  TemplateArgumentList(const TemplateArgument *Args, unsigned NumArgs);
+  TemplateArgumentList(ArrayRef Args);
 
 public:
   /// \brief Type used to indicate that the template argument list itself is a
@@ -194,16 +194,14 @@ public:
   /// \brief Create a new template argument list that copies the given set of
   /// template arguments.
   static TemplateArgumentList *CreateCopy(ASTContext &Context,
-  const TemplateArgument *Args,
-  unsigned NumArgs);
+  ArrayRef Args);
 
   /// \brief Construct a new, temporary template argument list on the stack.
   ///
   /// The template argument list does not own the template arguments
   /// provided.
-  explicit TemplateArgumentList(OnStackType, const TemplateArgument *Args,
-unsigned NumArgs)
-  : Arguments(Args), NumArguments(NumArgs) {}
+  explicit TemplateArgumentList(OnStackType, ArrayRef Args)
+  : Arguments(Args.data()), NumArguments(Args.size()) {}
 
   /// \brief Produces a shallow copy of the given template argument list.
   ///
@@ -1583,8 +1581,7 @@ protected:
   DeclContext *DC, SourceLocation StartLoc,
   SourceLocation IdLoc,
   ClassTemplateDecl *SpecializedTemplate,
-  const TemplateArgument *Args,
-  unsigned NumArgs,
+  ArrayRef Args,
   ClassTemplateSpecializationDecl *PrevDecl);
 
   explicit ClassTemplateSpecializationDecl(ASTContext &C, Kind DK);
@@ -1594,8 +1591,7 @@ public:
   Create(ASTContext &Context, TagKind TK, DeclContext *DC,
  SourceLocation StartLoc, SourceLocation IdLoc,
  ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef Args,
  ClassTemplateSpecializationDecl *PrevDecl);
   static ClassTemplateSpecializationDecl *
   CreateDeserialized(ASTContext &C, unsigned ID);
@@ -1811,8 +1807,7 @@ class ClassTemplatePartialSpecialization
  SourceLocation IdLoc,
  TemplateParameterList *Params,
  ClassTemplateDecl 
*SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef Args,
const ASTTemplateArgumentListInfo 
*ArgsAsWritten,
ClassTemplatePartialSpecializationDecl 
*PrevDecl);
 
@@ -1827,8 +1822,7 @@ public:
  SourceLocation StartLoc, SourceLocation IdLoc,
  TemplateParameterList *Params,
  ClassTemplateDecl *SpecializedTemplate,
- const TemplateArgument *Args,
- unsigned NumArgs,
+ ArrayRef Args,
  const TemplateArgumentListInfo &ArgInfos,
  QualType CanonInjectedType,
  ClassTemplatePartialSpecializationDecl *PrevDecl);
@@ -2442,8 +2436,8 @@ protected:
 SourceLocation StartLoc, SourceLocation IdLoc,
 VarTemplateDecl *SpecializedTemplate,
 QualType T, TypeSourceInfo *TInfo,
-StorageClass S, const TemplateArgument *Args,
-unsigned NumArgs);
+StorageClass S,
+ArrayRef Args);
 
   explicit VarTemplateSpecializationDecl(Kind DK, ASTContext &Context);
 
@@ -2451,8 +2445,8 @@ public:
   static V

Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-07-03 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 62638.
Alexander_Droste added a comment.

- change comment style to LLVM style
- remove 'misc-m-p-i-type-mismatch' entry from `list.rst` 
(misc-mpi-type-mismatch is the correct one)


http://reviews.llvm.org/D21962

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-mpi-type-mismatch.rst
  test/clang-tidy/misc-mpi-type-mismatch.cpp

Index: test/clang-tidy/misc-mpi-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-mpi-type-mismatch.cpp
@@ -0,0 +1,249 @@
+// RUN: %check_clang_tidy %s misc-mpi-type-mismatch %t
+
+// #include "clang/../../test/Analysis/MPIMock.h"
+#include "/Users/lx/Documents/Text/Code/Open_Source/llvm_trunk_git/repo/tools/clang/test/Analysis/MPIMock.h"
+
+void charNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int buf2;
+  MPI_Send(&buf2, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+}
+
+void intNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+}
+
+void longNegativeTest() {
+  char buf;
+  MPI_Send(&buf, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'char' does not match the MPI datatype 'MPI_LONG'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned int' does not match the MPI datatype 'MPI_LONG'. [misc-mpi-type-mismatch]
+  
+  unsigned short buf3;
+  MPI_Send(&buf3, 1, M

Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-07-03 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 62639.
Alexander_Droste added a comment.

- fix some comments


http://reviews.llvm.org/D21962

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-mpi-type-mismatch.rst
  test/clang-tidy/misc-mpi-type-mismatch.cpp

Index: test/clang-tidy/misc-mpi-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-mpi-type-mismatch.cpp
@@ -0,0 +1,249 @@
+// RUN: %check_clang_tidy %s misc-mpi-type-mismatch %t
+
+// #include "clang/../../test/Analysis/MPIMock.h"
+#include "/Users/lx/Documents/Text/Code/Open_Source/llvm_trunk_git/repo/tools/clang/test/Analysis/MPIMock.h"
+
+void charNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int buf2;
+  MPI_Send(&buf2, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+}
+
+void intNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+}
+
+void longNegativeTest() {
+  char buf;
+  MPI_Send(&buf, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'char' does not match the MPI datatype 'MPI_LONG'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned int' does not match the MPI datatype 'MPI_LONG'. [misc-mpi-type-mismatch]
+  
+  unsigned short buf3;
+  MPI_Send(&buf3, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned short' does not ma

Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-07-03 Thread Alexander Droste via cfe-commits
Alexander_Droste updated this revision to Diff 62640.
Alexander_Droste added a comment.

- fix comments


http://reviews.llvm.org/D21962

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.cpp
  clang-tidy/misc/MpiTypeMismatchCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-mpi-type-mismatch.rst
  test/clang-tidy/misc-mpi-type-mismatch.cpp

Index: test/clang-tidy/misc-mpi-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-mpi-type-mismatch.cpp
@@ -0,0 +1,249 @@
+// RUN: %check_clang_tidy %s misc-mpi-type-mismatch %t
+
+// #include "clang/../../test/Analysis/MPIMock.h"
+#include "/Users/lx/Documents/Text/Code/Open_Source/llvm_trunk_git/repo/tools/clang/test/Analysis/MPIMock.h"
+
+void charNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int buf2;
+  MPI_Send(&buf2, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_CHAR'. [misc-mpi-type-mismatch]
+}
+
+void intNegativeTest() {
+  unsigned char buf;
+  MPI_Send(&buf, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned char' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  short buf3;
+  MPI_Send(&buf3, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'short' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long buf4;
+  MPI_Send(&buf4, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+  
+  int8_t buf5;
+  MPI_Send(&buf5, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'int8_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  uint16_t buf6;
+  MPI_Send(&buf6, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'uint16_t' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  long double _Complex buf7;
+  MPI_Send(&buf7, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'long double _Complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+
+  std::complex buf8;
+  MPI_Send(&buf8, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'complex' does not match the MPI datatype 'MPI_INT'. [misc-mpi-type-mismatch]
+}
+
+void longNegativeTest() {
+  char buf;
+  MPI_Send(&buf, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'char' does not match the MPI datatype 'MPI_LONG'. [misc-mpi-type-mismatch]
+  
+  unsigned buf2;
+  MPI_Send(&buf2, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned int' does not match the MPI datatype 'MPI_LONG'. [misc-mpi-type-mismatch]
+  
+  unsigned short buf3;
+  MPI_Send(&buf3, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: Buffer type 'unsigned short' does not match t

r274477 - [Sema] A flexible array member must not be the only named member

2016-07-03 Thread David Majnemer via cfe-commits
Author: majnemer
Date: Sun Jul  3 19:24:59 2016
New Revision: 274477

URL: http://llvm.org/viewvc/llvm-project?rev=274477&view=rev
Log:
[Sema] A flexible array member must not be the only named member

We didn't correctly detect situations where a flexible array member was
the only named member in a record.

This fixes PR28407.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/Sema/MicrosoftExtensions.c

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=274477&r1=274476&r2=274477&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Sun Jul  3 19:24:59 2016
@@ -13952,14 +13952,12 @@ void Sema::ActOnFields(Scope *S, SourceL
  : getLangOpts().CPlusPlus
? diag::ext_flexible_array_union_gnu
: diag::err_flexible_array_union;
-  else if (Fields.size() == 1)
+  else if (NumNamedMembers < 1)
 DiagID = getLangOpts().MicrosoftExt
  ? diag::ext_flexible_array_empty_aggregate_ms
  : getLangOpts().CPlusPlus
? diag::ext_flexible_array_empty_aggregate_gnu
-   : NumNamedMembers < 1
- ? diag::err_flexible_array_empty_aggregate
- : 0;
+   : diag::err_flexible_array_empty_aggregate;
 
   if (DiagID)
 Diag(FD->getLocation(), DiagID) << FD->getDeclName()

Modified: cfe/trunk/test/Sema/MicrosoftExtensions.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/MicrosoftExtensions.c?rev=274477&r1=274476&r2=274477&view=diff
==
--- cfe/trunk/test/Sema/MicrosoftExtensions.c (original)
+++ cfe/trunk/test/Sema/MicrosoftExtensions.c Sun Jul  3 19:24:59 2016
@@ -6,6 +6,12 @@ struct A
int a[];  /* expected-warning {{flexible array member 'a' in otherwise 
empty struct is a Microsoft extension}} */
 };
 
+struct PR28407
+{
+  int : 1;
+  int a[]; /* expected-warning {{flexible array member 'a' in otherwise empty 
struct is a Microsoft extension}} */
+};
+
 struct C {
int l;
union {


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


Trivial comment updates: include/clang/Lex/PPCallbacks.h, docs/pp-trace.rst (clang-tools-extra)

2016-07-03 Thread via cfe-commits
 

Delete "param MD The MacroDefinition if the name was a macro, null
otherwise.". 

Reason: MD, a reference, can't be null. 

 Index: include/clang/Lex/PPCallbacks.h
===
--- include/clang/Lex/PPCallbacks.h	(revision 274481)
+++ include/clang/Lex/PPCallbacks.h	(working copy)
@@ -256,7 +256,6 @@
   }
   
   /// \brief Hook called whenever the 'defined' operator is seen.
-  /// \param MD The MacroDirective if the name was a macro, null otherwise.
   virtual void Defined(const Token &MacroNameTok, const MacroDefinition &MD,
SourceRange Range) {
   }
@@ -294,7 +293,6 @@
   /// \brief Hook called whenever an \#ifdef is seen.
   /// \param Loc the source location of the directive.
   /// \param MacroNameTok Information on the token being tested.
-  /// \param MD The MacroDefinition if the name was a macro, null otherwise.
   virtual void Ifdef(SourceLocation Loc, const Token &MacroNameTok,
  const MacroDefinition &MD) {
   }
@@ -302,7 +300,6 @@
   /// \brief Hook called whenever an \#ifndef is seen.
   /// \param Loc the source location of the directive.
   /// \param MacroNameTok Information on the token being tested.
-  /// \param MD The MacroDefiniton if the name was a macro, null otherwise.
   virtual void Ifndef(SourceLocation Loc, const Token &MacroNameTok,
   const MacroDefinition &MD) {
   }
Index: docs/pp-trace.rst
===
--- docs/pp-trace.rst	(revision 274481)
+++ docs/pp-trace.rst	(working copy)
@@ -571,7 +571,7 @@
 `MacroExpands `_ Callback
 ^
 
-MacroExpands is called when ::HandleMacroExpandedIdentifier when a macro invocation is found.
+MacroExpands is called when a macro invocation is found.
 
 Argument descriptions:
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits