[PATCH] D50130: [libc++] Fix build failures after merging

2018-07-31 Thread Zhihao Yuan via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rCXX338486: [libc++] Fix build failures after merging 
charconv (authored by lichray, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50130?vs=158464=158465#toc

Repository:
  rCXX libc++

https://reviews.llvm.org/D50130

Files:
  lib/abi/x86_64-unknown-linux-gnu.v1.abilist
  test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  test/support/charconv_test_helpers.h


Index: test/support/charconv_test_helpers.h
===
--- test/support/charconv_test_helpers.h
+++ test/support/charconv_test_helpers.h
@@ -178,7 +178,7 @@
 {
 assert(x == 0xc);
 assert(r2.ptr == buf);
-assert(r.ec == std::errc::invalid_argument);
+assert(r2.ec == std::errc::invalid_argument);
 }
 else
 {
Index: test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
===
--- test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
+++ test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
@@ -37,6 +37,7 @@
 using xl = std::numeric_limits;
 
 test(1, b);
+test(-1, b);
 test(xl::lowest(), b);
 test((xl::max)(), b);
 test((xl::max)() / 2, b);
Index: lib/abi/x86_64-unknown-linux-gnu.v1.abilist
===
--- lib/abi/x86_64-unknown-linux-gnu.v1.abilist
+++ lib/abi/x86_64-unknown-linux-gnu.v1.abilist
@@ -1192,6 +1192,8 @@
 {'name': '_ZNSt3__15wclogE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__15wcoutE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__16__clocEv', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u64toaEmPc', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u32toaEjPc', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}


Index: test/support/charconv_test_helpers.h
===
--- test/support/charconv_test_helpers.h
+++ test/support/charconv_test_helpers.h
@@ -178,7 +178,7 @@
 {
 assert(x == 0xc);
 assert(r2.ptr == buf);
-assert(r.ec == std::errc::invalid_argument);
+assert(r2.ec == std::errc::invalid_argument);
 }
 else
 {
Index: test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
===
--- test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
+++ test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
@@ -37,6 +37,7 @@
 using xl = std::numeric_limits;
 
 test(1, b);
+test(-1, b);
 test(xl::lowest(), b);
 test((xl::max)(), b);
 test((xl::max)() / 2, b);
Index: lib/abi/x86_64-unknown-linux-gnu.v1.abilist
===
--- lib/abi/x86_64-unknown-linux-gnu.v1.abilist
+++ lib/abi/x86_64-unknown-linux-gnu.v1.abilist
@@ -1192,6 +1192,8 @@
 {'name': '_ZNSt3__15wclogE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__15wcoutE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__16__clocEv', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u64toaEmPc', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u32toaEjPc', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_', 'is_defined': True, 'type': 'FUNC'}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r338486 - [libc++] Fix build failures after merging

2018-07-31 Thread Zhihao Yuan via cfe-commits
Author: lichray
Date: Tue Jul 31 22:21:26 2018
New Revision: 338486

URL: http://llvm.org/viewvc/llvm-project?rev=338486=rev
Log:
[libc++] Fix build failures after merging 

Summary:
- fix a stupid unit test typo
- add  symbols to Linux abilist

Reviewers: EricWF

Subscribers: christof, ldionne, cfe-commits

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

Modified:
libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.v1.abilist

libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
libcxx/trunk/test/support/charconv_test_helpers.h

Modified: libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.v1.abilist
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.v1.abilist?rev=338486=338485=338486=diff
==
--- libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.v1.abilist (original)
+++ libcxx/trunk/lib/abi/x86_64-unknown-linux-gnu.v1.abilist Tue Jul 31 
22:21:26 2018
@@ -1192,6 +1192,8 @@
 {'name': '_ZNSt3__15wclogE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__15wcoutE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__16__clocEv', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u64toaEmPc', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u32toaEjPc', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}

Modified: 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp?rev=338486=338485=338486=diff
==
--- 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp 
Tue Jul 31 22:21:26 2018
@@ -37,6 +37,7 @@ struct test_basics : roundtrip_test_base
 using xl = std::numeric_limits;
 
 test(1, b);
+test(-1, b);
 test(xl::lowest(), b);
 test((xl::max)(), b);
 test((xl::max)() / 2, b);

Modified: libcxx/trunk/test/support/charconv_test_helpers.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/charconv_test_helpers.h?rev=338486=338485=338486=diff
==
--- libcxx/trunk/test/support/charconv_test_helpers.h (original)
+++ libcxx/trunk/test/support/charconv_test_helpers.h Tue Jul 31 22:21:26 2018
@@ -178,7 +178,7 @@ struct roundtrip_test_base
 {
 assert(x == 0xc);
 assert(r2.ptr == buf);
-assert(r.ec == std::errc::invalid_argument);
+assert(r2.ec == std::errc::invalid_argument);
 }
 else
 {


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


[PATCH] D50130: [libc++] Fix build failures after merging

2018-07-31 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray created this revision.
Herald added a reviewer: EricWF.
Herald added subscribers: cfe-commits, ldionne, christof.

- fix a stupid unit test typo
- add  symbols to Linux abilist


Repository:
  rCXX libc++

https://reviews.llvm.org/D50130

Files:
  lib/abi/x86_64-unknown-linux-gnu.v1.abilist
  test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  test/support/charconv_test_helpers.h


Index: test/support/charconv_test_helpers.h
===
--- test/support/charconv_test_helpers.h
+++ test/support/charconv_test_helpers.h
@@ -178,7 +178,7 @@
 {
 assert(x == 0xc);
 assert(r2.ptr == buf);
-assert(r.ec == std::errc::invalid_argument);
+assert(r2.ec == std::errc::invalid_argument);
 }
 else
 {
Index: test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
===
--- test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
+++ test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
@@ -37,6 +37,7 @@
 using xl = std::numeric_limits;
 
 test(1, b);
+test(-1, b);
 test(xl::lowest(), b);
 test((xl::max)(), b);
 test((xl::max)() / 2, b);
Index: lib/abi/x86_64-unknown-linux-gnu.v1.abilist
===
--- lib/abi/x86_64-unknown-linux-gnu.v1.abilist
+++ lib/abi/x86_64-unknown-linux-gnu.v1.abilist
@@ -1192,6 +1192,8 @@
 {'name': '_ZNSt3__15wclogE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__15wcoutE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__16__clocEv', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u64toaEmPc', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u32toaEjPc', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_', 'is_defined': True, 
'type': 'FUNC'}


Index: test/support/charconv_test_helpers.h
===
--- test/support/charconv_test_helpers.h
+++ test/support/charconv_test_helpers.h
@@ -178,7 +178,7 @@
 {
 assert(x == 0xc);
 assert(r2.ptr == buf);
-assert(r.ec == std::errc::invalid_argument);
+assert(r2.ec == std::errc::invalid_argument);
 }
 else
 {
Index: test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
===
--- test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
+++ test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
@@ -37,6 +37,7 @@
 using xl = std::numeric_limits;
 
 test(1, b);
+test(-1, b);
 test(xl::lowest(), b);
 test((xl::max)(), b);
 test((xl::max)() / 2, b);
Index: lib/abi/x86_64-unknown-linux-gnu.v1.abilist
===
--- lib/abi/x86_64-unknown-linux-gnu.v1.abilist
+++ lib/abi/x86_64-unknown-linux-gnu.v1.abilist
@@ -1192,6 +1192,8 @@
 {'name': '_ZNSt3__15wclogE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__15wcoutE', 'is_defined': True, 'type': 'OBJECT', 'size': 160}
 {'name': '_ZNSt3__16__clocEv', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u64toaEmPc', 'is_defined': True, 'type': 'FUNC'}
+{'name': '_ZNSt3__16__itoa8__u32toaEjPc', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIaaEEPaEEvT0_S5_T_', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIccEEPcEEvT0_S5_T_', 'is_defined': True, 'type': 'FUNC'}
 {'name': '_ZNSt3__16__sortIRNS_6__lessIddEEPdEEvT0_S5_T_', 'is_defined': True, 'type': 'FUNC'}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49771: CodeGen: use non-zero memset when possible for automatic variables

2018-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D49771#1183641, @mehdi_amini wrote:

> > I'm worried, however, about generating a bunch more code than needed from 
> > clang in the hopes that the compiler will clean it up later.
>
> Isn't a strong design component of clang/LLVM? Clang does not try to generate 
> "smart" code and leave it up to LLVM to clean it up.


The code around this one, and lack of code in LLVM, seem to disagree. :-)


Repository:
  rL LLVM

https://reviews.llvm.org/D49771



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


[PATCH] D50123: [OpenEmbedded] Explicitly specify -stdlib and -rtlib in tests

2018-07-31 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338482: [OpenEmbedded] Explicitly specify -rtlib in tests 
(authored by phosek, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50123?vs=158444=158457#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50123

Files:
  cfe/trunk/test/Driver/linux-ld.c


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -1816,7 +1816,7 @@
 
 // Check whether the OpenEmbedded ARM libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=arm-oe-linux-gnueabi \
+// RUN: --target=arm-oe-linux-gnueabi -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -1835,7 +1835,7 @@
 
 // Check whether the OpenEmbedded AArch64 libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=aarch64-oe-linux \
+// RUN: --target=aarch64-oe-linux -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 


Index: cfe/trunk/test/Driver/linux-ld.c
===
--- cfe/trunk/test/Driver/linux-ld.c
+++ cfe/trunk/test/Driver/linux-ld.c
@@ -1816,7 +1816,7 @@
 
 // Check whether the OpenEmbedded ARM libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=arm-oe-linux-gnueabi \
+// RUN: --target=arm-oe-linux-gnueabi -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -1835,7 +1835,7 @@
 
 // Check whether the OpenEmbedded AArch64 libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=aarch64-oe-linux \
+// RUN: --target=aarch64-oe-linux -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338482 - [OpenEmbedded] Explicitly specify -rtlib in tests

2018-07-31 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Tue Jul 31 20:30:06 2018
New Revision: 338482

URL: http://llvm.org/viewvc/llvm-project?rev=338482=rev
Log:
[OpenEmbedded] Explicitly specify -rtlib in tests

Tests added in r338294 implicitly assume that libgcc is the runtime library,
but that's not the case when the user configures Clang to use compiler-rt in
which case these tests will break. Explicitly request libgcc when invoking
clang in these tests to avoid that.

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

Modified:
cfe/trunk/test/Driver/linux-ld.c

Modified: cfe/trunk/test/Driver/linux-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/linux-ld.c?rev=338482=338481=338482=diff
==
--- cfe/trunk/test/Driver/linux-ld.c (original)
+++ cfe/trunk/test/Driver/linux-ld.c Tue Jul 31 20:30:06 2018
@@ -1816,7 +1816,7 @@
 
 // Check whether the OpenEmbedded ARM libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=arm-oe-linux-gnueabi \
+// RUN: --target=arm-oe-linux-gnueabi -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -1835,7 +1835,7 @@
 
 // Check whether the OpenEmbedded AArch64 libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=aarch64-oe-linux \
+// RUN: --target=aarch64-oe-linux -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 


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


[PATCH] D38320: [clang] Fix serializers for `TypeTemplateParmDecl` + related types

2018-07-31 Thread Steve O'Brien via Phabricator via cfe-commits
elsteveogrande added inline comments.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3448-3456
   if (!inheritDefaultTemplateArgument(Context, FTTP, ToParam))
 break;
 } else if (auto *FNTTP = dyn_cast(FromParam)) {
   if (!inheritDefaultTemplateArgument(Context, FNTTP, ToParam))
 break;
 } else {
   if (!inheritDefaultTemplateArgument(

rsmith wrote:
> The idea is to reconstruct the 'inherited default template argument' 
> information when we read a template declaration and find it's a redeclaration 
> of another one, rather than serializing it and deserializing it. (In 
> particular, if an imported template redeclares a non-imported template or a 
> template imported from an unrelated module, it won't know that the prior 
> declaration had a default argument because it doesn't know what the prior 
> declaration was.)
> 
> The problem with our implementation of that idea is these `break`s: we're 
> (incorrectly) assuming that a template parameter cannot have a default 
> argument if there's a later template parameter that does not have one.
> 
> I removed the `break`s in r338438, and it fixed your testcase (which I 
> committed alongside that change). Can you check to see if that also fixes the 
> original problem from which this was reduced? Thanks!
Thanks @rsmith!  It sounds like that ought to do it.  We'll try again on our 
end and let you know.  Thanks for the quick fix!


Repository:
  rC Clang

https://reviews.llvm.org/D38320



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-31 Thread Zhihao Yuan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338479: [libc++][C++17] Elementary string conversions for 
integral types (authored by lichray, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D41458?vs=158404=158455#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D41458

Files:
  libcxx/trunk/include/CMakeLists.txt
  libcxx/trunk/include/charconv
  libcxx/trunk/include/module.modulemap
  libcxx/trunk/src/charconv.cpp
  libcxx/trunk/test/libcxx/double_include.sh.cpp
  
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp
  libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp
  libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
  libcxx/trunk/test/support/charconv_test_helpers.h

Index: libcxx/trunk/src/charconv.cpp
===
--- libcxx/trunk/src/charconv.cpp
+++ libcxx/trunk/src/charconv.cpp
@@ -0,0 +1,233 @@
+//===- charconv.cpp ---===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "charconv"
+#include 
+
+_LIBCPP_BEGIN_NAMESPACE_STD
+
+namespace __itoa
+{
+
+static constexpr char cDigitsLut[200] = {
+'0', '0', '0', '1', '0', '2', '0', '3', '0', '4', '0', '5', '0', '6', '0',
+'7', '0', '8', '0', '9', '1', '0', '1', '1', '1', '2', '1', '3', '1', '4',
+'1', '5', '1', '6', '1', '7', '1', '8', '1', '9', '2', '0', '2', '1', '2',
+'2', '2', '3', '2', '4', '2', '5', '2', '6', '2', '7', '2', '8', '2', '9',
+'3', '0', '3', '1', '3', '2', '3', '3', '3', '4', '3', '5', '3', '6', '3',
+'7', '3', '8', '3', '9', '4', '0', '4', '1', '4', '2', '4', '3', '4', '4',
+'4', '5', '4', '6', '4', '7', '4', '8', '4', '9', '5', '0', '5', '1', '5',
+'2', '5', '3', '5', '4', '5', '5', '5', '6', '5', '7', '5', '8', '5', '9',
+'6', '0', '6', '1', '6', '2', '6', '3', '6', '4', '6', '5', '6', '6', '6',
+'7', '6', '8', '6', '9', '7', '0', '7', '1', '7', '2', '7', '3', '7', '4',
+'7', '5', '7', '6', '7', '7', '7', '8', '7', '9', '8', '0', '8', '1', '8',
+'2', '8', '3', '8', '4', '8', '5', '8', '6', '8', '7', '8', '8', '8', '9',
+'9', '0', '9', '1', '9', '2', '9', '3', '9', '4', '9', '5', '9', '6', '9',
+'7', '9', '8', '9', '9'};
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY char*
+append1(char* buffer, T i)
+{
+*buffer = '0' + static_cast(i);
+return buffer + 1;
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY char*
+append2(char* buffer, T i)
+{
+memcpy(buffer, [(i)*2], 2);
+return buffer + 2;
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY char*
+append3(char* buffer, T i)
+{
+return append2(append1(buffer, (i) / 100), (i) % 100);
+}
+
+template 
+inline _LIBCPP_INLINE_VISIBILITY char*
+append4(char* buffer, T i)
+{
+return append2(append2(buffer, (i) / 100), (i) % 100);
+}
+
+char*
+__u32toa(uint32_t value, char* buffer)
+{
+if (value < 1)
+{
+if (value < 100)
+{
+if (value < 10)
+buffer = append1(buffer, value);
+else
+buffer = append2(buffer, value);
+}
+else
+{
+if (value < 1000)
+buffer = append3(buffer, value);
+else
+buffer = append4(buffer, value);
+}
+}
+else if (value < 1)
+{
+// value = 
+const uint32_t b = value / 1;
+const uint32_t c = value % 1;
+
+if (value < 100)
+{
+if (value < 10)
+buffer = append1(buffer, b);
+else
+buffer = append2(buffer, b);
+}
+else
+{
+if (value < 1000)
+buffer = append3(buffer, b);
+else
+buffer = append4(buffer, b);
+}
+
+buffer = append4(buffer, c);
+}
+else
+{
+// value = aa in decimal
+const uint32_t a = value / 1;  // 1 to 42
+value %= 1;
+
+if (a < 10)
+buffer = append1(buffer, a);
+else
+buffer = append2(buffer, a);
+
+buffer = append4(buffer, value / 1);
+buffer = append4(buffer, value % 1);
+}
+
+return buffer;
+}
+
+char*
+__u64toa(uint64_t value, char* buffer)
+{
+if (value < 1)
+{
+uint32_t v = static_cast(value);
+if (v < 1)
+{
+if (v < 100)
+{
+if (v < 10)

[libcxx] r338479 - [libc++][C++17] Elementary string conversions for integral types

2018-07-31 Thread Zhihao Yuan via cfe-commits
Author: lichray
Date: Tue Jul 31 19:38:30 2018
New Revision: 338479

URL: http://llvm.org/viewvc/llvm-project?rev=338479=rev
Log:
[libc++][C++17] Elementary string conversions for integral types

Summary:
Major QoI considerations:

- The facility is backported to C++14, same as libstdc++.
- Efforts have been made to minimize the header dependencies.
- The design is friendly to the uses of MSVC intrinsics (`__emulu`, `_umul128`, 
`_BitScanForward`, `_BitScanForward64`) but not implemented; future 
contributions are welcome.

Thanks to Milo Yip for contributing the implementation of `__u64toa` and 
`__u32toa`.

References:
 https://wg21.link/p0067r5
 https://wg21.link/p0682r1

Reviewers: mclow.lists, EricWF

Reviewed By: mclow.lists

Subscribers: ldionne, Quuxplusone, christof, mgorny, cfe-commits

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

Added:
libcxx/trunk/include/charconv
libcxx/trunk/src/charconv.cpp
libcxx/trunk/test/std/utilities/charconv/
libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/

libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp

libcxx/trunk/test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/

libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp
libcxx/trunk/test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
libcxx/trunk/test/support/charconv_test_helpers.h
Modified:
libcxx/trunk/include/CMakeLists.txt
libcxx/trunk/include/module.modulemap
libcxx/trunk/test/libcxx/double_include.sh.cpp

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=338479=338478=338479=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Tue Jul 31 19:38:30 2018
@@ -32,6 +32,7 @@ set(files
   cerrno
   cfenv
   cfloat
+  charconv
   chrono
   cinttypes
   ciso646

Added: libcxx/trunk/include/charconv
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/charconv?rev=338479=auto
==
--- libcxx/trunk/include/charconv (added)
+++ libcxx/trunk/include/charconv Tue Jul 31 19:38:30 2018
@@ -0,0 +1,610 @@
+// -*- C++ -*-
+//===-- charconv 
--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef _LIBCPP_CHARCONV
+#define _LIBCPP_CHARCONV
+
+/*
+charconv synopsis
+
+namespace std {
+
+  // floating-point format for primitive numerical conversion
+  enum class chars_format {
+scientific = unspecified,
+fixed = unspecified,
+hex = unspecified,
+general = fixed | scientific
+  };
+
+  // 23.20.2, primitive numerical output conversion
+  struct to_chars_result {
+char* ptr;
+errc ec;
+  };
+
+  to_chars_result to_chars(char* first, char* last, see below value,
+   int base = 10);
+
+  to_chars_result to_chars(char* first, char* last, float value);
+  to_chars_result to_chars(char* first, char* last, double value);
+  to_chars_result to_chars(char* first, char* last, long double value);
+
+  to_chars_result to_chars(char* first, char* last, float value,
+   chars_format fmt);
+  to_chars_result to_chars(char* first, char* last, double value,
+   chars_format fmt);
+  to_chars_result to_chars(char* first, char* last, long double value,
+   chars_format fmt);
+
+  to_chars_result to_chars(char* first, char* last, float value,
+   chars_format fmt, int precision);
+  to_chars_result to_chars(char* first, char* last, double value,
+   chars_format fmt, int precision);
+  to_chars_result to_chars(char* first, char* last, long double value,
+   chars_format fmt, int precision);
+
+  // 23.20.3, primitive numerical input conversion
+  struct from_chars_result {
+const char* ptr;
+errc ec;
+  };
+
+  from_chars_result from_chars(const char* first, const char* last,
+   see below& value, int base = 10);
+
+  from_chars_result from_chars(const char* first, const char* last,
+   float& value,
+   chars_format fmt = chars_format::general);
+  from_chars_result from_chars(const char* first, const char* last,
+   double& value,
+   chars_format fmt = chars_format::general);
+  from_chars_result from_chars(const 

[PATCH] D50123: [OpenEmbedded] Explicitly specify -stdlib and -rtlib in tests

2018-07-31 Thread Mandeep Singh Grang via Phabricator via cfe-commits
mgrang accepted this revision.
mgrang added a comment.
This revision is now accepted and ready to land.

LGTM.


Repository:
  rC Clang

https://reviews.llvm.org/D50123



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


r338478 - Work around GCC miscompile exposed by r338464.

2018-07-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 31 19:27:18 2018
New Revision: 338478

URL: http://llvm.org/viewvc/llvm-project?rev=338478=rev
Log:
Work around GCC miscompile exposed by r338464.

See gcc.gnu.org/PR86769 for details of the bug.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=338478=338477=338478=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jul 31 19:27:18 2018
@@ -6011,9 +6011,12 @@ static void checkAttributesAfterMerging(
 
   // Check the attributes on the function type, if any.
   if (const auto *FD = dyn_cast()) {
+// Don't declare this variable in the second operand of the for-statement;
+// GCC miscompiles that by ending its lifetime before evaluating the
+// third operand. See gcc.gnu.org/PR86769.
+AttributedTypeLoc ATL;
 for (TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
- auto ATL = TL ? TL.getAsAdjusted()
-   : AttributedTypeLoc();
+ (ATL = TL.getAsAdjusted());
  TL = ATL.getModifiedLoc()) {
   // The [[lifetimebound]] attribute can be applied to the implicit object
   // parameter of a non-static member function (other than a ctor or dtor)


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


[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Hmm, AST has just changed in https://reviews.llvm.org/rC338135. While the 
current patch is still relevant, it might be that we'll need to treat this 
construction context as if it's a simple temporary now.


https://reviews.llvm.org/D49627



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


[PATCH] D50008: [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY

2018-07-31 Thread Louis Dionne via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338475: [libc++] Remove _LIBCPP_BUILDING_XXX macros, which 
are redundant sinceā€¦ (authored by ldionne, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D50008?vs=158058=158451#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50008

Files:
  libcxx/trunk/include/__functional_base
  libcxx/trunk/include/__mutex_base
  libcxx/trunk/include/functional
  libcxx/trunk/include/memory
  libcxx/trunk/include/new
  libcxx/trunk/include/shared_mutex
  libcxx/trunk/include/system_error
  libcxx/trunk/include/utility
  libcxx/trunk/src/bind.cpp
  libcxx/trunk/src/memory.cpp
  libcxx/trunk/src/mutex.cpp
  libcxx/trunk/src/new.cpp
  libcxx/trunk/src/shared_mutex.cpp
  libcxx/trunk/src/system_error.cpp
  libcxx/trunk/src/utility.cpp
  libcxxabi/trunk/src/stdlib_exception.cpp
  libcxxabi/trunk/src/stdlib_new_delete.cpp

Index: libcxxabi/trunk/src/stdlib_new_delete.cpp
===
--- libcxxabi/trunk/src/stdlib_new_delete.cpp
+++ libcxxabi/trunk/src/stdlib_new_delete.cpp
@@ -9,7 +9,6 @@
 // This file implements the new and delete operators.
 //===--===//
 
-#define _LIBCPP_BUILDING_NEW
 #define _LIBCPP_BUILDING_LIBRARY
 #include "__cxxabi_config.h"
 #include 
Index: libcxxabi/trunk/src/stdlib_exception.cpp
===
--- libcxxabi/trunk/src/stdlib_exception.cpp
+++ libcxxabi/trunk/src/stdlib_exception.cpp
@@ -8,7 +8,6 @@
 //===--===//
 
 #define _LIBCPP_BUILDING_LIBRARY
-#define _LIBCPP_BUILDING_NEW
 #include 
 #include 
 
Index: libcxx/trunk/src/bind.cpp
===
--- libcxx/trunk/src/bind.cpp
+++ libcxx/trunk/src/bind.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#define _LIBCPP_BUILDING_BIND
 #include "functional"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
Index: libcxx/trunk/src/memory.cpp
===
--- libcxx/trunk/src/memory.cpp
+++ libcxx/trunk/src/memory.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#define _LIBCPP_BUILDING_MEMORY
 #include "memory"
 #ifndef _LIBCPP_HAS_NO_THREADS
 #include "mutex"
Index: libcxx/trunk/src/mutex.cpp
===
--- libcxx/trunk/src/mutex.cpp
+++ libcxx/trunk/src/mutex.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#define _LIBCPP_BUILDING_MUTEX
 #include "mutex"
 #include "limits"
 #include "system_error"
Index: libcxx/trunk/src/system_error.cpp
===
--- libcxx/trunk/src/system_error.cpp
+++ libcxx/trunk/src/system_error.cpp
@@ -9,7 +9,6 @@
 
 #include "__config"
 
-#define _LIBCPP_BUILDING_SYSTEM_ERROR
 #include "system_error"
 
 #include "include/config_elast.h"
Index: libcxx/trunk/src/new.cpp
===
--- libcxx/trunk/src/new.cpp
+++ libcxx/trunk/src/new.cpp
@@ -7,8 +7,6 @@
 //
 //===--===//
 
-#define _LIBCPP_BUILDING_NEW
-
 #include 
 
 #include "new"
Index: libcxx/trunk/src/shared_mutex.cpp
===
--- libcxx/trunk/src/shared_mutex.cpp
+++ libcxx/trunk/src/shared_mutex.cpp
@@ -10,7 +10,6 @@
 #include "__config"
 #ifndef _LIBCPP_HAS_NO_THREADS
 
-#define _LIBCPP_BUILDING_SHARED_MUTEX
 #include "shared_mutex"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
Index: libcxx/trunk/src/utility.cpp
===
--- libcxx/trunk/src/utility.cpp
+++ libcxx/trunk/src/utility.cpp
@@ -7,7 +7,6 @@
 //
 //===--===//
 
-#define _LIBCPP_BUILDING_UTILITY
 #include "utility"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
Index: libcxx/trunk/include/functional
===
--- libcxx/trunk/include/functional
+++ libcxx/trunk/include/functional
@@ -2005,7 +2005,7 @@
 
 template  struct __ph {};
 
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 _LIBCPP_FUNC_VIS extern const __ph<1>   _1;
 _LIBCPP_FUNC_VIS extern const __ph<2>   _2;
 _LIBCPP_FUNC_VIS extern const __ph<3>   _3;
@@ -2027,7 +2027,7 @@
 /* _LIBCPP_INLINE_VAR */ constexpr __ph<8>   _8{};
 /* _LIBCPP_INLINE_VAR */ constexpr __ph<9>   _9{};
 /* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{};
-#endif // 

[libcxx] r338475 - [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY

2018-07-31 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Jul 31 19:08:59 2018
New Revision: 338475

URL: http://llvm.org/viewvc/llvm-project?rev=338475=rev
Log:
[libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since 
_LIBCPP_BUILDING_LIBRARY

Summary: As suggested by Marshall in https://reviews.llvm.org/D49914

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

Modified:
libcxx/trunk/include/__functional_base
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/functional
libcxx/trunk/include/memory
libcxx/trunk/include/new
libcxx/trunk/include/shared_mutex
libcxx/trunk/include/system_error
libcxx/trunk/include/utility
libcxx/trunk/src/bind.cpp
libcxx/trunk/src/memory.cpp
libcxx/trunk/src/mutex.cpp
libcxx/trunk/src/new.cpp
libcxx/trunk/src/shared_mutex.cpp
libcxx/trunk/src/system_error.cpp
libcxx/trunk/src/utility.cpp

Modified: libcxx/trunk/include/__functional_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__functional_base?rev=338475=338474=338475=diff
==
--- libcxx/trunk/include/__functional_base (original)
+++ libcxx/trunk/include/__functional_base Tue Jul 31 19:08:59 2018
@@ -561,7 +561,7 @@ struct __is_transparent<_Tp, _Up,
 
 struct _LIBCPP_TEMPLATE_VIS allocator_arg_t { };
 
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MEMORY)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 extern const allocator_arg_t allocator_arg;
 #else
 /* _LIBCPP_INLINE_VAR */ constexpr allocator_arg_t allocator_arg = 
allocator_arg_t();

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=338475=338474=338475=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Tue Jul 31 19:08:59 2018
@@ -74,7 +74,7 @@ struct _LIBCPP_TYPE_VIS defer_lock_t {};
 struct _LIBCPP_TYPE_VIS try_to_lock_t {};
 struct _LIBCPP_TYPE_VIS adopt_lock_t {};
 
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_MUTEX)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 
 extern const defer_lock_t  defer_lock;
 extern const try_to_lock_t try_to_lock;

Modified: libcxx/trunk/include/functional
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/functional?rev=338475=338474=338475=diff
==
--- libcxx/trunk/include/functional (original)
+++ libcxx/trunk/include/functional Tue Jul 31 19:08:59 2018
@@ -2005,7 +2005,7 @@ namespace placeholders
 
 template  struct __ph {};
 
-#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
+#if defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 _LIBCPP_FUNC_VIS extern const __ph<1>   _1;
 _LIBCPP_FUNC_VIS extern const __ph<2>   _2;
 _LIBCPP_FUNC_VIS extern const __ph<3>   _3;
@@ -2027,7 +2027,7 @@ _LIBCPP_FUNC_VIS extern const __ph<10> _
 /* _LIBCPP_INLINE_VAR */ constexpr __ph<8>   _8{};
 /* _LIBCPP_INLINE_VAR */ constexpr __ph<9>   _9{};
 /* _LIBCPP_INLINE_VAR */ constexpr __ph<10> _10{};
-#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_BIND)
+#endif // defined(_LIBCPP_CXX03_LANG) || defined(_LIBCPP_BUILDING_LIBRARY)
 
 }  // placeholders
 

Modified: libcxx/trunk/include/memory
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/memory?rev=338475=338474=338475=diff
==
--- libcxx/trunk/include/memory (original)
+++ libcxx/trunk/include/memory Tue Jul 31 19:08:59 2018
@@ -3511,7 +3511,7 @@ public:
 explicit __shared_count(long __refs = 0) _NOEXCEPT
 : __shared_owners_(__refs) {}
 
-#if defined(_LIBCPP_BUILDING_MEMORY) && \
+#if defined(_LIBCPP_BUILDING_LIBRARY) && \
 
defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
 void __add_shared() _NOEXCEPT;
 bool __release_shared() _NOEXCEPT;
@@ -3549,7 +3549,7 @@ protected:
 virtual ~__shared_weak_count();
 
 public:
-#if defined(_LIBCPP_BUILDING_MEMORY) && \
+#if defined(_LIBCPP_BUILDING_LIBRARY) && \
 
defined(_LIBCPP_DEPRECATED_ABI_LEGACY_LIBRARY_DEFINITIONS_FOR_INLINE_FUNCTIONS)
 void __add_shared() _NOEXCEPT;
 void __add_weak() _NOEXCEPT;
@@ -5549,7 +5549,7 @@ struct _LIBCPP_TYPE_VIS pointer_safety
 #endif
 
 #if !defined(_LIBCPP_ABI_POINTER_SAFETY_ENUM_TYPE) && \
-defined(_LIBCPP_BUILDING_MEMORY)
+defined(_LIBCPP_BUILDING_LIBRARY)
 _LIBCPP_FUNC_VIS pointer_safety get_pointer_safety() _NOEXCEPT;
 #else
 // This function is only offered in C++03 under ABI v1.

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=338475=338474=338475=diff

[libcxxabi] r338475 - [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY

2018-07-31 Thread Louis Dionne via cfe-commits
Author: ldionne
Date: Tue Jul 31 19:08:59 2018
New Revision: 338475

URL: http://llvm.org/viewvc/llvm-project?rev=338475=rev
Log:
[libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since 
_LIBCPP_BUILDING_LIBRARY

Summary: As suggested by Marshall in https://reviews.llvm.org/D49914

Reviewers: mclow.lists, EricWF

Subscribers: christof, dexonsmith, cfe-commits

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

Modified:
libcxxabi/trunk/src/stdlib_exception.cpp
libcxxabi/trunk/src/stdlib_new_delete.cpp

Modified: libcxxabi/trunk/src/stdlib_exception.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/stdlib_exception.cpp?rev=338475=338474=338475=diff
==
--- libcxxabi/trunk/src/stdlib_exception.cpp (original)
+++ libcxxabi/trunk/src/stdlib_exception.cpp Tue Jul 31 19:08:59 2018
@@ -8,7 +8,6 @@
 
//===--===//
 
 #define _LIBCPP_BUILDING_LIBRARY
-#define _LIBCPP_BUILDING_NEW
 #include 
 #include 
 

Modified: libcxxabi/trunk/src/stdlib_new_delete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/stdlib_new_delete.cpp?rev=338475=338474=338475=diff
==
--- libcxxabi/trunk/src/stdlib_new_delete.cpp (original)
+++ libcxxabi/trunk/src/stdlib_new_delete.cpp Tue Jul 31 19:08:59 2018
@@ -9,7 +9,6 @@
 // This file implements the new and delete operators.
 
//===--===//
 
-#define _LIBCPP_BUILDING_NEW
 #define _LIBCPP_BUILDING_LIBRARY
 #include "__cxxabi_config.h"
 #include 


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


[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-31 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- updated this revision to Diff 158450.
0x8000- added a comment.

Add reference to 5.1.1 Use symbolic names instead of literal values in code 

 in the documentation.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tidy/readability/MagicNumbersCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-magic-numbers.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-magic-numbers.rst
  test/clang-tidy/readability-magic-numbers.cpp

Index: test/clang-tidy/readability-magic-numbers.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-magic-numbers.cpp
@@ -0,0 +1,199 @@
+// RUN: %check_clang_tidy %s readability-magic-numbers %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: readability-magic-numbers.IgnoredIntegerValues, value: "0;1;2;10;100;"}, \
+// RUN:   {key: readability-magic-numbers.IgnoredFloatingPointValues, value: "3.14;2.71828;9.81;1.0;101.0;0x1.2p3"}, \
+// RUN:   {key: readability-magic-numbers.IgnorePowersOf2IntegerValues, value: 1}]}' \
+// RUN: --
+
+template 
+struct ValueBucket {
+  T value[V];
+};
+
+int BadGlobalInt = 5;
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+int IntSquarer(int param) {
+  return param * param;
+}
+
+void BuggyFunction() {
+  int BadLocalInt = 6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  (void)IntSquarer(7);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int LocalArray[15];
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  for (int ii = 0; ii < 22; ++ii)
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 22 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+  {
+LocalArray[ii] = 3 * ii;
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+  }
+
+  ValueBucket Bucket;
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 66 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+}
+
+class TwoIntContainer {
+public:
+  TwoIntContainer(int val) : anotherMember(val * val), yetAnotherMember(6), anotherConstant(val + val) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:73: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int getValue() const;
+
+private:
+  int oneMember = 9;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int anotherMember;
+
+  int yetAnotherMember;
+
+  const int oneConstant = 2;
+
+  const int anotherConstant;
+};
+
+int ValueArray[] = {3, 5};
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+float FloatPiVariable = 3.1415926535f;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 3.1415926535f is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+double DoublePiVariable = 6.283185307;
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 6.283185307 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+float SomeFloats[] = {0.5, 0x1.2p4};
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 0.5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: 0x1.2p4 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+int getAnswer() {
+  if (ValueArray[0] < ValueArray[1])
+return ValueArray[1];
+
+  return -3; // FILENOTFOUND
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+}
+
+/*
+ * Clean code
+ */
+
+#define INT_MACRO 5
+
+const int GoodGlobalIntConstant = 42;
+
+constexpr int AlsoGoodGlobalIntConstant = 42;
+
+int InitializedByMacro = INT_MACRO;
+
+void SolidFunction() {
+  const int GoodLocalIntConstant = 43;
+
+  (void)IntSquarer(GoodLocalIntConstant);
+
+  int LocalArray[INT_MACRO];
+
+  

[PATCH] D49997: [libcxx] Fix _LIBCPP_NO_EXCEPTIONS redefined warning

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

I'm fine with this; it matches the pattern used on line #354 of this file. 
(which is in the 'clang' block).

We don't do anything like this for the IBM or MS compilers - yet.


Repository:
  rCXX libc++

https://reviews.llvm.org/D49997



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


[PATCH] D49715: [analyzer] CallEvent: Add partially working methods for obtaining the callee stack frame.

2018-07-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338474: [analyzer] CallEvent: Add helper methods for 
obtaining the callee stack frame. (authored by dergachev, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49715?vs=157550=158446#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49715

Files:
  cfe/trunk/include/clang/Analysis/ConstructionContext.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
  cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
@@ -581,6 +581,14 @@
 return svalBuilder.evalBinOp(ST, Op, LHS, RHS, T);
   }
 
+  /// By looking at a certain item that may be potentially part of an object's
+  /// ConstructionContext, retrieve such object's location. A particular
+  /// statement can be transparently passed as \p Item in most cases.
+  static Optional
+  getObjectUnderConstruction(ProgramStateRef State,
+ const ConstructionContextItem ,
+ const LocationContext *LC);
+
 protected:
   /// evalBind - Handle the semantics of binding a value to a specific location.
   ///  This method is used by evalStore, VisitDeclStmt, and others.
@@ -773,13 +781,6 @@
const ConstructionContextItem ,
const LocationContext *LC);
 
-  /// If the given statement corresponds to an object under construction,
-  /// being part of its construciton context, retrieve that object's location.
-  static Optional
-  getObjectUnderConstruction(ProgramStateRef State,
- const ConstructionContextItem ,
- const LocationContext *LC);
-
   /// If the given expression corresponds to a temporary that was used for
   /// passing into an elidable copy/move constructor and that constructor
   /// was actually elided, track that we also need to elide the destructor.
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
@@ -29,6 +29,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
@@ -404,6 +405,46 @@
   /// \p D must not be null.
   static bool isVariadic(const Decl *D);
 
+  /// Returns AnalysisDeclContext for the callee stack frame.
+  /// Currently may fail; returns null on failure.
+  AnalysisDeclContext *getCalleeAnalysisDeclContext() const;
+
+  /// Returns the callee stack frame. That stack frame will only be entered
+  /// during analysis if the call is inlined, but it may still be useful
+  /// in intermediate calculations even if the call isn't inlined.
+  /// May fail; returns null on failure.
+  const StackFrameContext *getCalleeStackFrame() const;
+
+  /// Returns memory location for a parameter variable within the callee stack
+  /// frame. May fail; returns null on failure.
+  const VarRegion *getParameterLocation(unsigned Index) const;
+
+  /// Returns true if on the current path, the argument was constructed by
+  /// calling a C++ constructor over it. This is an internal detail of the
+  /// analysis which doesn't necessarily represent the program semantics:
+  /// if we are supposed to construct an argument directly, we may still
+  /// not do that because we don't know how (i.e., construction context is
+  /// unavailable in the CFG or not supported by the analyzer).
+  bool isArgumentConstructedDirectly(unsigned Index) const {
+// This assumes that the object was not yet removed from the state.
+return ExprEngine::getObjectUnderConstruction(
+getState(), {getOriginExpr(), Index}, getCalleeStackFrame()).hasValue();
+  }
+
+  /// Some calls have parameter numbering mismatched from argument numbering.
+  /// This function converts an argument index to the corresponding
+  /// parameter index. Returns None is the argument doesn't correspond
+  /// to any parameter variable.
+  Optional getAdjustedParameterIndex(unsigned ArgumentIndex) const {
+if (dyn_cast_or_null(getOriginExpr()) &&
+dyn_cast_or_null(getDecl())) {
+  // For member operator calls argument 0 on the 

r338473 - Speculative fix for buildbot failures after r338464.

2018-07-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 31 18:57:49 2018
New Revision: 338473

URL: http://llvm.org/viewvc/llvm-project?rev=338473=rev
Log:
Speculative fix for buildbot failures after r338464.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=338473=338472=338473=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jul 31 18:57:49 2018
@@ -6012,7 +6012,8 @@ static void checkAttributesAfterMerging(
   // Check the attributes on the function type, if any.
   if (const auto *FD = dyn_cast()) {
 for (TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();
- auto ATL = TL.getAsAdjusted();
+ auto ATL = TL ? TL.getAsAdjusted()
+   : AttributedTypeLoc();
  TL = ATL.getModifiedLoc()) {
   // The [[lifetimebound]] attribute can be applied to the implicit object
   // parameter of a non-static member function (other than a ctor or dtor)


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


r338474 - [analyzer] CallEvent: Add helper methods for obtaining the callee stack frame.

2018-07-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Jul 31 18:58:15 2018
New Revision: 338474

URL: http://llvm.org/viewvc/llvm-project?rev=338474=rev
Log:
[analyzer] CallEvent: Add helper methods for obtaining the callee stack frame.

Newly added methods allow reasoning about the stack frame of the call (as
opposed to the stack frame on which the call was made, which was always
available) - obtain the stack frame context, obtain parameter regions - even if
the call is not going to be (or was not) inlined, i.e. even if the analysis
has never actually entered the stack frame.

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

Modified:
cfe/trunk/include/clang/Analysis/ConstructionContext.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/StaticAnalyzer/Core/CallEvent.cpp

Modified: cfe/trunk/include/clang/Analysis/ConstructionContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ConstructionContext.h?rev=338474=338473=338474=diff
==
--- cfe/trunk/include/clang/Analysis/ConstructionContext.h (original)
+++ cfe/trunk/include/clang/Analysis/ConstructionContext.h Tue Jul 31 18:58:15 
2018
@@ -112,6 +112,13 @@ public:
   ConstructionContextItem(const ObjCMessageExpr *ME, unsigned Index)
   : Data(ME), Kind(ArgumentKind), Index(Index) {}
 
+  // A polymorphic version of the previous calls with dynamic type check.
+  ConstructionContextItem(const Expr *E, unsigned Index)
+  : Data(E), Kind(ArgumentKind), Index(Index) {
+assert(isa(E) || isa(E) ||
+   isa(E));
+  }
+
   ConstructionContextItem(const CXXCtorInitializer *Init)
   : Data(Init), Kind(InitializerKind), Index(0) {}
 

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=338474=338473=338474=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Tue 
Jul 31 18:58:15 2018
@@ -29,6 +29,7 @@
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ProgramState_Fwd.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/SVals.h"
@@ -404,6 +405,46 @@ public:
   /// \p D must not be null.
   static bool isVariadic(const Decl *D);
 
+  /// Returns AnalysisDeclContext for the callee stack frame.
+  /// Currently may fail; returns null on failure.
+  AnalysisDeclContext *getCalleeAnalysisDeclContext() const;
+
+  /// Returns the callee stack frame. That stack frame will only be entered
+  /// during analysis if the call is inlined, but it may still be useful
+  /// in intermediate calculations even if the call isn't inlined.
+  /// May fail; returns null on failure.
+  const StackFrameContext *getCalleeStackFrame() const;
+
+  /// Returns memory location for a parameter variable within the callee stack
+  /// frame. May fail; returns null on failure.
+  const VarRegion *getParameterLocation(unsigned Index) const;
+
+  /// Returns true if on the current path, the argument was constructed by
+  /// calling a C++ constructor over it. This is an internal detail of the
+  /// analysis which doesn't necessarily represent the program semantics:
+  /// if we are supposed to construct an argument directly, we may still
+  /// not do that because we don't know how (i.e., construction context is
+  /// unavailable in the CFG or not supported by the analyzer).
+  bool isArgumentConstructedDirectly(unsigned Index) const {
+// This assumes that the object was not yet removed from the state.
+return ExprEngine::getObjectUnderConstruction(
+getState(), {getOriginExpr(), Index}, 
getCalleeStackFrame()).hasValue();
+  }
+
+  /// Some calls have parameter numbering mismatched from argument numbering.
+  /// This function converts an argument index to the corresponding
+  /// parameter index. Returns None is the argument doesn't correspond
+  /// to any parameter variable.
+  Optional getAdjustedParameterIndex(unsigned ArgumentIndex) const {
+if (dyn_cast_or_null(getOriginExpr()) &&
+dyn_cast_or_null(getDecl())) {
+  // For member operator calls argument 0 on the expression corresponds
+  // to implicit this-parameter on the declaration.
+  return (ArgumentIndex > 0) ? Optional(ArgumentIndex - 1) : 
None;
+}
+return ArgumentIndex;
+  }
+
   // Iterator access to formal parameters and their types.
 private:
   struct GetTypeFn {

Modified: 

[PATCH] D50101: [asan] Update a vector's storage annotation during destruction.

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

I'm OK with this.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50101



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


[PATCH] D50123: [OpenEmbedded] Explicitly specify -stdlib and -rtlib in tests

2018-07-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

This broke all our bots so I plan on submitting this if I don't hear back soon.


Repository:
  rC Clang

https://reviews.llvm.org/D50123



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


[PATCH] D50123: [OpenEmbedded] Explicitly specify -stdlib and -rtlib in tests

2018-07-31 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added reviewers: rsmith, mgrang, Hahnfeld.
Herald added a subscriber: cfe-commits.

Tests added r338294 implicitly assume that the libstdc++ is the standard
C++ library and libgcc is the runtime library, but that's not the case
when the user configures Clang to use libc++ or compiler-rt when these
tests will break. Explicitly request libstdc++ and libgcc when invoking
clang in these tests to avoid that.


Repository:
  rC Clang

https://reviews.llvm.org/D50123

Files:
  clang/test/Driver/linux-header-search.cpp
  clang/test/Driver/linux-ld.c


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1816,7 +1816,7 @@
 
 // Check whether the OpenEmbedded ARM libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=arm-oe-linux-gnueabi \
+// RUN: --target=arm-oe-linux-gnueabi -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -1835,7 +1835,7 @@
 
 // Check whether the OpenEmbedded AArch64 libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=aarch64-oe-linux \
+// RUN: --target=aarch64-oe-linux -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 
Index: clang/test/Driver/linux-header-search.cpp
===
--- clang/test/Driver/linux-header-search.cpp
+++ clang/test/Driver/linux-header-search.cpp
@@ -496,7 +496,7 @@
 
 // Check header search on OpenEmbedded ARM.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
-// RUN: -target arm-oe-linux-gnueabi \
+// RUN: -target arm-oe-linux-gnueabi -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -507,7 +507,7 @@
 
 // Check header search on OpenEmbedded AArch64.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
-// RUN: -target aarch64-oe-linux \
+// RUN: -target aarch64-oe-linux -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 


Index: clang/test/Driver/linux-ld.c
===
--- clang/test/Driver/linux-ld.c
+++ clang/test/Driver/linux-ld.c
@@ -1816,7 +1816,7 @@
 
 // Check whether the OpenEmbedded ARM libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=arm-oe-linux-gnueabi \
+// RUN: --target=arm-oe-linux-gnueabi -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -1835,7 +1835,7 @@
 
 // Check whether the OpenEmbedded AArch64 libs are added correctly.
 // RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
-// RUN: --target=aarch64-oe-linux \
+// RUN: --target=aarch64-oe-linux -rtlib=libgcc \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 
Index: clang/test/Driver/linux-header-search.cpp
===
--- clang/test/Driver/linux-header-search.cpp
+++ clang/test/Driver/linux-header-search.cpp
@@ -496,7 +496,7 @@
 
 // Check header search on OpenEmbedded ARM.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
-// RUN: -target arm-oe-linux-gnueabi \
+// RUN: -target arm-oe-linux-gnueabi -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_arm_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-ARM %s
 
@@ -507,7 +507,7 @@
 
 // Check header search on OpenEmbedded AArch64.
 // RUN: %clang -no-canonical-prefixes %s -### -fsyntax-only 2>&1 \
-// RUN: -target aarch64-oe-linux \
+// RUN: -target aarch64-oe-linux -stdlib=libstdc++ \
 // RUN: --sysroot=%S/Inputs/openembedded_aarch64_linux_tree \
 // RUN:   | FileCheck --check-prefix=CHECK-OE-AARCH64 %s
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49754: Add -m(no-)spe, and e500 CPU definitions and support to clang

2018-07-31 Thread vit9696 via Phabricator via cfe-commits
vit9696 added a comment.

Hello,

Thank you for working this. I tried the change and have a couple of suggestions:

1. -mspe option in GCC works like -mspe=yes or -mspe=no. While it does make 
sense to have it the way you did (-mno-spe and -mspe) it would be nice to have 
at least have an alias for compiler compatibility.
2. One of the known CPU examples with SPE support is MPC8548 
(https://www.nxp.com/docs/en/reference-manual/MPC8548ERM.pdf), it will be nice 
to have it recognised in -mcpu argument as 8548 like in GCC.

Other than that, it appears that the implementation has several issues. Since 
this patch is partially unmerged yet, I did not use bugzilla but include the 
information below.

1. The following code makes the compiler to crash:

  struct a {
long double b() const;
  };
  class c {
struct C {
  C(long d) : e(d) {}
  long e;
  double f;
};
unsigned g;
C h[5];
unsigned i;
void k(C d) {
  long j(g);
  if (j)
h[i] = d;
}
c (const a &);
  };
  c ::fn(const a ) {
double l = d.b();
k(l);
  }



  $ clang-7 -cc1 -triple powerpc-gnu-linux-eabi -emit-obj -target-cpu ppc 
-target-feature +spe -O2  t.cpp
  t.cpp:23:1: warning: control reaches end of non-void function
  }
  ^
  Stack dump:
  0.Program arguments: clang-7 -cc1 -triple powerpc-gnu-linux-eabi 
-emit-obj -target-cpu ppc -target-feature +spe -O2 t.cpp 
  1. parser at end of file
  2.Code generation
  3.Running pass 'Function Pass Manager' on module 't.cpp'.
  4.Running pass 'PowerPC DAG->DAG Pattern Instruction Selection' on 
function '@_ZN1c2fnERK1a'
  0  clang-7  0x00010a6e722d 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 37
  1  clang-7  0x00010a6e760d SignalHandler(int) + 185
  2  libsystem_platform.dylib 0x7fff6a4baf5a _sigtramp + 26
  3  clang-7  0x00010ac4948a 
llvm::DenseMapBase, llvm::detail::DenseMapPair >, unsigned int, unsigned int, llvm::DenseMapInfo, 
llvm::detail::DenseMapPair >::find(unsigned int 
const&) + 18
  4  clang-7  0x00010ac3e23e 
llvm::DAGTypeLegalizer::ExpandIntRes_SIGN_EXTEND(llvm::SDNode*, llvm::SDValue&, 
llvm::SDValue&) + 514
  5  clang-7  0x00010ac3a670 
llvm::DAGTypeLegalizer::ExpandIntegerResult(llvm::SDNode*, unsigned int) + 1774
  6  clang-7  0x00010ac49793 llvm::DAGTypeLegalizer::run() 
+ 531
  7  clang-7  0x00010ac4c1cd 
llvm::SelectionDAG::LegalizeTypes() + 57
  8  clang-7  0x00010acde3da 
llvm::SelectionDAGISel::CodeGenAndEmitDAG() + 468
  9  clang-7  0x00010acdd8a9 
llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) + 5521
  10 clang-7  0x00010acdbbc9 
llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 1433
  11 clang-7  0x000109e18962 (anonymous 
namespace)::PPCDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) + 70
  12 clang-7  0x00010a20d353 
llvm::MachineFunctionPass::runOnFunction(llvm::Function&) + 113
  13 clang-7  0x00010a393af4 
llvm::FPPassManager::runOnFunction(llvm::Function&) + 338
  14 clang-7  0x00010a393c89 
llvm::FPPassManager::runOnModule(llvm::Module&) + 49
  15 clang-7  0x00010a393f66 
llvm::legacy::PassManagerImpl::run(llvm::Module&) + 556
  16 clang-7  0x00010a81a77b 
clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::HeaderSearchOptions 
const&, clang::CodeGenOptions const&, clang::TargetOptions const&, 
clang::LangOptions const&, llvm::DataLayout const&, llvm::Module*, 
clang::BackendAction, std::__1::unique_ptr >) + 13071
  17 clang-7  0x00010a97e61c 
clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 888
  18 clang-7  0x00010b14479c clang::ParseAST(clang::Sema&, 
bool, bool) + 458
  19 clang-7  0x00010aaff2b9 
clang::FrontendAction::Execute() + 67
  20 clang-7  0x00010aad1ac0 
clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 664
  21 clang-7  0x00010ab3352c 
clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1267
  22 clang-7  0x000109c49f00 cc1_main(llvm::ArrayRef, char const*, void*) + 1138
  23 clang-7  0x000109c4923d main + 7612
  24 libdyld.dylib0x7fff6a1ac015 start + 1
  25 libdyld.dylib0x000b start + 2514829303
  Segmentation fault: 11



2. Several instructions seem to fail at variable allocation due to improper 
type. For example, the following code will overwrite the variables on stack and 
crash:

  int global_var1;
  
  void test_func2(void) { }
  
  void test_func(int a1, long long a2, void *a3, int *a4, int *a5) {
  int *ptr = _var1;
  
  if (ptr != 0) {
  

r338471 - AMDGPU: Add clamp bit to dot builtins

2018-07-31 Thread Konstantin Zhuravlyov via cfe-commits
Author: kzhuravl
Date: Tue Jul 31 18:32:21 2018
New Revision: 338471

URL: http://llvm.org/viewvc/llvm-project?rev=338471=rev
Log:
AMDGPU: Add clamp bit to dot builtins

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

Added:
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err-clamp.cl
Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=338471=338470=338471=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Tue Jul 31 18:32:21 2018
@@ -124,13 +124,13 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h,
 // Deep learning builtins.
 
//===--===//
 
-TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hf", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSi", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUi", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSi", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUi", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSi", "nc", "dl-insts")
-TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUi", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_fdot2, "fV2hV2hfIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot2, "SiV2SsV2SsSiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot2, "UiV2UsV2UsUiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot4, "SiSiSiSiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot4, "UiUiUiUiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_sdot8, "SiSiSiSiIb", "nc", "dl-insts")
+TARGET_BUILTIN(__builtin_amdgcn_udot8, "UiUiUiUiIb", "nc", "dl-insts")
 
 
//===--===//
 // Special builtins.

Added: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err-clamp.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err-clamp.cl?rev=338471=auto
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err-clamp.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err-clamp.cl Tue Jul 
31 18:32:21 2018
@@ -0,0 +1,25 @@
+// REQUIRES: amdgpu-registered-target
+
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -target-cpu gfx906 -verify 
-S -emit-llvm -o - %s
+
+typedef unsigned int uint;
+typedef half __attribute__((ext_vector_type(2))) half2;
+typedef short __attribute__((ext_vector_type(2))) short2;
+typedef unsigned short __attribute__((ext_vector_type(2))) ushort2;
+
+kernel void builtins_amdgcn_dl_insts_err(
+global float *fOut, global int *siOut, global uint *uiOut,
+half2 v2hA, half2 v2hB, float fC,
+short2 v2ssA, short2 v2ssB, int siA, int siB, int siC,
+ushort2 v2usA, ushort2 v2usB, uint uiA, uint uiB, uint uiC, uint isClamp) {
+  fOut[0] = __builtin_amdgcn_fdot2(v2hA, v2hB, fC, isClamp == 0 ? false : 
true); // expected-error {{'__builtin_amdgcn_fdot2' must be a constant 
integer}}
+
+  siOut[0] = __builtin_amdgcn_sdot2(v2ssA, v2ssB, siC, isClamp == 0 ? false : 
true); // expected-error {{'__builtin_amdgcn_sdot2' must be a constant integer}}
+  uiOut[0] = __builtin_amdgcn_udot2(v2usA, v2usB, uiC, isClamp == 0 ? false : 
true); // expected-error {{'__builtin_amdgcn_udot2' must be a constant integer}}
+
+  siOut[1] = __builtin_amdgcn_sdot4(siA, siB, siC, isClamp == 0 ? false : 
true); // expected-error {{'__builtin_amdgcn_sdot4' must be a constant 
integer}}
+  uiOut[1] = __builtin_amdgcn_udot4(uiA, uiB, uiC, isClamp == 0 ? false : 
true); // expected-error {{'__builtin_amdgcn_udot4' must be a constant 
integer}}
+
+  siOut[2] = __builtin_amdgcn_sdot8(siA, siB, siC, isClamp == 0 ? false : 
true); // expected-error {{'__builtin_amdgcn_sdot8' must be a constant 
integer}}
+  uiOut[2] = __builtin_amdgcn_udot8(uiA, uiB, uiC, isClamp == 0 ? false : 
true); // expected-error {{'__builtin_amdgcn_udot8' must be a constant 
integer}}
+}

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl?rev=338471=338470=338471=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn-dl-insts-err.cl Tue Jul 31 
18:32:21 2018
@@ -12,14 +12,24 @@ kernel void builtins_amdgcn_dl_insts_err
 half2 v2hA, half2 v2hB, float fC,
  

[PATCH] D50122: Complex Variable defined in InitCapture Crash fix

2018-07-31 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Hi Balaji,
Can you try to manually reduce the attached testcase? Its really difficult to 
understand exactly what is actually happening here, and why your fix is 
correct, without having a minimal reproducer. Ideally there would just be a few 
decls that succinctly demonstrate what the problem is.

Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D50122



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


[PATCH] D49396: [WebAssembly] Support for atomic.wait / atomic.wake builtins

2018-07-31 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:38
+// Atomic wait and wake.
+BUILTIN(__builtin_wasm_atomic_wait_i32, "Uii*iLLi", "n")
+BUILTIN(__builtin_wasm_atomic_wait_i64, "UiLLi*LLiLLi", "n")

dschuff wrote:
> So this means that the signature is basically `unsigned int 
> __builtin_wasm_atomic_wait_i32(int *, int, long long)`? We should maybe make 
> it `int __builtin_wasm_atomic_wait_i32(const unsigned char *, int, unsigned 
> long long)`. Returning int so that you could define a C enum with the 
> possible return values and compare without type coercion; unsigned char * so 
> that it aliases with everything (i.e. a byte ptr), and unsigned long long 
> since a negative relative timeout isn't meaningful(?). Not sure whether we 
> should use int or unsigned int as the expected value, can't think of any 
> particular reason right now to use one or the other.
> 
> Likewise with the other signatures.
> Returning int so that you could define a C enum with the possible return 
> values and compare without type coercion;
Done.

> unsigned char * so that it aliases with everything (i.e. a byte ptr),
From this pointer a value will be loaded and compared with the expected value, 
which is an int. Shouldn't this be an int pointer then? Not sure why it should 
alias with a byte ptr.

> and unsigned long long since a negative relative timeout isn't meaningful(?).
[[ 
https://github.com/WebAssembly/threads/blob/master/proposals/threads/Overview.md#wait
 | Timeouts can be negative ]], in which case it never expires. The wake count 
of `atomics.wake` builtin can be negative too, in which case it waits for all 
waiters.

> Not sure whether we should use int or unsigned int as the expected value, 
> can't think of any particular reason right now to use one or the other.
We didn't impose any restrictions other than it is an int in the spec, so I 
think it should be a (signed) int?


Repository:
  rC Clang

https://reviews.llvm.org/D49396



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


[PATCH] D49396: [WebAssembly] Support for atomic.wait / atomic.wake builtins

2018-07-31 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin updated this revision to Diff 158434.
aheejin marked an inline comment as done.
aheejin added a comment.

- Changed types


Repository:
  rC Clang

https://reviews.llvm.org/D49396

Files:
  include/clang/Basic/BuiltinsWebAssembly.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGen/builtins-wasm.c


Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -50,3 +50,21 @@
 // WEBASSEMBLY32: call void @llvm.wasm.rethrow()
 // WEBASSEMBLY64: call void @llvm.wasm.rethrow()
 }
+
+int f8(int *addr, int expected, long long timeout) {
+  return __builtin_wasm_atomic_wait_i32(addr, expected, timeout);
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 
%{{.*}}, i64 %{{.*}})
+}
+
+int f9(long long *addr, long long expected, long long timeout) {
+  return __builtin_wasm_atomic_wait_i64(addr, expected, timeout);
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 
%{{.*}}, i64 %{{.*}})
+}
+
+unsigned long long f10(int *addr, long long wake_count) {
+  return __builtin_wasm_atomic_wake(addr, wake_count);
+// WEBASSEMBLY32: call i64 @llvm.wasm.atomic.wake(i32* %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY64: call i64 @llvm.wasm.atomic.wake(i32* %{{.*}}, i64 %{{.*}})
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -12081,6 +12081,26 @@
 Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_rethrow);
 return Builder.CreateCall(Callee);
   }
+  case WebAssembly::BI__builtin_wasm_atomic_wait_i32: {
+Value *Addr = EmitScalarExpr(E->getArg(0));
+Value *Expected = EmitScalarExpr(E->getArg(1));
+Value *Timeout = EmitScalarExpr(E->getArg(2));
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_atomic_wait_i32);
+return Builder.CreateCall(Callee, {Addr, Expected, Timeout});
+  }
+  case WebAssembly::BI__builtin_wasm_atomic_wait_i64: {
+Value *Addr = EmitScalarExpr(E->getArg(0));
+Value *Expected = EmitScalarExpr(E->getArg(1));
+Value *Timeout = EmitScalarExpr(E->getArg(2));
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_atomic_wait_i64);
+return Builder.CreateCall(Callee, {Addr, Expected, Timeout});
+  }
+  case WebAssembly::BI__builtin_wasm_atomic_wake: {
+Value *Addr = EmitScalarExpr(E->getArg(0));
+Value *WakeCount = EmitScalarExpr(E->getArg(1));
+Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_atomic_wake);
+return Builder.CreateCall(Callee, {Addr, WakeCount});
+  }
 
   default:
 return nullptr;
Index: include/clang/Basic/BuiltinsWebAssembly.def
===
--- include/clang/Basic/BuiltinsWebAssembly.def
+++ include/clang/Basic/BuiltinsWebAssembly.def
@@ -34,4 +34,9 @@
 BUILTIN(__builtin_wasm_throw, "vUiv*", "r")
 BUILTIN(__builtin_wasm_rethrow, "v", "r")
 
+// Atomic wait and wake.
+BUILTIN(__builtin_wasm_atomic_wait_i32, "ii*iLLi", "n")
+BUILTIN(__builtin_wasm_atomic_wait_i64, "iLLi*LLiLLi", "n")
+BUILTIN(__builtin_wasm_atomic_wake, "ULLii*LLi", "n")
+
 #undef BUILTIN


Index: test/CodeGen/builtins-wasm.c
===
--- test/CodeGen/builtins-wasm.c
+++ test/CodeGen/builtins-wasm.c
@@ -50,3 +50,21 @@
 // WEBASSEMBLY32: call void @llvm.wasm.rethrow()
 // WEBASSEMBLY64: call void @llvm.wasm.rethrow()
 }
+
+int f8(int *addr, int expected, long long timeout) {
+  return __builtin_wasm_atomic_wait_i32(addr, expected, timeout);
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i32(i32* %{{.*}}, i32 %{{.*}}, i64 %{{.*}})
+}
+
+int f9(long long *addr, long long expected, long long timeout) {
+  return __builtin_wasm_atomic_wait_i64(addr, expected, timeout);
+// WEBASSEMBLY32: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY64: call i32 @llvm.wasm.atomic.wait.i64(i64* %{{.*}}, i64 %{{.*}}, i64 %{{.*}})
+}
+
+unsigned long long f10(int *addr, long long wake_count) {
+  return __builtin_wasm_atomic_wake(addr, wake_count);
+// WEBASSEMBLY32: call i64 @llvm.wasm.atomic.wake(i32* %{{.*}}, i64 %{{.*}})
+// WEBASSEMBLY64: call i64 @llvm.wasm.atomic.wake(i32* %{{.*}}, i64 %{{.*}})
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -12081,6 +12081,26 @@
 Value *Callee = CGM.getIntrinsic(Intrinsic::wasm_rethrow);
 return Builder.CreateCall(Callee);
   }
+  case WebAssembly::BI__builtin_wasm_atomic_wait_i32: {
+Value *Addr = 

[PATCH] D50122: Complex Variable defined in InitCapture Crash fix

2018-07-31 Thread Balaji Iyer via Phabricator via cfe-commits
bviyer created this revision.
bviyer added reviewers: erik.pilkington, ahatanak, arphaman, dexonsmith.
Herald added a subscriber: cfe-commits.

When a variable is defined in the init capture and it is of type struct that is 
dependent on additional structure, its definition is not found. An exception is 
created in the findInstantiatedDecl () function.


Repository:
  rC Clang

https://reviews.llvm.org/D50122

Files:
  lib/Sema/SemaTemplateInstantiate.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/SemaCXX/lambda-init-capture-vardefine.cpp


Index: test/SemaCXX/lambda-init-capture-vardefine.cpp
===
--- /dev/null
+++ test/SemaCXX/lambda-init-capture-vardefine.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++14  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  using a = void;
+template  struct c { static const int d = b; };
+template > struct e : c {};
+template  g h(int);
+template  decltype(h(0)) i;
+template  struct e())>>;
+template  auto func(k &&);
+template  struct l {
+  template  static auto n(k o) {
+return [f{o}](auto) { func([](auto...) -> decltype(f) {}); };
+  }
+};
+template  auto func(k &) { return l::d>::n(o); }
+int main(void) {
+  auto f = [](auto) {};
+  func(f)(1);
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4962,6 +4962,14 @@
   return cast(Inst);
 }
 
+// If the variable is in InitCapture and variable types are of type
+// mentioned in the above comment (the comment starting as "Normally
+// this function...") then its existance won't be known so we have to
+// make an exclusion for them.
+if (const VarDecl *VD = dyn_cast(D))
+  if (VD->isInitCapture())
+return nullptr;
+
 // If we didn't find the decl, then we must have a label decl that hasn't
 // been found yet.  Lazily instantiate it and return it now.
 assert(isa(D));
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -2913,6 +2913,9 @@
   // error recovery.
   if (isa(D))
 return nullptr;
+  if (const VarDecl *VD = dyn_cast(D))
+if (VD->isInitCapture())
+  return nullptr;
 
   // If we didn't find the decl, then we either have a sema bug, or we have a
   // forward reference to a label declaration.  Return null to indicate that


Index: test/SemaCXX/lambda-init-capture-vardefine.cpp
===
--- /dev/null
+++ test/SemaCXX/lambda-init-capture-vardefine.cpp
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 -std=c++14  -fsyntax-only -verify %s
+// RUN: %clang_cc1 -std=c++17  -fsyntax-only -verify %s
+// expected-no-diagnostics
+
+template  using a = void;
+template  struct c { static const int d = b; };
+template > struct e : c {};
+template  g h(int);
+template  decltype(h(0)) i;
+template  struct e())>>;
+template  auto func(k &&);
+template  struct l {
+  template  static auto n(k o) {
+return [f{o}](auto) { func([](auto...) -> decltype(f) {}); };
+  }
+};
+template  auto func(k &) { return l::d>::n(o); }
+int main(void) {
+  auto f = [](auto) {};
+  func(f)(1);
+}
Index: lib/Sema/SemaTemplateInstantiateDecl.cpp
===
--- lib/Sema/SemaTemplateInstantiateDecl.cpp
+++ lib/Sema/SemaTemplateInstantiateDecl.cpp
@@ -4962,6 +4962,14 @@
   return cast(Inst);
 }
 
+// If the variable is in InitCapture and variable types are of type
+// mentioned in the above comment (the comment starting as "Normally
+// this function...") then its existance won't be known so we have to
+// make an exclusion for them.
+if (const VarDecl *VD = dyn_cast(D))
+  if (VD->isInitCapture())
+return nullptr;
+
 // If we didn't find the decl, then we must have a label decl that hasn't
 // been found yet.  Lazily instantiate it and return it now.
 assert(isa(D));
Index: lib/Sema/SemaTemplateInstantiate.cpp
===
--- lib/Sema/SemaTemplateInstantiate.cpp
+++ lib/Sema/SemaTemplateInstantiate.cpp
@@ -2913,6 +2913,9 @@
   // error recovery.
   if (isa(D))
 return nullptr;
+  if (const VarDecl *VD = dyn_cast(D))
+if (VD->isInitCapture())
+  return nullptr;
 
   // If we didn't find the decl, then we either have a sema bug, or we have a
   // forward reference to a label declaration.  Return null to indicate that
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338467 - Avoid exposing name for range-based for '__range' variables in lifetime warnings.

2018-07-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 31 18:03:33 2018
New Revision: 338467

URL: http://llvm.org/viewvc/llvm-project?rev=338467=rev
Log:
Avoid exposing name for range-based for '__range' variables in lifetime 
warnings.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=338467=338466=338467=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Tue Jul 31 18:03:33 
2018
@@ -7875,7 +7875,8 @@ def warn_ret_addr_label : Warning<
 def err_ret_local_block : Error<
   "returning block that lives on the local stack">;
 def note_local_var_initializer : Note<
-  "%select{via initialization of|binding reference}0 variable %1 here">;
+  "%select{via initialization of|binding reference}0 variable "
+  "%select{%2 |}1here">;
 def note_init_with_default_member_initalizer : Note<
   "initializing field %0 with default member initializer">;
 
@@ -7907,13 +7908,14 @@ def note_lifetime_extending_member_decla
   "member with %select{reference|'std::initializer_list'}0 subobject}1 "
   "declared here">;
 def warn_dangling_variable : Warning<
-  "%select{temporary %select{whose address is used as value of|bound to}3 "
-  "%select{%select{|reference }3member of local variable|"
-  "local %select{variable|reference}3}1|"
+  "%select{temporary %select{whose address is used as value of|"
+  "%select{|implicitly }2bound to}4 "
+  "%select{%select{|reference }4member of local variable|"
+  "local %select{variable|reference}4}1|"
   "array backing "
   "%select{initializer list subobject of local variable|"
   "local initializer list}1}0 "
-  "%2 will be destroyed at the end of the full-expression">,
+  "%select{%3 |}2will be destroyed at the end of the full-expression">,
   InGroup;
 def warn_new_dangling_reference : Warning<
   "temporary bound to reference member of allocated object "

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=338467=338466=338467=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Jul 31 18:03:33 2018
@@ -6847,8 +6847,9 @@ void Sema::checkInitializerLifetime(cons
   return false;
 
 Diag(DiagLoc, diag::warn_dangling_variable)
-<< RK << !Entity.getParent() << ExtendingEntity->getDecl()
-<< Init->isGLValue() << DiagRange;
+<< RK << !Entity.getParent()
+<< ExtendingEntity->getDecl()->isImplicit()
+<< ExtendingEntity->getDecl() << Init->isGLValue() << DiagRange;
   }
   break;
 }
@@ -6969,7 +6970,8 @@ void Sema::checkInitializerLifetime(cons
   case IndirectLocalPathEntry::VarInit:
 const VarDecl *VD = cast(Elem.D);
 Diag(VD->getLocation(), diag::note_local_var_initializer)
-<< VD->getType()->isReferenceType() << VD->getDeclName()
+<< VD->getType()->isReferenceType()
+<< VD->isImplicit() << VD->getDeclName()
 << nextPathEntryRange(Path, I + 1, L);
 break;
   }

Modified: cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp?rev=338467=338466=338467=diff
==
--- cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp (original)
+++ cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp Tue Jul 31 18:03:33 2018
@@ -101,7 +101,7 @@ namespace p0936r0_examples {
   std::vector make_vector();
   void use_reversed_range() {
 // FIXME: Don't expose the name of the internal range variable.
-for (auto x : reversed(make_vector())) {} // expected-warning {{temporary 
bound to local reference '__range1'}}
+for (auto x : reversed(make_vector())) {} // expected-warning {{temporary 
implicitly bound to local reference will be destroyed at the end of the 
full-expression}}
   }
 
   template 


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


