[PATCH] D86065: [SVE] Make ElementCount members private

2020-08-27 Thread David Sherwood via Phabricator via cfe-commits
david-arm added a comment.

Hi @ctetreau, ok for now I'm going to completely remove the operators and 
revert the code using those operators to how it was before. I'm not sure what 
you mean about the predicate functions so I've left those for now, since they 
aren't needed for this patch. The purpose of this patch was originally supposed 
to be mechanical anyway - just making members private. I only added the 
operators as an after-thought really, just to be consistent with how TypeSize 
dealt with the identical problem. For what it's worth, I believe that GCC 
solved this exact same problem by adding two types of comparison functions - 
one set that absolutely wanted an answer to ">,<,>=,<=" and asserted if it 
wasn't known at compile time, and another set of comparison functions that 
returned an additional boolean value indicating whether the answer was known or 
not. Perhaps my knowledge is out of date, but I believe this was the accepted 
solution and seemed to work well.


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

https://reviews.llvm.org/D86065

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


[PATCH] D85474: Add -fbinutils-version= to gate ELF features on the specified binutils version

2020-08-27 Thread James Henderson via Phabricator via cfe-commits
jhenderson added a comment.

This looks reasonable to me, but I don't know the surrounding code well enough 
to be comfortable LGTM-ing it. Sorry!




Comment at: llvm/include/llvm/MC/MCAsmInfo.h:387
 
+  // Generated object files can only use features support by GNU ld of this
+  // binutils version.

This sentence implies this specific version, but I think it's meant to be a 
minimum. If so, I'd add "or later" to the end of the sentence.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85474

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


[PATCH] D86488: [X86] Default to -mtune=generic unless -march is passed to the driver. Add TuneCPU to the AST serialization

2020-08-27 Thread Nikita Popov via Phabricator via cfe-commits
nikic added a comment.

This change has a 0.3% compile-time regression 
(https://llvm-compile-time-tracker.com/compare.php?from=0c55889d809027136048a0d144209a2bc282e7fc&to=71f3169e1baeff262583b35ef88f8fb6df7be85e&stat=instructions)
 and a 0.3% max-rss regression 
(https://llvm-compile-time-tracker.com/compare.php?from=0c55889d809027136048a0d144209a2bc282e7fc&to=71f3169e1baeff262583b35ef88f8fb6df7be85e&stat=max-rss).

Is that expected? The diff looks pretty harmless to me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86488

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


[PATCH] D86660: Modifying ImportDeclContext(...) to ensure that we also handle the case when the FieldDecl is an ArrayType whose ElementType is a RecordDecl

2020-08-27 Thread Pavel Labath via Phabricator via cfe-commits
labath added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:1755-1759
+  QualType FromTy = ArrayFrom->getElementType();
+  QualType ToTy = ArrayTo->getElementType();
+
+  FromRecordDecl = FromTy->getAsRecordDecl();
+  ToRecordDecl = ToTy->getAsRecordDecl();

What about 2- or n-dimensional arrays?



Comment at: 
lldb/test/API/commands/expression/codegen-crash-import-def-arraytype-element/main.cpp:22-27
+  union {
+struct {
+  unsigned char *_s;
+} t;
+char *tt[1];
+  } U;

What's the significance of this union?


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

https://reviews.llvm.org/D86660

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


[PATCH] D86668: Fix Calling Convention of __float128 and long double(128bits) in i386

2020-08-27 Thread Bing Yu via Phabricator via cfe-commits
yubing updated this revision to Diff 288218.
yubing added a comment.

Modify a testcase: clang/test/CodeGenCXX/float128-declarations.cpp


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86668

Files:
  clang/lib/CodeGen/TargetInfo.cpp
  clang/test/CodeGen/x86-long-double.cpp
  clang/test/CodeGen/x86_32-fp128-call-conv-linux.c
  clang/test/CodeGenCXX/float128-declarations.cpp

Index: clang/test/CodeGenCXX/float128-declarations.cpp
===
--- clang/test/CodeGenCXX/float128-declarations.cpp
+++ clang/test/CodeGenCXX/float128-declarations.cpp
@@ -3,7 +3,7 @@
 // RUN: %clang_cc1 -emit-llvm -triple powerpc64le-unknown-unknown \
 // RUN:   -target-feature +float128 -std=c++11 %s -o - | FileCheck %s
 // RUN: %clang_cc1 -emit-llvm -triple i386-unknown-linux-gnu -std=c++11 \
-// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
+// RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86-32-LINUX
 // RUN: %clang_cc1 -emit-llvm -triple x86_64-unknown-linux-gnu -std=c++11 \
 // RUN:   %s -o - | FileCheck %s -check-prefix=CHECK-X86
 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-openbsd -std=c++11 \
@@ -123,3 +123,25 @@
 // CHECK-X86-DAG: [[F4L:%[a-z0-9]+]] = load fp128, fp128* %f4l
 // CHECK-X86-DAG: [[INC:%[a-z0-9]+]] = fadd fp128 [[F4L]], 0xL3FFF
 // CHECK-X86-DAG: store fp128 [[INC]], fp128* %f4l
+
+// CHECK-X86-32-LINUX-DAG: @_ZN12_GLOBAL__N_13f1nE = internal global fp128 0xL
+// CHECK-X86-32-LINUX-DAG: @_ZN12_GLOBAL__N_13f2nE = internal global fp128 0xL40040800
+// CHECK-X86-32-LINUX-DAG: @_ZN12_GLOBAL__N_15arr1nE = internal global [10 x fp128]
+// CHECK-X86-32-LINUX-DAG: @_ZN12_GLOBAL__N_15arr2nE = internal global [3 x fp128] [fp128 0xL3FFF, fp128 0xL40008000, fp128 0xL4025176592E0]
+// CHECK-X86-32-LINUX-DAG: define internal fp128 @_ZN12_GLOBAL__N_16func1nERKg(fp128*
+// CHECK-X86-32-LINUX-DAG: @f1f = global fp128 0xL
+// CHECK-X86-32-LINUX-DAG: @f2f = global fp128 0xL40040333
+// CHECK-X86-32-LINUX-DAG: @arr1f = global [10 x fp128]
+// CHECK-X86-32-LINUX-DAG: @arr2f = global [3 x fp128] [fp128 0xLBFFF, fp128 0xLC0008000, fp128 0xLC025176592E0]
+// CHECK-X86-32-LINUX-DAG: declare fp128 @_Z6func1fg(fp128* byval(fp128) align 16) #3
+// CHECK-X86-32-LINUX-DAG: define linkonce_odr void @_ZN2C1C2Eg(%class.C1* %this, fp128* byval(fp128) align 16 %0)
+// CHECK-X86-32-LINUX-DAG: define linkonce_odr fp128 @_ZN2C16func2cEg(fp128* byval(fp128) align 16 %0)
+// CHECK-X86-32-LINUX-DAG: define linkonce_odr fp128 @_Z6func1tIgET_S0_(fp128* byval(fp128) align 16 %0)
+// CHECK-X86-32-LINUX-DAG: @__const.main.s1 = private unnamed_addr constant %struct.S1 { fp128 0xL40060800 }
+// CHECK-X86-32-LINUX-DAG: store fp128 0xLF0AFD0EBFF292DCE42E0B38CDD83F26F, fp128* %f1l, align 16
+// CHECK-X86-32-LINUX-DAG: store fp128 0xL8000, fp128* %f2l, align 16
+// CHECK-X86-32-LINUX-DAG: store fp128 0xL7FFE, fp128* %f3l, align 16
+// CHECK-X86-32-LINUX-DAG: store fp128 0xLBFFF, fp128* %f5l, align 16
+// CHECK-X86-32-LINUX-DAG: [[F4L:%[a-z0-9]+]] = load fp128, fp128* %f4l
+// CHECK-X86-32-LINUX-DAG: [[INC:%[a-z0-9]+]] = fadd fp128 [[F4L]], 0xL3FFF
+// CHECK-X86-32-LINUX-DAG: store fp128 [[INC]], fp128* %f4l
Index: clang/test/CodeGen/x86_32-fp128-call-conv-linux.c
===
--- /dev/null
+++ clang/test/CodeGen/x86_32-fp128-call-conv-linux.c
@@ -0,0 +1,28 @@
+// RUN: %clang_cc1 -mlong-double-128 -w -fblocks -ffreestanding -triple i386-pc-linux-gnu -emit-llvm -o %t %s || FileCheck < %t %s
+
+
+// CHECK-LABEL: define void @testfp128
+// CHECK-NEXT:  %a.addr = alloca fp128, align 16
+// CHECK-NEXT:  %a = load fp128, fp128* %0, align 16
+// CHECK-NEXT:  store fp128 %a, fp128* %a.addr, align 16
+void testfp128(__float128 a) {
+  return;
+}
+
+// CHECK-LABEL: define void @testlongdouble
+// CHECK-NEXT:  %a.addr = alloca fp128, align 16
+// CHECK-NEXT:  %a = load fp128, fp128* %0, align 16
+// CHECK-NEXT:  store fp128 %a, fp128* %a.addr, align 16
+void testlongdouble(long double a) {
+  return;
+}
+
+// CHECK-LABEL: define void @testPassArguments
+// CHECK:   call void @testfp128(fp128* byval(fp128) align 16 %{{.*}})
+// CHECK:   call void @testlongdouble(fp128* byval(fp128) align 16 %{{.*}})
+void testPassArguments() {
+  __float128 a=1.0;
+  testfp128(a);
+  testlongdouble(a);
+  return;
+}
Index: clang/test/CodeGen/x86-long-double.cpp
===
--- clang/test/CodeGen/x86-long-do

[PATCH] D86488: [X86] Default to -mtune=generic unless -march is passed to the driver. Add TuneCPU to the AST serialization

2020-08-27 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

In D86488#2241176 , @nikic wrote:

> This change has a 0.3% compile-time regression 
> (https://llvm-compile-time-tracker.com/compare.php?from=0c55889d809027136048a0d144209a2bc282e7fc&to=71f3169e1baeff262583b35ef88f8fb6df7be85e&stat=instructions)
>  and a 0.3% max-rss regression 
> (https://llvm-compile-time-tracker.com/compare.php?from=0c55889d809027136048a0d144209a2bc282e7fc&to=71f3169e1baeff262583b35ef88f8fb6df7be85e&stat=max-rss).
>
> Is that expected? The diff looks pretty harmless to me.

No it wasnt expected. There was already a comment on the commit about it. The 
settings it’s selecting should match the default we get with no -march on 
Linux. The only thing I’ve found so far is extra time to read the function 
attribute from getSubtargetImpl which happen every time getTTI is called. And 
extra time to add the function attribute in clang. The strange thing is it 
seems to have regressed O0 even so that rules out a lot of optimization related 
code. Any information you can provide would be helpful.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86488

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


[PATCH] D82657: [AST][RecoveryAST] Preserve the type by default for recovery expression.

2020-08-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D82657#2240603 , @vvereschaka wrote:

> Hi @hokein,
>
> sorry, but looks like your changes break one of libc++ tests on ARM cross 
> toolchain build on Windows: `libc++::function_type_default_deleter.fail.cpp`
> Here is the first failed build: 
> http://lab.llvm.org:8011/builders/llvm-clang-win-x-armv7l/builds/945
>
> I didn't get how these changes affects the failing test, but reverting of 
> your commit fixes the problem.
>
> Would you take a look and fix the problem? or revert the changes if it is 
> going to take a lot of time to resolve?
>
> Here is the command line to build the test:
>
>   C:/buildbot/temp/build/./bin/clang++.exe 
> C:/buildbot/temp/llvm-project/libcxx/test/libcxx/utilities/memory/util.smartptr/util.smartptr.shared/function_type_default_deleter.fail.cpp
>  -v --sysroot=C:/buildbot/.arm-ubuntu --target=armv7-linux-gnueabihf -include 
> C:/buildbot/temp/build/runtimes/runtimes-bins/libcxx\__config_site -include 
> C:/buildbot/temp/llvm-project/libcxx\test\support\nasty_macros.h -nostdinc++ 
> -IC:/buildbot/temp/llvm-project/libcxx\include 
> -IC:/buildbot/temp/build/runtimes/runtimes-bins/libcxx\include\c++build 
> -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -D__STDC_CONSTANT_MACROS 
> -IC:/buildbot/temp/llvm-project/libcxx\test/support -Werror -Wall -Wextra 
> -D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -Wshadow 
> -Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
> -Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type 
> -Wno-atomic-alignment -Wsign-compare -Wunused-variable -Wunused-parameter 
> -Wunreachable-code -Wno-unused-local-typedef -std=c++2a -fcoroutines-ts 
> -Werror=thread-safety -Wuser-defined-warnings -fsyntax-only -Wno-error 
> -Xclang -verify -Xclang -verify-ignore-unexpected=note -ferror-limit=0
>
> Here is the result output:
>
>   clang -cc1 version 12.0.0 based upon LLVM 12.0.0git default target 
> armv7-linux-gnueabihf
>   ignoring nonexistent directory "C:/buildbot/.arm-ubuntu/usr/local/include"
>   ignoring nonexistent directory "C:/buildbot/.arm-ubuntu/include"
>   #include "..." search starts here:
>   #include <...> search starts here:
>C:/buildbot/temp/llvm-project/libcxx\include
>C:/buildbot/temp/build/runtimes/runtimes-bins/libcxx\include\c++build
>C:/buildbot/temp/llvm-project/libcxx\test/support
>C:\buildbot\temp\build\lib\clang\12.0.0\include
>C:/buildbot/.arm-ubuntu/usr/include/arm-linux-gnueabihf
>C:/buildbot/.arm-ubuntu/usr/include
>   End of search list.
>   error: 'error' diagnostics seen but not expected:
> File C:/buildbot/temp/llvm-project/libcxx\include\memory Line 2033: no 
> member named 'value' in 'std::__1::is_empty   (*)(Tag<5>), std::__1::default_delete)>>>'
>   1 error generated.

thanks! I have a proposal fix in D86685 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D82657

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


[PATCH] D86668: Fix Calling Convention of __float128 and long double(128bits) in i386

2020-08-27 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/lib/CodeGen/TargetInfo.cpp:1603
+  if (IsLinuxABI && Ty->isFloatingType() && getContext().getTypeSize(Ty) == 
128)
+return 16;
+

I don't think this should be restricted to just Linux.  It's a fix for all OSes 
that support `__float128`, i.e. Haiku, Linux, OpenBSD, and Solaris.

It would be better to check the floating-point semantics rather than relying on 
the type size, since the type size could easily be rounded up to 128 for 
alignment reasons.

Should this also apply to structs containing `__float128`, the same way that 
SIMD does below?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86668

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


[PATCH] D85176: [Coverage] Enable emitting gap area between macros

2020-08-27 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

We started seeing assertion failure after rolling a toolchain that contains 
this change and `git bisect` identified this change. I have filed a bug with a 
reproducer as PR47324.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85176

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


[PATCH] D86146: [ARM][BFloat16] Change types of some Arm and AArch64 bf16 intrinsics

2020-08-27 Thread Dave Green via Phabricator via cfe-commits
dmgreen accepted this revision.
dmgreen added a comment.
This revision is now accepted and ready to land.

Thanks. LGTM.




Comment at: llvm/include/llvm/IR/IntrinsicsAArch64.td:473
   def int_aarch64_neon_bfdot : AdvSIMD_Dot_Intrinsic;
-  def int_aarch64_neon_bfmmla : AdvSIMD_MatMul_Intrinsic;
-  def int_aarch64_neon_bfmlalb : AdvSIMD_FML_Intrinsic;
-  def int_aarch64_neon_bfmlalt : AdvSIMD_FML_Intrinsic;
+  def int_aarch64_neon_bfmmla
+: Intrinsic<[llvm_v4f32_ty],

This can be a AdvSIMD_BF16FML_Intrinsic?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86146

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


[PATCH] D86581: [clang-format] Handle shifts within conditions

2020-08-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

I think this LGTM and the solution is much more elegant than mine! You were not 
stepping on my toes, I'm always happy for someone else to take things over and 
this is a much smarter solution than mine.

This bug has been reported multiple times I think this is a good first step 
towards a solution, and I don't think "perfection should be the enemy of good", 
I think for most cases this will suffice.

anything else more obtuse I wonder why people write code in that form when its 
hard for the non author to read, but we can address those cases when we hit 
them.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86581

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


[PATCH] D86632: [Fixed Point] Add codegen for conversion between fixed-point and floating point.

2020-08-27 Thread Bevin Hansson via Phabricator via cfe-commits
ebevhan added inline comments.



Comment at: llvm/include/llvm/IR/FixedPointBuilder.h:171-172
+// lossless, except for overflow to infinity which is unlikely.
+return B.CreateFMul(Result,
+ConstantFP::get(DstTy, std::pow(2, -(int)SrcSema.getScale(;
+  }

leonardchan wrote:
> Was there a reason for preferring multiplying by the reciprocal instead of 
> dividing by a power of 2?
> 
> I think this was discussed before, but can't seem to remember/find the 
> conversation.
Multiplication should be more efficient than division with the same effect.

However, as @rjmccall mentioned in D54749, this rescaling might not work if the 
exponent is not large enough to fit the scaled value. This is unlikely for 
single precision float and larger formats, but it probably won't work for half 
precision.

I'm not entirely sure what to do about that. I was originally planning on 
adding an intrinsic that did pretty much the same thing as the one in that 
patch, but with a scaling factor. However, I figured that it would not be 
necessary when I noticed that an integer intrinsic was already in the works.

It feels odd to have intrinsics that do pretty much the same thing as another 
intrinsic but with an internal multiplication baked in. On top of that, it 
would require adding 4 new intrinsics (signed/unsigned, 
nonsaturating/saturating) which seems like a bit much.

Perhaps it may be necessary to emit something else when half precision is 
involved here...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86632

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


[PATCH] D86688: [RecoveryExpr] Add 11.0.0 release note.

2020-08-27 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: clang.
hokein requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86688

Files:
  clang/docs/ReleaseNotes.rst


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -48,6 +48,37 @@
 
 - ...
 
+Recovery ASTs
+^
+
+clang's AST now improves support for representing broken C++ code. This 
improves
+the quality of subsequent diagnostics after an error is encountered. It also
+exposes more information to tools like clang-tidy and clangd that consume
+clang’s AST, allowing them to be more accurate on broken code.
+
+A RecoveryExpr is introduced in clang's AST, marking an expression containing
+semantic errors. This preserves the source range and subexpressions of the
+broken expression in the AST (rather than discarding the whole expression).
+
+For the following invalid code:
+
+  .. code-block:: c++
+
+ int NoArg(); // Line 1
+ int x = NoArg(42); // oops!
+
+ // clang-10 produces the minimal placeholder:
+ // VarDecl  col:5 x 'int'
+
+ // clangd-11 produces a richer AST:
+ // VarDecl  col:5 x 'int' cinit
+ // `-RecoveryExpr  '' contains-errors 
lvalue
+ //`-UnresolvedLookupExpr  '' lvalue (ADL) 
= 'NoArg'
+ //`-IntegerLiteral  'int' 42
+
+Note that error-dependent types and values may now occur outside a template
+context. Tools may need to adjust assumptions about dependent code.
+
 Improvements to Clang's diagnostics
 ^^^
 


Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -48,6 +48,37 @@
 
 - ...
 
+Recovery ASTs
+^
+
+clang's AST now improves support for representing broken C++ code. This improves
+the quality of subsequent diagnostics after an error is encountered. It also
+exposes more information to tools like clang-tidy and clangd that consume
+clang’s AST, allowing them to be more accurate on broken code.
+
+A RecoveryExpr is introduced in clang's AST, marking an expression containing
+semantic errors. This preserves the source range and subexpressions of the
+broken expression in the AST (rather than discarding the whole expression).
+
+For the following invalid code:
+
+  .. code-block:: c++
+
+ int NoArg(); // Line 1
+ int x = NoArg(42); // oops!
+
+ // clang-10 produces the minimal placeholder:
+ // VarDecl  col:5 x 'int'
+
+ // clangd-11 produces a richer AST:
+ // VarDecl  col:5 x 'int' cinit
+ // `-RecoveryExpr  '' contains-errors lvalue
+ //`-UnresolvedLookupExpr  '' lvalue (ADL) = 'NoArg'
+ //`-IntegerLiteral  'int' 42
+
+Note that error-dependent types and values may now occur outside a template
+context. Tools may need to adjust assumptions about dependent code.
+
 Improvements to Clang's diagnostics
 ^^^
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86691: [analyzer] Fix wrong parameter name in printFormattedEntry

2020-08-27 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp created this revision.
nullptr.cpp added reviewers: dcoughlin, NoQ, xazax.hun, Szelethus.
Herald added subscribers: cfe-commits, ASDenysPetrov, martong, Charusso, 
dkrupp, donat.nagy, mikhail.ramalho, a.sidorin, rnkovacs, szepet, 
baloghadamsoftware.
Herald added a project: clang.
nullptr.cpp requested review of this revision.

Function `printFormattedEntry` has declaration:

  static void printFormattedEntry(
  llvm::raw_ostream &Out,
  std::pair EntryDescPair,
  size_t EntryWidth, size_t InitialPad, size_t MinLineWidth = 0);

But in its definition:

  void AnalyzerOptions::printFormattedEntry(
  llvm::raw_ostream &Out,
  std::pair EntryDescPair,
  size_t InitialPad, size_t EntryWidth, size_t MinLineWidth) {

`EntryWidth` and `InitialPad` have different position.

The definition code and all `printFormattedEntry`'s usages use the same
position as the definition, so fix the wrong parameter name in declaration.
Also fix some errors in the comments and make the comments clearer.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86691

Files:
  clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp


Index: clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -40,7 +40,7 @@
   const size_t PadForDesc = InitialPad + EntryWidth;
 
   FOut.PadToColumn(InitialPad) << EntryDescPair.first;
-  // If the buffer's length is greater then PadForDesc, print a newline.
+  // If the buffer's length is greater than PadForDesc, print a newline.
   if (FOut.getColumn() > PadForDesc)
 FOut << '\n';
 
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -177,23 +177,23 @@
   /// description in a formatted manner. If \p MinLineWidth is set to 0, no 
line
   /// breaks are introduced for the description.
   ///
-  /// Format, depending whether the option name's length is less then
-  /// \p OptionWidth:
+  /// Format, depending whether the option name's length is less than
+  /// \p EntryWidth:
   ///
   ///   EntryNameDescription
   ///   <-padding->Description
   ///   <-padding->Description
   ///
-  ///   VeryVeryLongOptionName
+  ///   VeryVeryLongEntryName
   ///   <-padding->Description
   ///   <-padding->Description
-  ///   ^~~~ InitialPad
-  ///   ^~ EntryWidth
+  ///   ^InitialPad
+  ///^~EntryWidth
   ///   ^~MinLineWidth
-  static void printFormattedEntry(
-  llvm::raw_ostream &Out,
-  std::pair EntryDescPair,
-  size_t EntryWidth, size_t InitialPad, size_t MinLineWidth = 0);
+  static void printFormattedEntry(llvm::raw_ostream &Out,
+  std::pair 
EntryDescPair,
+  size_t InitialPad, size_t EntryWidth,
+  size_t MinLineWidth = 0);
 
   /// Pairs of checker/package name and enable/disable.
   std::vector> CheckersAndPackages;


Index: clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
@@ -40,7 +40,7 @@
   const size_t PadForDesc = InitialPad + EntryWidth;
 
   FOut.PadToColumn(InitialPad) << EntryDescPair.first;
-  // If the buffer's length is greater then PadForDesc, print a newline.
+  // If the buffer's length is greater than PadForDesc, print a newline.
   if (FOut.getColumn() > PadForDesc)
 FOut << '\n';
 
Index: clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ clang/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -177,23 +177,23 @@
   /// description in a formatted manner. If \p MinLineWidth is set to 0, no line
   /// breaks are introduced for the description.
   ///
-  /// Format, depending whether the option name's length is less then
-  /// \p OptionWidth:
+  /// Format, depending whether the option name's length is less than
+  /// \p EntryWidth:
   ///
   ///   EntryNameDescription
   ///   <-padding->Description
   ///   <-padding->Description
   ///
-  ///   VeryVeryLongOptionName
+  ///   VeryVeryLongEntryName
   ///   <-padding->Description
   ///   <-padding->Description
-  ///   ^~~~ InitialPad
-  ///   ^~ EntryWidth
+  ///   ^~~~

[PATCH] D86691: [analyzer] Fix wrong parameter name in printFormattedEntry

2020-08-27 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus accepted this revision.
Szelethus added a comment.
This revision is now accepted and ready to land.

Nice, thank you! Did you stumble across this, or found it with a tool?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86691

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


[PATCH] D86621: [clang][Sparc] Default to -mcpu=v9 for SparcV8 on Solaris

2020-08-27 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

While doing 2-stage builds, the 2 `XFAIL`s due to Bug 42493 were required.  
However, I've since also done a 1-stage build with gcc 10, which shows

  Unexpectedly Passed Tests (2):
UBSan-Standalone-sparc :: TestCases/Float/cast-overflow.cpp
UBSan-Standalone-sparc :: TestCases/Misc/log-path_test.cpp

which is no wonder since the underlying bug only exists in `clang` `long 
double` handling.

I'm a bit uncertain how to deal with this: since the Solaris/sparcv9 buildbot 
currently does 1-stage builds with gcc, the resulting `XPASS`es would turn the 
bot red.  However, currently there's no clang-vs.-gcc feature in `lit` to 
distinguish the two builds, AFAICT.  `libcxx` has something like this, but that 
might be overkill to extract.

Perhaps just remove the `XFAIL`s for now?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86621

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


[PATCH] D85736: [Sema][AArch64] Support arm_sve_vector_bits attribute

2020-08-27 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes updated this revision to Diff 288250.
c-rhodes added a comment.

Address comments


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

https://reviews.llvm.org/D85736

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// expected-no-diagnostics
+
+#define N __ARM_FEATURE_SVE_BITS_EXPERIMENTAL
+
+typedef __SVInt8_t svint8_t;
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+
+template struct S { T var; };
+
+S s;
+
+svint8_t to_svint8_t(fixed_int8_t x) { return x; }
+fixed_int8_t from_svint8_t(svint8_t x) { return x; }
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -102,8 +102,11 @@
   svint8_t ss8;
 
   void *sel __attribute__((unused));
-  sel = c ? ss8 : fs8; // expected-error {{incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'fixed_int8_t' (aka '__SVInt8_t'))}}
-  sel = c ? fs8 : ss8; // expected-error {{incompatible operand types ('fixed_int8_t' (aka '__SVInt8_t') and 'svint8_t' (aka '__SVInt8_t'))}}
+  sel = c ? ss8 : fs8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+  sel = c ? fs8 : ss8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+
+  sel = fs8 + ss8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+  sel = ss8 + fs8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
 }
 
 // --//
@@ -192,14 +195,18 @@
 TEST_CAST(bool)
 
 // Test the implicit conversion only applies to valid types
-fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (aka '__SVInt8_t')}}
-fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (aka '__SVBool_t')}}
+fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (vector of {{[0-9]+}} 'signed char' values)}}
+fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
+
+// Test conversion between predicate and uint8 is invalid, both have the same
+// memory representation.
+fixed_bool_t to_fixed_bool_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
 
 // Test the implicit conversion only applies to fixed-length types
 typedef signed int vSInt32 __attribute__((__vector_size__(16)));
-svint32_t to_svint32_t_from_gnut(vSInt32 x) { return x; } // expected-error {{returning 'vSInt32' (vector of 4 'int' values) from a function with incompatible result type 'svint32_t' (aka '__SVInt32_t')}}
+svint32_t to_svint32_t_from_gnut(vSInt32 x) { return x; } // expected-error-re {{returning 'vSInt32' (vector of {{[0-9]+}} 'int' values) from a function with incompatible result type 'svint32_t' (aka '__SVInt32_t')}}
 
-vSInt32 to_gnut_from_svint32_t(svint32_t x) { return x; } // expected-error {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'vSInt32' (vector of 4 'int' values)}}
+vSInt32 to_gnut_from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'vSInt32' (vector of {{[0-9]+}} 'i

[PATCH] D85736: [Sema][AArch64] Support arm_sve_vector_bits attribute

2020-08-27 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes marked 7 inline comments as done.
c-rhodes added a comment.

@rsandifo-arm @aaron.ballman thanks for reviewing!


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

https://reviews.llvm.org/D85736

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


[PATCH] D86101: [AArch64][SVE] Add missing debug info for ACLE types.

2020-08-27 Thread Sander de Smalen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4e9b66de3f04: [AArch64][SVE] Add missing debug info for ACLE 
types. (authored by sdesmalen).

Changed prior to commit:
  https://reviews.llvm.org/D86101?vs=287911&id=288254#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86101

Files:
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/test/CodeGen/aarch64-debug-sve-vector-types.c
  clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c
  clang/test/CodeGen/aarch64-debug-sve-vectorx3-types.c
  clang/test/CodeGen/aarch64-debug-sve-vectorx4-types.c
  clang/test/CodeGen/aarch64-sve.c
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
  llvm/test/DebugInfo/AArch64/dbg-sve-types.ll

Index: llvm/test/DebugInfo/AArch64/dbg-sve-types.ll
===
--- /dev/null
+++ llvm/test/DebugInfo/AArch64/dbg-sve-types.ll
@@ -0,0 +1,44 @@
+; Test that the debug info for the vector type is correctly codegenerated
+; when the DISubrange has no count, but only an upperbound.
+; RUN: llc -mtriple aarch64 -mattr=+sve -filetype=obj -o %t %s
+; RUN: llvm-dwarfdump %t | FileCheck %s
+; RUN: rm %t
+
+; CHECK:  {{.*}}: DW_TAG_subrange_type
+; CHECK-NEXT:   DW_AT_type({{.*}} "__ARRAY_SIZE_TYPE__")
+; CHECK-NEXT:   DW_AT_upper_bound (DW_OP_lit8, DW_OP_bregx VG+0, DW_OP_mul, DW_OP_lit1, DW_OP_minus)
+
+define  @test_svint8_t( returned %op1) !dbg !7 {
+entry:
+  call void @llvm.dbg.value(metadata  %op1, metadata !19, metadata !DIExpression()), !dbg !20
+  ret  %op1, !dbg !21
+}
+
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5}
+!llvm.ident = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 12.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
+!1 = !DIFile(filename: "dbg-sve-types.ll", directory: "")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 4}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{!"clang version 12.0.0"}
+!7 = distinct !DISubprogram(name: "test_svint8_t", scope: !8, file: !8, line: 5, type: !9, scopeLine: 5, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !18)
+!8 = !DIFile(filename: "dbg-sve-types.ll", directory: "")
+!9 = !DISubroutineType(types: !10)
+!10 = !{!11, !11}
+!11 = !DIDerivedType(tag: DW_TAG_typedef, name: "svint8_t", file: !12, line: 32, baseType: !13)
+!12 = !DIFile(filename: "lib/clang/12.0.0/include/arm_sve.h", directory: "")
+!13 = !DIDerivedType(tag: DW_TAG_typedef, name: "__SVInt8_t", file: !1, baseType: !14)
+!14 = !DICompositeType(tag: DW_TAG_array_type, baseType: !15, flags: DIFlagVector, elements: !16)
+!15 = !DIBasicType(name: "signed char", size: 8, encoding: DW_ATE_signed_char)
+!16 = !{!17}
+!17 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 8, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus))
+!18 = !{!19}
+!19 = !DILocalVariable(name: "op1", arg: 1, scope: !7, file: !8, line: 5, type: !11)
+!20 = !DILocation(line: 0, scope: !7)
+!21 = !DILocation(line: 5, column: 39, scope: !7)
Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1422,8 +1422,10 @@
  Elements[0]->getTag() == dwarf::DW_TAG_subrange_type &&
  "Invalid vector element array, expected one element of type subrange");
   const auto Subrange = cast(Elements[0]);
