[PATCH] D69520: [libc++] Disallow dynamic -> static span conversions

2019-11-01 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added inline comments.



Comment at: libcxx/test/std/containers/views/span.cons/span.fail.cpp:78
-
-//  Try to remove const and/or volatile (static -> static)
-{

Ok. The comment here is wrong; this is testing dynamic -> static.

However, why are you removing these (failing) tests?




Comment at: libcxx/test/std/containers/views/span.cons/span.pass.cpp:65
 }
-
-//  dynamic -> static

These cases (on the other hand) should be moved to a failure test.



Comment at: libcxx/test/std/containers/views/span.cons/span.pass.cpp:80
+
+  return s1.data() == nullptr && s1.size() == 0 && s2.data() == nullptr &&
+ s2.size() == 0 && s3.data() == nullptr && s3.size() == 0;

Please line these up like the other ones were. Makes it easy to see copy-pasta 
errors:
```
return s1.data() == nullptr && s1.size() == 0 
&& s2.data() == nullptr && s2.size() == 0
&& s3.data() == nullptr && s3.size() == 0;
```



Comment at: libcxx/test/std/containers/views/span.cons/span.pass.cpp:112
+std::span s3(s0d);// static -> dynamic
+return s1.data() == nullptr && s1.size() == 0 && s2.data() == nullptr &&
+   s2.size() == 0 && s3.data() == nullptr && s3.size() == 0;

same comment as above re: alignment.


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

https://reviews.llvm.org/D69520



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


[PATCH] D69573: [clang-format] [PR36294] AlwaysBreakAfterReturnType works incorrectly for some operator functions

2019-11-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked 5 inline comments as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/TokenAnnotator.cpp:2105
+  if ((Next->isSimpleTypeSpecifier() || Next->is(tok::identifier)) &&
+  Next->Next && Next->Next->is(tok::star)) {
+// For operator void*(), operator char*(), operator Foo*().

sammccall wrote:
> I'm suspicious of code that handles star but not amp, though maybe I 
> shouldn't be.
added those and mutated your test cases to cover that


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69573



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


[PATCH] D69573: [clang-format] [PR36294] AlwaysBreakAfterReturnType works incorrectly for some operator functions

2019-11-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 227405.
MyDeveloperDay set the repository for this revision to rG LLVM Github Monorepo.
MyDeveloperDay added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69573

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
@@ -6111,7 +6111,48 @@
"void\n"
"A::operator>>() {}\n"
"void\n"
-   "A::operator+() {}\n",
+   "A::operator+() {}\n"
+   "void\n"
+   "A::operator*() {}\n"
+   "void\n"
+   "A::operator->() {}\n"
+   "void\n"
+   "A::operator void *() {}\n"
+   "void\n"
+   "A::operator void &() {}\n"
+   "void\n"
+   "A::operator void &&() {}\n"
+   "void\n"
+   "A::operator char *() {}\n"
+   "void\n"
+   "A::operator[]() {}\n"
+   "void\n"
+   "A::operator!() {}\n",
+   Style);
+  verifyFormat("constexpr auto\n"
+   "operator()() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator>>() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator+() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator*() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator->() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator++() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator void *() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator void &() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator void &&() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator char *() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator!() const -> reference {}\n"
+   "constexpr auto\n"
+   "operator[]() const -> reference {}\n",
Style);
   verifyFormat("void *operator new(std::size_t s);", // No break here.
Style);
@@ -14728,6 +14769,53 @@
"#endif // while");
 }
 
+TEST_F(FormatTest, OperatorSpacing) {
+  FormatStyle Style = getLLVMStyle();
+  Style.PointerAlignment = FormatStyle::PAS_Right;
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator void *();", Style);
+  verifyFormat("Foo::operator()(void *);", Style);
+  verifyFormat("Foo::operator*(void *);", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator void &();", Style);
+  verifyFormat("Foo::operator()(void &);", Style);
+  verifyFormat("Foo::operator&(void &);", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator void &&();", Style);
+  verifyFormat("Foo::operator()(void &&);", Style);
+  verifyFormat("Foo::operator&&(void &&);", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+
+  Style.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("Foo::operator void*();", Style);
+  verifyFormat("Foo::operator()(void*);", Style);
+  verifyFormat("Foo::operator*(void*);", Style);
+  verifyFormat("Foo::operator*();", Style);
+  verifyFormat("operator*(int (*)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("Foo::operator void&();", Style);
+  verifyFormat("Foo::operator()(void&);", Style);
+  verifyFormat("Foo::operator&(void&);", Style);
+  verifyFormat("Foo::operator&();", Style);
+  verifyFormat("operator&(int (&)(), class Foo);", Style);
+
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("Foo::operator void&&();", Style);
+  verifyFormat("Foo::operator()(void&&);", Style);
+  verifyFormat("Foo::operator&&(void&&);", Style);
+  verifyFormat("Foo::operator&&();", Style);
+  verifyFormat("operator&&(int(&&)(), class Foo);", Style);
+}
+
 } // namespace
 } // namespace format
 } // namespace clang
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -950,9 +950,9 @@
 if (CurrentToken->isOneOf(tok::star, tok::amp))
  

[PATCH] D69573: [clang-format] [PR36294] AlwaysBreakAfterReturnType works incorrectly for some operator functions

2019-11-01 Thread pre-merge checks [bot] via Phabricator via cfe-commits
merge_guards_bot added a comment.

Build result: pass - 59827 tests passed, 0 failed and 762 were skipped.
Log files: console-log.txt 
,
 CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69573



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


[PATCH] D69435: [clang-tidy] New checker performance-trivially-destructible-check

2019-11-01 Thread Anton Bikineev via Phabricator via cfe-commits
AntonBikineev added a comment.

In D69435#1729580 , @gribozavr2 wrote:

> Alright then. (Although I don't know whether the redeclaration chain always 
> models that wording in the standard, and what that wording means when we 
> don't have a linear ordering of text -- that is, in modules.)
>
> Do you have commit access or do you need me to commit for you?


Thanks for taking the look, I'll commit.


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

https://reviews.llvm.org/D69435



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


Re: [PATCH] D55802: Change CGObjC to use objc intrinsics instead of runtime methods

2019-11-01 Thread David Chisnall via cfe-commits

Hi,

I think the assumption that intrinsics can't read any global is, indeed, 
the problem here.  `@llvm.objc.autoreleasePoolPop` may call any number 
of `-dealloc` methods with arbitrary side effects (though if they cause 
resurrection then that's undefined behaviour), so there should be no 
assumptions about the memory that it will read and write.


This check looks wrong, the documentation in Intrinsics.td states:

> By default, intrinsics are assumed to have side
> effects, so this property is only necessary if you have defined one of
> the memory properties listed above.

Looking at the other intrinsics, the ones that don't touch memory 
(mostly?) seem to have the IntrNoMem attribute set.  I think that should 
GlobalsAA should probably check that intrinsics either have that 
attribute set or one of the others that restricts the memory it can 
touch (e.g. IntrArgMemOnly).


David

On 31/10/2019 23:55, Alina Sbirlea wrote:

Following up on this, AFAICT this is working as intended on the LLVM side.

The different decision is made in GlobalsAA + MemoryDependencyAnalysis.
IIUC, the logic there is along the lines of: if I have a global G that's 
"internal" ("static" in C), and an intrinsic method M, then M cannot 
read from or write to G. In the LLVM IR for the test, @deallocCalled is 
an internal global, @llvm.objc.autoreleasePoolPop is an intrinsic, hence 
@llvm.objc.autoreleasePoolPop cannot read or write @deallocCalled.


Please note however that there are a couple of things that I found and 
intend to fix in GlobalsAA, but they do not seem to affect this case.


The one problem in particular that I thought was relevant here is that 
the "MayReadAnyGlobal" is not set on a path in 
GlobalsAAResult::AnalyzeCallGraph, but should apply when the function is 
not an intrinsic (judging by the other code paths). If 
@llvm.objc.autoreleasePoolPop was not an intrinsic, then with the fix in 
D69690  would resolve this miscompile.
Perhaps we should not rely on the assumption that intrinsics are 
restricted to this behavior in GlobalsAA?


Best,
Alina


On Thu, Oct 17, 2019 at 3:00 PM Alina Sbirlea > wrote:


I only got a chance to look more into this now. I can reproduce it
with re-inserting the "static".

The miscompile is not related to MemorySSA, i.e. disabling all uses
of MemorySSA doesn't help.
It appears to be a GVN bug, but I haven't tracked it further than this.

To repro, see attached .ll files. The only difference is the global
variable being static or not, which in IR translates to internal or
dso_local.
A simple `opt -O3 AssociatedObject_O0_*.ll` shows the difference you
mention.

Reducing the pipeline, I believe the result after the following
command is incorrect.
`opt -globals-aa -gvn AssociatedObject_O0_*.ll`
I'll need to dig deeper to confirm and track down the bug inside the
pass.


Thanks,
Alina


On Mon, Sep 30, 2019 at 4:30 AM David Chisnall
mailto:david.chisn...@cl.cam.ac.uk>>
wrote:

Hi,

Yes, I believe it does still reproduce (at least, with the most
recent
build that I tried).  We worked around the clang bug to make the
test pass:


https://github.com/gnustep/libobjc2/commit/eab35fce379eb6ab1423dbb6d7908cb782f13458#diff-7f1eea7fdb5c7c3bf21f08d1cfe98a19

Reintroducing the 'static' on deallocCalled reduces the test
case to
unconditionally failing the assert immediately after the pop,
and DCEs
the rest of the code.

David

On 11/09/2019 01:17, Alina Sbirlea wrote:
 > Hi David,
 >
 > Does this still reproduce?
 > I'm seeing the load after the call to autoreleasePoolPop at
ToT, but
 > perhaps I'm not using the proper flags?
 > I only checked out the github repo and did "clang
 > -fobjc-runtime=gnustep-2.0 -O3 -emit-llvm -S
 > libobjc2/Test/AssociatedObject.m" with a ToT clang.
 >
 > Thanks,
 > Alina
 >
 >
 > On Sun, Feb 24, 2019 at 9:56 AM Pete Cooper via llvm-commits
 > mailto:llvm-comm...@lists.llvm.org>
>> wrote:
 >
 >     Hey David
 >
 >     Thanks for letting me know, and analysing it this far!
 >
 >     I also can't see anything wrong with the intrinsic.  Its just
 >     defined as:
 >
 >         def int_objc_autoreleasePoolPop             :
Intrinsic<[],
 >         [llvm_ptr_ty]>;
 >
 >
 >     which (I believe) means it has unmodelled side effects so
it should
 >     have been fine for your example.
 >
 >     I'll try build the same file you did and see if I can
reproduce.
 >

[PATCH] D69657: [AArch64][SVE] Implement several floating-point arithmetic intrinsics

2019-11-01 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG5ec34dfdf733: [AArch64][SVE] Implement several 
floating-point arithmetic intrinsics (authored by kmclaughlin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69657

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-fp-arith.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-fp-arith.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-fp-arith.ll
@@ -0,0 +1,530 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; FABD
+;
+
+define  @fabd_h( %pg,  %a,  %b) {
+; CHECK-LABEL: fabd_h:
+; CHECK: fabd z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fabd.nxv8f16( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @fabd_s( %pg,  %a,  %b) {
+; CHECK-LABEL: fabd_s:
+; CHECK: fabd z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fabd.nxv4f32( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @fabd_d( %pg,  %a,  %b) {
+; CHECK-LABEL: fabd_d:
+; CHECK: fabd z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fabd.nxv2f64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+;
+; FADD
+;
+
+define  @fadd_h( %pg,  %a,  %b) {
+; CHECK-LABEL: fadd_h:
+; CHECK: fadd z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fadd.nxv8f16( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @fadd_s( %pg,  %a,  %b) {
+; CHECK-LABEL: fadd_s:
+; CHECK: fadd z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fadd.nxv4f32( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @fadd_d( %pg,  %a,  %b) {
+; CHECK-LABEL: fadd_d:
+; CHECK: fadd z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fadd.nxv2f64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+;
+; FDIV
+;
+
+define  @fdiv_h( %pg,  %a,  %b) {
+; CHECK-LABEL: fdiv_h:
+; CHECK: fdiv z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fdiv.nxv8f16( %pg,
+  %a,
+  %b)
+  ret  %out
+}
+
+define  @fdiv_s( %pg,  %a,  %b) {
+; CHECK-LABEL: fdiv_s:
+; CHECK: fdiv z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fdiv.nxv4f32( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @fdiv_d( %pg,  %a,  %b) {
+; CHECK-LABEL: fdiv_d:
+; CHECK: fdiv z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fdiv.nxv2f64( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+;
+; FDIVR
+;
+
+define  @fdivr_h( %pg,  %a,  %b) {
+; CHECK-LABEL: fdivr_h:
+; CHECK: fdivr z0.h, p0/m, z0.h, z1.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fdivr.nxv8f16( %pg,
+   %a,
+   %b)
+  ret  %out
+}
+
+define  @fdivr_s( %pg,  %a,  %b) {
+; CHECK-LABEL: fdivr_s:
+; CHECK: fdivr z0.s, p0/m, z0.s, z1.s
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fdivr.nxv4f32( %pg,
+%a,
+%b)
+  ret  %out
+}
+
+define  @fdivr_d( %pg,  %a,  %b) {
+; CHECK-LABEL: fdivr_d:
+; CHECK: fdivr z0.d, p0/m, z0.d, z1.d
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fdivr.nxv2f64( %pg,
+ %a,
+ %b)
+  ret  %out
+}
+
+;
+; FMAX
+;
+
+define  @fmax_h( %pg,  %a,  %b) {
+; CHECK-LABEL: fmax_h:
+; CHECK: fmax z0.h, p0/m, z0.h, z

[PATCH] D69233: [OpenCL] Support -fdeclare-opencl-builtins in C++ mode

2019-11-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

LGTM! Thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D69233



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


[PATCH] D69242: [Sema] Make helper in TreeTransform.h 'inline' instead of 'static'. NFC

2019-11-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia accepted this revision.
Anastasia added a comment.
This revision is now accepted and ready to land.

I agree. LGTM! Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69242



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


[PATCH] D69383: [RISCV] Match GCC `-march`/`-mabi` driver defaults

2019-11-01 Thread Sam Elliott via Phabricator via cfe-commits
lenary updated this revision to Diff 227418.
lenary added a comment.

- Update tests to reflect new defaults


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69383

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/lib/Driver/ToolChains/Arch/RISCV.h
  clang/lib/Driver/ToolChains/Gnu.cpp
  clang/test/Driver/riscv-abi.c
  clang/test/Driver/riscv-gnutools.c

Index: clang/test/Driver/riscv-gnutools.c
===
--- clang/test/Driver/riscv-gnutools.c
+++ clang/test/Driver/riscv-gnutools.c
@@ -1,19 +1,40 @@
 // Check gnutools are invoked with propagated values for -mabi and -march.
+//
+// This test also checks the default -march/-mabi for certain targets.
 
-// RUN: %clang -target riscv32 -fno-integrated-as %s -###  -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32 %s
+// 32-bit checks
 
-// RUN: %clang -target riscv32 -fno-integrated-as -march=rv32g %s -### -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP32-MARCH-G %s
+// Check default on riscv32-unknown-elf
+// RUN: %clang -target riscv32-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAC-ILP32 %s
 
-// RUN: %clang -target riscv64 -fno-integrated-as %s -###  -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64 %s
+// Check default on riscv32-unknown-linux-gnu
+// RUN: %clang -target riscv32-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32IMAFDC-ILP32D %s
 
-// RUN: %clang -target riscv64 -fno-integrated-as -march=rv64g %s -### -c \
-// RUN: 2>&1 | FileCheck -check-prefix=MABI-ILP64-MARCH-G %s
+// Check default when -march=rv32g specified
+// RUN: %clang -target riscv32 -fno-integrated-as %s -### -c -march=rv32g \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV32G-ILP32D %s
 
-// MABI-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32"
-// MABI-ILP32-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32g"
+// CHECK-RV32IMAC-ILP32: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32" "-march" "rv32imac"
+// CHECK-RV32IMAFDC-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32imafdc"
+// CHECK-RV32G-ILP32D: "{{.*}}as{{(.exe)?}}" "-mabi" "ilp32d" "-march" "rv32g"
 
-// MABI-ILP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64"
-// MABI-ILP64-MARCH-G: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64g"
+
+// 64-bit checks
+
+// Check default on riscv64-unknown-elf
+// RUN: %clang -target riscv64-unknown-elf -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64IMAC-LP64 %s
+
+// Check default on riscv64-unknown-linux-gnu
+// RUN: %clang -target riscv64-unknown-linux-gnu -fno-integrated-as %s -### -c \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64IMAFDC-LP64D %s
+
+// Check default when -march=rv64g specified
+// RUN: %clang -target riscv64 -fno-integrated-as %s -### -c -march=rv64g \
+// RUN: 2>&1 | FileCheck -check-prefix=CHECK-RV64G-LP64D %s
+
+// CHECK-RV64IMAC-LP64: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64" "-march" "rv64imac"
+// CHECK-RV64IMAFDC-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64imafdc"
+// CHECK-RV64G-LP64D: "{{.*}}as{{(.exe)?}}" "-mabi" "lp64d" "-march" "rv64g"
Index: clang/test/Driver/riscv-abi.c
===
--- clang/test/Driver/riscv-abi.c
+++ clang/test/Driver/riscv-abi.c
@@ -16,6 +16,10 @@
 
 // RUN: %clang -target riscv32-unknown-elf %s -### -o %t.o -march=rv32ifd -mabi=ilp32d 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
+// RUN: %clang -target riscv32-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
+// RUN: %clang -target riscv32-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-ILP32D %s
 
 // CHECK-ILP32D: "-target-abi" "ilp32d"
 
@@ -42,6 +46,10 @@
 
 // RUN: %clang -target riscv64-unknown-elf %s -### -o %t.o -march=rv64d -mabi=lp64d 2>&1 \
 // RUN:   | FileCheck -check-prefix=CHECK-LP64D %s
+// RUN: %clang -target riscv64-unknown-linux-gnu %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64D %s
+// RUN: %clang -target riscv64-unknown-linux-gnu -x assembler %s -### -o %t.o 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHECK-LP64D  %s
 
 // CHECK-LP64D: "-target-abi" "lp64d"
 
Index: clang/lib/Driver/ToolChains/Gnu.cpp
===
--- clang/lib/Driver/ToolChains/Gnu.cpp
+++ clang/lib/Driver/ToolChains/Gnu.cpp
@@ -709,11 +709,9 @@
 StringRef ABIName = riscv::getRISCVABI(Args, getToolChain().getTriple());
 CmdArgs.push_back("-mabi");
 CmdArgs.push_back(ABIName.data());
-if (const Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
-  StringRef MArch = A->getValue();
-  CmdArgs.push_back("-march");
-  CmdArgs.push_back(MArch.data());
-}
+StringRef MArchN

[PATCH] D69518: [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode

2019-11-01 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

This broke two stage builds of libc++. Can we revert this until a fix is ready?

  FAIL: libc++ :: 
std/utilities/meta/meta.const.eval/is_constant_evaluated.fail.cpp (55845 of 
59103)
   TEST 'libc++ :: 
std/utilities/meta/meta.const.eval/is_constant_evaluated.fail.cpp' FAILED 

  Command: ['/p/tllvm/bin/clang++', '-o', '/dev/null', '-x', 'c++', 
'/home/dave/s/lp/libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.fail.cpp',
 '-c', '-v', '-ftemplate-depth=270', '-fsyntax-only', '-Xclang', '-verify', 
'-Xclang', '-verify-ignore-unexpected=note', '-ferror-limit=1024', 
'-Werror=thread-safety', '-std=c++2a', '-include', 
'/home/dave/s/lp/libcxx/test/support/nasty_macros.h', '-nostdinc++', 
'-I/home/dave/s/lp/libcxx/include', 
'-I/tmp/_update_lc/t/projects/libcxx/include/c++build', 
'-D__STDC_FORMAT_MACROS', '-D__STDC_LIMIT_MACROS', '-D__STDC_CONSTANT_MACROS', 
'-I/home/dave/s/lp/libcxx/test/support', 
'-DLIBCXX_FILESYSTEM_STATIC_TEST_ROOT="/home/dave/s/lp/libcxx/test/std/input.output/filesystems/Inputs/static_test_env"',
 
'-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT="/tmp/_update_lc/t/projects/libcxx/test/filesystem/Output/dynamic_env"',
 '-DLIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER="/usr/bin/python 
/home/dave/s/lp/libcxx/test/support/filesystem_dynamic_test_helper.py"', 
'-D_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER', '-Wall', '-Wextra', '-Werror', 
'-Wuser-defined-warnings', '-Wshadow', '-Wno-unused-command-line-argument', 
'-Wno-attributes', '-Wno-pessimizing-move', '-Wno-c++11-extensions', 
'-Wno-user-defined-literals', '-Wno-noexcept-type', '-Wsign-compare', 
'-Wunused-variable', '-Wunused-parameter', '-Wunreachable-code', 
'-Wno-error=user-defined-warnings', '-c']
  Exit Code: 1
  Standard Error:
  --
  clang version 10.0.0 (/home/dave/s/lp/clang 
7e1a3076419d4d453d71143a1e81409ea1db177c)
  Target: x86_64-unknown-linux-gnu
  Thread model: posix
  InstalledDir: /p/tllvm/bin
  Found candidate GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
  Selected GCC installation: /usr/lib/gcc/x86_64-redhat-linux/9
  Candidate multilib: .;@m64
  Candidate multilib: 32;@m32
  Selected multilib: .;@m64
   "/p/tllvm/bin/clang-10" -cc1 -triple x86_64-unknown-linux-gnu -fsyntax-only 
-disable-free -disable-llvm-verifier -discard-value-names -main-file-name 
is_constant_evaluated.fail.cpp -mrelocation-model static -mthread-model posix 
-mframe-pointer=all -fmath-errno -masm-verbose -mconstructor-aliases 
-munwind-tables -fuse-init-array -target-cpu x86-64 -dwarf-column-info 
-debugger-tuning=gdb -v -nostdinc++ -resource-dir /p/tllvm/lib64/clang/10.0.0 
-include /home/dave/s/lp/libcxx/test/support/nasty_macros.h -I 
/home/dave/s/lp/libcxx/include -I 
/tmp/_update_lc/t/projects/libcxx/include/c++build -D __STDC_FORMAT_MACROS -D 
__STDC_LIMIT_MACROS -D __STDC_CONSTANT_MACROS -I 
/home/dave/s/lp/libcxx/test/support -D 
"LIBCXX_FILESYSTEM_STATIC_TEST_ROOT=\"/home/dave/s/lp/libcxx/test/std/input.output/filesystems/Inputs/static_test_env\""
 -D 
"LIBCXX_FILESYSTEM_DYNAMIC_TEST_ROOT=\"/tmp/_update_lc/t/projects/libcxx/test/filesystem/Output/dynamic_env\""
 -D "LIBCXX_FILESYSTEM_DYNAMIC_TEST_HELPER=\"/usr/bin/python 
/home/dave/s/lp/libcxx/test/support/filesystem_dynamic_test_helper.py\"" -D 
_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER -internal-isystem /usr/local/include 
-internal-isystem /p/tllvm/lib64/clang/10.0.0/include -internal-externc-isystem 
/include -internal-externc-isystem /usr/include -Werror=thread-safety -Wall 
-Wextra -Werror -Wuser-defined-warnings -Wshadow 
-Wno-unused-command-line-argument -Wno-attributes -Wno-pessimizing-move 
-Wno-c++11-extensions -Wno-user-defined-literals -Wno-noexcept-type 
-Wsign-compare -Wunused-variable -Wunused-parameter -Wunreachable-code 
-Wno-error=user-defined-warnings -std=c++2a -fdeprecated-macro 
-fdebug-compilation-dir /tmp/_update_lc/t -ftemplate-depth 270 -ferror-limit 
1024 -fmessage-length 0 -fgnuc-version=4.2.1 -fno-implicit-modules 
-fobjc-runtime=gcc -fcxx-exceptions -fexceptions -fdiagnostics-show-option 
-verify -verify-ignore-unexpected=note -faddrsig -x c++ 
/home/dave/s/lp/libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.fail.cpp
  clang -cc1 version 10.0.0 based upon LLVM 10.0.0svn default target 
x86_64-unknown-linux-gnu
  ignoring nonexistent directory "/include"
  #include "..." search starts here:
  #include <...> search starts here:
   /home/dave/s/lp/libcxx/include
   /tmp/_update_lc/t/projects/libcxx/include/c++build
   /home/dave/s/lp/libcxx/test/support
   /usr/local/include
   /p/tllvm/lib64/clang/10.0.0/include
   /usr/include
  End of search list.
  error: 'error' diagnostics seen but not expected: 
File 
/home/dave/s/lp/libcxx/test/std/utilities/meta/meta.const.eval/is_constant_evaluated.fail.cpp
 Line 26: 'std::is_constant_evaluated' will always evaluate to 'true' in a 
manifestly constant-evaluated expression
  1 error generated.
  --
  
  Expected compilatio

[PATCH] D69706: [Diagnostics] Teach -Wnull-dereference about address_space attribute

2019-11-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 created this revision.
xbolva00 added reviewers: aaron.ballman, rsmith.
xbolva00 added a project: clang.
Herald added subscribers: libcxx-commits, christof.
Herald added a project: libc++.

Clang should not warn for:
test.c:2:12: warning: indirection of non-volatile null pointer will be deleted,

not trap [-Wnull-dereference]
  return *(int __attribute__((address_space(256))) *) 0;
 ^~

Solves PR42292.

[libcxx] Disable -Wconstant-evaluated for libcxx's testsuite


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69706

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Sema/exprs.c
  libcxx/utils/libcxx/test/config.py


Index: libcxx/utils/libcxx/test/config.py
===
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -915,6 +915,7 @@
 self.cxx.addWarningFlagIfSupported('-Wshadow')
 self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument')
 self.cxx.addWarningFlagIfSupported('-Wno-attributes')
+self.cxx.addWarningFlagIfSupported('-Wno-constant-evaluated')
 self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
 self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions')
 self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals')
Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,11 +179,14 @@
   test18_e(); // expected-error {{too few arguments to function call, expected 
at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
   *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null 
pointer}} \
   // expected-note {{consider using __builtin_trap}}
   *(volatile int*)0 = 0;  // Ok.
+   *(int __attribute__((address_space(256))) *)0 = 0; // Ok.
+   *(int_AS256*)0 = 0; // Ok.
 
   // rdar://9269271
   int x = *(int*)0;  // expected-warning {{indirection of non-volatile null 
pointer}} \
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -483,15 +483,17 @@
   // only handles the pattern "*null", which is a very syntactic check.
   if (UnaryOperator *UO = dyn_cast(E->IgnoreParenCasts()))
 if (UO->getOpcode() == UO_Deref &&
-UO->getSubExpr()->IgnoreParenCasts()->
-  isNullPointerConstant(S.Context, Expr::NPC_ValueDependentIsNotNull) 
&&
+!isTargetAddressSpace(
+UO->getSubExpr()->getType()->getPointeeType().getAddressSpace()) &&
+UO->getSubExpr()->IgnoreParenCasts()->isNullPointerConstant(
+S.Context, Expr::NPC_ValueDependentIsNotNull) &&
 !UO->getType().isVolatileQualified()) {
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-  S.PDiag(diag::warn_indirection_through_null)
-<< UO->getSubExpr()->getSourceRange());
-S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
-S.PDiag(diag::note_indirection_through_null));
-  }
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::warn_indirection_through_null)
+<< UO->getSubExpr()->getSourceRange());
+  S.DiagRuntimeBehavior(UO->getOperatorLoc(), UO,
+S.PDiag(diag::note_indirection_through_null));
+}
 }
 
 static void DiagnoseDirectIsaAccess(Sema &S, const ObjCIvarRefExpr *OIRE,


Index: libcxx/utils/libcxx/test/config.py
===
--- libcxx/utils/libcxx/test/config.py
+++ libcxx/utils/libcxx/test/config.py
@@ -915,6 +915,7 @@
 self.cxx.addWarningFlagIfSupported('-Wshadow')
 self.cxx.addWarningFlagIfSupported('-Wno-unused-command-line-argument')
 self.cxx.addWarningFlagIfSupported('-Wno-attributes')
+self.cxx.addWarningFlagIfSupported('-Wno-constant-evaluated')
 self.cxx.addWarningFlagIfSupported('-Wno-pessimizing-move')
 self.cxx.addWarningFlagIfSupported('-Wno-c++11-extensions')
 self.cxx.addWarningFlagIfSupported('-Wno-user-defined-literals')
Index: clang/test/Sema/exprs.c
===
--- clang/test/Sema/exprs.c
+++ clang/test/Sema/exprs.c
@@ -179,11 +179,14 @@
   test18_e(); // expected-error {{too few arguments to function call, expected at least 2, have 0}}
 }
 
+typedef int __attribute__((address_space(256))) int_AS256;
 // PR7569
 void test19() {
   *(int*)0 = 0;   // expected-warning {{indirection of non-volatile null pointer}} \
   // expected-note {{consider using __builtin_trap}}
   *(volatile int*)0 = 0;  // Ok.
+   *(int __attribute__((address_space(256)))

[PATCH] D69518: [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode

2019-11-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Line 918

Add:
self.cxx.addWarningFlagIfSupported('-Wno-constant-evaluated')

to libcxx/utils/libcxx/test/config.py

Can you please try?

cc @EricWF


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69518



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


[PATCH] D69706: [Diagnostics] Teach -Wnull-dereference about address_space attribute

2019-11-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

(mistake)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69706



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


[PATCH] D69707: [AArch64][SVE] Implement additional floating-point arithmetic intrinsics

2019-11-01 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, huntergr, dancgr.
Herald added subscribers: psnobl, rkruppe, hiraditya, kristof.beyls, tschuett.
Herald added a project: LLVM.

Adds intrinsics for the following:

- ftssel
- fcadd, fcmla
- fmla, fmls, fnmla, fnmls
- fmad, fmsb, fnmad, fnmsb


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69707

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrFormats.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-fp-arith.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-fp-arith.ll
===
--- llvm/test/CodeGen/AArch64/sve-intrinsics-fp-arith.ll
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-fp-arith.ll
@@ -69,6 +69,111 @@
 }
 
 ;
+; FCADD
+;
+
+define  @fcadd_h( %pg,  %a,  %b) {
+; CHECK-LABEL: fcadd_h:
+; CHECK: fcadd z0.h, p0/m, z0.h, z1.h, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcadd.nxv8f16( %pg,
+   %a,
+   %b,
+  i32 90)
+  ret  %out
+}
+
+define  @fcadd_s( %pg,  %a,  %b) {
+; CHECK-LABEL: fcadd_s:
+; CHECK: fcadd z0.s, p0/m, z0.s, z1.s, #270
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcadd.nxv4f32( %pg,
+%a,
+%b,
+   i32 270)
+  ret  %out
+}
+
+define  @fcadd_d( %pg,  %a,  %b) {
+; CHECK-LABEL: fcadd_d:
+; CHECK: fcadd z0.d, p0/m, z0.d, z1.d, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcadd.nxv2f64( %pg,
+ %a,
+ %b,
+i32 90)
+  ret  %out
+}
+
+;
+; FCMLA
+;
+
+define  @fcmla_h( %pg,  %a,  %b,  %c) {
+; CHECK-LABEL: fcmla_h:
+; CHECK: fcmla z0.h, p0/m, z1.h, z2.h, #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcmla.nxv8f16( %pg,
+   %a,
+   %b,
+   %c,
+  i32 90)
+  ret  %out
+}
+
+define  @fcmla_s( %pg,  %a,  %b,  %c) {
+; CHECK-LABEL: fcmla_s:
+; CHECK: fcmla z0.s, p0/m, z1.s, z2.s, #180
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcmla.nxv4f32( %pg,
+%a,
+%b,
+%c,
+   i32 180)
+  ret  %out
+}
+
+define  @fcmla_d( %pg,  %a,  %b,  %c) {
+; CHECK-LABEL: fcmla_d:
+; CHECK: fcmla z0.d, p0/m, z1.d, z2.d, #270
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcmla.nxv2f64( %pg,
+ %a,
+ %b,
+ %c,
+i32 270)
+  ret  %out
+}
+
+;
+; FCMLA (Indexed)
+;
+
+define  @fcmla_lane_h( %a,  %b,  %c) {
+; CHECK-LABEL: fcmla_lane_h:
+; CHECK: fcmla z0.h, z1.h, z2.h[3], #0
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcmla.lane.nxv8f16( %a,
+%b,
+%c,
+   i32 3,
+   i32 0)
+  ret  %out
+}
+
+define  @fcmla_lane_s( %a,  %b,  %c) {
+; CHECK-LABEL: fcmla_lane_s:
+; CHECK: fcmla z0.s, z1.s, z2.s[1], #90
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fcmla.lane.nxv4f32( %a,
+ %b,
+ %c,
+i32 1,
+i32 90)
+  ret  %out
+}
+
+;
 ; FDIV
 ;
 
@@ -137,6 +242,43 @@
 }
 
 ;
+; FMAD
+;
+
+define  @fmad_h( %pg,  %a,  %b,  %c) {
+; CHECK-LABEL: fmad_h:
+; CHECK: fmad z0.h, p0/m, z1.h, z2.h
+; CHECK-NEXT: ret
+  %out = call  @llvm.aarch64.sve.fmad.nxv8f16( %pg,
+ 

[PATCH] D69518: [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode

2019-11-01 Thread David Zarzycki via Phabricator via cfe-commits
davezarzycki added a comment.

Hi @xbolva00 – Thanks. That does make the libcxx test suite pass.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69518



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


[PATCH] D69518: [Diagnostics] Warn for std::is_constant_evaluated in constexpr mode

2019-11-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

Thanks! Commited in rGdba83965722b540f6baf43163210943c41e1378a 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69518



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


[PATCH] D69498: IR: Invert convergent attribute handling

2019-11-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D69498#1725692 , @kariddi wrote:

> In D69498#1725528 , @rjmccall wrote:
>
> > It absolutely makes sense for Clang as a GPU-programming frontend to set 
> > attributes appropriately when targeting the GPU.  I'm objecting to making 
> > "convergence" and related "code layout is semantics" properties a universal 
> > part of the IR semantics that literally every frontend has to know about in 
> > order to get reasonable behavior from LLVM.  I know that doing so makes 
> > sense to GPU backend developers because you mostly work exclusively on GPU 
> > toolchains, but AFAIK there are half a dozen GPU frontends and they're all 
> > forks of Clang, whereas there are dozens of LLVM frontends out there that 
> > don't care about targeting the GPU and quite possibly never will.  (And 
> > even if they do target GPUs, they often will not care about exposing thread 
> > groups; many programming environments are just interested in taking 
> > advantage of the GPU's parallel-computation power and have no interest in 
> > inter-thread interference.)
> >
> > John.
>
>
> I agree that the issue with making it "transparent" as a concept to whoever 
> is not interested in programming models that have the concept of SIMD-wide 
> execution is an open issue (not only related to this patch, but in general to 
> the convergent idea as a whole, where writing a llvm pass that maintains 
> convergence now is an extra burden to the developer of such pass that wasn't 
> there before and that is probably completely orthogonal to the interest of 
> the pass writer probably targeting C/C++ or other non-parallel languages). I 
> opened some discussions going on the other related RFC for extending the 
> concept of convergent to avoid hoisting as well regarding how are we gonna 
> avoid burdening the LLVM community and maintain the invariants we want with 
> respect to this concept.
>  I have no idea what the impact of the convergent attribute is in Clang (with 
> the exception of adding the flag itself), but a lot of the heavy-lifting I 
> know its in LVLM itself.
>
> That said I just want to point out that some of these languages run on CPUs 
> as well (like openCL ) and they share the same properties with respect to 
> instructions that read execution masks of neighboring threads and making sure 
> threads stay converged when executing them. It's certainly unfortunate that 
> LLVM has some deficiencies in supporting these concepts and that the so far 
> proposed solutions are not burden free for the rest of the community. :-/


Aside from functionality issues with inter-thread interference, there is 
another very related aspect - optimizing for SIMT execution. This topic hasn't 
been discussed much yet but optimizing for single threaded execution doesn't 
always yield optimal result when run in SIMT style. For example divergent code 
regions can significantly slow down execution of multiple threads even if they 
have small instruction count. I think the biggest gap in LLVM is absence of a 
way to represent SIMT concept in general i.e. by adding special annotations to 
functions that run in SIMT mode or adding annotation to the whole module. This 
can be useful not only to correctly implement `convergent` but to potentially 
setup separate optimization pass pipeline for GPU-like targets to allow 
excluding harmful transformations and potentially add more passes to middle end 
that are targeting SIMT.  Currently there is no solution to this at middle end 
and therefore each backend ends up adding the same logic during lowering phases 
instead. However, adding the concept of SIMT seems like a large architectural 
change and might not be something we can do quickly. Potentially we can 
identify some small steps towards this goal that can be done now to at least to 
support the `convergent` for SIMT targets correctly without affecting much 
non-SIMT community.


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

https://reviews.llvm.org/D69498



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


[PATCH] D14927: clang-format: Add SpaceBeforeTemplateParameterList option

2019-11-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

This I believe is covered by `SpaceAfterTemplateKeyword` which does the same 
thing


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

https://reviews.llvm.org/D14927



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


[clang] 0aed36d - [OpenCL] Support -fdeclare-opencl-builtins in C++ mode

2019-11-01 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2019-11-01T13:56:43Z
New Revision: 0aed36d261d38c8dbc98bc52be26189e0ce57e30

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

LOG: [OpenCL] Support -fdeclare-opencl-builtins in C++ mode

Support for C++ mode was accidentally lacking due to not checking the
OpenCLCPlusPlus LangOpts version.

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

Added: 


Modified: 
clang/lib/Sema/SemaLookup.cpp
clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl

Removed: 




diff  --git a/clang/lib/Sema/SemaLookup.cpp b/clang/lib/Sema/SemaLookup.cpp
index d56c5980237c..3aedcdc66bcf 100644
--- a/clang/lib/Sema/SemaLookup.cpp
+++ b/clang/lib/Sema/SemaLookup.cpp
@@ -765,10 +765,13 @@ static void InsertOCLBuiltinDeclarationsFromTable(Sema 
&S, LookupResult &LR,
 ASTContext &Context = S.Context;
 
 // Ignore this BIF if its version does not match the language options.
-if (Context.getLangOpts().OpenCLVersion < OpenCLBuiltin.MinVersion)
+unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
+if (Context.getLangOpts().OpenCLCPlusPlus)
+  OpenCLVersion = 200;
+if (OpenCLVersion < OpenCLBuiltin.MinVersion)
   continue;
 if ((OpenCLBuiltin.MaxVersion != 0) &&
-(Context.getLangOpts().OpenCLVersion >= OpenCLBuiltin.MaxVersion))
+(OpenCLVersion >= OpenCLBuiltin.MaxVersion))
   continue;
 
 SmallVector RetTypes;

diff  --git a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl 
b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
index 250a3f008c94..84cbb7aeec9b 100644
--- a/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ b/clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -4,8 +4,10 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 // expected-no-diagnostics
 #endif
 
@@ -97,7 +99,7 @@ kernel void basic_image_writeonly(write_only image1d_buffer_t 
image_write_only_i
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is 
invalid in OpenCL}}
 // expected-error@-3{{implicit conversion changes signedness: 'int' to 'uint' 
(aka 'unsigned int')}}
 #endif
@@ -130,7 +132,7 @@ kernel void basic_work_item() {
   uint ui;
 
   get_enqueued_local_size(ui);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 
'get_enqueued_local_size' is invalid in OpenCL}}
 #endif
 }



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


[PATCH] D69233: [OpenCL] Support -fdeclare-opencl-builtins in C++ mode

2019-11-01 Thread Sven van Haastregt via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0aed36d261d3: [OpenCL] Support -fdeclare-opencl-builtins in 
C++ mode (authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69233

Files:
  clang/lib/Sema/SemaLookup.cpp
  clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -4,8 +4,10 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror 
-fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 // expected-no-diagnostics
 #endif
 
@@ -97,7 +99,7 @@
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is 
invalid in OpenCL}}
 // expected-error@-3{{implicit conversion changes signedness: 'int' to 'uint' 
(aka 'unsigned int')}}
 #endif
@@ -130,7 +132,7 @@
   uint ui;
 
   get_enqueued_local_size(ui);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 
'get_enqueued_local_size' is invalid in OpenCL}}
 #endif
 }
Index: clang/lib/Sema/SemaLookup.cpp
===
--- clang/lib/Sema/SemaLookup.cpp
+++ clang/lib/Sema/SemaLookup.cpp
@@ -765,10 +765,13 @@
 ASTContext &Context = S.Context;
 
 // Ignore this BIF if its version does not match the language options.
-if (Context.getLangOpts().OpenCLVersion < OpenCLBuiltin.MinVersion)
+unsigned OpenCLVersion = Context.getLangOpts().OpenCLVersion;
+if (Context.getLangOpts().OpenCLCPlusPlus)
+  OpenCLVersion = 200;
+if (OpenCLVersion < OpenCLBuiltin.MinVersion)
   continue;
 if ((OpenCLBuiltin.MaxVersion != 0) &&
-(Context.getLangOpts().OpenCLVersion >= OpenCLBuiltin.MaxVersion))
+(OpenCLVersion >= OpenCLBuiltin.MaxVersion))
   continue;
 
 SmallVector RetTypes;