[PATCH] D50008: [libc++] Remove _LIBCPP_BUILDING_XXX macros, which are redundant since _LIBCPP_BUILDING_LIBRARY

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

This looks fine to me.


Repository:
  rCXX libc++

https://reviews.llvm.org/D50008



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


[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute

2018-07-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
rsmith marked 2 inline comments as done.
Closed by commit rC338464: [P0936R0] add [[clang::lifetimebound]] attribute 
(authored by rsmith, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D49922?vs=158149=158430#toc

Repository:
  rC Clang

https://reviews.llvm.org/D49922

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaInit.cpp
  lib/Sema/SemaType.cpp
  test/SemaCXX/attr-lifetimebound.cpp
  utils/TableGen/ClangAttrEmitter.cpp

Index: utils/TableGen/ClangAttrEmitter.cpp
===
--- utils/TableGen/ClangAttrEmitter.cpp
+++ utils/TableGen/ClangAttrEmitter.cpp
@@ -3305,11 +3305,16 @@
   // Otherwise, generate an appertainsTo check specific to this attribute which
   // checks all of the given subjects against the Decl passed in. Return the
   // name of that check to the caller.
+  //
+  // If D is null, that means the attribute was not applied to a declaration
+  // at all (for instance because it was applied to a type), or that the caller
+  // has determined that the check should fail (perhaps prior to the creation
+  // of the declaration).
   std::string FnName = "check" + Attr.getName().str() + "AppertainsTo";
   std::stringstream SS;
   SS << "static bool " << FnName << "(Sema , const ParsedAttr , ";
   SS << "const Decl *D) {\n";
-  SS << "  if (";
+  SS << "  if (!D || (";
   for (auto I = Subjects.begin(), E = Subjects.end(); I != E; ++I) {
 // If the subject has custom code associated with it, generate a function
 // for it. The function cannot be inlined into this check (yet) because it
@@ -3325,7 +3330,7 @@
 if (I + 1 != E)
   SS << " && ";
   }
-  SS << ") {\n";
+  SS << ")) {\n";
   SS << "S.Diag(Attr.getLoc(), diag::";
   SS << (Warn ? "warn_attribute_wrong_decl_type_str" :
"err_attribute_wrong_decl_type_str");
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -4237,6 +4237,7 @@
 attr_null_unspecified,
 attr_objc_kindof,
 attr_objc_inert_unsafe_unretained,
+attr_lifetimebound,
   };
 
 private:
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -141,6 +141,13 @@
isa(S)}],
  "non-K functions">;
 