-  const auto CI = Subrange->getCount().get();
-  const int32_t NumVecElements = CI->getSExtValue();
+  const auto NumVecElements =
+  Subrange->getCount()
+  ? Subrange->getCount().get()->getSExtValue()
+  : 0;
 
   // Ensure we found the element count and that the actual size is wide
   // enough to contain the requested size.
Index: clang/test/CodeGen/aarch64-sve.c
===
--- clang/test/CodeGen/aarch64-sve.c
+++ clang/test/CodeGen/aarch64-sve.c
@@ -1,22 +1,6 @@
-// RUN: not %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
-// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s -check-prefix=CHECK-DEBUG
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
 // RUN:  -emit-llvm -o - %s 2>&1 | FileCheck %s -check-prefix=CHECK
 
-// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt8_t'
-// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt16_t'
-// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt32_t'
-// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVInt64_t'
-// CHECK-DEBUG: cannot yet generate debug info for SVE type '__SVUint8_t'
-// CH

[clang] 4e9b66d - [AArch64][SVE] Add missing debug info for ACLE types.

2020-08-27 Thread Sander de Smalen via cfe-commits

Author: Sander de Smalen
Date: 2020-08-27T10:56:42+01:00
New Revision: 4e9b66de3f046c1e97b34c938b0920fa6401f40c

URL: 
https://github.com/llvm/llvm-project/commit/4e9b66de3f046c1e97b34c938b0920fa6401f40c
DIFF: 
https://github.com/llvm/llvm-project/commit/4e9b66de3f046c1e97b34c938b0920fa6401f40c.diff

LOG: [AArch64][SVE] Add missing debug info for ACLE types.

This patch adds type information for SVE ACLE vector types,
by describing them as vectors, with a lower bound of 0, and
an upper bound described by a DWARF expression using the
AArch64 Vector Granule register (VG), which contains the
runtime multiple of 64bit granules in an SVE vector.

Reviewed By: efriedma

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

Added: 
clang/test/CodeGen/aarch64-debug-sve-vector-types.c
clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c
clang/test/CodeGen/aarch64-debug-sve-vectorx3-types.c
clang/test/CodeGen/aarch64-debug-sve-vectorx4-types.c
llvm/test/DebugInfo/AArch64/dbg-sve-types.ll

Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp
clang/test/CodeGen/aarch64-sve.c
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index 36bab9c22d43..d90cffb4bb95 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -720,23 +720,39 @@ llvm::DIType *CGDebugInfo::CreateType(const BuiltinType 
*BT) {
   case BuiltinType::Id: \
 return getOrCreateStructPtrType("opencl_" #ExtType, Id##Ty);
 #include "clang/Basic/OpenCLExtensionTypes.def"
-  // TODO: real support for SVE types requires more infrastructure
-  // to be added first.  The types have a variable length and are
-  // represented in debug info as types whose length depends on a
-  // target-specific pseudo register.
-#define SVE_TYPE(Name, Id, SingletonId) \
-  case BuiltinType::Id:
+
+#define SVE_TYPE(Name, Id, SingletonId) case BuiltinType::Id:
 #include "clang/Basic/AArch64SVEACLETypes.def"
-  {
-unsigned DiagID = CGM.getDiags().getCustomDiagID(
-DiagnosticsEngine::Error,
-"cannot yet generate debug info for SVE type '%0'");
-auto Name = BT->getName(CGM.getContext().getPrintingPolicy());
-CGM.getDiags().Report(DiagID) << Name;
-// Return something safe.
-return CreateType(cast(CGM.getContext().IntTy));
-  }
+{
+  ASTContext::BuiltinVectorTypeInfo Info =
+  CGM.getContext().getBuiltinVectorTypeInfo(BT);
+  unsigned NumElemsPerVG = (Info.EC.Min * Info.NumVectors) / 2;
+
+  // Debuggers can't extract 1bit from a vector, so will display a
+  // bitpattern for svbool_t instead.
+  if (Info.ElementType == CGM.getContext().BoolTy) {
+NumElemsPerVG /= 8;
+Info.ElementType = CGM.getContext().UnsignedCharTy;
+  }
 
+  auto *LowerBound =
+  llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
+  llvm::Type::getInt64Ty(CGM.getLLVMContext()), 0));
+  SmallVector Expr(
+  {llvm::dwarf::DW_OP_constu, NumElemsPerVG, llvm::dwarf::DW_OP_bregx,
+   /* AArch64::VG */ 46, 0, llvm::dwarf::DW_OP_mul,
+   llvm::dwarf::DW_OP_constu, 1, llvm::dwarf::DW_OP_minus});
+  auto *UpperBound = DBuilder.createExpression(Expr);
+
+  llvm::Metadata *Subscript = DBuilder.getOrCreateSubrange(
+  /*count*/ nullptr, LowerBound, UpperBound, /*stride*/ nullptr);
+  llvm::DINodeArray SubscriptArray = DBuilder.getOrCreateArray(Subscript);
+  llvm::DIType *ElemTy =
+  getOrCreateType(Info.ElementType, TheCU->getFile());
+  auto Align = getTypeAlignIfRequired(BT, CGM.getContext());
+  return DBuilder.createVectorType(/*Size*/ 0, Align, ElemTy,
+   SubscriptArray);
+}
   case BuiltinType::UChar:
   case BuiltinType::Char_U:
 Encoding = llvm::dwarf::DW_ATE_unsigned_char;

diff  --git a/clang/test/CodeGen/aarch64-debug-sve-vector-types.c 
b/clang/test/CodeGen/aarch64-debug-sve-vector-types.c
new file mode 100644
index ..4325e3f44747
--- /dev/null
+++ b/clang/test/CodeGen/aarch64-debug-sve-vector-types.c
@@ -0,0 +1,71 @@
+// RUN:  %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve \
+// RUN:  -emit-llvm -o - %s -debug-info-kind=limited 2>&1 | FileCheck %s
+
+void test_locals(void) {
+  // CHECK-DAG: name: "__SVBool_t",{{.*}}, baseType: ![[CT1:[0-9]+]]
+  // CHECK-DAG: ![[CT1]] = !DICompositeType(tag: DW_TAG_array_type, baseType: 
![[ELTTYU8:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64:[0-9]+]])
+  // CHECK-DAG: ![[ELTTYU8]] = !DIBasicType(name: "unsigned char", size: 8, 
encoding: DW_ATE_unsigned_char)
+  // CHECK-DAG: ![[ELTS1_64]] = !{![[REALELTS1_64:[0-9]+]]}
+  // CHECK-DAG: ![[REALELTS1_64]] = !DISubrange(lowerBound: 0, upperBound: 
!DIExpression(DW_OP_constu, 1, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, 
DW_OP

[PATCH] D86101: [AArch64][SVE] Add missing debug info for ACLE types.

2020-08-27 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen added a comment.

Thanks for the review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86101

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-08-27 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop created this revision.
russell.gallop added reviewers: cryptoad, aganea, hans.
Herald added subscribers: llvm-commits, Sanitizers, cfe-commits, mgorny.
Herald added projects: clang, Sanitizers, LLVM.
russell.gallop requested review of this revision.

This is basically https://reviews.llvm.org/D42519 updated for monorepo with a 
few changes to allow -fsanitize=scudo in clang-cl and permit 
LLVM_USE_SANITIZER=Scudo.

This is to allow evaluation of Scudo as a replacement memory allocator on 
Windows for comparison with https://reviews.llvm.org/D71786


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86694

Files:
  clang/lib/Driver/ToolChains/MSVC.cpp
  compiler-rt/cmake/config-ix.cmake
  compiler-rt/lib/sanitizer_common/sanitizer_win.cpp
  compiler-rt/lib/scudo/scudo_allocator.cpp
  compiler-rt/lib/scudo/scudo_new_delete.cpp
  compiler-rt/lib/scudo/scudo_platform.h
  compiler-rt/lib/scudo/scudo_tsd.h
  compiler-rt/lib/scudo/scudo_tsd_shared.cpp
  compiler-rt/lib/scudo/scudo_tsd_shared.inc
  compiler-rt/test/scudo/interface.cpp
  compiler-rt/test/scudo/lit.cfg.py
  compiler-rt/test/scudo/malloc.cpp
  compiler-rt/test/scudo/memalign.c
  compiler-rt/test/scudo/mismatch.cpp
  compiler-rt/test/scudo/overflow.c
  compiler-rt/test/scudo/preload.cpp
  compiler-rt/test/scudo/rss.c
  compiler-rt/test/scudo/secondary.c
  compiler-rt/test/scudo/threads.c
  compiler-rt/test/scudo/tsd_destruction.c
  compiler-rt/test/scudo/valloc.c
  llvm/cmake/modules/HandleLLVMOptions.cmake

Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -775,6 +775,9 @@
 elseif (LLVM_USE_SANITIZER STREQUAL "Leaks")
   append_common_sanitizer_flags()
   append("-fsanitize=leak" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+elseif (LLVM_USE_SANITIZER STREQUAL "Scudo")
+  append_common_sanitizer_flags()
+  append("-fsanitize=scudo" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
 else()
   message(FATAL_ERROR "Unsupported value of LLVM_USE_SANITIZER: ${LLVM_USE_SANITIZER}")
 endif()
@@ -782,6 +785,9 @@
 if (LLVM_USE_SANITIZER STREQUAL "Address")
   append_common_sanitizer_flags()
   append("-fsanitize=address" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
+elseif (LLVM_USE_SANITIZER STREQUAL "Scudo")
+  append_common_sanitizer_flags()
+  append("-fsanitize=scudo" CMAKE_C_FLAGS CMAKE_CXX_FLAGS)
 else()
   message(FATAL_ERROR "This sanitizer not yet supported in the MSVC environment: ${LLVM_USE_SANITIZER}")
 endif()
Index: compiler-rt/test/scudo/valloc.c
===
--- compiler-rt/test/scudo/valloc.c
+++ compiler-rt/test/scudo/valloc.c
@@ -2,7 +2,7 @@
 // RUN: %run %t valid   2>&1
 // RUN: not %run %t invalid 2>&1 | FileCheck %s
 // RUN: %env_scudo_opts=allocator_may_return_null=1 %run %t invalid 2>&1
-// UNSUPPORTED: android
+// UNSUPPORTED: android, win32
 
 // Tests that valloc and pvalloc work as intended.
 
Index: compiler-rt/test/scudo/tsd_destruction.c
===
--- compiler-rt/test/scudo/tsd_destruction.c
+++ compiler-rt/test/scudo/tsd_destruction.c
@@ -1,5 +1,6 @@
 // RUN: %clang_scudo %s -o %t
 // RUN: %run %t 2>&1
+// UNSUPPORTED: win32
 
 #include 
 #include 
Index: compiler-rt/test/scudo/threads.c
===
--- compiler-rt/test/scudo/threads.c
+++ compiler-rt/test/scudo/threads.c
@@ -1,6 +1,7 @@
 // RUN: %clang_scudo %s -o %t
 // RUN: %env_scudo_opts="QuarantineSizeKb=0:ThreadLocalQuarantineSizeKb=0" %run %t 5 100 2>&1
 // RUN: %env_scudo_opts="QuarantineSizeKb=1024:ThreadLocalQuarantineSizeKb=64" %run %t 5 100 2>&1
+// UNSUPPORTED: win32
 
 // Tests parallel allocations and deallocations of memory chunks from a number
 // of concurrent threads, with and without quarantine.
Index: compiler-rt/test/scudo/secondary.c
===
--- compiler-rt/test/scudo/secondary.c
+++ compiler-rt/test/scudo/secondary.c
@@ -6,37 +6,60 @@
 // allocated by the Secondary allocator, or writing too far in front of it.
 
 #include 
-#include 
-#include 
 #include 
 #include 
-#include 
+#include 
+#ifdef _WIN32
+# include 
+#else
+# include 
+# include 
+#endif
 
+#ifdef _WIN32
+DWORD getpagesize() {
+  SYSTEM_INFO si;
+  GetSystemInfo(&si);
+  return si.dwPageSize;
+}
+LONG WINAPI handler(EXCEPTION_POINTERS *ExceptionInfo)
+{
+  fprintf(stderr, "AccessViolation\n");
+  ExitProcess(0);
+}
+#else
 void handler(int signo, siginfo_t *info, void *uctx) {
   if (info->si_code == SEGV_ACCERR) {
-fprintf(stderr, "SCUDO SIGSEGV\n");
+fprintf(stderr, "AccessViolation\n");
 exit(0);
   }
   exit(1);
 }
+long getp

[PATCH] D86065: [SVE] Make ElementCount members private

2020-08-27 Thread David Sherwood via Phabricator via cfe-commits
david-arm updated this revision to Diff 288260.
david-arm edited the summary of this revision.

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

https://reviews.llvm.org/D86065

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CodeGenTypes.cpp
  llvm/include/llvm/Analysis/TargetTransformInfo.h
  llvm/include/llvm/Analysis/VectorUtils.h
  llvm/include/llvm/CodeGen/ValueTypes.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/DerivedTypes.h
  llvm/include/llvm/IR/Instructions.h
  llvm/include/llvm/Support/MachineValueType.h
  llvm/include/llvm/Support/TypeSize.h
  llvm/lib/Analysis/InstructionSimplify.cpp
  llvm/lib/Analysis/VFABIDemangling.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/Bitcode/Writer/BitcodeWriter.cpp
  llvm/lib/CodeGen/CodeGenPrepare.cpp
  llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
  llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
  llvm/lib/CodeGen/TargetLoweringBase.cpp
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/AsmWriter.cpp
  llvm/lib/IR/ConstantFold.cpp
  llvm/lib/IR/Constants.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/lib/IR/Function.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/IR/Instructions.cpp
  llvm/lib/IR/IntrinsicInst.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/AArch64/AArch64ISelDAGToDAG.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/lib/Transforms/Utils/FunctionComparator.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
  llvm/lib/Transforms/Vectorize/VPlan.cpp
  llvm/lib/Transforms/Vectorize/VPlan.h
  llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
  llvm/unittests/IR/VectorTypesTest.cpp

Index: llvm/unittests/IR/VectorTypesTest.cpp
===
--- llvm/unittests/IR/VectorTypesTest.cpp
+++ llvm/unittests/IR/VectorTypesTest.cpp
@@ -119,8 +119,8 @@
   EXPECT_EQ(ConvTy->getElementType()->getScalarSizeInBits(), 64U);
 
   EltCnt = V8Int64Ty->getElementCount();
-  EXPECT_EQ(EltCnt.Min, 8U);
-  ASSERT_FALSE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 8U);
+  ASSERT_FALSE(EltCnt.isScalable());
 }
 
 TEST(VectorTypesTest, Scalable) {
@@ -215,8 +215,8 @@
   EXPECT_EQ(ConvTy->getElementType()->getScalarSizeInBits(), 64U);
 
   EltCnt = ScV8Int64Ty->getElementCount();
-  EXPECT_EQ(EltCnt.Min, 8U);
-  ASSERT_TRUE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 8U);
+  ASSERT_TRUE(EltCnt.isScalable());
 }
 
 TEST(VectorTypesTest, BaseVectorType) {
@@ -250,7 +250,7 @@
 // test I == J
 VectorType *VI = VTys[I];
 ElementCount ECI = VI->getElementCount();
-EXPECT_EQ(isa(VI), ECI.Scalable);
+EXPECT_EQ(isa(VI), ECI.isScalable());
 
 for (size_t J = I + 1, JEnd = VTys.size(); J < JEnd; ++J) {
   // test I < J
Index: llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
===
--- llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
+++ llvm/unittests/CodeGen/ScalableVectorMVTsTest.cpp
@@ -71,8 +71,8 @@
 
   // Check fields inside llvm::ElementCount
   EltCnt = Vnx4i32.getVectorElementCount();
-  EXPECT_EQ(EltCnt.Min, 4U);
-  ASSERT_TRUE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 4U);
+  ASSERT_TRUE(EltCnt.isScalable());
 
   // Check that fixed-length vector types aren't scalable.
   EVT V8i32 = EVT::getVectorVT(Ctx, MVT::i32, 8);
@@ -82,8 +82,8 @@
 
   // Check that llvm::ElementCount works for fixed-length types.
   EltCnt = V8i32.getVectorElementCount();
-  EXPECT_EQ(EltCnt.Min, 8U);
-  ASSERT_FALSE(EltCnt.Scalable);
+  EXPECT_EQ(EltCnt.getKnownMinValue(), 8U);
+  ASSERT_FALSE(EltCnt.isScalable());
 }
 
 TEST(ScalableVectorMVTsTest, IRToVTTranslation) {
Index: llvm/lib/Transforms/Vectorize/VPlan.h
===
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -151,14 +151,15 @@
   /// \return True if the map has a scalar entry for \p Key and \p Instance.
   bool hasScalarValue(Value *Key, const VPIteration &Instance) const {
 assert(Instance.Part < UF && "Queried Scalar Part is too large.");
-assert(Instance.Lane < VF.Min && "Queried Scalar Lane is too large.");
-assert(!VF.Scalable && "VF is assumed to be non scalable.");
+assert(Instance.Lane < VF.getKnownMinValue() &&
+   "Queried Scalar Lane is too large.");
+assert(!VF.isScalable() && "VF is assumed to be non scalable.");
 
 if (!hasAnyScalarValue(Key))
   return false;
 const ScalarParts &Entry = ScalarMapStorage.find(Key)->second;
 assert(Entry.size() == UF && "ScalarParts has wrong dimensions.");
-assert(Entry[Instance.Part].size() == VF.Min &&
+assert(Entry[Instance.Part].size() == VF.getKnownMinValue() &&
"ScalarParts has wrong dimensions.");
 return Entry[Instance.Part][Instance.Lane] != nullptr;
   }
@@ -197,7 +198,7 @@
   // TODO: Consider storing uniform value

[PATCH] D72705: [analyzer] Added new checker 'alpha.unix.ErrorReturn'.

2020-08-27 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added a comment.

The summary of this last discussion is that it is not acceptable to have only 
the simple check for the explicit comparison with a fixed constant. At least 
not for return types where the "implicit" check (a check that is always true or 
false for the error return value) is possible, for example the `char*` case. 
For functions that return a sort of "handle" (mainly a pointer to a struct that 
is not normally used with pointer arithmetic) the checker can still be useful.

Another solution for the problem is if the system calls are modeled in a way 
that there is always a state split between error end non-error (we will have a 
path where it is known that the specific variable can be only (for example) 
`NULL` and this can be detected by other checkers).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72705

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


[clang] feed5a7 - [Sema][AArch64] Support arm_sve_vector_bits attribute

2020-08-27 Thread Cullen Rhodes via cfe-commits

Author: Cullen Rhodes
Date: 2020-08-27T10:38:32Z
New Revision: feed5a7239d8ed0ec9f90775080ce8546bf364df

URL: 
https://github.com/llvm/llvm-project/commit/feed5a7239d8ed0ec9f90775080ce8546bf364df
DIFF: 
https://github.com/llvm/llvm-project/commit/feed5a7239d8ed0ec9f90775080ce8546bf364df.diff

LOG: [Sema][AArch64] Support arm_sve_vector_bits attribute

This patch implements the semantics for the 'arm_sve_vector_bits' type
attribute, defined by the Arm C Language Extensions (ACLE) for SVE [1].
The purpose of this attribute is to define vector-length-specific (VLS)
versions of existing vector-length-agnostic (VLA) types.

The semantics were already implemented by D83551, although the
implementation approach has since changed to represent VLSTs as
VectorType in the AST and fixed-length vectors in the IR everywhere
except in function args/returns. This is described in the prototype
patch D85128 demonstrating the new approach.

The semantic changes added in D83551 are changed since the
AttributedType is replaced by VectorType in the AST. Minimal changes
were necessary in the previous patch as the canonical type for both VLA
and VLS was the same (i.e. sizeless), except in constructs such as
globals and structs where sizeless types are unsupported. This patch
reverts the changes that permitted VLS types that were represented as
sizeless types in such circumstances, and adds support for implicit
casting between VLA <-> VLS types as described in section 3.7.3.2 of the
ACLE.

Since the SVE builtin types for bool and uint8 are both represented as
BuiltinType::UChar in VLSTs, two new vector kinds are implemented to
distinguish predicate and data vectors.

[1] https://developer.arm.com/documentation/100987/latest

Reviewed By: aaron.ballman

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

Added: 
clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Modified: 
clang/include/clang/AST/ASTContext.h
clang/include/clang/AST/Type.h
clang/include/clang/Basic/Attr.td
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/include/clang/Sema/Overload.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/ASTContext.cpp
clang/lib/AST/JSONNodeDumper.cpp
clang/lib/AST/TextNodeDumper.cpp
clang/lib/AST/Type.cpp
clang/lib/AST/TypePrinter.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaExprCXX.cpp
clang/lib/Sema/SemaOverload.cpp
clang/lib/Sema/SemaType.cpp
clang/test/Sema/attr-arm-sve-vector-bits.c

Removed: 




diff  --git a/clang/include/clang/AST/ASTContext.h 
b/clang/include/clang/AST/ASTContext.h
index b71f144d22a3..de0d1198b6d4 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -2058,6 +2058,11 @@ class ASTContext : public RefCountedBase {
   /// types.
   bool areCompatibleVectorTypes(QualType FirstVec, QualType SecondVec);
 
+  /// Return true if the given types are an SVE builtin and a VectorType that
+  /// is a fixed-length representation of the SVE builtin for a specific
+  /// vector-length.
+  bool areCompatibleSveTypes(QualType FirstType, QualType SecondType);
+
   /// Return true if the type has been explicitly qualified with ObjC 
ownership.
   /// A type may be implicitly qualified with ownership under ObjC ARC, and in
   /// some cases the compiler treats these 
diff erently.
@@ -2114,10 +2119,6 @@ class ASTContext : public RefCountedBase {
 return getTypeSizeInCharsIfKnown(QualType(Ty, 0));
   }
 
-  /// Returns the bitwidth of \p T, an SVE type attributed with
-  /// 'arm_sve_vector_bits'. Should only be called if T->isVLST().
-  unsigned getBitwidthForAttributedSveType(const Type *T) const;
-
   /// Return the ABI-specified alignment of a (complete) type \p T, in
   /// bits.
   unsigned getTypeAlign(QualType T) const { return getTypeInfo(T).Align; }

diff  --git a/clang/include/clang/AST/Type.h b/clang/include/clang/AST/Type.h
index df9c926ce902..d8eece10475a 100644
--- a/clang/include/clang/AST/Type.h
+++ b/clang/include/clang/AST/Type.h
@@ -1886,14 +1886,16 @@ class alignas(8) Type : public ExtQualsTypeCommonBase {
   bool isSizelessType() const;
   bool isSizelessBuiltinType() const;
 
-  /// Determines if this is a vector-length-specific type (VLST), i.e. a
-  /// sizeless type with the 'arm_sve_vector_bits' attribute applied.
-  bool isVLST() const;
   /// Determines if this is a sizeless type supported by the
   /// 'arm_sve_vector_bits' type attribute, which can be applied to a single
   /// SVE vector or predicate, excluding tuple types such as svint32x4_t.
   bool isVLSTBuiltinType() const;
 
+  /// Returns the representative type for the element of an SVE builtin type.
+  /// This is used to represent fixed-length SVE vectors created with the
+  /// 'arm_sve_vector_bits' type attribute as VectorType.
+  QualType getSveEltType(const ASTContext &Ctx) const;
+
   /// Types are

[PATCH] D85736: [Sema][AArch64] Support arm_sve_vector_bits attribute

2020-08-27 Thread Cullen Rhodes via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfeed5a7239d8: [Sema][AArch64] Support arm_sve_vector_bits 
attribute (authored by c-rhodes).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85736

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Sema/Overload.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/JSONNodeDumper.cpp
  clang/lib/AST/TextNodeDumper.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
+// expected-no-diagnostics
+
+#define N __ARM_FEATURE_SVE_BITS_EXPERIMENTAL
+
+typedef __SVInt8_t svint8_t;
+typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
+
+template struct S { T var; };
+
+S s;
+
+svint8_t to_svint8_t(fixed_int8_t x) { return x; }
+fixed_int8_t from_svint8_t(svint8_t x) { return x; }
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -102,8 +102,11 @@
   svint8_t ss8;
 
   void *sel __attribute__((unused));
-  sel = c ? ss8 : fs8; // expected-error {{incompatible operand types ('svint8_t' (aka '__SVInt8_t') and 'fixed_int8_t' (aka '__SVInt8_t'))}}
-  sel = c ? fs8 : ss8; // expected-error {{incompatible operand types ('fixed_int8_t' (aka '__SVInt8_t') and 'svint8_t' (aka '__SVInt8_t'))}}
+  sel = c ? ss8 : fs8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+  sel = c ? fs8 : ss8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+
+  sel = fs8 + ss8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
+  sel = ss8 + fs8; // expected-error {{cannot convert between a fixed-length and a sizeless vector}}
 }
 
 // --//
@@ -192,14 +195,18 @@
 TEST_CAST(bool)
 
 // Test the implicit conversion only applies to valid types
-fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (aka '__SVInt8_t')}}
-fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (aka '__SVBool_t')}}
+fixed_int8_t to_fixed_int8_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_int8_t' (vector of {{[0-9]+}} 'signed char' values)}}
+fixed_bool_t to_fixed_bool_t__from_svint32_t(svint32_t x) { return x; } // expected-error-re {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
+
+// Test conversion between predicate and uint8 is invalid, both have the same
+// memory representation.
+fixed_bool_t to_fixed_bool_t__from_svuint8_t(svuint8_t x) { return x; } // expected-error-re {{returning 'svuint8_t' (aka '__SVUint8_t') from a function with incompatible result type 'fixed_bool_t' (vector of {{[0-9]+}} 'unsigned char' values)}}
 
 // Test the implicit conversion only applies to fixed-length types
 typedef signed int vSInt32 __attribute__((__vector_size__(16)));
-svint32_t to_svint32_t_from_gnut(vSInt32 x) { return x; } // expected-error {{returning 'vSInt32' (vector of 4 'int' values) from a function with incompatible result type 'svint32_t' (aka '__SVInt32_t')}}
+svint32_t to_svint32_t_from_gnut(vSInt32 x) { return x; } // expected-error-re {{returning 'vSInt32' (vector of {{[0-9]+}} 'int' values) from a function with incompatible result type 'svint32_t' (aka '__SVInt32_t')}}
 
-vSInt32 to_gnut_from_svint32_t(svint32_t x) { return x; } // expected-error {{returning 'svint32_t' (aka '__SVInt32_t') from a function with incompatible result type 'vSInt32' (vector of 4 'int' values)}}
+vSInt32 to_gnut_from_svint32_t(svint32_t x) { return x; } // expected-

[PATCH] D86679: [SyntaxTree][NFC] Append "get" to syntax Nodes accessor names

2020-08-27 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added a comment.
This revision is now accepted and ready to land.