Index: clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
===
--- clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
+++ clang/test/SemaOpenCL/fdeclare-opencl-builtins.cl
@@ -4,8 +4,10 @@
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL1.2 -fdeclare-opencl-builtins -finclude-default-header
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -DNO_HEADER
 // RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CL2.0 -fdeclare-opencl-builtins -finclude-default-header
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -DNO_HEADER
+// RUN: %clang_cc1 %s -triple spir -verify -pedantic -Wconversion -Werror -fsyntax-only -cl-std=CLC++ -fdeclare-opencl-builtins -finclude-default-header
 
-#if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+#if defined(__OPENCL_CPP_VERSION__) || __OPENCL_C_VERSION__ >= CL_VERSION_2_0
 // expected-no-diagnostics
 #endif
 
@@ -97,7 +99,7 @@
 
 kernel void basic_subgroup(global uint *out) {
   out[0] = get_sub_group_size();
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_sub_group_size' is invalid in OpenCL}}
 // expected-error@-3{{implicit conversion changes signedness: 'int' to 'uint' (aka 'unsigned int')}}
 #endif
@@ -130,7 +132,7 @@
   uint ui;
 
   get_enqueued_local_size(ui);
-#if __OPENCL_C_VERSION__ < CL_VERSION_2_0
+#if !defined(__OPENCL_CPP_VERSION__) && __OPENCL_C_VERSION__ < CL_VERSION_2_0
 // expected-error@-2{{implicit declaration of function 'get_enqueued_local_size' i

[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.def:426-436
+OPENMP_DEFAULTMAP_KIND(aggregate)
+OPENMP_DEFAULTMAP_KIND(pointer)
 
 // Modifiers for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_MODIFIER(alloc)
+OPENMP_DEFAULTMAP_MODIFIER(to)
+OPENMP_DEFAULTMAP_MODIFIER(from)

Add some guards in the code, these values must be enabled only for OpenMP 5.0, 
for 4.5 only scalar:tofrom is allowed. Add a test that the error messages are 
emitted for new cases in OpenMP 4.5



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7274
+  case OMPC_DEFAULTMAP_MODIFIER_none:
+Bits = OMP_MAP_NONE;
+break;

I think you just need to keep the original value of the `Bits` variable set in 
line 7242



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7276
+break;
+  default:
+llvm_unreachable("Unexpected implicit behavior!");

It is not recommended to use `default:` case in switches over enumerics, just 
add a case for each enum value and remove `default:`



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:7368-7370
+  bool IsImplicit, OpenMPDefaultmapClauseModifier ImplicitBehavior =
+  OMPC_DEFAULTMAP_MODIFIER_default,
+  OpenMPDefaultmapClauseKind VariableCategory = OMPC_DEFAULTMAP_unknown,

Do you really need the default params values here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:134
+DefaultMapVariableCategory VariableCategory = DMVC_unspecified;
+SourceLocation SLoc = SourceLocation();
+DefaultmapInfo() = default;

No need to call the constructor for classes as a default value, just 
`SourceLocation SLoc;` is enough



Comment at: clang/lib/Sema/SemaOpenMP.cpp:149
 SourceLocation DefaultAttrLoc;
-DefaultMapAttributes DefaultMapAttr = DMA_unspecified;
-SourceLocation DefaultMapAttrLoc;
+DefaultmapInfo DefaultmapMap[3];
+

Maybe, it would be better to make `DMVC_unspecified` the last one in the 
`DefaultMapVariableCategory` and use it as an array dimension here rather than 
rely on the magical number?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:623
+auto &DefaultmapInfo = getTopOfStack().
+   DefaultmapMap[static_cast(DMVC-1)];
+DefaultmapInfo.ImplicitBehavior = DMIB;

Do you really need the static_cast here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:625
+DefaultmapInfo.ImplicitBehavior = DMIB;
+DefaultmapInfo.VariableCategory = DMVC;
+DefaultmapInfo.SLoc = Loc;

Do you really need this field if your DefaultmapMap already variable category 
based array?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:630
+  bool hasSetDefaultmapCategory(OpenMPDefaultmapClauseKind VariableCategory) {
+int VC = static_cast(VariableCategory);
+return getTopOfStack().DefaultmapMap[VC].ImplicitBehavior != 
DMIB_unspecified &&

Do you really need a cast here?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:656
+ DefaultMapVariableCategory DMVC) const {
+if (DMVC == DMVC_scalar) {
+  return (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==

Better to use switch here.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:657-673
+  return (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==
+DMIB_alloc) ||
+ (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==
+DMIB_to) ||
+ (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==
+DMIB_from) ||
+ (getDefaultDMIBAtLevel(Level, OMPC_DEFAULTMAP_scalar) ==

Seems to me, these 2 checks are very similar, you cam merge them



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2928
+bool IsDMIBNone = false;
+if (VD->getType()->isPointerType() || 
VD->getType()->isMemberPointerType()) {
+  IsDMIBNone =

Just `isAnyPointerType()`



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2932-2933
+} else if (VD->getType()->isScalarType() &&
+   !VD->getType()->isBlockPointerType() &&
+   !VD->getType()->isObjCObjectPointerType()) {
+  IsDMIBNone =

Just `!VD->getType()->isAnyPointerType()`. Plus, I think you won't need it here 
in case of fixed condition in the main `if`.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2936
+Stack->getDefaultDMIB(OMPC_DEFAULTMAP_scalar) == DMIB_none;
+} else if (VD->getType()->isArrayType() || 
VD->getType()->isRecordType()) {
+  IsDMIBNone =

Just `isAggregateType()`? 



Comment at: clang/lib/Sema/SemaOpenMP.cpp:2996-3003
+

[PATCH] D69715: NeonEmitter: change Type representation. NFC.

2019-11-01 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: efriedma.
Herald added a subscriber: mcrosier.
Herald added a project: clang.

This has been separated off from D69618  to 
reduce clutter. Instead of using a sequence of bools to describe whether a type 
is floating, signed, ..., which can fairly easily end up in an inconsistent or 
otherwise meaningless state this switches to a single enum Kind. There should 
be no functional changes from this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69715

Files:
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -140,7 +140,15 @@
 private:
   TypeSpec TS;
 
-  bool Float, Signed, Immediate, Void, Poly, Constant, Pointer;
+  enum TypeKind {
+Void,
+Float,
+SInt,
+UInt,
+Poly,
+  };
+  TypeKind Kind;
+  bool Immediate, Constant, Pointer;
   // ScalarForMangling and NoManglingQ are really not suited to live here as
   // they are not related to the type. But they live in the TypeSpec (not the
   // prototype), so this is really the only place to store them.
@@ -149,15 +157,14 @@
 
 public:
   Type()
-  : Float(false), Signed(false), Immediate(false), Void(true), Poly(false),
-Constant(false), Pointer(false), ScalarForMangling(false),
-NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
+  : Kind(Void), Immediate(false), Constant(false),
+Pointer(false), ScalarForMangling(false), NoManglingQ(false),
+Bitwidth(0), ElementBitwidth(0), NumVectors(0) {}
 
   Type(TypeSpec TS, char CharMod)
-  : TS(std::move(TS)), Float(false), Signed(false), Immediate(false),
-Void(false), Poly(false), Constant(false), Pointer(false),
-ScalarForMangling(false), NoManglingQ(false), Bitwidth(0),
-ElementBitwidth(0), NumVectors(0) {
+  : TS(std::move(TS)), Kind(Void), Immediate(false),
+Constant(false), Pointer(false), ScalarForMangling(false),
+NoManglingQ(false), Bitwidth(0), ElementBitwidth(0), NumVectors(0) {
 applyModifier(CharMod);
   }
 
@@ -174,21 +181,21 @@
   bool noManglingQ() const { return NoManglingQ; }
 
   bool isPointer() const { return Pointer; }
-  bool isFloating() const { return Float; }
-  bool isInteger() const { return !Float && !Poly; }
-  bool isSigned() const { return Signed; }
+  bool isFloating() const { return Kind == Float; }
+  bool isInteger() const { return Kind == SInt || Kind == UInt; }
+  bool isPoly() const { return Kind == Poly; }
+  bool isSigned() const { return Kind == SInt; }
   bool isImmediate() const { return Immediate; }
   bool isScalar() const { return NumVectors == 0; }
   bool isVector() const { return NumVectors > 0; }
-  bool isFloat() const { return Float && ElementBitwidth == 32; }
-  bool isDouble() const { return Float && ElementBitwidth == 64; }
-  bool isHalf() const { return Float && ElementBitwidth == 16; }
-  bool isPoly() const { return Poly; }
+  bool isFloat() const { return isFloating() && ElementBitwidth == 32; }
+  bool isDouble() const { return isFloating() && ElementBitwidth == 64; }
+  bool isHalf() const { return isFloating() && ElementBitwidth == 16; }
   bool isChar() const { return ElementBitwidth == 8; }
-  bool isShort() const { return !Float && ElementBitwidth == 16; }
-  bool isInt() const { return !Float && ElementBitwidth == 32; }
-  bool isLong() const { return !Float && ElementBitwidth == 64; }
-  bool isVoid() const { return Void; }
+  bool isShort() const { return isInteger() && ElementBitwidth == 16; }
+  bool isInt() const { return isInteger() && ElementBitwidth == 32; }
+  bool isLong() const { return isInteger() && ElementBitwidth == 64; }
+  bool isVoid() const { return Kind == Void; }
   unsigned getNumElements() const { return Bitwidth / ElementBitwidth; }
   unsigned getSizeInBits() const { return Bitwidth; }
   unsigned getElementSizeInBits() const { return ElementBitwidth; }
@@ -197,21 +204,24 @@
   //
   // Mutator functions
   //
-  void makeUnsigned() { Signed = false; }
-  void makeSigned() { Signed = true; }
+  void makeUnsigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = UInt;
+  }
+  void makeSigned() {
+assert(isInteger() && "not a potentially signed type");
+Kind = SInt;
+  }
 
   void makeInteger(unsigned ElemWidth, bool Sign) {
-Float = false;
-Poly = false;
-Signed = Sign;
+assert(!isVoid() && "converting void to int probably not useful");
+Kind = Sign ? SInt : UInt;
 Immediate = false;
 ElementBitwidth = ElemWidth;
   }
 
   void makeImmediate(unsigned ElemWidth) {
-Float = false;
-Poly = false;
-Signed = true;
+Kind = SInt;
 Immediate = true;
 ElementBitwidth = ElemWidth;
   }
@@ -257,7 +267,7 @@
   /// seen. Th

[PATCH] D69716: NeonEmitter: remove special 'a' modifier.

2019-11-01 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover created this revision.
t.p.northover added a reviewer: efriedma.
Herald added a subscriber: mcrosier.
Herald added a project: clang.

This has been separated off from D69618  to 
reduce diff clutter, as it really stands on its own. The 'a' modifier is rarely 
used, but emits splatting code from NeonEmitter.cpp when it is. This 
functionality can be implemented directly in .td files though, at a net 
reduction in lines of code.

There are a few test changes, but they're just moving bitcasts around due to 
the slightly different input Clang sees. Nothing really changes.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69716

Files:
  clang/include/clang/Basic/arm_neon.td
  clang/include/clang/Basic/arm_neon_incl.td
  clang/test/CodeGen/aarch64-neon-2velem.c
  clang/test/CodeGen/arm_neon_intrinsics.c
  clang/utils/TableGen/NeonEmitter.cpp

Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -412,17 +412,6 @@
 return Idx - 1;
   }
 
-  /// Return true if the intrinsic takes an splat operand.
-  bool hasSplat() const { return Proto.find('a') != std::string::npos; }
-
-  /// Return the parameter index of the splat operand.
-  unsigned getSplatIdx() const {
-assert(hasSplat());
-unsigned Idx = Proto.find('a');
-assert(Idx > 0 && "Can't return a splat!");
-return Idx - 1;
-  }
-
   unsigned getNumParams() const { return Proto.size() - 1; }
   Type getReturnType() const { return Types[0]; }
   Type getParamType(unsigned I) const { return Types[I + 1]; }
@@ -431,7 +420,6 @@
   std::string getProto() const { return Proto; }
 
   /// Return true if the prototype has a scalar argument.
-  /// This does not return true for the "splat" code ('a').
   bool protoHasScalar() const;
 
   /// Return the index that parameter PIndex will sit at
@@ -950,7 +938,6 @@
 NumVectors = 0;
 break;
   case 's':
-  case 'a':
 Bitwidth = ElementBitwidth;
 NumVectors = 0;
 break;
@@ -1354,8 +1341,6 @@
   }
 }
 
-// We don't check 'a' in this function, because for builtin function the
-// argument matching to 'a' uses a vector type splatted from a scalar type.
 bool Intrinsic::protoHasScalar() const {
   return (Proto.find('s') != std::string::npos ||
   Proto.find('z') != std::string::npos ||
@@ -1374,12 +1359,6 @@
   bool SRet = getReturnType().getNumVectors() >= 2;
 
   StringRef N = Name;
-  if (hasSplat()) {
-// Call the non-splat builtin: chop off the "_n" suffix from the name.
-assert(N.endswith("_n"));
-N = N.drop_back(2);
-  }
-
   ClassKind LocalCK = CK;
   if (!protoHasScalar())
 LocalCK = ClassB;
@@ -1413,21 +1392,8 @@
   continue;
 }
 
-std::string Arg;
+std::string Arg = V.getName();
 Type CastToType = T;
-if (hasSplat() && I == getSplatIdx()) {
-  Arg = "(" + BaseType.str() + ") {";
-  for (unsigned J = 0; J < BaseType.getNumElements(); ++J) {
-if (J != 0)
-  Arg += ", ";
-Arg += V.getName();
-  }
-  Arg += "}";
-
-  CastToType = BaseType;
-} else {
-  Arg = V.getName();
-}
 
 // Check if an explicit cast is needed.
 if (CastToType.isVector()) {
@@ -2091,10 +2057,6 @@
   for (auto *Def : Defs) {
 if (Def->hasBody())
   continue;
-// Functions with 'a' (the splat code) in the type prototype should not get
-// their own builtin as they use the non-splat variant.
-if (Def->hasSplat())
-  continue;
 
 std::string S = "BUILTIN(__builtin_neon_" + Def->getMangledName() + ", \"";
 
@@ -2131,10 +2093,6 @@
 // __builtin_neon_* so we don't need to generate a definition for it.
 if (Def->hasBody())
   continue;
-// Functions with 'a' (the splat code) in the type prototype should not get
-// their own builtin as they use the non-splat variant.
-if (Def->hasSplat())
-  continue;
 // Functions which have a scalar argument cannot be overloaded, no need to
 // check them if we are emitting the type checking code.
 if (Def->protoHasScalar())
@@ -2215,10 +2173,6 @@
   for (auto *Def : Defs) {
 if (Def->hasBody())
   continue;
-// Functions with 'a' (the splat code) in the type prototype should not get
-// their own builtin as they use the non-splat variant.
-if (Def->hasSplat())
-  continue;
 // Functions which do not have an immediate do not need to have range
 // checking code emitted.
 if (!Def->hasImmediate())
Index: clang/test/CodeGen/arm_neon_intrinsics.c
===
--- clang/test/CodeGen/arm_neon_intrinsics.c
+++ clang/test/CodeGen/arm_neon_intrinsics.c
@@ -8472,11 +8472,11 @@
 }
 
 // CHECK-LABEL: @test_vmull_n_s16(
-// CHECK:   [[TMP0:%.*]] = bitcast <4 x i16> %a to <8 x i8>
 // CHECK:   [[VECINIT_I:%.*]] = insertelement <4

[PATCH] D69435: [clang-tidy] New checker performance-trivially-destructible-check

2019-11-01 Thread Anton Bikineev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGd36a03331026: [clang-tidy] New checker 
performance-trivially-destructible-check (authored by AntonBikineev).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69435

Files:
  clang-tools-extra/clang-tidy/performance/CMakeLists.txt
  clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
  clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
  clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.h
  clang-tools-extra/clang-tidy/utils/Matchers.h
  clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
  clang-tools-extra/clang-tidy/utils/TypeTraits.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst
  
clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp
@@ -0,0 +1,84 @@
+// RUN: %check_clang_tidy %s performance-trivially-destructible %t
+// RUN: grep -Ev "// *[A-Z-]+:" %s > %t.cpp
+// RUN: clang-tidy %t.cpp -checks='-*,performance-trivially-destructible' -fix
+// RUN: clang-tidy %t.cpp -checks='-*,performance-trivially-destructible' -warnings-as-errors='-*,performance-trivially-destructible'
+
+struct TriviallyDestructible1 {
+  int a;
+};
+
+struct TriviallyDestructible2 : TriviallyDestructible1 {
+  ~TriviallyDestructible2() = default;
+  TriviallyDestructible1 b;
+};
+
+struct NotTriviallyDestructible1 : TriviallyDestructible2 {
+  ~NotTriviallyDestructible1();
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'NotTriviallyDestructible1' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
+  // CHECK-FIXES: ~NotTriviallyDestructible1() = default;
+  TriviallyDestructible2 b;
+};
+
+NotTriviallyDestructible1::~NotTriviallyDestructible1() = default; // to-be-removed
+// CHECK-MESSAGES: :[[@LINE-1]]:28: note: destructor definition is here
+// CHECK-FIXES: {{^}}// to-be-removed
+
+// Don't emit for class template with type-dependent fields.
+template 
+struct MaybeTriviallyDestructible1 {
+  ~MaybeTriviallyDestructible1() noexcept;
+  T t;
+};
+
+template 
+MaybeTriviallyDestructible1::~MaybeTriviallyDestructible1() noexcept = default;
+
+// Don't emit for specializations.
+template struct MaybeTriviallyDestructible1;
+
+// Don't emit for class template with type-dependent bases.
+template 
+struct MaybeTriviallyDestructible2 : T {
+  ~MaybeTriviallyDestructible2() noexcept;
+};
+
+template 
+MaybeTriviallyDestructible2::~MaybeTriviallyDestructible2() noexcept = default;
+
+// Emit for templates without dependent bases and fields.
+template 
+struct MaybeTriviallyDestructible1 {
+  ~MaybeTriviallyDestructible1() noexcept;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'MaybeTriviallyDestructible1' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
+  // CHECK-FIXES: ~MaybeTriviallyDestructible1() noexcept = default;
+  TriviallyDestructible1 t;
+};
+
+template 
+MaybeTriviallyDestructible1::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
+// CHECK-MESSAGES: :[[@LINE-1]]:35: note: destructor definition is here
+// CHECK-FIXES: {{^}}// to-be-removed
+
+// Emit for explicit specializations.
+template <>
+struct MaybeTriviallyDestructible1: TriviallyDestructible1 {
+  ~MaybeTriviallyDestructible1() noexcept;
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: class 'MaybeTriviallyDestructible1' can be made trivially destructible by defaulting the destructor on its first declaration [performance-trivially-destructible]
+  // CHECK-FIXES: ~MaybeTriviallyDestructible1() noexcept = default;
+};
+
+MaybeTriviallyDestructible1::~MaybeTriviallyDestructible1() noexcept = default; // to-be-removed
+// CHECK-MESSAGES: :[[@LINE-1]]:38: note: destructor definition is here
+// CHECK-FIXES: {{^}}// to-be-removed
+
+struct NotTriviallyDestructible2 {
+  virtual ~NotTriviallyDestructible2();
+};
+
+NotTriviallyDestructible2::~NotTriviallyDestructible2() = default;
+
+struct NotTriviallyDestructible3: NotTriviallyDestructible2 {
+  ~NotTriviallyDestructible3();
+};
+
+NotTriviallyDestructible3::~NotTriviallyDestructible3() = default;
Index: clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst
@@ -0,0 +1,15 @@
+.. title:: clang-tidy - performance-trivi

[clang-tools-extra] d36a033 - [clang-tidy] New checker performance-trivially-destructible-check

2019-11-01 Thread Anton Bikineev via cfe-commits

Author: Anton Bikineev
Date: 2019-11-01T16:16:49+01:00
New Revision: d36a0333102698a1398971d0717465322b1c5c2c

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

LOG: [clang-tidy] New checker performance-trivially-destructible-check

Checks for types which can be made trivially-destructible by removing
out-of-line defaulted destructor declarations.

The check is motivated by the work on C++ garbage collector in Blink
(rendering engine for Chrome), which strives to minimize destructors and
improve runtime of sweeping phase.

In the entire chromium codebase the check hits over 2000 times.

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

Added: 
clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.h

clang-tools-extra/docs/clang-tidy/checks/performance-trivially-destructible.rst

clang-tools-extra/test/clang-tidy/checkers/performance-trivially-destructible.cpp

Modified: 
clang-tools-extra/clang-tidy/performance/CMakeLists.txt
clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
clang-tools-extra/clang-tidy/utils/Matchers.h
clang-tools-extra/clang-tidy/utils/TypeTraits.cpp
clang-tools-extra/clang-tidy/utils/TypeTraits.h
clang-tools-extra/docs/ReleaseNotes.rst
clang-tools-extra/docs/clang-tidy/checks/list.rst

Removed: 




diff  --git a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt 
b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
index b6302a5ff815..cde2e246bf9e 100644
--- a/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
+++ b/clang-tools-extra/clang-tidy/performance/CMakeLists.txt
@@ -11,6 +11,7 @@ add_clang_library(clangTidyPerformanceModule
   MoveConstructorInitCheck.cpp
   NoexceptMoveConstructorCheck.cpp
   PerformanceTidyModule.cpp
+  TriviallyDestructibleCheck.cpp
   TypePromotionInMathFnCheck.cpp
   UnnecessaryCopyInitialization.cpp
   UnnecessaryValueParamCheck.cpp

diff  --git 
a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp 
b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
index f4b620a14f85..269d09b98a68 100644
--- a/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
+++ b/clang-tools-extra/clang-tidy/performance/PerformanceTidyModule.cpp
@@ -18,6 +18,7 @@
 #include "MoveConstArgCheck.h"
 #include "MoveConstructorInitCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
+#include "TriviallyDestructibleCheck.h"
 #include "TypePromotionInMathFnCheck.h"
 #include "UnnecessaryCopyInitialization.h"
 #include "UnnecessaryValueParamCheck.h"
@@ -47,6 +48,8 @@ class PerformanceModule : public ClangTidyModule {
 "performance-move-constructor-init");
 CheckFactories.registerCheck(
 "performance-noexcept-move-constructor");
+CheckFactories.registerCheck(
+"performance-trivially-destructible");
 CheckFactories.registerCheck(
 "performance-type-promotion-in-math-fn");
 CheckFactories.registerCheck(

diff  --git 
a/clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp 
b/clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
new file mode 100644
index ..5ed705b0cd79
--- /dev/null
+++ b/clang-tools-extra/clang-tidy/performance/TriviallyDestructibleCheck.cpp
@@ -0,0 +1,82 @@
+//===--- TriviallyDestructibleCheck.cpp - clang-tidy 
--===//
+//
+// 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 "TriviallyDestructibleCheck.h"
+#include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+using namespace clang::ast_matchers::internal;
+using namespace clang::tidy::matchers;
+
+namespace clang {
+namespace tidy {
+namespace performance {
+
+namespace {
+
+AST_MATCHER(Decl, isFirstDecl) { return Node.isFirstDecl(); }
+
+AST_MATCHER_P(CXXRecordDecl, hasBase, Matcher, InnerMatcher) {
+  for (const CXXBaseSpecifier &BaseSpec : Node.bases()) {
+QualType BaseType = BaseSpec.getType();
+if (InnerMatcher.matches(BaseType, Finder, Builder))
+  return true;
+  }
+  return false;
+}
+
+} // namespace
+
+void TriviallyDestructibleCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus11)
+return;
+
+  Finder->addMatcher(
+  cxxDestructorDecl(
+  isDefaulted(),
+  unless(anyOf(isFirstDecl(), isVirtual(),
+   ofClass(cxxR

[PATCH] D69574: Remove lazy thread-initialisation

2019-11-01 Thread Matthew Malcomson via Phabricator via cfe-commits
mmalcomson added a comment.

Ping @pcc -- does this change to remove lazy thread initialisation look OK?

(I'm looking to start upstreaming hwasan instrumentation to GCC soon, and need 
to know whether GCC must insert the thread initialisation code in function 
prologues)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69574



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


[PATCH] D69632: [libTooling] Add Stencil constructor.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 227457.
ymandel added a comment.

renamed free function to avoid overloading a templated function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69632

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69574: Remove lazy thread-initialisation

2019-11-01 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc accepted this revision.
pcc added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69574



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


[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked an inline comment as done.
ymandel added a comment.

In D69613#1729703 , @gribozavr2 wrote:

> I see. Some decoupling is desirable, I agree. Maybe move `StencilInterface` 
> and `Stencil` into a separate header that `RewriteRule` can depend on, and 
> then define the library of stencils in another header?


This sounds good. I'll put together a (stacked) revision to do this. It seems 
worth doing separately given that it will involve a substantial to the 
RewriteRule library & tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613



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


[PATCH] D69625: [libTooling] Support implicit coercions in Stencil's `access` combinator.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D69625#1729702 , @gribozavr2 wrote:

> > Which idiom do you think we should encourage, then, for text and 
> > range-selectors -- the named combinator or the single-argument cat? That is
>
> You are making a very interesting point!
>
> It sounds very appealing to me to remove the special `text` and `selection` 
> functions in favor of `cat`. Users of the library (both readers and writers) 
> will have to know about `cat`. So the advantage of having special functions 
> `text` and `selection` is really limited I think.


Are you suggesting we remove `text` and `selection` entirely?  I really like 
this idea, just want to be sure I hadn't read more into your comment than you 
intended.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69625



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


[PATCH] D69360: [NFC] Refactor representation of materialized temporaries

2019-11-01 Thread Tyker via Phabricator via cfe-commits
Tyker updated this revision to Diff 227454.
Tyker marked 8 inline comments as done.
Tyker added a comment.

fixed comments.

i will do the other changes later.

i also renamed MaterializeTemporaryExpr::GetTemporaryExpr to 
MaterializeTemporaryExpr::getSubExpr and change all uses of 
MaterializeTemporaryExpr::getTemporary to use it.
the renaming is for consistancy with other implicit nodes.


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

https://reviews.llvm.org/D69360

Files:
  clang-tools-extra/clang-tidy/abseil/StrCatAppendCheck.cpp
  clang-tools-extra/clang-tidy/modernize/AvoidBindCheck.cpp
  clang-tools-extra/clang-tidy/modernize/LoopConvertUtils.cpp
  clang-tools-extra/clang-tidy/performance/ImplicitConversionInLoopCheck.cpp
  clang-tools-extra/clang-tidy/readability/NonConstParameterCheck.cpp
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/AST/ExprCXX.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/include/clang/Basic/DeclNodes.td
  clang/include/clang/Sema/Template.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/AST/DeclCXX.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprCXX.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/Analysis/CFG.cpp
  clang/lib/Analysis/Consumed.cpp
  clang/lib/Analysis/ThreadSafetyCommon.cpp
  clang/lib/CodeGen/CGDecl.cpp
  clang/lib/CodeGen/CGExpr.cpp
  clang/lib/CodeGen/CGExprAgg.cpp
  clang/lib/CodeGen/CGExprConstant.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Sema/JumpDiagnostics.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/SemaStmt.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/tools/libclang/CIndex.cpp

Index: clang/tools/libclang/CIndex.cpp
===
--- clang/tools/libclang/CIndex.cpp
+++ clang/tools/libclang/CIndex.cpp
@@ -6308,6 +6308,7 @@
   case Decl::PragmaDetectMismatch:
   case Decl::UsingPack:
   case Decl::Concept:
+  case Decl::LifetimeExtendedTemporary:
 return C;
 
   // Declaration kinds that don't make any sense here, but are
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -27,7 +27,7 @@
   ExplodedNode *Pred,
   ExplodedNodeSet &Dst) {
   StmtNodeBuilder Bldr(Pred, Dst, *currBldrCtx);
-  const Expr *tempExpr = ME->GetTemporaryExpr()->IgnoreParens();
+  const Expr *tempExpr = ME->getSubExpr()->IgnoreParens();
   ProgramStateRef state = Pred->getState();
   const LocationContext *LCtx = Pred->getLocationContext();
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -1427,7 +1427,7 @@
 
   bool IsTemporary = false;
   if (const auto *MTE = dyn_cast(ArgE)) {
-ArgE = MTE->GetTemporaryExpr();
+ArgE = MTE->getSubExpr();
 IsTemporary = true;
   }
 
Index: clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -766,8 +766,7 @@
 CheckerContext &C) const {
   /* Transfer iterator state to temporary objects */
   auto State = C.getState();
-  const auto *Pos =
-  getIteratorPosition(State, C.getSVal(MTE->GetTemporaryExpr()));
+  const auto *Pos = getIteratorPosition(State, C.getSVal(MTE->getSubExpr()));
   if (!Pos)
 return;
   State = setIteratorPosition(State, C.getSVal(MTE), *Pos);
Index: clang/lib/Serialization/ASTWriterStmt.cpp
===
--- clang/lib/Serialization/ASTWriterStmt.cpp
+++ clang/lib/Serialization/ASTWriterStmt.cpp
@@ -1835,9 +1835,11 @@
 
 void ASTStmtWriter::VisitMaterializeTemporaryExpr(MaterializeTemporaryExpr *E) {
   VisitExpr(E);
-  Record.AddStmt(E->getTemporary());
-  Record.AddDeclRef(E->getExtendingDecl());
-  Record.push_back(E->getManglingNumber());
+  Record.push_

[PATCH] D69638: [NFC] Add SUPPORT_PLUGINS to add_llvm_executable()

2019-11-01 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 227461.
daltenty added a comment.

- Address review comments round 1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69638

Files:
  clang/tools/driver/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/cmake/modules/HandleLLVMOptions.cmake
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/opt/CMakeLists.txt

Index: llvm/tools/opt/CMakeLists.txt
===
--- llvm/tools/opt/CMakeLists.txt
+++ llvm/tools/opt/CMakeLists.txt
@@ -24,9 +24,6 @@
   Passes
   )
 
-# Support plugins.
-set(LLVM_SUPPORT_PLUGINS 1)
-
 add_llvm_tool(opt
   AnalysisWrappers.cpp
   BreakpointPrinter.cpp
@@ -39,6 +36,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(opt)
 
Index: llvm/tools/llc/CMakeLists.txt
===
--- llvm/tools/llc/CMakeLists.txt
+++ llvm/tools/llc/CMakeLists.txt
@@ -19,13 +19,11 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_SUPPORT_PLUGINS 1)
-
 add_llvm_tool(llc
   llc.cpp
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(llc)
Index: llvm/tools/bugpoint/CMakeLists.txt
===
--- llvm/tools/bugpoint/CMakeLists.txt
+++ llvm/tools/bugpoint/CMakeLists.txt
@@ -21,9 +21,6 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_SUPPORT_PLUGINS 1)
-
 add_llvm_tool(bugpoint
   BugDriver.cpp
   CrashDebugger.cpp
@@ -37,6 +34,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(bugpoint)
 
Index: llvm/cmake/modules/HandleLLVMOptions.cmake
===
--- llvm/cmake/modules/HandleLLVMOptions.cmake
+++ llvm/cmake/modules/HandleLLVMOptions.cmake
@@ -744,7 +744,7 @@
 # Add flags for add_dead_strip().
 # FIXME: With MSVS, consider compiling with /Gy and linking with /OPT:REF?
 # But MinSizeRel seems to add that automatically, so maybe disable these
-# flags instead if LLVM_SUPPORT_PLUGINS is set.
+# flags instead if LLVM_NO_DEAD_STRIP is set.
 if(NOT CYGWIN AND NOT WIN32)
   if(NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin" AND
  NOT uppercase_CMAKE_BUILD_TYPE STREQUAL "DEBUG")
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -228,7 +228,7 @@
   # to enable. See https://sourceware.org/bugzilla/show_bug.cgi?id=17704.
 endif()
 
-if(NOT LLVM_SUPPORT_PLUGINS)
+if(NOT LLVM_NO_DEAD_STRIP)
   if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
 # ld64's implementation of -dead_strip breaks tools that use plugins.
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
@@ -245,7 +245,7 @@
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
  LINK_FLAGS " -Wl,--gc-sections")
   endif()
-else() #LLVM_SUPPORT_PLUGINS
+else() #LLVM_NO_DEAD_STRIP
   if(${CMAKE_SYSTEM_NAME} MATCHES "AIX")
 set_property(TARGET ${target_name} APPEND_STRING PROPERTY
  LINK_FLAGS " -Wl,-bnogc")
@@ -732,7 +732,7 @@
 
 macro(add_llvm_executable name)
   cmake_parse_arguments(ARG
-"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
 "ENTITLEMENTS;BUNDLE_PATH"
 "DEPENDS"
 ${ARGN})
@@ -782,6 +782,11 @@
   if(NOT LLVM_ENABLE_OBJLIB)
 llvm_update_compile_flags(${name})
   endif()
+
+  if (ARG_SUPPORT_PLUGINS)
+set(LLVM_NO_DEAD_STRIP On)
+  endif()
+
   add_link_opts( ${name} )
 
   # Do not add -Dname_EXPORTS to the command-line when building files in this
Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -19,10 +19,9 @@
 
 option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
 
-# Support plugins. This must be before add_clang_executable as it reads
-# LLVM_SUPPORT_PLUGINS.
+# Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
-  set(LLVM_SUPPORT_PLUGINS 1)
+  set(support_plugins SUPPORT_PLUGINS)
 endif()
 
 if(NOT CLANG_BUILT_STANDALONE)
@@ -37,6 +36,7 @@
 
   DEPENDS
   ${tablegen_deps}
+  ${support_plugins}
   )
 
 clang_target_link_libraries(clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69638: [NFC] Add SUPPORT_PLUGINS to add_llvm_executable()

2019-11-01 Thread David Tenty via Phabricator via cfe-commits
daltenty updated this revision to Diff 227463.
daltenty marked an inline comment as done.
daltenty added a comment.

- Rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69638

Files:
  clang/tools/driver/CMakeLists.txt
  llvm/cmake/modules/AddLLVM.cmake
  llvm/tools/bugpoint/CMakeLists.txt
  llvm/tools/llc/CMakeLists.txt
  llvm/tools/opt/CMakeLists.txt

Index: llvm/tools/opt/CMakeLists.txt
===
--- llvm/tools/opt/CMakeLists.txt
+++ llvm/tools/opt/CMakeLists.txt
@@ -24,9 +24,6 @@
   Passes
   )
 
-# Support plugins.
-set(LLVM_NO_DEAD_STRIP 1)
-
 add_llvm_tool(opt
   AnalysisWrappers.cpp
   BreakpointPrinter.cpp
@@ -39,6 +36,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(opt)
 
Index: llvm/tools/llc/CMakeLists.txt
===
--- llvm/tools/llc/CMakeLists.txt
+++ llvm/tools/llc/CMakeLists.txt
@@ -19,13 +19,11 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_NO_DEAD_STRIP 1)
-
 add_llvm_tool(llc
   llc.cpp
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(llc)
Index: llvm/tools/bugpoint/CMakeLists.txt
===
--- llvm/tools/bugpoint/CMakeLists.txt
+++ llvm/tools/bugpoint/CMakeLists.txt
@@ -21,9 +21,6 @@
   Vectorize
   )
 
-# Support plugins.
-set(LLVM_NO_DEAD_STRIP 1)
-
 add_llvm_tool(bugpoint
   BugDriver.cpp
   CrashDebugger.cpp
@@ -37,6 +34,7 @@
 
   DEPENDS
   intrinsics_gen
+  SUPPORT_PLUGINS
   )
 export_executable_symbols(bugpoint)
 
Index: llvm/cmake/modules/AddLLVM.cmake
===
--- llvm/cmake/modules/AddLLVM.cmake
+++ llvm/cmake/modules/AddLLVM.cmake
@@ -732,7 +732,7 @@
 
 macro(add_llvm_executable name)
   cmake_parse_arguments(ARG
-"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH"
+"DISABLE_LLVM_LINK_LLVM_DYLIB;IGNORE_EXTERNALIZE_DEBUGINFO;NO_INSTALL_RPATH;SUPPORT_PLUGINS"
 "ENTITLEMENTS;BUNDLE_PATH"
 "DEPENDS"
 ${ARGN})
@@ -782,6 +782,11 @@
   if(NOT LLVM_ENABLE_OBJLIB)
 llvm_update_compile_flags(${name})
   endif()
+
+  if (ARG_SUPPORT_PLUGINS)
+set(LLVM_NO_DEAD_STRIP On)
+  endif()
+
   add_link_opts( ${name} )
 
   # Do not add -Dname_EXPORTS to the command-line when building files in this
Index: clang/tools/driver/CMakeLists.txt
===
--- clang/tools/driver/CMakeLists.txt
+++ clang/tools/driver/CMakeLists.txt
@@ -19,10 +19,9 @@
 
 option(CLANG_PLUGIN_SUPPORT "Build clang with plugin support" ON)
 
-# Support plugins. This must be before add_clang_executable as it reads
-# LLVM_NO_DEAD_STRIP.
+# Support plugins.
 if(CLANG_PLUGIN_SUPPORT)
-  set(LLVM_NO_DEAD_STRIP 1)
+  set(support_plugins SUPPORT_PLUGINS)
 endif()
 
 if(NOT CLANG_BUILT_STANDALONE)
@@ -37,6 +36,7 @@
 
   DEPENDS
   ${tablegen_deps}
+  ${support_plugins}
   )
 
 clang_target_link_libraries(clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 6e759da - [libTooling] Add Stencil constructor.

2019-11-01 Thread Yitzhak Mandelbaum via cfe-commits

Author: Yitzhak Mandelbaum
Date: 2019-11-01T11:53:14-04:00
New Revision: 6e759daf2ea891fdd624d68690cdafdadcca11c9

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

LOG: [libTooling] Add Stencil constructor.

Summary:
Adds a constructor that takes a vector with which to initialize the `Parts`
field and a corresponding free function that forwards to the constructor. These
definitions are needed to assist in transitioning away from `Stencil` as a class
to defining it as a type alias.

Reviewers: ilya-biryukov

Subscribers: cfe-commits, gribozavr

Tags: #clang

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

Added: 


Modified: 
clang/include/clang/Tooling/Transformer/Stencil.h

Removed: 




diff  --git a/clang/include/clang/Tooling/Transformer/Stencil.h 
b/clang/include/clang/Tooling/Transformer/Stencil.h
index 66d1388f9710..6ef44e5ce7ba 100644
--- a/clang/include/clang/Tooling/Transformer/Stencil.h
+++ b/clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@ class StencilPart {
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@ class Stencil {
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);



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


[PATCH] D69632: [libTooling] Add Stencil constructor.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6e759daf2ea8: [libTooling] Add Stencil constructor. 
(authored by ymandel).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69632

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);


Index: clang/include/clang/Tooling/Transformer/Stencil.h
===
--- clang/include/clang/Tooling/Transformer/Stencil.h
+++ clang/include/clang/Tooling/Transformer/Stencil.h
@@ -90,6 +90,7 @@
 class Stencil {
 public:
   Stencil() = default;
+  Stencil(std::vector Parts) : Parts(std::move(Parts)) {}
 
   /// Composes a stencil from a series of parts.
   template  static Stencil cat(Ts &&... Parts) {
@@ -140,6 +141,12 @@
 template  Stencil cat(Ts &&... Parts) {
   return Stencil::cat(std::forward(Parts)...);
 }
+/// Convenience wrapper for Stencil constructor of the same type. Declaration
+/// outside of the class supports transition of `Stencil` type to an alias
+/// rather than a class.
+inline Stencil catVector(std::vector Parts) {
+  return Stencil(std::move(Parts));
+}
 
 /// \returns exactly the text provided.
 StencilPart text(llvm::StringRef Text);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69699: [clang][driver] Add ProfileData to LLVM_LINK_COMPONENTS

2019-11-01 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69699



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


[PATCH] D69393: [RFC][DebugInfo] emit user specified address_space in dwarf

2019-11-01 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a subscriber: rsmith.
probinson added a comment.

In D69393#1729772 , @yonghong-song 
wrote:

> During experimenting with linux kernel codes, I found that clang does not 
> allow address_space attribute for function pointers, specifically, in 
> `clang/lib/Sema/SemaType.cpp`,
>
>   // ISO/IEC TR 18037 S5.3 (amending C99 6.7.3): "A function type shall not be
>   // qualified by an address-space qualifier."
>   if (Type->isFunctionType()) {
> S.Diag(Attr.getLoc(), diag::err_attribute_address_function_type);
> Attr.setInvalid();
> return;
>   }
>   
>
> But linux kernel tries to annotate signal handling function pointer with 
> address space to indicate it is accessing user space.
>
>   typedef __signalfn_t __user *__sighandler_t;
>   typedef __restorefn_t __user *__sigrestore_t;
>
>
> Such attribute makes sense for linux since indeed the signal handler code 
> resides in user space and the kernel pointer
>  merely points to user memory here.
>
> But such attributes are not allowed for function pointers.
>
> Maybe somebody can give some context about this particular ISO/IEC TR 18037 
> specification? cc @probinson


I have no insight into the standards committees.  @rsmith is your guru here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69393



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


[PATCH] D69625: [libTooling] Support implicit coercions in Stencil's `access` combinator.

2019-11-01 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> Are you suggesting we remove text and selection entirely?

Yes!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69625



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


[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 227470.
mibintc added a comment.

Respond to recent code review from @rjmccall ; I modified the test cases and 
added functions for translating between the LangOptions enumeration and llvm 
enumeration for rounding-mode and exception-behavior.  I wasn't able to use 
BooleanFFlag because at the moment that is only usable for unsupported options.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fast-math.c
  clang/test/Driver/fp-model.c
  llvm/include/llvm/Target/TargetOptions.h

Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -107,7 +107,7 @@
   public:
 TargetOptions()
 : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
-  NoNaNsFPMath(false), NoTrappingFPMath(false),
+  NoNaNsFPMath(false), NoTrappingFPMath(true),
   NoSignedZerosFPMath(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
Index: clang/test/Driver/fp-model.c
===
--- /dev/null
+++ clang/test/Driver/fp-model.c
@@ -0,0 +1,130 @@
+// Test that incompatible combinations of -ffp-model= options
+// and other floating point options get a warning diagnostic.
+//
+// REQUIRES: clang-driver
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN %s
+// WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN1 %s
+// WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN2 %s
+// WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN3 %s
+// WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN4 %s
+// WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN5 %s
+// WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN7 %s
+// WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN8 %s
+// WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN9 %s
+// WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNa %s
+// WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNb %s
+// WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNc %s
+// WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN:   | FileCheck --che

[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:133
+
+llvm::ConstrainedFPIntrinsic::ExceptionBehavior
+CodeGenFunction::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) {

I added these 2 functions, is this what you have in mind or do you want me to 
write them differently?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D69322: [hip][cuda] Enable extended lambda support on Windows.

2019-11-01 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

kindly PING for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69322



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


[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 227473.
ymandel added a comment.

addressed to comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -96,7 +96,7 @@
  .bind("expr")))
 .bind("stmt"));
 ASSERT_TRUE(StmtMatch);
-if (auto ResultOrErr = Stencil.eval(StmtMatch->Result)) {
+if (auto ResultOrErr = Stencil->eval(StmtMatch->Result)) {
   ADD_FAILURE() << "Expected failure but succeeded: " << *ResultOrErr;
 } else {
   auto Err = llvm::handleErrors(ResultOrErr.takeError(),
@@ -131,11 +131,12 @@
   // Invert the if-then-else.
   auto Stencil = cat("if (!", node(Condition), ") ", statement(Else), " else ",
  statement(Then));
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
-TEST_F(StencilTest, SingleStatementCallOperator) {
+// Tests `stencil`.
+TEST_F(StencilTest, StencilFactoryFunction) {
   StringRef Condition("C"), Then("T"), Else("E");
   const std::string Snippet = R"cc(
 if (true)
@@ -148,9 +149,9 @@
   hasThen(stmt().bind(Then)), hasElse(stmt().bind(Else;
   ASSERT_TRUE(StmtMatch);
   // Invert the if-then-else.
-  Stencil S = cat("if (!", node(Condition), ") ", statement(Else), " else ",
-  statement(Then));
-  EXPECT_THAT_EXPECTED(S(StmtMatch->Result),
+  auto Consumer = cat("if (!", node(Condition), ") ", statement(Else), " else ",
+  statement(Then));
+  EXPECT_THAT_EXPECTED(Consumer(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
@@ -165,7 +166,7 @@
  hasThen(stmt().bind("a2";
   ASSERT_TRUE(StmtMatch);
   auto Stencil = cat("if(!", node("a1"), ") ", node("UNBOUND"), ";");
-  auto ResultOrErr = Stencil.eval(StmtMatch->Result);
+  auto ResultOrErr = Stencil->eval(StmtMatch->Result);
   EXPECT_TRUE(llvm::errorToBool(ResultOrErr.takeError()))
   << "Expected unbound node, got " << *ResultOrErr;
 }
@@ -176,14 +177,14 @@
   StringRef Expected) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result), HasValue(Expected));
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result), HasValue(Expected));
 }
 
 void testFailure(StringRef Id, StringRef Snippet, const Stencil &Stencil,
  testing::Matcher MessageMatcher) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
Failed(testing::Property(
&StringError::getMessage, MessageMatcher)));
 }
@@ -195,28 +196,28 @@
 
 TEST_F(StencilTest, IfBoundOpBound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound(Id, text("5"), text("7"))), "5");
+  testExpr(Id, "3;", ifBound(Id, text("5"), text("7")), "5");
 }
 
 TEST_F(StencilTest, IfBoundOpUnbound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound("other", text("5"), text("7"))), "7");
+  testExpr(Id, "3;", ifBound("other", text("5"), text("7")), "7");
 }
 
 TEST_F(StencilTest, ExpressionOpNoParens) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(expression(Id)), "3");
+  testExpr(Id, "3;", expression(Id), "3");
 }
 
 // Don't parenthesize a parens expression.
 TEST_F(StencilTest, ExpressionOpNoParensParens) {
   StringRef Id = "id";
-  testExpr(Id, "(3);", cat(expression(Id)), "(3)");
+  testExpr(Id, "(3);", expression(Id), "(3)");
 }
 
 TEST_F(StencilTest, ExpressionOpBinaryOpParens) {
   StringRef Id = "id";
-  testExpr(Id, "3+4;", cat(expression(Id)), "(3+4)");
+  testExpr(Id, "3+4;", expression(Id), "(3+4)");
 }
 
 // `expression` shares code with other ops, so we get sufficient coverage of the
@@ -224,33 +225,33 @@
 // tests should be added.
 TEST_F(StencilTest, ExpressionOpUnbound) {
   StringRef Id = "id";
-  testFailure(Id, "3;", cat(expression("ACACA")),
+  testFailure(Id, "3;", expression("ACACA"),
   AllOf(HasSubstr("ACACA"), HasSubstr("not bound")));
 }
 
 TEST_F(StencilTest, DerefPointer) {
   StringRef Id = "id";
-  testExpr(Id, "int *x; x;", cat(deref(Id)), "*x");
+  testExpr(Id, "int *x; x;", deref(Id), "*x");
 }
 
 TEST_F(StencilTest, DerefBinOp) {
   StringRef Id = "id";
-  testExpr(Id, "int *x; x + 1;", cat(deref(Id)), "*(x + 1)");
+  test

[PATCH] D57829: [CUDA][HIP] Disable emitting llvm.linker.options in device compilation

2019-11-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: clang/lib/Driver/ToolChains/Clang.cpp:389-392
+  // The linker_option directives are intended for host compilation.
+  if (JA.isDeviceOffloading(Action::OFK_Cuda) ||
+  JA.isDeviceOffloading(Action::OFK_HIP))
+Default = false;

yaxunl wrote:
> tra wrote:
> > Shouldn't it be `true`, considering that we do want to **disable** 
> > autolinking by default for device-side CUDA/HIP?
> > 
> > If we don't support autolinking at all for CUDA/HIP, perhaps we should just 
> > return `true` here.
> This variable Default is to be used as the default value of OPT_fautolink. 
> For device compilation we want the default value to be false. However if 
> users want to force it to be true, we may still want to respect it.
You are correct. I've missed the `!` in the return below.  Don't never use 
double negation. :-/

Nit: Perhaps we can rename `Default` -> `AutolinkEnabledByDefault` because 
right now it's easy to misinterpret it as the default return value of the 
function. Maybe, even change the function itself to `ShouldEnableAutolink()`. 



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

https://reviews.llvm.org/D57829



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


[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 12 inline comments as done.
ymandel added a comment.

In D69613#1730238 , @ymandel wrote:

> In D69613#1729703 , @gribozavr2 
> wrote:
>
> > I see. Some decoupling is desirable, I agree. Maybe move `StencilInterface` 
> > and `Stencil` into a separate header that `RewriteRule` can depend on, and 
> > then define the library of stencils in another header?
>
>
> This sounds good. I'll put together a (stacked) revision to do this. It seems 
> worth doing separately given that it will involve a substantial to the 
> RewriteRule library & tests.


In order to keep the client unaffected by the change, I reinstated a simple 
Stencil class to wrap the shared_ptr and provide the call operator.  This means 
that the code is now backwards compatible and forwards compatible (to the 
change we've discussed in RewriteRule to be stencil-aware).  This was simpler 
than adding temporary(?) overloads in `RewriteRule.h` for every function with a 
`TextGenerator` argument.

I included an overload of `operator->` so that we can collapse it back to just 
a type alias.




Comment at: clang/include/clang/Tooling/Transformer/Stencil.h:155
+template  MatchConsumer stencil(Ts &&... Parts) {
+  Stencil S = cat(std::forward(Parts)...);
+  return [S](const ast_matchers::MatchFinder::MatchResult &R) {

gribozavr2 wrote:
> I'm not sure the convenience of being able to avoid to say "cat(...)" at the 
> callsite is worth the API complexity. In other words, my suggestion is to 
> make this function take a single stencil.
Based on discussion, removed this entirely.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613



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


[PATCH] D68781: [OpenCL] Fix address space for const method call from nonconst

2019-11-01 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh updated this revision to Diff 227476.
svenvh retitled this revision from "[OpenCL] Fix addr space conversion check in 
obj arg initialization" to "[OpenCL] Fix address space for const method call 
from nonconst".
svenvh set the repository for this revision to rC Clang.
svenvh added a comment.
Herald added subscribers: cfe-commits, ebevhan.
Herald added a project: clang.

Fix formatting, reduce use of auto, and add a test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68781

Files:
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl


Index: clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -203,3 +203,14 @@
 // IMPL: [[C2GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C2GEN]] to 
i8 addrspace(4)*
 // IMPL: [[C1GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C1GEN]] to 
i8 addrspace(4)*
 // IMPL:  call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* 
{{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]]
+
+// Test that calling a const method from a non-const method does not crash 
Clang.
+class ConstAndNonConstMethod {
+public:
+  void DoConst() const {
+  }
+
+  void DoNonConst() {
+DoConst();
+  }
+};
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5370,7 +5370,10 @@
 
   if (!Context.hasSameType(From->getType(), DestType)) {
 CastKind CK;
-if (FromRecordType.getAddressSpace() != DestType.getAddressSpace())
+QualType PteeTy = DestType->getPointeeType();
+LangAS DestAS =
+PteeTy.isNull() ? DestType.getAddressSpace() : 
PteeTy.getAddressSpace();
+if (FromRecordType.getAddressSpace() != DestAS)
   CK = CK_AddressSpaceConversion;
 else
   CK = CK_NoOp;


Index: clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ clang/test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -203,3 +203,14 @@
 // IMPL: [[C2GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C2GEN]] to i8 addrspace(4)*
 // IMPL: [[C1GENVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[C1GEN]] to i8 addrspace(4)*
 // IMPL:  call void @llvm.memcpy.p4i8.p4i8.i32(i8 addrspace(4)* {{.*}}[[C2GENVOID]], i8 addrspace(4)* {{.*}}[[C1GENVOID]]
+
+// Test that calling a const method from a non-const method does not crash Clang.
+class ConstAndNonConstMethod {
+public:
+  void DoConst() const {
+  }
+
+  void DoNonConst() {
+DoConst();
+  }
+};
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5370,7 +5370,10 @@
 
   if (!Context.hasSameType(From->getType(), DestType)) {
 CastKind CK;
-if (FromRecordType.getAddressSpace() != DestType.getAddressSpace())
+QualType PteeTy = DestType->getPointeeType();
+LangAS DestAS =
+PteeTy.isNull() ? DestType.getAddressSpace() : PteeTy.getAddressSpace();
+if (FromRecordType.getAddressSpace() != DestAS)
   CK = CK_AddressSpaceConversion;
 else
   CK = CK_NoOp;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69613: [libTooling] Simplify type structure of `Stencil`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel updated this revision to Diff 227478.
ymandel marked an inline comment as done.
ymandel added a comment.

remove stray comments; clang-format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69613

Files:
  clang/include/clang/Tooling/Transformer/Stencil.h
  clang/lib/Tooling/Transformer/Stencil.cpp
  clang/unittests/Tooling/StencilTest.cpp

Index: clang/unittests/Tooling/StencilTest.cpp
===
--- clang/unittests/Tooling/StencilTest.cpp
+++ clang/unittests/Tooling/StencilTest.cpp
@@ -96,7 +96,7 @@
  .bind("expr")))
 .bind("stmt"));
 ASSERT_TRUE(StmtMatch);
-if (auto ResultOrErr = Stencil.eval(StmtMatch->Result)) {
+if (auto ResultOrErr = Stencil->eval(StmtMatch->Result)) {
   ADD_FAILURE() << "Expected failure but succeeded: " << *ResultOrErr;
 } else {
   auto Err = llvm::handleErrors(ResultOrErr.takeError(),
@@ -131,11 +131,12 @@
   // Invert the if-then-else.
   auto Stencil = cat("if (!", node(Condition), ") ", statement(Else), " else ",
  statement(Then));
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
-TEST_F(StencilTest, SingleStatementCallOperator) {
+// Tests `stencil`.
+TEST_F(StencilTest, StencilFactoryFunction) {
   StringRef Condition("C"), Then("T"), Else("E");
   const std::string Snippet = R"cc(
 if (true)
@@ -148,9 +149,9 @@
   hasThen(stmt().bind(Then)), hasElse(stmt().bind(Else;
   ASSERT_TRUE(StmtMatch);
   // Invert the if-then-else.
-  Stencil S = cat("if (!", node(Condition), ") ", statement(Else), " else ",
-  statement(Then));
-  EXPECT_THAT_EXPECTED(S(StmtMatch->Result),
+  auto Consumer = cat("if (!", node(Condition), ") ", statement(Else), " else ",
+  statement(Then));
+  EXPECT_THAT_EXPECTED(Consumer(StmtMatch->Result),
HasValue("if (!true) return 0; else return 1;"));
 }
 
@@ -165,7 +166,7 @@
  hasThen(stmt().bind("a2";
   ASSERT_TRUE(StmtMatch);
   auto Stencil = cat("if(!", node("a1"), ") ", node("UNBOUND"), ";");
-  auto ResultOrErr = Stencil.eval(StmtMatch->Result);
+  auto ResultOrErr = Stencil->eval(StmtMatch->Result);
   EXPECT_TRUE(llvm::errorToBool(ResultOrErr.takeError()))
   << "Expected unbound node, got " << *ResultOrErr;
 }
@@ -176,14 +177,14 @@
   StringRef Expected) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result), HasValue(Expected));
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result), HasValue(Expected));
 }
 
 void testFailure(StringRef Id, StringRef Snippet, const Stencil &Stencil,
  testing::Matcher MessageMatcher) {
   auto StmtMatch = matchStmt(Snippet, expr().bind(Id));
   ASSERT_TRUE(StmtMatch);
-  EXPECT_THAT_EXPECTED(Stencil.eval(StmtMatch->Result),
+  EXPECT_THAT_EXPECTED(Stencil->eval(StmtMatch->Result),
Failed(testing::Property(
&StringError::getMessage, MessageMatcher)));
 }
@@ -195,28 +196,28 @@
 
 TEST_F(StencilTest, IfBoundOpBound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound(Id, text("5"), text("7"))), "5");
+  testExpr(Id, "3;", ifBound(Id, text("5"), text("7")), "5");
 }
 
 TEST_F(StencilTest, IfBoundOpUnbound) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(ifBound("other", text("5"), text("7"))), "7");
+  testExpr(Id, "3;", ifBound("other", text("5"), text("7")), "7");
 }
 
 TEST_F(StencilTest, ExpressionOpNoParens) {
   StringRef Id = "id";
-  testExpr(Id, "3;", cat(expression(Id)), "3");
+  testExpr(Id, "3;", expression(Id), "3");
 }
 
 // Don't parenthesize a parens expression.
 TEST_F(StencilTest, ExpressionOpNoParensParens) {
   StringRef Id = "id";
-  testExpr(Id, "(3);", cat(expression(Id)), "(3)");
+  testExpr(Id, "(3);", expression(Id), "(3)");
 }
 
 TEST_F(StencilTest, ExpressionOpBinaryOpParens) {
   StringRef Id = "id";
-  testExpr(Id, "3+4;", cat(expression(Id)), "(3+4)");
+  testExpr(Id, "3+4;", expression(Id), "(3+4)");
 }
 
 // `expression` shares code with other ops, so we get sufficient coverage of the
@@ -224,33 +225,33 @@
 // tests should be added.
 TEST_F(StencilTest, ExpressionOpUnbound) {
   StringRef Id = "id";
-  testFailure(Id, "3;", cat(expression("ACACA")),
+  testFailure(Id, "3;", expression("ACACA"),
   AllOf(HasSubstr("ACACA"), HasSubstr("not bound")));
 }
 
 TEST_F(StencilTest, DerefPointer) {
   StringRef Id = "id";
-  testExpr(Id, "int *x; x;", cat(deref(Id)), "*x");
+  testExpr(Id, "int *x; x;", deref(Id), "*x");
 }
 
 TEST_F(StencilTest, DerefBinOp) {
   StringRef Id = "id";
-  testExpr(Id

[clang] 935c84c - [WebAssembly] Add experimental SIMD dot product instruction

2019-11-01 Thread Thomas Lively via cfe-commits

Author: Thomas Lively
Date: 2019-11-01T10:45:48-07:00
New Revision: 935c84c3c27de4544917216fc2b0557314802202

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

LOG: [WebAssembly] Add experimental SIMD dot product instruction

Summary:
This instruction is not merged to the spec proposal, but we need it to
be implemented in the toolchain to experiment with it. It is available
only on an opt-in basis through a clang builtin.

Defined in https://github.com/WebAssembly/simd/pull/127.

Depends on D69696.

Reviewers: aheejin

Subscribers: dschuff, sbc100, jgravelle-google, hiraditya, sunfish, 
cfe-commits, llvm-commits

Tags: #clang, #llvm

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

Added: 


Modified: 
clang/include/clang/Basic/BuiltinsWebAssembly.def
clang/lib/CodeGen/CGBuiltin.cpp
clang/test/CodeGen/builtins-wasm.c
llvm/include/llvm/IR/IntrinsicsWebAssembly.td
llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
llvm/test/MC/WebAssembly/simd-encodings.s

Removed: 




diff  --git a/clang/include/clang/Basic/BuiltinsWebAssembly.def 
b/clang/include/clang/Basic/BuiltinsWebAssembly.def
index 2233c20c4d64..2c57c5b70ef6 100644
--- a/clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ b/clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -132,6 +132,8 @@ TARGET_BUILTIN(__builtin_wasm_max_f32x4, "V4fV4fV4f", "nc", 
"simd128")
 TARGET_BUILTIN(__builtin_wasm_min_f64x2, "V2dV2dV2d", "nc", 
"unimplemented-simd128")
 TARGET_BUILTIN(__builtin_wasm_max_f64x2, "V2dV2dV2d", "nc", 
"unimplemented-simd128")
 
+TARGET_BUILTIN(__builtin_wasm_dot_s_i32x4_i16x8, "V4iV8sV8s", "nc", "simd128")
+
 TARGET_BUILTIN(__builtin_wasm_sqrt_f32x4, "V4fV4f", "nc", 
"unimplemented-simd128")
 TARGET_BUILTIN(__builtin_wasm_sqrt_f64x2, "V2dV2d", "nc", 
"unimplemented-simd128")
 

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index fef5cab8c8d1..cc2cbb907076 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -14360,6 +14360,12 @@ Value 
*CodeGenFunction::EmitWebAssemblyBuiltinExpr(unsigned BuiltinID,
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_dot_s_i32x4_i16x8: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_dot);
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_any_true_i8x16:
   case WebAssembly::BI__builtin_wasm_any_true_i16x8:
   case WebAssembly::BI__builtin_wasm_any_true_i32x4:

diff  --git a/clang/test/CodeGen/builtins-wasm.c 
b/clang/test/CodeGen/builtins-wasm.c
index c07e73fa1af8..eea51eb71b69 100644
--- a/clang/test/CodeGen/builtins-wasm.c
+++ b/clang/test/CodeGen/builtins-wasm.c
@@ -436,6 +436,12 @@ i32x4 max_u_i32x4(i32x4 x, i32x4 y) {
   // WEBASSEMBLY-NEXT: ret
 }
 
+i32x4 dot_i16x8_s(i16x8 x, i16x8 y) {
+  return __builtin_wasm_dot_s_i32x4_i16x8(x, y);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) {
   return __builtin_wasm_bitselect(x, y, c);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.bitselect.v4i32(

diff  --git a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td 
b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
index b99abb43d116..422334a78bb4 100644
--- a/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ b/llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -152,6 +152,10 @@ def int_wasm_qfms :
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
+def int_wasm_dot :
+  Intrinsic<[llvm_v4i32_ty],
+[llvm_v8i16_ty, llvm_v8i16_ty],
+[IntrNoMem, IntrSpeculatable]>;
 def int_wasm_narrow_signed :
   Intrinsic<[llvm_anyvector_ty],
 [llvm_anyvector_ty, LLVMMatchType<1>],

diff  --git a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td 
b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
index 2a423acc3016..137234f89b30 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -738,6 +738,13 @@ defm MAX_S : SIMDBinaryIntNoI64x2;
 defm MAX_U : SIMDBinaryIntNoI64x2;
 } // isCommutable = 1
 
+// Widening dot product: i32x4.dot_i16x8_s
+let isCommutable = 1 in
+defm DOT : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs), (outs), (ins),
+  [(set V128:$dst, (int_wasm_dot V128:$lhs, V128:$rhs))],
+  "i32x4.dot_i16x8_s\t$dst, $lhs, $rhs", "i32x4.dot_i16x8_s

[PATCH] D69697: [WebAssembly] Add experimental SIMD dot product instruction

2019-11-01 Thread Thomas Lively via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG935c84c3c27d: [WebAssembly] Add experimental SIMD dot 
product instruction (authored by tlively).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69697

Files:
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins-wasm.c
  llvm/include/llvm/IR/IntrinsicsWebAssembly.td
  llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
  llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
  llvm/test/MC/WebAssembly/simd-encodings.s

Index: llvm/test/MC/WebAssembly/simd-encodings.s
===
--- llvm/test/MC/WebAssembly/simd-encodings.s
+++ llvm/test/MC/WebAssembly/simd-encodings.s
@@ -571,4 +571,7 @@
 # CHECK: v128.andnot # encoding: [0xfd,0xd8,0x01]
 v128.andnot
 
+# CHECK: i32x4.dot_i16x8_s # encoding: [0xfd,0xd9,0x01]
+i32x4.dot_i16x8_s
+
 end_function
Index: llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
===
--- llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
+++ llvm/test/CodeGen/WebAssembly/simd-intrinsics.ll
@@ -387,6 +387,16 @@
   ret <4 x i32> %a
 }
 
+; CHECK-LABEL: dot:
+; SIMD128-NEXT: .functype dot (v128, v128) -> (v128){{$}}
+; SIMD128-NEXT: i32x4.dot_i16x8_s $push[[R:[0-9]+]]=, $0, $1{{$}}
+; SIMD128-NEXT: return $pop[[R]]{{$}}
+declare <4 x i32> @llvm.wasm.dot(<8 x i16>, <8 x i16>)
+define <4 x i32> @dot(<8 x i16> %x, <8 x i16> %y) {
+  %a = call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y)
+  ret <4 x i32> %a
+}
+
 ; CHECK-LABEL: any_v4i32:
 ; SIMD128-NEXT: .functype any_v4i32 (v128) -> (i32){{$}}
 ; SIMD128-NEXT: i32x4.any_true $push[[R:[0-9]+]]=, $0{{$}}
Index: llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
===
--- llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
+++ llvm/lib/Target/WebAssembly/WebAssemblyInstrSIMD.td
@@ -738,6 +738,13 @@
 defm MAX_U : SIMDBinaryIntNoI64x2;
 } // isCommutable = 1
 
+// Widening dot product: i32x4.dot_i16x8_s
+let isCommutable = 1 in
+defm DOT : SIMD_I<(outs V128:$dst), (ins V128:$lhs, V128:$rhs), (outs), (ins),
+  [(set V128:$dst, (int_wasm_dot V128:$lhs, V128:$rhs))],
+  "i32x4.dot_i16x8_s\t$dst, $lhs, $rhs", "i32x4.dot_i16x8_s",
+  217>;
+
 //===--===//
 // Floating-point unary arithmetic
 //===--===//
Index: llvm/include/llvm/IR/IntrinsicsWebAssembly.td
===
--- llvm/include/llvm/IR/IntrinsicsWebAssembly.td
+++ llvm/include/llvm/IR/IntrinsicsWebAssembly.td
@@ -152,6 +152,10 @@
   Intrinsic<[llvm_anyvector_ty],
 [LLVMMatchType<0>, LLVMMatchType<0>, LLVMMatchType<0>],
 [IntrNoMem, IntrSpeculatable]>;
+def int_wasm_dot :
+  Intrinsic<[llvm_v4i32_ty],
+[llvm_v8i16_ty, llvm_v8i16_ty],
+[IntrNoMem, IntrSpeculatable]>;
 def int_wasm_narrow_signed :
   Intrinsic<[llvm_anyvector_ty],
 [llvm_anyvector_ty, LLVMMatchType<1>],
Index: clang/test/CodeGen/builtins-wasm.c
===
--- clang/test/CodeGen/builtins-wasm.c
+++ clang/test/CodeGen/builtins-wasm.c
@@ -436,6 +436,12 @@
   // WEBASSEMBLY-NEXT: ret
 }
 
+i32x4 dot_i16x8_s(i16x8 x, i16x8 y) {
+  return __builtin_wasm_dot_s_i32x4_i16x8(x, y);
+  // WEBASSEMBLY: call <4 x i32> @llvm.wasm.dot(<8 x i16> %x, <8 x i16> %y)
+  // WEBASSEMBLY-NEXT: ret
+}
+
 i32x4 bitselect(i32x4 x, i32x4 y, i32x4 c) {
   return __builtin_wasm_bitselect(x, y, c);
   // WEBASSEMBLY: call <4 x i32> @llvm.wasm.bitselect.v4i32(
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -14360,6 +14360,12 @@
 Function *Callee = CGM.getIntrinsic(IntNo, ConvertType(E->getType()));
 return Builder.CreateCall(Callee, {LHS, RHS});
   }
+  case WebAssembly::BI__builtin_wasm_dot_s_i32x4_i16x8: {
+Value *LHS = EmitScalarExpr(E->getArg(0));
+Value *RHS = EmitScalarExpr(E->getArg(1));
+Function *Callee = CGM.getIntrinsic(Intrinsic::wasm_dot);
+return Builder.CreateCall(Callee, {LHS, RHS});
+  }
   case WebAssembly::BI__builtin_wasm_any_true_i8x16:
   case WebAssembly::BI__builtin_wasm_any_true_i16x8:
   case WebAssembly::BI__builtin_wasm_any_true_i32x4:
Index: clang/include/clang/Basic/BuiltinsWebAssembly.def
===
--- clang/include/clang/Basic/BuiltinsWebAssembly.def
+++ clang/include/clang/Basic/BuiltinsWebAssembly.def
@@ -132,6 +132,8 @@
 TARGET_B

[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-01 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen marked an inline comment as done.
cchen added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.def:426-436
+OPENMP_DEFAULTMAP_KIND(aggregate)
+OPENMP_DEFAULTMAP_KIND(pointer)
 
 // Modifiers for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_MODIFIER(alloc)
+OPENMP_DEFAULTMAP_MODIFIER(to)
+OPENMP_DEFAULTMAP_MODIFIER(from)

ABataev wrote:
> Add some guards in the code, these values must be enabled only for OpenMP 
> 5.0, for 4.5 only scalar:tofrom is allowed. Add a test that the error 
> messages are emitted for new cases in OpenMP 4.5
Do you mean that I should add the guards in this file (OpenMPKinds.def) so that 
Clang will not even parse those new keywords for OpenMP < 50 or I could just 
check the use of those keywords in Sema?
If I should put guards in the .def file, could you give me any hint or point me 
to an example? Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D69204: [OpenMP 5.0] - Extend defaultmap

2019-11-01 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/Basic/OpenMPKinds.def:426-436
+OPENMP_DEFAULTMAP_KIND(aggregate)
+OPENMP_DEFAULTMAP_KIND(pointer)
 
 // Modifiers for 'defaultmap' clause.
+OPENMP_DEFAULTMAP_MODIFIER(alloc)
+OPENMP_DEFAULTMAP_MODIFIER(to)
+OPENMP_DEFAULTMAP_MODIFIER(from)

cchen wrote:
> ABataev wrote:
> > Add some guards in the code, these values must be enabled only for OpenMP 
> > 5.0, for 4.5 only scalar:tofrom is allowed. Add a test that the error 
> > messages are emitted for new cases in OpenMP 4.5
> Do you mean that I should add the guards in this file (OpenMPKinds.def) so 
> that Clang will not even parse those new keywords for OpenMP < 50 or I could 
> just check the use of those keywords in Sema?
> If I should put guards in the .def file, could you give me any hint or point 
> me to an example? Thanks!
No, not in this file, this is just general comment. You need to guard this 
during semantic analysis


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69204



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


[PATCH] D68074: [clang-tidy] Add readability-make-member-function-const

2019-11-01 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.
This revision is now accepted and ready to land.



Comment at: 
clang-tools-extra/clang-tidy/readability/MakeMemberFunctionConstCheck.cpp:180
+//  use((const S*)this);
+//  (const S*)->f()
+// when 'f' is a public member function.

I think you meant `((const S*)this)->f()`.



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:21
+  Str S;
+  Str Sref;
+

Did you mean `Str &Sref`?



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:168
+
+  int M;
+  int keepConst() const { return M; }

Move up, close to other data members?



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:179
+
+  Str S;
+  void call_non_const_member_on_field() { S.non_const_method(); }

Move up, close to other data members?



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:247
+template 
+struct KeepWithTemplateBase : public Base {
+  int M;

"DependentBase"



Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:255
+template 
+struct KeepTemplateClass {
+  int M;

"ClassTemplate"




Comment at: 
clang-tools-extra/test/clang-tidy/readability-make-member-function-const.cpp:262
+
+struct KeepTemplateMethod {
+  int M;

"MemberFunctionTemplate"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68074



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


[PATCH] D69184: [libTooling] Introduce general combinator for fixed-value `MatchConsumer`s.

2019-11-01 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 added a comment.

> In fact, it might be a good idea to rename `change` to `changeTo` (WDYT?).

I like it. It should combine well with all stencils, not just `text`.

> An alternative, is not to introduce a new combinator at all, and just use 
> Stencils:

I think we are converging on that in another review. Do you plan to pursue this 
patch still?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69184



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


[PATCH] D69184: [libTooling] Introduce general combinator for fixed-value `MatchConsumer`s.

2019-11-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel added a comment.

In D69184#1730523 , @gribozavr2 wrote:

> > In fact, it might be a good idea to rename `change` to `changeTo` (WDYT?).
>
> I like it. It should combine well with all stencils, not just `text`.


Agreed. Will do.

> 
> 
>> An alternative, is not to introduce a new combinator at all, and just use 
>> Stencils:
> 
> I think we are converging on that in another review. Do you plan to pursue 
> this patch still?

Agreed. Let's drop this one.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69184



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


[PATCH] D69651: [CMake] Add cross ARM toolchain CMake cache file.

2019-11-01 Thread Vlad Vereschaka via Phabricator via cfe-commits
vvereschaka updated this revision to Diff 227501.
vvereschaka edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake

Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- /dev/null
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -0,0 +1,109 @@
+# CrossWinToARMLinux.cmake
+#
+# Set up a CMakeCache for a cross Windows to ARM Linux toolchain build.
+#
+# This cache file can be used to build a cross toolchain to ARM Linux
+# on Windows platform.
+#
+# NOTE: the build requires a development ARM Linux root filesystem to use
+# proper target platform depended library and header files.
+#
+# Configure:
+#  cmake -G Ninja ^
+#   -DCMAKE_INSTALL_PREFIX=../install ^
+#   -DDEFAULT_SYSROOT= ^
+#   -DLLVM_AR=/bin/llvm-ar[.exe] ^
+#   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -C/llvm-project/clang/caches/CrossWinToARMLinux.cmake ^
+#   /llvm-project/llvm
+# Build:
+#  cmake --build . --target install
+# Test:
+#  cmake --build . --target check-llvm
+#  cmake --build . --target check-clang
+#  cmake --build . --target check-lld
+
+if (NOT DEFINED DEFAULT_SYSROOT)
+  message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
+endif()
+
+if (DEFINED LLVM_AR)
+  set(CMAKE_AR "${LLVM_AR}" CACHE STRING "")
+endif()
+
+if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
+  set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_C_COMPILER_TARGET)
+  # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
+  set(CMAKE_C_COMPILER_TARGET "armv7-linux-gnueabihf" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+endif()
+
+set(CMAKE_CROSSCOMPILINGON CACHE BOOL "")
+set(CMAKE_CL_SHOWINCLUDES_PREFIX"Note: including file: " CACHE STRING "")
+
+set(LLVM_ENABLE_ASSERTIONS  ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS"clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
+set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
+
+set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
+
+set(COMPILER_RT_BUILD_BUILTINS  ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERSOFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY  OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
+set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+
+set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBUNWIND_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDERON CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
+set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLY 			ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  LTO
+  clang-format
+  builtins
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.

This patch introduces a way to store the symbolic size and its expression.


Repository:
  rC Clang

https://reviews.llvm.org/D69726

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSizeInfo.h
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
  clang/test/Analysis/null-deref-ps-region.c
  clang/test/Analysis/string.c

Index: clang/test/Analysis/string.c
===
--- clang/test/Analysis/string.c
+++ clang/test/Analysis/string.c
@@ -1274,7 +1274,7 @@
 void memset5_char_malloc_overflow_null() {
   char *str = (char *)malloc(10 * sizeof(char));
   memset(str, '\0', 12);
-  clang_analyzer_eval(str[1] == 0); // expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(str[1] == 0); // expected-warning{{TRUE}}
   free(str);
 }
 #endif
@@ -1362,7 +1362,7 @@
   char *str = (char *)malloc(10 * sizeof(int));
   int *array = (int *)str;
   memset(array, 0, 5 * sizeof(int));
-  clang_analyzer_eval(str[10] == '\0');// expected-warning{{UNKNOWN}}
+  clang_analyzer_eval(str[10] == '\0');// expected-warning{{TRUE}}
   clang_analyzer_eval(strlen((char *)array) == 0); // expected-warning{{TRUE}}
   clang_analyzer_eval(strlen(str) == 0);   // expected-warning{{TRUE}}
   free(str);
@@ -1380,7 +1380,7 @@
 int memset21_scalar() {
   int *x = malloc(sizeof(int));
   memset(x, 0, 1);
-  int num = 1 / *x;
+  int num = 1 / *x; // expected-warning{{Division by zero}}
   free(x);
   return num;
 }
@@ -1476,7 +1476,7 @@
 #endif
   clang_analyzer_eval(privkey[0] == '\0');
 #ifdef SUPPRESS_OUT_OF_BOUND
-  // expected-warning@-2 {{UNKNOWN}}
+  // expected-warning@-2 {{TRUE}}
 #endif
   free(privkey);
 }
Index: clang/test/Analysis/null-deref-ps-region.c
===
--- clang/test/Analysis/null-deref-ps-region.c
+++ clang/test/Analysis/null-deref-ps-region.c
@@ -33,7 +33,7 @@
 void bar() {
   int *x = malloc(sizeof(int));
   memset(x, 0, 1);
-  int n = 1 / *x; // no-warning
+  int n = 1 / *x; // expected-warning {{Division by zero}}
   free(x);
 }
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -10,7 +10,6 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
@@ -18,6 +17,8 @@
 #include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -653,16 +654,21 @@
 
 // See if we need to conjure a heap pointer instead of
 // a regular unknown pointer.
-bool IsHeapPointer = false;
-if (const auto *CNE = dyn_cast(E))
-  if (CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
-// FIXME: Delegate this to evalCall in MallocChecker?
-IsHeapPointer = true;
+const auto *CNE = dyn_cast(E);
+if (CNE && CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  // FIXME: Delegate this to evalCall in MallocChecker?
+  DefinedOrUnknownSVal Size = UnknownVal();
+  const Expr *SizeExpr = nullptr;
+
+  if ((SizeExpr = CNE->getArraySize().getValueOr(nullptr))) {
+Size = State->getSVal(SizeExpr, LCtx).castAs();
   }
 
-R = IsHeapPointer ? svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count)
-  : svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy,
- Count);
+  R = svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count);
+  State = setDynamicSize(State, R.getAsRegion(), Size, SizeExpr);
+} else {
+  R = svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy, Count);
+}
   }
   return State->BindExpr(E, LCtx, R);
 }
Index: cl

[PATCH] D69642: [analyzer] DynamicSize: Simplify the assumption creating of sizes

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso abandoned this revision.
Charusso added a comment.

I think we do not need to create assumptions. However, there is a tiny 
difference which continues in D69726 


Repository:
  rC Clang

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

https://reviews.llvm.org/D69642



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added a comment.

I do not want to reverse engineer the `MallocChecker` to obtain the size on 
call basis. The current model without D68725  
makes it enough difficult to obtain the size even with this generic map, but it 
is working fine.




Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1073
+
+setDynamicSize(State, BR, *SizeNL, Size);
 

That dual assumption made changes in the test files, and there is no other dual 
assumption.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69726



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


[PATCH] D69651: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Andrei Lebedev via Phabricator via cfe-commits
andreil99 accepted this revision.
andreil99 added a comment.
This revision is now accepted and ready to land.

Thanks, Vlad! Looks good.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651



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


[PATCH] D69651: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Galina via Phabricator via cfe-commits
gkistanova accepted this revision.
gkistanova added a comment.

LGTM. Thank you!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651



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


[clang] a264e85 - [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Vladimir Vereschaka via cfe-commits

Author: Vladimir Vereschaka
Date: 2019-11-01T12:40:25-07:00
New Revision: a264e85dd9f99391bedc7f069926bdd8d2f44388

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

LOG: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

This cache file can be used to build a cross Windows to ARM Linux
toolchain.

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

Added: 
clang/cmake/caches/CrossWinToARMLinux.cmake

Modified: 


Removed: 




diff  --git a/clang/cmake/caches/CrossWinToARMLinux.cmake 
b/clang/cmake/caches/CrossWinToARMLinux.cmake
new file mode 100644
index ..246f6241f0e2
--- /dev/null
+++ b/clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -0,0 +1,109 @@
+# CrossWinToARMLinux.cmake
+#
+# Set up a CMakeCache for a cross Windows to ARM Linux toolchain build.
+#
+# This cache file can be used to build a cross toolchain to ARM Linux
+# on Windows platform.
+#
+# NOTE: the build requires a development ARM Linux root filesystem to use
+# proper target platform depended library and header files.
+#
+# Configure:
+#  cmake -G Ninja ^
+#   -DCMAKE_INSTALL_PREFIX=../install ^
+#   -DDEFAULT_SYSROOT= ^
+#   -DLLVM_AR=/bin/llvm-ar[.exe] ^
+#   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -C/llvm-project/clang/caches/CrossWinToARMLinux.cmake ^
+#   /llvm-project/llvm
+# Build:
+#  cmake --build . --target install
+# Test:
+#  cmake --build . --target check-llvm
+#  cmake --build . --target check-clang
+#  cmake --build . --target check-lld
+
+if (NOT DEFINED DEFAULT_SYSROOT)
+  message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain 
build.")
+endif()
+
+if (DEFINED LLVM_AR)
+  set(CMAKE_AR "${LLVM_AR}" CACHE STRING "")
+endif()
+
+if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
+  set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_C_COMPILER_TARGET)
+  # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
+  set(CMAKE_C_COMPILER_TARGET "armv7-linux-gnueabihf" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+endif()
+
+set(CMAKE_CROSSCOMPILINGON CACHE BOOL "")
+set(CMAKE_CL_SHOWINCLUDES_PREFIX"Note: including file: " CACHE 
STRING "")
+
+set(LLVM_ENABLE_ASSERTIONS  ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS"clang;clang-tools-extra;lld" 
CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES
"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
+set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE 
STRING "" FORCE)
+
+set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
+
+set(COMPILER_RT_BUILD_BUILTINS  ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERSOFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY  OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
+set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+
+set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LIBUNWIND_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING 
"")
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDERON CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING 
"")
+
+set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
+set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE 
STRING "")
+set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING 
"")
+
+set(BUILTINS_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(RUNTIMES_CMAKE_ARGS 
"-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLYON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTI

[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso created this revision.
Charusso added a reviewer: NoQ.
Charusso added a project: clang.
Herald added subscribers: cfe-commits, dkrupp, donat.nagy, Szelethus, 
mikhail.ramalho, a.sidorin, szepet, baloghadamsoftware, xazax.hun.
Charusso added a parent revision: D69726: [analyzer] DynamicSize: Store the 
dynamic size.

This patch hooks the `Preprocessor` trough `BugReporter` to the
`CheckerContext` so the checkers could look for macro definitions.


Repository:
  rC Clang

https://reviews.llvm.org/D69731

Files:
  clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
  clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
  clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
  clang/unittests/StaticAnalyzer/Reusables.h

Index: clang/unittests/StaticAnalyzer/Reusables.h
===
--- clang/unittests/StaticAnalyzer/Reusables.h
+++ clang/unittests/StaticAnalyzer/Reusables.h
@@ -58,7 +58,7 @@
   ExprEngineConsumer(CompilerInstance &C)
   : C(C), ChkMgr(C.getASTContext(), *C.getAnalyzerOpts()), CTU(C),
 Consumers(),
-AMgr(C.getASTContext(), Consumers,
+AMgr(C.getASTContext(), C.getPreprocessor(), Consumers,
  CreateRegionStoreManager, CreateRangeConstraintManager, &ChkMgr,
  *C.getAnalyzerOpts()),
 VisitedCallees(), FS(),
Index: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
===
--- clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
+++ clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
@@ -192,7 +192,7 @@
 
 public:
   ASTContext *Ctx;
-  const Preprocessor &PP;
+  Preprocessor &PP;
   const std::string OutDir;
   AnalyzerOptionsRef Opts;
   ArrayRef Plugins;
@@ -335,8 +335,8 @@
 checkerMgr = createCheckerManager(
 *Ctx, *Opts, Plugins, CheckerRegistrationFns, PP.getDiagnostics());
 
-Mgr = std::make_unique(*Ctx, PathConsumers, CreateStoreMgr,
-CreateConstraintMgr,
+Mgr = std::make_unique(*Ctx, PP, PathConsumers,
+CreateStoreMgr, CreateConstraintMgr,
 checkerMgr.get(), *Opts, Injector);
   }
 
Index: clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
===
--- clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
+++ clang/lib/StaticAnalyzer/Core/AnalysisManager.cpp
@@ -13,7 +13,7 @@
 
 void AnalysisManager::anchor() { }
 
-AnalysisManager::AnalysisManager(ASTContext &ASTCtx,
+AnalysisManager::AnalysisManager(ASTContext &ASTCtx, Preprocessor &PP,
  const PathDiagnosticConsumers &PDC,
  StoreManagerCreator storemgr,
  ConstraintManagerCreator constraintmgr,
@@ -38,7 +38,7 @@
   Options.ShouldElideConstructors,
   /*addVirtualBaseBranches=*/true,
   injector),
-  Ctx(ASTCtx), LangOpts(ASTCtx.getLangOpts()),
+  Ctx(ASTCtx), PP(PP), LangOpts(ASTCtx.getLangOpts()),
   PathConsumers(PDC), CreateStoreMgr(storemgr),
   CreateConstraintMgr(constraintmgr), CheckerMgr(checkerMgr),
   options(Options) {
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h
@@ -107,6 +107,10 @@
 return getBugReporter().getSourceManager();
   }
 
+  const Preprocessor &getPreprocessor() {
+return getBugReporter().getPreprocessor();
+  }
+
   SValBuilder &getSValBuilder() {
 return Eng.getSValBuilder();
   }
Index: clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
===
--- clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
+++ clang/include/clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h
@@ -16,6 +16,7 @@
 
 #include "clang/Analysis/AnalysisDeclContext.h"
 #include "clang/Analysis/PathDiagnostic.h"
+#include "clang/Lex/Preprocessor.h"
 #include "clang/StaticAnalyzer/Core/AnalyzerOptions.h"
 #include "clang/StaticAnalyzer/Core/BugReporter/BugReporter.h"
 #include "clang/StaticAnalyzer/Core/PathDiagnosticConsumers.h"
@@ -32,6 +33,7 @@
   AnalysisDeclContextManager AnaCtxMgr;
 
   ASTContext &Ctx;
+  Preprocessor &PP;
   const LangOptions &LangOpts;
   PathDiagnosticConsumers PathConsumers;
 
@@ -44,7 +46,7 @@
 public:
   AnalyzerOptions &options;
 
-  AnalysisManager(ASTContext &ctx,
+  AnalysisManager(ASTContext &ctx, Preprocessor &PP,
   const PathDiagnosticConsumer

[PATCH] D69651: [CMake] Add cross Windows to ARM Linux toolchain CMake cache file.

2019-11-01 Thread Vlad Vereschaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGa264e85dd9f9: [CMake] Add cross Windows to ARM Linux 
toolchain CMake cache file. (authored by vvereschaka).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69651

Files:
  clang/cmake/caches/CrossWinToARMLinux.cmake

Index: clang/cmake/caches/CrossWinToARMLinux.cmake
===
--- /dev/null
+++ clang/cmake/caches/CrossWinToARMLinux.cmake
@@ -0,0 +1,109 @@
+# CrossWinToARMLinux.cmake
+#
+# Set up a CMakeCache for a cross Windows to ARM Linux toolchain build.
+#
+# This cache file can be used to build a cross toolchain to ARM Linux
+# on Windows platform.
+#
+# NOTE: the build requires a development ARM Linux root filesystem to use
+# proper target platform depended library and header files.
+#
+# Configure:
+#  cmake -G Ninja ^
+#   -DCMAKE_INSTALL_PREFIX=../install ^
+#   -DDEFAULT_SYSROOT= ^
+#   -DLLVM_AR=/bin/llvm-ar[.exe] ^
+#   -DCMAKE_CXX_FLAGS="-D__OPTIMIZE__" ^
+#   -C/llvm-project/clang/caches/CrossWinToARMLinux.cmake ^
+#   /llvm-project/llvm
+# Build:
+#  cmake --build . --target install
+# Test:
+#  cmake --build . --target check-llvm
+#  cmake --build . --target check-clang
+#  cmake --build . --target check-lld
+
+if (NOT DEFINED DEFAULT_SYSROOT)
+  message(WARNING "DEFAULT_SYSROOT must be specified for the cross toolchain build.")
+endif()
+
+if (DEFINED LLVM_AR)
+  set(CMAKE_AR "${LLVM_AR}" CACHE STRING "")
+endif()
+
+if (NOT DEFINED LLVM_TARGETS_TO_BUILD)
+  set(LLVM_TARGETS_TO_BUILD "ARM" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_C_COMPILER_TARGET)
+  # Required if COMPILER_RT_DEFAULT_TARGET_ONLY is ON
+  set(CMAKE_C_COMPILER_TARGET "armv7-linux-gnueabihf" CACHE STRING "")
+endif()
+
+if (NOT DEFINED CMAKE_BUILD_TYPE)
+  set(CMAKE_BUILD_TYPE "Release" CACHE STRING "")
+endif()
+
+set(CMAKE_CROSSCOMPILINGON CACHE BOOL "")
+set(CMAKE_CL_SHOWINCLUDES_PREFIX"Note: including file: " CACHE STRING "")
+
+set(LLVM_ENABLE_ASSERTIONS  ON CACHE BOOL "")
+set(LLVM_ENABLE_PROJECTS"clang;clang-tools-extra;lld" CACHE STRING "")
+set(LLVM_ENABLE_RUNTIMES"compiler-rt;libunwind;libcxxabi;libcxx" CACHE STRING "")
+set(LLVM_DEFAULT_TARGET_TRIPLE  "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_TARGET_ARCH"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LLVM_LIT_ARGS   "-vv ${LLVM_LIT_ARGS}" CACHE STRING "" FORCE)
+
+set(CLANG_DEFAULT_LINKER"lld" CACHE STRING "")
+
+set(COMPILER_RT_BUILD_BUILTINS  ON CACHE BOOL "")
+set(COMPILER_RT_BUILD_SANITIZERSOFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_XRAY  OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_LIBFUZZER OFF CACHE BOOL "")
+set(COMPILER_RT_BUILD_PROFILE   OFF CACHE BOOL "")
+set(COMPILER_RT_DEFAULT_TARGET_ONLY ON CACHE BOOL "")
+
+set(LIBUNWIND_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBUNWIND_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBUNWIND_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
+
+set(LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_STATIC_UNWINDERON CACHE BOOL "")
+set(LIBCXXABI_USE_COMPILER_RT   ON CACHE BOOL "")
+set(LIBCXXABI_ENABLE_NEW_DELETE_DEFINITIONS OFF CACHE BOOL "")
+set(LIBCXXABI_TARGET_TRIPLE "${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXXABI_SYSROOT   "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(LIBCXX_USE_COMPILER_RT  ON CACHE BOOL "")
+set(LIBCXX_TARGET_TRIPLE"${CMAKE_C_COMPILER_TARGET}" CACHE STRING "")
+set(LIBCXX_SYSROOT  "${DEFAULT_SYSROOT}" CACHE STRING "")
+
+set(BUILTINS_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+set(RUNTIMES_CMAKE_ARGS "-DCMAKE_SYSTEM_NAME=Linux;-DCMAKE_AR=${CMAKE_AR}" CACHE STRING "")
+
+set(LLVM_INSTALL_TOOLCHAIN_ONLY 			ON CACHE BOOL "")
+set(LLVM_TOOLCHAIN_TOOLS
+  llvm-ar
+  llvm-cov
+  llvm-cxxfilt
+  llvm-dwarfdump
+  llvm-lib
+  llvm-nm
+  llvm-objdump
+  llvm-profdata
+  llvm-ranlib
+  llvm-readobj
+  llvm-size
+  llvm-symbolizer
+  CACHE STRING "")
+
+set(LLVM_DISTRIBUTION_COMPONENTS
+  clang
+  lld
+  LTO
+  clang-format
+  builtins
+  runtimes
+  ${LLVM_TOOLCHAIN_TOOLS}
+  CACHE STRING "")
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69716: NeonEmitter: remove special 'a' modifier.

2019-11-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69716



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso marked an inline comment as done.
Charusso added a comment.

It is needed for my work, and also I have seen other checkers in need of that.




Comment at: clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp:195
   ASTContext *Ctx;
-  const Preprocessor &PP;
   const std::string OutDir;

I have dropped the `const` because the methods of `Preprocessor` are non-const 
because of the `BumpPtrAllocator`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

> This is the first step to mitigate that issue.

What's the issue?




Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:37-39
+  const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size);
+  if (!SizeInt)
+return UnknownVal();

Even if the size is not concrete, you can ask `SValBuilder` to perform the 
division. It's going to be a symbolic expression which we won't be able to work 
with anyway, but these days we believe that it's still worth it, in hope that 
our constraint solver eventually gets better.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69599



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


[PATCH] D69662: [Checkers] Avoid using evalCall in StreamChecker.

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

But why?




Comment at: clang/lib/StaticAnalyzer/Checkers/StreamChecker.cpp:161
   .castAs();
   state = state->BindExpr(CE, C.getLocationContext(), RetVal);
 

You're not allowed to do this in `checkPostCall` because other post-call 
checkers may have already read the return value.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69662



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


[PATCH] D69732: [WIP][LTO] Apply SamplePGO pipeline tunes for ThinLTO pre-link to full LTO

2019-11-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson created this revision.
tejohnson added reviewers: wristow, ormris.
Herald added subscribers: llvm-commits, cfe-commits, dexonsmith, steven_wu, 
hiraditya, inglorion, mehdi_amini.
Herald added projects: clang, LLVM.

There are several modifications to the optimizations performed by the
ThinLTO pre link compile when building with Sample PGO, in order to get
better matching of the SamplePGO when it is re-applied in the backend.
These same tunes should be done for full LTO pre-links as well, as
presumably the same matching issues could occur there.

There are a few issues with this patch as it stands, relating to the
fact that not all of these optimizations are attempted again in the full
LTO backend, owing to the larger compile time with the monolithic LTO.
Specifically, this includes some loop optimizations:

- In the old PM, LoopUnrollAndJam is not done in the full LTO backend.
- In the new PM, none of the loop unrolling is done in the full LTO

backend. The comments indicate that this is in part due to issues with
the new PM loop pass manager (presumably sorted out by now, but I
haven't followed this). Here is the comment:

  // FIXME: at this point, we run a bunch of loop passes:
  // indVarSimplify, loopDeletion, loopInterchange, loopUnroll,
  // loopVectorize. Enable them once the remaining issue with LPM
  // are sorted out.

So what needs to happen still is to either:

1. Continue to diverge the ThinLTO and full LTO pre-link pipelines for

these optimizations (which means this patch needs to be adjusted).
OR

2. Fix the full LTO post-link pipelines to ensure these optimizations

all occur there.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69732

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  clang/test/CodeGen/pgo-sample-thinlto-summary.c
  llvm/include/llvm/Passes/PassBuilder.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Transforms/IPO/PassManagerBuilder.cpp

Index: llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
===
--- llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
+++ llvm/lib/Transforms/IPO/PassManagerBuilder.cpp
@@ -498,12 +498,12 @@
 MPM.add(createPGOIndirectCallPromotionLegacyPass(/*InLTO = */ true,
  !PGOSampleUse.empty()));
 
-  // For SamplePGO in ThinLTO compile phase, we do not want to unroll loops
+  // For SamplePGO in the *LTO compile phase, we do not want to unroll loops
   // as it will change the CFG too much to make the 2nd profile annotation
   // in backend more difficult.
-  bool PrepareForThinLTOUsingPGOSampleProfile =
-  PrepareForThinLTO && !PGOSampleUse.empty();
-  if (PrepareForThinLTOUsingPGOSampleProfile)
+  bool PrepareForLTOUsingPGOSampleProfile =
+  (PrepareForThinLTO || PrepareForLTO) && !PGOSampleUse.empty();
+  if (PrepareForLTOUsingPGOSampleProfile)
 DisableUnrollLoops = true;
 
   // Infer attributes about declarations if possible.
@@ -530,12 +530,12 @@
   addExtensionsToPM(EP_Peephole, MPM);
   MPM.add(createCFGSimplificationPass()); // Clean up after IPCP & DAE
 
-  // For SamplePGO in ThinLTO compile phase, we do not want to do indirect
+  // For SamplePGO in the *LTO compile phase, we do not want to do indirect
   // call promotion as it will change the CFG too much to make the 2nd
   // profile annotation in backend more difficult.
-  // PGO instrumentation is added during the compile phase for ThinLTO, do
+  // PGO instrumentation is added during the compile phase for *LTO, do
   // not run it a second time
-  if (DefaultOrPreLinkPipeline && !PrepareForThinLTOUsingPGOSampleProfile)
+  if (DefaultOrPreLinkPipeline && !PrepareForLTOUsingPGOSampleProfile)
 addPGOInstrPasses(MPM);
 
   // Create profile COMDAT variables. Lld linker wants to see all variables
Index: llvm/lib/Passes/PassBuilder.cpp
===
--- llvm/lib/Passes/PassBuilder.cpp
+++ llvm/lib/Passes/PassBuilder.cpp
@@ -383,10 +383,8 @@
 C(LAM);
 }
 
-FunctionPassManager
-PassBuilder::buildFunctionSimplificationPipeline(OptimizationLevel Level,
- ThinLTOPhase Phase,
- bool DebugLogging) {
+FunctionPassManager PassBuilder::buildFunctionSimplificationPipeline(
+OptimizationLevel Level, LTOPhase Phase, bool DebugLogging) {
   assert(Level != O0 && "Must request optimizations!");
   FunctionPassManager FPM(DebugLogging);
 
@@ -465,10 +463,10 @@
 C(LPM2, Level);
 
   LPM2.addPass(LoopDeletionPass());
-  // Do not enable unrolling in PreLinkThinLTO phase during sample PGO
+  // Do not enable unrolling in PreLink LTO phase during sample PGO
   // because it changes IR to makes profile annotation in back compile
   // inaccurate.
-  if ((Phase != ThinLTOPhase::PreLink || !PGOOpt ||
+  if ((Phase != LTOPhase::PreLink || !PGOOpt ||
PGOOpt->Action != PGOOptions::SampleUse) &&
 

[PATCH] D69715: NeonEmitter: change Type representation. NFC.

2019-11-01 Thread Eli Friedman via Phabricator via cfe-commits
efriedma accepted this revision.
efriedma added a comment.
This revision is now accepted and ready to land.

I guess the extra checks are due to existing code "accidentally" doing the 
right thing?

Have you verified this is NFC in terms of the generated arm_neon.h etc?

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69715



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


[PATCH] D69732: [WIP][LTO] Apply SamplePGO pipeline tunes for ThinLTO pre-link to full LTO

2019-11-01 Thread Teresa Johnson via Phabricator via cfe-commits
tejohnson added a comment.

This probably needs to be taken over by someone who cares about full LTO 
performance (@wristow or @ormris ?). This patch was some cleanup of the full 
LTO sample PGO pipeline, but has a number of issues I enumerate in the summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69732



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h:29-31
+/// \returns The stored dynamic size expression for the region \p MR.
+const Expr *getDynamicSizeExpr(ProgramStateRef State, const MemRegion *MR);
+

Why do we need this?



Comment at: clang/lib/StaticAnalyzer/Checkers/CStringChecker.cpp:1073
+
+setDynamicSize(State, BR, *SizeNL, Size);
 

Charusso wrote:
> That dual assumption made changes in the test files, and there is no other 
> dual assumption.
Wait, this code should not have been changed. It's not an allocation site, we 
don't receive any new information about the size of the region here.



Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:180
-  // Assume should not fail at this point.
-  assert(state);
 

This gets rid of the assertion failure in 
https://bugs.llvm.org/show_bug.cgi?id=28450 by implementing my suggestion (2). 
Yay.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69726



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


[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

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



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:133
+
+llvm::ConstrainedFPIntrinsic::ExceptionBehavior
+CodeGenFunction::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) {

mibintc wrote:
> I added these 2 functions, is this what you have in mind or do you want me to 
> write them differently?
Slightly differently, yes, please.

```
static llvm::ConstrainedFPIntrinsic::ExceptionBehavior 
getConstrainedExceptionBehavior(LangOptions;:FPExceptionModeKind kind) {
  switch (kind) {
  case LangOptions::FPE_Ignore:
return llvm::ConstrainedFPIntrinsic::ebIgnore;
  // ...rest of cases here...
  // no default: should be exhaustive over the enum
  }
  llvm_unreachable("bad kind");
}
```


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[clang] 52ea308 - [NFC]: Removed an implicit capture argument from lambda.

2019-11-01 Thread Sourabh Singh Tomar via cfe-commits

Author: Sourabh Singh Tomar
Date: 2019-11-02T01:37:46+05:30
New Revision: 52ea308f705af0a8f5d55e036a64fd2b5e4c2ee6

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

LOG: [NFC]: Removed an implicit capture argument from lambda.

Added: 


Modified: 
clang/lib/CodeGen/CGDebugInfo.cpp

Removed: 




diff  --git a/clang/lib/CodeGen/CGDebugInfo.cpp 
b/clang/lib/CodeGen/CGDebugInfo.cpp
index d2d9e8e59119..38750d7d3369 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1608,7 +1608,7 @@ llvm::DISubprogram *CGDebugInfo::CreateCXXMemberFunction(
 
   // We're checking for deleted C++ special member functions
   // [Ctors,Dtors, Copy/Move]
-  auto checkAttrDeleted = [&SPFlags](const auto *Method) {
+  auto checkAttrDeleted = [&](const auto *Method) {
 if (Method->getCanonicalDecl()->isDeleted())
   SPFlags |= llvm::DISubprogram::SPFlagDeleted;
   };



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Also path-insensitive checkers will probably benefit a lot more from this info.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

We probably need this because every time we try to deal with macros we struggle 
quite a bit.

I'm not sure though - because we somehow survived without this for like 10 
years. Eg. `BugReporterVisitors.cpp`:

  250 static bool isFunctionMacroExpansion(SourceLocation Loc,
  251 const SourceManager &SM) {
  252   if (!Loc.isMacroID())
  253 return false;
  254   while (SM.isMacroArgExpansion(Loc))
  255 Loc = SM.getImmediateExpansionRange(Loc).getBegin();
  256   std::pair TLInfo = SM.getDecomposedLoc(Loc);
  257   SrcMgr::SLocEntry SE = SM.getSLocEntry(TLInfo.first);
  258   const SrcMgr::ExpansionInfo &EInfo = SE.getExpansion();
  259   return EInfo.isFunctionMacroExpansion();
  260 }

I'd love to see some actual use before committing.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D62686: [RISCV] Add support for save/restore of callee-saved registers via libcalls

2019-11-01 Thread Lewis Revill via Phabricator via cfe-commits
lewis-revill updated this revision to Diff 227512.
lewis-revill added a comment.
Herald added a subscriber: sameer.abuasal.

Rebased and merged D68644  into this patch - 
this patch already assumes shrink wrapping support anyway.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62686

Files:
  clang/lib/Driver/ToolChains/Arch/RISCV.cpp
  clang/test/Driver/riscv-features.c
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
  llvm/lib/Target/RISCV/RISCVFrameLowering.h
  llvm/lib/Target/RISCV/RISCVMachineFunctionInfo.h
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.h
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/saverestore.ll
  llvm/test/CodeGen/RISCV/shrinkwrap.ll

Index: llvm/test/CodeGen/RISCV/shrinkwrap.ll
===
--- llvm/test/CodeGen/RISCV/shrinkwrap.ll
+++ llvm/test/CodeGen/RISCV/shrinkwrap.ll
@@ -1,6 +1,8 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
 ; RUN: llc -mtriple riscv32 < %s | FileCheck %s -check-prefix=RV32I-NOSW
 ; RUN: llc -mtriple riscv32 -enable-shrink-wrap < %s | FileCheck %s -check-prefix=RV32I-SW
+; RUN: llc -mtriple riscv32 -enable-shrink-wrap -mattr=+save-restore < %s \
+; RUN: | FileCheck %s -check-prefix=RV32I-SW-SR
 
 
 declare void @abort()
@@ -29,6 +31,16 @@
 ; RV32I-SW-NEXT:addi sp, sp, -16
 ; RV32I-SW-NEXT:sw ra, 12(sp)
 ; RV32I-SW-NEXT:call abort
+;
+; RV32I-SW-SR-LABEL: eliminate_restore:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bgeu a1, a0, .LBB0_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.end
+; RV32I-SW-SR-NEXT:ret
+; RV32I-SW-SR-NEXT:  .LBB0_2: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_0
+; RV32I-SW-SR-NEXT:call abort
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
@@ -84,6 +96,23 @@
 ; RV32I-SW-NEXT:addi sp, sp, 16
 ; RV32I-SW-NEXT:  .LBB1_2: # %if.end
 ; RV32I-SW-NEXT:ret
+;
+; RV32I-SW-SR-LABEL: conditional_alloca:
+; RV32I-SW-SR:   # %bb.0:
+; RV32I-SW-SR-NEXT:addi a1, zero, 32
+; RV32I-SW-SR-NEXT:bltu a1, a0, .LBB1_2
+; RV32I-SW-SR-NEXT:  # %bb.1: # %if.then
+; RV32I-SW-SR-NEXT:call t0, __riscv_save_1
+; RV32I-SW-SR-NEXT:addi s0, sp, 16
+; RV32I-SW-SR-NEXT:addi a0, a0, 15
+; RV32I-SW-SR-NEXT:andi a0, a0, -16
+; RV32I-SW-SR-NEXT:sub a0, sp, a0
+; RV32I-SW-SR-NEXT:mv sp, a0
+; RV32I-SW-SR-NEXT:call notdead
+; RV32I-SW-SR-NEXT:addi sp, s0, -16
+; RV32I-SW-SR-NEXT:tail __riscv_restore_1
+; RV32I-SW-SR-NEXT:  .LBB1_2: # %if.end
+; RV32I-SW-SR-NEXT:ret
   %cmp = icmp ule i32 %n, 32
   br i1 %cmp, label %if.then, label %if.end
 
Index: llvm/test/CodeGen/RISCV/saverestore.ll
===
--- /dev/null
+++ llvm/test/CodeGen/RISCV/saverestore.ll
@@ -0,0 +1,299 @@
+; RUN: llc -mtriple=riscv32 < %s | FileCheck %s -check-prefix=RV32I
+; RUN: llc -mtriple=riscv64 < %s | FileCheck %s -check-prefix=RV64I
+; RUN: llc -mtriple=riscv32 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV32I-SR
+; RUN: llc -mtriple=riscv64 -mattr=+save-restore < %s | FileCheck %s -check-prefix=RV64I-SR
+; RUN: llc -mtriple=riscv32 -mattr=+f,+save-restore -target-abi=ilp32f < %s | FileCheck %s -check-prefix=RV32I-FP-SR
+; RUN: llc -mtriple=riscv64 -mattr=+f,+d,+save-restore -target-abi=lp64d < %s | FileCheck %s -check-prefix=RV64I-FP-SR
+
+; Check that the correct save/restore libcalls are generated.
+
+@var0 = global [18 x i32] zeroinitializer
+@var1 = global [24 x i32] zeroinitializer
+@var2 = global [30 x i32] zeroinitializer
+
+define void @callee_saved0() nounwind {
+; RV32I-LABEL: callee_saved0:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved0:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail __riscv_restore
+;
+; RV32I-SR-LABEL: callee_saved0:
+; RV32I-SR: call t0, __riscv_save_5
+; RV32I-SR: tail __riscv_restore_5
+;
+; RV64I-SR-LABEL: callee_saved0:
+; RV64I-SR: call t0, __riscv_save_5
+; RV64I-SR: tail __riscv_restore_5
+;
+; RV32I-FP-SR-LABEL: callee_saved0:
+; RV32I-FP-SR: call t0, __riscv_save_5
+; RV32I-FP-SR: tail __riscv_restore_5
+;
+; RV64I-FP-SR-LABEL: callee_saved0:
+; RV64I-FP-SR: call t0, __riscv_save_5
+; RV64I-FP-SR: tail __riscv_restore_5
+  %val = load [18 x i32], [18 x i32]* @var0
+  store volatile [18 x i32] %val, [18 x i32]* @var0
+  ret void
+}
+
+define void @callee_saved1() nounwind {
+; RV32I-LABEL: callee_saved1:
+; RV32I-NOT: call t0, __riscv_save
+; RV32I-NOT: tail __riscv_restore
+;
+; RV64I-LABEL: callee_saved1:
+; RV64I-NOT: call t0, __riscv_save
+; RV64I-NOT: tail __riscv_res

[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227524.
Charusso marked 2 inline comments as done.
Charusso added a comment.

- Fix.


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

https://reviews.llvm.org/D69599

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -622,15 +622,6 @@
   StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx,
   SymbolReaper& SymReaper) override;
 
-  //===--===//
-  // Region "extents".
-  //===--===//
-
-  // FIXME: This method will soon be eliminated; see the note in Store.h.
-  DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion* R,
- QualType EleTy) override;
-
   //===--===//
   // Utility methods.
   //===--===//
@@ -1387,37 +1378,6 @@
   return StoreRef(B.asStore(), *this);
 }
 
-//===--===//
-// Extents for regions.
-//===--===//
-
-DefinedOrUnknownSVal
-RegionStoreManager::getSizeInElements(ProgramStateRef state,
-  const MemRegion *R,
-  QualType EleTy) {
-  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
-  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
-  if (!SizeInt)
-return UnknownVal();
-
-  CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
-
-  if (Ctx.getAsVariableArrayType(EleTy)) {
-// FIXME: We need to track extra state to properly record the size
-// of VLAs.  Returning UnknownVal here, however, is a stop-gap so that
-// we don't have a divide-by-zero below.
-return UnknownVal();
-  }
-
-  CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
-
-  // If a variable is reinterpreted as a type that doesn't fit into a larger
-  // type evenly, round it down.
-  // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize,
-svalBuilder.getArrayIndexType());
-}
-
 //===--===//
 // Location and region casting.
 //===--===//
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
+++ clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -26,5 +27,37 @@
   return MR->getMemRegionManager().getStaticSize(MR, SVB);
 }
 
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder &SVB,
+QualType ElementTy) {
+  MemRegionManager &MemMgr = MR->getMemRegionManager();
+  ASTContext &Ctx = MemMgr.getContext();
+
+  CharUnits ElementSize = Ctx.getTypeSizeInChars(ElementTy);
+  DefinedOrUnknownSVal Size = getDynamicSize(State, MR, SVB);
+
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.
+return SVB.makeIntVal(RegionSize / ElementSize, SVB.getArrayIndexType());
+  }
+
+  // Try to rely on the 'SValBuilder'.
+  SVal ElementSizeV = SVB.makeIntVal(
+  llvm::APS

[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69599#1730707 , @NoQ wrote:

> > This is the first step to mitigate that issue.
>
> What's the issue?


Well, after I mentioned an issue I have realized the somewhat path-insensitive 
`getSizeInElements()` does not touch the (void *) return value. Basically the 
expression `int *foo = malloc()` could not compile, and I had felt that the 
assumptions about the overflow are wrong. Now I see that none of the overflow 
tests would compile, so I think we just bypass a cast here-and-there. Therefore 
there is no issue, just I was surprised.




Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:37-39
+  const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size);
+  if (!SizeInt)
+return UnknownVal();

NoQ wrote:
> Even if the size is not concrete, you can ask `SValBuilder` to perform the 
> division. It's going to be a symbolic expression which we won't be able to 
> work with anyway, but these days we believe that it's still worth it, in hope 
> that our constraint solver eventually gets better.
Good idea, thanks!


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

https://reviews.llvm.org/D69599



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


[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 227527.
mibintc added a comment.

Recoded ToConstrainedRoundingMD and ToConstrainedExceptionMD as requested by 
@rjmccall


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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fast-math.c
  clang/test/Driver/fp-model.c
  llvm/include/llvm/Target/TargetOptions.h

Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -107,7 +107,7 @@
   public:
 TargetOptions()
 : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
-  NoNaNsFPMath(false), NoTrappingFPMath(false),
+  NoNaNsFPMath(false), NoTrappingFPMath(true),
   NoSignedZerosFPMath(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
Index: clang/test/Driver/fp-model.c
===
--- /dev/null
+++ clang/test/Driver/fp-model.c
@@ -0,0 +1,130 @@
+// Test that incompatible combinations of -ffp-model= options
+// and other floating point options get a warning diagnostic.
+//
+// REQUIRES: clang-driver
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN %s
+// WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN1 %s
+// WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN2 %s
+// WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN3 %s
+// WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN4 %s
+// WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN5 %s
+// WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN7 %s
+// WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN8 %s
+// WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN9 %s
+// WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNa %s
+// WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNb %s
+// WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNc %s
+// WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNd %s
+// WARNd: warning: overriding '-ffp-model=strict' option with '-freciprocal-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -funsafe-math-optimizations -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WA

[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

And then remove the manual division.


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

https://reviews.llvm.org/D69599



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


[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

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



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:137
+  llvm_unreachable("Unsupported FP Exception Behavior");
+}
+

Sorry for dragging this out, but is there a reason these need to be member 
functions on `CodeGenFunction` rather than just `static` functions in this file?


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

https://reviews.llvm.org/D62731



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


[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc updated this revision to Diff 227532.
mibintc added a comment.

Made a couple functions static per @rjmccall request


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731

Files:
  clang/docs/UsersManual.rst
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangOptions.h
  clang/include/clang/Driver/Options.td
  clang/lib/CodeGen/CodeGenFunction.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/fpconstrained.c
  clang/test/Driver/clang_f_opts.c
  clang/test/Driver/fast-math.c
  clang/test/Driver/fp-model.c
  llvm/include/llvm/Target/TargetOptions.h

Index: llvm/include/llvm/Target/TargetOptions.h
===
--- llvm/include/llvm/Target/TargetOptions.h
+++ llvm/include/llvm/Target/TargetOptions.h
@@ -107,7 +107,7 @@
   public:
 TargetOptions()
 : PrintMachineCode(false), UnsafeFPMath(false), NoInfsFPMath(false),
-  NoNaNsFPMath(false), NoTrappingFPMath(false),
+  NoNaNsFPMath(false), NoTrappingFPMath(true),
   NoSignedZerosFPMath(false),
   HonorSignDependentRoundingFPMathOption(false), NoZerosInBSS(false),
   GuaranteedTailCallOpt(false), StackSymbolOrdering(true),
Index: clang/test/Driver/fp-model.c
===
--- /dev/null
+++ clang/test/Driver/fp-model.c
@@ -0,0 +1,130 @@
+// Test that incompatible combinations of -ffp-model= options
+// and other floating point options get a warning diagnostic.
+//
+// REQUIRES: clang-driver
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN %s
+// WARN: warning: overriding '-ffp-model=fast' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=fast -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN1 %s
+// WARN1: warning: overriding '-ffp-model=fast' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fassociative-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN2 %s
+// WARN2: warning: overriding '-ffp-model=strict' option with '-fassociative-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffast-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN3 %s
+// WARN3: warning: overriding '-ffp-model=strict' option with '-ffast-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffinite-math-only -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN4 %s
+// WARN4: warning: overriding '-ffp-model=strict' option with '-ffinite-math-only' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=fast -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN5 %s
+// WARN5: warning: overriding '-ffp-model=strict' option with '-ffp-contract=fast' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=off -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN6 %s
+// WARN6: warning: overriding '-ffp-model=strict' option with '-ffp-contract=off' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -ffp-contract=on -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN7 %s
+// WARN7: warning: overriding '-ffp-model=strict' option with '-ffp-contract=on' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-infinities -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN8 %s
+// WARN8: warning: overriding '-ffp-model=strict' option with '-fno-honor-infinities' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-honor-nans -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARN9 %s
+// WARN9: warning: overriding '-ffp-model=strict' option with '-fno-honor-nans' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-rounding-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNa %s
+// WARNa: warning: overriding '-ffp-model=strict' option with '-fno-rounding-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-signed-zeros -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNb %s
+// WARNb: warning: overriding '-ffp-model=strict' option with '-fno-signed-zeros' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -fno-trapping-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNc %s
+// WARNc: warning: overriding '-ffp-model=strict' option with '-fno-trapping-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -freciprocal-math -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNd %s
+// WARNd: warning: overriding '-ffp-model=strict' option with '-freciprocal-math' [-Woverriding-t-option]
+
+// RUN: %clang -### -ffp-model=strict -funsafe-math-optimizations -c %s 2>&1 \
+// RUN:   | FileCheck --check-prefix=WARNe %s
+// W

[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

NoQ wrote:
> And then remove the manual division.
Hmpf.

```
Failing Tests (7):
Clang :: Analysis/misc-ps-region-store.m
Clang :: Analysis/mpichecker.cpp
Clang :: Analysis/outofbound.c
Clang :: Analysis/rdar-6541136-region.c
Clang :: Analysis/return-ptr-range.cpp
Clang :: Analysis/track-control-dependency-conditions.cpp
Clang :: Analysis/uninit-vals.c
```

I would pick that solution because it may be a tiny-bit faster, and then later 
on investigate this issue when we model more about dynamic sizes.


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

https://reviews.llvm.org/D69599



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


[PATCH] D62731: Add support for options -frounding-math, ftrapping-math, -fp-model=, and -fp-exception-behavior=, : Specify floating point behavior

2019-11-01 Thread Melanie Blower via Phabricator via cfe-commits
mibintc marked an inline comment as done.
mibintc added inline comments.



Comment at: clang/lib/CodeGen/CodeGenFunction.cpp:133
+
+llvm::ConstrainedFPIntrinsic::ExceptionBehavior
+CodeGenFunction::ToConstrainedExceptMD(LangOptions::FPExceptionModeKind Kind) {

rjmccall wrote:
> mibintc wrote:
> > I added these 2 functions, is this what you have in mind or do you want me 
> > to write them differently?
> Slightly differently, yes, please.
> 
> ```
> static llvm::ConstrainedFPIntrinsic::ExceptionBehavior 
> getConstrainedExceptionBehavior(LangOptions;:FPExceptionModeKind kind) {
>   switch (kind) {
>   case LangOptions::FPE_Ignore:
> return llvm::ConstrainedFPIntrinsic::ebIgnore;
>   // ...rest of cases here...
>   // no default: should be exhaustive over the enum
>   }
>   llvm_unreachable("bad kind");
> }
> ```
sorry i missed that detail (static) the first time around


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h:29-31
+/// \returns The stored dynamic size expression for the region \p MR.
+const Expr *getDynamicSizeExpr(ProgramStateRef State, const MemRegion *MR);
+

NoQ wrote:
> Why do we need this?
I think as the checkers are growing and we push more-and-more allocation 
modeling so that at some point the Git's 8-parameter allocator's size 
expression could be retrieved so easily. This is the full arsenal of my 
buffer-overflow checker's needs, so I have pushed it here. Also it made a 
meaning to have a helper-class with two fields (one would be lame).



Comment at: clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp:1416
+   SizeInBytes.castAs(),
+   NE->getArraySize().getValueOr(nullptr));
   }

My problem was only that. It partially repeats the 
`ExprEngine::bindReturnValue()`, which is a wonky design. I will look into that 
later.



Comment at: clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp:180
-  // Assume should not fail at this point.
-  assert(state);
 

NoQ wrote:
> This gets rid of the assertion failure in 
> https://bugs.llvm.org/show_bug.cgi?id=28450 by implementing my suggestion 
> (2). Yay.
Cool!


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

https://reviews.llvm.org/D69726



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


[PATCH] D69726: [analyzer] DynamicSize: Store the dynamic size

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227534.
Charusso marked 6 inline comments as done.
Charusso added a comment.

- Fix.


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

https://reviews.llvm.org/D69726

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSizeInfo.h
  clang/lib/StaticAnalyzer/Checkers/BuiltinFunctionChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/VLASizeChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp

Index: clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCallAndReturn.cpp
@@ -10,7 +10,6 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "PrettyStackTraceLocationContext.h"
 #include "clang/AST/CXXInheritance.h"
 #include "clang/AST/DeclCXX.h"
@@ -18,6 +17,8 @@
 #include "clang/Analysis/ConstructionContext.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/Statistic.h"
 #include "llvm/Support/SaveAndRestore.h"
@@ -653,16 +654,21 @@
 
 // See if we need to conjure a heap pointer instead of
 // a regular unknown pointer.
-bool IsHeapPointer = false;
-if (const auto *CNE = dyn_cast(E))
-  if (CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
-// FIXME: Delegate this to evalCall in MallocChecker?
-IsHeapPointer = true;
+const auto *CNE = dyn_cast(E);
+if (CNE && CNE->getOperatorNew()->isReplaceableGlobalAllocationFunction()) {
+  // FIXME: Delegate this to evalCall in MallocChecker?
+  DefinedOrUnknownSVal Size = UnknownVal();
+  const Expr *SizeExpr = nullptr;
+
+  if ((SizeExpr = CNE->getArraySize().getValueOr(nullptr))) {
+Size = State->getSVal(SizeExpr, LCtx).castAs();
   }
 
-R = IsHeapPointer ? svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count)
-  : svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy,
- Count);
+  R = svalBuilder.getConjuredHeapSymbolVal(E, LCtx, Count);
+  State = setDynamicSize(State, R.getAsRegion(), Size, SizeExpr);
+} else {
+  R = svalBuilder.conjureSymbolVal(nullptr, E, LCtx, ResultTy, Count);
+}
   }
   return State->BindExpr(E, LCtx, R);
 }
Index: clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
@@ -10,15 +10,16 @@
 //
 //===--===//
 
-#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
-#include "clang/Analysis/ConstructionContext.h"
 #include "clang/AST/DeclCXX.h"
-#include "clang/AST/StmtCXX.h"
 #include "clang/AST/ParentMap.h"
+#include "clang/AST/StmtCXX.h"
+#include "clang/Analysis/ConstructionContext.h"
 #include "clang/Basic/PrettyStackTrace.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/AnalysisManager.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 
 using namespace clang;
 using namespace ento;
@@ -761,11 +762,20 @@
   // heap. We realize this is an approximation that might not correctly model
   // a custom global allocator.
   if (symVal.isUnknown()) {
-if (IsStandardGlobalOpNewFunction)
+if (IsStandardGlobalOpNewFunction) {
+  DefinedOrUnknownSVal Size = UnknownVal();
+  const Expr *SizeExpr = nullptr;
+
+  if ((SizeExpr = CNE->getArraySize().getValueOr(nullptr))) {
+Size = State->getSVal(SizeExpr, LCtx).castAs();
+  }
+
   symVal = svalBuilder.getConjuredHeapSymbolVal(CNE, LCtx, blockCount);
-else
+  State = setDynamicSize(State, symVal.getAsRegion(), Size, SizeExpr);
+} else {
   symVal = svalBuilder.conjureSymbolVal(nullptr, CNE, LCtx, CNE->getType(),
 blockCount);
+}
   }
 
   CallEventManager &CEMgr = getStateManager().getCallEventManager();
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAna

[PATCH] D69732: [WIP][LTO] Apply SamplePGO pipeline tunes for ThinLTO pre-link to full LTO

2019-11-01 Thread Wenlei He via Phabricator via cfe-commits
wenlei added a comment.

> The comments indicate that this is in part due to issues with
>  the new PM loop pass manager

Wondering how different it is for these loop passes to be enabled for MonoLTO 
vs ThinLTO? If it's due to problems with the newPM, I guess ThinLTO would have 
the same problems? Asking because we have almost the same change as internal 
patch trying to get better LTO time profile precision for MonoLTO, and with 
that there's small win for oldPM+MonoLTO. But we'd love to converge on new PM 
for both MonoLTO and ThinLTO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69732



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69731#1730784 , @NoQ wrote:

> I'm not sure though - because we somehow survived without this for like 10 
> years. Eg. `BugReporterVisitors.cpp`: [...]
>  I'd love to see some actual use before committing.


"Teaser":

  const Preprocessor &PP = C.getPreprocessor();
  Optional WantSafeFunctions;

  if (PP.isMacroDefined("__STDC_LIB_EXT1__")) {
MacroDefinition MD = PP.getMacroDefinition("__STDC_WANT_LIB_EXT1__");
if (const MacroInfo *MI = MD.getMacroInfo()) {
  const Token &T = MI->tokens().back();
  StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
  llvm::APInt IntValue;
  ValueStr.getAsInteger(10, IntValue);
  WantSafeFunctions = IntValue.getZExtValue();
}
  }


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

Charusso wrote:
> NoQ wrote:
> > And then remove the manual division.
> Hmpf.
> 
> ```
> Failing Tests (7):
> Clang :: Analysis/misc-ps-region-store.m
> Clang :: Analysis/mpichecker.cpp
> Clang :: Analysis/outofbound.c
> Clang :: Analysis/rdar-6541136-region.c
> Clang :: Analysis/return-ptr-range.cpp
> Clang :: Analysis/track-control-dependency-conditions.cpp
> Clang :: Analysis/uninit-vals.c
> ```
> 
> I would pick that solution because it may be a tiny-bit faster, and then 
> later on investigate this issue when we model more about dynamic sizes.
Soo what does it tell us about the correctness of the new `evalBinOp`-based 
solution?


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

https://reviews.llvm.org/D69599



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

It sounds like the code is querying the temporary internal state of the 
preprocessor which is supposed to be queried during preprocessing, not after 
it. Say, `PP.isMacroDefined("__STDC_LIB_EXT1__")` clearly depends on the 
location, as a macro can be un-defined and re-defined as many times as 
possible. But it doesn't receive the location as an argument, so it's probably 
implied to be "the location that the preprocessor is currently 
preprocessing"(?) Like, i've no idea how does the `Preprocessor` class work, 
but the code clearly looks too primitive to solve the problem. Clang-Tidy's 
`PPCallbacks` subsystem looks much more realistic.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[clang] 42465f4 - DebugInfo: (NFC) Refactor DWARF version calculation to make a future change (-fdebug-default-version) easier

2019-11-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-01T14:56:43-07:00
New Revision: 42465f406bcea5ea06001ccc52ab779120b68e87

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

LOG: DebugInfo: (NFC) Refactor DWARF version calculation to make a future 
change (-fdebug-default-version) easier

Added: 


Modified: 
clang/lib/Driver/ToolChains/Clang.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 81e01aee1da9..9cfa39840566 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,11 +3198,16 @@ static void RenderDebugOptions(const ToolChain &TC, 
const Driver &D,
   }
 
   // If a -gdwarf argument appeared, remember it.
-  if (const Arg *A =
+  const Arg *GDwarfN =
   Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
-  options::OPT_gdwarf_4, options::OPT_gdwarf_5))
-if (checkDebugInfoOption(A, Args, D, TC))
-  DWARFVersion = DwarfVersionNum(A->getSpelling());
+  options::OPT_gdwarf_4, options::OPT_gdwarf_5);
+  bool EmitDwarf = false;
+  if (GDwarfN) {
+if (checkDebugInfoOption(GDwarfN, Args, D, TC))
+  EmitDwarf = true;
+else
+  GDwarfN = nullptr;
+  }
 
   if (const Arg *A = Args.getLastArg(options::OPT_gcodeview)) {
 if (checkDebugInfoOption(A, Args, D, TC))
@@ -3211,18 +3216,28 @@ static void RenderDebugOptions(const ToolChain &TC, 
const Driver &D,
 
   // If the user asked for debug info but did not explicitly specify -gcodeview
   // or -gdwarf, ask the toolchain for the default format.
-  if (!EmitCodeView && DWARFVersion == 0 &&
+  if (!EmitCodeView && !EmitDwarf &&
   DebugInfoKind != codegenoptions::NoDebugInfo) {
 switch (TC.getDefaultDebugFormat()) {
 case codegenoptions::DIF_CodeView:
   EmitCodeView = true;
   break;
 case codegenoptions::DIF_DWARF:
-  DWARFVersion = TC.GetDefaultDwarfVersion();
+  EmitDwarf = true;
   break;
 }
   }
 
+  if (EmitDwarf) {
+// Start with the platform default DWARF version
+DWARFVersion = TC.GetDefaultDwarfVersion();
+
+// Override with a user-specified DWARF version
+if (GDwarfN)
+  if (auto ExplicitVersion = DwarfVersionNum(GDwarfN->getSpelling()))
+DWARFVersion = ExplicitVersion;
+  }
+
   // -gline-directives-only supported only for the DWARF debug info.
   if (DWARFVersion == 0 && DebugInfoKind == 
codegenoptions::DebugDirectivesOnly)
 DebugInfoKind = codegenoptions::NoDebugInfo;



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

Thanks, now it is cool!




Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

NoQ wrote:
> Charusso wrote:
> > NoQ wrote:
> > > And then remove the manual division.
> > Hmpf.
> > 
> > ```
> > Failing Tests (7):
> > Clang :: Analysis/misc-ps-region-store.m
> > Clang :: Analysis/mpichecker.cpp
> > Clang :: Analysis/outofbound.c
> > Clang :: Analysis/rdar-6541136-region.c
> > Clang :: Analysis/return-ptr-range.cpp
> > Clang :: Analysis/track-control-dependency-conditions.cpp
> > Clang :: Analysis/uninit-vals.c
> > ```
> > 
> > I would pick that solution because it may be a tiny-bit faster, and then 
> > later on investigate this issue when we model more about dynamic sizes.
> Soo what does it tell us about the correctness of the new 
> `evalBinOp`-based solution?
So, when I tried to inject an `APSInt` it converted to `0` so division by zero 
made that. I felt that the implicit conversion is wonky, but dividing by 0, ugh.


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

https://reviews.llvm.org/D69599



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227543.
Charusso marked 4 inline comments as done.
Charusso added a comment.

- Old division swapped by `evalBinOp`.


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

https://reviews.llvm.org/D69599

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -622,15 +622,6 @@
   StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx,
   SymbolReaper& SymReaper) override;
 
-  //===--===//
-  // Region "extents".
-  //===--===//
-
-  // FIXME: This method will soon be eliminated; see the note in Store.h.
-  DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion* R,
- QualType EleTy) override;
-
   //===--===//
   // Utility methods.
   //===--===//
@@ -1387,37 +1378,6 @@
   return StoreRef(B.asStore(), *this);
 }
 
-//===--===//
-// Extents for regions.
-//===--===//
-
-DefinedOrUnknownSVal
-RegionStoreManager::getSizeInElements(ProgramStateRef state,
-  const MemRegion *R,
-  QualType EleTy) {
-  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
-  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
-  if (!SizeInt)
-return UnknownVal();
-
-  CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
-
-  if (Ctx.getAsVariableArrayType(EleTy)) {
-// FIXME: We need to track extra state to properly record the size
-// of VLAs.  Returning UnknownVal here, however, is a stop-gap so that
-// we don't have a divide-by-zero below.
-return UnknownVal();
-  }
-
-  CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
-
-  // If a variable is reinterpreted as a type that doesn't fit into a larger
-  // type evenly, round it down.
-  // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize,
-svalBuilder.getArrayIndexType());
-}
-
 //===--===//
 // Location and region casting.
 //===--===//
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
+++ clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -26,5 +27,25 @@
   return MR->getMemRegionManager().getStaticSize(MR, SVB);
 }
 
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder &SVB,
+QualType ElementTy) {
+  MemRegionManager &MemMgr = MR->getMemRegionManager();
+  ASTContext &Ctx = MemMgr.getContext();
+
+  DefinedOrUnknownSVal Size = getDynamicSize(State, MR, SVB);
+  SVal ElementSizeV = SVB.makeIntVal(
+  Ctx.getTypeSizeInChars(ElementTy).getQuantity(), SVB.getArrayIndexType());
+
+  SVal DivisionV =
+  SVB.evalBinOp(State, BO_Div, Size, ElementSizeV, SVB.getArrayIndexType());
+
+  if (auto DV = DivisionV.getAs())
+return *DV;
+
+  return UnknownVal();
+}
+
 } // namespace ento
 } // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ clang/lib/StaticAnal

[PATCH] D69638: [NFC] Add SUPPORT_PLUGINS to add_llvm_executable()

2019-11-01 Thread Chris Bieneman via Phabricator via cfe-commits
beanz accepted this revision.
beanz added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69638



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


[PATCH] D69540: [analyzer] DynamicSize: Remove 'getExtent()' from regions

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added a comment.
This revision is now accepted and ready to land.

Fantastic, let's land this!


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

https://reviews.llvm.org/D69540



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ accepted this revision.
NoQ added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:40-48
+  if (const llvm::APSInt *SizeInt = SVB.getKnownValue(State, Size)) {
+CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
+
+// If a variable is reinterpreted as a type that doesn't fit into a larger
+// type evenly, round it down.
+// This is a signed value, since it's used in arithmetic with signed
+// indices.

Charusso wrote:
> NoQ wrote:
> > Charusso wrote:
> > > NoQ wrote:
> > > > And then remove the manual division.
> > > Hmpf.
> > > 
> > > ```
> > > Failing Tests (7):
> > > Clang :: Analysis/misc-ps-region-store.m
> > > Clang :: Analysis/mpichecker.cpp
> > > Clang :: Analysis/outofbound.c
> > > Clang :: Analysis/rdar-6541136-region.c
> > > Clang :: Analysis/return-ptr-range.cpp
> > > Clang :: Analysis/track-control-dependency-conditions.cpp
> > > Clang :: Analysis/uninit-vals.c
> > > ```
> > > 
> > > I would pick that solution because it may be a tiny-bit faster, and then 
> > > later on investigate this issue when we model more about dynamic sizes.
> > Soo what does it tell us about the correctness of the new 
> > `evalBinOp`-based solution?
> So, when I tried to inject an `APSInt` it converted to `0` so division by 
> zero made that. I felt that the implicit conversion is wonky, but dividing by 
> 0, ugh.
Yay, great job figuring this out!

Also the conversion wasn't implicit; you explicitly specified 
`llvm::APSInt(...)`. I agree that this constructor is evil, though.



Comment at: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp:44-47
+  if (auto DV = DivisionV.getAs())
+return *DV;
+
+  return UnknownVal();

I'd rather do a `castAs` here. Allocating a region of garbage size should be an 
immediate warning; supplying a zero-size `ElementTy` should be an immediate 
crash; in all other cases the result of division must be defined.


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

https://reviews.llvm.org/D69599



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


[clang] 098d901 - DebugInfo: Let -gdwarf use the toolchain default DWARF version, instead of hardcoded/aliased to -gdwarf-4

2019-11-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-01T15:17:51-07:00
New Revision: 098d901bd1be07f60c41450fa4af775b130117b9

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

LOG: DebugInfo: Let -gdwarf use the toolchain default DWARF version, instead of 
hardcoded/aliased to -gdwarf-4

Added: 


Modified: 
clang/include/clang/Driver/Options.td
clang/lib/Driver/ToolChains/Clang.cpp
clang/test/CodeGen/dwarf-version.c

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 07c27ebcefee..44259a2a53e8 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1972,6 +1972,10 @@ def ggdb2 : Flag<["-"], "ggdb2">, Group;
 def ggdb3 : Flag<["-"], "ggdb3">, Group;
 def glldb : Flag<["-"], "glldb">, Group;
 def gsce : Flag<["-"], "gsce">, Group;
+// Equivalent to our default dwarf version. Forces usual dwarf emission when
+// CodeView is enabled.
+def gdwarf : Flag<["-"], "gdwarf">, Group,
+  HelpText<"Generate source-level debug information with the default dwarf 
version">;
 def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group,
   HelpText<"Generate source-level debug information with dwarf version 2">;
 def gdwarf_3 : Flag<["-"], "gdwarf-3">, Group,
@@ -1989,10 +1993,6 @@ def gcodeview_ghash : Flag<["-"], "gcodeview-ghash">,
   Flags<[CC1Option, CoreOption]>;
 def gno_codeview_ghash : Flag<["-"], "gno-codeview-ghash">, 
Flags<[CoreOption]>;
 
-// Equivalent to our default dwarf version. Forces usual dwarf emission when
-// CodeView is enabled.
-def gdwarf : Flag<["-"], "gdwarf">, Alias, Flags<[CoreOption]>;
-
 def gfull : Flag<["-"], "gfull">, Group;
 def gused : Flag<["-"], "gused">, Group;
 def gstabs : Joined<["-"], "gstabs">, Group, Flags<[Unsupported]>;

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp 
b/clang/lib/Driver/ToolChains/Clang.cpp
index 9cfa39840566..529c33a16748 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -3198,9 +3198,9 @@ static void RenderDebugOptions(const ToolChain &TC, const 
Driver &D,
   }
 
   // If a -gdwarf argument appeared, remember it.
-  const Arg *GDwarfN =
-  Args.getLastArg(options::OPT_gdwarf_2, options::OPT_gdwarf_3,
-  options::OPT_gdwarf_4, options::OPT_gdwarf_5);
+  const Arg *GDwarfN = Args.getLastArg(
+  options::OPT_gdwarf_2, options::OPT_gdwarf_3, options::OPT_gdwarf_4,
+  options::OPT_gdwarf_5, options::OPT_gdwarf);
   bool EmitDwarf = false;
   if (GDwarfN) {
 if (checkDebugInfoOption(GDwarfN, Args, D, TC))
@@ -3231,6 +3231,7 @@ static void RenderDebugOptions(const ToolChain &TC, const 
Driver &D,
   if (EmitDwarf) {
 // Start with the platform default DWARF version
 DWARFVersion = TC.GetDefaultDwarfVersion();
+assert(DWARFVersion && "toolchain default DWARF version must be nonzero");
 
 // Override with a user-specified DWARF version
 if (GDwarfN)

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index 39bcbc209037..10add21d88dd 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -14,6 +14,7 @@
 // RUN: %clang -target powerpc-unknown-openbsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target powerpc-unknown-freebsd -g -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 // RUN: %clang -target i386-pc-solaris -g -S -emit-llvm -o - %s | FileCheck %s 
--check-prefix=VER2
+// RUN: %clang -target i386-pc-solaris -gdwarf -S -emit-llvm -o - %s | 
FileCheck %s --check-prefix=VER2
 
 // Check which debug info formats we use on Windows. By default, in an MSVC
 // environment, we should use codeview. You can enable dwarf, which implicitly



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


[PATCH] D69731: [analyzer] CheckerContext: Make the Preprocessor available

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso added a comment.

In D69731#1730899 , @NoQ wrote:

> Clang-Tidy's `PPCallbacks` subsystem looks much more realistic.


I wanted to make it available from the `AnalysisManager` so that I can obtain 
the macro definitions once before the analysis starts. Nor the Clang Tidy's 
`PPCallback`, nor the `AnalysisManager` could retrieve the necessary 
information at that point in the analysis. However, at that point when we 
analyze something all the necessary information is available. Most of the Tidy 
checkers grab their own `PP` reference to use it later on. The Tidy devs agree 
to retrieve such information even in the main `check()` call which going to 
rerun in every `TranslationUnit`. So even it is so primitive, there is no 
better solution as I know. I hope we could find something better / cache it. At 
the moment this code-snippet I have just showed you runs in every `evalCall()`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69731



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


[clang] 1de2a05 - DebugInfo: Accept -gdwarf even in clang-cl

2019-11-01 Thread David Blaikie via cfe-commits

Author: David Blaikie
Date: 2019-11-01T15:36:15-07:00
New Revision: 1de2a05701e73f8ef5914c2f6ea2dcbe617ce18b

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

LOG: DebugInfo: Accept -gdwarf even in clang-cl

Fixes regression introduced by llvmorg-10-init-8908-g098d901bd1b

Added: 


Modified: 
clang/include/clang/Driver/Options.td

Removed: 




diff  --git a/clang/include/clang/Driver/Options.td 
b/clang/include/clang/Driver/Options.td
index 44259a2a53e8..722427bc35a6 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1974,7 +1974,7 @@ def glldb : Flag<["-"], "glldb">, Group;
 def gsce : Flag<["-"], "gsce">, Group;
 // Equivalent to our default dwarf version. Forces usual dwarf emission when
 // CodeView is enabled.
-def gdwarf : Flag<["-"], "gdwarf">, Group,
+def gdwarf : Flag<["-"], "gdwarf">, Group, Flags<[CoreOption]>,
   HelpText<"Generate source-level debug information with the default dwarf 
version">;
 def gdwarf_2 : Flag<["-"], "gdwarf-2">, Group,
   HelpText<"Generate source-level debug information with dwarf version 2">;



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


[PATCH] D69599: [analyzer] DynamicSize: Remove 'getSizeInElements()' from store

2019-11-01 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso updated this revision to Diff 227546.
Charusso marked 3 inline comments as done.
Charusso added a comment.

- Done.


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

https://reviews.llvm.org/D69599

Files:
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h
  clang/include/clang/StaticAnalyzer/Core/PathSensitive/Store.h
  clang/lib/StaticAnalyzer/Checkers/ArrayBoundChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/ReturnPointerRangeChecker.cpp
  clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
  clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
  clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Index: clang/lib/StaticAnalyzer/Core/RegionStore.cpp
===
--- clang/lib/StaticAnalyzer/Core/RegionStore.cpp
+++ clang/lib/StaticAnalyzer/Core/RegionStore.cpp
@@ -622,15 +622,6 @@
   StoreRef removeDeadBindings(Store store, const StackFrameContext *LCtx,
   SymbolReaper& SymReaper) override;
 
-  //===--===//
-  // Region "extents".
-  //===--===//
-
-  // FIXME: This method will soon be eliminated; see the note in Store.h.
-  DefinedOrUnknownSVal getSizeInElements(ProgramStateRef state,
- const MemRegion* R,
- QualType EleTy) override;
-
   //===--===//
   // Utility methods.
   //===--===//
@@ -1387,37 +1378,6 @@
   return StoreRef(B.asStore(), *this);
 }
 
-//===--===//
-// Extents for regions.
-//===--===//
-
-DefinedOrUnknownSVal
-RegionStoreManager::getSizeInElements(ProgramStateRef state,
-  const MemRegion *R,
-  QualType EleTy) {
-  DefinedOrUnknownSVal Size = getDynamicSize(state, R, svalBuilder);
-  const llvm::APSInt *SizeInt = svalBuilder.getKnownValue(state, Size);
-  if (!SizeInt)
-return UnknownVal();
-
-  CharUnits RegionSize = CharUnits::fromQuantity(SizeInt->getSExtValue());
-
-  if (Ctx.getAsVariableArrayType(EleTy)) {
-// FIXME: We need to track extra state to properly record the size
-// of VLAs.  Returning UnknownVal here, however, is a stop-gap so that
-// we don't have a divide-by-zero below.
-return UnknownVal();
-  }
-
-  CharUnits EleSize = Ctx.getTypeSizeInChars(EleTy);
-
-  // If a variable is reinterpreted as a type that doesn't fit into a larger
-  // type evenly, round it down.
-  // This is a signed value, since it's used in arithmetic with signed indices.
-  return svalBuilder.makeIntVal(RegionSize / EleSize,
-svalBuilder.getArrayIndexType());
-}
-
 //===--===//
 // Location and region casting.
 //===--===//
Index: clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
===
--- clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
+++ clang/lib/StaticAnalyzer/Core/DynamicSize.cpp
@@ -11,6 +11,7 @@
 //===--===//
 
 #include "clang/StaticAnalyzer/Core/PathSensitive/DynamicSize.h"
+#include "clang/AST/Expr.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/MemRegion.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
@@ -26,5 +27,22 @@
   return MR->getMemRegionManager().getStaticSize(MR, SVB);
 }
 
+DefinedOrUnknownSVal getDynamicElementCount(ProgramStateRef State,
+const MemRegion *MR,
+SValBuilder &SVB,
+QualType ElementTy) {
+  MemRegionManager &MemMgr = MR->getMemRegionManager();
+  ASTContext &Ctx = MemMgr.getContext();
+
+  DefinedOrUnknownSVal Size = getDynamicSize(State, MR, SVB);
+  SVal ElementSizeV = SVB.makeIntVal(
+  Ctx.getTypeSizeInChars(ElementTy).getQuantity(), SVB.getArrayIndexType());
+
+  SVal DivisionV =
+  SVB.evalBinOp(State, BO_Div, Size, ElementSizeV, SVB.getArrayIndexType());
+
+  return DivisionV.castAs();
+}
+
 } // namespace ento
 } // namespace clang
Index: clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
===
--- clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
+++ clang/lib/StaticAnalyzer/Checkers/UndefResultChecker.cpp
@@ -16,6 +16,7 @@
 #include "clang/StaticAn

  1   2   >