+// A subject that matches the implicit object parameter of a non-static member
+// function. Accepted as a function type attribute on the type of such a
+// member function.
+// FIXME: This does not actually ever match currently.
+def ImplicitObjectParameter : SubsetSubject;
+
 // A single argument to an attribute
 class Argument {
   string Name = name;
@@ -1211,6 +1218,13 @@
   let Documentation = [LayoutVersionDocs];
 }
 
+def LifetimeBound : InheritableAttr {
+  let Spellings = [Clang<"lifetimebound", 0>];
+  let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
+  let Documentation = [LifetimeBoundDocs];
+  let LangOpts = [CPlusPlus];
+}
+
 def TrivialABI : InheritableAttr {
   // This attribute does not have a C [[]] spelling because it requires the
   // CPlusPlus language option.
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -7854,6 +7854,13 @@
   "null returned from %select{function|method}0 that requires a non-null return value">,
   InGroup;
 
+def err_lifetimebound_no_object_param : Error<
+  "'lifetimebound' attribute cannot be applied; %select{static |non-}0member "
+  "function has no implicit object parameter">;
+def err_lifetimebound_ctor_dtor : Error<
+  "'lifetimebound' attribute cannot be applied to a "
+  "%select{constructor|destructor}0">;
+
 // CHECK: returning address/reference of stack memory
 def warn_ret_stack_addr_ref : Warning<
   "%select{address of|reference to}0 stack memory associated with "
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -2362,6 +2362,22 @@
   }];
 }
 
+def LifetimeBoundDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``lifetimebound`` attribute indicates that a resource owned by
+a function parameter or implicit object parameter
+is retained by the return value of the annotated function
+(or, for a parameter of a constructor, in the value of the constructed object).
+It is only supported in 

[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute

2018-07-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith marked 3 inline comments as done.
rsmith added inline comments.



Comment at: lib/Sema/SemaInit.cpp:6959
+  case IndirectLocalPathEntry::LifetimeBoundCall:
+// FIXME: Consider adding a note for this.
+break;

aaron.ballman wrote:
> Is this something you intended to handle in this patch and forgot, or are you 
> saving this for a future patch?
It's something I'm going to experiment with and see if it improves the 
diagnostic quality, but not for this patch.



Comment at: test/SemaCXX/attr-lifetimebound.cpp:4
+namespace usage_invalid {
+  // FIXME: Diagnose void return type?
+  void voidreturn(int  [[clang::lifetimebound]]);

aaron.ballman wrote:
> Something you intended to support in this patch?
More like an open question for the standards proposal. I've slightly reworded 
the FIXME to indicate that this is an open question.


https://reviews.llvm.org/D49922



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


r338464 - [P0936R0] add [[clang::lifetimebound]] attribute

2018-07-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 31 17:33:25 2018
New Revision: 338464

URL: http://llvm.org/viewvc/llvm-project?rev=338464=rev
Log:
[P0936R0] add [[clang::lifetimebound]] attribute

This patch adds support for a new attribute, [[clang::lifetimebound]], that
indicates that the lifetime of a function result is related to one of the
function arguments. When walking an initializer to make sure that the lifetime
of the initial value is at least as long as the lifetime of the initialized
object, we step through parameters (including the implicit object parameter of
a non-static member function) that are marked with this attribute.

There's nowhere to write an attribute on the implicit object parameter, so in
lieu of that, it may be applied to a function type (where it appears
immediately after the cv-qualifiers and ref-qualifier, which is as close to a
declaration of the implicit object parameter as we have). I'm currently
modeling this in the AST as the attribute appertaining to the function type.

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

Added:
cfe/trunk/test/SemaCXX/attr-lifetimebound.cpp
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypePrinter.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/utils/TableGen/ClangAttrEmitter.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=338464=338463=338464=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Tue Jul 31 17:33:25 2018
@@ -4237,6 +4237,7 @@ public:
 attr_null_unspecified,
 attr_objc_kindof,
 attr_objc_inert_unsafe_unretained,
+attr_lifetimebound,
   };
 
 private:

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=338464=338463=338464=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Tue Jul 31 17:33:25 2018
@@ -141,6 +141,13 @@ def HasFunctionProto : SubsetSubject(S)}],
  "non-K functions">;
 
+// A subject that matches the implicit object parameter of a non-static member
+// function. Accepted as a function type attribute on the type of such a
+// member function.
+// FIXME: This does not actually ever match currently.
+def ImplicitObjectParameter : SubsetSubject;
+
 // A single argument to an attribute
 class Argument {
   string Name = name;
@@ -1211,6 +1218,13 @@ def LayoutVersion : InheritableAttr, Tar
   let Documentation = [LayoutVersionDocs];
 }
 
+def LifetimeBound : InheritableAttr {
+  let Spellings = [Clang<"lifetimebound", 0>];
+  let Subjects = SubjectList<[ParmVar, ImplicitObjectParameter], ErrorDiag>;
+  let Documentation = [LifetimeBoundDocs];
+  let LangOpts = [CPlusPlus];
+}
+
 def TrivialABI : InheritableAttr {
   // This attribute does not have a C [[]] spelling because it requires the
   // CPlusPlus language option.

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=338464=338463=338464=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Tue Jul 31 17:33:25 2018
@@ -2362,6 +2362,22 @@ It is only supported when using the Micr
   }];
 }
 