> It's worth noting that accessors in the base APIs don't follow this rule. 
> Should we refactor them as well?

I'd say yes.

> In this patch?

Up to you.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86679

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


[PATCH] D86695: [RFC] Call ParseLangArgs for all inputs

2020-08-27 Thread Harald van Dijk via Phabricator via cfe-commits
hvdijk created this revision.
Herald added subscribers: cfe-commits, atanasyan, arichardson, sdardis.
Herald added a project: clang.
hvdijk requested review of this revision.

clang/lib/CodeGen/BackendUtil.cpp contains multiple checks for attributes of 
LangOpts. The option processing that sets up LangOpts is mostly done by 
ParseLangArgs, which is skipped for LLVM IR files. Because of this, there are 
code generation differences when the -save-temps command line option is used: 
that command line option causes LLVM IR to be emitted to file and a new process 
to be spawned to process that file, which does not process options the same way.

An example of this is

  typedef float __attribute__((ext_vector_type(2))) float2;
  float2 foo (float2 a, float2 b, float2 c) {
return a * b + c;
  }

This used to generate different code with clang --target=mips -mcpu=mips32r5 
-mfp64 -mmsa -O3 -ffp-contract=fast depending on whether -save-temps was also 
present, because the -ffp-contract=fast option affects instruction selection 
but was ignored for LLVM IR input files.

While CompilerInvocation::CreateFromArgs contained special exceptions for a few 
options that were handled by ParseLangArgs that also need to be handled for 
LLVM IR, there are many more, and just allowing ParseLangArgs to be called 
seems like the simpler fix.

For InputKind::Precompiled, -std=* options were previously silently ignored and 
continue to be silently ignored, as it is reasonable for users to add them and 
in fact this is done in quite a number of tests in the test suite.

For Language::LLVM_IR, -std=* options were previously silently ignored and now 
result in an error, as it is not reasonable for users to add them.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86695

Files:
  clang/lib/Frontend/CompilerInvocation.cpp

Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2432,9 +2432,11 @@
   const LangStandard &S) {
   switch (IK.getLanguage()) {
   case Language::Unknown:
-  case Language::LLVM_IR:
 llvm_unreachable("should not parse language flags for this input");
 
+  case Language::LLVM_IR:
+return false;
+
   case Language::C:
   case Language::ObjC:
   case Language::RenderScript:
@@ -2507,30 +2509,32 @@
 if (LangStd == LangStandard::lang_unspecified) {
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
-  // Report supported standards with short description.
-  for (unsigned KindValue = 0;
-   KindValue != LangStandard::lang_unspecified;
-   ++KindValue) {
-const LangStandard &Std = LangStandard::getLangStandardForKind(
-  static_cast(KindValue));
-if (IsInputCompatibleWithStandard(IK, Std)) {
-  auto Diag = Diags.Report(diag::note_drv_use_standard);
-  Diag << Std.getName() << Std.getDescription();
-  unsigned NumAliases = 0;
+  if (IK.getFormat() != InputKind::Precompiled) {
+// Report supported standards with short description.
+for (unsigned KindValue = 0;
+ KindValue != LangStandard::lang_unspecified;
+ ++KindValue) {
+  const LangStandard &Std = LangStandard::getLangStandardForKind(
+static_cast(KindValue));
+  if (IsInputCompatibleWithStandard(IK, Std)) {
+auto Diag = Diags.Report(diag::note_drv_use_standard);
+Diag << Std.getName() << Std.getDescription();
+unsigned NumAliases = 0;
 #define LANGSTANDARD(id, name, lang, desc, features)
 #define LANGSTANDARD_ALIAS(id, alias) \
-  if (KindValue == LangStandard::lang_##id) ++NumAliases;
+if (KindValue == LangStandard::lang_##id) ++NumAliases;
 #define LANGSTANDARD_ALIAS_DEPR(id, alias)
 #include "clang/Basic/LangStandards.def"
-  Diag << NumAliases;
+Diag << NumAliases;
 #define LANGSTANDARD(id, name, lang, desc, features)
 #define LANGSTANDARD_ALIAS(id, alias) \
-  if (KindValue == LangStandard::lang_##id) Diag << alias;
+if (KindValue == LangStandard::lang_##id) Diag << alias;
 #define LANGSTANDARD_ALIAS_DEPR(id, alias)
 #include "clang/Basic/LangStandards.def"
+  }
 }
   }
-} else {
+} else if (IK.getFormat() != InputKind::Precompiled) {
   // Valid standard, check to make sure language and standard are
   // compatible.
   const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
@@ -2592,7 +2596,9 @@
   Opts.DeclareOpenCLBuiltins = Args.hasArg(OPT_fdeclare_opencl_builtins);
 
   llvm::Triple T(TargetOpts.Triple);
-  CompilerInvocation::setLangDefaults(Opts, IK, T, PPOpts, LangStd);
+  if (IK.getFormat() != InputKind::Precompiled &&
+  IK.getLanguage() != Language::LLVM_IR)
+CompilerInvocati

[PATCH] D86691: [analyzer] Fix wrong parameter name in printFormattedEntry

2020-08-27 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

In D86691#2241401 , @Szelethus wrote:

> Nice, thank you! Did you stumble across this, or found it with a tool?

I just happened to see these code:-).
Maybe we should write a checker to check this situation? I will start doing 
this!

BTW, I don't have commit access, can you help commit this and D86334 
? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86691

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


[PATCH] D86065: [SVE] Make ElementCount members private

2020-08-27 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added inline comments.



Comment at: llvm/include/llvm/Support/TypeSize.h:108
+
+  bool isPowerOf2() const { return isPowerOf2_32(Min); }
 };

I don't believe this is safe.  For example we know SVE supported vector lengths 
only have to be a multiple of 128bits.  So for scalable vectors we cannot know 
the element count is a power of 2 unless we perform a runtime check.


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

https://reviews.llvm.org/D86065

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


[PATCH] D75044: [AArch64] __builtin_return_address for PAuth.

2020-08-27 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss updated this revision to Diff 288275.
danielkiss added a comment.

updating tests too. check-llvm, check-clang passes.


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

https://reviews.llvm.org/D75044

Files:
  llvm/include/llvm/CodeGen/ISDOpcodes.h
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
  llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
  llvm/test/CodeGen/AArch64/arm64_32.ll
  llvm/test/CodeGen/AArch64/returnaddr.ll

Index: llvm/test/CodeGen/AArch64/returnaddr.ll
===
--- llvm/test/CodeGen/AArch64/returnaddr.ll
+++ llvm/test/CodeGen/AArch64/returnaddr.ll
@@ -3,6 +3,7 @@
 define i8* @rt0(i32 %x) nounwind readnone {
 entry:
 ; CHECK-LABEL: rt0:
+; CHECK: hint #7
 ; CHECK: mov x0, x30
   %0 = tail call i8* @llvm.returnaddress(i32 0)
   ret i8* %0
@@ -13,7 +14,9 @@
 ; CHECK-LABEL: rt2:
 ; CHECK: ldr x[[reg:[0-9]+]], [x29]
 ; CHECK: ldr x[[reg]], [x[[reg]]]
-; CHECK: ldr x0, [x[[reg]], #8]
+; CHECK: ldr x30, [x[[reg]], #8]
+; CHECK: hint #7
+; CHECK: mov x0, x30
   %0 = tail call i8* @llvm.returnaddress(i32 2)
   ret i8* %0
 }
Index: llvm/test/CodeGen/AArch64/arm64_32.ll
===
--- llvm/test/CodeGen/AArch64/arm64_32.ll
+++ llvm/test/CodeGen/AArch64/arm64_32.ll
@@ -253,7 +253,9 @@
 define i8* @test_deep_returnaddr() {
 ; CHECK-LABEL: test_deep_returnaddr:
 ; CHECK: ldr x[[FRAME_REC:[0-9]+]], [x29]
-; CHECK-OPT: ldr x0, [x[[FRAME_REC]], #8]
+; CHECK-OPT: ldr x30, [x[[FRAME_REC]], #8]
+; CHECK-OPT: hint #7
+; CHECK-OPT: mov x0, x30
 ; CHECK-FAST: ldr [[TMP:x[0-9]+]], [x[[FRAME_REC]], #8]
 ; CHECK-FAST: and x0, [[TMP]], #0x
   %val = call i8* @llvm.returnaddress(i32 1)
Index: llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
===
--- llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
+++ llvm/test/CodeGen/AArch64/arm64-returnaddr.ll
@@ -3,6 +3,7 @@
 define i8* @rt0(i32 %x) nounwind readnone {
 entry:
 ; CHECK-LABEL: rt0:
+; CHECK: hint #7
 ; CHECK: mov x0, x30
 ; CHECK: ret
   %0 = tail call i8* @llvm.returnaddress(i32 0)
@@ -16,7 +17,9 @@
 ; CHECK: mov x29, sp
 ; CHECK: ldr x[[REG:[0-9]+]], [x29]
 ; CHECK: ldr x[[REG2:[0-9]+]], [x[[REG]]]
-; CHECK: ldr x0, [x[[REG2]], #8]
+; CHECK: ldr x30, [x[[REG2]], #8]
+; CHECK: hint #7
+; CHECK: mov x0, x30
 ; CHECK: ldp x29, x30, [sp], #16
 ; CHECK: ret
   %0 = tail call i8* @llvm.returnaddress(i32 2)
Index: llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/aarch64-signedreturnaddress.ll
@@ -0,0 +1,49 @@
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.2a | FileCheck %s
+; RUN: llc < %s -mtriple=arm64-eabi -asm-verbose=false -mattr=v8.3a | FileCheck %s --check-prefix=CHECKV83
+
+; Armv8.3-A Pointer Authetication requires a special intsruction to strip the
+; pointer authentication code from the pointer.
+; The XPACLRI instruction assembles to a hint-space instruction before Armv8.3-A
+; therefore this instruction can be safely used for any pre Armv8.3-A architectures.
+; On Armv8.3-A and onwards XPACI is available so use that instead.
+
+define i8* @ra0() nounwind readnone {
+entry:
+; CHECK-LABEL: ra0:
+; CHECK-NEXT: str x30, [sp, #-16]!
+; CHECK-NEXT: hint#7
+; CHECK-NEXT: mov x0, x30
+; CHECK-NEXT: ldr x30, [sp], #16
+; CHECK-NEXT: ret
+; CHECKV83:   str x30, [sp, #-16]!
+; CHECKV83-NEXT:  xpaci   x30
+; CHECKV83-NEXT:  mov x0, x30
+; CHECKV83-NEXT:  ldr x30, [sp], #16
+; CHECKV83-NEXT:  ret
+  %0 = tail call i8* @llvm.returnaddress(i32 0)
+  ret i8* %0
+}
+
+define i8* @ra1() nounwind readnone #0 {
+entry:
+; CHECK-LABEL: ra1:
+; CHECK:  hint#25
+; CHECK-NEXT: str x30, [sp, #-16]!
+; CHECK-NEXT: hint#7
+; CHECK-NEXT: mov x0, x30
+; CHECK-NEXT: ldr x30, [sp], #16
+; CHECK-NEXT: hint#29
+; CHECK-NEXT: ret
+; CHECKV83:   paciasp
+; CHECKV83-NEXT:  str x30, [sp, #-16]!
+; CHECKV83-NEXT:  xpaci   x30
+; CHECKV83-NEXT:  mov x0, x30
+; CHECKV83-NEXT:  ldr x30, [sp], #16
+; CHECKV83-NEXT:  retaa
+  %0 = tail call i8* @llvm.returnaddress(i32 0)
+  ret i8* %0
+}
+
+attributes #0 = { "sign-return-address"="all" }
+
+declare i8* @llvm.returnaddress(i32) nounwind readnone
Index: llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -6469,17 +6469,34 @@
   EVT VT = Op.getValueType();
   SDLoc DL(Op);
   unsigned Depth = cast(Op.getOperand(0))->getZExtValue();
+  SDValue ReturnAddress;
   if (Depth) {
 SDValue FrameAddr = LowerFRAMEADDR(Op, DAG);
 SDValue Offset = DAG.getConstan

[PATCH] D86065: [SVE] Make ElementCount members private

2020-08-27 Thread David Sherwood via Phabricator via cfe-commits
david-arm added inline comments.



Comment at: llvm/include/llvm/Support/TypeSize.h:108
+
+  bool isPowerOf2() const { return isPowerOf2_32(Min); }
 };

paulwalker-arm wrote:
> I don't believe this is safe.  For example we know SVE supported vector 
> lengths only have to be a multiple of 128bits.  So for scalable vectors we 
> cannot know the element count is a power of 2 unless we perform a runtime 
> check.
Ok, but if that's true how is code in llvm/lib/CodeGen/TargetLoweringBase.cpp 
ever safe for scalable vectors? I thought that the question being asked wasn't 
that the total size was a power of 2, but whether or not it was safe to split 
the vector. The answer should be the same even if vscale is 3, for example. I 
thought the problem here is that the legaliser simply needs to know in what way 
it should break down different types, and that whatever approach it took would 
work when scaled up. The vector breakdown algorithm relies upon having an 
answer here - perhaps this is just a case of changing the question and name of 
function?


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

https://reviews.llvm.org/D86065

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


[PATCH] D86289: [NFC][compiler-rt] Factor out __mulo[sdt]i3 implementations to .inc file

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfce035eae980: [NFC][compiler-rt] Factor out __mulo[sdt]i4 
implementations to .inc file (authored by atrosinenko).

Changed prior to commit:
  https://reviews.llvm.org/D86289?vs=287032&id=288279#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86289

Files:
  compiler-rt/lib/builtins/int_mulo_impl.inc
  compiler-rt/lib/builtins/mulodi4.c
  compiler-rt/lib/builtins/mulosi4.c
  compiler-rt/lib/builtins/muloti4.c

Index: compiler-rt/lib/builtins/muloti4.c
===
--- compiler-rt/lib/builtins/muloti4.c
+++ compiler-rt/lib/builtins/muloti4.c
@@ -18,36 +18,11 @@
 
 // Effects: sets *overflow to 1  if a * b overflows
 
+#define fixint_t ti_int
+#include "int_mulo_impl.inc"
+
 COMPILER_RT_ABI ti_int __muloti4(ti_int a, ti_int b, int *overflow) {
-  const int N = (int)(sizeof(ti_int) * CHAR_BIT);
-  const ti_int MIN = (ti_int)1 << (N - 1);
-  const ti_int MAX = ~MIN;
-  *overflow = 0;
-  ti_int result = a * b;
-  if (a == MIN) {
-if (b != 0 && b != 1)
-  *overflow = 1;
-return result;
-  }
-  if (b == MIN) {
-if (a != 0 && a != 1)
-  *overflow = 1;
-return result;
-  }
-  ti_int sa = a >> (N - 1);
-  ti_int abs_a = (a ^ sa) - sa;
-  ti_int sb = b >> (N - 1);
-  ti_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return result;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  *overflow = 1;
-  } else {
-if (abs_a > MIN / -abs_b)
-  *overflow = 1;
-  }
-  return result;
+  return __muloXi4(a, b, overflow);
 }
 
 #endif // CRT_HAS_128BIT
Index: compiler-rt/lib/builtins/mulosi4.c
===
--- compiler-rt/lib/builtins/mulosi4.c
+++ compiler-rt/lib/builtins/mulosi4.c
@@ -10,40 +10,13 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t si_int
+#include "int_mulo_impl.inc"
 
 // Returns: a * b
 
 // Effects: sets *overflow to 1  if a * b overflows
 
 COMPILER_RT_ABI si_int __mulosi4(si_int a, si_int b, int *overflow) {
-  const int N = (int)(sizeof(si_int) * CHAR_BIT);
-  const si_int MIN = (si_int)1 << (N - 1);
-  const si_int MAX = ~MIN;
-  *overflow = 0;
-  si_int result = a * b;
-  if (a == MIN) {
-if (b != 0 && b != 1)
-  *overflow = 1;
-return result;
-  }
-  if (b == MIN) {
-if (a != 0 && a != 1)
-  *overflow = 1;
-return result;
-  }
-  si_int sa = a >> (N - 1);
-  si_int abs_a = (a ^ sa) - sa;
-  si_int sb = b >> (N - 1);
-  si_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return result;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  *overflow = 1;
-  } else {
-if (abs_a > MIN / -abs_b)
-  *overflow = 1;
-  }
-  return result;
+  return __muloXi4(a, b, overflow);
 }
Index: compiler-rt/lib/builtins/mulodi4.c
===
--- compiler-rt/lib/builtins/mulodi4.c
+++ compiler-rt/lib/builtins/mulodi4.c
@@ -10,40 +10,13 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t di_int
+#include "int_mulo_impl.inc"
 
 // Returns: a * b
 
 // Effects: sets *overflow to 1  if a * b overflows
 
 COMPILER_RT_ABI di_int __mulodi4(di_int a, di_int b, int *overflow) {
-  const int N = (int)(sizeof(di_int) * CHAR_BIT);
-  const di_int MIN = (di_int)1 << (N - 1);
-  const di_int MAX = ~MIN;
-  *overflow = 0;
-  di_int result = a * b;
-  if (a == MIN) {
-if (b != 0 && b != 1)
-  *overflow = 1;
-return result;
-  }
-  if (b == MIN) {
-if (a != 0 && a != 1)
-  *overflow = 1;
-return result;
-  }
-  di_int sa = a >> (N - 1);
-  di_int abs_a = (a ^ sa) - sa;
-  di_int sb = b >> (N - 1);
-  di_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return result;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  *overflow = 1;
-  } else {
-if (abs_a > MIN / -abs_b)
-  *overflow = 1;
-  }
-  return result;
+  return __muloXi4(a, b, overflow);
 }
Index: compiler-rt/lib/builtins/int_mulo_impl.inc
===
--- compiler-rt/lib/builtins/int_mulo_impl.inc
+++ compiler-rt/lib/builtins/int_mulo_impl.inc
@@ -1,4 +1,4 @@
-//===-- mulodi4.c - Implement __mulodi4 ---===//
+//===-- int_mulo_impl.inc - Implement __mulo[sdt]i4 ---*- C -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===--===//
 //
-// This file implements __mulodi4 for the compiler_rt l

[PATCH] D86277: [NFC][compiler-rt] Factor out __mulv[sdt]i3 implementations to .inc file

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG182d14db07f1: [NFC][compiler-rt] Factor out __mulv[sdt]i3 
implementations to .inc file (authored by atrosinenko).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86277

Files:
  compiler-rt/lib/builtins/int_mulv_impl.inc
  compiler-rt/lib/builtins/mulvdi3.c
  compiler-rt/lib/builtins/mulvsi3.c
  compiler-rt/lib/builtins/mulvti3.c

Index: compiler-rt/lib/builtins/mulvti3.c
===
--- compiler-rt/lib/builtins/mulvti3.c
+++ compiler-rt/lib/builtins/mulvti3.c
@@ -18,34 +18,9 @@
 
 // Effects: aborts if a * b overflows
 
-COMPILER_RT_ABI ti_int __mulvti3(ti_int a, ti_int b) {
-  const int N = (int)(sizeof(ti_int) * CHAR_BIT);
-  const ti_int MIN = (ti_int)1 << (N - 1);
-  const ti_int MAX = ~MIN;
-  if (a == MIN) {
-if (b == 0 || b == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  if (b == MIN) {
-if (a == 0 || a == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  ti_int sa = a >> (N - 1);
-  ti_int abs_a = (a ^ sa) - sa;
-  ti_int sb = b >> (N - 1);
-  ti_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return a * b;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  compilerrt_abort();
-  } else {
-if (abs_a > MIN / -abs_b)
-  compilerrt_abort();
-  }
-  return a * b;
-}
+#define fixint_t ti_int
+#include "int_mulv_impl.inc"
+
+COMPILER_RT_ABI ti_int __mulvti3(ti_int a, ti_int b) { return __mulvXi3(a, b); }
 
 #endif // CRT_HAS_128BIT
Index: compiler-rt/lib/builtins/mulvsi3.c
===
--- compiler-rt/lib/builtins/mulvsi3.c
+++ compiler-rt/lib/builtins/mulvsi3.c
@@ -10,38 +10,11 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t si_int
+#include "int_mulv_impl.inc"
 
 // Returns: a * b
 
 // Effects: aborts if a * b overflows
 
-COMPILER_RT_ABI si_int __mulvsi3(si_int a, si_int b) {
-  const int N = (int)(sizeof(si_int) * CHAR_BIT);
-  const si_int MIN = (si_int)1 << (N - 1);
-  const si_int MAX = ~MIN;
-  if (a == MIN) {
-if (b == 0 || b == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  if (b == MIN) {
-if (a == 0 || a == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  si_int sa = a >> (N - 1);
-  si_int abs_a = (a ^ sa) - sa;
-  si_int sb = b >> (N - 1);
-  si_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return a * b;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  compilerrt_abort();
-  } else {
-if (abs_a > MIN / -abs_b)
-  compilerrt_abort();
-  }
-  return a * b;
-}
+COMPILER_RT_ABI si_int __mulvsi3(si_int a, si_int b) { return __mulvXi3(a, b); }
Index: compiler-rt/lib/builtins/mulvdi3.c
===
--- compiler-rt/lib/builtins/mulvdi3.c
+++ compiler-rt/lib/builtins/mulvdi3.c
@@ -10,38 +10,11 @@
 //
 //===--===//
 
-#include "int_lib.h"
+#define fixint_t di_int
+#include "int_mulv_impl.inc"
 
 // Returns: a * b
 
 // Effects: aborts if a * b overflows
 
-COMPILER_RT_ABI di_int __mulvdi3(di_int a, di_int b) {
-  const int N = (int)(sizeof(di_int) * CHAR_BIT);
-  const di_int MIN = (di_int)1 << (N - 1);
-  const di_int MAX = ~MIN;
-  if (a == MIN) {
-if (b == 0 || b == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  if (b == MIN) {
-if (a == 0 || a == 1)
-  return a * b;
-compilerrt_abort();
-  }
-  di_int sa = a >> (N - 1);
-  di_int abs_a = (a ^ sa) - sa;
-  di_int sb = b >> (N - 1);
-  di_int abs_b = (b ^ sb) - sb;
-  if (abs_a < 2 || abs_b < 2)
-return a * b;
-  if (sa == sb) {
-if (abs_a > MAX / abs_b)
-  compilerrt_abort();
-  } else {
-if (abs_a > MIN / -abs_b)
-  compilerrt_abort();
-  }
-  return a * b;
-}
+COMPILER_RT_ABI di_int __mulvdi3(di_int a, di_int b) { return __mulvXi3(a, b); }
Index: compiler-rt/lib/builtins/int_mulv_impl.inc
===
--- compiler-rt/lib/builtins/int_mulv_impl.inc
+++ compiler-rt/lib/builtins/int_mulv_impl.inc
@@ -1,4 +1,4 @@
-//===-- mulvdi3.c - Implement __mulvdi3 ---===//
+//===-- int_mulv_impl.inc - Implement __mulv[sdt]i3 ---*- C -*-===//
 //
 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
 // See https://llvm.org/LICENSE.txt for license information.
@@ -6,7 +6,7 @@
 //
 //===--===//
 //
-// This file implements __mulvdi3 for the compiler_rt library.
+// Helper used by __mulvsi3, __mulvdi3 and __mulvti3.
 //
 //===

[PATCH] D86289: [NFC][compiler-rt] Factor out __mulo[sdt]i3 implementations to .inc file

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Uploaded because it was already approved and no other review comments received 
since then. Anyway, please feel free to request followup changes if needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86289

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


[PATCH] D86277: [NFC][compiler-rt] Factor out __mulv[sdt]i3 implementations to .inc file

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Uploaded because it was already approved and no other review comments received 
since then. Anyway, please feel free to request followup changes if needed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86277

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


[PATCH] D86698: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

2020-08-27 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86698

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1745,19 +1745,15 @@
 struct X {
   friend X operator+(X, const X&);
 };
-// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
-// implicit copy constructor called on `x`. This should've been ignored already,
-// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
 )cpp",
   {R"txt(
 BinaryOperatorExpression Expression
-|-UnknownExpression LeftHandSide
-| `-IdExpression
-|   `-UnqualifiedId UnqualifiedId
-| `-'x'
+|-IdExpression LeftHandSide
+| `-UnqualifiedId UnqualifiedId
+|   `-'x'
 |-'+' OperatorToken
 `-IdExpression RightHandSide
   `-UnqualifiedId UnqualifiedId
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -44,8 +44,80 @@
 
 using namespace clang;
 
+static Expr *ignoreExprNodesImpl(Expr *E) { return E; }
+template 
+static Expr *ignoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&...Fns) {
+  return ignoreExprNodesImpl(Fn(E), std::forward(Fns)...);
+}
+
+template 
+static Expr *ignoreUntilFixedPoint(Expr *E, FnTys &&...Fns) {
+  Expr *LastE = nullptr;
+  while (E != LastE) {
+LastE = E;
+E = ignoreExprNodesImpl(E, std::forward(Fns)...);
+assert(E->getSourceRange() == LastE->getSourceRange());
+  }
+  return E;
+}
+
+static Expr *ignoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 {
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;
+}
+  }
+  return E;
+}
+
+static Expr *ignoreImplicitCast(Expr *E) {
+  if (auto *ICE = dyn_cast(E)) {
+
+auto *UnderlyingE = ICE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreFull(Expr *E) {
+  if (auto *FE = dyn_cast(E)) {
+auto *UnderlyingE = FE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreMaterializeTemporary(Expr *E) {
+  if (auto *MTE = dyn_cast(E)) {
+auto *UnderlyingE = MTE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreCXXBindTemporary(Expr *E) {
+  if (auto *BTE = dyn_cast(E)) {
+auto *UnderlyingE = BTE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreImplicit(Expr *E) {
+  return ignoreUntilFixedPoint(E, ignoreCXXBindTemporary, ignoreImplicitCast,
+   ignoreMaterializeTemporary, ignoreFull,
+   ignoreImplicitCXXConstructExpr);
+}
+
 LLVM_ATTRIBUTE_UNUSED
-static bool isImplicitExpr(Expr *E) { return E->IgnoreImplicit() != E; }
+static bool isImplicitExpr(Expr *E) { return ignoreImplicit(E) != E; }
 
 namespace {
 /// Get start location of the Declarator from the TypeLoc.
@@ -703,7 +775,7 @@
   for (auto *D : DS->decls())
 Builder.noticeDeclWithoutSemicolon(D);
 } else if (auto *E = dyn_cast_or_null(S)) {
-  return RecursiveASTVisitor::TraverseStmt(E->IgnoreImplicit());
+  return RecursiveASTVisitor::TraverseStmt(ignoreImplicit(E));
 }
 return RecursiveASTVisitor::TraverseStmt(S);
   }
@@ -1575,7 +1647,7 @@
 void syntax::TreeBuilder::markExprChild(Expr *Child, NodeRole Role) {
   if (!Child)
 return;
-  Child = Child->IgnoreImplicit();
+  Child = ignoreImplicit(Child);
 
   syntax::Tree *ChildNode = Mapping.find(Child);
   assert(ChildNode != nullptr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86698: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

2020-08-27 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas updated this revision to Diff 288282.
eduucaldas added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86698

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1745,19 +1745,15 @@
 struct X {
   friend X operator+(X, const X&);
 };
-// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
-// implicit copy constructor called on `x`. This should've been ignored already,
-// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
 )cpp",
   {R"txt(
 BinaryOperatorExpression Expression
-|-UnknownExpression LeftHandSide
-| `-IdExpression
-|   `-UnqualifiedId UnqualifiedId
-| `-'x'
+|-IdExpression LeftHandSide
+| `-UnqualifiedId UnqualifiedId
+|   `-'x'
 |-'+' OperatorToken
 `-IdExpression RightHandSide
   `-UnqualifiedId UnqualifiedId
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -44,8 +44,80 @@
 
 using namespace clang;
 
+static Expr *ignoreExprNodesImpl(Expr *E) { return E; }
+template 
+static Expr *ignoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&...Fns) {
+  return ignoreExprNodesImpl(Fn(E), std::forward(Fns)...);
+}
+
+template 
+static Expr *ignoreUntilFixedPoint(Expr *E, FnTys &&...Fns) {
+  Expr *LastE = nullptr;
+  while (E != LastE) {
+LastE = E;
+E = ignoreExprNodesImpl(E, std::forward(Fns)...);
+assert(E->getSourceRange() == LastE->getSourceRange());
+  }
+  return E;
+}
+
+static Expr *ignoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 {
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;
+}
+  }
+  return E;
+}
+
+static Expr *ignoreImplicitCast(Expr *E) {
+  if (auto *ICE = dyn_cast(E)) {
+
+auto *UnderlyingE = ICE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreFull(Expr *E) {
+  if (auto *FE = dyn_cast(E)) {
+auto *UnderlyingE = FE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreMaterializeTemporary(Expr *E) {
+  if (auto *MTE = dyn_cast(E)) {
+auto *UnderlyingE = MTE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreCXXBindTemporary(Expr *E) {
+  if (auto *BTE = dyn_cast(E)) {
+auto *UnderlyingE = BTE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreImplicit(Expr *E) {
+  return ignoreUntilFixedPoint(E, ignoreCXXBindTemporary, ignoreImplicitCast,
+   ignoreMaterializeTemporary, ignoreFull,
+   ignoreImplicitCXXConstructExpr);
+}
+
 LLVM_ATTRIBUTE_UNUSED
-static bool isImplicitExpr(Expr *E) { return E->IgnoreImplicit() != E; }
+static bool isImplicitExpr(Expr *E) { return ignoreImplicit(E) != E; }
 
 namespace {
 /// Get start location of the Declarator from the TypeLoc.
@@ -703,7 +775,7 @@
   for (auto *D : DS->decls())
 Builder.noticeDeclWithoutSemicolon(D);
 } else if (auto *E = dyn_cast_or_null(S)) {
-  return RecursiveASTVisitor::TraverseStmt(E->IgnoreImplicit());
+  return RecursiveASTVisitor::TraverseStmt(ignoreImplicit(E));
 }
 return RecursiveASTVisitor::TraverseStmt(S);
   }
@@ -1575,7 +1647,7 @@
 void syntax::TreeBuilder::markExprChild(Expr *Child, NodeRole Role) {
   if (!Child)
 return;
-  Child = Child->IgnoreImplicit();
+  Child = ignoreImplicit(Child);
 
   syntax::Tree *ChildNode = Mapping.find(Child);
   assert(ChildNode != nullptr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86699: [SyntaxTree] Ignore implicit non-leaf `CXXConstructExpr`

2020-08-27 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86699

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp

Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -1745,19 +1745,15 @@
 struct X {
   friend X operator+(X, const X&);
 };
-// FIXME: Remove additional `UnknownExpression` wrapping `x`. For that, ignore
-// implicit copy constructor called on `x`. This should've been ignored already,
-// as we `IgnoreImplicit` when traversing an `Stmt`.
 void test(X x, X y) {
   [[x + y]];
 }
 )cpp",
   {R"txt(
 BinaryOperatorExpression Expression
-|-UnknownExpression LeftHandSide
-| `-IdExpression
-|   `-UnqualifiedId UnqualifiedId
-| `-'x'
+|-IdExpression LeftHandSide
+| `-UnqualifiedId UnqualifiedId
+|   `-'x'
 |-'+' OperatorToken
 `-IdExpression RightHandSide
   `-UnqualifiedId UnqualifiedId
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -44,8 +44,80 @@
 
 using namespace clang;
 
+static Expr *ignoreExprNodesImpl(Expr *E) { return E; }
+template 
+static Expr *ignoreExprNodesImpl(Expr *E, FnTy &&Fn, FnTys &&...Fns) {
+  return ignoreExprNodesImpl(Fn(E), std::forward(Fns)...);
+}
+
+template 
+static Expr *ignoreUntilFixedPoint(Expr *E, FnTys &&...Fns) {
+  Expr *LastE = nullptr;
+  while (E != LastE) {
+LastE = E;
+E = ignoreExprNodesImpl(E, std::forward(Fns)...);
+assert(E->getSourceRange() == LastE->getSourceRange());
+  }
+  return E;
+}
+
+static Expr *ignoreImplicitCXXConstructExpr(Expr *E) {
+  if (auto *C = dyn_cast(E)) {
+auto NumArgs = C->getNumArgs();
+if (NumArgs == 1 || (NumArgs > 1 && isa(C->getArg(1 {
+  auto *A = C->getArg(0);
+  if (A->getSourceRange() == E->getSourceRange())
+return A;
+}
+  }
+  return E;
+}
+
+static Expr *ignoreImplicitCast(Expr *E) {
+  if (auto *ICE = dyn_cast(E)) {
+
+auto *UnderlyingE = ICE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreFull(Expr *E) {
+  if (auto *FE = dyn_cast(E)) {
+auto *UnderlyingE = FE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreMaterializeTemporary(Expr *E) {
+  if (auto *MTE = dyn_cast(E)) {
+auto *UnderlyingE = MTE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreCXXBindTemporary(Expr *E) {
+  if (auto *BTE = dyn_cast(E)) {
+auto *UnderlyingE = BTE->getSubExpr();
+assert(UnderlyingE->getSourceRange() == E->getSourceRange());
+return UnderlyingE;
+  }
+  return E;
+}
+
+static Expr *ignoreImplicit(Expr *E) {
+  return ignoreUntilFixedPoint(E, ignoreCXXBindTemporary, ignoreImplicitCast,
+   ignoreMaterializeTemporary, ignoreFull,
+   ignoreImplicitCXXConstructExpr);
+}
+
 LLVM_ATTRIBUTE_UNUSED
-static bool isImplicitExpr(Expr *E) { return E->IgnoreImplicit() != E; }
+static bool isImplicitExpr(Expr *E) { return ignoreImplicit(E) != E; }
 
 namespace {
 /// Get start location of the Declarator from the TypeLoc.
@@ -703,7 +775,7 @@
   for (auto *D : DS->decls())
 Builder.noticeDeclWithoutSemicolon(D);
 } else if (auto *E = dyn_cast_or_null(S)) {
-  return RecursiveASTVisitor::TraverseStmt(E->IgnoreImplicit());
+  return RecursiveASTVisitor::TraverseStmt(ignoreImplicit(E));
 }
 return RecursiveASTVisitor::TraverseStmt(S);
   }
@@ -1575,7 +1647,7 @@
 void syntax::TreeBuilder::markExprChild(Expr *Child, NodeRole Role) {
   if (!Child)
 return;
-  Child = Child->IgnoreImplicit();
+  Child = ignoreImplicit(Child);
 
   syntax::Tree *ChildNode = Mapping.find(Child);
   assert(ChildNode != nullptr);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86369: [Sema][MSVC] warn at dynamic_cast when /GR- is given

2020-08-27 Thread Hans Wennborg via Phabricator via cfe-commits
hans added inline comments.



Comment at: clang/lib/Sema/SemaCast.cpp:895
+  if (!Self.getLangOpts().RTTIData) {
+bool isMSVC = Self.getDiagnostics().getDiagnosticOptions().getFormat() ==
+  DiagnosticOptions::MSVC;

I'm not sure isMSVC is the best name (it's not clear what aspect is MSVC 
exactly -- in this case it's the diagnostics format).

It's possible to target MSVC both with clang-cl and with regular clang.

For example, one could use

  clang-cl /c /tmp/a.cpp

or

  clang -c /tmp/a.cpp -target i686-pc-windows-msvc19.11.0 -fms-extensions


My understanding is that the purpose of "isMSVC" here is to try and detect if 
we're using clang-cl or clang so that the diagnostic can say "/GR-" or 
"-fno-rtti-data". So maybe it's better to call it "isClangCL" or something like 
that.

Also, I don't think we should check "isMSVC" in the if-statement below. We want 
the warning to fire both when using clang and clang-cl: as long as 
-fno-rtti-data or /GR- is used, the warning makes sense.

So I think the code could be more like:

```
if (!Self.getLangOpts().RTTIData && !DestPointee->isVoidType()) {
  bool isClangCL = ...;
  Self.Diag(...) << isClangCL;
}
```



Comment at: clang/test/SemaCXX/ms_no_dynamic_cast.cpp:1
+// RUN: %clang_cl %s /GR- -fsyntax-only 2>&1 | FileCheck %s
+

zequanwu wrote:
> hans wrote:
> > When using %clang_cl, the source file should always come after a "--", 
> > otherwise if for example the source file is "/Users/foo/src/test.cc" the 
> > filename can get interpreted as a command-line option.
> > 
> > But tests outside of Driver/ generally invoke cc1 directly, with %clang_cc1 
> > and passing the appropriate flags. I'd suggest doing that here too. (And in 
> > the other test.)
> This test is for testing in clang-cl. Another test is for clang. If I use 
> %clang_cc1, /GR- can not be passed.
But clang-cl is just a driver mode, all it does is pass flags to the cc1 
invocation. So normally we test the driver separately (in Driver/) and the 
compiler (cc1) separately.

In this case the warning lives in the compiler (cc1) so it makes sense to 
target that directly with the test. If you grep through clang/test/Sema and 
clang/test/SemaCXX, you'll see that %clang_cl is not use in any test.

You should be able to run cc1 with and without "-fdiagnostics-format msvc" and 
-fno-rtti-data to test the new warnings.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86369

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


[PATCH] D86700: [SyntaxTree] Ignore leaf implicit `CXXConstructExpr`

2020-08-27 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86700

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/unittests/Tooling/Syntax/BuildTreeTest.cpp


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -548,9 +548,6 @@
   struct S { };
 }
 void test() {
-  // FIXME: Remove the `UnknownExpression` wrapping `s1` and `s2`. This
-  // `UnknownExpression` comes from a leaf `CXXConstructExpr` in the
-  // ClangAST. We need to ignore leaf implicit nodes.
   [[::n::S s1]];
   [[n::S s2]];
 }
@@ -564,8 +561,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -575,8 +571,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
@@ -608,8 +603,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -623,8 +617,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1146,6 +1146,12 @@
 return true;
   }
 
+  bool WalkUpFromCXXConstructExpr(CXXConstructExpr *S) {
+if (S->getParenOrBraceRange().isInvalid())
+  return true;
+return RecursiveASTVisitor::WalkUpFromCXXConstructExpr(S);
+  }
+
   bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
 // To construct a syntax tree of the same shape for calls to built-in and
 // user-defined operators, ignore the `DeclRefExpr` that refers to the


Index: clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
+++ clang/unittests/Tooling/Syntax/BuildTreeTest.cpp
@@ -548,9 +548,6 @@
   struct S { };
 }
 void test() {
-  // FIXME: Remove the `UnknownExpression` wrapping `s1` and `s2`. This
-  // `UnknownExpression` comes from a leaf `CXXConstructExpr` in the
-  // ClangAST. We need to ignore leaf implicit nodes.
   [[::n::S s1]];
   [[n::S s2]];
 }
@@ -564,8 +561,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -575,8 +571,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
@@ -608,8 +603,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s1'
+  `-'s1'
 )txt",
R"txt(
 SimpleDeclaration
@@ -623,8 +617,7 @@
 | `-'::' ListDelimiter
 |-'S'
 `-SimpleDeclarator Declarator
-  `-UnknownExpression
-`-'s2'
+  `-'s2'
 )txt"}));
 }
 
Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -1146,6 +1146,12 @@
 return true;
   }
 
+  bool WalkUpFromCXXConstructExpr(CXXConstructExpr *S) {
+if (S->getParenOrBraceRange().isInvalid())
+  return true;
+return RecursiveASTVisitor::WalkUpFromCXXConstructExpr(S);
+  }
+
   bool TraverseCXXOperatorCallExpr(CXXOperatorCallExpr *S) {
 // To construct a syntax tree of the same shape for calls to built-in and
 // user-defined operators, ignore the `DeclRefExpr` that refers to the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86065: [SVE] Make ElementCount members private

2020-08-27 Thread Paul Walker via Phabricator via cfe-commits
paulwalker-arm added a comment.

I cannot say whether such questions make sense without a deeper investigation, 
but I can say for certain that EC.isPowerOf2 is a question we cannot answer at 
compile time.  Given this is a mechanical change I would just remove the member 
function and leave the code as is (well change EC.Min to 
EC.getKnownMinValue()). We already know that we'll need to visit the places 
where getKnownMinValue() is used to ensure the question makes sense in the face 
of scalable vectors.


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

https://reviews.llvm.org/D86065

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


[PATCH] D85324: [SystemZ][z/OS] Add z/OS Target and define macros

2020-08-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan added inline comments.



Comment at: clang/test/Preprocessor/init-zos.c:4
+
+// S390X-ZOS-GNUXX:#define _EXT 1
+// S390X-ZOS:#define _LONG_LONG 1

MaskRay wrote:
> --match-full-lines  is different from --match-full-lines --strict-whitespace. 
> You can freely add leading and trailing spaces to align `#` for readability.
> 
> Might not be necessary changing now.
Thanks MaskRay, I will try to update this testcase in upcoming patches that 
touch this file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85324

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


[PATCH] D86581: [clang-format] Handle shifts within conditions

2020-08-27 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

@Saldivarcher do you have commit access?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86581

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


[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-08-27 Thread Raul Tambre via Phabricator via cfe-commits
tambre updated this revision to Diff 288292.
tambre added a comment.

Rebase, just in case


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  libunwind/src/CMakeLists.txt


Index: libunwind/src/CMakeLists.txt
===
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -24,14 +24,10 @@
 UnwindRegistersRestore.S
 UnwindRegistersSave.S
 )
-if (MINGW OR APPLE)
-  # CMake doesn't build assembly sources for windows/gnu targets properly
-  # (up to current CMake, 3.16), so treat them as C files.
-  # Additionally, CMake ignores OSX_ARCHITECTURE for ASM files when targeting
-  # Apple platforms.
-  set_source_files_properties(${LIBUNWIND_ASM_SOURCES}
-  PROPERTIES
-LANGUAGE C)
+
+# See add_asm_sources() in compiler-rt for explanation of this workaround.
+if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
+  set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)
 endif()
 
 set(LIBUNWIND_HEADERS
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will 
fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. 
https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. 
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by compiling as C.
+  # Same workaround used in libunwind. Also update there if changed here.
+  if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
 set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C)
   endif()
 endfunction()
Index: clang/runtime/CMakeLists.txt
===
--- clang/runtime/CMakeLists.txt
+++ clang/runtime/CMakeLists.txt
@@ -75,6 +75,7 @@
 CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+   -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config


Index: libunwind/src/CMakeLists.txt
===
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -24,14 +24,10 @@
 UnwindRegistersRestore.S
 UnwindRegistersSave.S
 )
-if (MINGW OR APPLE)
-  # CMake doesn't build assembly sources for windows/gnu targets properly
-  # (up to current CMake, 3.16), so treat them as C files.
-  # Additionally, CMake ignores OSX_ARCHITECTURE for ASM files when targeting
-  # Apple platforms.
-  set_source_files_properties(${LIBUNWIND_ASM_SOURCES}
-  PROPERTIES
-LANGUAGE C)
+
+# See add_asm_sources() in compiler-rt for explanation of this workaround.
+if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION VERSION_LESS 3.17))
+  set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)
 endif()
 
 set(LIBUNWIND_HEADERS
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by compiling as C.
+  # Same work

[PATCH] D78491: Avoid relying on address space zero default parameter in llvm/IR

2020-08-27 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added a comment.

Note to the readers: A recent-ish llvm-dev discussion around this patch can be 
found in here  
whrein a consensus is found on the way forward on this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78491

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


[PATCH] D86308: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-08-27 Thread Raul Tambre via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG45344cf7ac5b: [CMake][compiler-rt][libunwind] Compile 
assembly files as ASM not C, unify… (authored by tambre).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86308

Files:
  clang/runtime/CMakeLists.txt
  compiler-rt/cmake/Modules/AddCompilerRT.cmake
  libunwind/src/CMakeLists.txt


Index: libunwind/src/CMakeLists.txt
===
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -24,14 +24,10 @@
 UnwindRegistersRestore.S
 UnwindRegistersSave.S
 )
-if (MINGW OR APPLE)
-  # CMake doesn't build assembly sources for windows/gnu targets properly
-  # (up to current CMake, 3.16), so treat them as C files.
-  # Additionally, CMake ignores OSX_ARCHITECTURE for ASM files when targeting
-  # Apple platforms.
-  set_source_files_properties(${LIBUNWIND_ASM_SOURCES}
-  PROPERTIES
-LANGUAGE C)
+
+# See add_asm_sources() in compiler-rt for explanation of this workaround.
+if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
+  set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)
 endif()
 
 set(LIBUNWIND_HEADERS
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will 
fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. 
https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. 
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by compiling as C.
+  # Same workaround used in libunwind. Also update there if changed here.
+  if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
 set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C)
   endif()
 endfunction()
Index: clang/runtime/CMakeLists.txt
===
--- clang/runtime/CMakeLists.txt
+++ clang/runtime/CMakeLists.txt
@@ -75,6 +75,7 @@
 CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+   -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config


Index: libunwind/src/CMakeLists.txt
===
--- libunwind/src/CMakeLists.txt
+++ libunwind/src/CMakeLists.txt
@@ -24,14 +24,10 @@
 UnwindRegistersRestore.S
 UnwindRegistersSave.S
 )
-if (MINGW OR APPLE)
-  # CMake doesn't build assembly sources for windows/gnu targets properly
-  # (up to current CMake, 3.16), so treat them as C files.
-  # Additionally, CMake ignores OSX_ARCHITECTURE for ASM files when targeting
-  # Apple platforms.
-  set_source_files_properties(${LIBUNWIND_ASM_SOURCES}
-  PROPERTIES
-LANGUAGE C)
+
+# See add_asm_sources() in compiler-rt for explanation of this workaround.
+if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION VERSION_LESS 3.17))
+  set_source_files_properties(${LIBUNWIND_ASM_SOURCES} PROPERTIES LANGUAGE C)
 endif()
 
 set(LIBUNWIND_HEADERS
Index: compiler-rt/cmake/Modules/AddCompilerRT.cmake
===
--- compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW did

[libunwind] 45344cf - [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-08-27 Thread Raul Tambre via cfe-commits

Author: Raul Tambre
Date: 2020-08-27T15:40:15+03:00
New Revision: 45344cf7ac5b848f77825ffa37b0cb3b69b9b07b

URL: 
https://github.com/llvm/llvm-project/commit/45344cf7ac5b848f77825ffa37b0cb3b69b9b07b
DIFF: 
https://github.com/llvm/llvm-project/commit/45344cf7ac5b848f77825ffa37b0cb3b69b9b07b.diff

LOG: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify 
workarounds

It isn't very wise to pass an assembly file to the compiler and tell it to 
compile as a C file and hope that the compiler recognizes it as assembly 
instead.
Simply don't mark the file as C and CMake will recognize the rest.

This was attempted earlier in https://reviews.llvm.org/D85706, but reverted due 
to architecture issues on Apple.
Subsequent digging revealed a similar change was done earlier for libunwind in 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09.
Afterwards workarounds were added for MinGW and Apple:
* https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
* https://reviews.llvm.org/rGd4ded05ba851304b26a437896bc3962ef56f62cb

The workarounds in libunwind and compiler-rt are unified and comments added 
pointing to each other.
The workaround is updated to only be used for MinGW for CMake versions before 
3.17, which fixed the issue 
(https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287).

Additionally fixed Clang not being passed as the assembly compiler for 
compiler-rt runtime build.

Example error:
[525/634] Building C object 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
FAILED: lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
/opt/tooling/drive/host/bin/clang --target=aarch64-linux-gnu 
-I/opt/tooling/drive/llvm/compiler-rt/lib/tsan/.. -isystem 
/opt/tooling/drive/toolchain/opt/drive/toolchain/include -x c -Wall 
-Wno-unused-parameter -fno-lto -fPIC -fno-builtin -fno-exceptions 
-fomit-frame-pointer -funwind-tables -fno-stack-protector 
-fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only 
-Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE 
-fno-rtti -Wframe-larger-than=530 -Wglobal-constructors --sysroot=. -MD -MT 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -MF 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o.d -o 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -c 
/opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
/opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S:29:1: 
error: expected identifier or '('
.section .text
^
1 error generated.

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

Added: 


Modified: 
clang/runtime/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index e20cc26f60af..61bbbf8faedd 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -75,6 +75,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS 
${COMPILER_RT_SRC_ROOT}/)
 CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+   -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config

diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index efb660818270..f2f0b5ecde59 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@ endfunction()
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will 
fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. 
https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. 
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by compiling as C.
+  # Same workaround used in libunwind. Also update there if changed here.
+  if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
 set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C)
   endif()
 endfunction()

diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 928bc5992471..094

[clang] 45344cf - [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify workarounds

2020-08-27 Thread Raul Tambre via cfe-commits

Author: Raul Tambre
Date: 2020-08-27T15:40:15+03:00
New Revision: 45344cf7ac5b848f77825ffa37b0cb3b69b9b07b

URL: 
https://github.com/llvm/llvm-project/commit/45344cf7ac5b848f77825ffa37b0cb3b69b9b07b
DIFF: 
https://github.com/llvm/llvm-project/commit/45344cf7ac5b848f77825ffa37b0cb3b69b9b07b.diff

LOG: [CMake][compiler-rt][libunwind] Compile assembly files as ASM not C, unify 
workarounds

It isn't very wise to pass an assembly file to the compiler and tell it to 
compile as a C file and hope that the compiler recognizes it as assembly 
instead.
Simply don't mark the file as C and CMake will recognize the rest.

This was attempted earlier in https://reviews.llvm.org/D85706, but reverted due 
to architecture issues on Apple.
Subsequent digging revealed a similar change was done earlier for libunwind in 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09.
Afterwards workarounds were added for MinGW and Apple:
* https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
* https://reviews.llvm.org/rGd4ded05ba851304b26a437896bc3962ef56f62cb

The workarounds in libunwind and compiler-rt are unified and comments added 
pointing to each other.
The workaround is updated to only be used for MinGW for CMake versions before 
3.17, which fixed the issue 
(https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287).

Additionally fixed Clang not being passed as the assembly compiler for 
compiler-rt runtime build.

Example error:
[525/634] Building C object 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
FAILED: lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o
/opt/tooling/drive/host/bin/clang --target=aarch64-linux-gnu 
-I/opt/tooling/drive/llvm/compiler-rt/lib/tsan/.. -isystem 
/opt/tooling/drive/toolchain/opt/drive/toolchain/include -x c -Wall 
-Wno-unused-parameter -fno-lto -fPIC -fno-builtin -fno-exceptions 
-fomit-frame-pointer -funwind-tables -fno-stack-protector 
-fno-sanitize=safe-stack -fvisibility=hidden -fno-lto -O3 -gline-tables-only 
-Wno-gnu -Wno-variadic-macros -Wno-c99-extensions -Wno-non-virtual-dtor -fPIE 
-fno-rtti -Wframe-larger-than=530 -Wglobal-constructors --sysroot=. -MD -MT 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -MF 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o.d -o 
lib/tsan/CMakeFiles/clang_rt.tsan-aarch64.dir/rtl/tsan_rtl_aarch64.S.o -c 
/opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S
/opt/tooling/drive/llvm/compiler-rt/lib/tsan/rtl/tsan_rtl_aarch64.S:29:1: 
error: expected identifier or '('
.section .text
^
1 error generated.

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

Added: 


Modified: 
clang/runtime/CMakeLists.txt
compiler-rt/cmake/Modules/AddCompilerRT.cmake
libunwind/src/CMakeLists.txt

Removed: 




diff  --git a/clang/runtime/CMakeLists.txt b/clang/runtime/CMakeLists.txt
index e20cc26f60af..61bbbf8faedd 100644
--- a/clang/runtime/CMakeLists.txt
+++ b/clang/runtime/CMakeLists.txt
@@ -75,6 +75,7 @@ if(LLVM_BUILD_EXTERNAL_COMPILER_RT AND EXISTS 
${COMPILER_RT_SRC_ROOT}/)
 CMAKE_ARGS ${CLANG_COMPILER_RT_CMAKE_ARGS}
-DCMAKE_C_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_CXX_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang++
+   -DCMAKE_ASM_COMPILER=${LLVM_RUNTIME_OUTPUT_INTDIR}/clang
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_MAKE_PROGRAM=${CMAKE_MAKE_PROGRAM}
-DLLVM_CONFIG_PATH=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-config

diff  --git a/compiler-rt/cmake/Modules/AddCompilerRT.cmake 
b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
index efb660818270..f2f0b5ecde59 100644
--- a/compiler-rt/cmake/Modules/AddCompilerRT.cmake
+++ b/compiler-rt/cmake/Modules/AddCompilerRT.cmake
@@ -109,11 +109,11 @@ endfunction()
 
 function(add_asm_sources output)
   set(${output} ${ARGN} PARENT_SCOPE)
-  # Xcode will try to compile asm files as C ('clang -x c'), and that will 
fail.
-  if (${CMAKE_GENERATOR} STREQUAL "Xcode")
-enable_language(ASM)
-  else()
-# Pass ASM file directly to the C++ compiler.
+  # CMake doesn't pass the correct architecture for Apple prior to CMake 3.19. 
https://gitlab.kitware.com/cmake/cmake/-/issues/20771
+  # MinGW didn't work correctly with assembly prior to CMake 3.17. 
https://gitlab.kitware.com/cmake/cmake/-/merge_requests/4287 and 
https://reviews.llvm.org/rGb780df052dd2b246a760d00e00f7de9ebdab9d09
+  # Workaround these two issues by compiling as C.
+  # Same workaround used in libunwind. Also update there if changed here.
+  if((APPLE AND CMAKE_VERSION VERSION_LESS 3.19) OR (MINGW AND CMAKE_VERSION 
VERSION_LESS 3.17))
 set_source_files_properties(${ARGN} PROPERTIES LANGUAGE C)
   endif()
 endfunction()

diff  --git a/libunwind/src/CMakeLists.txt b/libunwind/src/CMakeLists.txt
index 928bc5992471..094

[PATCH] D86169: Initial support for letting plugins perform custom parsing of attribute arguments.

2020-08-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D86169#2240384 , 
@jonathan.protzenko wrote:

>> I'm hoping we can devise a way to not require the entity being attributed to 
>> be passed when parsing the attribute
>
> That sounds nice. My only concern with this proposal is to make sure this 
> doesn't rule out the interesting use-cases I was mentioning, like the 
> `managed_string` example I presented in the motivation section.

That should be possible.

> These use-cases would need to have some contextual information to perform 
> meaningful parsing. Note that I'm not particularly committed to struct field 
> declarations, one could imagine interesting use-cases with function 
> arguments, such as:
>
>   void f (int *arr [[ alloc_size(arr) == 8 ]], size_t idx [[ idx <= 4 ]])
>
> But I agree about the parsing problems you mention, and being unable to 
> meaningfully pass a `Declarator` (or anything else) based on incomplete 
> parsing information. Here's a solution that might makes us both happy :), but 
> you'd have to tell me if this is workable.
>
> - Upon encountering `[[ attr(X) ]]` where `attr` is a plugin-handled 
> attribute: clang parses `X` as token soup, only caring about finding a 
> matching parenthesis

Just to be clear, what you mean is to lex all of the tokens comprising `X` and 
store them off for later?

> - The complete construct (declaration, type, statement, or whatever the 
> attribute appertains to) is parsed.
> - Plugin's `diagAppertainsToDecl` gets called (as before). Plugin is free to 
> store in its internal state whatever information from the `Decl` is relevant.
> - Plugin's `parseAttributePayload` gets called in a state that consumes the 
> token soup (not sure if that's feasible?). The `parseAttributePayload` method 
> does not receive a `Declarator` or anything else. Plugins can rely on the 
> fact that if `diagAppertainsToDecl` returns `true`, `parseAttributePayload` 
> will be called next, and refer to its internal state to fetch whatever 
> information from the `Decl` it needs.
>
> Does this stand any chance of working?

This is along the same lines of what I was thinking, but there is one potential 
snag. Clang layers our library components and Sema should never refer back to 
the Parser (it doesn't link the library in). Because you have an odd 
requirement where you need to do further parsing during the semantics stage, 
you may run into awkwardness from this. Also, you may have to worry about 
needing this functionality recursively. e.g., `int x [[your_attr(int y 
[[your_attr(int z;)]];)]];` which could be... interesting.

> Bonus question: seeing `diagAppertainsToDecl`, the name of this function led 
> me to believe that for now, plugins could only handle attributes attached to 
> declarations. Is this the case?

Correct, the plugin system does not yet handle type or statement attributes (it 
was focusing on declaration attributes first, which are the lion's share of 
attributes in Clang).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86169

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


[PATCH] D85091: [Sema, CodeGen] Implement [[likely]] and [[unlikely]] in IfStmt

2020-08-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:1726
+  }
+  }];
+}

Mordante wrote:
> aaron.ballman wrote:
> > Something else we should document is what our behavior is when the 
> > attribute is not immediately inside of an `if` or `else` statement. e.g.,
> > ```
> > void func() { // Does not behave as though specified with [[gnu::hot]]
> >   [[likely]];
> > }
> > 
> > void func() {
> >   if (x) {
> > {
> >   [[likely]]; // Does this make the if branch likely?
> >   SomeRAIIObj Obj;
> > }
> >   } else {
> >   }
> > }
> > 
> > void func() {
> >   if (x) {
> > int y = ({[[likely]]; /* Does this make the if branch likely? */ 1;});
> >   } else {
> >   }
> > }
> > ```
> > Something else we should document is what our behavior is when the 
> > attribute is not immediately inside of an `if` or `else` statement. e.g.,
> > ```
> > void func() { // Does not behave as though specified with [[gnu::hot]]
> >   [[likely]];
> > }
> 
> No a few days ago I wondered whether it makes sense, but the [[gnu::hot]] 
> should be at the declaration of the function and not in the body. 
> So I think this doesn't make sense and the `[[likely]]` here will be ignored.
> 
> > void func() {
> >   if (x) {
> > {
> >   [[likely]]; // Does this make the if branch likely?
> >   SomeRAIIObj Obj;
> > }
> >   } else {
> >   }
> > }
> 
> Yes this should work, the attribute will recursively visit compound 
> statements.
> 
> > void func() {
> >   if (x) {
> > int y = ({[[likely]]; /* Does this make the if branch likely? */ 1;});
> >   } else {
> >   }
> > }
> > ```
> 
> Not in this patch. I'm working on more improvements to make switch statements 
> working. I tested it with my current WIP and there it does work.
> So in the future this will work.
> So I think this doesn't make sense and the [[likely]] here will be ignored.

Great, that matches the behavior I was hoping for.

> Yes this should work, the attribute will recursively visit compound 
> statements.

Great!

> Not in this patch. I'm working on more improvements to make switch statements 
> working.

I'm not certain what that example had to do with switch statement, but just as 
an FYI, I'd like this to work initially (assuming it's not overly hard) only 
because GNU statement expressions show up rather frequently in macros as an 
alternative form of the `do ... while (0);` pattern, which can have 
likely/unlikely path sensitivity.



Comment at: clang/lib/CodeGen/CGStmt.cpp:691
+  Visit(S);
+  if (Result != None)
+return;

Mordante wrote:
> aaron.ballman wrote:
> > Is early return the correct logic? Won't that give surprising results in 
> > the case the programmer has both attributes in the same compound statement? 
> > I think we need to look over all the statements in the current block, 
> > increment a counter when we hit `[[likely]]`, decrement the counter when we 
> > hit `[[unlikely]]` and return whether the counter is 0, negative 
> > (unlikely), or positive (likely).
> Yes here it accepts the first likelihood it finds and accepts that as the 
> wanted likelihood. I also start to doubt whether that's wanted. In my current 
> switch WIP I  issue an diagnostic if there's a conflict between the 
> likelihood diagnostics and ignore them. I feel that's a better approach. This 
> diagnostic is added to the `-Wignored-attributes` group, which is shown by 
> default.
> 
> I don't like the idea of using a counter. If the attribute is "hidden" in a 
> validation macro, adding it to a branch might suddenly change the likelihood 
> of that branch.
> 
> I don't like the idea of using a counter. If the attribute is "hidden" in a 
> validation macro, adding it to a branch might suddenly change the likelihood 
> of that branch.

That's definitely true and is also a concern of mine. I don't know what the 
correct answer is here by going on a per-statement basis. None of the solutions 
are satisfying and all of them leave this feature with surprising behavior.



Comment at: clang/lib/CodeGen/CGStmt.cpp:791
+  llvm::MDNode *Weights = nullptr;
+  uint64_t Count = getProfileCount(S.getThen());
+  if (!Count && CGM.getCodeGenOpts().OptimizationLevel) {

Mordante wrote:
> aaron.ballman wrote:
> > Perhaps not for this patch, but I wonder if we'd be doing users a good deed 
> > by alerting them when PGO weights do not match the attribute specified. 
> > e.g., if an attribute says "this branch is likely" and PGO shows it's 
> > unlikely, that seems like something the programmer may wish to know. WDYT?
> I already investigated before and there's a diagnostic 
> `warn_profile_data_misexpect` when using `__builtin_expect` so I expect I can 
> reuse existing code. So I want to have a look at it, but I first want to get 
> the more important parts of the likelihood attributes working properly.
> So I want to have 

[clang] ac87a0b - [SyntaxTree][NFC][Style] Functions start with lowercase

2020-08-27 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-27T12:55:24Z
New Revision: ac87a0b5873cc14b23eeb25a0586b26cc5c2c33f

URL: 
https://github.com/llvm/llvm-project/commit/ac87a0b5873cc14b23eeb25a0586b26cc5c2c33f
DIFF: 
https://github.com/llvm/llvm-project/commit/ac87a0b5873cc14b23eeb25a0586b26cc5c2c33f.diff

LOG: [SyntaxTree][NFC][Style] Functions start with lowercase

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

Added: 


Modified: 
clang/lib/Tooling/Syntax/BuildTree.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Syntax/BuildTree.cpp 
b/clang/lib/Tooling/Syntax/BuildTree.cpp
index 9e2f8178df90..b07e9c3faf9d 100644
--- a/clang/lib/Tooling/Syntax/BuildTree.cpp
+++ b/clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -820,7 +820,7 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
   }
 
   syntax::NameSpecifier *
-  BuildNameSpecifier(const NestedNameSpecifierLoc &NNSLoc) {
+  buildNameSpecifier(const NestedNameSpecifierLoc &NNSLoc) {
 assert(NNSLoc.hasQualifier());
 auto NameSpecifierTokens =
 Builder.getRange(getLocalSourceRange(NNSLoc)).drop_back();
@@ -870,7 +870,7 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
 if (!QualifierLoc)
   return true;
 for (auto it = QualifierLoc; it; it = it.getPrefix()) {
-  auto *NS = BuildNameSpecifier(it);
+  auto *NS = buildNameSpecifier(it);
   if (!NS)
 return false;
   Builder.markChild(NS, syntax::NodeRole::ListElement);
@@ -1221,7 +1221,7 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
 if (!L.getTypePtr()->hasTrailingReturn())
   return WalkUpFromFunctionTypeLoc(L);
 
-auto *TrailingReturnTokens = BuildTrailingReturn(L);
+auto *TrailingReturnTokens = buildTrailingReturn(L);
 // Finish building the node for parameters.
 Builder.markChild(TrailingReturnTokens, syntax::NodeRole::TrailingReturn);
 return WalkUpFromFunctionTypeLoc(L);
@@ -1459,7 +1459,7 @@ class BuildTreeVisitor : public 
RecursiveASTVisitor {
   }
 
   /// Returns the range of the built node.
-  syntax::TrailingReturnType *BuildTrailingReturn(FunctionProtoTypeLoc L) {
+  syntax::TrailingReturnType *buildTrailingReturn(FunctionProtoTypeLoc L) {
 assert(L.getTypePtr()->hasTrailingReturn());
 
 auto ReturnedType = L.getReturnLoc();



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


[PATCH] D86682: [SyntaxTree][NFC][Style] Functions start with lowercase

2020-08-27 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGac87a0b5873c: [SyntaxTree][NFC][Style] Functions start with 
lowercase (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86682

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp


Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -820,7 +820,7 @@
   }
 
   syntax::NameSpecifier *
-  BuildNameSpecifier(const NestedNameSpecifierLoc &NNSLoc) {
+  buildNameSpecifier(const NestedNameSpecifierLoc &NNSLoc) {
 assert(NNSLoc.hasQualifier());
 auto NameSpecifierTokens =
 Builder.getRange(getLocalSourceRange(NNSLoc)).drop_back();
@@ -870,7 +870,7 @@
 if (!QualifierLoc)
   return true;
 for (auto it = QualifierLoc; it; it = it.getPrefix()) {
-  auto *NS = BuildNameSpecifier(it);
+  auto *NS = buildNameSpecifier(it);
   if (!NS)
 return false;
   Builder.markChild(NS, syntax::NodeRole::ListElement);
@@ -1221,7 +1221,7 @@
 if (!L.getTypePtr()->hasTrailingReturn())
   return WalkUpFromFunctionTypeLoc(L);
 
-auto *TrailingReturnTokens = BuildTrailingReturn(L);
+auto *TrailingReturnTokens = buildTrailingReturn(L);
 // Finish building the node for parameters.
 Builder.markChild(TrailingReturnTokens, syntax::NodeRole::TrailingReturn);
 return WalkUpFromFunctionTypeLoc(L);
@@ -1459,7 +1459,7 @@
   }
 
   /// Returns the range of the built node.
-  syntax::TrailingReturnType *BuildTrailingReturn(FunctionProtoTypeLoc L) {
+  syntax::TrailingReturnType *buildTrailingReturn(FunctionProtoTypeLoc L) {
 assert(L.getTypePtr()->hasTrailingReturn());
 
 auto ReturnedType = L.getReturnLoc();


Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -820,7 +820,7 @@
   }
 
   syntax::NameSpecifier *
-  BuildNameSpecifier(const NestedNameSpecifierLoc &NNSLoc) {
+  buildNameSpecifier(const NestedNameSpecifierLoc &NNSLoc) {
 assert(NNSLoc.hasQualifier());
 auto NameSpecifierTokens =
 Builder.getRange(getLocalSourceRange(NNSLoc)).drop_back();
@@ -870,7 +870,7 @@
 if (!QualifierLoc)
   return true;
 for (auto it = QualifierLoc; it; it = it.getPrefix()) {
-  auto *NS = BuildNameSpecifier(it);
+  auto *NS = buildNameSpecifier(it);
   if (!NS)
 return false;
   Builder.markChild(NS, syntax::NodeRole::ListElement);
@@ -1221,7 +1221,7 @@
 if (!L.getTypePtr()->hasTrailingReturn())
   return WalkUpFromFunctionTypeLoc(L);
 
-auto *TrailingReturnTokens = BuildTrailingReturn(L);
+auto *TrailingReturnTokens = buildTrailingReturn(L);
 // Finish building the node for parameters.
 Builder.markChild(TrailingReturnTokens, syntax::NodeRole::TrailingReturn);
 return WalkUpFromFunctionTypeLoc(L);
@@ -1459,7 +1459,7 @@
   }
 
   /// Returns the range of the built node.
-  syntax::TrailingReturnType *BuildTrailingReturn(FunctionProtoTypeLoc L) {
+  syntax::TrailingReturnType *buildTrailingReturn(FunctionProtoTypeLoc L) {
 assert(L.getTypePtr()->hasTrailingReturn());
 
 auto ReturnedType = L.getReturnLoc();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] fda3fa8 - [SyntaxTree][NFC] Append "get" to syntax Nodes accessor names

2020-08-27 Thread Eduardo Caldas via cfe-commits

Author: Eduardo Caldas
Date: 2020-08-27T12:55:23Z
New Revision: fda3fa822cb6812c8db63f7cee4a8387e71e66ff

URL: 
https://github.com/llvm/llvm-project/commit/fda3fa822cb6812c8db63f7cee4a8387e71e66ff
DIFF: 
https://github.com/llvm/llvm-project/commit/fda3fa822cb6812c8db63f7cee4a8387e71e66ff.diff

LOG: [SyntaxTree][NFC] Append "get" to syntax Nodes accessor names

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

Added: 


Modified: 
clang/include/clang/Tooling/Syntax/Nodes.h
clang/lib/Tooling/Syntax/Nodes.cpp

Removed: 




diff  --git a/clang/include/clang/Tooling/Syntax/Nodes.h 
b/clang/include/clang/Tooling/Syntax/Nodes.h
index 4a483111aad3..a6505c8167ee 100644
--- a/clang/include/clang/Tooling/Syntax/Nodes.h
+++ b/clang/include/clang/Tooling/Syntax/Nodes.h
@@ -271,9 +271,9 @@ class NestedNameSpecifier final : public List {
   static bool classof(const Node *N) {
 return N->kind() <= NodeKind::NestedNameSpecifier;
   }
-  std::vector specifiers();
+  std::vector getSpecifiers();
   std::vector>
-  specifiersAndDoubleColons();
+  getSpecifiersAndDoubleColons();
 };
 
 /// Models an `unqualified-id`. C++ [expr.prim.id.unqual]
@@ -299,9 +299,9 @@ class IdExpression final : public Expression {
   static bool classof(const Node *N) {
 return N->kind() == NodeKind::IdExpression;
   }
-  NestedNameSpecifier *qualifier();
-  Leaf *templateKeyword();
-  UnqualifiedId *unqualifiedId();
+  NestedNameSpecifier *getQualifier();
+  Leaf *getTemplateKeyword();
+  UnqualifiedId *getUnqualifiedId();
 };
 
 /// An expression of an unknown kind, i.e. one not currently handled by the
@@ -321,7 +321,7 @@ class ThisExpression final : public Expression {
   static bool classof(const Node *N) {
 return N->kind() == NodeKind::ThisExpression;
   }
-  Leaf *thisKeyword();
+  Leaf *getThisKeyword();
 };
 
 /// Models arguments of a function call.
@@ -335,8 +335,8 @@ class CallArguments final : public List {
   static bool classof(const Node *N) {
 return N->kind() <= NodeKind::CallArguments;
   }
-  std::vector arguments();
-  std::vector> argumentsAndCommas();
+  std::vector getArguments();
+  std::vector> getArgumentsAndCommas();
 };
 
 /// A function call. C++ [expr.call]
@@ -349,10 +349,10 @@ class CallExpression final : public Expression {
   static bool classof(const Node *N) {
 return N->kind() == NodeKind::CallExpression;
   }
-  Expression *callee();
-  Leaf *openParen();
-  CallArguments *arguments();
-  Leaf *closeParen();
+  Expression *getCallee();
+  Leaf *getOpenParen();
+  CallArguments *getArguments();
+  Leaf *getCloseParen();
 };
 
 /// Models a parenthesized expression `(E)`. C++ [expr.prim.paren]
@@ -363,9 +363,9 @@ class ParenExpression final : public Expression {
   static bool classof(const Node *N) {
 return N->kind() == NodeKind::ParenExpression;
   }
-  Leaf *openParen();
-  Expression *subExpression();
-  Leaf *closeParen();
+  Leaf *getOpenParen();
+  Expression *getSubExpression();
+  Leaf *getCloseParen();
 };
 
 /// Models a class member access. C++ [expr.ref]
@@ -382,10 +382,10 @@ class MemberExpression final : public Expression {
   static bool classof(const Node *N) {
 return N->kind() == NodeKind::MemberExpression;
   }
-  Expression *object();
-  Leaf *accessToken();
-  Leaf *templateKeyword();
-  IdExpression *member();
+  Expression *getObject();
+  Leaf *getAccessToken();
+  Leaf *getTemplateKeyword();
+  IdExpression *getMember();
 };
 
 /// Expression for literals. C++ [lex.literal]
@@ -404,7 +404,7 @@ class LiteralExpression : public Expression {
N->kind() == NodeKind::CharUserDefinedLiteralExpression ||
N->kind() == NodeKind::StringUserDefinedLiteralExpression;
   }
-  Leaf *literalToken();
+  Leaf *getLiteralToken();
 };
 
 /// Expression for integer literals. C++ [lex.icon]
@@ -539,8 +539,8 @@ class UnaryOperatorExpression : public Expression {
 return N->kind() == NodeKind::PrefixUnaryOperatorExpression ||
N->kind() == NodeKind::PostfixUnaryOperatorExpression;
   }
-  Leaf *operatorToken();
-  Expression *operand();
+  Leaf *getOperatorToken();
+  Expression *getOperand();
 };
 
 ///  
@@ -588,9 +588,9 @@ class BinaryOperatorExpression final : public Expression {
   static bool classof(const Node *N) {
 return N->kind() == NodeKind::BinaryOperatorExpression;
   }
-  Expression *lhs();
-  Leaf *operatorToken();
-  Expression *rhs();
+  Expression *getLhs();
+  Leaf *getOperatorToken();
+  Expression *getRhs();
 };
 
 /// An abstract node for C++ statements, e.g. 'while', 'if', etc.
@@ -639,8 +639,8 @@ class SwitchStatement final : public Statement {
   static bool classof(const Node *N) {
 return N->kind() == NodeKind::SwitchStatement;
   }
-  Leaf *switchKeyword();
-  Statement *body();
+  Leaf *getSwitchKeyword();
+  Statement *getBody();
 };
 
 /// case : 
@@ -650,9 +650,9 @@ class CaseStatement final : public

[PATCH] D86679: [SyntaxTree][NFC] Append "get" to syntax Nodes accessor names

2020-08-27 Thread Eduardo Caldas via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGfda3fa822cb6: [SyntaxTree][NFC] Append "get" to 
syntax Nodes accessor names (authored by eduucaldas).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86679

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/Nodes.cpp

Index: clang/lib/Tooling/Syntax/Nodes.cpp
===
--- clang/lib/Tooling/Syntax/Nodes.cpp
+++ clang/lib/Tooling/Syntax/Nodes.cpp
@@ -224,7 +224,8 @@
 
 // We could have an interator in list to not pay memory costs of temporary
 // vector
-std::vector syntax::NestedNameSpecifier::specifiers() {
+std::vector
+syntax::NestedNameSpecifier::getSpecifiers() {
   auto specifiersAsNodes = getElementsAsNodes();
   std::vector Children;
   for (const auto &element : specifiersAsNodes) {
@@ -234,7 +235,7 @@
 }
 
 std::vector>
-syntax::NestedNameSpecifier::specifiersAndDoubleColons() {
+syntax::NestedNameSpecifier::getSpecifiersAndDoubleColons() {
   auto specifiersAsNodesAndDoubleColons = getElementsAsNodesAndDelimiters();
   std::vector>
   Children;
@@ -246,7 +247,7 @@
   return Children;
 }
 
-std::vector syntax::CallArguments::arguments() {
+std::vector syntax::CallArguments::getArguments() {
   auto ArgumentsAsNodes = getElementsAsNodes();
   std::vector Children;
   for (const auto &ArgumentAsNode : ArgumentsAsNodes) {
@@ -256,7 +257,7 @@
 }
 
 std::vector>
-syntax::CallArguments::argumentsAndCommas() {
+syntax::CallArguments::getArgumentsAndCommas() {
   auto ArgumentsAsNodesAndCommas = getElementsAsNodesAndDelimiters();
   std::vector> Children;
   for (const auto &ArgumentAsNodeAndComma : ArgumentsAsNodesAndCommas) {
@@ -268,7 +269,7 @@
 }
 
 std::vector
-syntax::ParameterDeclarationList::parameterDeclarations() {
+syntax::ParameterDeclarationList::getParameterDeclarations() {
   auto ParametersAsNodes = getElementsAsNodes();
   std::vector Children;
   for (const auto &ParameterAsNode : ParametersAsNodes) {
@@ -278,7 +279,7 @@
 }
 
 std::vector>
-syntax::ParameterDeclarationList::parametersAndCommas() {
+syntax::ParameterDeclarationList::getParametersAndCommas() {
   auto ParametersAsNodesAndCommas = getElementsAsNodesAndDelimiters();
   std::vector>
   Children;
@@ -290,215 +291,215 @@
   return Children;
 }
 
-syntax::Expression *syntax::MemberExpression::object() {
+syntax::Expression *syntax::MemberExpression::getObject() {
   return cast_or_null(findChild(syntax::NodeRole::Object));
 }
 
-syntax::Leaf *syntax::MemberExpression::templateKeyword() {
+syntax::Leaf *syntax::MemberExpression::getTemplateKeyword() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TemplateKeyword));
 }
 
-syntax::Leaf *syntax::MemberExpression::accessToken() {
+syntax::Leaf *syntax::MemberExpression::getAccessToken() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::AccessToken));
 }
 
-syntax::IdExpression *syntax::MemberExpression::member() {
+syntax::IdExpression *syntax::MemberExpression::getMember() {
   return cast_or_null(
   findChild(syntax::NodeRole::Member));
 }
 
-syntax::NestedNameSpecifier *syntax::IdExpression::qualifier() {
+syntax::NestedNameSpecifier *syntax::IdExpression::getQualifier() {
   return cast_or_null(
   findChild(syntax::NodeRole::Qualifier));
 }
 
-syntax::Leaf *syntax::IdExpression::templateKeyword() {
+syntax::Leaf *syntax::IdExpression::getTemplateKeyword() {
   return llvm::cast_or_null(
   findChild(syntax::NodeRole::TemplateKeyword));
 }
 
-syntax::UnqualifiedId *syntax::IdExpression::unqualifiedId() {
+syntax::UnqualifiedId *syntax::IdExpression::getUnqualifiedId() {
   return cast_or_null(
   findChild(syntax::NodeRole::UnqualifiedId));
 }
 
-syntax::Leaf *syntax::ParenExpression::openParen() {
+syntax::Leaf *syntax::ParenExpression::getOpenParen() {
   return cast_or_null(findChild(syntax::NodeRole::OpenParen));
 }
 
-syntax::Expression *syntax::ParenExpression::subExpression() {
+syntax::Expression *syntax::ParenExpression::getSubExpression() {
   return cast_or_null(
   findChild(syntax::NodeRole::SubExpression));
 }
 
-syntax::Leaf *syntax::ParenExpression::closeParen() {
+syntax::Leaf *syntax::ParenExpression::getCloseParen() {
   return cast_or_null(findChild(syntax::NodeRole::CloseParen));
 }
 
-syntax::Leaf *syntax::ThisExpression::thisKeyword() {
+syntax::Leaf *syntax::ThisExpression::getThisKeyword() {
   return cast_or_null(
   findChild(syntax::NodeRole::IntroducerKeyword));
 }
 
-syntax::Leaf *syntax::LiteralExpression::literalToken() {
+syntax::Leaf *syntax::LiteralExpression::getLiteralToken() {
   return cast_or_null(findChild(syntax::NodeRole::LiteralToken));
 }
 
-syntax::Expression *syntax::BinaryOperatorExpression::lhs() {
+syntax::Expression *syntax::BinaryOperatorExpress

[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-08-27 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:4297
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();

arichardson wrote:
> akhuang wrote:
> > arichardson wrote:
> > > arsenm wrote:
> > > > I would expect datalayout upgrades to work by parsing the old string, 
> > > > and checking the field values inside. I guess directly checking the 
> > > > string isn't a new problem here
> > > I agree that would be less error prone. I wonder if there are cases where 
> > > the old string may fail to parse so you have to do the textual upgrade 
> > > first. I'm happy to make this change.
> > > 
> > > @akhuang is there a reason you used string parsing in D67631? Any 
> > > objections to changing the code to parse the datalayout and add missing 
> > > attributes?
> > I don't think so; parsing the datalayout sounds better to me too. 
> I just looked into parsing the DataLayout instead. Unfortunately the 
> resulting code is more complicated since there are no setters in DataLayout 
> and no way to create a normalized representation.
> There's also no way to differentiate between no `-G ` passed and `-G0` so  
> something like `e-p:64:64-G0` will be converted to `e-p:64:64-G0-G1`
> 
I suspect it would be possible to use the existing `DataLayout(StringRef)` 
constructor on the string, then call `getDefaultGlobalsAddressSpace()` on it, 
explicitly ignoring modifying the datalayout for the special case of an 
explicit `-G0`.

For example,

```cpp
  DataLayout ParsedDL = DataLayout(DL);
  if (T.isAMDGPU() && !DL.contains("-G0") 
&&ParsedDL.getDefaultGlobalsAddressSpace() != 1) {
return DL.empty() ? std::string("G1") : (DL + "-G1").str();
  }
```

As I understand it, this would cover the fact that we cannot distinguish 
between an explicit default globals space of zero, and a datalayout without a 
default globals space (also `DL::getDefaultGlobalsAddressSpace() == 0`) by 
explicitly excluding the special case `-G0`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84345

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


[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-08-27 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:4297
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();

dylanmckay wrote:
> arichardson wrote:
> > akhuang wrote:
> > > arichardson wrote:
> > > > arsenm wrote:
> > > > > I would expect datalayout upgrades to work by parsing the old string, 
> > > > > and checking the field values inside. I guess directly checking the 
> > > > > string isn't a new problem here
> > > > I agree that would be less error prone. I wonder if there are cases 
> > > > where the old string may fail to parse so you have to do the textual 
> > > > upgrade first. I'm happy to make this change.
> > > > 
> > > > @akhuang is there a reason you used string parsing in D67631? Any 
> > > > objections to changing the code to parse the datalayout and add missing 
> > > > attributes?
> > > I don't think so; parsing the datalayout sounds better to me too. 
> > I just looked into parsing the DataLayout instead. Unfortunately the 
> > resulting code is more complicated since there are no setters in DataLayout 
> > and no way to create a normalized representation.
> > There's also no way to differentiate between no `-G ` passed and `-G0` so  
> > something like `e-p:64:64-G0` will be converted to `e-p:64:64-G0-G1`
> > 
> I suspect it would be possible to use the existing `DataLayout(StringRef)` 
> constructor on the string, then call `getDefaultGlobalsAddressSpace()` on it, 
> explicitly ignoring modifying the datalayout for the special case of an 
> explicit `-G0`.
> 
> For example,
> 
> ```cpp
>   DataLayout ParsedDL = DataLayout(DL);
>   if (T.isAMDGPU() && !DL.contains("-G0") 
> &&ParsedDL.getDefaultGlobalsAddressSpace() != 1) {
> return DL.empty() ? std::string("G1") : (DL + "-G1").str();
>   }
> ```
> 
> As I understand it, this would cover the fact that we cannot distinguish 
> between an explicit default globals space of zero, and a datalayout without a 
> default globals space (also `DL::getDefaultGlobalsAddressSpace() == 0`) by 
> explicitly excluding the special case `-G0`
To be completely correct it should not assume that the global address space is 
not at the very start of the data layout as my initial snippet did. I've 
removed the `-` prefix from the `contains` check

```
  DataLayout ParsedDL = DataLayout(DL);
  if (T.isAMDGPU() && !DL.contains("G0") 
&&ParsedDL.getDefaultGlobalsAddressSpace() != 1) {
return DL.empty() ? std::string("G1") : (DL + "-G1").str();
  }
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84345

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


[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-08-27 Thread Douglas Chen via Phabricator via cfe-commits
dougpuob updated this revision to Diff 288302.
dougpuob added a comment.

Fixed typos and add new Case Type, szHungarianNotation in doc.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

Files:
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/ReservedIdentifierCheck.h
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp
  clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.h
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.h
  clang-tools-extra/docs/clang-tidy/checks/readability-identifier-naming.rst
  
clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/readability-identifier-naming-hungarian-notation.cpp
@@ -0,0 +1,103 @@
+#include 
+#include 
+
+// RUN: %check_clang_tidy %s readability-identifier-naming %t -- \
+// RUN:   -config="{CheckOptions: [\
+// RUN:   {key: readability-identifier-naming.VariableCase, value: szHungarianNotation}, \
+// RUN:   ]}"
+
+const char *NamePtr = "Name";
+// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: invalid case style for variable 'NamePtr' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}const char *szNamePtr = "Name";
+
+const char NameArray[] = "Name";
+// CHECK-MESSAGES: :[[@LINE-1]]:12: warning: invalid case style for variable 'NameArray' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}const char szNameArray[] = "Name";
+
+void *BufferPtr1 = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for variable 'BufferPtr1' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}void *pBufferPtr1 = NULL;
+
+void **BufferPtr2 = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'BufferPtr2' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}void **ppBufferPtr2 = NULL;
+
+void **pBufferPtr3 = NULL;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'pBufferPtr3' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}void **ppBufferPtr3 = NULL;
+
+int8_t ValueI8 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'ValueI8' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int8_t i8ValueI8 = 0;
+
+int16_t ValueI16 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueI16' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int16_t i16ValueI16 = 0;
+
+int32_t ValueI32 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueI32' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int32_t i32ValueI32 = 0;
+
+int64_t ValueI64 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueI64' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int64_t i64ValueI64 = 0;
+
+uint8_t ValueU8 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:9: warning: invalid case style for variable 'ValueU8' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint8_t u8ValueU8 = 0;
+
+uint16_t ValueU16 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for variable 'ValueU16' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint16_t u16ValueU16 = 0;
+
+uint32_t ValueU32 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for variable 'ValueU32' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint32_t u32ValueU32 = 0;
+
+uint64_t ValueU64 = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:10: warning: invalid case style for variable 'ValueU64' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}uint64_t u64ValueU64 = 0;
+
+float ValueFloat = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: invalid case style for variable 'ValueFloat' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}float fValueFloat = 0;
+
+double ValueDouble = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style for variable 'ValueDouble' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}double dValueDouble = 0;
+
+char ValueChar = 'c';
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for variable 'ValueChar' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}char cValueChar = 'c';
+
+bool ValueBool = true;
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: invalid case style for variable 'ValueBool' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}bool bValueBool = true;
+
+int ValueInt = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: invalid case style for variable 'ValueInt' [readability-identifier-naming]
+// CHECK-FIXES: {{^}}int iValueInt = 0;
+
+size_t ValueSize = 0;
+// CHECK-MESSAGES: :[[@LINE-1]]:8: warning: invalid case style f

[PATCH] D86688: [RecoveryExpr] Add 11.0.0 release note.

2020-08-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/ReleaseNotes.rst:51
 
+Recovery ASTs
+^

nit: AST rather than ASTs (matching the flag, and also it's AST is singular in 
the text)



Comment at: clang/docs/ReleaseNotes.rst:81
+context. Tools may need to adjust assumptions about dependent code.
+
 Improvements to Clang's diagnostics

This feature is on by default for C++ code, and can be explicitly controlled 
with ``-Xclang -f[no-]recovery-ast``.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86688

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


[PATCH] D86688: [RecoveryExpr] Add 11.0.0 release note.

2020-08-27 Thread Thorsten via Phabricator via cfe-commits
tschuett added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:73
+
+ // clangd-11 produces a richer AST:
+ // VarDecl  col:5 x 'int' cinit

clangd-11 or clang-11?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86688

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


[PATCH] D84602: [MSP430] Expose msp430_builtin calling convention to C code

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 288305.
atrosinenko added a comment.

- Rebase onto current master branch
- Add a dummy `switch` case with `FIXME`, as suggested by @aaron.ballman
- Applied a couple of style fixes proposed by linter


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84602

Files:
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/Specifiers.h
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypePrinter.cpp
  clang/lib/Basic/Targets/MSP430.h
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/test/CodeGen/msp430-cc-builtin.c
  clang/test/Sema/attr-msp430.c
  clang/tools/libclang/CXType.cpp
  llvm/lib/Target/MSP430/MSP430ISelLowering.cpp

Index: llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
===
--- llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
+++ llvm/lib/Target/MSP430/MSP430ISelLowering.cpp
@@ -573,6 +573,7 @@
 report_fatal_error("Unsupported calling convention");
   case CallingConv::C:
   case CallingConv::Fast:
+  case CallingConv::MSP430_BUILTIN:
 return LowerCCCArguments(Chain, CallConv, isVarArg, Ins, dl, DAG, InVals);
   case CallingConv::MSP430_INTR:
 if (Ins.empty())
Index: clang/tools/libclang/CXType.cpp
===
--- clang/tools/libclang/CXType.cpp
+++ clang/tools/libclang/CXType.cpp
@@ -666,6 +666,7 @@
   TCALLINGCONV(Swift);
   TCALLINGCONV(PreserveMost);
   TCALLINGCONV(PreserveAll);
+case CC_MSP430Builtin: return CXCallingConv_Unexposed;
 case CC_SpirFunction: return CXCallingConv_Unexposed;
 case CC_OpenCLKernel: return CXCallingConv_Unexposed;
   break;
Index: clang/test/Sema/attr-msp430.c
===
--- clang/test/Sema/attr-msp430.c
+++ clang/test/Sema/attr-msp430.c
@@ -11,3 +11,7 @@
 
 __attribute__((interrupt(0))) void f6(void);
 __attribute__((interrupt(63))) void f7(void);
+
+__attribute__((msp430_builtin)) int t2;   // expected-warning {{'msp430_builtin' only applies to function types; type here is 'int'}}
+__attribute__((msp430_builtin(1))) void f8(long long a, long long b); // expected-error {{'msp430_builtin' attribute takes no arguments}}
+__attribute__((msp430_builtin)) void f9(long long a, long long b);
Index: clang/test/CodeGen/msp430-cc-builtin.c
===
--- /dev/null
+++ clang/test/CodeGen/msp430-cc-builtin.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple msp430 -emit-llvm < %s | FileCheck %s
+
+__attribute__((msp430_builtin)) int f(long long x, long long y);
+
+__attribute__((msp430_builtin)) int g(long long x, long long y) {
+  return (int)42;
+}
+// CHECK: define cc94 {{(dso_local )?}}i16 @g(i64 %x, i64 %y)
+
+int caller() {
+  return f(0, 0);
+// CHECK: call cc94 i16 @f
+}
+
+// CHECK: declare cc94 {{(dso_local )?}}i16 @f(i64, i64)
Index: clang/lib/Sema/SemaType.cpp
===
--- clang/lib/Sema/SemaType.cpp
+++ clang/lib/Sema/SemaType.cpp
@@ -124,7 +124,8 @@
   case ParsedAttr::AT_Pcs: \
   case ParsedAttr::AT_IntelOclBicc:\
   case ParsedAttr::AT_PreserveMost:\
-  case ParsedAttr::AT_PreserveAll
+  case ParsedAttr::AT_PreserveAll: \
+  case ParsedAttr::AT_MSP430Builtin
 
 // Function type attributes.
 #define FUNCTION_TYPE_ATTRS_CASELIST   \
@@ -7304,6 +7305,8 @@
 return createSimpleAttr(Ctx, Attr);
   case ParsedAttr::AT_PreserveAll:
 return createSimpleAttr(Ctx, Attr);
+  case ParsedAttr::AT_MSP430Builtin:
+return createSimpleAttr(Ctx, Attr);
   }
   llvm_unreachable("unexpected attribute kind!");
 }
Index: clang/lib/Sema/SemaDeclAttr.cpp
===
--- clang/lib/Sema/SemaDeclAttr.cpp
+++ clang/lib/Sema/SemaDeclAttr.cpp
@@ -4476,6 +4476,9 @@
   case ParsedAttr::AT_PreserveAll:
 D->addAttr(::new (S.Context) PreserveAllAttr(S.Context, AL));
 return;
+  case ParsedAttr::AT_MSP430Builtin:
+D->addAttr(::new (S.Context) MSP430BuiltinAttr(S.Context, AL));
+return;
   default:
 llvm_unreachable("unexpected attribute kind");
   }
@@ -4641,6 +4644,9 @@
   case ParsedAttr::AT_PreserveAll:
 CC = CC_PreserveAll;
 break;
+  case ParsedAttr::AT_MSP430Builtin:
+CC = CC_MSP430Builtin;
+break;
   default: llvm_unreachable("unexpected attribute kind");
   }
 
@@ -7296,6 +7302,7 @@
   case ParsedAttr::AT_PreserveMost:
   case ParsedAttr::AT_PreserveAll:
   case ParsedAttr::AT_AAr

[PATCH] D86559: [Sema, CodeGen] Allow [[likely]] and [[unlikely]] on labels

2020-08-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D86559#2239859 , @Mordante wrote:

> In D86559#2239013 , @aaron.ballman 
> wrote:
>
>> I'd like to understand your reasoning for ignore + diagnose as opposed to 
>> count attrs (+ optionally diagnose) or other strategies. I can see pros and 
>> cons to basically anything we do here.
>>
>> If we decide to ignore conflicting likelihoods, then I agree we should issue 
>> a diagnostic. However, I suspect that's going to come up frequently in 
>> practice because people are going to write macros that include these 
>> attributes. For instance, it's very sensible for a developer to put 
>> [[unlikely]] in front of an `assert` under the assumption this is telling 
>> the compiler "this assertion isn't likely to happen" when in fact it's 
>> saying "this branch containing the assertion is unlikely to be taken".
>
> This macro is example why I dislike the counting. If `MyAssert` has an 
> `[[unlikely]]` attribute, then changing the number of `MyAssert` statements 
> will influence the likelihood of the branches taken.

, but this is an example of why I don't like the behavior of applying this 
to arbitrary statements; this is spooky behavior that would be very hard to 
spot in code reviews unless you're an expert on C++.

>> This is one of the reasons why the GCC behavior of allowing these attributes 
>> on arbitrary statements feels like an awful trap for users to get into. If 
>> the attribute only applied to compound statements following a flow control 
>> construct, I think the average programmer will have a far better chance of 
>> not using this wrong. (I know that I said in the other thread we should 
>> match the GCC behavior, but I'm still uncomfortable with it because that 
>> behavior seems to be fraught with dangers for users, and this patch 
>> introduces new sharp edges, as @Quuxplusone pointed out.)
>
> I'm also not fond of GCC's implementation, but I think their implementation 
> conforms with the standard.

Conforming to the standard is not hard in this case. We can parse the 
attributes and ignore their semantics entirely (but not the constraints) and 
that also conforms to the standard. Our job is to figure out what the best 
behavior is for our implementation (which may or may not mean following the GCC 
behavior).

> In hindsight I think it indeed makes more sense to only allow it on compound 
> statements. That will require thinking about how to mark multiple cases as 
> `[[likely]]` when falling through:
>
>   switch(a) {
> case '0':
> case '1':
> case '2': [[likely]] { return 'a' - '0'; }  // All 3 cases likely?
>   
> case '3':  // neutral?
> case '4': [[likely]]()// likely?
> case '5': [[unlikely]] {return 'a' - '0'; }  // unlikely?
>   }
>
> Of course this can be solved by only allowing it on the case labels:
>
>   switch(a) {
>[[likely]] case '0':
>[[likely]] case '1':
>[[likely]] case '2':  { return 'a' - '0'; }// All 3 cases likely
>   
> case '3': // neutral
> [[likely]] case '4':// likely
> [[unlikely case '5':  {return 'a' - '0'; }  // unlikely
>   }

That is exactly the behavior I am coming to believe we should follow. You can 
either write it on a compound statement that is guarded by a flow control 
decision (`if`/`else`/`while`) or you can write it on a label, otherwise the 
attribute is parsed and ignored (with a diagnostic). This feels like the right 
mixture of useful with understandable semantics so far, but perhaps we'll find 
other examples that change our minds.

The fallthrough behavior question has one more case we may want to think about:

  switch (x) {
  case 0:
  case 1:
  [[likely]] case 2: break;
  [[unlikely]] default:
  }

Does this mark cases `0` and `1` as being likely or not? I could see users 
wanting to use shorthand rather than repeat themselves on all the cases. 
However, I'm also not certain whether there would be any performance impact if 
we marked only `case 2` as likely and left cases `0` and `1` with default 
likelihood. My gut feeling is that this should only mark `case 2`, but others 
may have different views.

> I fully agree the behaviour mandated by the standard is way too complex and 
> user unfriendly. It would have been nice if there were simpler rules, making 
> it easier to use and to teach. Still I think it would be best to use the 
> complex approach now, since that's what the standard specifies. During that 
> process we can see whether there are more pitfalls. Then we can discuss it 
> with other vendors and see whether we can change the wording of the standard. 
> Do you agree?

The only requirement from the standard is that we parse `[[likely]]` or 
`[[unlikely]]` on a statement or label, th

[PATCH] D86691: [analyzer] Fix wrong parameter name in printFormattedEntry

2020-08-27 Thread Gabor Marton via Phabricator via cfe-commits
martong accepted this revision.
martong added a comment.

In D86691#2241604 , @nullptr.cpp wrote:

> In D86691#2241401 , @Szelethus wrote:
>
>> Nice, thank you! Did you stumble across this, or found it with a tool?
>
> I just happened to see these code:-).
> Maybe we should write a checker to check this situation? I will start doing 
> this!

Good idea! And thanks for the fix! :)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86691

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


[PATCH] D86688: [RecoveryExpr] Add 11.0.0 release note.

2020-08-27 Thread Sam McCall via Phabricator via cfe-commits
sammccall added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:65
+
+  .. code-block:: c++
+

Oops, I missed this, I think this should be three code blocks: one for C++, one 
for the first AST and one for the second AST.
Tex like "clang-10 produces the minimal placeholder" goes between them rather 
than in the code blocks.

(I don't think pretending this is all C++ and wrapping it in comments helps 
readability)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86688

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


[PATCH] D84602: [MSP430] Expose msp430_builtin calling convention to C code

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko added a comment.

Pinging @echristo in case there is some trivial way to allocate a calling 
convention ID (but probably there is not, unless GCC allocated one already). As 
I understand, without this ID the debugger may show some misleading output for 
a limited number of LibCalls. On the other hand, it will not help either, 
unless the debugger knows this ID.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84602

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


[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2020-08-27 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko updated this revision to Diff 288306.
vsavchenko marked 21 inline comments as done.
vsavchenko added a comment.

Fix review remarks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

Files:
  
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h
  clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp
  clang/lib/StaticAnalyzer/Core/RangedConstraintManager.cpp
  clang/unittests/StaticAnalyzer/RangeSetTest.cpp

Index: clang/unittests/StaticAnalyzer/RangeSetTest.cpp
===
--- clang/unittests/StaticAnalyzer/RangeSetTest.cpp
+++ clang/unittests/StaticAnalyzer/RangeSetTest.cpp
@@ -11,120 +11,330 @@
 #include "clang/Basic/SourceManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h"
 #include "clang/Tooling/Tooling.h"
+#include "llvm/ADT/APSInt.h"
+#include "llvm/Support/raw_ostream.h"
+#include "gtest/gtest-typed-test.h"
 #include "gtest/gtest.h"
 
+using namespace clang;
+using namespace ento;
+
 namespace clang {
 namespace ento {
-namespace {
 
-// TestCase contains to lists of ranges.
-// Original one has to be negated.
-// Expected one has to be compared to negated original range.
-template  struct TestCase {
-  RangeSet original;
-  RangeSet expected;
-
-  TestCase(BasicValueFactory &BVF, RangeSet::Factory &F,
-   const std::initializer_list &originalList,
-   const std::initializer_list &expectedList)
-  : original(createRangeSetFromList(BVF, F, originalList)),
-expected(createRangeSetFromList(BVF, F, expectedList)) {}
-
-private:
-  RangeSet createRangeSetFromList(BasicValueFactory &BVF, RangeSet::Factory &F,
-  const std::initializer_list rangeList) {
-llvm::APSInt from(sizeof(T) * 8, std::is_unsigned::value);
-llvm::APSInt to = from;
-RangeSet rangeSet = F.getEmptySet();
-for (auto it = rangeList.begin(); it != rangeList.end(); it += 2) {
-  from = *it;
-  to = *(it + 1);
-  rangeSet = rangeSet.addRange(
-  F, RangeSet(F, BVF.getValue(from), BVF.getValue(to)));
-}
-return rangeSet;
-  }
+template  static std::string toString(const RangeOrSet &Obj) {
+  std::string ObjRepresentation;
+  llvm::raw_string_ostream SS(ObjRepresentation);
+  Obj.dump(SS);
+  return SS.str();
+}
+LLVM_ATTRIBUTE_UNUSED static std::string toString(const llvm::APSInt &Point) {
+  return Point.toString(10);
+}
+// We need it here for better fail diagnostics from gtest.
+LLVM_ATTRIBUTE_UNUSED static std::ostream &operator<<(std::ostream &OS,
+  const RangeSet &Set) {
+  return OS << toString(Set);
+}
 
-  void printNegate(const TestCase &TestCase) {
-TestCase.original.print(llvm::dbgs());
-llvm::dbgs() << " => ";
-TestCase.expected.print(llvm::dbgs());
-  }
-};
+} // namespace ento
+} // namespace clang
+
+namespace {
 
-class RangeSetTest : public testing::Test {
-protected:
+template  class RangeSetTest : public testing::Test {
+public:
   // Init block
   std::unique_ptr AST = tooling::buildASTFromCode("struct foo;");
-  ASTContext &context = AST->getASTContext();
-  llvm::BumpPtrAllocator alloc;
-  BasicValueFactory BVF{context, alloc};
-  RangeSet::Factory F;
+  ASTContext &Context = AST->getASTContext();
+  llvm::BumpPtrAllocator Arena;
+  BasicValueFactory BVF{Context, Arena};
+  RangeSet::Factory F{BVF};
   // End init block
 
-  template  void checkNegate() {
-using type = T;
-
-// Use next values of the range {MIN, A, B, MID, C, D, MAX}.
-
-// MID is a value in the middle of the range
-// which unary minus does not affect on,
-// e.g. int8/int32(0), uint8(128), uint32(2147483648).
-
-constexpr type MIN = std::numeric_limits::min();
-constexpr type MAX = std::numeric_limits::max();
-constexpr type MID = std::is_signed::value
- ? 0
- : ~(static_cast(-1) / static_cast(2));
-constexpr type A = MID - static_cast(42 + 42);
-constexpr type B = MID - static_cast(42);
-constexpr type C = -B;
-constexpr type D = -A;
-
-static_assert(MIN < A && A < B && B < MID && MID < C && C < D && D < MAX,
-  "Values shall be in an ascending order");
-
-// Left {[x, y], [x, y]} is what shall be negated.
-// Right {[x, y], [x, y]} is what shall be compared to a negation result.
-TestCase cases[] = {
-{BVF, F, {MIN, A}, {MIN, MIN, D, MAX}},
-{BVF, F, {MIN, C}, {MIN, MIN, B, MAX}},
-{BVF, F, {MIN, MID}, {MIN, MIN, MID, MAX}},
-{BVF, F, {MIN, MAX}, {MIN, MAX}},
-{BVF, F, {A, D}, {A, D}},
-{BVF, F, {A, B}, {C, D}},
-{BVF, F, {MIN, A, D, MAX}, {MIN, A, D, MAX}},
-{BVF, F, {MIN, B, MID, D}, {MIN, MIN, A, MID, C, MAX}},
-{BVF, F, {MIN, MID, C, D}, {MIN, MIN, A, B,

[PATCH] D86465: [analyzer][solver] Redesign constraint ranges data structure

2020-08-27 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko added a comment.

In D86465#2238614 , @martong wrote:

> These are really promising figures, nice work! (And the measurement stuff 
> itself is also a great addition, thanks for that!)

Thanks 😊

> Not that it would matter much, but I was just wondering why there is a 
> slightly bigger memory usage in some of the `docker/small` projects? The most 
> conspicuous is `oatpp`.

The measurements fluctuate quite significantly and as you can see the means for 
both `old` and `new` experiments for `oatpp` are pretty close.  So, I would say 
that the memory differences are not conclusive.
This being said, the performance measurements should also be taken with a grain 
of salt.  We can't really say that we get **5-10%** performance improvement for 
sure, but that analysis //tends// to be faster instead.




Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:53-55
+  // In order to keep non-overlapping ranges sorted, we can compare only From
+  // points.
+  inline bool operator<(const Range &RHS) const { return From() < RHS.From(); }

steakhal wrote:
> It's a good practice to define comparison operators as //friend// functions 
> inline.
> Even if we don't rely on implicit conversions.
It doesn't seem like there is a single opinion on this in the codebase.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:135
+/// @{
+RangeSet getSet(Range Origin);
+RangeSet getSet(const llvm::APSInt &From, const llvm::APSInt &To) {

steakhal wrote:
> NoQ wrote:
> > "But what about `setGet()`???" - some user, probably :)
> Why don't we call this `createSetOf`?
> And `createEmptySet`.
> I know that we don't create the empty set, but then what does a //factory// 
> if not create stuff?
The naming is this way to be consistent with `ImmutableSet::Factory`



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/RangedConstraintManager.h:272-273
+private:
+  RangeSet(ContainerType *RawContainer) : Impl(RawContainer) {}
+  RangeSet(UnderlyingType Ptr) : Impl(Ptr) {}
 

steakhal wrote:
> vsavchenko wrote:
> > steakhal wrote:
> > > Missing `explicit`.
> > More like missing `/* implicit */` because it is intentional
> It doesn't have a too long identifier.
> The users can always refer to it `auto R = RangeSet(...)`, so we still don't 
> repeat ourselves.
> Do you have any particular counterexample?
> Probably the tests will become slightly more bloated but eh. whatever.
These constructors are `private` and used in `Factory` methods.  IMO they make 
those methods less cluttered.



Comment at: clang/lib/StaticAnalyzer/Core/RangeConstraintManager.cpp:322-325
+  auto swap = [&First, &FirstEnd, &Second, &SecondEnd]() {
+std::swap(First, Second);
+std::swap(FirstEnd, SecondEnd);
+  };

steakhal wrote:
> vsavchenko wrote:
> > steakhal wrote:
> > > It could definitely bear a longer name.
> > I think that there is nothing wrong in spelling out `std::swap` twice.
> > And do we have a naming convention for lambdas, is it a variable or a 
> > function from a naming perspective?
> That's a good question :)
> I would say that its a variable, since you can mark it `const`, otherwise you 
> could overwrite it. xD But that's a different story I think.
> About the `swap` thingie, its a good practice to respect ADL for functions 
> which know to be used via ADL.
> Even if we don't depend on ADL in this particular case.
I'm sorry but I still don't get the importance of dropping `std::` here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86465

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


[PATCH] D86597: [Tooling][Format] Treat compound extensions (foo.bar.cc) as matching foo.h

2020-08-27 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG266825620c7f: [Tooling][Format] Treat compound extensions 
(foo.bar.cc) as matching foo.h (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86597

Files:
  clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
  clang/unittests/Tooling/HeaderIncludesTest.cpp


Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -40,7 +40,7 @@
 return *Result;
   }
 
-  const std::string FileName = "fix.cpp";
+  std::string FileName = "fix.cpp";
   IncludeStyle Style = format::getLLVMStyle().IncludeStyle;
 };
 
@@ -102,6 +102,15 @@
   Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
   .IncludeStyle;
   EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "fix.cu.cpp";
+  EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "fix_test.cu.cpp";
+  EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "bar.cpp";
+  EXPECT_NE(Expected, insert(Code, "")) << "Not main header";
 }
 
 TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -12,6 +12,7 @@
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace tooling {
@@ -174,12 +175,22 @@
 const char IncludeRegexPattern[] =
 R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
 
+// The filename of Path excluding extension.
+// Used to match implementation with headers, this differs from 
sys::path::stem:
+//  - in names with multiple dots (foo.cu.cc) it terminates at the *first*
+//  - an empty stem is never returned: /foo/.bar.x => .bar
+//  - we don't bother to handle . and .. specially
+StringRef matchingStem(llvm::StringRef Path) {
+  StringRef Name = llvm::sys::path::filename(Path);
+  return Name.substr(0, Name.find('.', 1));
+}
+
 } // anonymous namespace
 
 IncludeCategoryManager::IncludeCategoryManager(const IncludeStyle &Style,
StringRef FileName)
 : Style(Style), FileName(FileName) {
-  FileStem = llvm::sys::path::stem(FileName);
+  FileStem = matchingStem(FileName);
   for (const auto &Category : Style.IncludeCategories)
 CategoryRegexs.emplace_back(Category.Regex, llvm::Regex::IgnoreCase);
   IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||
@@ -222,8 +233,7 @@
 bool IncludeCategoryManager::isMainHeader(StringRef IncludeName) const {
   if (!IncludeName.startswith("\""))
 return false;
-  StringRef HeaderStem =
-  llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
+  StringRef HeaderStem = matchingStem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem) ||
   FileStem.startswith_lower(HeaderStem)) {
 llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,


Index: clang/unittests/Tooling/HeaderIncludesTest.cpp
===
--- clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -40,7 +40,7 @@
 return *Result;
   }
 
-  const std::string FileName = "fix.cpp";
+  std::string FileName = "fix.cpp";
   IncludeStyle Style = format::getLLVMStyle().IncludeStyle;
 };
 
@@ -102,6 +102,15 @@
   Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
   .IncludeStyle;
   EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "fix.cu.cpp";
+  EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "fix_test.cu.cpp";
+  EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "bar.cpp";
+  EXPECT_NE(Expected, insert(Code, "")) << "Not main header";
 }
 
 TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {
Index: clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
===
--- clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -12,6 +12,7 @@
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace tooling {
@@ -174,12 +175,22 @@
 const char IncludeRegexPattern[] =
 R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
 
+// The filename of Path excluding extension.
+// Used to match implementation with headers, this differs from sys::path::stem:
+//  - in names with multiple dots (foo.cu.cc) it terminates at the *f

[clang] 2668256 - [Tooling][Format] Treat compound extensions (foo.bar.cc) as matching foo.h

2020-08-27 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2020-08-27T15:24:17+02:00
New Revision: 266825620c7f8d10d48abd0346527cea50c8202d

URL: 
https://github.com/llvm/llvm-project/commit/266825620c7f8d10d48abd0346527cea50c8202d
DIFF: 
https://github.com/llvm/llvm-project/commit/266825620c7f8d10d48abd0346527cea50c8202d.diff

LOG: [Tooling][Format] Treat compound extensions (foo.bar.cc) as matching foo.h

Motivating use case is ".cu.cc" extensions used in some bazel projects.

Alternative is to work around this with IncludeIsMainRegex in styles.
I proposed this approach because it seems like a better default.

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

Added: 


Modified: 
clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
clang/unittests/Tooling/HeaderIncludesTest.cpp

Removed: 




diff  --git a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp 
b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
index b65d7f0c1a39..e0368975ea3e 100644
--- a/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
+++ b/clang/lib/Tooling/Inclusions/HeaderIncludes.cpp
@@ -12,6 +12,7 @@
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/Path.h"
 
 namespace clang {
 namespace tooling {
@@ -174,12 +175,22 @@ inline StringRef trimInclude(StringRef IncludeName) {
 const char IncludeRegexPattern[] =
 R"(^[\t\ ]*#[\t\ ]*(import|include)[^"<]*(["<][^">]*[">]))";
 
+// The filename of Path excluding extension.
+// Used to match implementation with headers, this 
diff ers from sys::path::stem:
+//  - in names with multiple dots (foo.cu.cc) it terminates at the *first*
+//  - an empty stem is never returned: /foo/.bar.x => .bar
+//  - we don't bother to handle . and .. specially
+StringRef matchingStem(llvm::StringRef Path) {
+  StringRef Name = llvm::sys::path::filename(Path);
+  return Name.substr(0, Name.find('.', 1));
+}
+
 } // anonymous namespace
 
 IncludeCategoryManager::IncludeCategoryManager(const IncludeStyle &Style,
StringRef FileName)
 : Style(Style), FileName(FileName) {
-  FileStem = llvm::sys::path::stem(FileName);
+  FileStem = matchingStem(FileName);
   for (const auto &Category : Style.IncludeCategories)
 CategoryRegexs.emplace_back(Category.Regex, llvm::Regex::IgnoreCase);
   IsMainFile = FileName.endswith(".c") || FileName.endswith(".cc") ||
@@ -222,8 +233,7 @@ int 
IncludeCategoryManager::getSortIncludePriority(StringRef IncludeName,
 bool IncludeCategoryManager::isMainHeader(StringRef IncludeName) const {
   if (!IncludeName.startswith("\""))
 return false;
-  StringRef HeaderStem =
-  llvm::sys::path::stem(IncludeName.drop_front(1).drop_back(1));
+  StringRef HeaderStem = matchingStem(IncludeName.drop_front(1).drop_back(1));
   if (FileStem.startswith(HeaderStem) ||
   FileStem.startswith_lower(HeaderStem)) {
 llvm::Regex MainIncludeRegex(HeaderStem.str() + Style.IncludeIsMainRegex,

diff  --git a/clang/unittests/Tooling/HeaderIncludesTest.cpp 
b/clang/unittests/Tooling/HeaderIncludesTest.cpp
index d38104fe40ec..37007fbfb65e 100644
--- a/clang/unittests/Tooling/HeaderIncludesTest.cpp
+++ b/clang/unittests/Tooling/HeaderIncludesTest.cpp
@@ -40,7 +40,7 @@ class HeaderIncludesTest : public ::testing::Test {
 return *Result;
   }
 
-  const std::string FileName = "fix.cpp";
+  std::string FileName = "fix.cpp";
   IncludeStyle Style = format::getLLVMStyle().IncludeStyle;
 };
 
@@ -102,6 +102,15 @@ TEST_F(HeaderIncludesTest, InsertAfterMainHeader) {
   Style = format::getGoogleStyle(format::FormatStyle::LanguageKind::LK_Cpp)
   .IncludeStyle;
   EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "fix.cu.cpp";
+  EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "fix_test.cu.cpp";
+  EXPECT_EQ(Expected, insert(Code, ""));
+
+  FileName = "bar.cpp";
+  EXPECT_NE(Expected, insert(Code, "")) << "Not main header";
 }
 
 TEST_F(HeaderIncludesTest, InsertBeforeSystemHeaderLLVM) {



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


[PATCH] D86707: [SystemZ][z/OS] Adding initial toolchain for z/OS

2020-08-27 Thread Abhina Sree via Phabricator via cfe-commits
abhina.sreeskantharajan created this revision.
abhina.sreeskantharajan added reviewers: Kai, uweigand, hubert.reinterpretcast, 
stevewan, SeanP, lalovic.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
abhina.sreeskantharajan requested review of this revision.

This patch adds the initial toolchain for z/OS that will set some defaults. In 
subsequent patches, we plan to add support to use the system linker and 
assembler.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86707

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/ZOS.cpp
  clang/lib/Driver/ToolChains/ZOS.h

Index: clang/lib/Driver/ToolChains/ZOS.h
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.h
@@ -0,0 +1,36 @@
+//===--- ZOS.h - z/OS ToolChain Implementations -*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+#define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
+
+#include "clang/Driver/Tool.h"
+#include "clang/Driver/ToolChain.h"
+
+namespace clang {
+namespace driver {
+namespace toolchains {
+
+class LLVM_LIBRARY_VISIBILITY ZOS : public ToolChain {
+public:
+  ZOS(const Driver &D, const llvm::Triple &Triple,
+  const llvm::opt::ArgList &Args);
+  ~ZOS() override;
+
+  bool isPICDefault() const override { return false; }
+  bool isPIEDefault() const override { return false; }
+  bool isPICDefaultForced() const override { return false; }
+
+  bool IsIntegratedAssemblerDefault() const override { return true; }
+};
+
+} // end namespace toolchains
+} // end namespace driver
+} // end namespace clang
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_ZOS_H
Index: clang/lib/Driver/ToolChains/ZOS.cpp
===
--- /dev/null
+++ clang/lib/Driver/ToolChains/ZOS.cpp
@@ -0,0 +1,23 @@
+//===--- ZOS.cpp - z/OS ToolChain Implementations ---*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "ZOS.h"
+#include "CommonArgs.h"
+#include "clang/Driver/Compilation.h"
+#include "clang/Driver/Options.h"
+#include "llvm/Option/ArgList.h"
+
+using namespace clang::driver;
+using namespace clang::driver::toolchains;
+using namespace llvm::opt;
+using namespace clang;
+
+ZOS::ZOS(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
+: ToolChain(D, Triple, Args) {}
+
+ZOS::~ZOS() {}
Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -46,6 +46,7 @@
 #include "ToolChains/VEToolchain.h"
 #include "ToolChains/WebAssembly.h"
 #include "ToolChains/XCore.h"
+#include "ToolChains/ZOS.h"
 #include "clang/Basic/TargetID.h"
 #include "clang/Basic/Version.h"
 #include "clang/Config/config.h"
@@ -5072,6 +5073,9 @@
 case llvm::Triple::Hurd:
   TC = std::make_unique(*this, Target, Args);
   break;
+case llvm::Triple::ZOS:
+  TC = std::make_unique(*this, Target, Args);
+  break;
 default:
   // Of these targets, Hexagon is the only one that might have
   // an OS of Linux, in which case it got handled above already.
Index: clang/lib/Driver/CMakeLists.txt
===
--- clang/lib/Driver/CMakeLists.txt
+++ clang/lib/Driver/CMakeLists.txt
@@ -73,6 +73,7 @@
   ToolChains/XCore.cpp
   ToolChains/PPCLinux.cpp
   ToolChains/InterfaceStubs.cpp
+  ToolChains/ZOS.cpp
   Types.cpp
   XRayArgs.cpp
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86708: [clang-format] Parse volatile as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, 
curdeius.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.

Before: void f() { MACRO(A * volatile a); }
After:  void f() { MACRO(A *volatile a); }

Also check that the __volatile and __volatile__ aliases are handled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86708

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8053,6 +8053,9 @@
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
   verifyIndependentOfContext("MACRO(A *const a);");
+  verifyIndependentOfContext("MACRO(A *volatile a);");
+  verifyIndependentOfContext("MACRO(A *__volatile a);");
+  verifyIndependentOfContext("MACRO(A *__volatile__ a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
   verifyFormat("void f() { f(float{1}, a * a); }");
   // FIXME: Is there a way to make this work?
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1891,7 +1891,7 @@
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
-   tok::kw_noexcept) ||
+   tok::kw_volatile, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8053,6 +8053,9 @@
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
   verifyIndependentOfContext("MACRO(A *const a);");
+  verifyIndependentOfContext("MACRO(A *volatile a);");
+  verifyIndependentOfContext("MACRO(A *__volatile a);");
+  verifyIndependentOfContext("MACRO(A *__volatile__ a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
   verifyFormat("void f() { f(float{1}, a * a); }");
   // FIXME: Is there a way to make this work?
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1891,7 +1891,7 @@
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
-   tok::kw_noexcept) ||
+   tok::kw_volatile, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86710: [clang-format] Parse restrict as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, 
curdeius.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.

Before: void f() { MACRO(A * restrict a); }
After:  void f() { MACRO(A *restrict a); }

Also check that the __restrict and __restrict__ aliases are handled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86710

Files:
  clang/lib/Format/Format.cpp
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8053,6 +8053,9 @@
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
   verifyIndependentOfContext("MACRO(A *const a);");
+  verifyIndependentOfContext("MACRO(A *restrict a);");
+  verifyIndependentOfContext("MACRO(A *__restrict__ a);");
+  verifyIndependentOfContext("MACRO(A *__restrict a);");
   verifyIndependentOfContext("MACRO(A *volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile__ a);");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1891,7 +1891,8 @@
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
-   tok::kw_volatile, tok::kw_noexcept) ||
+   tok::kw_restrict, tok::kw_volatile,
+   tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2739,6 +2739,7 @@
   LangOpts.ObjC = 1;
   LangOpts.MicrosoftExt = 1;// To get kw___try, kw___finally.
   LangOpts.DeclSpecKeyword = 1; // To get __declspec.
+  LangOpts.C99 = 1; // To get kw_restrict for non-underscore-prefixed restrict.
   return LangOpts;
 }
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8053,6 +8053,9 @@
   verifyIndependentOfContext("MACRO(auto *a);");
   verifyIndependentOfContext("MACRO(const A *a);");
   verifyIndependentOfContext("MACRO(A *const a);");
+  verifyIndependentOfContext("MACRO(A *restrict a);");
+  verifyIndependentOfContext("MACRO(A *__restrict__ a);");
+  verifyIndependentOfContext("MACRO(A *__restrict a);");
   verifyIndependentOfContext("MACRO(A *volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile__ a);");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1891,7 +1891,8 @@
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
-   tok::kw_volatile, tok::kw_noexcept) ||
+   tok::kw_restrict, tok::kw_volatile,
+   tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2739,6 +2739,7 @@
   LangOpts.ObjC = 1;
   LangOpts.MicrosoftExt = 1;// To get kw___try, kw___finally.
   LangOpts.DeclSpecKeyword = 1; // To get __declspec.
+  LangOpts.C99 = 1; // To get kw_restrict for non-underscore-prefixed restrict.
   return LangOpts;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86671: [clang-tidy] Add new case type to check variables with Hungarian notation

2020-08-27 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added a comment.

Please fix Clang-tidy warnings and mention changes in Release Notes.




Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:317
+  if (Style.Case == IdentifierNamingCheck::CaseType::CT_HungarianNotation) {
+const auto TypePrefix = getHungarianNotationTypePrefix(Type.str(), Decl);
+if (TypePrefix.length() > 0) {

Please don't use auto when type is not specified explicitly in same statement 
or iterator.



Comment at: 
clang-tools-extra/clang-tidy/readability/IdentifierNamingCheck.cpp:430
+const NamedDecl *pNamedDecl = dyn_cast(pDecl);
+const auto TypePrefix =
+getHungarianNotationTypePrefix(Type.str(), pNamedDecl);

Please don't use auto when type is not specified explicitly in same statement 
or iterator.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86671

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


[PATCH] D86691: [analyzer] Fix wrong parameter name in printFormattedEntry

2020-08-27 Thread Yang Fan via Phabricator via cfe-commits
nullptr.cpp added a comment.

@Szelethus @martong
Sorry to interrupt, I don't have commit access, can you help commit this and 
D86334 ?
Yang Fan 
Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86691

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


[PATCH] D86711: [clang-format] Parse __attribute((foo)) as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, 
curdeius.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.

Before: void f() { MACRO(A * __attribute((foo)) a); }
After:  void f() { MACRO(A *__attribute((foo)) a); }

Also check that the __attribute__ alias is handled.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86711

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8059,6 +8059,8 @@
   verifyIndependentOfContext("MACRO(A *volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile__ a);");
+  verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);");
+  verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
   verifyFormat("void f() { f(float{1}, a * a); }");
   // FIXME: Is there a way to make this work?
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1892,7 +1892,7 @@
 if (!NextToken ||
 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
tok::kw_restrict, tok::kw_volatile,
-   tok::kw_noexcept) ||
+   tok::kw___attribute, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8059,6 +8059,8 @@
   verifyIndependentOfContext("MACRO(A *volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile__ a);");
+  verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);");
+  verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
   verifyFormat("void f() { f(float{1}, a * a); }");
   // FIXME: Is there a way to make this work?
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1892,7 +1892,7 @@
 if (!NextToken ||
 NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
tok::kw_restrict, tok::kw_volatile,
-   tok::kw_noexcept) ||
+   tok::kw___attribute, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: llvm/lib/IR/AutoUpgrade.cpp:4297
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();

dylanmckay wrote:
> dylanmckay wrote:
> > arichardson wrote:
> > > akhuang wrote:
> > > > arichardson wrote:
> > > > > arsenm wrote:
> > > > > > I would expect datalayout upgrades to work by parsing the old 
> > > > > > string, and checking the field values inside. I guess directly 
> > > > > > checking the string isn't a new problem here
> > > > > I agree that would be less error prone. I wonder if there are cases 
> > > > > where the old string may fail to parse so you have to do the textual 
> > > > > upgrade first. I'm happy to make this change.
> > > > > 
> > > > > @akhuang is there a reason you used string parsing in D67631? Any 
> > > > > objections to changing the code to parse the datalayout and add 
> > > > > missing attributes?
> > > > I don't think so; parsing the datalayout sounds better to me too. 
> > > I just looked into parsing the DataLayout instead. Unfortunately the 
> > > resulting code is more complicated since there are no setters in 
> > > DataLayout and no way to create a normalized representation.
> > > There's also no way to differentiate between no `-G ` passed and `-G0` so 
> > >  something like `e-p:64:64-G0` will be converted to `e-p:64:64-G0-G1`
> > > 
> > I suspect it would be possible to use the existing `DataLayout(StringRef)` 
> > constructor on the string, then call `getDefaultGlobalsAddressSpace()` on 
> > it, explicitly ignoring modifying the datalayout for the special case of an 
> > explicit `-G0`.
> > 
> > For example,
> > 
> > ```cpp
> >   DataLayout ParsedDL = DataLayout(DL);
> >   if (T.isAMDGPU() && !DL.contains("-G0") 
> > &&ParsedDL.getDefaultGlobalsAddressSpace() != 1) {
> > return DL.empty() ? std::string("G1") : (DL + "-G1").str();
> >   }
> > ```
> > 
> > As I understand it, this would cover the fact that we cannot distinguish 
> > between an explicit default globals space of zero, and a datalayout without 
> > a default globals space (also `DL::getDefaultGlobalsAddressSpace() == 0`) 
> > by explicitly excluding the special case `-G0`
> To be completely correct it should not assume that the global address space 
> is not at the very start of the data layout as my initial snippet did. I've 
> removed the `-` prefix from the `contains` check
> 
> ```
>   DataLayout ParsedDL = DataLayout(DL);
>   if (T.isAMDGPU() && !DL.contains("G0") 
> &&ParsedDL.getDefaultGlobalsAddressSpace() != 1) {
> return DL.empty() ? std::string("G1") : (DL + "-G1").str();
>   }
> ```
We then end up overwriting explicitly specified `G` flags. Maybe some tests 
would like to check that overriding the globals address space works? Also I 
believe this can result in an invalid datalayout: `"...-G2"` will be converted 
to `"...-G2-G1"`.

Not sure what the correct approach is @arsenm ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84345

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


[PATCH] D84345: [AMDGPU] Set the default globals address space to 1

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson updated this revision to Diff 288316.
arichardson added a comment.

- fix failing tests after datalayout change


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84345

Files:
  clang/lib/Basic/Targets/AMDGPU.cpp
  clang/lib/CodeGen/CGClass.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGVTT.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGen/target-data.c
  clang/test/CodeGenOpenCL/amdgpu-env-amdgcn.cl
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
  llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp

Index: llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
===
--- llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
+++ llvm/unittests/Bitcode/DataLayoutUpgradeTest.cpp
@@ -27,6 +27,10 @@
  "-f80:32-n8:16:32-S32");
   EXPECT_EQ(DL3, "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128"
  "-n32:64-S128");
+
+  // Check that AMDGPU targets add -G1 if it's not present.
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32", "r600"), "e-p:32:32-G1");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64", "amdgcn"), "e-p:64:64-G1");
 }
 
 TEST(DataLayoutUpgradeTest, NoDataLayoutUpgrade) {
@@ -46,6 +50,13 @@
   EXPECT_EQ(DL2, "e-p:32:32");
   EXPECT_EQ(DL3, "e-m:e-i64:64-n32:64");
   EXPECT_EQ(DL4, "e-m:o-i64:64-i128:128-n32:64-S128");
+
+  // Check that AMDGPU targets don't add -G1 if there is already a -G flag.
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:32:32-G2", "r600"), "e-p:32:32-G2");
+  EXPECT_EQ(UpgradeDataLayoutString("G2", "r600"), "G2");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64-G2", "amdgcn"), "e-p:64:64-G2");
+  EXPECT_EQ(UpgradeDataLayoutString("G2-e-p:64:64", "amdgcn"), "G2-e-p:64:64");
+  EXPECT_EQ(UpgradeDataLayoutString("e-p:64:64-G0", "amdgcn"), "e-p:64:64-G0");
 }
 
 TEST(DataLayoutUpgradeTest, EmptyDataLayout) {
@@ -54,6 +65,10 @@
   "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128", "");
   EXPECT_EQ(DL1, "");
   EXPECT_EQ(DL2, "e-m:e-p:32:32-i64:64-f80:128-n8:16:32:64-S128");
+
+  // Check that AMDGPU targets add G1 if it's not present.
+  EXPECT_EQ(UpgradeDataLayoutString("", "r600"), "G1");
+  EXPECT_EQ(UpgradeDataLayoutString("", "amdgcn"), "G1");
 }
 
 } // end namespace
Index: llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
===
--- llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -344,15 +344,15 @@
 static StringRef computeDataLayout(const Triple &TT) {
   if (TT.getArch() == Triple::r600) {
 // 32-bit pointers.
-  return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
- "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5";
+return "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
+   "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1";
   }
 
   // 32-bit private, local, and region pointers. 64-bit global, constant and
   // flat, non-integral buffer fat pointers.
-return "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
+  return "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32"
  "-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128"
- "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
+ "-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5-G1"
  "-ni:7";
 }
 
Index: llvm/lib/IR/AutoUpgrade.cpp
===
--- llvm/lib/IR/AutoUpgrade.cpp
+++ llvm/lib/IR/AutoUpgrade.cpp
@@ -4308,11 +4308,17 @@
 }
 
 std::string llvm::UpgradeDataLayoutString(StringRef DL, StringRef TT) {
-  StringRef AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
+  Triple T(TT);
+  // For AMDGPU we uprgrade older DataLayouts to include the default globals
+  // address space of 1.
+  if (T.isAMDGPU() && !DL.contains("-G") && !DL.startswith("G")) {
+return DL.empty() ? std::string("G1") : (DL + "-G1").str();
+  }
 
+  std::string AddrSpaces = "-p270:32:32-p271:32:32-p272:64:64";
   // If X86, and the datalayout matches the expected format, add pointer size
   // address spaces to the datalayout.
-  if (!Triple(TT).isX86() || DL.contains(AddrSpaces))
+  if (!T.isX86() || DL.contains(AddrSpaces))
 return std::string(DL);
 
   SmallVector Groups;
Index: llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -214,7 +214,7 @@
 GV->setAlignment(Align(8));
 Ident = GV;
   }
-  return Ident;
+  return Builder.CreatePointerCast(Ident, IdentPtr);
 }
 
 Constant *OpenMPIRBuilder::getOrCreateSrcLocStr(StringRef LocStr) {
Index: clang/test/CodeGenOpenCL/amd

[PATCH] D86711: [clang-format] Parse __attribute((foo)) as a pointer qualifier

2020-08-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1895
tok::kw_restrict, tok::kw_volatile,
-   tok::kw_noexcept) ||
+   tok::kw___attribute, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))

What about other attributes than GNU-style ones, like 
`[[clang::address_space(0)]]`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86711

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


[PATCH] D86154: AMDGPU: Add llvm.amdgcn.{read,readfirst,write}lane2 intrinsics with type overloads

2020-08-27 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm added a comment.

In D86154#2229292 , @nhaehnle wrote:

> In D86154#2224272 , @arsenm wrote:
>
>> In D86154#2224270 , @nhaehnle wrote:
>>
>>> Note that part of my motivation here over D84639 
>>>  is to support more general types on the 
>>> lane intrinsics, since they also express some semantic content which would 
>>> be interesting to be able to express e.g. on descriptors. I wasn't able to 
>>> bend the SelectionDAG type legalization to my will, so that's why I instead 
>>> "legalize" the intrinsics in the AMDGPUCodeGenPrepare pass.
>>
>> Don't you just need to handle this in ReplaceNodeResults the same way?
>
> ReplaceNodeResults expects the result type to be changed in semi-magical ways 
> during vector type legalization, which is non-obvious since the method can be 
> called from different places. I think it *could* be made to work with a lot 
> of patience, but it's really a bad interface -- and besides, by doing it in 
> IR we reduce code duplication between SelectionDAG and GlobalISel, which is 
> an added benefit IMO.

Well the globalisel handling should be much simpler. We have a lot of stuff 
that's randomly handled in the IR to work around the DAG which long term should 
be moved where it belongs in codegen


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86154

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


[PATCH] D86708: [clang-format] Parse volatile as a pointer qualifier

2020-08-27 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD accepted this revision.
JakeMerdichAMD added a comment.
This revision is now accepted and ready to land.

LGTM. Wait a bit to give others a chance to chime in before submitting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86708

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


[PATCH] D86711: [clang-format] Parse __attribute((foo)) as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1895
tok::kw_restrict, tok::kw_volatile,
-   tok::kw_noexcept) ||
+   tok::kw___attribute, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))

aaron.ballman wrote:
> What about other attributes than GNU-style ones, like 
> `[[clang::address_space(0)]]`?
I guess those should also be handled. I can try to do that in a follow-up 
change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86711

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


[PATCH] D86713: [clang-format] Parse nullability attributes as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, 
curdeius.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.

Before:
void f() { MACRO(A * _Nonnull a); }
void f() { MACRO(A * _Nullable a); }
void f() { MACRO(A * _Null_unspecified a); }

After:
void f() { MACRO(A *_Nonnull a); }
void f() { MACRO(A *_Nullable a); }
void f() { MACRO(A *_Null_unspecified a); }


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86713

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8025,6 +8025,10 @@
   verifyFormat("vector v;");
   verifyFormat("vector v;");
   verifyFormat("vector v;");
+  verifyFormat("vector v;");
+  verifyFormat("vector v;");
+  verifyFormat("vector v;");
+  verifyFormat("vector v;");
   verifyFormat("vector v;");
   verifyFormat("foo();");
   verifyFormat("foo();");
@@ -8059,6 +8063,9 @@
   verifyIndependentOfContext("MACRO(A *volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile__ a);");
+  verifyIndependentOfContext("MACRO(A *_Nonnull a);");
+  verifyIndependentOfContext("MACRO(A *_Nullable a);");
+  verifyIndependentOfContext("MACRO(A *_Null_unspecified a);");
   verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);");
   verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1890,9 +1890,10 @@
 
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
-NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
-   tok::kw_restrict, tok::kw_volatile,
-   tok::kw___attribute, tok::kw_noexcept) ||
+NextToken->isOneOf(
+tok::arrow, tok::equal, tok::kw_const, tok::kw_restrict,
+tok::kw_volatile, tok::kw___attribute, tok::kw__Nonnull,
+tok::kw__Nullable, tok::kw__Null_unspecified, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8025,6 +8025,10 @@
   verifyFormat("vector v;");
   verifyFormat("vector v;");
   verifyFormat("vector v;");
+  verifyFormat("vector v;");
+  verifyFormat("vector v;");
+  verifyFormat("vector v;");
+  verifyFormat("vector v;");
   verifyFormat("vector v;");
   verifyFormat("foo();");
   verifyFormat("foo();");
@@ -8059,6 +8063,9 @@
   verifyIndependentOfContext("MACRO(A *volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile a);");
   verifyIndependentOfContext("MACRO(A *__volatile__ a);");
+  verifyIndependentOfContext("MACRO(A *_Nonnull a);");
+  verifyIndependentOfContext("MACRO(A *_Nullable a);");
+  verifyIndependentOfContext("MACRO(A *_Null_unspecified a);");
   verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);");
   verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1890,9 +1890,10 @@
 
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
-NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_const,
-   tok::kw_restrict, tok::kw_volatile,
-   tok::kw___attribute, tok::kw_noexcept) ||
+NextToken->isOneOf(
+tok::arrow, tok::equal, tok::kw_const, tok::kw_restrict,
+tok::kw_volatile, tok::kw___attribute, tok::kw__Nonnull,
+tok::kw__Nullable, tok::kw__Null_unspecified, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))
   return TT_PointerOrReference;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-08-27 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad added a comment.

That's awesome! Is it meant to eventually be committed or only be used for 
comparison purposes?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[PATCH] D86694: [scudo] Allow -fsanitize=scudo on Linux and Windows (WIP, don't land as is)

2020-08-27 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D86694#2242140 , @cryptoad wrote:

> That's awesome! Is it meant to eventually be committed or only be used for 
> comparison purposes?

I'd like it to be committed, but can't claim I know the code from 
https://reviews.llvm.org/D42519 well enough. The good news is that I can build 
LLVM on Windows with this. Is there a good sanity check that it is actually 
using Scudo rather than silently using the standard alloc?

You marked D42519  as WIP, can you remember 
what was still TBD?

Also, it might make sense to separate out the "use" of sanitize=Scudo in LLVM, 
from providing Windows support. I put them together here for evaluation 
purposes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86694

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


[PATCH] D86581: [clang-format] Handle shifts within conditions

2020-08-27 Thread Miguel Saldivar via Phabricator via cfe-commits
Saldivarcher added a comment.

@MyDeveloperDay thanks for the kind words, it's much appreciated! I'm just glad 
I was able to help. Nope, I don't have commit access, can you do me the favor 
of commiting for me?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86581

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


[PATCH] D84603: Thread safety analysis: More consistent warning message

2020-08-27 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/lib/Analysis/ThreadSafety.cpp:1644
 if (!LDat) {
-  Analyzer->Handler.handleMutexNotHeld("", D, POK, Cp.toString(),
-   LK_Shared, Loc);
+  Analyzer->Handler.handleMutexNotHeld("negative capability", D, POK,
+   Cp.toString(), LK_Shared, Loc);

aaronpuchert wrote:
> aaron.ballman wrote:
> > aaronpuchert wrote:
> > > aaron.ballman wrote:
> > > > It's a bit odd that we aren't using `DiagKind` as below, I assume 
> > > > that's because this is a negative test and the others are positive 
> > > > tests, but doesn't this introduce a terminology difference where a 
> > > > positive failure may call it a mutex and a negative failure may call it 
> > > > a negative capability? Should this be hooked in to 
> > > > `ClassifyDiagnostic()` (perhaps we need a 
> > > > `ClassifyNegativeDiagnostic()`?
> > > My thinking was that whatever the positive capability is called, we 
> > > should only talk about a "negative capability" instead of a "negative 
> > > mutex" or a "negative role". Also because not holding a capability is in 
> > > some way its own kind of capability.
> > I may still be confused or thinking of this differently, but I would assume 
> > that a negative mutex would be a mutex that's explicitly not held, which 
> > you may want to ensure on a function boundary to avoid deadlock. From that, 
> > I'd have guessed we would want the diagnostic to read `cannot call function 
> > 'bar' while mutex 'mu' is held` or `calling function 'bar' requires mutex 
> > 'mu' to not be held` because that's more clear than talking about negative 
> > capabilities (when the user is thinking in terms of mutexes which are or 
> > aren't held).
> Now I get it. I don't see an issue with that, but we need to distinguish 
> between `EXCLUDES(mu)` and `REQUIRES(!mu)`. The former will produce "cannot 
> call function 'bar' while mutex 'mu' is held" and we probably want the latter 
> to produce a different warning message.
> 
> Now one argument for the existing scheme remains that with 
> `-Wthread-safety-negative`, if you see a warning like "acquiring mutex 'mu' 
> requires negative capability '!mu'" on a lock operation, you know you can fix 
> that by adding `REQUIRES(!mu)` to your function.
> 
> If we say "warning: acquiring mutex 'mu' requires mutex 'mu' not to be held" 
> it might not be as clear what we want.
> Now I get it. I don't see an issue with that, but we need to distinguish 
> between EXCLUDES(mu) and REQUIRES(!mu). The former will produce "cannot call 
> function 'bar' while mutex 'mu' is held" and we probably want the latter to 
> produce a different warning message.

Ahhh, that's a good point.

> Now one argument for the existing scheme remains that with 
> -Wthread-safety-negative, if you see a warning like "acquiring mutex 'mu' 
> requires negative capability '!mu'" on a lock operation, you know you can fix 
> that by adding REQUIRES(!mu) to your function.
>
> If we say "warning: acquiring mutex 'mu' requires mutex 'mu' not to be held" 
> it might not be as clear what we want.

Hm, that's a good point as well.

Now that I understand the situation a bit better, I will be happy with either 
route, so I leave the decision in your capable hands. (If we get it wrong, we 
can always change the diagnostics later.) Do you have a preferred approach?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D84603

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


[PATCH] D86660: Modifying ImportDeclContext(...) to ensure that we also handle the case when the FieldDecl is an ArrayType whose ElementType is a RecordDecl

2020-08-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:1737
 
 // If we are in the process of ImportDefinition(...) for a RecordDecl we
 // want to make sure that we are also completing each FieldDecl. There

`ImportDefinition(...)` here refers to `ASTImporter::ImportDefinition(Decl*)` 
and not any of the `ASTNodeImporter::ImportDefinition` funcitons. This is a 
very important distinction, because the former is part of the public interface, 
while the latter are private implementation functions. Could you please fix 
this in the comment?



Comment at: clang/lib/AST/ASTImporter.cpp:1755-1759
+  QualType FromTy = ArrayFrom->getElementType();
+  QualType ToTy = ArrayTo->getElementType();
+
+  FromRecordDecl = FromTy->getAsRecordDecl();
+  ToRecordDecl = ToTy->getAsRecordDecl();

labath wrote:
> What about 2- or n-dimensional arrays?
@labath, this is a very good question! And made me realize that D71378 is 
fundamentally flawed (@shafik, please take no offense). Let me explain.

So, with D71378, we added the `if (ImportedOrErr) { ... }` block to import 
definitions specifically of fields' Record types. But we forget to handle 
arrays. Now we may forget to handle multidimensional arrays ... and we may 
forget to handle other language constructs. So, we would finally end up in 
re-implementing the logic of `ASTNodeImporter::VisitFieldDecl`.

So all this should have been handled properly by the preceding import call of 
the FieldDecl! Here
```
1735: ExpectedDecl ImportedOrErr = import(From);
```
I have a suspicion that real reason why this import call fails in case of the 
public ASTImporter::ImportDefinition() is that we fail to drive through the 
import kind (`IDK_Everything`) during the import process.
Below we set IDK_Everything and start a complete import process.
```
  8784   if (auto *ToRecord = dyn_cast(To)) {
  8785 if (!ToRecord->getDefinition()) {
  8786   return Importer.ImportDefinition(   // 
ASTNodeImporter::ImportDefinition !
  8787   cast(FromDC), ToRecord,
  8788   ASTNodeImporter::IDK_Everything);
  8789 }
  8790   }
```
However, there may be many places where we fail to channel through that we want 
to do a complete import. E.g here
```
1957   ImportDefinitionIfNeeded(Base1.getType()->getAsCXXRecordDecl()))
```
we do another definition import and IDK_Everything is not set. So we may have a 
wrong kind of import since the "minimal" flag is set.

The thing is, it is really confusing and error-prone to have both the 
`ASTImporter::Minimal` flag and the `ImportDefinitionKind`. They seem to be in 
contradiction to each other some times.
I think we should get rid of the Minimal flag. And Kind should be either a full 
completion (IDK_Everythink) or just a minimal (IDK_Basic). So, I'd scrap the 
IDK_Default too. Alternatively we could have a Kind member in 
AST**//Node//**Importer.
I think we should go into this direction to avoid similar problems during 
CodeGen in the future. WDYT?


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

https://reviews.llvm.org/D86660

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


[PATCH] D86691: [analyzer] Fix wrong parameter name in printFormattedEntry

2020-08-27 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D86691#2242004 , @nullptr.cpp wrote:

> @Szelethus @martong
> Sorry to interrupt, I don't have commit access, can you help commit this and 
> D86334 ?
> Yang Fan 
> Thanks!

Yep, no problem, I'll commit them tomorrow, first thing! Thanks again!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86691

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


[PATCH] D86716: [clang-format] Detect pointer qualifiers in cast expressions

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, 
curdeius.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.

When guessing whether a closing paren is then end of a cast expression also
skip over pointer qualifiers while looking for TT_PointerOrReference.
This prevents some address-of and dereference operators from being parsed
as a binary operator.

Before:
x = (foo *const) * v;
x = (foo *const volatile restrict __attribute__((foo)) _Nonnull 
_Null_unspecified _Nonnull) & v;

After:
x = (foo *const)*v;
x = (foo *const volatile restrict __attribute__((foo)) _Nonnull 
_Null_unspecified _Nonnull)&v;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86716

Files:
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8127,6 +8127,33 @@
AfterType);
 }
 
+TEST_F(FormatTest, UnderstandsPointerQualifiersInCast) {
+  // Check that qualifiers on pointers don't break parsing of casts.
+  verifyFormat("x = (foo *const)*v;");
+  verifyFormat("x = (foo *volatile)*v;");
+  verifyFormat("x = (foo *restrict)*v;");
+  verifyFormat("x = (foo *__attribute__((foo)))*v;");
+  verifyFormat("x = (foo *_Nonnull)*v;");
+  verifyFormat("x = (foo *_Nullable)*v;");
+  verifyFormat("x = (foo *_Null_unspecified)*v;");
+  verifyFormat("x = (foo *_Nonnull const)*v;");
+
+  // Check that we handle multiple trailing qualifiers and skip them all to
+  // determine that the expression is a cast to a pointer type.
+  FormatStyle LongPointerRight = getLLVMStyleWithColumns(999);
+  FormatStyle LongPointerLeft = getLLVMStyleWithColumns(999);
+  LongPointerLeft.PointerAlignment = FormatStyle::PAS_Left;
+  StringRef AllQualifiers = "const volatile restrict __attribute__((foo)) "
+"_Nonnull _Null_unspecified _Nonnull";
+  verifyFormat(("x = (foo *" + AllQualifiers + ")*v;").str(), LongPointerRight);
+  verifyFormat(("x = (foo* " + AllQualifiers + ")*v;").str(), LongPointerLeft);
+
+  // Also check that address-of is not parsed as a binary bitwise-and:
+  verifyFormat("x = (foo *const)&v;");
+  verifyFormat(("x = (foo *" + AllQualifiers + ")&v;").str(), LongPointerRight);
+  verifyFormat(("x = (foo* " + AllQualifiers + ")&v;").str(), LongPointerLeft);
+}
+
 TEST_F(FormatTest, UnderstandsSquareAttributes) {
   verifyFormat("SomeType s [[unused]] (InitValue);");
   verifyFormat("SomeType s [[gnu::unused]] (InitValue);");
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1827,10 +1827,30 @@
   return true;
 
 // Heuristically try to determine whether the parentheses contain a type.
-bool ParensAreType =
-!Tok.Previous ||
-Tok.Previous->isOneOf(TT_PointerOrReference, TT_TemplateCloser) ||
-Tok.Previous->isSimpleTypeSpecifier();
+auto IsQualifiedPointerOrReference = [](FormatToken *T) {
+  // This is used to handle cases such as x = (foo *const)&y;
+  assert(!T->isSimpleTypeSpecifier() && "Should have already been checked");
+  // Strip trailing qualifiers such as const or volatile when checking
+  // whether the parens could be a cast to a pointer/reference type.
+  while (T) {
+if (T->is(TT_AttributeParen)) {
+  // Handle `x = (foo *__attribute__((foo)))&v;`:
+  if (T->MatchingParen && T->MatchingParen->Previous &&
+  T->MatchingParen->Previous->is(tok::kw___attribute)) {
+T = T->MatchingParen->Previous->Previous;
+continue;
+  }
+} else if (T->canBePointerOrReferenceQualifier()) {
+  T = T->Previous;
+  continue;
+}
+break;
+  }
+  return T && T->is(TT_PointerOrReference);
+};
+bool ParensAreType = !Tok.Previous || Tok.Previous->is(TT_TemplateCloser) ||
+ Tok.Previous->isSimpleTypeSpecifier() ||
+ IsQualifiedPointerOrReference(Tok.Previous);
 bool ParensCouldEndDecl =
 Tok.Next->isOneOf(tok::equal, tok::semi, tok::l_brace, tok::greater);
 if (ParensAreType && !ParensCouldEndDecl)
@@ -1890,10 +1910,8 @@
 
 const FormatToken *NextToken = Tok.getNextNonComment();
 if (!NextToken ||
-NextToken->isOneOf(
-tok::arrow, tok::equal, tok::kw_const, tok::kw_restrict,
-tok::kw_volatile, tok::kw___attribute, tok::kw__Nonnull,
-tok::kw__Nullable, tok::kw__Null_unspecified, tok::kw_noexcept) ||
+NextToken->isOneOf(tok::arrow, tok::equal, tok::kw_noexcept) ||
+NextToken->canBeP

[PATCH] D85743: [CodeGen][AArch64] Support arm_sve_vector_bits attribute

2020-08-27 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes added a comment.

In D85743#2219215 , @efriedma wrote:

> LGTM
>
> Like I mentioned on the review for the prototype, I still think we should try 
> to implement a scheme that makes CK_BItCast between fixed and scalable types 
> trivial.  Doing coercion this way is going to have a significant performance 
> cost.  But there isn't any user-visible effect, so I'm fine with leaving that 
> for a followup.

I agree the bitcast scheme certainly isn't optimal but it's a start at least 
and something we intend to address going forward. Thanks for reviewing!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85743

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


[PATCH] D86710: [clang-format] Parse restrict as a pointer qualifier

2020-08-27 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD accepted this revision.
JakeMerdichAMD added a comment.
This revision is now accepted and ready to land.

LGTM, assuming tests pass (automated checks failed to resolve your patch since 
you based it off of your other one). Looks like enabling C99 should have no 
other effects, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86710

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


[PATCH] D86710: [clang-format] Parse restrict as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D86710#2242197 , @JakeMerdichAMD 
wrote:

> LGTM, assuming tests pass (automated checks failed to resolve your patch 
> since you based it off of your other one). Looks like enabling C99 should 
> have no other effects, right?

Tests are passing locally. Looking at TokenKinds.def it seems the only thing 
setting C99 enables is `restrict` and `inline` (but we already get that via 
C++).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86710

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


[PATCH] D86713: [clang-format] Parse nullability attributes as a pointer qualifier

2020-08-27 Thread Jake Merdich via Phabricator via cfe-commits
JakeMerdichAMD accepted this revision.
JakeMerdichAMD added a comment.
This revision is now accepted and ready to land.

LGTM, again assuming tests pass locally (patch did not resolve).

Out of curiosity, is _Atomic on your radar? I found some code in clang proper 
that handled restrict and _Atomic together. C/C++ have way too many 
qualifiers...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86713

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


[PATCH] D85032: [builtins] Make divXf3 handle denormal results

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 288349.
atrosinenko added a comment.

No-change re-upload: rebase onto current master branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85032

Files:
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/test/builtins/Unit/divdf3_test.c
  compiler-rt/test/builtins/Unit/divsf3_test.c
  compiler-rt/test/builtins/Unit/divtf3_test.c

Index: compiler-rt/test/builtins/Unit/divtf3_test.c
===
--- compiler-rt/test/builtins/Unit/divtf3_test.c
+++ compiler-rt/test/builtins/Unit/divtf3_test.c
@@ -146,6 +146,13 @@
  UINT64_C(0xfffe)))
 return 1;
 
+// smallest normal value divided by 2.0
+if (test__divtf3(0x1.0p-16382L, 2.L, UINT64_C(0x8000), UINT64_C(0x0)))
+  return 1;
+// smallest subnormal result
+if (test__divtf3(0x1.0p-1022L, 0x1p+52L, UINT64_C(0x0), UINT64_C(0x1)))
+  return 1;
+
 // any / any
 if (test__divtf3(0x1.a23b45362464523375893ab4cdefp+5L,
  0x1.eedcbaba3a94546558237654321fp-1L,
Index: compiler-rt/test/builtins/Unit/divsf3_test.c
===
--- compiler-rt/test/builtins/Unit/divsf3_test.c
+++ compiler-rt/test/builtins/Unit/divsf3_test.c
@@ -92,5 +92,20 @@
 if (test__divsf3(0x1.0p+0F, 0x1.0001p+0F, UINT32_C(0x3f7fff00)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divsf3(0x1.0p-126F, 2.0F, UINT32_C(0x0040)))
+  return 1;
+// smallest subnormal result
+if (test__divsf3(0x1.0p-126F, 0x1p+23F, UINT32_C(0x0001)))
+  return 1;
+
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divsf3(-0x1.3e75e6p-108F, -0x1.cf372p+38F, UINT32_C(0x0006)))
+  return 1;
+if (test__divsf3(0x1.e77c54p+81F, -0x1.e77c52p-47F, UINT32_C(0xff80)))
+  return 1;
+if (test__divsf3(0x1.fep-126F, 2.F, UINT32_C(0x0080)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,6 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// smallest normal value divided by 2.0
+if (test__divdf3(0x1.0p-1022, 2., UINT64_C(0x0008)))
+  return 1;
+// smallest subnormal result
+if (test__divdf3(0x1.0p-1022, 0x1.0p+52, UINT64_C(0x0001)))
+  return 1;
+
 // some misc test cases obtained by fuzzing against h/w implementation
 if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
   return 1;
@@ -99,6 +106,12 @@
   return 1;
 if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
   return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.9p+5, UINT64_C(0x51eb851eb852)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+41, UINT64_C(0x07ff)))
+  return 1;
+if (test__divdf3(0x1.0p-1022, 0x1.0028p+52, UINT64_C(0x1)))
+  return 1;
 
 return 0;
 }
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- compiler-rt/lib/builtins/fp_div_impl.inc
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -275,6 +275,7 @@
   if (quotient_UQ1 < (implicitBit << 1)) {
 residualLo = (aSignificand << (significandBits + 1)) - quotient_UQ1 * bSignificand;
 writtenExponent -= 1;
+aSignificand <<= 1;
 
 // the error is doubled
   } else {
@@ -304,19 +305,25 @@
   // Now, quotient_UQ1_SB <= the correctly-rounded result
   // and may need taking NextAfter() up to 3 times (see error estimates above)
   // r = a - b * q
+  rep_t absResult;
+  if (writtenExponent > 0) {
+// Clear the implicit bit
+absResult = quotient_UQ1 & significandMask;
+// Insert the exponent
+absResult |= (rep_t)writtenExponent << significandBits;
+residualLo <<= 1;
+  } else {
+// Prevent shift amount from being negative
+if (significandBits + writtenExponent < 0)
+  return fromRep(quotientSign);
 
-  if (writtenExponent < 0) {
-// Result is definitely subnormal, flushing to zero
-return fromRep(quotientSign);
-  }
+absResult = quotient_UQ1 >> (-writtenExponent + 1);
 
-  // Clear the implicit bit
-  rep_t absResult = quotient_UQ1 & significandMask;
-  // Insert the exponent
-  absResult |= (rep_t)writtenExponent << significandBits;
+// multiplied by two to prevent shift amount to be negative
+residualLo = (aSignificand << (significandBits + writtenExponent)) - (absResult * bSignificand << 1);
+  }
 
   // Round
-  residualLo <<= 1;
   residualLo += abs

[PATCH] D85031: [builtins] Unify the softfloat division implementation

2020-08-27 Thread Anatoly Trosinenko via Phabricator via cfe-commits
atrosinenko updated this revision to Diff 288348.
atrosinenko added a comment.

No-change re-upload: rebase onto current master branch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D85031

Files:
  compiler-rt/lib/builtins/divdf3.c
  compiler-rt/lib/builtins/divsf3.c
  compiler-rt/lib/builtins/divtf3.c
  compiler-rt/lib/builtins/fp_div_impl.inc
  compiler-rt/lib/builtins/fp_lib.h
  compiler-rt/lib/builtins/int_util.h
  compiler-rt/test/builtins/Unit/divdf3_test.c

Index: compiler-rt/test/builtins/Unit/divdf3_test.c
===
--- compiler-rt/test/builtins/Unit/divdf3_test.c
+++ compiler-rt/test/builtins/Unit/divdf3_test.c
@@ -92,5 +92,13 @@
 if (test__divdf3(0x1.0p+0, 0x1.0001p+0, UINT64_C(0x3fefffe0)))
   return 1;
 
+// some misc test cases obtained by fuzzing against h/w implementation
+if (test__divdf3(0x1.fdc239dd64735p-658, -0x1.fff9364c0843fp-948, UINT64_C(0xd20fdc8fc0ceffb1)))
+  return 1;
+if (test__divdf3(-0x1.78abb261d47c8p+794, 0x1.fb01d537cc5aep+266, UINT64_C(0xe0e7c6148ffc23e3)))
+  return 1;
+if (test__divdf3(-0x1.da7dfe6048b8bp-875, 0x1.ffc7ea3ff60a4p-610, UINT64_C(0xaf5dab1fe0269e2a)))
+  return 1;
+
 return 0;
 }
Index: compiler-rt/lib/builtins/int_util.h
===
--- compiler-rt/lib/builtins/int_util.h
+++ compiler-rt/lib/builtins/int_util.h
@@ -28,4 +28,20 @@
 #define COMPILE_TIME_ASSERT2(expr, cnt)\
   typedef char ct_assert_##cnt[(expr) ? 1 : -1] UNUSED
 
+// Force unrolling the code specified to be repeated N times.
+#define REPEAT_0_TIMES(code_to_repeat) /* do nothing */
+#define REPEAT_1_TIMES(code_to_repeat) code_to_repeat
+#define REPEAT_2_TIMES(code_to_repeat) \
+  REPEAT_1_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_3_TIMES(code_to_repeat) \
+  REPEAT_2_TIMES(code_to_repeat)   \
+  code_to_repeat
+#define REPEAT_4_TIMES(code_to_repeat) \
+  REPEAT_3_TIMES(code_to_repeat)   \
+  code_to_repeat
+
+#define REPEAT_N_TIMES_(N, code_to_repeat) REPEAT_##N##_TIMES(code_to_repeat)
+#define REPEAT_N_TIMES(N, code_to_repeat) REPEAT_N_TIMES_(N, code_to_repeat)
+
 #endif // INT_UTIL_H
Index: compiler-rt/lib/builtins/fp_lib.h
===
--- compiler-rt/lib/builtins/fp_lib.h
+++ compiler-rt/lib/builtins/fp_lib.h
@@ -40,9 +40,12 @@
 
 #if defined SINGLE_PRECISION
 
+typedef uint16_t half_rep_t;
 typedef uint32_t rep_t;
+typedef uint64_t twice_rep_t;
 typedef int32_t srep_t;
 typedef float fp_t;
+#define HALF_REP_C UINT16_C
 #define REP_C UINT32_C
 #define significandBits 23
 
@@ -58,9 +61,11 @@
 
 #elif defined DOUBLE_PRECISION
 
+typedef uint32_t half_rep_t;
 typedef uint64_t rep_t;
 typedef int64_t srep_t;
 typedef double fp_t;
+#define HALF_REP_C UINT32_C
 #define REP_C UINT64_C
 #define significandBits 52
 
@@ -102,9 +107,11 @@
 #elif defined QUAD_PRECISION
 #if __LDBL_MANT_DIG__ == 113 && defined(__SIZEOF_INT128__)
 #define CRT_LDBL_128BIT
+typedef uint64_t half_rep_t;
 typedef __uint128_t rep_t;
 typedef __int128_t srep_t;
 typedef long double fp_t;
+#define HALF_REP_C UINT64_C
 #define REP_C (__uint128_t)
 // Note: Since there is no explicit way to tell compiler the constant is a
 // 128-bit integer, we let the constant be casted to 128-bit integer
Index: compiler-rt/lib/builtins/fp_div_impl.inc
===
--- /dev/null
+++ compiler-rt/lib/builtins/fp_div_impl.inc
@@ -0,0 +1,336 @@
+//===-- lib/fp_div_impl.inc - Floating point division -*- C -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This file implements soft-float division with the IEEE-754 default
+// rounding (to nearest, ties to even).
+//
+//===--===//
+
+#include "fp_lib.h"
+
+// The __divXf3__ function implements Newton-Raphson floating point division.
+// It uses 3 iterations for float32, 4 for float64 and 5 for float128,
+// respectively. Due to number of significant bits being roughly doubled
+// every iteration, there are two modes supported: N full-width iterations (as
+// it is done for float32 by default) and (N-1) half-width iteration plus one
+// final full-width iteration. It is expected that half-width integer
+//

[PATCH] D86719: [SyntaxTree][NFC] Refactor function templates into functions taking base class

2020-08-27 Thread Eduardo Caldas via Phabricator via cfe-commits
eduucaldas created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
eduucaldas requested review of this revision.

The refactored functions were

- `isReponsibleForCreatingDeclaration`
- `getQualifiedNameStart`


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86719

Files:
  clang/lib/Tooling/Syntax/BuildTree.cpp


Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -378,11 +378,10 @@
 
   /// Returns true if \p D is the last declarator in a chain and is thus
   /// reponsible for creating SimpleDeclaration for the whole chain.
-  template 
-  bool isResponsibleForCreatingDeclaration(const T *D) const {
-static_assert((std::is_base_of::value ||
-   std::is_base_of::value),
-  "only DeclaratorDecl and TypedefNameDecl are supported.");
+  bool isResponsibleForCreatingDeclaration(const Decl *D) const {
+auto isSupported = isa(D);
+assert(isSupported &&
+   "only DeclaratorDecl and TypedefNameDecl are supported.");
 
 const Decl *Next = D->getNextDeclInContext();
 
@@ -390,15 +389,15 @@
 if (Next == nullptr) {
   return true;
 }
-const auto *NextT = dyn_cast(Next);
 
 // Next sibling is not the same type, this one is responsible.
-if (NextT == nullptr) {
+if (D->getKind() != Next->getKind()) {
   return true;
 }
+
 // Next sibling doesn't begin at the same loc, it must be a different
 // declaration, so this declarator is responsible.
-if (NextT->getBeginLoc() != D->getBeginLoc()) {
+if (Next->getBeginLoc() != D->getBeginLoc()) {
   return true;
 }
 
@@ -1405,10 +1404,10 @@
   }
 
 private:
-  template  SourceLocation getQualifiedNameStart(T *D) {
-static_assert((std::is_base_of::value ||
-   std::is_base_of::value),
-  "only DeclaratorDecl and TypedefNameDecl are supported.");
+  SourceLocation getQualifiedNameStart(NamedDecl *D) {
+auto isSupported = isa(D);
+assert(isSupported &&
+   "only DeclaratorDecl and TypedefNameDecl are supported.");
 
 auto DN = D->getDeclName();
 bool IsAnonymous = DN.isIdentifier() && !DN.getAsIdentifierInfo();
@@ -1438,10 +1437,9 @@
   /// Folds SimpleDeclarator node (if present) and in case this is the last
   /// declarator in the chain it also folds SimpleDeclaration node.
   template  bool processDeclaratorAndDeclaration(T *D) {
-SourceRange Initializer = getInitializerRange(D);
-auto Range = getDeclaratorRange(Builder.sourceManager(),
-D->getTypeSourceInfo()->getTypeLoc(),
-getQualifiedNameStart(D), Initializer);
+auto Range = getDeclaratorRange(
+Builder.sourceManager(), D->getTypeSourceInfo()->getTypeLoc(),
+getQualifiedNameStart(D), getInitializerRange(D));
 
 // There doesn't have to be a declarator (e.g. `void foo(int)` only has
 // declaration, but no declarator).


Index: clang/lib/Tooling/Syntax/BuildTree.cpp
===
--- clang/lib/Tooling/Syntax/BuildTree.cpp
+++ clang/lib/Tooling/Syntax/BuildTree.cpp
@@ -378,11 +378,10 @@
 
   /// Returns true if \p D is the last declarator in a chain and is thus
   /// reponsible for creating SimpleDeclaration for the whole chain.
-  template 
-  bool isResponsibleForCreatingDeclaration(const T *D) const {
-static_assert((std::is_base_of::value ||
-   std::is_base_of::value),
-  "only DeclaratorDecl and TypedefNameDecl are supported.");
+  bool isResponsibleForCreatingDeclaration(const Decl *D) const {
+auto isSupported = isa(D);
+assert(isSupported &&
+   "only DeclaratorDecl and TypedefNameDecl are supported.");
 
 const Decl *Next = D->getNextDeclInContext();
 
@@ -390,15 +389,15 @@
 if (Next == nullptr) {
   return true;
 }
-const auto *NextT = dyn_cast(Next);
 
 // Next sibling is not the same type, this one is responsible.
-if (NextT == nullptr) {
+if (D->getKind() != Next->getKind()) {
   return true;
 }
+
 // Next sibling doesn't begin at the same loc, it must be a different
 // declaration, so this declarator is responsible.
-if (NextT->getBeginLoc() != D->getBeginLoc()) {
+if (Next->getBeginLoc() != D->getBeginLoc()) {
   return true;
 }
 
@@ -1405,10 +1404,10 @@
   }
 
 private:
-  template  SourceLocation getQualifiedNameStart(T *D) {
-static_assert((std::is_base_of::value ||
-   std::is_base_of::value),
-  "only DeclaratorDecl and TypedefNameDecl are supported.");
+  SourceLocation getQualifiedNameStart(NamedDecl *D) {
+auto isSupported = isa(D);
+assert(isSupported &&
+   "only DeclaratorDecl and TypedefNameDecl 

[PATCH] D86720: [clang][aarch64] Drop experimental from __ARM_FEATURE_SVE_BITS macro

2020-08-27 Thread Cullen Rhodes via Phabricator via cfe-commits
c-rhodes created this revision.
c-rhodes added reviewers: sdesmalen, david-arm, efriedma.
Herald added subscribers: danielkiss, kristof.beyls, tschuett.
Herald added a reviewer: rengolin.
Herald added a reviewer: aaron.ballman.
Herald added a project: clang.
c-rhodes requested review of this revision.

The __ARM_FEATURE_SVE_BITS feature macro is specified in the Arm C
Language Extensions (ACLE) for SVE [1] (version 00bet5). From the spec,
where __ARM_FEATURE_SVE_BITS==N:

  When N is nonzero, indicates that the implementation is generating
  code for an N-bit SVE target and that the arm_sve_vector_bits(N)
  attribute is available.

This was defined in D83550  as 
__ARM_FEATURE_SVE_BITS_EXPERIMENTAL and
enabled under the -msve-vector-bits flag to simplify initial tests.
This patch drops _EXPERIMENTAL now there is support for the feature.

[1] https://developer.arm.com/documentation/100987/latest


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86720

Files:
  clang/include/clang/Basic/AttrDocs.td
  clang/lib/Basic/Targets/AArch64.cpp
  clang/test/CodeGen/attr-arm-sve-vector-bits-bitcast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-call.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-cast.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-codegen.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-globals.c
  clang/test/CodeGen/attr-arm-sve-vector-bits-types.c
  clang/test/CodeGenCXX/aarch64-mangle-sve-fixed-vectors.cpp
  clang/test/CodeGenCXX/aarch64-sve-fixedtypeinfo.cpp
  clang/test/Preprocessor/aarch64-target-features.c
  clang/test/Sema/attr-arm-sve-vector-bits.c
  clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp

Index: clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
===
--- clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
+++ clang/test/SemaCXX/attr-arm-sve-vector-bits.cpp
@@ -1,7 +1,7 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -std=c++11 -msve-vector-bits=512 -fallow-half-arguments-and-returns %s
 // expected-no-diagnostics
 
-#define N __ARM_FEATURE_SVE_BITS_EXPERIMENTAL
+#define N __ARM_FEATURE_SVE_BITS
 
 typedef __SVInt8_t svint8_t;
 typedef svint8_t fixed_int8_t __attribute__((arm_sve_vector_bits(N)));
Index: clang/test/Sema/attr-arm-sve-vector-bits.c
===
--- clang/test/Sema/attr-arm-sve-vector-bits.c
+++ clang/test/Sema/attr-arm-sve-vector-bits.c
@@ -4,7 +4,7 @@
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=1024 -fallow-half-arguments-and-returns %s
 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fsyntax-only -verify -msve-vector-bits=2048 -fallow-half-arguments-and-returns %s
 
-#define N __ARM_FEATURE_SVE_BITS_EXPERIMENTAL
+#define N __ARM_FEATURE_SVE_BITS
 
 typedef __SVInt8_t svint8_t;
 typedef __SVInt16_t svint16_t;
Index: clang/test/Preprocessor/aarch64-target-features.c
===
--- clang/test/Preprocessor/aarch64-target-features.c
+++ clang/test/Preprocessor/aarch64-target-features.c
@@ -44,12 +44,12 @@
 // CHECK-NOT: __ARM_BF16_FORMAT_ALTERNATIVE 1
 // CHECK-NOT: __ARM_FEATURE_BF16 1
 // CHECK-NOT: __ARM_FEATURE_BF16_VECTOR_ARITHMETIC 1
-// CHECK-NOT: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 0
-// CHECK-NOT: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 128
-// CHECK-NOT: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 256
-// CHECK-NOT: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 512
-// CHECK-NOT: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 1024
-// CHECK-NOT: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 2048
+// CHECK-NOT: __ARM_FEATURE_SVE_BITS 0
+// CHECK-NOT: __ARM_FEATURE_SVE_BITS 128
+// CHECK-NOT: __ARM_FEATURE_SVE_BITS 256
+// CHECK-NOT: __ARM_FEATURE_SVE_BITS 512
+// CHECK-NOT: __ARM_FEATURE_SVE_BITS 1024
+// CHECK-NOT: __ARM_FEATURE_SVE_BITS 2048
 
 // RUN: %clang -target aarch64_be-eabi -x c -E -dM %s -o - | FileCheck %s -check-prefix CHECK-BIGENDIAN
 // CHECK-BIGENDIAN: __ARM_BIG_ENDIAN 1
@@ -444,10 +444,8 @@
 // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=1024 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-1024 %s
 // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=2048 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-2048 %s
 // RUN: %clang -target aarch64-arm-none-eabi -march=armv8-a+sve -msve-vector-bits=2048 -x c -E -dM %s -o - 2>&1 | FileCheck -check-prefix=CHECK-SVE-VECTOR-BITS-2048 %s
-// NOTE: The __ARM_FEATURE_SVE_BITS feature macro is experimental until the
-// feature is complete.
-// CHECK-SVE-VECTOR-BITS-128: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 128
-// CHECK-SVE-VECTOR-BITS-256: __ARM_FEATURE_SVE_BITS_EXPERIMENTAL 256
-// CHECK-SVE-VECTOR-BITS-512: __ARM_FEATUR

[PATCH] D86713: [clang-format] Parse nullability attributes as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added a comment.

In D86713#2242253 , @JakeMerdichAMD 
wrote:

> LGTM, again assuming tests pass locally (patch did not resolve).
>
> Out of curiosity, is _Atomic on your radar? I found some code in clang proper 
> that handled restrict and _Atomic together. C/C++ have way too many 
> qualifiers...

I have not looked at _Atomic yet and it's probably low priority for me unless 
it's a trivial change.
My main motivation with these changes is to format a `__capability` pointer 
qualifier correctly (an extension that we add for our out-of-tree CHERI C/C++ 
dialect).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86713

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


[PATCH] D86721: [clang-format] Parse double-square attributes as pointer qualifiers

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson created this revision.
arichardson added reviewers: MyDeveloperDay, JakeMerdichAMD, sammccall, 
curdeius, aaron.ballman.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
arichardson requested review of this revision.

Before: x = (foo *[[clang::attr]] const) * v;
After:  x = (foo *[[clang::attr]] const)*v;


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D86721

Files:
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8068,6 +8068,7 @@
   verifyIndependentOfContext("MACRO(A *_Null_unspecified a);");
   verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);");
   verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);");
+  verifyIndependentOfContext("MACRO(A *[[clang::attr]] a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
   verifyFormat("void f() { f(float{1}, a * a); }");
   // FIXME: Is there a way to make this work?
@@ -8137,14 +8138,16 @@
   verifyFormat("x = (foo *_Nullable)*v;");
   verifyFormat("x = (foo *_Null_unspecified)*v;");
   verifyFormat("x = (foo *_Nonnull const)*v;");
+  verifyFormat("x = (foo *[[clang::attr]] const)*v;");
 
   // Check that we handle multiple trailing qualifiers and skip them all to
   // determine that the expression is a cast to a pointer type.
   FormatStyle LongPointerRight = getLLVMStyleWithColumns(999);
   FormatStyle LongPointerLeft = getLLVMStyleWithColumns(999);
   LongPointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  StringRef AllQualifiers = "const volatile restrict __attribute__((foo)) "
-"_Nonnull _Null_unspecified _Nonnull";
+  StringRef AllQualifiers =
+  "const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified 
"
+  "_Nonnull [[clang::attr]]";
   verifyFormat(("x = (foo *" + AllQualifiers + ")*v;").str(), 
LongPointerRight);
   verifyFormat(("x = (foo* " + AllQualifiers + ")*v;").str(), LongPointerLeft);
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1840,6 +1840,12 @@
 T = T->MatchingParen->Previous->Previous;
 continue;
   }
+} else if (T->is(TT_AttributeSquare)) {
+  // Handle `x = (foo *[[clang::foo]])&v;`:
+  if (T->MatchingParen && T->MatchingParen->Previous) {
+T = T->MatchingParen->Previous;
+continue;
+  }
 } else if (T->canBePointerOrReferenceQualifier()) {
   T = T->Previous;
   continue;


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -8068,6 +8068,7 @@
   verifyIndependentOfContext("MACRO(A *_Null_unspecified a);");
   verifyIndependentOfContext("MACRO(A *__attribute__((foo)) a);");
   verifyIndependentOfContext("MACRO(A *__attribute((foo)) a);");
+  verifyIndependentOfContext("MACRO(A *[[clang::attr]] a);");
   verifyIndependentOfContext("MACRO('0' <= c && c <= '9');");
   verifyFormat("void f() { f(float{1}, a * a); }");
   // FIXME: Is there a way to make this work?
@@ -8137,14 +8138,16 @@
   verifyFormat("x = (foo *_Nullable)*v;");
   verifyFormat("x = (foo *_Null_unspecified)*v;");
   verifyFormat("x = (foo *_Nonnull const)*v;");
+  verifyFormat("x = (foo *[[clang::attr]] const)*v;");
 
   // Check that we handle multiple trailing qualifiers and skip them all to
   // determine that the expression is a cast to a pointer type.
   FormatStyle LongPointerRight = getLLVMStyleWithColumns(999);
   FormatStyle LongPointerLeft = getLLVMStyleWithColumns(999);
   LongPointerLeft.PointerAlignment = FormatStyle::PAS_Left;
-  StringRef AllQualifiers = "const volatile restrict __attribute__((foo)) "
-"_Nonnull _Null_unspecified _Nonnull";
+  StringRef AllQualifiers =
+  "const volatile restrict __attribute__((foo)) _Nonnull _Null_unspecified "
+  "_Nonnull [[clang::attr]]";
   verifyFormat(("x = (foo *" + AllQualifiers + ")*v;").str(), LongPointerRight);
   verifyFormat(("x = (foo* " + AllQualifiers + ")*v;").str(), LongPointerLeft);
 
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1840,6 +1840,12 @@
 T = T->MatchingParen->Previous->Previous;
 continue;
   }
+} else if (T->is(TT_AttributeSquare)) {
+  // Handle `x = (foo *[[clang::foo]])&v;`:
+  if (T->MatchingParen && T->MatchingParen->Previous) {
+T = T->MatchingParen->Previous

[PATCH] D86711: [clang-format] Parse __attribute((foo)) as a pointer qualifier

2020-08-27 Thread Alexander Richardson via Phabricator via cfe-commits
arichardson added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:1895
tok::kw_restrict, tok::kw_volatile,
-   tok::kw_noexcept) ||
+   tok::kw___attribute, tok::kw_noexcept) ||
 (NextToken->is(tok::l_brace) && !NextToken->getNextNonComment()))

arichardson wrote:
> aaron.ballman wrote:
> > What about other attributes than GNU-style ones, like 
> > `[[clang::address_space(0)]]`?
> I guess those should also be handled. I can try to do that in a follow-up 
> change.
It appears that they are already handled for this case. I've handled them in 
cast expressions in D86721. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D86711

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


  1   2   3   >