+def LifetimeBoundDocs : Documentation {
+  let Category = DocCatFunction;
+  let Content = [{
+The ``lifetimebound`` attribute indicates that a resource owned by
+a function parameter or implicit object parameter
+is retained by the return value of the annotated function
+(or, for a parameter of a constructor, in the value of the constructed object).
+It is only supported in C++.
+
+This attribute provides an experimental implementation of the facility
+described in the C++ committee paper [http://wg21.link/p0936r0](P0936R0),
+and is subject to change as the design of the corresponding functionality
+changes.
+  }];
+}
+
 def TrivialABIDocs : Documentation {
   let Category = DocCatVariable;
   let Content = [{

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=338464=338463=338464=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td 

[PATCH] D48341: [clang-doc] Refactoring mapper to map by scope

2018-07-31 Thread Julie Hockett via Phabricator via cfe-commits
juliehockett added inline comments.



Comment at: clang-tools-extra/clang-doc/Representation.h:246
+
+  std::vector ChildNamespaces;
+  std::vector ChildRecords;

ioeric wrote:
> Would a record ever have namespace children? Maybe we should assert that this 
> doesn't happen?
You're right, that's actually not valid in C++. Removed the field.



Comment at: clang-tools-extra/test/clang-doc/bc-linkage.cpp:106
+// CHECK-0-NEXT: 
+// CHECK-0-NEXT:   
+// CHECK-0-NEXT:blob data = 'InnerClass'

ioeric wrote:
> I'm still a bit concerned about hardcoding a lot of USRs in tests. They are 
> not interpretable and generally not interesting for testing. Also as they are 
> auto-generated,   it's hard to tell whether they are actually the desired 
> USRs. I'm concerned because the maintenance is getting higher as number of 
> tests grows - everyone changing USR semantics in the future has to know to 
> regenerate clang-doc tests, this can be annoying and potentially unmanageable 
> when a small change in clang USR requires changes to many test files in 
> clang-tools-extra :( Comparing to the value it brings to test USRs in all 
> tests, I'd still suggest  simply matching them with a `{{.*}}`and only test 
> USRs in few tests where you are actually interested in them.
Okay, I updated it to only check the length -- is that reasonable?


https://reviews.llvm.org/D48341



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


[PATCH] D50119: Compiler support for P1144R0 "__is_trivially_relocatable(T)"

2018-07-31 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone created this revision.
Quuxplusone added a reviewer: rsmith.
Quuxplusone added a project: clang.
Herald added a subscriber: cfe-commits.

This is the compiler half of C++ proposal 1144 "Object relocation in terms of 
move plus destroy," as seen on https://godbolt.org/g/zUUAVW and 
https://quuxplusone.github.io/blog/2018/07/18/announcing-trivially-relocatable/ 
.

There are two parts to this compiler support:

- the type trait `__is_trivially_relocatable(T)`, which is similar in spirit to 
`__is_trivially_destructible(T)`, in that it lets the programmer access 
information that the compiler itself already knows; and
- the warranting attribute `[[trivially_relocatable]]`, which is similar in 
spirit to `[[trivial_abi]]`, in that it lets the programmer communicate back to 
the compiler that a certain user-defined type should be //assumed// to have 
this property even though it would not //naturally// have the property all else 
being equal.

The official home of this branch thus far has been 
https://github.com/Quuxplusone/clang/tree/trivially-relocatable , but I figure 
that a Clang review would be a good way to get some more eyeballs on it, plus, 
if we can get it into Clang trunk then I wouldn't have to keep rebasing it 
every week.


Repository:
  rC Clang

https://reviews.llvm.org/D50119

Files:
  docs/LanguageExtensions.rst
  include/clang/AST/DeclCXX.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/Features.def
  include/clang/Basic/TokenKinds.def
  include/clang/Basic/TypeTraits.h
  include/clang/Sema/Sema.h
  lib/AST/ASTImporter.cpp
  lib/AST/DeclCXX.cpp
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclAttr.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Serialization/ASTReaderDecl.cpp
  lib/Serialization/ASTWriter.cpp
  test/Lexer/has_extension_cxx.cpp
  test/Misc/pragma-attribute-supported-attributes-list.test
  test/SemaCXX/trivially-relocatable.cpp

Index: test/SemaCXX/trivially-relocatable.cpp
===
--- /dev/null
+++ test/SemaCXX/trivially-relocatable.cpp
@@ -0,0 +1,478 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+// expected-diagnostics
+
+static_assert(__has_extension(trivially_relocatable), "");
+
+// It shall appear at most once in each attribute-list
+// and no attribute-argument-clause shall be present.
+
+struct [[trivially_relocatable, trivially_relocatable]] B1 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot appear multiple times in an attribute specifier}}
+
+struct [[trivially_relocatable]] [[trivially_relocatable]] B2 {}; // should really be an error
+
+struct [[trivially_relocatable(42)]] B3 {};
+// expected-error@-1{{attribute 'trivially_relocatable' cannot have an argument list}}
+
+
+//   The first declaration of a type shall specify the
+//   trivially_relocatable attribute if any declaration of that
+//   type specifies the trivially_relocatable attribute.
+
+struct [[trivially_relocatable]] A1 {};  // ok
+struct [[trivially_relocatable]] A1;
+
+struct [[trivially_relocatable]] A2;  // ok
+struct [[trivially_relocatable]] A2 {};
+
+struct [[trivially_relocatable]] A3 {};  // ok
+struct A3;
+
+struct [[trivially_relocatable]] A4;  // ok
+struct A4 {};
+
+struct A5 {};
+struct [[trivially_relocatable]] A5;
+// expected-error@-1{{type A5 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+// expected-warning@-3{{attribute declaration must precede definition}}
+// expected-note@-5{{previous definition is here}}
+
+struct A6;
+struct [[trivially_relocatable]] A6 {};
+// expected-error@-1{{type A6 declared 'trivially_relocatable' after its first declaration}}
+// expected-note@-3{{declaration missing 'trivially_relocatable' attribute is here}}
+
+
+// If a type T is declared with the trivially_relocatable attribute, and T is either
+// not move-constructible or not destructible, the program is ill-formed.
+
+struct NonDestructible {
+NonDestructible(const NonDestructible&) = default;
+NonDestructible(NonDestructible&&) = default;
+~NonDestructible() = delete;
+};
+struct NonCopyConstructible {
+NonCopyConstructible(const NonCopyConstructible&) = delete;
+};
+struct NonMoveConstructible {
+NonMoveConstructible(const NonMoveConstructible&) = default;
+NonMoveConstructible(NonMoveConstructible&&) = delete;
+};
+static_assert(!__is_trivially_relocatable(NonDestructible), "");
+static_assert(!__is_trivially_relocatable(NonCopyConstructible), "");
+static_assert(!__is_constructible(NonCopyConstructible, NonCopyConstructible&&), "");
+static_assert(!__is_trivially_relocatable(NonMoveConstructible), "");
+static_assert(!__is_constructible(NonMoveConstructible, NonMoveConstructible&&), "");
+
+struct [[trivially_relocatable]] D1 { ~D1() = 

[PATCH] D49114: [clang-tidy] Add a check for "magic numbers"

2018-07-31 Thread Florin Iucha via Phabricator via cfe-commits
0x8000- updated this revision to Diff 158425.
0x8000- added a comment.

Add tests to show that we can detect, report and ignore floating point numbers 
represented using hexadecimal notation


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D49114

Files:
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/MagicNumbersCheck.cpp
  clang-tidy/readability/MagicNumbersCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-avoid-magic-numbers.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-magic-numbers.rst
  test/clang-tidy/readability-magic-numbers.cpp

Index: test/clang-tidy/readability-magic-numbers.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-magic-numbers.cpp
@@ -0,0 +1,199 @@
+// RUN: %check_clang_tidy %s readability-magic-numbers %t \
+// RUN: -config='{CheckOptions: \
+// RUN:  [{key: readability-magic-numbers.IgnoredIntegerValues, value: "0;1;2;10;100;"}, \
+// RUN:   {key: readability-magic-numbers.IgnoredFloatingPointValues, value: "3.14;2.71828;9.81;1.0;101.0;0x1.2p3"}, \
+// RUN:   {key: readability-magic-numbers.IgnorePowersOf2IntegerValues, value: 1}]}' \
+// RUN: --
+
+template 
+struct ValueBucket {
+  T value[V];
+};
+
+int BadGlobalInt = 5;
+// CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+int IntSquarer(int param) {
+  return param * param;
+}
+
+void BuggyFunction() {
+  int BadLocalInt = 6;
+  // CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  (void)IntSquarer(7);
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 7 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int LocalArray[15];
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: 15 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  for (int ii = 0; ii < 22; ++ii)
+  // CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 22 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+  {
+LocalArray[ii] = 3 * ii;
+// CHECK-MESSAGES: :[[@LINE-1]]:22: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+  }
+
+  ValueBucket Bucket;
+  // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: 66 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+}
+
+class TwoIntContainer {
+public:
+  TwoIntContainer(int val) : anotherMember(val * val), yetAnotherMember(6), anotherConstant(val + val) {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:73: warning: 6 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int getValue() const;
+
+private:
+  int oneMember = 9;
+  // CHECK-MESSAGES: :[[@LINE-1]]:19: warning: 9 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+  int anotherMember;
+
+  int yetAnotherMember;
+
+  const int oneConstant = 2;
+
+  const int anotherConstant;
+};
+
+int ValueArray[] = {3, 5};
+// CHECK-MESSAGES: :[[@LINE-1]]:21: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+// CHECK-MESSAGES: :[[@LINE-2]]:24: warning: 5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+float FloatPiVariable = 3.1415926535f;
+// CHECK-MESSAGES: :[[@LINE-1]]:25: warning: 3.1415926535f is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+double DoublePiVariable = 6.283185307;
+// CHECK-MESSAGES: :[[@LINE-1]]:27: warning: 6.283185307 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+float SomeFloats[] = {0.5, 0x1.2p4};
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: 0.5 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+// CHECK-MESSAGES: :[[@LINE-2]]:28: warning: 0x1.2p4 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+
+int getAnswer() {
+  if (ValueArray[0] < ValueArray[1])
+return ValueArray[1];
+
+  return -3; // FILENOTFOUND
+  // CHECK-MESSAGES: :[[@LINE-1]]:11: warning: 3 is a magic number; consider replacing it with a named constant [readability-magic-numbers]
+}
+
+/*
+ * Clean code
+ */
+
+#define INT_MACRO 5
+
+const int GoodGlobalIntConstant = 42;
+
+constexpr int AlsoGoodGlobalIntConstant = 42;
+
+int InitializedByMacro = INT_MACRO;
+
+void SolidFunction() {
+  const int GoodLocalIntConstant = 43;
+
+  (void)IntSquarer(GoodLocalIntConstant);
+
+  int LocalArray[INT_MACRO];
+
+  ValueBucket Bucket;
+}
+
+const int ConstValueArray[] = {7, 9};
+
+const int 

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 158423.
leonardchan added a comment.

- Moved the counter and set into `ExpressionEvaluationContextRecord`


Repository:
  rC Clang

https://reviews.llvm.org/D49511

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaType.cpp
  test/Frontend/noderef.c
  test/Frontend/noderef_on_non_pointers.cpp
  test/Frontend/noderef_on_non_pointers.m

Index: test/Frontend/noderef_on_non_pointers.m
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+@interface NSObject
++ (id)new;
+@end
+
+void func() {
+  id NODEREF obj = [NSObject new]; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
Index: test/Frontend/noderef_on_non_pointers.cpp
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fblocks -verify %s
+
+/**
+ * Test `noderef` attribute against other pointer-like types.
+ */
+
+#define NODEREF __attribute__((noderef))
+
+void Normal() {
+  int NODEREF i;// expected-warning{{`noderef` can only be used on an array or pointer type}}
+  int NODEREF *i_ptr;   // ok
+  int NODEREF **i_ptr2; // ok
+  int *NODEREF i_ptr3;  // expected-warning{{`noderef` can only be used on an array or pointer type}}
+  int *NODEREF *i_ptr4; // ok
+
+  auto NODEREF *auto_i_ptr = i_ptr;
+  auto NODEREF auto_i = i; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+
+  struct {
+int x;
+int y;
+  } NODEREF *s;
+
+  int __attribute__((noderef(10))) * no_args; // expected-error{{'noderef' attribute takes no arguments}}
+}
+
+const int NODEREF *const_i_ptr;
+static int NODEREF *static_i_ptr;
+
+void ParenTypes() {
+  int NODEREF(*i_ptr);// ok (same as `int NODEREF *`)
+  int NODEREF *(*i_ptr2); // ok (same as `int NODEREF **`)
+}
+
+// Function declarations
+int NODEREF func();   // expected-warning{{`noderef` can only be used on an array or pointer type}}
+int NODEREF *func2(); // ok (returning pointer)
+
+typedef int NODEREF (*func3)(int); // expected-warning{{`noderef` can only be used on an array or pointer type}}
+typedef int NODEREF *(*func4)(int);
+
+void Arrays() {
+  int NODEREF i_arr[10];  // ok
+  int NODEREF i_arr2[10][10]; // ok
+  int NODEREF *i_arr3[10];// ok
+  int NODEREF i_arr4[] = {1, 2};
+}
+
+void ParenArrays() {
+  int NODEREF(i_ptr[10]);
+  int NODEREF(i_ptr2[10])[10];
+}
+
+typedef int NODEREF *(*func5[10])(int);
+
+// Arguments
+void func6(int NODEREF x); // expected-warning{{`noderef` can only be used on an array or pointer type}}
+void func7(int NODEREF *x);
+void func8() NODEREF;
+
+void References() {
+  int x = 2;
+  int NODEREF  = x; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+  int *xp = 
+  int NODEREF * = xp; // ok (reference to a NODEREF *)
+  int *NODEREF  = xp; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
+
+void BlockPointers() {
+  typedef int NODEREF (^IntBlock)(); // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
+
+class A {
+public:
+  int member;
+  int NODEREF *member2;
+  int NODEREF member3; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+};
+
+void MemberPointer() {
+  int NODEREF A::*var = ::member; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
+
+template 
+class B {
+  Ty NODEREF *member;
+  Ty NODEREF member2; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+};
Index: test/Frontend/noderef.c
===
--- /dev/null
+++ test/Frontend/noderef.c
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -Wno-unused-value -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+struct S {
+  int a;
+  int b;
+};
+
+struct S2 {
+  int a[2];
+  int NODEREF a2[2];
+  int *b;
+  int NODEREF *b2;
+  struct S *s;
+  struct S NODEREF *s2;
+};
+
+int NODEREF *func(int NODEREF *arg) {  // expected-note{{arg declared here}}
+  int y = *arg; // expected-warning{{dereferencing arg; was declared with a `noderef` type}}
+  return arg;
+}
+
+void func2(int x) {}
+
+int test() {
+  int NODEREF *p;   // expected-note 31 {{p declared here}}
+  int *p2;
+
+  int x = *p;   // expected-warning{{dereferencing p; was declared with a `noderef` type}}
+  x = *((int NODEREF *)p2); // expected-warning{{dereferencing expression marked as `noderef`}}
+
+  int NODEREF **q;
+  int 

[PATCH] D49771: CodeGen: use non-zero memset when possible for automatic variables

2018-07-31 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

> I'm worried, however, about generating a bunch more code than needed from 
> clang in the hopes that the compiler will clean it up later.

Isn't a strong design component of clang/LLVM? Clang does not try to generate 
"smart" code and leave it up to LLVM to clean it up.


Repository:
  rL LLVM

https://reviews.llvm.org/D49771



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


[PATCH] D50118: [VFS] Unify iteration code for VFSFromYamlDirIterImpl, NFC intended.

2018-07-31 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.
vsapsai added reviewers: bruno, benlangmuir.
Herald added a subscriber: dexonsmith.

First and subsequent iteration steps are similar, capture this similarity.


https://reviews.llvm.org/D50118

Files:
  clang/lib/Basic/VirtualFileSystem.cpp


Index: clang/lib/Basic/VirtualFileSystem.cpp
===
--- clang/lib/Basic/VirtualFileSystem.cpp
+++ clang/lib/Basic/VirtualFileSystem.cpp
@@ -896,6 +896,8 @@
   RedirectingFileSystem 
   RedirectingDirectoryEntry::iterator Current, End;
 
+  std::error_code incrementImpl();
+
 public:
   VFSFromYamlDirIterImpl(const Twine , RedirectingFileSystem ,
  RedirectingDirectoryEntry::iterator Begin,
@@ -1948,36 +1950,25 @@
 RedirectingDirectoryEntry::iterator Begin,
 RedirectingDirectoryEntry::iterator End, std::error_code )
 : Dir(_Path.str()), FS(FS), Current(Begin), End(End) {
-  while (Current != End) {
-SmallString<128> PathStr(Dir);
-llvm::sys::path::append(PathStr, (*Current)->getName());
-llvm::ErrorOr S = FS.status(PathStr);
-if (S) {
-  CurrentEntry = *S;
-  return;
-}
-// Skip entries which do not map to a reliable external content.
-if (FS.ignoreNonExistentContents() &&
-S.getError() == llvm::errc::no_such_file_or_directory) {
-  ++Current;
-  continue;
-} else {
-  EC = S.getError();
-  break;
-}
-  }
+  EC = incrementImpl();
 }
 
 std::error_code VFSFromYamlDirIterImpl::increment() {
   assert(Current != End && "cannot iterate past end");
-  while (++Current != End) {
+  ++Current;
+  return incrementImpl();
+}
+
+std::error_code VFSFromYamlDirIterImpl::incrementImpl() {
+  while (Current != End) {
 SmallString<128> PathStr(Dir);
 llvm::sys::path::append(PathStr, (*Current)->getName());
 llvm::ErrorOr S = FS.status(PathStr);
 if (!S) {
   // Skip entries which do not map to a reliable external content.
   if (FS.ignoreNonExistentContents() &&
   S.getError() == llvm::errc::no_such_file_or_directory) {
+++Current;
 continue;
   } else {
 return S.getError();


Index: clang/lib/Basic/VirtualFileSystem.cpp
===
--- clang/lib/Basic/VirtualFileSystem.cpp
+++ clang/lib/Basic/VirtualFileSystem.cpp
@@ -896,6 +896,8 @@
   RedirectingFileSystem 
   RedirectingDirectoryEntry::iterator Current, End;
 
+  std::error_code incrementImpl();
+
 public:
   VFSFromYamlDirIterImpl(const Twine , RedirectingFileSystem ,
  RedirectingDirectoryEntry::iterator Begin,
@@ -1948,36 +1950,25 @@
 RedirectingDirectoryEntry::iterator Begin,
 RedirectingDirectoryEntry::iterator End, std::error_code )
 : Dir(_Path.str()), FS(FS), Current(Begin), End(End) {
-  while (Current != End) {
-SmallString<128> PathStr(Dir);
-llvm::sys::path::append(PathStr, (*Current)->getName());
-llvm::ErrorOr S = FS.status(PathStr);
-if (S) {
-  CurrentEntry = *S;
-  return;
-}
-// Skip entries which do not map to a reliable external content.
-if (FS.ignoreNonExistentContents() &&
-S.getError() == llvm::errc::no_such_file_or_directory) {
-  ++Current;
-  continue;
-} else {
-  EC = S.getError();
-  break;
-}
-  }
+  EC = incrementImpl();
 }
 
 std::error_code VFSFromYamlDirIterImpl::increment() {
   assert(Current != End && "cannot iterate past end");
-  while (++Current != End) {
+  ++Current;
+  return incrementImpl();
+}
+
+std::error_code VFSFromYamlDirIterImpl::incrementImpl() {
+  while (Current != End) {
 SmallString<128> PathStr(Dir);
 llvm::sys::path::append(PathStr, (*Current)->getName());
 llvm::ErrorOr S = FS.status(PathStr);
 if (!S) {
   // Skip entries which do not map to a reliable external content.
   if (FS.ignoreNonExistentContents() &&
   S.getError() == llvm::errc::no_such_file_or_directory) {
+++Current;
 continue;
   } else {
 return S.getError();
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[libcxx] r338457 - Final bit of P0063 - make sure that aligned_alloc is available when the underlying C library supports it

2018-07-31 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jul 31 16:39:12 2018
New Revision: 338457

URL: http://llvm.org/viewvc/llvm-project?rev=338457=rev
Log:
Final bit of P0063 - make sure that aligned_alloc is available when the 
underlying C library supports it

Modified:
libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp
libcxx/trunk/www/cxx1z_status.html

Modified: libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp?rev=338457=338456=338457=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/stdlib_h.pass.cpp Tue Jul 31 
16:39:12 2018
@@ -12,6 +12,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 // As of 1/10/2015 clang emits a -Wnonnull warnings even if the warning occurs
 // in an unevaluated context. For this reason we manually suppress the warning.
 #if defined(__clang__)
@@ -83,6 +85,14 @@ int main()
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+
+//  Microsoft does not implement aligned_alloc in their C library
+#ifndef TEST_COMPILER_C1XX
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+static_assert((std::is_same::value), 
"");
+#endif
+#endif
+
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");

Modified: 
libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp?rev=338457=338456=338457=diff
==
--- libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp 
(original)
+++ libcxx/trunk/test/std/language.support/support.runtime/cstdlib.pass.cpp Tue 
Jul 31 16:39:12 2018
@@ -13,6 +13,8 @@
 #include 
 #include 
 
+#include "test_macros.h"
+
 // As of 1/10/2015 clang emits a -Wnonnull warnings even if the warning occurs
 // in an unevaluated context. For this reason we manually suppress the warning.
 #if defined(__clang__)
@@ -71,6 +73,14 @@ int main()
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");
+
+//  Microsoft does not implement aligned_alloc in their C library
+#ifndef TEST_COMPILER_C1XX
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+static_assert((std::is_same::value), "");
+#endif
+#endif
+
 static_assert((std::is_same::value), 
"");
 static_assert((std::is_same::value), "");
 static_assert((std::is_same::value), "");

Modified: libcxx/trunk/www/cxx1z_status.html
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/www/cxx1z_status.html?rev=338457=338456=338457=diff
==
--- libcxx/trunk/www/cxx1z_status.html (original)
+++ libcxx/trunk/www/cxx1z_status.html Tue Jul 31 16:39:12 2018
@@ -99,9 +99,9 @@

https://wg21.link/p0032r3;>p0032r3LWGHomogeneous 
interface for variant, any and 
optionalOuluComplete4.0
https://wg21.link/p0040r3;>p0040r3LWGExtending 
memory management toolsOuluComplete4.0
-   https://wg21.link/p0063r3;>p0063r3LWGC++17 should 
refer to C11 instead of C99OuluNothing to 
don/a
-   https://wg21.link/p0067r3;>p0067r3LWGElementary 
string conversionsOuluNow https://wg21.link/P0067R5;>P0067R5
-   https://wg21.link/p0083r3;>p0083r3LWGSplicing Maps 
and SetsOulu
+   https://wg21.link/p0063r3;>p0063r3LWGC++17 should 
refer to C11 instead of C99OuluComplete7.0
+   https://wg21.link/p0067r3;>p0067r3LWGElementary 
string conversionsOuluNow https://wg21.link/P0067R5;>P0067R5n/a
+   https://wg21.link/p0083r3;>p0083r3LWGSplicing Maps 
and SetsOuluPartially Done
https://wg21.link/p0084r2;>p0084r2LWGEmplace Return 
TypeOuluComplete4.0
https://wg21.link/p0088r3;>p0088r3LWGVariant: a 
type-safe union for C++17OuluComplete4.0
https://wg21.link/p0137r1;>p0137r1CWGCore Issue 
1776: Replacement of class objects containing reference 
membersOuluComplete6.0
@@ -127,7 +127,7 @@
https://wg21.link/P0394r4;>P0394r4LWGHotel 
Parallelifornia: terminate() for Parallel Algorithms Exception 
HandlingOulu

https://wg21.link/P0003R5;>P0003R5LWGRemoving 
Deprecated Exception Specifications from 
C++17IssaquahComplete5.0
-   https://wg21.link/P0067R5;>P0067R5LWGElementary 
string conversions, revision 5Issaquah
+   https://wg21.link/P0067R5;>P0067R5LWGElementary 
string conversions, revision 5IssaquahPartially 
done
https://wg21.link/P0403R1;>P0403R1LWGLiteral 

[PATCH] D49953: [compiler-rt] Add a routine to specify the mode used when creating profile dirs.

2018-07-31 Thread Matt Davis via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
mattd marked an inline comment as done.
Closed by commit rCRT338456: [compiler-rt] Add a routine to specify the mode 
used when creating profile dirs. (authored by mattd, committed by ).
Herald added subscribers: Sanitizers, llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49953?vs=158298=158419#toc

Repository:
  rCRT Compiler Runtime

https://reviews.llvm.org/D49953

Files:
  lib/profile/InstrProfilingUtil.c
  lib/profile/InstrProfilingUtil.h
  test/profile/instrprof-set-dir-mode.c

Index: test/profile/instrprof-set-dir-mode.c
===
--- test/profile/instrprof-set-dir-mode.c
+++ test/profile/instrprof-set-dir-mode.c
@@ -0,0 +1,48 @@
+// UNSUPPORTED: windows
+// RUN: %clang_pgogen -o %t.bin %s -DTESTPATH=\"%t.dir\"
+// RUN: rm -rf %t.dir
+// RUN: %run %t.bin
+
+#include 
+#include 
+#include 
+#include 
+
+void __llvm_profile_set_dir_mode(unsigned Mode);
+unsigned __llvm_profile_get_dir_mode(void);
+void __llvm_profile_recursive_mkdir(char *Path);
+
+static int test(unsigned Mode, const char *TestDir) {
+  int Ret = 0;
+
+  /* Create a dir and set the mode accordingly. */
+  char *Dir = strdup(TestDir);
+  if (!Dir)
+return -1;
+  __llvm_profile_set_dir_mode(Mode);
+  __llvm_profile_recursive_mkdir(Dir);
+
+  if (Mode != __llvm_profile_get_dir_mode())
+Ret = -1;
+  else {
+const unsigned Expected = ~umask(0) & Mode;
+struct stat DirSt;
+if (stat(Dir, ) == -1)
+  Ret = -1;
+else if (DirSt.st_mode != Expected) {
+  printf("Modes do not match: Expected %o but found %o (%s)\n", Expected,
+ DirSt.st_mode, Dir);
+  Ret = -1;
+}
+  }
+
+  free(Dir);
+  return Ret;
+}
+
+int main(void) {
+  if (test(S_IFDIR | 0777, TESTPATH "/foo/bar/baz/") ||
+  test(S_IFDIR | 0666, TESTPATH "/foo/bar/qux/"))
+return -1;
+  return 0;
+}
Index: lib/profile/InstrProfilingUtil.h
===
--- lib/profile/InstrProfilingUtil.h
+++ lib/profile/InstrProfilingUtil.h
@@ -16,6 +16,12 @@
 /*! \brief Create a directory tree. */
 void __llvm_profile_recursive_mkdir(char *Pathname);
 
+/*! Set the mode used when creating profile directories. */
+void __llvm_profile_set_dir_mode(unsigned Mode);
+
+/*! Return the directory creation mode. */
+unsigned __llvm_profile_get_dir_mode(void);
+
 int lprofLockFd(int fd);
 int lprofUnlockFd(int fd);
 
Index: lib/profile/InstrProfilingUtil.c
===
--- lib/profile/InstrProfilingUtil.c
+++ lib/profile/InstrProfilingUtil.c
@@ -35,6 +35,8 @@
 #include "InstrProfiling.h"
 #include "InstrProfilingUtil.h"
 
+COMPILER_RT_WEAK unsigned lprofDirMode = 0755;
+
 COMPILER_RT_VISIBILITY
 void __llvm_profile_recursive_mkdir(char *path) {
   int i;
@@ -47,12 +49,19 @@
 #ifdef _WIN32
 _mkdir(path);
 #else
-mkdir(path, 0755); /* Some of these will fail, ignore it. */
+/* Some of these will fail, ignore it. */
+mkdir(path, __llvm_profile_get_dir_mode());
 #endif
 path[i] = save;
   }
 }
 
+COMPILER_RT_VISIBILITY
+void __llvm_profile_set_dir_mode(unsigned Mode) { lprofDirMode = Mode; }
+
+COMPILER_RT_VISIBILITY
+unsigned __llvm_profile_get_dir_mode(void) { return lprofDirMode; }
+
 #if COMPILER_RT_HAS_ATOMICS != 1
 COMPILER_RT_VISIBILITY
 uint32_t lprofBoolCmpXchg(void **Ptr, void *OldV, void *NewV) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49396: [WebAssembly] Support for atomic.wait / atomic.wake builtins

2018-07-31 Thread Derek Schuff via Phabricator via cfe-commits
dschuff added inline comments.



Comment at: include/clang/Basic/BuiltinsWebAssembly.def:38
+// Atomic wait and wake.
+BUILTIN(__builtin_wasm_atomic_wait_i32, "Uii*iLLi", "n")
+BUILTIN(__builtin_wasm_atomic_wait_i64, "UiLLi*LLiLLi", "n")

So this means that the signature is basically `unsigned int 
__builtin_wasm_atomic_wait_i32(int *, int, long long)`? We should maybe make it 
`int __builtin_wasm_atomic_wait_i32(const unsigned char *, int, unsigned long 
long)`. Returning int so that you could define a C enum with the possible 
return values and compare without type coercion; unsigned char * so that it 
aliases with everything (i.e. a byte ptr), and unsigned long long since a 
negative relative timeout isn't meaningful(?). Not sure whether we should use 
int or unsigned int as the expected value, can't think of any particular reason 
right now to use one or the other.

Likewise with the other signatures.


Repository:
  rC Clang

https://reviews.llvm.org/D49396



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


r338455 - [constexpr] Support for constant evaluation of __builtin_memcpy and

2018-07-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 31 16:35:09 2018
New Revision: 338455

URL: http://llvm.org/viewvc/llvm-project?rev=338455=rev
Log:
[constexpr] Support for constant evaluation of __builtin_memcpy and
__builtin_memmove (in non-type-punning cases).

This is intended to permit libc++ to make std::copy etc constexpr
without sacrificing the optimization that uses memcpy on
trivially-copyable types.

__builtin_strcpy and __builtin_wcscpy are not handled by this change.
They'd be straightforward to add, but we haven't encountered a need for
them just yet.

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CodeGen/builtin-memfns.c
cfe/trunk/test/SemaCXX/constexpr-string.cpp

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=338455=338454=338455=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Jul 31 16:35:09 2018
@@ -471,6 +471,8 @@ BUILTIN(__builtin_wcslen, "zwC*", "nF")
 BUILTIN(__builtin_wcsncmp, "iwC*wC*z", "nF")
 BUILTIN(__builtin_wmemchr, "w*wC*wz", "nF")
 BUILTIN(__builtin_wmemcmp, "iwC*wC*z", "nF")
+BUILTIN(__builtin_wmemcpy, "w*w*wC*z", "nF")
+BUILTIN(__builtin_wmemmove, "w*w*wC*z", "nF")
 BUILTIN(__builtin_return_address, "v*IUi", "n")
 BUILTIN(__builtin_extract_return_addr, "v*v*", "n")
 BUILTIN(__builtin_frame_address, "v*IUi", "n")
@@ -908,6 +910,8 @@ LIBBUILTIN(wcslen,  "zwC*", "f", "wc
 LIBBUILTIN(wcsncmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES)
 LIBBUILTIN(wmemchr, "w*wC*wz",  "f", "wchar.h", ALL_LANGUAGES)
 LIBBUILTIN(wmemcmp, "iwC*wC*z", "f", "wchar.h", ALL_LANGUAGES)
+LIBBUILTIN(wmemcpy, "w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES)
+LIBBUILTIN(wmemmove,"w*w*wC*z", "f", "wchar.h", ALL_LANGUAGES)
 
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine

Modified: cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td?rev=338455=338454=338455=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticASTKinds.td Tue Jul 31 16:35:09 2018
@@ -163,6 +163,20 @@ def note_constexpr_unsupported_unsized_a
 def note_constexpr_unsized_array_indexed : Note<
   "indexing of array without known bound is not allowed "
   "in a constant expression">;
+def note_constexpr_memcpy_type_pun : Note<
+  "cannot constant evaluate '%select{memcpy|memmove}0' from object of "
+  "type %1 to object of type %2">;
+def note_constexpr_memcpy_nontrivial : Note<
+  "cannot constant evaluate '%select{memcpy|memmove}0' between objects of "
+  "non-trivially-copyable type %1">;
+def note_constexpr_memcpy_overlap : Note<
+  "'%select{memcpy|wmemcpy}0' between overlapping memory regions">;
+def note_constexpr_memcpy_unsupported : Note<
+  "'%select{%select{memcpy|wmemcpy}1|%select{memmove|wmemmove}1}0' "
+  "not supported: %select{"
+  "size to copy (%4) is not a multiple of size of element type %3 (%5)|"
+  "source is not a contiguous array of at least %4 elements of type %3|"
+  "destination is not a contiguous array of at least %4 elements of type 
%3}2">;
 
 def warn_integer_constant_overflow : Warning<
   "overflow in expression; result is %0 with type %1">,

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=338455=338454=338455=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Tue Jul 31 16:35:09 2018
@@ -319,6 +319,25 @@ namespace {
   return false;
 }
 
+/// Get the range of valid index adjustments in the form
+///   {maximum value that can be subtracted from this pointer,
+///maximum value that can be added to this pointer}
+std::pair validIndexAdjustments() {
+  if (Invalid || isMostDerivedAnUnsizedArray())
+return {0, 0};
+
+  // [expr.add]p4: For the purposes of these operators, a pointer to a
+  // nonarray object behaves the same as a pointer to the first element of
+  // an array of length one with the type of the object as its element 
type.
+  bool IsArray = MostDerivedPathLength == Entries.size() &&
+ MostDerivedIsArrayElement;
+  uint64_t ArrayIndex =
+  IsArray ? Entries.back().ArrayIndex : (uint64_t)IsOnePastTheEnd;
+  uint64_t ArraySize =
+  IsArray ? getMostDerivedArraySize() : (uint64_t)1;
+  return {ArrayIndex, ArraySize - ArrayIndex};
+}
+
 /// Check that this refers to a valid subobject.
 

[libcxx] r338454 - Test for the presence of a bunch of new macros for c++17. These macros come from C11. Part of P0063

2018-07-31 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Tue Jul 31 16:29:06 2018
New Revision: 338454

URL: http://llvm.org/viewvc/llvm-project?rev=338454=rev
Log:
Test for the presence of a bunch of new macros for c++17. These macros come 
from C11. Part of P0063

Modified:
libcxx/trunk/include/cfloat
libcxx/trunk/include/float.h
libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp

libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp

Modified: libcxx/trunk/include/cfloat
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/cfloat?rev=338454=338453=338454=diff
==
--- libcxx/trunk/include/cfloat (original)
+++ libcxx/trunk/include/cfloat Tue Jul 31 16:29:06 2018
@@ -20,11 +20,18 @@ Macros:
 FLT_EVAL_METHOD // C99
 FLT_RADIX
 
+FLT_HAS_SUBNORM // C11
+DBL_HAS_SUBNORM // C11
+LDBL_HAS_SUBNORM// C11
+
 FLT_MANT_DIG
 DBL_MANT_DIG
 LDBL_MANT_DIG
 
 DECIMAL_DIG // C99
+FLT_DECIMAL_DIG // C11
+DBL_DECIMAL_DIG // C11
+LDBL_DECIMAL_DIG// C11
 
 FLT_DIG
 DBL_DIG
@@ -58,6 +65,9 @@ Macros:
 DBL_MIN
 LDBL_MIN
 
+FLT_TRUE_MIN// C11
+DBL_TRUE_MIN// C11
+LDBL_TRUE_MIN   // C11
 */
 
 #include <__config>

Modified: libcxx/trunk/include/float.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/float.h?rev=338454=338453=338454=diff
==
--- libcxx/trunk/include/float.h (original)
+++ libcxx/trunk/include/float.h Tue Jul 31 16:29:06 2018
@@ -24,7 +24,14 @@ Macros:
 DBL_MANT_DIG
 LDBL_MANT_DIG
 
+FLT_HAS_SUBNORM // C11
+DBL_HAS_SUBNORM // C11
+LDBL_HAS_SUBNORM// C11
+
 DECIMAL_DIG // C99
+FLT_DECIMAL_DIG // C11
+DBL_DECIMAL_DIG // C11
+LDBL_DECIMAL_DIG// C11
 
 FLT_DIG
 DBL_DIG
@@ -58,6 +65,10 @@ Macros:
 DBL_MIN
 LDBL_MIN
 
+FLT_TRUE_MIN// C11
+DBL_TRUE_MIN// C11
+LDBL_TRUE_MIN   // C11
+
 */
 
 #include <__config>

Modified: libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp?rev=338454=338453=338454=diff
==
--- libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp (original)
+++ libcxx/trunk/test/std/depr/depr.c.headers/float_h.pass.cpp Tue Jul 31 
16:29:06 2018
@@ -23,6 +23,20 @@
 #error FLT_RADIX not defined
 #endif
 
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#ifndef FLT_HAS_SUBNORM
+#error FLT_HAS_SUBNORM not defined
+#endif
+
+#ifndef DBL_HAS_SUBNORM
+#error DBL_HAS_SUBNORM not defined
+#endif
+
+#ifndef LDBL_HAS_SUBNORM
+#error LDBL_HAS_SUBNORM not defined
+#endif
+#endif
+
 #ifndef FLT_MANT_DIG
 #error FLT_MANT_DIG not defined
 #endif
@@ -39,6 +53,20 @@
 #error DECIMAL_DIG not defined
 #endif
 
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#ifndef FLT_DECIMAL_DIG
+#error FLT_DECIMAL_DIG not defined
+#endif
+
+#ifndef DBL_DECIMAL_DIG
+#error DBL_DECIMAL_DIG not defined
+#endif
+
+#ifndef LDBL_DECIMAL_DIG
+#error LDBL_DECIMAL_DIG not defined
+#endif
+#endif
+
 #ifndef FLT_DIG
 #error FLT_DIG not defined
 #endif
@@ -135,6 +163,20 @@
 #error LDBL_MIN not defined
 #endif
 
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#ifndef FLT_TRUE_MIN
+#error FLT_TRUE_MIN not defined
+#endif
+
+#ifndef DBL_TRUE_MIN
+#error DBL_TRUE_MIN not defined
+#endif
+
+#ifndef LDBL_TRUE_MIN
+#error LDBL_TRUE_MIN not defined
+#endif
+#endif
+
 int main()
 {
 }

Modified: 
libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp?rev=338454=338453=338454=diff
==
--- 
libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/language.support/support.limits/c.limits/cfloat.pass.cpp 
Tue Jul 31 16:29:06 2018
@@ -23,6 +23,20 @@
 #error FLT_RADIX not defined
 #endif
 
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#ifndef FLT_HAS_SUBNORM
+#error FLT_HAS_SUBNORM not defined
+#endif
+
+#ifndef DBL_HAS_SUBNORM
+#error DBL_HAS_SUBNORM not defined
+#endif
+
+#ifndef LDBL_HAS_SUBNORM
+#error LDBL_HAS_SUBNORM not defined
+#endif
+#endif
+
 #ifndef FLT_MANT_DIG
 #error FLT_MANT_DIG not defined
 #endif
@@ -39,6 +53,20 @@
 #error DECIMAL_DIG not defined
 #endif
 
+#if TEST_STD_VER > 14 && defined(TEST_HAS_C11_FEATURES)
+#ifndef FLT_DECIMAL_DIG
+#error FLT_DECIMAL_DIG not defined
+#endif
+
+#ifndef DBL_DECIMAL_DIG
+#error DBL_DECIMAL_DIG not defined
+#endif
+
+#ifndef LDBL_DECIMAL_DIG
+#error LDBL_DECIMAL_DIG not defined

[PATCH] D38320: [clang] Fix serializers for `TypeTemplateParmDecl` + related types

2018-07-31 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: lib/Serialization/ASTReaderDecl.cpp:3448-3456
   if (!inheritDefaultTemplateArgument(Context, FTTP, ToParam))
 break;
 } else if (auto *FNTTP = dyn_cast(FromParam)) {
   if (!inheritDefaultTemplateArgument(Context, FNTTP, ToParam))
 break;
 } else {
   if (!inheritDefaultTemplateArgument(

The idea is to reconstruct the 'inherited default template argument' 
information when we read a template declaration and find it's a redeclaration 
of another one, rather than serializing it and deserializing it. (In 
particular, if an imported template redeclares a non-imported template or a 
template imported from an unrelated module, it won't know that the prior 
declaration had a default argument because it doesn't know what the prior 
declaration was.)

The problem with our implementation of that idea is these `break`s: we're 
(incorrectly) assuming that a template parameter cannot have a default argument 
if there's a later template parameter that does not have one.

I removed the `break`s in r338438, and it fixed your testcase (which I 
committed alongside that change). Can you check to see if that also fixes the 
original problem from which this was reduced? Thanks!


Repository:
  rC Clang

https://reviews.llvm.org/D38320



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


[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458



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


Re: r338321 - Fix use of uninitialized variable in r338299

2018-07-31 Thread Eric Christopher via cfe-commits
On Tue, Jul 31, 2018 at 3:59 PM  wrote:

> What might be missing is the impl of CreateMemberType:
>
> llvm::DIType *CGDebugInfo::CreateMemberType(llvm::DIFile *Unit, QualType
> FType,
>  StringRef Name, uint64_t
> *Offset) {
>llvm::DIType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
>uint64_t FieldSize = CGM.getContext().getTypeSize(FType);
>auto FieldAlign = getTypeAlignIfRequired(FType, CGM.getContext());
>llvm::DIType *Ty =
>DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize,
> FieldAlign,
>  *Offset, llvm::DINode::FlagZero,
> FieldTy);
>*Offset += FieldSize;
>return Ty;
> }
>
> The FieldOffset is advanced twice in the OpenCL case, each time by
> getTypeSize(IntTy). I'm not certain why CreateMemberType is not used
> for __descriptor in the non-OpenCL case; it looks like it is
> because it needs to handle FieldTy in a special way?
>
>
I'd either forgotten or blocked that the code does that. Also, why on earth.
And probably.

Anyhow, if you don't mind commenting the OpenCL part of the code when you
get a chance to do the rest of the cleanup I'd appreciate it.

-eric


> Scott
>
> On 2018-07-31 18:03, Eric Christopher wrote:
> > I'm probably missing something, from looking here:
> >
> >   FieldOffset = 0;
> >   if (CGM.getLangOpts().OpenCL) {
> > FType = CGM.getContext().IntTy;
> > EltTys.push_back(CreateMemberType(Unit, FType, "__size",
> > ));
> > EltTys.push_back(CreateMemberType(Unit, FType, "__align",
> > ));
> >   } else {
> > FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> > EltTys.push_back(CreateMemberType(Unit, FType, "__isa",
> > ));
> > FType = CGM.getContext().IntTy;
> > EltTys.push_back(CreateMemberType(Unit, FType, "__flags",
> > ));
> > EltTys.push_back(CreateMemberType(Unit, FType, "__reserved",
> > ));
> > FType = CGM.getContext().getPointerType(Ty->getPointeeType());
> > EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr",
> > ));
> > FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
> > FieldSize = CGM.getContext().getTypeSize(Ty);
> > FieldAlign = CGM.getContext().getTypeAlign(Ty);
> > EltTys.push_back(DBuilder.createMemberType(
> > Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
> > FieldOffset,
> > llvm::DINode::FlagZero, DescTy));
> > FieldOffset += FieldSize;
> >   }
> >
> > FieldOffset is only advanced for non opencl blocks. And then just used
> > in the type.
> >
> > I'll be honest none of that makes any particular sense, but in
> > particular these two definitely don't match for the type.
> >
> > Thoughts? At any rate if you could document what the intended code is
> > here I'd appreciate it.
> >
> > -eric
> >
> > On Tue, Jul 31, 2018 at 9:18 AM  wrote:
> >
> >> I think this version is right; the FieldOffset for OpenCL here will
> >> be 2
> >> * getTypeSize(IntTy). The final `FieldOffset += FieldSize` that was
> >> moved only applies to the non-OpenCL "__descriptor" field.
> >>
> >> Scott
> >>
> >> On 2018-07-30 19:22, Eric Christopher wrote:
> >>> Is 0 right for FieldOffset for OpenCL here? Seems a little odd.
> >>>
> >>> -eric
> >>>
> >>> On Mon, Jul 30, 2018 at 3:56 PM Scott Linder via cfe-commits
> >>>  wrote:
> >>>
>  Author: scott.linder
>  Date: Mon Jul 30 15:52:07 2018
>  New Revision: 338321
> 
>  URL: http://llvm.org/viewvc/llvm-project?rev=338321=rev [1]
> >> [1]
>  Log:
>  Fix use of uninitialized variable in r338299
> 
>  Modified:
>  cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> 
>  Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>  URL:
> 
> >>>
> >>
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321=338320=338321=diff
> >> [2]
>  [2]
> 
> >>>
> >>
> >
> ==
>  --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>  +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 15:52:07
> >> 2018
>  @@ -989,9 +989,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
>  EltTys.push_back(DBuilder.createMemberType(
>  Unit, "__descriptor", nullptr, LineNo, FieldSize,
>  FieldAlign, FieldOffset,
>  llvm::DINode::FlagZero, DescTy));
>  + FieldOffset += FieldSize;
>  }
> 
>  - FieldOffset += FieldSize;
>  Elements = DBuilder.getOrCreateArray(EltTys);
> 
>  // The __block_literal_generic structs are marked with a special
> 
>  ___
>  cfe-commits mailing list
>  cfe-commits@lists.llvm.org
>  http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits [3]
> >> [3]
> >>>
> >>>
> >>> Links:
> >>> --
> >>> [1] http://llvm.org/viewvc/llvm-project?rev=338321view=rev
> >> [4]
> >>> [2]
> >>>
> >>
> >
> 

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

> Your current counter-based approach doesn't work very well in the case where 
> we switch to another context while processing an expression (for example, 
> during template instantiation): you'll defer all the diagnostics for the 
> inner construct until the outer construct is complete. Generally global 
> `Sema` state doesn't work very well for this reason.

Alternatively, I could move the set, counter, and logic using them into the 
`ExpressionEvaluationContextRecord`. Instead of tracking relative to a global 
Sema state, it would be relative to the latest record on the stack.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.

In https://reviews.llvm.org/D46845#1183462, @erik.pilkington wrote:

> In https://reviews.llvm.org/D46845#1183435, @mclow.lists wrote:
>
> > One more thing - 
> >  When you add a new header file, you need to update 
> > `include/module.modulemap`, `test/libcxx/double_include.sh.cpp`, and 
> > `include/CMakeLists.txt`.
> >  Take a look at https://reviews.llvm.org/D49338 for an example.
>
>
> Are you sure we have to update test/libcxx/double_include.sh.cpp? Looks like 
> that file only has public headers, but this patch only adds `__node_handle`, 
> which is internal. The new patch adds this header to include/CMakeLists.txt 
> though (`__node_handle` already appeared in module.modulemap)


D'oh! You're right. I didn't see that you had a patch for `module.modulemap`.
Sorry for the noise.

Go ahead and commit (and thanks for doing this!)


https://reviews.llvm.org/D46845



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


[PATCH] D49771: CodeGen: use non-zero memset when possible for automatic variables

2018-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D49771#1183562, @mehdi_amini wrote:

> In https://reviews.llvm.org/D49771#1183380, @jfb wrote:
>
> > In https://reviews.llvm.org/D49771#1181008, @mehdi_amini wrote:
> >
> > > I'm curious: isn't the kind of optimization we should expect LLVM to 
> > > provide?
> >
> >
> > Maybe? It seems obvious to do here since we know we'll probably want to be 
> > doing it, and I have another patch I'm working on which will make it that 
> > much more obviously useful to have here. The middle-end can definitely 
> > figure it out but it just seems like more work, later, so in the meantime 
> > we'd be looking at more stuff.
>
>
> I'm not asking where is it easier to do, but where does it make the most 
> sense :)


What I mean by "easy" is: we know we're likely to want this type of code, 
there's not much pattern recognition needed on our part here. Were we to wait 
we'd need to do more work. I believe this statement will become truer over time.

> Doing such in LLVM in general means catching more patterns (i.e. after 
> inlining, etc.), and also catching it from multiple frontend. So in general 
> I'm worried when I see optimizations implemented in the frontend  instead of 
> the middle end.

Agreed, LLVM could also do it, and it would likely be useful to do so. I'm 
worried, however, about generating a bunch more code than needed from clang in 
the hopes that the compiler will clean it up later.


Repository:
  rL LLVM

https://reviews.llvm.org/D49771



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


Re: r338321 - Fix use of uninitialized variable in r338299

2018-07-31 Thread via cfe-commits

What might be missing is the impl of CreateMemberType:

llvm::DIType *CGDebugInfo::CreateMemberType(llvm::DIFile *Unit, QualType 
FType,
StringRef Name, uint64_t 
*Offset) {

  llvm::DIType *FieldTy = CGDebugInfo::getOrCreateType(FType, Unit);
  uint64_t FieldSize = CGM.getContext().getTypeSize(FType);
  auto FieldAlign = getTypeAlignIfRequired(FType, CGM.getContext());
  llvm::DIType *Ty =
  DBuilder.createMemberType(Unit, Name, Unit, 0, FieldSize, 
FieldAlign,
*Offset, llvm::DINode::FlagZero, 
FieldTy);

  *Offset += FieldSize;
  return Ty;
}

The FieldOffset is advanced twice in the OpenCL case, each time by
getTypeSize(IntTy). I'm not certain why CreateMemberType is not used
for __descriptor in the non-OpenCL case; it looks like it is
because it needs to handle FieldTy in a special way?

Scott

On 2018-07-31 18:03, Eric Christopher wrote:

I'm probably missing something, from looking here:

  FieldOffset = 0;
  if (CGM.getLangOpts().OpenCL) {
FType = CGM.getContext().IntTy;
EltTys.push_back(CreateMemberType(Unit, FType, "__size",
));
EltTys.push_back(CreateMemberType(Unit, FType, "__align",
));
  } else {
FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
EltTys.push_back(CreateMemberType(Unit, FType, "__isa",
));
FType = CGM.getContext().IntTy;
EltTys.push_back(CreateMemberType(Unit, FType, "__flags",
));
EltTys.push_back(CreateMemberType(Unit, FType, "__reserved",
));
FType = CGM.getContext().getPointerType(Ty->getPointeeType());
EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr",
));
FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
FieldSize = CGM.getContext().getTypeSize(Ty);
FieldAlign = CGM.getContext().getTypeAlign(Ty);
EltTys.push_back(DBuilder.createMemberType(
Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
FieldOffset,
llvm::DINode::FlagZero, DescTy));
FieldOffset += FieldSize;
  }

FieldOffset is only advanced for non opencl blocks. And then just used
in the type.

I'll be honest none of that makes any particular sense, but in
particular these two definitely don't match for the type.

Thoughts? At any rate if you could document what the intended code is
here I'd appreciate it.

-eric

On Tue, Jul 31, 2018 at 9:18 AM  wrote:


I think this version is right; the FieldOffset for OpenCL here will
be 2
* getTypeSize(IntTy). The final `FieldOffset += FieldSize` that was
moved only applies to the non-OpenCL "__descriptor" field.

Scott

On 2018-07-30 19:22, Eric Christopher wrote:

Is 0 right for FieldOffset for OpenCL here? Seems a little odd.

-eric

On Mon, Jul 30, 2018 at 3:56 PM Scott Linder via cfe-commits
 wrote:


Author: scott.linder
Date: Mon Jul 30 15:52:07 2018
New Revision: 338321

URL: http://llvm.org/viewvc/llvm-project?rev=338321=rev [1]

[1]

Log:
Fix use of uninitialized variable in r338299

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL:






http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321=338320=338321=diff

[2]

[2]






==

--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 15:52:07

2018

@@ -989,9 +989,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
EltTys.push_back(DBuilder.createMemberType(
Unit, "__descriptor", nullptr, LineNo, FieldSize,
FieldAlign, FieldOffset,
llvm::DINode::FlagZero, DescTy));
+ FieldOffset += FieldSize;
}

- FieldOffset += FieldSize;
Elements = DBuilder.getOrCreateArray(EltTys);

// The __block_literal_generic structs are marked with a special

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

[3]



Links:
--
[1] http://llvm.org/viewvc/llvm-project?rev=338321view=rev

[4]

[2]




http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321r1=338320r2=338321view=diff

[5]

[3] http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits [3]



Links:
--
[1] http://llvm.org/viewvc/llvm-project?rev=338321view=rev
[2]
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321r1=338320r2=338321view=diff
[3] http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
[4] http://llvm.org/viewvc/llvm-project?rev=338321amp;view=rev
[5]
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321amp;r1=338320amp;r2=338321amp;view=diff

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


[PATCH] D49771: CodeGen: use non-zero memset when possible for automatic variables

2018-07-31 Thread Mehdi AMINI via Phabricator via cfe-commits
mehdi_amini added a comment.

In https://reviews.llvm.org/D49771#1183380, @jfb wrote:

> In https://reviews.llvm.org/D49771#1181008, @mehdi_amini wrote:
>
> > I'm curious: isn't the kind of optimization we should expect LLVM to 
> > provide?
>
>
> Maybe? It seems obvious to do here since we know we'll probably want to be 
> doing it, and I have another patch I'm working on which will make it that 
> much more obviously useful to have here. The middle-end can definitely figure 
> it out but it just seems like more work, later, so in the meantime we'd be 
> looking at more stuff.


I'm not asking where is it easier to do, but where does it make the most sense 
:)
Doing such in LLVM in general means catching more patterns (i.e. after 
inlining, etc.), and also catching it from multiple frontend. So in general I'm 
worried when I see optimizations implemented in the frontend  instead of the 
middle end.


Repository:
  rL LLVM

https://reviews.llvm.org/D49771



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


[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.



> You shouldn't be adding your own `ExpressionEvaluationContextRecord`s. What I 
> was suggesting is that you store a list of pending `noderef` expressions on 
> the record, and diagnose them when the record is popped (if they've not been 
> removed since).

This is what I initially tried but the last record left on the stack, which is 
what I add them to, wasn't getting popped. While parsing, the stack of records 
(from what I've observed) has only one record that doesn't get popped via 
`PopExpressionEvaluationContext`. I'm still looking into ways to try to do this 
though.

> That said... have you considered changing the specification of your attribute 
> so that you warn on lvalue-to-rvalue conversions instead of warning on 
> dereference-like things with a list of exceptions?

I'll look into this for the next revision on this patch.


Repository:
  rC Clang

https://reviews.llvm.org/D49511



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


[PATCH] D50102: [clang-tidy] Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-07-31 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang updated this revision to Diff 158408.
shuaiwang added a comment.

Add test case


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50102

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp
  test/clang-tidy/performance-unnecessary-value-param.cpp

Index: test/clang-tidy/performance-unnecessary-value-param.cpp
===
--- test/clang-tidy/performance-unnecessary-value-param.cpp
+++ test/clang-tidy/performance-unnecessary-value-param.cpp
@@ -15,6 +15,20 @@
 void useAsConstReference(const ExpensiveToCopyType &);
 void useByValue(ExpensiveToCopyType);
 
+template  class Vector {
+ public:
+  using iterator = T*;
+  using const_iterator = const T*;
+
+  Vector(const Vector&);
+  Vector& operator=(const Vector&);
+
+  iterator begin();
+  iterator end();
+  const_iterator begin() const;
+  const_iterator end() const;
+};
+
 // This class simulates std::pair<>. It is trivially copy constructible
 // and trivially destructible, but not trivially copy assignable.
 class SomewhatTrivial {
@@ -59,6 +73,14 @@
   useByValue(Obj);
 }
 
+void positiveVector(Vector V) {
+  // CHECK-MESSAGES: [[@LINE-1]]:49: warning: the parameter 'V' is copied for each invocation but only used as a const reference; consider making it a const reference [performance-unnecessary-value-param]
+  // CHECK-FIXES: void positiveVector(const Vector& V) {
+  for (const auto& Obj : V) {
+useByValue(Obj);
+  }
+}
+
 void positiveWithComment(const ExpensiveToCopyType /* important */ S);
 // CHECK-FIXES: void positiveWithComment(const ExpensiveToCopyType& /* important */ S);
 void positiveWithComment(const ExpensiveToCopyType /* important */ S) {
Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -10,6 +10,7 @@
 #include "UnnecessaryValueParamCheck.h"
 
 #include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
 #include "../utils/TypeTraits.h"
@@ -98,43 +99,52 @@
 void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult ) {
   const auto *Param = Result.Nodes.getNodeAs("param");
   const auto *Function = Result.Nodes.getNodeAs("functionDecl");
-  const size_t Index = std::find(Function->parameters().begin(),
- Function->parameters().end(), Param) -
-   Function->parameters().begin();
-  bool IsConstQualified =
-  Param->getType().getCanonicalType().isConstQualified();
-
-  auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
-  *Param, *Function, *Result.Context);
-  auto ConstDeclRefExprs = utils::decl_ref_expr::constReferenceDeclRefExprs(
-  *Param, *Function, *Result.Context);
 
   // Do not trigger on non-const value parameters when they are not only used as
   // const.
-  if (!isSubset(AllDeclRefExprs, ConstDeclRefExprs))
+  if (utils::ExprMutationAnalyzer(Function->getBody(), Result.Context)
+  .isMutated(Param))
 return;
+  if (const auto *Ctor = dyn_cast(Function)) {
+for (const auto *Init : Ctor->inits()) {
+  if (utils::ExprMutationAnalyzer(Init->getInit(), Result.Context)
+  .isMutated(Param))
+return;
+}
+  }
+
+  const bool IsConstQualified =
+  Param->getType().getCanonicalType().isConstQualified();
 
   // If the parameter is non-const, check if it has a move constructor and is
   // only referenced once to copy-construct another object or whether it has a
   // move assignment operator and is only referenced once when copy-assigned.
   // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary
   // copy.
-  if (!IsConstQualified && AllDeclRefExprs.size() == 1) {
-auto CanonicalType = Param->getType().getCanonicalType();
-const auto   = **AllDeclRefExprs.begin();
-
-if (!hasLoopStmtAncestor(DeclRefExpr, *Function, *Result.Context) &&
-((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
-  utils::decl_ref_expr::isCopyConstructorArgument(
-  DeclRefExpr, *Function, *Result.Context)) ||
- (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) &&
-  utils::decl_ref_expr::isCopyAssignmentArgument(
-  DeclRefExpr, *Function, *Result.Context {
-  handleMoveFix(*Param, DeclRefExpr, *Result.Context);
-  return;
+  if (!IsConstQualified) {
+auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
+*Param, *Function, *Result.Context);
+if (AllDeclRefExprs.size() == 1) {
+  auto CanonicalType = Param->getType().getCanonicalType();
+  const auto  = **AllDeclRefExprs.begin();
+
+  if (!hasLoopStmtAncestor(DeclRefExpr, *Function, *Result.Context) &&
+  

[PATCH] D49511: [Sema/Attribute] Check for noderef attribute

2018-07-31 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan updated this revision to Diff 158407.
leonardchan marked 6 inline comments as done.
leonardchan added a comment.

- Added tests for checking that `noderef` can only be used for C style pointers 
and arrays (not usable for references or ObjC pointers)
- Added warnings for dereferencing a noderef expression where we cannot trace 
back the original declrefexpr.
- Added warning for adding `noderef` on a type that `noderef` cannot be 
attatched to.
- Added warning group.
- Use SmallPtrSet instead of std::unordered_set


Repository:
  rC Clang

https://reviews.llvm.org/D49511

Files:
  include/clang/AST/Type.h
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/Type.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExpr.cpp
  lib/Sema/SemaExpr.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaType.cpp
  test/Frontend/noderef.c
  test/Frontend/noderef_on_non_pointers.cpp
  test/Frontend/noderef_on_non_pointers.m

Index: test/Frontend/noderef_on_non_pointers.m
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.m
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+@interface NSObject
++ (id)new;
+@end
+
+void func() {
+  id NODEREF obj = [NSObject new]; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
Index: test/Frontend/noderef_on_non_pointers.cpp
===
--- /dev/null
+++ test/Frontend/noderef_on_non_pointers.cpp
@@ -0,0 +1,88 @@
+// RUN: %clang_cc1 -fblocks -verify %s
+
+/**
+ * Test `noderef` attribute against other pointer-like types.
+ */
+
+#define NODEREF __attribute__((noderef))
+
+void Normal() {
+  int NODEREF i;// expected-warning{{`noderef` can only be used on an array or pointer type}}
+  int NODEREF *i_ptr;   // ok
+  int NODEREF **i_ptr2; // ok
+  int *NODEREF i_ptr3;  // expected-warning{{`noderef` can only be used on an array or pointer type}}
+  int *NODEREF *i_ptr4; // ok
+
+  auto NODEREF *auto_i_ptr = i_ptr;
+  auto NODEREF auto_i = i; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+
+  struct {
+int x;
+int y;
+  } NODEREF *s;
+
+  int __attribute__((noderef(10))) * no_args; // expected-error{{'noderef' attribute takes no arguments}}
+}
+
+const int NODEREF *const_i_ptr;
+static int NODEREF *static_i_ptr;
+
+void ParenTypes() {
+  int NODEREF(*i_ptr);// ok (same as `int NODEREF *`)
+  int NODEREF *(*i_ptr2); // ok (same as `int NODEREF **`)
+}
+
+// Function declarations
+int NODEREF func();   // expected-warning{{`noderef` can only be used on an array or pointer type}}
+int NODEREF *func2(); // ok (returning pointer)
+
+typedef int NODEREF (*func3)(int); // expected-warning{{`noderef` can only be used on an array or pointer type}}
+typedef int NODEREF *(*func4)(int);
+
+void Arrays() {
+  int NODEREF i_arr[10];  // ok
+  int NODEREF i_arr2[10][10]; // ok
+  int NODEREF *i_arr3[10];// ok
+  int NODEREF i_arr4[] = {1, 2};
+}
+
+void ParenArrays() {
+  int NODEREF(i_ptr[10]);
+  int NODEREF(i_ptr2[10])[10];
+}
+
+typedef int NODEREF *(*func5[10])(int);
+
+// Arguments
+void func6(int NODEREF x); // expected-warning{{`noderef` can only be used on an array or pointer type}}
+void func7(int NODEREF *x);
+void func8() NODEREF;
+
+void References() {
+  int x = 2;
+  int NODEREF  = x; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+  int *xp = 
+  int NODEREF * = xp; // ok (reference to a NODEREF *)
+  int *NODEREF  = xp; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
+
+void BlockPointers() {
+  typedef int NODEREF (^IntBlock)(); // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
+
+class A {
+public:
+  int member;
+  int NODEREF *member2;
+  int NODEREF member3; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+};
+
+void MemberPointer() {
+  int NODEREF A::*var = ::member; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+}
+
+template 
+class B {
+  Ty NODEREF *member;
+  Ty NODEREF member2; // expected-warning{{`noderef` can only be used on an array or pointer type}}
+};
Index: test/Frontend/noderef.c
===
--- /dev/null
+++ test/Frontend/noderef.c
@@ -0,0 +1,154 @@
+// RUN: %clang_cc1 -Wno-unused-value -verify %s
+
+#define NODEREF __attribute__((noderef))
+
+struct S {
+  int a;
+  int b;
+};
+
+struct S2 {
+  int a[2];
+  int NODEREF a2[2];
+  int *b;
+  int NODEREF *b2;
+  struct S *s;
+  struct S NODEREF *s2;
+};
+
+int NODEREF *func(int NODEREF *arg) {  // expected-note{{arg declared here}}
+  int y = *arg; // expected-warning{{dereferencing arg; was declared with a 

[PATCH] D41458: [libc++][C++17] Elementary string conversions for integral types

2018-07-31 Thread Zhihao Yuan via Phabricator via cfe-commits
lichray updated this revision to Diff 158404.
lichray added a comment.

Dropping a lambda


Repository:
  rCXX libc++

https://reviews.llvm.org/D41458

Files:
  include/CMakeLists.txt
  include/charconv
  include/module.modulemap
  src/charconv.cpp
  test/libcxx/double_include.sh.cpp
  test/std/utilities/charconv/
  test/std/utilities/charconv/charconv.from.chars/
  test/std/utilities/charconv/charconv.from.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.from.chars/integral.pass.cpp
  test/std/utilities/charconv/charconv.to.chars/
  test/std/utilities/charconv/charconv.to.chars/integral.bool.fail.cpp
  test/std/utilities/charconv/charconv.to.chars/integral.pass.cpp
  test/support/charconv_test_helpers.h

Index: test/support/charconv_test_helpers.h
===
--- /dev/null
+++ test/support/charconv_test_helpers.h
@@ -0,0 +1,232 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef SUPPORT_CHARCONV_TEST_HELPERS_H
+#define SUPPORT_CHARCONV_TEST_HELPERS_H
+
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#include "test_macros.h"
+
+#if TEST_STD_VER <= 11
+#error This file requires C++14
+#endif
+
+using std::false_type;
+using std::true_type;
+
+template 
+constexpr auto
+is_non_narrowing(From a) -> decltype(To{a}, true_type())
+{
+return {};
+}
+
+template 
+constexpr auto
+is_non_narrowing(...) -> false_type
+{
+return {};
+}
+
+template 
+constexpr bool
+_fits_in(T, true_type /* non-narrowing*/, ...)
+{
+return true;
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed*/, true_type /* X signed */)
+{
+return xl::lowest() <= v && v <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, true_type /* T signed */, false_type /* X unsigned*/)
+{
+return 0 <= v && std::make_unsigned_t(v) <= (xl::max)();
+}
+
+template >
+constexpr bool
+_fits_in(T v, false_type, false_type /* T unsigned */, ...)
+{
+return v <= std::make_unsigned_t((xl::max)());
+}
+
+template 
+constexpr bool
+fits_in(T v)
+{
+return _fits_in(v, is_non_narrowing(v), std::is_signed(),
+   std::is_signed());
+}
+
+template 
+struct to_chars_test_base
+{
+template 
+void test(T v, char const ()[N], Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+constexpr size_t len = N - 1;
+static_assert(len > 0, "expected output won't be empty");
+
+if (!fits_in(v))
+return;
+
+r = to_chars(buf, buf + len - 1, X(v), args...);
+assert(r.ptr == buf + len - 1);
+assert(r.ec == std::errc::value_too_large);
+
+r = to_chars(buf, buf + sizeof(buf), X(v), args...);
+assert(r.ptr == buf + len);
+assert(r.ec == std::errc{});
+assert(memcmp(buf, expect, len) == 0);
+}
+
+template 
+void test_value(X v, Ts... args)
+{
+using std::to_chars;
+std::to_chars_result r;
+
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+*r.ptr = '\0';
+
+auto a = fromchars(buf, r.ptr, args...);
+assert(v == a);
+
+auto ep = r.ptr - 1;
+r = to_chars(buf, ep, v, args...);
+assert(r.ptr == ep);
+assert(r.ec == std::errc::value_too_large);
+}
+
+private:
+static auto fromchars(char const* p, char const* ep, int base, true_type)
+{
+char* last;
+auto r = strtoll(p, , base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base, false_type)
+{
+char* last;
+auto r = strtoull(p, , base);
+assert(last == ep);
+
+return r;
+}
+
+static auto fromchars(char const* p, char const* ep, int base = 10)
+{
+return fromchars(p, ep, base, std::is_signed());
+}
+
+char buf[100];
+};
+
+template 
+struct roundtrip_test_base
+{
+template 
+void test(T v, Ts... args)
+{
+using std::from_chars;
+using std::to_chars;
+std::from_chars_result r2;
+std::to_chars_result r;
+X x = 0xc;
+
+if (fits_in(v))
+{
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+
+r2 = from_chars(buf, r.ptr, x, args...);
+assert(r2.ptr == r.ptr);
+assert(x == X(v));
+}
+else
+{
+r = to_chars(buf, buf + sizeof(buf), v, args...);
+assert(r.ec == std::errc{});
+
+r2 = from_chars(buf, r.ptr, x, args...);
+

[PATCH] D50112: [Android] Increase default new alignment for Android

2018-07-31 Thread Pirama Arumuga Nainar via Phabricator via cfe-commits
pirama created this revision.
pirama added a reviewer: rsmith.

Android's memory allocators also guarantee 8-byte alignment for 32-bit
architectures and 16-byte alignment for 64-bit.


Repository:
  rC Clang

https://reviews.llvm.org/D50112

Files:
  lib/Basic/TargetInfo.cpp
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9019,7 +9019,7 @@
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
-// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
+// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | 
FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -63,8 +63,9 @@
   MinGlobalAlign = 0;
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
-  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
+  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
+  // This alignment guarantee also applies to Windows and Android.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9019,7 +9019,7 @@
 // ANDROID:#define __ANDROID__ 1
 //
 // RUN: %clang_cc1 -x c++ -triple i686-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix I386-ANDROID-CXX %s
-// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 4U
+// I386-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 8U
 //
 // RUN: %clang_cc1 -x c++ -triple x86_64-linux-android -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix X86_64-ANDROID-CXX %s
 // X86_64-ANDROID-CXX:#define __STDCPP_DEFAULT_NEW_ALIGNMENT__ 16UL
Index: lib/Basic/TargetInfo.cpp
===
--- lib/Basic/TargetInfo.cpp
+++ lib/Basic/TargetInfo.cpp
@@ -63,8 +63,9 @@
   MinGlobalAlign = 0;
   // From the glibc documentation, on GNU systems, malloc guarantees 16-byte
   // alignment on 64-bit systems and 8-byte alignment on 32-bit systems. See
-  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html
-  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment())
+  // https://www.gnu.org/software/libc/manual/html_node/Malloc-Examples.html.
+  // This alignment guarantee also applies to Windows and Android.
+  if (T.isGNUEnvironment() || T.isWindowsMSVCEnvironment() || T.isAndroid())
 NewAlign = Triple.isArch64Bit() ? 128 : Triple.isArch32Bit() ? 64 : 0;
   else
 NewAlign = 0; // Infer from basic type alignment.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50110: Handle shared release attributes correctly

2018-07-31 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added reviewers: aaron.ballman, delesley.
Herald added a subscriber: cfe-commits.

Repository:
  rC Clang

https://reviews.llvm.org/D50110

Files:
  lib/Analysis/ThreadSafety.cpp
  test/SemaCXX/warn-thread-safety-analysis.cpp


Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -4078,6 +4078,14 @@
 mu_.Unlock();
   }
 
+  void unlockExclusive() EXCLUSIVE_UNLOCK_FUNCTION(mu_) {
+mu_.Unlock();
+  }
+
+  void unlockShared() SHARED_UNLOCK_FUNCTION(mu_) {
+mu_.ReaderUnlock();
+  }
+
   // Check failure to lock.
   void lockBad() EXCLUSIVE_LOCK_FUNCTION(mu_) {// expected-note {{mutex 
acquired here}}
 mu2_.Lock();
Index: lib/Analysis/ThreadSafety.cpp
===
--- lib/Analysis/ThreadSafety.cpp
+++ lib/Analysis/ThreadSafety.cpp
@@ -2242,8 +2242,8 @@
 // We must ignore such methods.
 if (A->args_size() == 0)
   return;
-// FIXME -- deal with exclusive vs. shared unlock functions?
-getMutexIDs(ExclusiveLocksToAdd, A, nullptr, D);
+getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A,
+nullptr, D);
 getMutexIDs(LocksReleased, A, nullptr, D);
 CapDiagKind = ClassifyDiagnostic(A);
   } else if (const auto *A = dyn_cast(Attr)) {


Index: test/SemaCXX/warn-thread-safety-analysis.cpp
===
--- test/SemaCXX/warn-thread-safety-analysis.cpp
+++ test/SemaCXX/warn-thread-safety-analysis.cpp
@@ -4078,6 +4078,14 @@
 mu_.Unlock();
   }
 
+  void unlockExclusive() EXCLUSIVE_UNLOCK_FUNCTION(mu_) {
+mu_.Unlock();
+  }
+
+  void unlockShared() SHARED_UNLOCK_FUNCTION(mu_) {
+mu_.ReaderUnlock();
+  }
+
   // Check failure to lock.
   void lockBad() EXCLUSIVE_LOCK_FUNCTION(mu_) {// expected-note {{mutex acquired here}}
 mu2_.Lock();
Index: lib/Analysis/ThreadSafety.cpp
===
--- lib/Analysis/ThreadSafety.cpp
+++ lib/Analysis/ThreadSafety.cpp
@@ -2242,8 +2242,8 @@
 // We must ignore such methods.
 if (A->args_size() == 0)
   return;
-// FIXME -- deal with exclusive vs. shared unlock functions?
-getMutexIDs(ExclusiveLocksToAdd, A, nullptr, D);
+getMutexIDs(A->isShared() ? SharedLocksToAdd : ExclusiveLocksToAdd, A,
+nullptr, D);
 getMutexIDs(LocksReleased, A, nullptr, D);
 CapDiagKind = ClassifyDiagnostic(A);
   } else if (const auto *A = dyn_cast(Attr)) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r338321 - Fix use of uninitialized variable in r338299

2018-07-31 Thread Eric Christopher via cfe-commits
I'm probably missing something, from looking here:

  FieldOffset = 0;
  if (CGM.getLangOpts().OpenCL) {
FType = CGM.getContext().IntTy;
EltTys.push_back(CreateMemberType(Unit, FType, "__size", ));
EltTys.push_back(CreateMemberType(Unit, FType, "__align",
));
  } else {
FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
EltTys.push_back(CreateMemberType(Unit, FType, "__isa", ));
FType = CGM.getContext().IntTy;
EltTys.push_back(CreateMemberType(Unit, FType, "__flags",
));
EltTys.push_back(CreateMemberType(Unit, FType, "__reserved",
));
FType = CGM.getContext().getPointerType(Ty->getPointeeType());
EltTys.push_back(CreateMemberType(Unit, FType, "__FuncPtr",
));
FType = CGM.getContext().getPointerType(CGM.getContext().VoidTy);
FieldSize = CGM.getContext().getTypeSize(Ty);
FieldAlign = CGM.getContext().getTypeAlign(Ty);
EltTys.push_back(DBuilder.createMemberType(
Unit, "__descriptor", nullptr, LineNo, FieldSize, FieldAlign,
FieldOffset,
llvm::DINode::FlagZero, DescTy));
FieldOffset += FieldSize;
  }

FieldOffset is only advanced for non opencl blocks. And then just used in
the type.

I'll be honest none of that makes any particular sense, but in particular
these two definitely don't match for the type.

Thoughts? At any rate if you could document what the intended code is here
I'd appreciate it.

-eric

On Tue, Jul 31, 2018 at 9:18 AM  wrote:

> I think this version is right; the FieldOffset for OpenCL here will be 2
> * getTypeSize(IntTy). The final `FieldOffset += FieldSize` that was
> moved only applies to the non-OpenCL "__descriptor" field.
>
> Scott
>
> On 2018-07-30 19:22, Eric Christopher wrote:
> > Is 0 right for FieldOffset for OpenCL here? Seems a little odd.
> >
> > -eric
> >
> > On Mon, Jul 30, 2018 at 3:56 PM Scott Linder via cfe-commits
> >  wrote:
> >
> >> Author: scott.linder
> >> Date: Mon Jul 30 15:52:07 2018
> >> New Revision: 338321
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=338321=rev [1]
> >> Log:
> >> Fix use of uninitialized variable in r338299
> >>
> >> Modified:
> >> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> >>
> >> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
> >> URL:
> >>
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321=338320=338321=diff
> >> [2]
> >>
> >
> ==
> >> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
> >> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Jul 30 15:52:07 2018
> >> @@ -989,9 +989,9 @@ llvm::DIType *CGDebugInfo::CreateType(co
> >> EltTys.push_back(DBuilder.createMemberType(
> >> Unit, "__descriptor", nullptr, LineNo, FieldSize,
> >> FieldAlign, FieldOffset,
> >> llvm::DINode::FlagZero, DescTy));
> >> + FieldOffset += FieldSize;
> >> }
> >>
> >> - FieldOffset += FieldSize;
> >> Elements = DBuilder.getOrCreateArray(EltTys);
> >>
> >> // The __block_literal_generic structs are marked with a special
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits [3]
> >
> >
> > Links:
> > --
> > [1] http://llvm.org/viewvc/llvm-project?rev=338321view=rev
> > [2]
> >
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=338321r1=338320r2=338321view=diff
> > [3] http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-07-31 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

In https://reviews.llvm.org/D46845#1183435, @mclow.lists wrote:

> One more thing - 
>  When you add a new header file, you need to update 
> `include/module.modulemap`, `test/libcxx/double_include.sh.cpp`, and 
> `include/CMakeLists.txt`.
>  Take a look at https://reviews.llvm.org/D49338 for an example.


Are you sure we have to update test/libcxx/double_include.sh.cpp? Looks like 
that file only has public headers, but this patch only adds `__node_handle`, 
which is internal. The new patch adds this header to include/CMakeLists.txt 
though (`__node_handle` already appeared in module.modulemap)


https://reviews.llvm.org/D46845



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


[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant

2018-07-31 Thread Balaji Iyer via Phabricator via cfe-commits
bviyer updated this revision to Diff 158392.
bviyer added a comment.

Forgot to pass the -emit-llvm to the test case.


https://reviews.llvm.org/D49952

Files:
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/empty-struct-init-list.cpp


Index: test/CodeGenCXX/empty-struct-init-list.cpp
===
--- /dev/null
+++ test/CodeGenCXX/empty-struct-init-list.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s
+// RUN: %clang_cc1 -std=c++14 -emit-llvm %s
+// RUN: %clang_cc1 -std=c++17 -emit-llvm %s
+// expected-no-diagnostics
+
+typedef struct { } a;
+
+typedef struct {
+  a b[];
+} c;
+c d{ };
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -2119,6 +2119,16 @@
   Elts.push_back(C);
 }
 
+/* This means that the array type is probably "IncompleteType" or some
+   type that is not ConstantArray.  */
+if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
+  const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
+  CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
+  llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
+NumElements);
+  return llvm::ConstantAggregateZero::get(AType);
+}
+
 return EmitArrayConstant(CGM, CAT, CommonElementType, NumElements, Elts,
  Filler);
   }


Index: test/CodeGenCXX/empty-struct-init-list.cpp
===
--- /dev/null
+++ test/CodeGenCXX/empty-struct-init-list.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11 -emit-llvm %s
+// RUN: %clang_cc1 -std=c++14 -emit-llvm %s
+// RUN: %clang_cc1 -std=c++17 -emit-llvm %s
+// expected-no-diagnostics
+
+typedef struct { } a;
+
+typedef struct {
+  a b[];
+} c;
+c d{ };
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -2119,6 +2119,16 @@
   Elts.push_back(C);
 }
 
+/* This means that the array type is probably "IncompleteType" or some
+   type that is not ConstantArray.  */
+if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
+  const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
+  CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
+  llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
+NumElements);
+  return llvm::ConstantAggregateZero::get(AType);
+}
+
 return EmitArrayConstant(CGM, CAT, CommonElementType, NumElements, Elts,
  Filler);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338444 - Revert r337635 "[Driver] Sanitizer support based on runtime library presence"

2018-07-31 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue Jul 31 14:57:35 2018
New Revision: 338444

URL: http://llvm.org/viewvc/llvm-project?rev=338444=rev
Log:
Revert r337635 "[Driver] Sanitizer support based on runtime library presence"

This change causes issues with distributed build systems, which may only
have compiler binaries without any runtime libraries. See discussion
about this on https://reviews.llvm.org/D15225.

Removed:
cfe/trunk/test/Driver/Inputs/resource_dir/lib/darwin/
Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/lib/Driver/ToolChains/Darwin.h
cfe/trunk/test/Driver/darwin-asan-nofortify.c
cfe/trunk/test/Driver/darwin-sanitizer-ld.c
cfe/trunk/test/Driver/fsanitize.c
cfe/trunk/test/Driver/fuzzer.c
cfe/trunk/test/Driver/sanitizer-ld.c

Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=338444=338443=338444=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Jul 31 14:57:35 2018
@@ -916,26 +916,13 @@ unsigned DarwinClang::GetDefaultDwarfVer
   return 4;
 }
 
-SmallString<128> MachO::runtimeLibDir(bool IsEmbedded) const {
-  SmallString<128> Dir(getDriver().ResourceDir);
-  llvm::sys::path::append(
-  Dir, "lib", IsEmbedded ? "macho_embedded" : "darwin");
-  return Dir;
-}
-
-std::string Darwin::getFileNameForSanitizerLib(StringRef SanitizerName,
-  bool Shared) const {
-  return (Twine("libclang_rt.") + SanitizerName + "_" +
-  getOSLibraryNameSuffix() +
-  (Shared ? "_dynamic.dylib" : ".a")).str();
-
-}
-
 void MachO::AddLinkRuntimeLib(const ArgList , ArgStringList ,
   StringRef DarwinLibName,
   RuntimeLinkOptions Opts) const {
+  SmallString<128> Dir(getDriver().ResourceDir);
+  llvm::sys::path::append(
+  Dir, "lib", (Opts & RLO_IsEmbedded) ? "macho_embedded" : "darwin");
 
-  SmallString<128> Dir = runtimeLibDir(Opts & RLO_IsEmbedded);
   SmallString<128> P(Dir);
   llvm::sys::path::append(P, DarwinLibName);
 
@@ -1055,9 +1042,12 @@ void DarwinClang::AddLinkSanitizerLibArg
   StringRef Sanitizer,
   bool Shared) const {
   auto RLO = RuntimeLinkOptions(RLO_AlwaysLink | (Shared ? RLO_AddRPath : 0U));
-  std::string SanitizerRelFilename =
-  getFileNameForSanitizerLib(Sanitizer, Shared);
-  AddLinkRuntimeLib(Args, CmdArgs, SanitizerRelFilename, RLO);
+  AddLinkRuntimeLib(Args, CmdArgs,
+(Twine("libclang_rt.") + Sanitizer + "_" +
+ getOSLibraryNameSuffix() +
+ (Shared ? "_dynamic.dylib" : ".a"))
+.str(),
+RLO);
 }
 
 ToolChain::RuntimeLibType DarwinClang::GetRuntimeLibType(
@@ -2295,43 +2285,24 @@ void Darwin::CheckObjCARC() const {
 SanitizerMask Darwin::getSupportedSanitizers() const {
   const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
-
-  {
-using namespace SanitizerKind;
-assert(!(Res & (Address | Leak | Fuzzer | FuzzerNoLink | Thread)) &&
-   "Sanitizer is already registered as supported");
-  }
-
-  if (sanitizerRuntimeExists("asan"))
-Res |= SanitizerKind::Address;
-  if (sanitizerRuntimeExists("lsan"))
-Res |= SanitizerKind::Leak;
-  if (sanitizerRuntimeExists("fuzzer", /*Shared=*/false)) {
-Res |= SanitizerKind::Fuzzer;
-Res |= SanitizerKind::FuzzerNoLink;
-  }
+  Res |= SanitizerKind::Address;
+  Res |= SanitizerKind::Leak;
+  Res |= SanitizerKind::Fuzzer;
+  Res |= SanitizerKind::FuzzerNoLink;
   Res |= SanitizerKind::Function;
-  if (isTargetMacOS() && !isMacosxVersionLT(10, 9))
-Res |= SanitizerKind::Vptr;
-  if (isTargetMacOS())
+  if (isTargetMacOS()) {
+if (!isMacosxVersionLT(10, 9))
+  Res |= SanitizerKind::Vptr;
 Res |= SanitizerKind::SafeStack;
-
-  if (sanitizerRuntimeExists("tsan") && IsX86_64 &&
-  (isTargetMacOS() || isTargetIOSSimulator() || isTargetTvOSSimulator()))
-Res |= SanitizerKind::Thread;
-
+if (IsX86_64)
+  Res |= SanitizerKind::Thread;
+  } else if (isTargetIOSSimulator() || isTargetTvOSSimulator()) {
+if (IsX86_64)
+  Res |= SanitizerKind::Thread;
+  }
   return Res;
 }
 
 void Darwin::printVerboseInfo(raw_ostream ) const {
   CudaInstallation.print(OS);
 }
-
-bool Darwin::sanitizerRuntimeExists(StringRef SanitizerName,
-bool Shared) const {
-std::string RelName = getFileNameForSanitizerLib(SanitizerName, Shared);
-SmallString<128> Dir = runtimeLibDir();
-SmallString<128> AbsName(Dir);
-llvm::sys::path::append(AbsName, RelName);
-return getVFS().exists(AbsName);
-}


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In https://reviews.llvm.org/D50050#1183341, @rjmccall wrote:

> LGTM.


Thank you for the review.
I'll land in ~+9 hours or so, since i did not hear from @erichkeane back yet..


Repository:
  rC Clang

https://reviews.llvm.org/D50050



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


[PATCH] D49952: Check for NULL Destination-Type when creating ArrayConstant

2018-07-31 Thread Balaji Iyer via Phabricator via cfe-commits
bviyer updated this revision to Diff 158391.
bviyer added a comment.

Fixed code as suggested by John McCall.


Repository:
  rC Clang

https://reviews.llvm.org/D49952

Files:
  lib/CodeGen/CGExprConstant.cpp
  test/CodeGenCXX/empty-struct-init-list.cpp


Index: test/CodeGenCXX/empty-struct-init-list.cpp
===
--- /dev/null
+++ test/CodeGenCXX/empty-struct-init-list.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11  %s
+// RUN: %clang_cc1 -std=c++14  %s
+// RUN: %clang_cc1 -std=c++17  %s
+// expected-no-diagnostics
+
+typedef struct { } a;
+
+typedef struct {
+  a b[];
+} c;
+c d{ };
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -2119,6 +2119,16 @@
   Elts.push_back(C);
 }
 
+/* This means that the array type is probably "IncompleteType" or some
+   type that is not ConstantArray.  */
+if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
+  const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
+  CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
+  llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
+NumElements);
+  return llvm::ConstantAggregateZero::get(AType);
+}
+
 return EmitArrayConstant(CGM, CAT, CommonElementType, NumElements, Elts,
  Filler);
   }


Index: test/CodeGenCXX/empty-struct-init-list.cpp
===
--- /dev/null
+++ test/CodeGenCXX/empty-struct-init-list.cpp
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -std=c++11  %s
+// RUN: %clang_cc1 -std=c++14  %s
+// RUN: %clang_cc1 -std=c++17  %s
+// expected-no-diagnostics
+
+typedef struct { } a;
+
+typedef struct {
+  a b[];
+} c;
+c d{ };
Index: lib/CodeGen/CGExprConstant.cpp
===
--- lib/CodeGen/CGExprConstant.cpp
+++ lib/CodeGen/CGExprConstant.cpp
@@ -2119,6 +2119,16 @@
   Elts.push_back(C);
 }
 
+/* This means that the array type is probably "IncompleteType" or some
+   type that is not ConstantArray.  */
+if (CAT == nullptr && CommonElementType == nullptr && !NumInitElts) {
+  const ArrayType *AT = CGM.getContext().getAsArrayType(DestType);
+  CommonElementType = CGM.getTypes().ConvertType(AT->getElementType());
+  llvm::ArrayType *AType = llvm::ArrayType::get(CommonElementType,
+NumElements);
+  return llvm::ConstantAggregateZero::get(AType);
+}
+
 return EmitArrayConstant(CGM, CAT, CommonElementType, NumElements, Elts,
  Filler);
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D50104: [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-07-31 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CGBuiltin.cpp:3342
   auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
+  // Always insert the alloca in the entry block so it remains static in
+  // the SelectionDAG.
+  BasicBlock *Begin = nullptr;
+  if (Instruction *Entry = CurFn->getEntryBlock().getTerminator()) {
+Begin = Builder.GetInsertBlock();
+Builder.SetInsertPoint(Entry);
+  }
   auto *Arr = Builder.CreateAlloca(AT);
   llvm::Value *Ptr;

You may try CreateMemTemp. It should handle the insert position and also debug 
info.



Comment at: test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl:2
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple amdgcn | 
FileCheck %s --check-prefixes=COMMON,AMDGPU
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple 
"spir-unknown-unknown" | FileCheck %s --check-prefixes=COMMON,SPIR32
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple 
"spir64-unknown-unknown" | FileCheck %s --check-prefixes=COMMON,SPIR64

Can we have a run line for debug info?


Repository:
  rC Clang

https://reviews.llvm.org/D50104



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


[PATCH] D46845: [libcxx][c++17] P0083R5: Splicing Maps and Sets

2018-07-31 Thread Marshall Clow via Phabricator via cfe-commits
mclow.lists added a comment.

One more thing - 
When you add a new header file, you need to update `include/module.modulemap`, 
`test/libcxx/double_include.sh.cpp`, and `include/CMakeLists.txt`.
Take a look at https://reviews.llvm.org/D49338 for an example.


https://reviews.llvm.org/D46845



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


[PATCH] D49210: [CFG] [analyzer] NFC: Enumerate construction context layer kinds and re-use their code for ExprEngine keys.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision.
NoQ added a comment.

Committed as https://reviews.llvm.org/rC338439 but Phabricator didn't pick it 
up because i put a `.` after the phabricator link.


https://reviews.llvm.org/D49210



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


[PATCH] D48681: [CFG] [analyzer] Add construction contexts for function arguments.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ closed this revision.
NoQ added a comment.

Committed as https://reviews.llvm.org/rC338436 but Phabricator didn't pick it 
up because i put a `.` after the phabricator link.


https://reviews.llvm.org/D48681



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


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

2018-07-31 Thread Louis Dionne via Phabricator via cfe-commits
ldionne created this revision.
ldionne added reviewers: EricWF, mclow.lists.
Herald added subscribers: cfe-commits, dexonsmith, christof.

The implementation of operator= for tuple currently diverges from the way
the Standard specifies them, which leads to subtle cases where the behavior
is not as specified. In particular, a class derived from a tuple-like type
(e.g. pair) could not be assigned to a tuple with corresponding members.
This commit re-implements operator= in a way much closer to the specification
and gets rid of this bug. Tests have been stolen from EricWF's assignment
tests in https://reviews.llvm.org/D27606.

As a fly-by improvement, tests for noexcept correctness have been added to
all overloads of operator=.

PR17550
rdar://problem/15837420


Repository:
  rCXX libc++

https://reviews.llvm.org/D50106

Files:
  libcxx/include/tuple
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/const_array.pass.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/rvalue_array.pass.cpp
  
libcxx/test/libcxx/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/const_pair.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_copy.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/convert_move.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/copy.pass.cpp
  
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/derived_from_tuple_like.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move.pass.cpp
  libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/move_pair.pass.cpp
  
libcxx/test/std/utilities/tuple/tuple.tuple/tuple.assign/tuple_array_template_depth.pass.cpp
  libcxx/test/support/propagate_value_category.hpp

Index: libcxx/test/support/propagate_value_category.hpp
===
--- /dev/null
+++ libcxx/test/support/propagate_value_category.hpp
@@ -0,0 +1,154 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+#define TEST_SUPPORT_PROPAGATE_VALUE_CATEGORY
+
+#include "test_macros.h"
+#include 
+
+#if TEST_STD_VER < 11
+#error this header may only be used in C++11
+#endif
+
+using UnderlyingVCType = unsigned;
+enum ValueCategory : UnderlyingVCType {
+  VC_None = 0,
+  VC_LVal = 1 << 0,
+  VC_RVal = 1 << 1,
+  VC_Const = 1 << 2,
+  VC_Volatile = 1 << 3,
+  VC_ConstVolatile = VC_Const | VC_Volatile
+};
+
+inline constexpr ValueCategory operator&(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS & (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator|(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS | (UnderlyingVCType)RHS);
+}
+
+inline constexpr ValueCategory operator^(ValueCategory LHS, ValueCategory RHS) {
+  return ValueCategory(LHS ^ (UnderlyingVCType)RHS);
+}
+
+inline constexpr bool isValidValueCategory(ValueCategory VC) {
+  return (VC & (VC_LVal | VC_RVal)) != (VC_LVal | VC_RVal);
+}
+
+inline constexpr bool hasValueCategory(ValueCategory Arg, ValueCategory Key) {
+  return Arg == Key || ((Arg & Key) == Key);
+}
+
+template 
+using UnCVRef =
+typename std::remove_cv::type>::type;
+
+template 
+constexpr ValueCategory getReferenceQuals() {
+  return std::is_lvalue_reference::value
+ ? VC_LVal
+ : (std::is_rvalue_reference::value ? VC_RVal : VC_None);
+}
+static_assert(getReferenceQuals() == VC_None, "");
+static_assert(getReferenceQuals() == VC_LVal, "");
+static_assert(getReferenceQuals() == VC_RVal, "");
+
+template 
+constexpr ValueCategory getCVQuals() {
+  using Vp = typename std::remove_reference::type;
+  return std::is_const::value && std::is_volatile::value
+ ? VC_ConstVolatile
+ : (std::is_const::value
+? VC_Const
+: (std::is_volatile::value ? VC_Volatile : VC_None));
+}
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+static_assert(getCVQuals() == VC_Volatile, "");
+static_assert(getCVQuals() == VC_ConstVolatile, "");
+static_assert(getCVQuals() == VC_None, "");
+static_assert(getCVQuals() == VC_Const, "");
+
+template 
+inline constexpr ValueCategory getValueCategory() {
+  return getReferenceQuals() | getCVQuals();
+}
+static_assert(getValueCategory() == VC_None, "");
+static_assert(getValueCategory() == (VC_LVal | VC_Const), "");
+static_assert(getValueCategory() ==
+  (VC_RVal | VC_ConstVolatile),
+  "");
+
+template 
+struct ApplyValueCategory {
+private:
+  

[PATCH] D50055: Update the coding standard about NFC changes and whitespace

2018-07-31 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc added inline comments.



Comment at: docs/DeveloperPolicy.rst:395-408
+Commits with No Functional Change
+-
+
+It may be permissible to commit changes without prior review when the changes
+have no semantic impact on the code if the changes being made are obvious and
+not invasive. For instance, removing trailing whitespace from a line, fixing a
+line ending to be consistent with the rest of the file, fixing a typo, code

I think this is a much broader statement than is warranted to address the 
specific problem. And I'm not completely comfortable with it.

I don't think guidance around "no functional change" is the right way to give 
guidance about what is or isn't "obvious" and fine to commit with post-commit 
review personally.

I'd really suggest just being direct about *formatting* and whitespace changes, 
and specifically suggest that they not be made unless the file or code region 
in question is an area that the author is planning subsequent changes to.


https://reviews.llvm.org/D50055



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


[PATCH] D49627: [CFG] [analyzer] Constructors of member CXXOperatorCallExpr's argument 0 are not argument constructors.

2018-07-31 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In https://reviews.llvm.org/D49627#1176326, @baloghadamsoftware wrote:

> How much different is a correct `this`-argument construction context from 
> real argument construction contexts?


It's identified in a similar manner; this patch pretty much already shows how 
to identify it. It carries the same amount of information: what call, what 
argument.

The tricky part is to come up with a good description for the target region and 
make sure it's actually used when the operator call is inlined.  It would 
probably be a simple `CXXTempObjectRegion` because we don't have a `VarDecl` to 
make a `VarRegion`.

Then we might need to proactively bind in in the Store to `CXXThisRegion` of 
the call, and for that purpose we might need a crystal ball to guess the future 
`StackFrameContext`, like in case of arguments.

We still need to invalidate the target region if operator call is 
conservatively evaluated, like in case of arguments, because the destructor 
will use the updated object.


https://reviews.llvm.org/D49627



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


[PATCH] D50104: [OpenCL] Always emit alloca in entry block for enqueue_kernel builtin

2018-07-31 Thread Scott Linder via Phabricator via cfe-commits
scott.linder created this revision.
scott.linder added reviewers: yaxunl, Anastasia, arsenm.
Herald added subscribers: cfe-commits, wdng.

Ensures the statically sized alloca is not converted to DYNAMIC_STACKALLOC 
later because it is not in the entry block.

I believe it is valid to insert the alloca in the entry block, but I'm not 
confident the way I accomplish it is correct.


Repository:
  rC Clang

https://reviews.llvm.org/D50104

Files:
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl


Index: test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple amdgcn | 
FileCheck %s --check-prefixes=COMMON,AMDGPU
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple 
"spir-unknown-unknown" | FileCheck %s --check-prefixes=COMMON,SPIR32
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple 
"spir64-unknown-unknown" | FileCheck %s --check-prefixes=COMMON,SPIR64
+
+typedef struct {int a;} ndrange_t;
+
+kernel void test(int i) {
+// COMMON-LABEL: define {{.*}} void @test
+// COMMON-LABEL: entry:
+// AMDGPU: alloca [1 x i64]
+// SPIR32: alloca [1 x i32]
+// SPIR64: alloca [1 x i64]
+// COMMON-LABEL: if.then:
+// COMMON-NOT: alloca
+// COMMON-LABEL: if.end
+  queue_t default_queue;
+  unsigned flags = 0;
+  ndrange_t ndrange;
+  if (i)
+enqueue_kernel(default_queue, flags, ndrange, ^(local void *a) { }, 32);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -3339,7 +3339,16 @@
 // for the block. \p First is the position of the first size argument.
 auto CreateArrayForSizeVar = [=](unsigned First) {
   auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
+  // Always insert the alloca in the entry block so it remains static in
+  // the SelectionDAG.
+  BasicBlock *Begin = nullptr;
+  if (Instruction *Entry = CurFn->getEntryBlock().getTerminator()) {
+Begin = Builder.GetInsertBlock();
+Builder.SetInsertPoint(Entry);
+  }
   auto *Arr = Builder.CreateAlloca(AT);
+  if (Begin)
+Builder.SetInsertPoint(Begin);
   llvm::Value *Ptr;
   // Each of the following arguments specifies the size of the 
corresponding
   // argument passed to the enqueued block.


Index: test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
===
--- /dev/null
+++ test/CodeGenOpenCL/enqueue-kernel-non-entry-block.cl
@@ -0,0 +1,21 @@
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple amdgcn | FileCheck %s --check-prefixes=COMMON,AMDGPU
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple "spir-unknown-unknown" | FileCheck %s --check-prefixes=COMMON,SPIR32
+// RUN: %clang_cc1 %s -cl-std=CL2.0 -O0 -emit-llvm -o - -triple "spir64-unknown-unknown" | FileCheck %s --check-prefixes=COMMON,SPIR64
+
+typedef struct {int a;} ndrange_t;
+
+kernel void test(int i) {
+// COMMON-LABEL: define {{.*}} void @test
+// COMMON-LABEL: entry:
+// AMDGPU: alloca [1 x i64]
+// SPIR32: alloca [1 x i32]
+// SPIR64: alloca [1 x i64]
+// COMMON-LABEL: if.then:
+// COMMON-NOT: alloca
+// COMMON-LABEL: if.end
+  queue_t default_queue;
+  unsigned flags = 0;
+  ndrange_t ndrange;
+  if (i)
+enqueue_kernel(default_queue, flags, ndrange, ^(local void *a) { }, 32);
+}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -3339,7 +3339,16 @@
 // for the block. \p First is the position of the first size argument.
 auto CreateArrayForSizeVar = [=](unsigned First) {
   auto *AT = llvm::ArrayType::get(SizeTy, NumArgs - First);
+  // Always insert the alloca in the entry block so it remains static in
+  // the SelectionDAG.
+  BasicBlock *Begin = nullptr;
+  if (Instruction *Entry = CurFn->getEntryBlock().getTerminator()) {
+Begin = Builder.GetInsertBlock();
+Builder.SetInsertPoint(Entry);
+  }
   auto *Arr = Builder.CreateAlloca(AT);
+  if (Begin)
+Builder.SetInsertPoint(Begin);
   llvm::Value *Ptr;
   // Each of the following arguments specifies the size of the corresponding
   // argument passed to the enqueued block.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49771: CodeGen: use non-zero memset when possible for automatic variables

2018-07-31 Thread JF Bastien via Phabricator via cfe-commits
jfb added a comment.

In https://reviews.llvm.org/D49771#1181008, @mehdi_amini wrote:

> I'm curious: isn't the kind of optimization we should expect LLVM to provide?


Maybe? It seems obvious to do here since we know we'll probably want to be 
doing it, and I have another patch I'm working on which will make it that much 
more obviously useful to have here. The middle-end can definitely figure it out 
but it just seems like more work, later, so in the meantime we'd be looking at 
more stuff.


Repository:
  rL LLVM

https://reviews.llvm.org/D49771



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


[PATCH] D49213: [analyzer] pr38072: Suppress an assertion failure for eliding the same destructor twice due to the default argument problem.

2018-07-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rC338441: [analyzer] Fix eliding the same destructor twice due 
to buggy default arguments. (authored by dergachev, committed by ).

Repository:
  rC Clang

https://reviews.llvm.org/D49213

Files:
  lib/StaticAnalyzer/Core/ExprEngine.cpp
  test/Analysis/temporaries.cpp


Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -458,6 +458,21 @@
 #endif // TEMPORARY_DTORS
 }
 
+namespace default_param_elided_destructors {
+struct a {
+  ~a();
+};
+struct F {
+  a d;
+  F(char *, a = a());
+};
+void g() {
+  char h[1];
+  for (int i = 0;;)
+F j(i ? j : h);
+}
+} // namespace default_param_elided_destructors
+
 void testStaticMaterializeTemporaryExpr() {
   static const Trivial  = getTrivial();
   clang_analyzer_eval(ref.value == 42); // expected-warning{{TRUE}}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -460,7 +460,8 @@
 const CXXBindTemporaryExpr *BTE,
 const LocationContext *LC) {
   ConstructedObjectKey Key({BTE, /*IsElided=*/true}, LC);
-  assert(!State->contains(Key));
+  // FIXME: Currently the state might already contain the marker due to
+  // incorrect handling of temporaries bound to default parameters.
   return State->set(Key, UnknownVal());
 }
 


Index: test/Analysis/temporaries.cpp
===
--- test/Analysis/temporaries.cpp
+++ test/Analysis/temporaries.cpp
@@ -458,6 +458,21 @@
 #endif // TEMPORARY_DTORS
 }
 
+namespace default_param_elided_destructors {
+struct a {
+  ~a();
+};
+struct F {
+  a d;
+  F(char *, a = a());
+};
+void g() {
+  char h[1];
+  for (int i = 0;;)
+F j(i ? j : h);
+}
+} // namespace default_param_elided_destructors
+
 void testStaticMaterializeTemporaryExpr() {
   static const Trivial  = getTrivial();
   clang_analyzer_eval(ref.value == 42); // expected-warning{{TRUE}}
Index: lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -460,7 +460,8 @@
 const CXXBindTemporaryExpr *BTE,
 const LocationContext *LC) {
   ConstructedObjectKey Key({BTE, /*IsElided=*/true}, LC);
-  assert(!State->contains(Key));
+  // FIXME: Currently the state might already contain the marker due to
+  // incorrect handling of temporaries bound to default parameters.
   return State->set(Key, UnknownVal());
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r338441 - [analyzer] Fix eliding the same destructor twice due to buggy default arguments.

2018-07-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Jul 31 14:17:40 2018
New Revision: 338441

URL: http://llvm.org/viewvc/llvm-project?rev=338441=rev
Log:
[analyzer] Fix eliding the same destructor twice due to buggy default arguments.

Because of incomplete support for CXXDefaultArgExpr, we cannot yet commit to
asserting that the same destructor won't be elided twice.

Suppress the assertion failure for now. Proper support is still an open problem.

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
cfe/trunk/test/Analysis/temporaries.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=338441=338440=338441=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Tue Jul 31 14:17:40 2018
@@ -460,7 +460,8 @@ ProgramStateRef ExprEngine::elideDestruc
 const CXXBindTemporaryExpr *BTE,
 const LocationContext *LC) {
   ConstructedObjectKey Key({BTE, /*IsElided=*/true}, LC);
-  assert(!State->contains(Key));
+  // FIXME: Currently the state might already contain the marker due to
+  // incorrect handling of temporaries bound to default parameters.
   return State->set(Key, UnknownVal());
 }
 

Modified: cfe/trunk/test/Analysis/temporaries.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/temporaries.cpp?rev=338441=338440=338441=diff
==
--- cfe/trunk/test/Analysis/temporaries.cpp (original)
+++ cfe/trunk/test/Analysis/temporaries.cpp Tue Jul 31 14:17:40 2018
@@ -458,6 +458,21 @@ namespace destructors {
 #endif // TEMPORARY_DTORS
 }
 
+namespace default_param_elided_destructors {
+struct a {
+  ~a();
+};
+struct F {
+  a d;
+  F(char *, a = a());
+};
+void g() {
+  char h[1];
+  for (int i = 0;;)
+F j(i ? j : h);
+}
+} // namespace default_param_elided_destructors
+
 void testStaticMaterializeTemporaryExpr() {
   static const Trivial  = getTrivial();
   clang_analyzer_eval(ref.value == 42); // expected-warning{{TRUE}}


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


[PATCH] D50102: Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

It is great when the test cases are included :)


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50102



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


r338439 - [CFG] [analyzer] NFC: Enumerate construction context layer kinds.

2018-07-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Jul 31 14:12:42 2018
New Revision: 338439

URL: http://llvm.org/viewvc/llvm-project?rev=338439=rev
Log:
[CFG] [analyzer] NFC: Enumerate construction context layer kinds.

This is a refactoring patch; no functional change intended.

The common part of ConstructionContextLayer and ConstructedObjectKey is
factored out into a new structure, ConstructionContextItem.

Various sub-kinds of ConstructionContextItem are enumerated in order to
provide richer information about construction contexts.

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

Modified:
cfe/trunk/include/clang/Analysis/ConstructionContext.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Analysis/ConstructionContext.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp

Modified: cfe/trunk/include/clang/Analysis/ConstructionContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ConstructionContext.h?rev=338439=338438=338439=diff
==
--- cfe/trunk/include/clang/Analysis/ConstructionContext.h (original)
+++ cfe/trunk/include/clang/Analysis/ConstructionContext.h Tue Jul 31 14:12:42 
2018
@@ -22,74 +22,193 @@
 
 namespace clang {
 
-/// Construction context is a linked list of multiple layers. Layers are
-/// created gradually while traversing the AST, and layers that represent
-/// the outmost AST nodes are built first, while the node that immediately
-/// contains the constructor would be built last and capture the previous
-/// layers as its parents. Construction context captures the last layer
-/// (which has links to the previous layers) and classifies the seemingly
-/// arbitrary chain of layers into one of the possible ways of constructing
-/// an object in C++ for user-friendly experience.
-class ConstructionContextLayer {
+/// Represents a single point (AST node) in the program that requires attention
+/// during construction of an object. ConstructionContext would be represented
+/// as a list of such items.
+class ConstructionContextItem {
 public:
-  typedef llvm::PointerUnion TriggerTy;
+  enum ItemKind {
+VariableKind,
+NewAllocatorKind,
+ReturnKind,
+MaterializationKind,
+TemporaryDestructorKind,
+ElidedDestructorKind,
+ElidableConstructorKind,
+ArgumentKind,
+STATEMENT_WITH_INDEX_KIND_BEGIN=ArgumentKind,
+STATEMENT_WITH_INDEX_KIND_END=ArgumentKind,
+STATEMENT_KIND_BEGIN = VariableKind,
+STATEMENT_KIND_END = ArgumentKind,
+InitializerKind,
+INITIALIZER_KIND_BEGIN=InitializerKind,
+INITIALIZER_KIND_END=InitializerKind
+  };
+
+  LLVM_DUMP_METHOD static StringRef getKindAsString(ItemKind K) {
+switch (K) {
+  case VariableKind:return "construct into local variable";
+  case NewAllocatorKind:return "construct into new-allocator";
+  case ReturnKind:  return "construct into return address";
+  case MaterializationKind: return "materialize temporary";
+  case TemporaryDestructorKind: return "destroy temporary";
+  case ElidedDestructorKind:return "elide destructor";
+  case ElidableConstructorKind: return "elide constructor";
+  case ArgumentKind:return "construct into argument";
+  case InitializerKind: return "construct into member variable";
+};
+  }
 
 private:
+  const void *const Data;
+  const ItemKind Kind;
+  const unsigned Index = 0;
+
+  bool hasStatement() const {
+return Kind >= STATEMENT_KIND_BEGIN &&
+   Kind <= STATEMENT_KIND_END;
+  }
+
+  bool hasIndex() const {
+return Kind >= STATEMENT_WITH_INDEX_KIND_BEGIN &&
+   Kind >= STATEMENT_WITH_INDEX_KIND_END;
+  }
+
+  bool hasInitializer() const {
+return Kind >= INITIALIZER_KIND_BEGIN &&
+   Kind <= INITIALIZER_KIND_END;
+  }
+
+public:
+  // ConstructionContextItem should be simple enough so that it was easy to
+  // re-construct it from the AST node it captures. For that reason we provide
+  // simple implicit conversions from all sorts of supported AST nodes.
+  ConstructionContextItem(const DeclStmt *DS)
+  : Data(DS), Kind(VariableKind) {}
+
+  ConstructionContextItem(const CXXNewExpr *NE)
+  : Data(NE), Kind(NewAllocatorKind) {}
+
+  ConstructionContextItem(const ReturnStmt *RS)
+  : Data(RS), Kind(ReturnKind) {}
+
+  ConstructionContextItem(const MaterializeTemporaryExpr *MTE)
+  : Data(MTE), Kind(MaterializationKind) {}
+
+  ConstructionContextItem(const CXXBindTemporaryExpr *BTE,
+  bool IsElided = false)
+  : Data(BTE),
+Kind(IsElided ? ElidedDestructorKind : TemporaryDestructorKind) {}
+
+  ConstructionContextItem(const CXXConstructExpr *CE)
+  : Data(CE), Kind(ElidableConstructorKind) {}
+
+  ConstructionContextItem(const CallExpr *CE, unsigned Index)
+  : Data(CE), 

[PATCH] D50102: Use ExprMutationAnalyzer in performance-unnecessary-value-param

2018-07-31 Thread Shuai Wang via Phabricator via cfe-commits
shuaiwang created this revision.
Herald added a reviewer: george.karpenkov.
Herald added subscribers: cfe-commits, a.sidorin.

This yields better recall as ExprMutationAnalyzer is more accurate.

One common pattern this check is now able to catch is:

  void foo(std::vector v) {
for (const auto& elm : v) {
  // ...
}
  }


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D50102

Files:
  clang-tidy/performance/UnnecessaryValueParamCheck.cpp


Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -10,6 +10,7 @@
 #include "UnnecessaryValueParamCheck.h"
 
 #include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include "../utils/Matchers.h"
 #include "../utils/TypeTraits.h"
@@ -98,43 +99,52 @@
 void UnnecessaryValueParamCheck::check(const MatchFinder::MatchResult ) 
{
   const auto *Param = Result.Nodes.getNodeAs("param");
   const auto *Function = Result.Nodes.getNodeAs("functionDecl");
-  const size_t Index = std::find(Function->parameters().begin(),
- Function->parameters().end(), Param) -
-   Function->parameters().begin();
-  bool IsConstQualified =
-  Param->getType().getCanonicalType().isConstQualified();
-
-  auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
-  *Param, *Function, *Result.Context);
-  auto ConstDeclRefExprs = utils::decl_ref_expr::constReferenceDeclRefExprs(
-  *Param, *Function, *Result.Context);
 
   // Do not trigger on non-const value parameters when they are not only used 
as
   // const.
-  if (!isSubset(AllDeclRefExprs, ConstDeclRefExprs))
+  if (utils::ExprMutationAnalyzer(Function->getBody(), Result.Context)
+  .isMutated(Param))
 return;
+  if (const auto *Ctor = dyn_cast(Function)) {
+for (const auto *Init : Ctor->inits()) {
+  if (utils::ExprMutationAnalyzer(Init->getInit(), Result.Context)
+  .isMutated(Param))
+return;
+}
+  }
+
+  const bool IsConstQualified =
+  Param->getType().getCanonicalType().isConstQualified();
 
   // If the parameter is non-const, check if it has a move constructor and is
   // only referenced once to copy-construct another object or whether it has a
   // move assignment operator and is only referenced once when copy-assigned.
   // In this case wrap DeclRefExpr with std::move() to avoid the unnecessary
   // copy.
-  if (!IsConstQualified && AllDeclRefExprs.size() == 1) {
-auto CanonicalType = Param->getType().getCanonicalType();
-const auto   = **AllDeclRefExprs.begin();
-
-if (!hasLoopStmtAncestor(DeclRefExpr, *Function, *Result.Context) &&
-((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
-  utils::decl_ref_expr::isCopyConstructorArgument(
-  DeclRefExpr, *Function, *Result.Context)) ||
- (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) &&
-  utils::decl_ref_expr::isCopyAssignmentArgument(
-  DeclRefExpr, *Function, *Result.Context {
-  handleMoveFix(*Param, DeclRefExpr, *Result.Context);
-  return;
+  if (!IsConstQualified) {
+auto AllDeclRefExprs = utils::decl_ref_expr::allDeclRefExprs(
+*Param, *Function, *Result.Context);
+if (AllDeclRefExprs.size() == 1) {
+  auto CanonicalType = Param->getType().getCanonicalType();
+  const auto  = **AllDeclRefExprs.begin();
+
+  if (!hasLoopStmtAncestor(DeclRefExpr, *Function, *Result.Context) &&
+  ((utils::type_traits::hasNonTrivialMoveConstructor(CanonicalType) &&
+utils::decl_ref_expr::isCopyConstructorArgument(
+DeclRefExpr, *Function, *Result.Context)) ||
+   (utils::type_traits::hasNonTrivialMoveAssignment(CanonicalType) &&
+utils::decl_ref_expr::isCopyAssignmentArgument(
+DeclRefExpr, *Function, *Result.Context {
+handleMoveFix(*Param, DeclRefExpr, *Result.Context);
+return;
+  }
 }
   }
 
+  const size_t Index = std::find(Function->parameters().begin(),
+ Function->parameters().end(), Param) -
+   Function->parameters().begin();
+
   auto Diag =
   diag(Param->getLocation(),
IsConstQualified ? "the const qualified parameter %0 is "


Index: clang-tidy/performance/UnnecessaryValueParamCheck.cpp
===
--- clang-tidy/performance/UnnecessaryValueParamCheck.cpp
+++ clang-tidy/performance/UnnecessaryValueParamCheck.cpp
@@ -10,6 +10,7 @@
 #include "UnnecessaryValueParamCheck.h"
 
 #include "../utils/DeclRefExprUtils.h"
+#include "../utils/ExprMutationAnalyzer.h"
 #include "../utils/FixItHintUtils.h"
 #include 

[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-07-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@rnk OK it's fine with me to revert it now and then we see what can be done.


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 158379.
lebedev.ri added a comment.

Drop pointless cast of zero.


Repository:
  rC Clang

https://reviews.llvm.org/D50050

Files:
  include/clang/AST/Expr.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/Stmt.h
  lib/AST/Expr.cpp
  lib/AST/ExprCXX.cpp
  test/CodeGenCXX/castexpr-basepathsize-threshold.cpp

Index: test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
===
--- /dev/null
+++ test/CodeGenCXX/castexpr-basepathsize-threshold.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 %s -emit-llvm -o -
+
+// https://bugs.llvm.org/show_bug.cgi?id=38356
+// We only check that we do not crash.
+
+template 
+struct d : d {};
+template 
+struct d {
+  a f[0];
+};
+struct g {
+  static g h(unsigned);
+};
+struct i {
+  void j() const;
+  // Current maximum depth of recursive template instantiation is 1024,
+  // thus, this \/ threshold value is used here. BasePathSize in CastExpr might
+  // not fit it, so we are testing that we do fit it.
+  // If -ftemplate-depth= is provided, larger values (4096 and up) cause crashes
+  // elsewhere.
+  d f;
+};
+void i::j() const {
+  const void *k{f.f};
+  (void)k;
+}
Index: lib/AST/ExprCXX.cpp
===
--- lib/AST/ExprCXX.cpp
+++ lib/AST/ExprCXX.cpp
@@ -559,7 +559,9 @@
  SourceLocation RParenLoc,
  SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXStaticCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
  RParenLoc, AngleBrackets);
@@ -571,7 +573,9 @@
 
 CXXStaticCastExpr *CXXStaticCastExpr::CreateEmpty(const ASTContext ,
   unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXStaticCastExpr(EmptyShell(), PathSize);
 }
 
@@ -584,7 +588,9 @@
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXDynamicCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
   RParenLoc, AngleBrackets);
@@ -596,7 +602,9 @@
 
 CXXDynamicCastExpr *CXXDynamicCastExpr::CreateEmpty(const ASTContext ,
 unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXDynamicCastExpr(EmptyShell(), PathSize);
 }
 
@@ -641,7 +649,9 @@
SourceLocation RParenLoc,
SourceRange AngleBrackets) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXReinterpretCastExpr(T, VK, K, Op, PathSize, WrittenTy, L,
   RParenLoc, AngleBrackets);
@@ -653,7 +663,9 @@
 
 CXXReinterpretCastExpr *
 CXXReinterpretCastExpr::CreateEmpty(const ASTContext , unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXReinterpretCastExpr(EmptyShell(), PathSize);
 }
 
@@ -676,7 +688,9 @@
   const CXXCastPath *BasePath,
   SourceLocation L, SourceLocation R) {
   unsigned PathSize = (BasePath ? BasePath->size() : 0);
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   auto *E =
   new (Buffer) CXXFunctionalCastExpr(T, VK, Written, K, Op, PathSize, L, R);
   if (PathSize)
@@ -687,7 +701,9 @@
 
 CXXFunctionalCastExpr *
 CXXFunctionalCastExpr::CreateEmpty(const ASTContext , unsigned PathSize) {
-  void *Buffer = C.Allocate(totalSizeToAlloc(PathSize));
+  void *Buffer =
+  C.Allocate(totalSizeToAlloc(
+  PathSize ? 1 : 0, PathSize));
   return new (Buffer) CXXFunctionalCastExpr(EmptyShell(), PathSize);
 }
 
Index: lib/AST/Expr.cpp

[PATCH] D47394: [OpenMP][Clang][NVPTX] Replace bundling with partial linking for the OpenMP NVPTX device offloading toolchain

2018-07-31 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea added inline comments.



Comment at: include/clang/Driver/Compilation.h:312
+  /// \param skipBundler - bool value set once by the driver.
+  void setSkipOffloadBundler(bool skipBundler);
+

sfantao wrote:
> gtbercea wrote:
> > sfantao wrote:
> > > gtbercea wrote:
> > > > sfantao wrote:
> > > > > Why is this a property of the compilation and not of a set of actions 
> > > > > referring to a given target? That would allow one to combine in the 
> > > > > same compilation targets requiring the bundler and targets that 
> > > > > wouldn't. 
> > > > This was a way to pass this information to the OpenMP NVPTX device 
> > > > toolchain.
> > > > 
> > > > Both the Driver OpenMP NVPTX toolchain need to agree on the usage of 
> > > > the new scheme (proposed in this patch) or the old scheme (the one that 
> > > > is in the compiler today).
> > > > 
> > > > 
> > > I understand, but the way I see it is that it is the toolchain that skips 
> > > the bundler not the compilation. I understand that as of this patch, you 
> > > skip only if there is a single nvptx target. If you have more than one 
> > > target, as some tests do, some toolchains will still need the bundler. 
> > > So, we are making what happens with the nvptx target dependent of other 
> > > toolchains. Is this an intended effect of this patch?
> > Bundler is skipped only for the OpenMP NVPTX toolchain. I'm not sure what 
> > you mean by "other toolchain".
> Is skipped for the NVPTX toolchain if there are no "other" device toolchains 
> requested. Say I have a working pipeline that does static linking with nvptx 
> correctly. Then on top of that I add another device to `-fopenmp-targets`, 
> that pipeline will now fail even for nvptx, right?
It's a choice between skipping the bundler and running the current, default 
mode with the bundler enabled. If targets other than NVPTX are present then we 
default to using the bundler for all toolchains.
There is no hybrid mode enabled where some targets use the bundler and some 
don't. 



Comment at: lib/Driver/Compilation.cpp:276
+void Compilation::setSkipOffloadBundler(bool skipBundler) {
+  skipOffloadBundler = skipBundler;
+}

sfantao wrote:
> gtbercea wrote:
> > sfantao wrote:
> > > gtbercea wrote:
> > > > sfantao wrote:
> > > > > Given the logic you have below, you are assuming this is not set to 
> > > > > false ever. It would be wise to get an assertion here in case you end 
> > > > > up having toolchains skipping and others don't. If that is just not 
> > > > > supported a diagnostic should be added instead.
> > > > > 
> > > > > The convention is that local variables use CamelCase.
> > > > The checks I added in the Driver will set this flag to true if all 
> > > > toolchains Clang offloads to support the skipping of the 
> > > > bundler/unbundler for object files. Currently only NVPTX toolchain can 
> > > > skip the bundler/unbundler for object files so the code path in this 
> > > > patch will be taken only for:
> > > > 
> > > > -fopenmp -fopenmp-targets=nvptx64-nvidia-cuda
> > > Ok, if that is the case, just add an assertion here.
> > If one of the toolchains in the list of toolchains can't skip then none of 
> > them skip. If all can skip then they all skip. What assertion would you 
> > like me to add?
> If SkipOffloadBundler is set to true you don't expect it to be set to false 
> afterwards, right? That should be asserted.
That's correct, I can add that sure.


Repository:
  rC Clang

https://reviews.llvm.org/D47394



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


[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D15225#1183318, @george.karpenkov wrote:

> @rnk changing subjects: will you be at the LLVM social on Thursday? Could we 
> discuss it there?


Yes, we can and should, but I'd like update chromium's copy of clang before 
then.


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


[PATCH] D50050: [AST] CastExpr: BasePathSize is not large enough.

2018-07-31 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.




Comment at: include/clang/AST/Expr.h:2791
+public:
+  using BasePathSizeTy = unsigned short;
+  static_assert(std::numeric_limits::max() >= 16384,

lebedev.ri wrote:
> erichkeane wrote:
> > I'll let @rjmccall comment here, but I think I'd be willing to give up 2 
> > more bytes here and just go with unsigned int.  It has the advantage of 
> > likely never being an issue again (since 4 billion bases is not an issue).
> > 
> > We might be paying for those 2 ANYWAY with alignment as well, right?
> Yes, i do expect that we are paying for 2 bytes in padding already.
Yeah, we could really use a `size_t` here without loss, but an `unsigned` is 
fine.


Repository:
  rC Clang

https://reviews.llvm.org/D50050



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


r338438 - [serialization] PR34728: Don't assume that only a suffix of template

2018-07-31 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Jul 31 14:01:53 2018
New Revision: 338438

URL: http://llvm.org/viewvc/llvm-project?rev=338438=rev
Log:
[serialization] PR34728: Don't assume that only a suffix of template
parameters can have default arguments.

At least for function templates and class template partial
specializations, it's possible for a template parameter with a default
argument to be followed by a non-pack template parameter with no default
argument, and this case was not properly handled here.

Testcase by Steve O'Brien!

Modified:
cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
cfe/trunk/test/PCH/cxx-templates.cpp
cfe/trunk/test/PCH/cxx-templates.h

Modified: cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReaderDecl.cpp?rev=338438=338437=338438=diff
==
--- cfe/trunk/lib/Serialization/ASTReaderDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReaderDecl.cpp Tue Jul 31 14:01:53 2018
@@ -3439,22 +3439,16 @@ static void inheritDefaultTemplateArgume
   assert(FromTP->size() == ToTP->size() && "merged mismatched templates?");
 
   for (unsigned I = 0, N = FromTP->size(); I != N; ++I) {
-NamedDecl *FromParam = FromTP->getParam(N - I - 1);
-if (FromParam->isParameterPack())
-  continue;
-NamedDecl *ToParam = ToTP->getParam(N - I - 1);
+NamedDecl *FromParam = FromTP->getParam(I);
+NamedDecl *ToParam = ToTP->getParam(I);
 
-if (auto *FTTP = dyn_cast(FromParam)) {
-  if (!inheritDefaultTemplateArgument(Context, FTTP, ToParam))
-break;
-} else if (auto *FNTTP = dyn_cast(FromParam)) {
-  if (!inheritDefaultTemplateArgument(Context, FNTTP, ToParam))
-break;
-} else {
-  if (!inheritDefaultTemplateArgument(
-  Context, cast(FromParam), ToParam))
-break;
-}
+if (auto *FTTP = dyn_cast(FromParam))
+  inheritDefaultTemplateArgument(Context, FTTP, ToParam);
+else if (auto *FNTTP = dyn_cast(FromParam))
+  inheritDefaultTemplateArgument(Context, FNTTP, ToParam);
+else
+  inheritDefaultTemplateArgument(
+  Context, cast(FromParam), ToParam);
   }
 }
 

Modified: cfe/trunk/test/PCH/cxx-templates.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.cpp?rev=338438=338437=338438=diff
==
--- cfe/trunk/test/PCH/cxx-templates.cpp (original)
+++ cfe/trunk/test/PCH/cxx-templates.cpp Tue Jul 31 14:01:53 2018
@@ -116,3 +116,19 @@ namespace MemberSpecializationLocation {
 #endif
   int k = A::n;
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=34728
+namespace PR34728 {
+int test() {
+  // Verify with several TemplateParmDecl kinds, using PCH (incl. modules).
+  int z1 = func1(/*ignored*/2.718);
+  int z2 = func2(/*ignored*/3.142);
+  int tmp3 = 30;
+  Container c = func3(tmp3);
+  int z3 = c.item;
+
+  // Return value is meaningless.  Just "use" all these values to avoid
+  // warning about unused vars / values.
+  return z1 + z2 + z3;
+}
+} // end namespace PR34728

Modified: cfe/trunk/test/PCH/cxx-templates.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/cxx-templates.h?rev=338438=338437=338438=diff
==
--- cfe/trunk/test/PCH/cxx-templates.h (original)
+++ cfe/trunk/test/PCH/cxx-templates.h Tue Jul 31 14:01:53 2018
@@ -361,3 +361,38 @@ namespace rdar15468709c {
 namespace MemberSpecializationLocation {
   template struct A { static int n; };
 }
+
+// https://bugs.llvm.org/show_bug.cgi?id=34728
+namespace PR34728 {
+
+// case 1: defaulted `NonTypeTemplateParmDecl`, non-defaulted 2nd tpl param
+template 
+int func1(T const &);
+
+template 
+int func1(T const &) {
+  return foo;
+}
+
+// case 2: defaulted `TemplateTypeParmDecl`, non-defaulted 2nd tpl param
+template 
+A func2(B const &);
+
+template 
+A func2(B const &) {
+  return A(20.0f);
+}
+
+// case 3: defaulted `TemplateTemplateParmDecl`, non-defaulted 2nd tpl param
+template 
+struct Container { T const  };
+
+template  class C = Container, class D>
+C func3(D const &);
+
+template  class C, class D>
+C func3(D const ) {
+  return Container{d};
+}
+
+} // end namespace PR34728


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


[PATCH] D49922: [P0936R0] add [[clang::lifetimebound]] attribute

2018-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, though I raised a few questions. If you want to handle them as part of 
this patch, I'm happy to do another round of review. If you want to handle them 
in a follow-up patch, I'm also okay.




Comment at: lib/Sema/SemaDecl.cpp:6013
+  // Check the attributes on the function type, if any.
+  if (auto *FD = dyn_cast()) {
+for (TypeLoc TL = FD->getTypeSourceInfo()->getTypeLoc();

rsmith wrote:
> aaron.ballman wrote:
> > `const auto *` (and thread the const-correctness through).
> > 
> > Actually, if you could double-check on the const correctness elsewhere in 
> > the patch, that'd be useful, as it looks like there are other places that 
> > could be similarly touched up.
> Done. I don't think it makes any difference, though: this constness is 
> shallow, and doesn't defend against us somehow accidentally mutating the 
> `TypeSourceInfo` (which is all we're looking at, and `TypeLoc` doesn't have a 
> `const` view).
Yeah, our const-correctness story is pretty hit or miss. However, I try to 
ensure new code attempts to be const-correct if it's not too annoying because 
I'm still a hopeful, optimistic kind of guy. :-P Thanks for handling this!



Comment at: lib/Sema/SemaDecl.cpp:6022-6028
+if (!MD || MD->isStatic()) {
+  S.Diag(ATL.getAttrNameLoc(), diag::err_lifetimebound_no_object_param)
+  << !MD << ATL.getLocalSourceRange();
+} else if (isa(MD) || isa(MD)) {
+  S.Diag(ATL.getAttrNameLoc(), diag::err_lifetimebound_ctor_dtor)
+  << isa(MD) << ATL.getLocalSourceRange();
+}

rsmith wrote:
> aaron.ballman wrote:
> > Can elide the braces.
> True, but the controlled statements are multi-line, so I'd prefer not to. :)
Sold.



Comment at: lib/Sema/SemaInit.cpp:6959
+  case IndirectLocalPathEntry::LifetimeBoundCall:
+// FIXME: Consider adding a note for this.
+break;

Is this something you intended to handle in this patch and forgot, or are you 
saving this for a future patch?



Comment at: lib/Sema/SemaType.cpp:7202-7207
+  if (D.isDeclarationOfFunction()) {
+CurType = S.Context.getAttributedType(AttributedType::attr_lifetimebound,
+  CurType, CurType);
+  } else {
+Attr.diagnoseAppertainsTo(S, nullptr);
+  }

rsmith wrote:
> aaron.ballman wrote:
> > Elide braces
> I'd prefer to not elide braces around a multi-line `if` body, and I'd 
> strongly prefer to avoid bracing an `if` and not its `else`.
Sounds good.



Comment at: test/SemaCXX/attr-lifetimebound.cpp:3
+
+namespace usage_invalid {
+  // FIXME: Diagnose void return type?

Can you also add a test demonstrating the attribute doesn't accept any 
arguments?



Comment at: test/SemaCXX/attr-lifetimebound.cpp:4
+namespace usage_invalid {
+  // FIXME: Diagnose void return type?
+  void voidreturn(int  [[clang::lifetimebound]]);

Something you intended to support in this patch?



Comment at: test/SemaCXX/attr-lifetimebound.cpp:102
+  void use_reversed_range() {
+// FIXME: Don't expose the name of the internal range variable.
+for (auto x : reversed(make_vector())) {} // expected-warning {{temporary 
bound to local reference '__range1'}}

Agreed; that is a bit ugly.


https://reviews.llvm.org/D49922



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


[PATCH] D50089: [DWARF v4] Suppressing the __debug_ranges section when there are no ranges

2018-07-31 Thread Wolfgang Pieb via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338437: [DWARF] Do not create a .debug_ranges section when 
no ranges are needed. (authored by wolfgangp, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D50089?vs=158328=158378#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D50089

Files:
  llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp


Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2136,7 +2136,7 @@
 return;
   }
 
-  if (getDwarfVersion() >= 5 && NoRangesPresent())
+  if (NoRangesPresent())
 return;
 
   // Start the dwarf ranges section.


Index: llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
===
--- llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ llvm/trunk/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -2136,7 +2136,7 @@
 return;
   }
 
-  if (getDwarfVersion() >= 5 && NoRangesPresent())
+  if (NoRangesPresent())
 return;
 
   // Start the dwarf ranges section.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49953: [compiler-rt] Add a routine to specify the mode used when creating profile dirs.

2018-07-31 Thread Paul Robinson via Phabricator via cfe-commits
probinson accepted this revision.
probinson added a comment.
This revision is now accepted and ready to land.

Using `%t` with suffixes instead of `%T` is the preferred idiom, glad you 
worked that out.
The more elaborate test depends on a set of Posix-y calls, but that's fine.  If 
there are more environments that can't handle it, the bots will find them for 
you. :-)
LGTM with the fancier test, once you fix the missing RUN.  (The RUN prefixes 
are how lit decides which lines are the test script.)




Comment at: test/profile/instrprof-set-dir-mode2.c:3
+// RUN: %clang_pgogen -o %t.bin %s -DTESTPATH=\"%t.dir\"
+// rm -rf %t.dir
+// RUN: %run %t.bin

This needs a RUN: in front of it, I think.


https://reviews.llvm.org/D49953



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


[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-07-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@rnk changing subjects: will you be at the LLVM social on Thursday? Could we 
discuss it there?


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


r338436 - [CFG] [analyzer] Implement function argument construction contexts.

2018-07-31 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Tue Jul 31 13:45:53 2018
New Revision: 338436

URL: http://llvm.org/viewvc/llvm-project?rev=338436=rev
Log:
[CFG] [analyzer] Implement function argument construction contexts.

In r330377 and r338425 we have already identified what constitutes function
argument constructors and added stubs in order to prevent confusing them
with other temporary object constructors.

Now we implement a ConstructionContext sub-class to carry all the necessary
information about the construction site, namely call expression and argument
index.

On the analyzer side, the patch interacts with the recently implemented
pre-C++17 copy elision support in an interesting manner. If on the CFG side we
didn't find a construction context for the elidable constructor, we build
the CFG as if the elidable constructor is not elided, and the non-elided
constructor within it is a simple temporary. But the same problem may occur
in the analyzer: if the elidable constructor has a construction context but
the analyzer doesn't implement such context yet, the analyzer should also
try to skip copy elision and still inline the non-elided temporary constructor.
This was implemented by adding a "roll back" mechanism: when elision fails,
roll back the changes and proceed as if it's a simple temporary. The approach
is wonky, but i'm fine with that as long as it's merely a defensive mechanism
that should eventually go away once all construction contexts become supported.

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

Modified:
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/Analysis/ConstructionContext.h
cfe/trunk/lib/Analysis/CFG.cpp
cfe/trunk/lib/Analysis/ConstructionContext.cpp
cfe/trunk/lib/StaticAnalyzer/Core/ExprEngineCXX.cpp
cfe/trunk/test/Analysis/cfg-rich-constructors.cpp
cfe/trunk/test/Analysis/cfg-rich-constructors.mm

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=338436=338435=338436=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Tue Jul 31 13:45:53 2018
@@ -196,7 +196,8 @@ public:
  // These are possible in C++17 due to mandatory copy elision.
  isa(C) ||
  isa(C) ||
- isa(C)));
+ isa(C) ||
+ isa(C)));
 Data2.setPointer(const_cast(C));
   }
 

Modified: cfe/trunk/include/clang/Analysis/ConstructionContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/ConstructionContext.h?rev=338436=338435=338436=diff
==
--- cfe/trunk/include/clang/Analysis/ConstructionContext.h (original)
+++ cfe/trunk/include/clang/Analysis/ConstructionContext.h Tue Jul 31 13:45:53 
2018
@@ -41,6 +41,12 @@ private:
   /// new-expression triggers construction of the newly allocated object(s).
   TriggerTy Trigger;
 
+  /// If a single trigger statement triggers multiple constructors, they are
+  /// usually being enumerated. This covers function argument constructors
+  /// triggered by a call-expression and items in an initializer list triggered
+  /// by an init-list-expression.
+  unsigned Index;
+
   /// Sometimes a single trigger is not enough to describe the construction
   /// site. In this case we'd have a chain of "partial" construction context
   /// layers.
@@ -55,13 +61,13 @@ private:
   /// Not all of these are currently supported.
   const ConstructionContextLayer *Parent = nullptr;
 
-  ConstructionContextLayer(TriggerTy Trigger,
-  const ConstructionContextLayer *Parent)
-  : Trigger(Trigger), Parent(Parent) {}
+  ConstructionContextLayer(TriggerTy Trigger, unsigned Index,
+   const ConstructionContextLayer *Parent)
+  : Trigger(Trigger), Index(Index), Parent(Parent) {}
 
 public:
   static const ConstructionContextLayer *
-  create(BumpVectorContext , TriggerTy Trigger,
+  create(BumpVectorContext , TriggerTy Trigger, unsigned Index = 0,
  const ConstructionContextLayer *Parent = nullptr);
 
   const ConstructionContextLayer *getParent() const { return Parent; }
@@ -75,11 +81,13 @@ public:
 return Trigger.dyn_cast();
   }
 
+  unsigned getIndex() const { return Index; }
+
   /// Returns true if these layers are equal as individual layers, even if
   /// their parents are different.
   bool isSameLayer(const ConstructionContextLayer *Other) const {
 assert(Other);
-return (Trigger == Other->Trigger);
+return (Trigger == Other->Trigger && Index == Other->Index);
   }
 
   /// See if Other is a proper initial segment of this construction context
@@ -114,7 +122,8 @@ public:
 SimpleReturnedValueKind,
 CXX17ElidedCopyReturnedValueKind,
 RETURNED_VALUE_BEGIN = 

r338432 - [OpenCL] Forbid size dependent types used as kernel arguments

2018-07-31 Thread via cfe-commits
Author: AlexeySotkin
Date: Tue Jul 31 13:26:43 2018
New Revision: 338432

URL: http://llvm.org/viewvc/llvm-project?rev=338432=rev
Log:
[OpenCL] Forbid size dependent types used as kernel arguments

Summary:
Size_t, intptr_t, uintptr_t and ptrdiff_t cannot be used as kernel
arguments, according to OpenCL Specification s6.9k:
The size in bytes of these types are implementation-defined and in
addition can also be different for the OpenCL device and the host
processor making it difficult to allocate buffer objects to be passed
as arguments to a kernel declared as pointer to these types.

Patch by: Andrew Savonichev

Reviewers: Anastasia, yaxunl

Subscribers: yaxunl, Anastasia, cfe-commits

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

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=338432=338431=338432=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Tue Jul 31 13:26:43 2018
@@ -8049,6 +8049,29 @@ enum OpenCLParamType {
   RecordKernelParam
 };
 
+static bool isOpenCLSizeDependentType(ASTContext , QualType Ty) {
+  // Size dependent types are just typedefs to normal integer types
+  // (e.g. unsigned long), so we cannot distinguish them from other typedefs to
+  // integers other than by their names.
+  StringRef SizeTypeNames[] = {"size_t", "intptr_t", "uintptr_t", "ptrdiff_t"};
+
+  // Remove typedefs one by one until we reach a typedef
+  // for a size dependent type.
+  QualType DesugaredTy = Ty;
+  do {
+ArrayRef Names(SizeTypeNames);
+auto Match =
+std::find(Names.begin(), Names.end(), DesugaredTy.getAsString());
+if (Names.end() != Match)
+  return true;
+
+Ty = DesugaredTy;
+DesugaredTy = Ty.getSingleStepDesugaredType(C);
+  } while (DesugaredTy != Ty);
+
+  return false;
+}
+
 static OpenCLParamType getOpenCLKernelParameterType(Sema , QualType PT) {
   if (PT->isPointerType()) {
 QualType PointeeType = PT->getPointeeType();
@@ -8061,8 +8084,13 @@ static OpenCLParamType getOpenCLKernelPa
 return PtrKernelParam;
   }
 
-  // TODO: Forbid the other integer types (size_t, ptrdiff_t...) when they can
-  // be used as builtin types.
+  // OpenCL v1.2 s6.9.k:
+  // Arguments to kernel functions in a program cannot be declared with the
+  // built-in scalar types bool, half, size_t, ptrdiff_t, intptr_t, and
+  // uintptr_t or a struct and/or union that contain fields declared to be one
+  // of these built-in scalar types.
+  if (isOpenCLSizeDependentType(S.getASTContext(), PT))
+return InvalidKernelParam;
 
   if (PT->isImageType())
 return PtrKernelParam;
@@ -8133,8 +8161,20 @@ static void checkIsValidOpenCLKernelPara
 // of event_t type.
 // Do not diagnose half type since it is diagnosed as invalid argument
 // type for any function elsewhere.
-if (!PT->isHalfType())
+if (!PT->isHalfType()) {
   S.Diag(Param->getLocation(), diag::err_bad_kernel_param_type) << PT;
+
+  // Explain what typedefs are involved.
+  const TypedefType *Typedef = nullptr;
+  while ((Typedef = PT->getAs())) {
+SourceLocation Loc = Typedef->getDecl()->getLocation();
+// SourceLocation may be invalid for a built-in type.
+if (Loc.isValid())
+  S.Diag(Loc, diag::note_entity_declared_at) << PT;
+PT = Typedef->desugar();
+  }
+}
+
 D.setInvalidType();
 return;
 

Modified: cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl?rev=338432=338431=338432=diff
==
--- cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl (original)
+++ cfe/trunk/test/SemaOpenCL/invalid-kernel-parameters.cl Tue Jul 31 13:26:43 
2018
@@ -9,7 +9,35 @@ kernel void half_arg(half x) { } // expe
 // bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them
 
-// TODO: Ban int types, size_t, ptrdiff_t ...
+typedef __SIZE_TYPE__ size_t; // expected-note{{'size_t' (aka 'unsigned int') 
declared here}}
+  // expected-note@-1{{'size_t' (aka 'unsigned 
int') declared here}}
+typedef __PTRDIFF_TYPE__ ptrdiff_t; // expected-note{{'ptrdiff_t' (aka 'int') 
declared here}}
+typedef __INTPTR_TYPE__ intptr_t; // expected-note{{'intptr_t' (aka 'int') 
declared here}}
+typedef __UINTPTR_TYPE__ uintptr_t; // expected-note{{'uintptr_t' (aka 
'unsigned int') declared here}}
+
+kernel void size_t_arg(size_t x) {} // expected-error{{'size_t' (aka 'unsigned 
int') cannot be used as the type of a kernel parameter}}
+
+kernel void ptrdiff_t_arg(ptrdiff_t x) {} // expected-error{{'ptrdiff_t' (aka 

[PATCH] D49725: [OpenCL] Forbid size dependent types used as kernel arguments

2018-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

FYI: @asavonic, the email address you have associated with your commit id is 
`AlexeySotkin@/etc/mailname` which is getting stuck in the moderation queue as 
not being signed up to the mailing list. You may want to correct your svn 
information as I am not certain what our list software will think of that 
domain.


Repository:
  rL LLVM

https://reviews.llvm.org/D49725



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


[PATCH] D50055: Update the coding standard about NFC changes and whitespace

2018-07-31 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added subscribers: llvm-commits, cfe-commits.
aaron.ballman added a comment.

In https://reviews.llvm.org/D50055#1183277, @probinson wrote:

> I think you forgot to subscribe llvm-commits to this review?


Oh shoot, good catch! I've added llvm-commits and cfe-commits both. Thank you 
for pointing that out.


https://reviews.llvm.org/D50055



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


[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-07-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

@rnk OK I see, we've accidentally posted comments nearly simultaneously.


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-07-31 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

> it's just that the runtime library didn't happen to exist on the system 
> performing compilation

But then conceptually, the compiler toolchain on the system performing 
compilation is not fully supporting asan, right?
It works for producing asanified object files, but fails with a link error if 
you wanted to produce an asanified executable.


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


[PATCH] D15225: [Driver] Sanitizer support based on runtime library presence

2018-07-31 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D15225#1183132, @george.karpenkov wrote:

> @rnk could you clarify how did it break the distributed asanified build? If 
> the slave compiler supports asan it should have this runtime, right?


Most open source distributed build systems wrap only compilation steps, not 
link steps. There's no reason to ship the runtime library just for compilation.

In https://reviews.llvm.org/D15225#1183135, @george.karpenkov wrote:

> @rnk Regarding the error message, would it be possible to compromise on 
> something like "sanitizer runtime not available"?
>  I understand that the exact error message would be very useful for you, but 
> it's just confusing for a user getting a toolchain with Xcode, since they 
> can't just add the required file into the toolchain.


I think you are underestimating the likelihood that users will repackage and 
redistribute the C/C++ toolchain parts of the XCode as part of their normal 
build processes. I think in principle it's better for clang to remain 
self-contained, for it to just "know" which platforms have working sanitizer 
libraries. It feels like this change is trying to check whether the link will 
succeed during compilation, which is kind of putting the cart before the horse.


Repository:
  rL LLVM

https://reviews.llvm.org/D15225



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


[PATCH] D49758: [clangd] allow clients to pass in compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request

2018-07-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: test/clangd/did-change-configuration-params.test:43
+#
+# ERR: Updating file /clangd-test/foo.c with command [/clangd-test2] clang -c 
foo.c -Wall -Werror
+# Don't reparse the second file:

ilya-biryukov wrote:
> Matching the stderr output seems fragile, but that's the only way to inspect 
> the actual compile command that's used, so that's probably fine here.
> However, the paths on windows will probably differ (notice the regexp matches 
> for file uris), so we might need to do the regexp match here as well, 
> e.g.`Updating file {{.*}}foo.c with command ...` to keep the Windows 
> buildbots happy.
Good point.
I also realized that I have to make this a UNIX-specific test as the 
compilation database updates require a path, which will obviously be different 
on Windows.


https://reviews.llvm.org/D49758



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


[PATCH] D49758: [clangd] allow clients to pass in compilationDatabaseChanges in the 'workspace/didChangeConfiguration' request

2018-07-31 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman updated this revision to Diff 158376.
arphaman marked 3 inline comments as done.
arphaman added a comment.

Updated to address review comments.


https://reviews.llvm.org/D49758

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdLSPServer.h
  clangd/GlobalCompilationDatabase.cpp
  clangd/GlobalCompilationDatabase.h
  clangd/Protocol.cpp
  clangd/Protocol.h
  clangd/tool/ClangdMain.cpp
  test/clangd/did-change-configuration-params.test

Index: test/clangd/did-change-configuration-params.test
===
--- /dev/null
+++ test/clangd/did-change-configuration-params.test
@@ -0,0 +1,52 @@
+# RUN: clangd -compile_args_from=lsp -lit-test < %s 2> %t | FileCheck -strict-whitespace %s
+# RUN: cat %t | FileCheck --check-prefix=ERR %s
+# UNSUPPORTED: mingw32,win32
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+---
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test", "compilationCommand": ["clang", "-c", "foo.c"]}
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.c","languageId":"c","version":1,"text":"int main() { int i; return i; }"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:  "params": {
+# CHECK-NEXT:"diagnostics": [],
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///bar.c","languageId":"c","version":1,"text":"int main() { int i; return i; }"}}}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:  "params": {
+# CHECK-NEXT:"diagnostics": [],
+# CHECK-NEXT:"uri": "file://{{.*}}/bar.c"
+# CHECK-NEXT:  }
+---
+{"jsonrpc":"2.0","method":"workspace/didChangeConfiguration","params":{"settings":{"compilationDatabaseChanges":{"/clangd-test/foo.c": {"workingDirectory":"/clangd-test2", "compilationCommand": ["clang", "-c", "foo.c", "-Wall", "-Werror"]}
+#  CHECK:  "method": "textDocument/publishDiagnostics",
+# CHECK-NEXT:  "params": {
+# CHECK-NEXT:"diagnostics": [
+# CHECK-NEXT:  {
+# CHECK-NEXT:"message": "variable 'i' is uninitialized when used here",
+# CHECK-NEXT:"range": {
+# CHECK-NEXT:  "end": {
+# CHECK-NEXT:"character": 28,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  },
+# CHECK-NEXT:  "start": {
+# CHECK-NEXT:"character": 27,
+# CHECK-NEXT:"line": 0
+# CHECK-NEXT:  }
+# CHECK-NEXT:},
+# CHECK-NEXT:"severity": 1
+# CHECK-NEXT:  }
+# CHECK-NEXT:],
+# CHECK-NEXT:"uri": "file://{{.*}}/foo.c"
+# CHECK-NEXT:  }
+#
+# ERR: Updating file {{.*}}foo.c with command [{{.*}}clangd-test2] clang -c foo.c -Wall -Werror
+# Don't reparse the second file:
+# ERR: Skipping rebuild of the AST for {{.*}}bar.c
+---
+{"jsonrpc":"2.0","id":5,"method":"shutdown"}
+---
+{"jsonrpc":"2.0","method":"exit"}
+
+
Index: clangd/tool/ClangdMain.cpp
===
--- clangd/tool/ClangdMain.cpp
+++ clangd/tool/ClangdMain.cpp
@@ -173,6 +173,18 @@
 "eventually. Don't rely on it."),
 llvm::cl::init(""), llvm::cl::Hidden);
 
+enum CompileArgsFrom { LSPCompileArgs, FilesystemCompileArgs };
+
+static llvm::cl::opt CompileArgsFrom(
+"compile_args_from", llvm::cl::desc("The source of compile commands"),
+llvm::cl::values(clEnumValN(LSPCompileArgs, "lsp",
+"All compile commands come from LSP and "
+"'compile_commands.json' files are ignored"),
+ clEnumValN(FilesystemCompileArgs, "filesystem",
+"All compile commands come from the "
+"'compile_commands.json' files")),
+llvm::cl::init(FilesystemCompileArgs), llvm::cl::Hidden);
+
 int main(int argc, char *argv[]) {
   llvm::sys::PrintStackTraceOnErrorSignal(argv[0]);
   llvm::cl::SetVersionPrinter([](llvm::raw_ostream ) {
@@ -289,7 +301,9 @@
   }
 
   // Initialize and run ClangdLSPServer.
-  ClangdLSPServer LSPServer(Out, CCOpts, CompileCommandsDirPath, Opts);
+  ClangdLSPServer LSPServer(
+  Out, CCOpts, CompileCommandsDirPath,
+  /*ShouldUseInMemoryCDB=*/CompileArgsFrom == LSPCompileArgs, Opts);
   constexpr int NoShutdownRequestErrorCode = 1;
   llvm::set_thread_name("clangd.main");
   // Change stdin to binary to not lose \r\n on windows.
Index: clangd/Protocol.h
===
--- clangd/Protocol.h
+++ clangd/Protocol.h
@@ -419,10 +419,24 @@
 };
 bool fromJSON(const llvm::json::Value &, DidChangeWatchedFilesParams &);
 
+/// Clangd extension that's used in the 'compilationDatabaseChanges' in
+/// 

[PATCH] D50101: [asan] Update a vector's storage annotation during destruction.

2018-07-31 Thread Ben via Phabricator via cfe-commits
bobsayshilol created this revision.
bobsayshilol added reviewers: mclow.lists, EricWF.
Herald added subscribers: cfe-commits, ldionne.

This allows a user replaced operator delete to modify or reuse returned memory 
in the case where the size and capacity of a vector do not match upon 
destruction and hence leave a portion of the memory poisoned.
This consequently also balances __annotate_delete() calls with those of 
__annotate_new().


Repository:
  rCXX libc++

https://reviews.llvm.org/D50101

Files:
  include/vector


Index: include/vector
===
--- include/vector
+++ include/vector
@@ -540,13 +540,14 @@
 value_type,
 typename 
iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
 
-#if _LIBCPP_DEBUG_LEVEL >= 2
 _LIBCPP_INLINE_VISIBILITY
 ~vector()
 {
+__annotate_delete();
+#if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__erase_c(this);
-}
 #endif
+}
 
 vector(const vector& __x);
 vector(const vector& __x, const allocator_type& __a);


Index: include/vector
===
--- include/vector
+++ include/vector
@@ -540,13 +540,14 @@
 value_type,
 typename iterator_traits<_ForwardIterator>::reference>::value>::type* = 0);
 
-#if _LIBCPP_DEBUG_LEVEL >= 2
 _LIBCPP_INLINE_VISIBILITY
 ~vector()
 {
+__annotate_delete();
+#if _LIBCPP_DEBUG_LEVEL >= 2
 __get_db()->__erase_c(this);
-}
 #endif
+}
 
 vector(const vector& __x);
 vector(const vector& __x, const allocator_type& __a);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D49058: [analyzer] Move InnerPointerChecker out of alpha

2018-07-31 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL338433: [analyzer] Move InnerPointerChecker out of alpha. 
(authored by rkovacs, committed by ).
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D49058?vs=157987=158373#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D49058

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/test/Analysis/inner-pointer.cpp


Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -276,6 +276,10 @@
 
 let ParentPackage = Cplusplus in {
 
+def InnerPointerChecker : Checker<"InnerPointer">,
+  HelpText<"Check for inner pointers of C++ containers used after 
re/deallocation">,
+  DescFile<"InnerPointerChecker.cpp">;
+
 def NewDeleteChecker : Checker<"NewDelete">,
   HelpText<"Check for double-free and use-after-free problems. Traces memory 
managed by new/delete.">,
   DescFile<"MallocChecker.cpp">;
@@ -305,10 +309,6 @@
"destructor in their base class">,
   DescFile<"DeleteWithNonVirtualDtorChecker.cpp">;
 
-def InnerPointerChecker : Checker<"InnerPointer">,
-  HelpText<"Check for inner pointers of C++ containers used after 
re/deallocation">,
-  DescFile<"InnerPointerChecker.cpp">;
-
 def IteratorRangeChecker : Checker<"IteratorRange">,
   HelpText<"Check for iterators used outside their valid ranges">,
   DescFile<"IteratorChecker.cpp">;
Index: cfe/trunk/test/Analysis/inner-pointer.cpp
===
--- cfe/trunk/test/Analysis/inner-pointer.cpp
+++ cfe/trunk/test/Analysis/inner-pointer.cpp
@@ -1,4 +1,4 @@
-//RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.InnerPointer %s 
-analyzer-output=text -verify
+//RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.InnerPointer %s 
-analyzer-output=text -verify
 
 namespace std {
 


Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -276,6 +276,10 @@
 
 let ParentPackage = Cplusplus in {
 
+def InnerPointerChecker : Checker<"InnerPointer">,
+  HelpText<"Check for inner pointers of C++ containers used after re/deallocation">,
+  DescFile<"InnerPointerChecker.cpp">;
+
 def NewDeleteChecker : Checker<"NewDelete">,
   HelpText<"Check for double-free and use-after-free problems. Traces memory managed by new/delete.">,
   DescFile<"MallocChecker.cpp">;
@@ -305,10 +309,6 @@
"destructor in their base class">,
   DescFile<"DeleteWithNonVirtualDtorChecker.cpp">;
 
-def InnerPointerChecker : Checker<"InnerPointer">,
-  HelpText<"Check for inner pointers of C++ containers used after re/deallocation">,
-  DescFile<"InnerPointerChecker.cpp">;
-
 def IteratorRangeChecker : Checker<"IteratorRange">,
   HelpText<"Check for iterators used outside their valid ranges">,
   DescFile<"IteratorChecker.cpp">;
Index: cfe/trunk/test/Analysis/inner-pointer.cpp
===
--- cfe/trunk/test/Analysis/inner-pointer.cpp
+++ cfe/trunk/test/Analysis/inner-pointer.cpp
@@ -1,4 +1,4 @@
-//RUN: %clang_analyze_cc1 -analyzer-checker=alpha.cplusplus.InnerPointer %s -analyzer-output=text -verify
+//RUN: %clang_analyze_cc1 -analyzer-checker=cplusplus.InnerPointer %s -analyzer-output=text -verify
 
 namespace std {
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   3   >