Re: Zorg migration to GitHub/monorepo

2019-10-18 Thread Galina Kistanova via cfe-commits
Hello build bot owners!

The staging master is ready. Please feel free to use it to make sure your
bots would work well with the monorepo and github.

The following builders could be configured to build monorepo:

* clang-atom-d525-fedora-rel
* clang-native-arm-lnt-perf
* clang-cmake-armv7-lnt
* clang-cmake-armv7-selfhost-neon
* clang-cmake-armv7-quick
* clang-cmake-armv7-global-isel
* clang-cmake-armv7-selfhost
* clang-cmake-aarch64-quick
* clang-cmake-aarch64-lld
* clang-cmake-aarch64-global-isel
* clang-ppc64be-linux-lnt
* clang-ppc64be-linux-multistage
* clang-ppc64le-linux-lnt
* clang-ppc64le-linux-multistage
* clang-ppc64be-linux
* clang-ppc64le-linux
* clang-s390x-linux
* clang-s390x-linux-multistage
* clang-s390x-linux-lnt
* clang-hexagon-elf
* clang-cmake-x86_64-avx2-linux
* clang-cmake-x86_64-avx2-linux-perf
* clang-cmake-x86_64-sde-avx512-linux
* clang-solaris11-amd64
* clang-x64-ninja-win7
* clang-solaris11-sparcv9
* clang-cmake-armv7-full
* clang-cmake-thumbv7-full-sh
* clang-cmake-armv8-lld
* clang-cmake-aarch64-full
* clang-armv7-linux-build-cache
* clang-aarch64-linux-build-cache
* libcxx-libcxxabi-x86_64-linux-debian
* libcxx-libcxxabi-x86_64-linux-debian-noexceptions
* libcxx-libcxxabi-libunwind-x86_64-linux-debian
* libcxx-libcxxabi-singlethreaded-x86_64-linux-debian
* libcxx-libcxxabi-x86_64-linux-ubuntu-cxx03
* libcxx-libcxxabi-x86_64-linux-ubuntu-cxx11
* libcxx-libcxxabi-x86_64-linux-ubuntu-cxx14
* libcxx-libcxxabi-x86_64-linux-ubuntu-cxx17
* libcxx-libcxxabi-x86_64-linux-ubuntu-cxx2a
* libcxx-libcxxabi-x86_64-linux-ubuntu-32bit
* libcxx-libcxxabi-x86_64-linux-ubuntu-asan
* libcxx-libcxxabi-x86_64-linux-ubuntu-ubsan
* libcxx-libcxxabi-x86_64-linux-ubuntu-msan
* libcxx-libcxxabi-libunwind-x86_64-linux-ubuntu
* libcxx-libcxxabi-x86_64-linux-ubuntu-tsan
* libcxx-libcxxabi-x86_64-linux-ubuntu-gcc5-cxx11
* libcxx-libcxxabi-x86_64-linux-ubuntu-gcc-tot-latest-std
* libcxx-libcxxabi-libunwind-armv7-linux
* libcxx-libcxxabi-libunwind-armv8-linux
* libcxx-libcxxabi-libunwind-armv7-linux-noexceptions
* libcxx-libcxxabi-libunwind-armv8-linux-noexceptions
* libcxx-libcxxabi-libunwind-aarch64-linux
* libcxx-libcxxabi-libunwind-aarch64-linux-noexceptions
* ppc64le-lld-multistage-test

These builders are already on the staging master. So, please ping me if you
would like to configure any of them to work with monorepo:

* clang-freebsd11-amd64

These builders have been already tested and could be reconfigured without
staging as soon as public master is ready:

* llvm-sphinx-docs
* clang-sphinx-docs
* clang-tools-sphinx-docs
* lld-sphinx-docs
* lldb-sphinx-docs
* libcxx-sphinx-docs
* libunwind-sphinx-docs
* clang-x86_64-debian-fast
* libcxx-libcxxabi-x86_64-linux-debian
* libcxx-libcxxabi-x86_64-linux-debian-noexceptions
* libcxx-libcxxabi-libunwind-x86_64-linux-debian
* libcxx-libcxxabi-singlethreaded-x86_64-linux-debian
* lld-x86_64-darwin13
* lld-x86_64-win7
* llvm-clang-lld-x86_64-scei-ps4-ubuntu-fast
* llvm-clang-lld-x86_64-scei-ps4-windows10pro-fast
* clang-x86_64-linux-abi-test
* clang-with-lto-ubuntu
* clang-with-thin-lto-ubuntu
* llvm-clang-x86_64-expensive-checks-win
* llvm-clang-x86_64-win-fast
* lld-x86_64-ubuntu-fast
* clang-lld-x86_64-2stage
* lld-perf-testsuite

Thanks for your patience and help!

Galina

On Thu, Oct 17, 2019 at 5:04 PM Galina Kistanova 
wrote:

> Hello everyone,
>
> The build bot is almost ready to move to github.
>
> As the next step we would migrate the staging master to listen for the
> both changes, from SVN as it was before, and from github.
>
> Tonight I am going to update the staging (aka silent) master and it will
> start working with github.
>
> I will send an email when it is done.
>
> If you bots use one of the ported build factories from the list in my
> previous e-mail, please feel free to stage them for working with
> monorepo/github and once you are happy, let me know, and I'll configure
> them accordingly on the production master. Once that's done, you could move
> the bots back to the production master and you are done.
>
> When you stage your bot, please follow these steps:
> 1. Stop your bot between builds, if possible,
> 2. Remove the bot working directory (usually this directory has a builder
> name and is under directory where your bot is installed; if you are not
> sure, check the 'builddir' param of your bot in
> zorg/buildbot/osuosl/master/config/builders.py),
> 3. Edit buildbot.tac in the directory where your bot is installed. Change
> "port = 9990" line to "port = 9994". Save the change.
> 4. Start your bot, make sure it connects to the staging master.
> 5. Send me a mail with the staged bot names.
>
> Once you are happy with your bot building monorepo changes from github,
> please send me an e-mail and I'll respond with the instructions of how to
> get your bot back to production.
>
> Please be aware that staging master could restart often. Please let me
> know if you are having long running builds.
>
> Feel free to ask if you have questions.

[PATCH] D68590: [clangd] Improve hover support for Objective-C

2019-10-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clangd/XRefs.cpp:461
+
+  OS << (Method->isInstanceMethod() ? '-' : '+')
+ << '[' << Class->getName();

it looks like `DeclPrinter::VisitObjCMethodDecl` already has a similar handling.
would it provide value if you printed class and category names in the general 
case? If so it might make sense to update the logic in `DeclPrinter`.
If not, it looks like printing `selector` via `getAsString` is not enough, 
there's some special handling in `DeclPrinter`. Maybe move it into a public
place and make use of the same logic also in here to be consistent?



Comment at: clangd/XRefs.cpp:470
+
+static std::string getNameForObjCContainer(const ObjCContainerDecl *C) {
+  if (const ObjCCategoryDecl *Category = dyn_cast(C)) {

again there are printers in for `ObjCCategory{Impl}Decl`s that don't respect 
`TerseOutput` option in printing policies. It might be sensible to update them 
instead to print an output like what you propose in here, in the presence of 
`TerseOutput` option. WDYT?



Comment at: clangd/XRefs.cpp:509
+  DC = DC->getParent();
+  if (DC) {  // Skip over parent Objective-C container.
+DC = DC->getParent();

instead of saying what you do, could you say why you do it. IIUC, it is because 
the relevant bits of the container is already printed in `getNameForObjCMethod` 
right?


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D68590



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


[PATCH] D63960: [C++20] Add consteval-specific semantic for functions

2019-10-18 Thread Tyker via Phabricator via cfe-commits
Tyker added a comment.

ping @rsmith


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

https://reviews.llvm.org/D63960



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


[PATCH] D67216: [cfi] Add flag to always generate .debug_frame

2019-10-18 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

How about `-f[no-]force-dwarf-frame`, which I think matches the spelling and 
behaviour of the existing `-fforce-enable-int128` and `-fforce-emit-vtables` 
options?


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

https://reviews.llvm.org/D67216



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


[PATCH] D69043: [RFC] Adding time-trace to LLD?

2019-10-18 Thread Russell Gallop via Phabricator via cfe-commits
russell.gallop added a comment.

In D69043#1714060 , @ruiu wrote:

> I applied this patch and built clang with ThinLTO. Here is the generated file:
>  This file seems much smaller than yours. What am I missing?


I have seen some very empty looking traces when ThinLTO doesn't have much to 
do. Is it possible that the ThinLTO cache is doing a very good job?

> (I couldn't download your file because the server times out perhaps due to 
> the file size.)

That's odd. I can download it okay from here.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69043



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 225575.
gchatelet marked 3 inline comments as done.
gchatelet added a comment.

- Change NoBuiltin from InheritableAttr to Attr
- Improve tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
\ No newline at end of file
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -74,6 +74,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,54 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}
+
+// CHECK-LABEL: define void @separate_attrs() #2
+extern "C" v

[PATCH] D68539: [clang-tidy] fix for readability-identifier-naming incorrectly fixes variables which become keywords

2019-10-18 Thread Daniel via Phabricator via cfe-commits
Daniel599 marked an inline comment as done.
Daniel599 added a comment.

Hi, any updates regarding my patch? issues to fix?
Thanks.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68539



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 225576.
gchatelet marked an inline comment as done.
gchatelet added a comment.

- Improve tests


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  void whatever() __attribute__((no_builtin("memcpy")));
+  // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -74,6 +74,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}

[PATCH] D69043: [RFC] Adding time-trace to LLD?

2019-10-18 Thread George Rimar via Phabricator via cfe-commits
grimar added a comment.

In D69043#1714134 , @russell.gallop 
wrote:

> In D69043#1714060 , @ruiu wrote:
>
> > (I couldn't download your file because the server times out perhaps due to 
> > the file size.)
>
>
> That's odd. I can download it okay from here.


It probably was a temporary issue. I was unable to download it ~2h ago too, but 
now it works fine for me.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69043



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 225578.
gchatelet added a comment.

- Reverting whole file formatting


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  void whatever() __attribute__((no_builtin("memcpy")));
+  // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -74,6 +74,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,59 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}
+
+// CHECK-LABEL: define

[PATCH] D68720: Support -fstack-clash-protection for x86

2019-10-18 Thread serge via Phabricator via cfe-commits
serge-sans-paille updated this revision to Diff 225580.
serge-sans-paille added a comment.

Explicilty prefer existing mechanism for windows.
Split loop/block allocation strategy to different functions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/CodeGenOptions.def
  clang/include/clang/Basic/DiagnosticFrontendKinds.td
  clang/include/clang/Basic/TargetInfo.h
  clang/include/clang/Driver/CC1Options.td
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/X86.h
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/stack-clash-protection.c
  clang/test/Driver/stack-clash-protection.c
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/CodeGen/TargetLowering.h
  llvm/lib/Target/X86/X86CallFrameOptimization.cpp
  llvm/lib/Target/X86/X86FrameLowering.cpp
  llvm/lib/Target/X86/X86FrameLowering.h
  llvm/lib/Target/X86/X86ISelLowering.cpp
  llvm/lib/Target/X86/X86ISelLowering.h
  llvm/lib/Target/X86/X86InstrCompiler.td
  llvm/lib/Target/X86/X86InstrInfo.td
  llvm/test/CodeGen/X86/stack-clash-dynamic-alloca.ll
  llvm/test/CodeGen/X86/stack-clash-large.ll
  llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
  llvm/test/CodeGen/X86/stack-clash-medium.ll
  llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
  llvm/test/CodeGen/X86/stack-clash-small.ll

Index: llvm/test/CodeGen/X86/stack-clash-small.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-small.ll
@@ -0,0 +1,25 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 288
+; CHECK-NEXT:  movl	$1, 264(%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$280, %rsp # imm = 0x118
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 100, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 98
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-no-free-probe.ll
@@ -0,0 +1,27 @@
+; RUN: llc < %s | FileCheck %s
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo(i64 %i) local_unnamed_addr #0 {
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, -128(%rsp,%rdi,4)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i32 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 %i
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
+
Index: llvm/test/CodeGen/X86/stack-clash-medium.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-medium.ll
@@ -0,0 +1,28 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+
+; CHECK-LABEL: foo:
+; CHECK:   # %bb.0:
+; CHECK-NEXT:  subq	$4096, %rsp # imm = 0x1000
+; CHECK-NEXT:  .cfi_def_cfa_offset 7888
+; CHECK-NEXT:  movl	$1, 880(%rsp)
+; CHECK-NEXT:  subq	$3784, %rsp # imm = 0xEC8
+; CHECK-NEXT:  movq	$0, (%rsp)
+; CHECK-NEXT:  movl	-128(%rsp), %eax
+; CHECK-NEXT:  addq	$7880, %rsp # imm = 0x1EC8
+; CHECK-NEXT:  .cfi_def_cfa_offset 8
+; CHECK-NEXT:  retq
+
+  %a = alloca i32, i64 2000, align 16
+  %b = getelementptr inbounds i32, i32* %a, i64 1198
+  store volatile i32 1, i32* %b
+  %c = load volatile i32, i32* %a
+  ret i32 %c
+}
+
+attributes #0 =  {"probe-stack"="inline-asm"}
Index: llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
===
--- /dev/null
+++ llvm/test/CodeGen/X86/stack-clash-medium-natural-probes.ll
@@ -0,0 +1,31 @@
+; RUN: llc < %s | FileCheck %s
+
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @foo() local_unnamed_addr #0 {
+
+; CHECK-LABEL: foo:
+; CHECK: # %bb.0:
+; CHECK-NEXT: 	 

[PATCH] D67550: [AArch64][SVE] Implement unpack intrinsics

2019-10-18 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
kmclaughlin marked an inline comment as done.
Closed by commit rG0c7cc383e5b8: [AArch64][SVE] Implement unpack intrinsics 
(authored by kmclaughlin).
Herald added a subscriber: hiraditya.
Herald added a project: LLVM.

Changed prior to commit:
  https://reviews.llvm.org/D67550?vs=224558&id=225581#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67550

Files:
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64ISelLowering.cpp
  llvm/lib/Target/AArch64/AArch64ISelLowering.h
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
  llvm/lib/Target/AArch64/SVEInstrFormats.td
  llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll

Index: llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/sve-intrinsics-perm-select.ll
@@ -0,0 +1,129 @@
+; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
+
+;
+; SUNPKHI
+;
+
+define  @sunpkhi_i16( %a) {
+; CHECK-LABEL: sunpkhi_i16
+; CHECK: sunpkhi z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpkhi.nxv8i16( %a)
+  ret  %res
+}
+
+define  @sunpkhi_i32( %a) {
+; CHECK-LABEL: sunpkhi_i32
+; CHECK: sunpkhi z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpkhi.nxv4i32( %a)
+  ret  %res
+}
+
+define  @sunpkhi_i64( %a) {
+; CHECK-LABEL:  sunpkhi_i64
+; CHECK: sunpkhi z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpkhi.nxv2i64( %a)
+  ret  %res
+}
+
+;
+; SUNPKLO
+;
+
+define  @sunpklo_i16( %a) {
+; CHECK-LABEL: sunpklo_i16
+; CHECK: sunpklo z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpklo.nxv8i16( %a)
+  ret  %res
+}
+
+define  @sunpklo_i32( %a) {
+; CHECK-LABEL: sunpklo_i32
+; CHECK: sunpklo z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpklo.nxv4i32( %a)
+  ret  %res
+}
+
+define  @sunpklo_i64( %a) {
+; CHECK-LABEL:  sunpklo_i64
+; CHECK: sunpklo z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.sunpklo.nxv2i64( %a)
+  ret  %res
+}
+
+;
+; UUNPKHI
+;
+
+define  @uunpkhi_i16( %a) {
+; CHECK-LABEL: uunpkhi_i16
+; CHECK: uunpkhi z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpkhi.nxv8i16( %a)
+  ret  %res
+}
+
+define  @uunpkhi_i32( %a) {
+; CHECK-LABEL: uunpkhi_i32
+; CHECK: uunpkhi z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpkhi.nxv4i32( %a)
+  ret  %res
+}
+
+define  @uunpkhi_i64( %a) {
+; CHECK-LABEL:  uunpkhi_i64
+; CHECK: uunpkhi z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpkhi.nxv2i64( %a)
+  ret  %res
+}
+
+;
+; UUNPKLO
+;
+
+define  @uunpklo_i16( %a) {
+; CHECK-LABEL: uunpklo_i16
+; CHECK: uunpklo z0.h, z0.b
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpklo.nxv8i16( %a)
+  ret  %res
+}
+
+define  @uunpklo_i32( %a) {
+; CHECK-LABEL: uunpklo_i32
+; CHECK: uunpklo z0.s, z0.h
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpklo.nxv4i32( %a)
+  ret  %res
+}
+
+define  @uunpklo_i64( %a) {
+; CHECK-LABEL:  uunpklo_i64
+; CHECK: uunpklo z0.d, z0.s
+; CHECK-NEXT: ret
+  %res = call  @llvm.aarch64.sve.uunpklo.nxv2i64( %a)
+  ret  %res
+}
+
+declare  @llvm.aarch64.sve.sunpkhi.nxv8i16()
+declare  @llvm.aarch64.sve.sunpkhi.nxv4i32()
+declare  @llvm.aarch64.sve.sunpkhi.nxv2i64()
+
+declare  @llvm.aarch64.sve.sunpklo.nxv8i16()
+declare  @llvm.aarch64.sve.sunpklo.nxv4i32()
+declare  @llvm.aarch64.sve.sunpklo.nxv2i64()
+
+declare  @llvm.aarch64.sve.uunpkhi.nxv8i16()
+declare  @llvm.aarch64.sve.uunpkhi.nxv4i32()
+declare  @llvm.aarch64.sve.uunpkhi.nxv2i64()
+
+declare  @llvm.aarch64.sve.uunpklo.nxv8i16()
+declare  @llvm.aarch64.sve.uunpklo.nxv4i32()
+declare  @llvm.aarch64.sve.uunpklo.nxv2i64()
Index: llvm/lib/Target/AArch64/SVEInstrFormats.td
===
--- llvm/lib/Target/AArch64/SVEInstrFormats.td
+++ llvm/lib/Target/AArch64/SVEInstrFormats.td
@@ -848,10 +848,14 @@
   let Inst{4-0}   = Zd;
 }
 
-multiclass sve_int_perm_unpk opc, string asm> {
+multiclass sve_int_perm_unpk opc, string asm, SDPatternOperator op> {
   def _H : sve_int_perm_unpk<0b01, opc, asm, ZPR16, ZPR8>;
   def _S : sve_int_perm_unpk<0b10, opc, asm, ZPR32, ZPR16>;
   def _D : sve_int_perm_unpk<0b11, opc, asm, ZPR64, ZPR32>;
+
+  def : SVE_1_Op_Pat(NAME # _H)>;
+  def : SVE_1_Op_Pat(NAME # _S)>;
+  def : SVE_1_Op_Pat(NAME # _D)>;
 }
 
 class sve_int_perm_insrs sz8_64, string asm, ZPRRegOp zprty,
Index: llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64SVEInstrInfo.td
@@ -211,10 +211,10 @@
   defm REV_PP : sve_int_perm_reverse_p<"rev">;
   defm REV_ZZ : sve_int_perm_re

[PATCH] D47987: Provide only one declaration of __throw_runtime_error

2019-10-18 Thread Dimitry Andric via Phabricator via cfe-commits
dim abandoned this revision.
dim added a comment.
Herald added a subscriber: libcxx-commits.

Obsoleted by D58425  (and rCXX354515 
).


Repository:
  rCXX libc++

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

https://reviews.llvm.org/D47987



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


[PATCH] D68720: Support -fstack-clash-protection for x86

2019-10-18 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

You should also probably document the arg in
clang/docs/ClangCommandLineReference.rst 
we have  -fstack-protector-strong & co in the doc


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68720



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/FindTarget.cpp:495
   struct Visitor : TypeLocVisitor {
-llvm::Optional Ref;
+llvm::SmallVector Refs;
 

Could we keep an `llvm::Optional<>` here in the visitor?
The logic in `VisitElaboratedTypeLoc` looks cheesy if there's more than 1 
reference stored...

The function can keep returning `SmallVector`, that's totally fine.



Comment at: clang-tools-extra/clangd/unittests/FindTargetTests.cpp:603
"0: targets = {ns}\n"
-   "1: targets = {ns::global}, qualifier = 'ns::'\n"},
+   "1: targets = {ns::global}, qualifier = 'ns::', decl\n"},
   // Simple types.

Similar to `using namespace`, this should be a non-decl reference.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D69162: [clangd] Remove using-namespace present inside a namespace.

2019-10-18 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 created this revision.
usaxena95 added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, mgrang, jkorous, 
MaskRay.
Herald added a project: clang.

This patch extends the removing using-namespace code action to remove
using-namespace decl that are present inside a namespace.

Goes over all the references that are declared in `TargetNS` and used in
`ContainingNS`. Removes the current qualifer and qualifies it with only
the `TargetNS`. No other qualifier is needed since it was legal to do
`using namespace TargetNS` in the `ContainingNS`. Therefore all
references inside the `ContainingNS` can be qualified with just
`TargetNS`.

Limitations:

- The using decl must be present in TUDecl or directly under NSDecl.
- Only references inside the DeclContext of using-decl are removed. Any

references outisde this DeclContext are retained as is which is
incorrect.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69162

Files:
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -789,15 +789,23 @@
 map m;
   }
 )cpp"},
-  {// Available only for top level namespace decl.
-   R"cpp(
-namespace aa {
-  namespace bb { struct map {}; }
-  using namespace b^b;
-}
-int main() { aa::map m; }
+  {
+  // FIXME: Does not remove usages outside the enclosing NS.
+  R"cpp(
+  namespace aa {
+  namespace bb { struct map {}; }
+  using namespace b^b;
+  }
+  int main() { aa::map m; }
 )cpp",
-   "unavailable"},
+  R"cpp(
+  namespace aa {
+  namespace bb { struct map {}; }
+  
+  }
+  int main() { aa::map m; }
+)cpp",
+  },
   {// FIXME: Unavailable for namespaces containing using-namespace decl.
R"cpp(
   namespace aa {
@@ -875,7 +883,82 @@
   int main() {
 std::vector V;
   }
-)cpp"}};
+)cpp"},
+  {// using inner namespaces.
+   R"cpp(
+  namespace A { namespace B { 
+  inline namespace ns1 { namespace std { struct vector {}; } }
+  using namespace st^d;
+  using namespace A::B::std;
+  using namespace B::std;
+  void func() { 
+vector V1;
+B::vector V2;
+A::B::vector V3;
+A::B::std::vector V4;
+::A::B::std::vector V5;
+::A::B::ns1::std::vector V6;
+  }
+  }}
+)cpp",
+   R"cpp(
+  namespace A { namespace B { 
+  inline namespace ns1 { namespace std { struct vector {}; } }
+  
+  
+  
+  void func() { 
+std::vector V1;
+std::vector V2;
+std::vector V3;
+std::vector V4;
+std::vector V5;
+std::vector V6;
+  }
+  }}
+)cpp"},
+  {// using outer namespaces.
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B { 
+  using namespace st^d;
+  void func() { 
+vector V1;
+B::vector V2;
+A::B::vector V3;
+::A::B::vector V4;
+  }
+  }}
+)cpp",
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B { 
+  
+  void func() { 
+std::vector V1;
+std::vector V2;
+std::vector V3;
+std::vector V4;
+  }
+  }}
+)cpp"},
+  {// FIXME: No replacements produced for extended namespace.
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B { using namespace st^d; }}
+  namespace A { namespace B { int func() { vector V1;}}}
+)cpp",
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B {  }}
+  namespace A { namespace B { int func() { vector V1;}}}
+)cpp"},
+  {// Not available for contexts that are not global or namespaces.
+   R"cpp(
+  namespace std { struct vector {}; }
+  int main() { if(true) { using namespace st^d;}}
+)cpp",
+   "unavailable"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
 }
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -18,6 +18,7 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "llvm/ADT/ScopeExit.h"
+#include 
 
 namespace clang {
 namespace clangd {
@@ -28,9 +29,10 @@
 ///   vector foo(std::map);
 /// Would become:
 ///   std::vector foo(std::map);
-/// Currently limited to using names

[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 225593.
gchatelet added a comment.

- Call sites to virtual functions are not annotated


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  void whatever() __attribute__((no_builtin("memcpy")));
+  // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -74,6 +74,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}
+
+// C

[PATCH] D69162: [clangd] Remove using-namespace present inside a namespace.

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

Build result: fail - 33547 tests passed, 1 failed and 464 were skipped.

  failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69162



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


[PATCH] D69162: [clangd] Remove using-namespace present inside a namespace.

2019-10-18 Thread UTKARSH SAXENA via Phabricator via cfe-commits
usaxena95 updated this revision to Diff 225596.
usaxena95 added a comment.

Added additional tests.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69162

Files:
  clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp

Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -789,15 +789,23 @@
 map m;
   }
 )cpp"},
-  {// Available only for top level namespace decl.
-   R"cpp(
-namespace aa {
-  namespace bb { struct map {}; }
-  using namespace b^b;
-}
-int main() { aa::map m; }
+  {
+  // FIXME: Does not remove usages outside the enclosing NS.
+  R"cpp(
+  namespace aa {
+  namespace bb { struct map {}; }
+  using namespace b^b;
+  }
+  int main() { aa::map m; }
 )cpp",
-   "unavailable"},
+  R"cpp(
+  namespace aa {
+  namespace bb { struct map {}; }
+  
+  }
+  int main() { aa::map m; }
+)cpp",
+  },
   {// FIXME: Unavailable for namespaces containing using-namespace decl.
R"cpp(
   namespace aa {
@@ -875,7 +883,116 @@
   int main() {
 std::vector V;
   }
-)cpp"}};
+)cpp"},
+  {// using inner namespaces.
+   R"cpp(
+  namespace A { namespace B { 
+  inline namespace ns1 { namespace std { struct vector {}; } }
+  using namespace st^d;
+  using namespace A::B::std;
+  using namespace B::std;
+  void func() { 
+vector V1;
+B::vector V2;
+A::B::vector V3;
+A::B::std::vector V4;
+::A::B::std::vector V5;
+::A::B::ns1::std::vector V6;
+  }
+  }}
+)cpp",
+   R"cpp(
+  namespace A { namespace B { 
+  inline namespace ns1 { namespace std { struct vector {}; } }
+  
+  
+  
+  void func() { 
+std::vector V1;
+std::vector V2;
+std::vector V3;
+std::vector V4;
+std::vector V5;
+std::vector V6;
+  }
+  }}
+)cpp"},
+  {// using outer namespaces.
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B { 
+  using namespace st^d;
+  void func() { 
+vector V1;
+B::vector V2;
+A::B::vector V3;
+::A::B::vector V4;
+  }
+  }}
+)cpp",
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B { 
+  
+  void func() { 
+std::vector V1;
+std::vector V2;
+std::vector V3;
+std::vector V4;
+  }
+  }}
+)cpp"},
+  {// FIXME: No replacements produced for extended namespace.
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B { using namespace st^d; }}
+  namespace A { namespace B { int func() { vector V1;}}}
+)cpp",
+   R"cpp(
+  namespace std { struct vector {}; }
+  namespace A { namespace B {  }}
+  namespace A { namespace B { int func() { vector V1;}}}
+)cpp"},
+  {// using namespace for outer and inner namespaces: remove inner.
+   R"cpp(
+  namespace out { namespace std { struct vector{}; }}
+  namespace A {
+  using namespace out;
+  using namespace st^d;
+  void func() { vector V;}
+  }
+)cpp",
+   R"cpp(
+  namespace out { namespace std { struct vector{}; }}
+  namespace A {
+  using namespace out;
+  
+  void func() { std::vector V;}
+  }
+)cpp"},
+  {// using namespace for outer and inner namespaces: remove outer.
+   R"cpp(
+  namespace out { namespace std { struct vector{}; }}
+  namespace A {
+  using namespace ou^t;
+  using namespace std;
+  void func() { vector V;}
+  }
+)cpp",
+   R"cpp(
+  namespace out { namespace std { struct vector{}; }}
+  namespace A {
+  
+  using namespace out::std;
+  void func() { vector V;}
+  }
+)cpp"},
+  {// Not available for contexts that are not global or namespaces.
+   R"cpp(
+  namespace std { struct vector {}; }
+  int main() { if(true) { using namespace st^d;}}
+)cpp",
+   "unavailable"}};
   for (auto C : Cases)
 EXPECT_EQ(C.second, apply(C.first)) << C.first;
 }
Index: clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/RemoveUsingNamespace.cpp
@@ -18,6 +18,7 @@
 #include "clang/Tooling/Core/Replacement.h"
 #include "clang/Tooling/Refactoring/RecursiveSymbolVisitor.h"
 #include "llvm/ADT/ScopeExit.

[PATCH] D69162: [clangd] Remove using-namespace present inside a namespace.

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

Build result: fail - 33547 tests passed, 1 failed and 464 were skipped.

  failed: LLVM.tools/llvm-ar/mri-utf8.test

Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69162



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-18 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 225597.
hokein marked 2 inline comments as done.
hokein added a comment.

address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2277,7 +2277,8 @@
   if (const auto *ND = llvm::dyn_cast(D))
 Names.push_back(ND->getQualifiedNameAsString());
 }
-EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls));
+EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
+<< File.code();
   }
 }
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -606,53 +606,61 @@
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
-   $0^Struct x;
-   $1^Typedef y;
-   static_cast<$2^Struct*>(0);
+   $0^Struct $1^x;
+   $2^Typedef $3^y;
+   static_cast<$4^Struct*>(0);
  }
)cpp",
"0: targets = {Struct}\n"
-   "1: targets = {Typedef}\n"
-   "2: targets = {Struct}\n"},
+   "1: targets = {x}, decl\n"
+   "2: targets = {Typedef}\n"
+   "3: targets = {y}, decl\n"
+   "4: targets = {Struct}\n"},
   // Name qualifiers.
   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
-   $0^a::$1^b::$2^S x;
-   using namespace $3^a::$4^b;
-   $5^S::$6^type y;
+   $0^a::$1^b::$2^S $3^x;
+   using namespace $4^a::$5^b;
+   $6^S::$7^type $8^y;
  }
 )cpp",
"0: targets = {a}\n"
"1: targets = {a::b}, qualifier = 'a::'\n"
"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {a}\n"
-   "4: targets = {a::b}, qualifier = 'a::'\n"
-   "5: targets = {a::b::S}\n"
-   "6: targets = {a::b::S::type}, qualifier = 'struct S::'\n"},
+   "3: targets = {x}, decl\n"
+   "4: targets = {a}\n"
+   "5: targets = {a::b}, qualifier = 'a::'\n"
+   "6: targets = {a::b::S}\n"
+   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
+   "8: targets = {y}, decl\n"},
   // Simple templates.
   {R"cpp(
   template  struct vector { using value_type = T; };
   template <> struct vector { using value_type = bool; };
   void foo() {
-$0^vector vi;
-$1^vector vb;
+$0^vector $1^vi;
+$2^vector $3^vb;
   }
 )cpp",
"0: targets = {vector}\n"
-   "1: targets = {vector}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {vector}\n"
+   "3: targets = {vb}, decl\n"},
   // Template type aliases.
   {R"cpp(
 template  struct vector { using value_type = T; };
 template <> struct vector { using value_type = bool; };
 template  using valias = vector;
 void foo() {
-  $0^valias vi;
-  $1^valias vb;
+  $0^valias $1^vi;
+  $2^valias $3^vb;
 }
   )cpp",
"0: targets = {valias}\n"
-   "1: targets = {valias}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {valias}\n"
+   "3: targets = {vb}, decl\n"},
   // MemberExpr should know their using declaration.
   {R"cpp(
 struct X { void func(int); }
@@ -694,13 +702,14 @@
 };
 
 void foo() {
-  for (int x : $0^vector()) {
-$1^x = 10;
+  for (int $0^x : $1^vector()) {
+$2^x = 10;
   }
 }
 )cpp",
-   "0: targets = {vector}\n"
-   "1: targets = {x}\n"},
+   "0: targets = {x}, decl\n"
+   "1: targets = {vector}\n"
+   "2: targets = {x}\n"},
   // Handle UnresolvedLookupExpr.
   {R"cpp(
 namespace ns1 { void func(char*); }
@@ -736,39 +745,42 @@
 void foo() {
   static_cast<$0^T>(0);
   $1^T();
-  $2^T t;
+  $2^T $3^t;
 }
 )cpp",
   

[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-18 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM. Many thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[clang-tools-extra] r375226 - [clangd] Report declaration references in findExplicitReferences.

2019-10-18 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Fri Oct 18 05:07:19 2019
New Revision: 375226

URL: http://llvm.org/viewvc/llvm-project?rev=375226&view=rev
Log:
[clangd] Report declaration references in findExplicitReferences.

Reviewers: ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/AST.cpp
clang-tools-extra/trunk/clangd/AST.h
clang-tools-extra/trunk/clangd/FindTarget.cpp
clang-tools-extra/trunk/clangd/FindTarget.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp
clang-tools-extra/trunk/clangd/unittests/XRefsTests.cpp

Modified: clang-tools-extra/trunk/clangd/AST.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.cpp?rev=375226&r1=375225&r2=375226&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.cpp (original)
+++ clang-tools-extra/trunk/clangd/AST.cpp Fri Oct 18 05:07:19 2019
@@ -103,16 +103,12 @@ static bool isAnonymous(const Declaratio
   return N.isIdentifier() && !N.getAsIdentifierInfo();
 }
 
-/// Returns a nested name specifier of \p ND if it was present in the source,
-/// e.g.
-/// void ns::something::foo() -> returns 'ns::something'
-/// void foo() -> returns null
-static NestedNameSpecifier *getQualifier(const NamedDecl &ND) {
+NestedNameSpecifierLoc getQualifierLoc(const NamedDecl &ND) {
   if (auto *V = llvm::dyn_cast(&ND))
-return V->getQualifier();
+return V->getQualifierLoc();
   if (auto *T = llvm::dyn_cast(&ND))
-return T->getQualifier();
-  return nullptr;
+return T->getQualifierLoc();
+  return NestedNameSpecifierLoc();
 }
 
 std::string printUsingNamespaceName(const ASTContext &Ctx,
@@ -153,7 +149,7 @@ std::string printName(const ASTContext &
   }
 
   // Print nested name qualifier if it was written in the source code.
-  if (auto *Qualifier = getQualifier(ND))
+  if (auto *Qualifier = getQualifierLoc(ND).getNestedNameSpecifier())
 Qualifier->print(Out, PP);
   // Print the name itself.
   ND.getDeclName().print(Out, PP);

Modified: clang-tools-extra/trunk/clangd/AST.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/AST.h?rev=375226&r1=375225&r2=375226&view=diff
==
--- clang-tools-extra/trunk/clangd/AST.h (original)
+++ clang-tools-extra/trunk/clangd/AST.h Fri Oct 18 05:07:19 2019
@@ -104,6 +104,12 @@ bool isImplicitTemplateInstantiation(con
 ///   explicit specialization.
 bool isExplicitTemplateSpecialization(const NamedDecl *D);
 
+/// Returns a nested name specifier loc of \p ND if it was present in the
+/// source, e.g.
+/// void ns::something::foo() -> returns 'ns::something'
+/// void foo() -> returns null
+NestedNameSpecifierLoc getQualifierLoc(const NamedDecl &ND);
+
 } // namespace clangd
 } // namespace clang
 

Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindTarget.cpp?rev=375226&r1=375225&r2=375226&view=diff
==
--- clang-tools-extra/trunk/clangd/FindTarget.cpp (original)
+++ clang-tools-extra/trunk/clangd/FindTarget.cpp Fri Oct 18 05:07:19 2019
@@ -412,63 +412,86 @@ explicitReferenceTargets(DynTypedNode N,
   return Targets;
 }
 
-Optional refInDecl(const Decl *D) {
+llvm::SmallVector refInDecl(const Decl *D) {
   struct Visitor : ConstDeclVisitor {
-llvm::Optional Ref;
+llvm::SmallVector Refs;
 
 void VisitUsingDirectiveDecl(const UsingDirectiveDecl *D) {
-  Ref = ReferenceLoc{D->getQualifierLoc(),
- D->getIdentLocation(),
- {D->getNominatedNamespaceAsWritten()}};
+  // We want to keep it as non-declaration references, as the
+  // "using namespace" declaration doesn't have a name.
+  Refs.push_back(ReferenceLoc{D->getQualifierLoc(),
+  D->getIdentLocation(),
+  /*IsDecl=*/false,
+  {D->getNominatedNamespaceAsWritten()}});
 }
 
 void VisitUsingDecl(const UsingDecl *D) {
-  Ref = ReferenceLoc{D->getQualifierLoc(), D->getLocation(),
- explicitReferenceTargets(DynTypedNode::create(*D),
-  DeclRelation::Underlying)};
+  // "using ns::identifer;" is a non-declaration reference.
+  Refs.push_back(
+  ReferenceLoc{D->getQualifierLoc(), D->getLocation(), 
/*IsDecl=*/false,
+   explicitReferenceTargets(DynTypedNode::create(*D),
+DeclRelation::Underlying)});
 }
 
 void VisitNamespaceAliasDecl(const NamespaceAliasDecl *D) {
-  Ref 

[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

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

Build result: fail - 33449 tests passed, 2 failed and 463 were skipped.

  failed: LLVM.tools/llvm-ar/mri-utf8.test
  failed: LLVM.tools/llvm-objdump/X86/disassemble-functions.test

Log files: cmake-log.txt 
, 
ninja_check_all-log.txt 
, 
CMakeCache.txt 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977



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


[PATCH] D68977: [clangd] Report declaration references in findExplicitReferences.

2019-10-18 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG65f61c0030c5: [clangd] Report declaration references in 
findExplicitReferences. (authored by hokein).

Changed prior to commit:
  https://reviews.llvm.org/D68977?vs=225597&id=225601#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68977

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2284,7 +2284,8 @@
   if (const auto *ND = llvm::dyn_cast(D))
 Names.push_back(ND->getQualifiedNameAsString());
 }
-EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls));
+EXPECT_THAT(Names, UnorderedElementsAreArray(C.ExpectedDecls))
+<< File.code();
   }
 }
 
Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- clang-tools-extra/clangd/unittests/FindTargetTests.cpp
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -622,53 +622,61 @@
  struct Struct { int a; };
  using Typedef = int;
  void foo() {
-   $0^Struct x;
-   $1^Typedef y;
-   static_cast<$2^Struct*>(0);
+   $0^Struct $1^x;
+   $2^Typedef $3^y;
+   static_cast<$4^Struct*>(0);
  }
)cpp",
"0: targets = {Struct}\n"
-   "1: targets = {Typedef}\n"
-   "2: targets = {Struct}\n"},
+   "1: targets = {x}, decl\n"
+   "2: targets = {Typedef}\n"
+   "3: targets = {y}, decl\n"
+   "4: targets = {Struct}\n"},
   // Name qualifiers.
   {R"cpp(
  namespace a { namespace b { struct S { typedef int type; }; } }
  void foo() {
-   $0^a::$1^b::$2^S x;
-   using namespace $3^a::$4^b;
-   $5^S::$6^type y;
+   $0^a::$1^b::$2^S $3^x;
+   using namespace $4^a::$5^b;
+   $6^S::$7^type $8^y;
  }
 )cpp",
"0: targets = {a}\n"
"1: targets = {a::b}, qualifier = 'a::'\n"
"2: targets = {a::b::S}, qualifier = 'a::b::'\n"
-   "3: targets = {a}\n"
-   "4: targets = {a::b}, qualifier = 'a::'\n"
-   "5: targets = {a::b::S}\n"
-   "6: targets = {a::b::S::type}, qualifier = 'struct S::'\n"},
+   "3: targets = {x}, decl\n"
+   "4: targets = {a}\n"
+   "5: targets = {a::b}, qualifier = 'a::'\n"
+   "6: targets = {a::b::S}\n"
+   "7: targets = {a::b::S::type}, qualifier = 'struct S::'\n"
+   "8: targets = {y}, decl\n"},
   // Simple templates.
   {R"cpp(
   template  struct vector { using value_type = T; };
   template <> struct vector { using value_type = bool; };
   void foo() {
-$0^vector vi;
-$1^vector vb;
+$0^vector $1^vi;
+$2^vector $3^vb;
   }
 )cpp",
"0: targets = {vector}\n"
-   "1: targets = {vector}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {vector}\n"
+   "3: targets = {vb}, decl\n"},
   // Template type aliases.
   {R"cpp(
 template  struct vector { using value_type = T; };
 template <> struct vector { using value_type = bool; };
 template  using valias = vector;
 void foo() {
-  $0^valias vi;
-  $1^valias vb;
+  $0^valias $1^vi;
+  $2^valias $3^vb;
 }
   )cpp",
"0: targets = {valias}\n"
-   "1: targets = {valias}\n"},
+   "1: targets = {vi}, decl\n"
+   "2: targets = {valias}\n"
+   "3: targets = {vb}, decl\n"},
   // MemberExpr should know their using declaration.
   {R"cpp(
 struct X { void func(int); }
@@ -710,13 +718,14 @@
 };
 
 void foo() {
-  for (int x : $0^vector()) {
-$1^x = 10;
+  for (int $0^x : $1^vector()) {
+$2^x = 10;
   }
 }
 )cpp",
-   "0: targets = {vector}\n"
-   "1: targets = {x}\n"},
+   "0: targets = {x}, decl\n"
+   "1: targets = {vector}\n"
+   "2: targets = {x}\n"},
   // Handle UnresolvedLookupExpr.
   {R"cpp(
 namespace ns1 { void func(char*); }
@@ -752,39 +761,42 @@
 void f

[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4407
+It accepts one or more strings corresponding to the name of the builtin
+(e.g. "memcpy", "memset") or "*" which disables all builtins at once.
+

This mention of `*` is now out of date.



Comment at: clang/include/clang/Basic/AttrDocs.td:4412
+  // The compiler is not allowed to add any builtin to foo's body.
+  void foo(char* data, size_t count) __attribute__((no_builtin("*"))) {
+// The compiler is not allowed to convert the loop into

This one too.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3609
+  "'%0' is not a valid builtin name for %1">,
+  InGroup; // Which group should it be in?
+def err_attribute_no_builtin_wildcard_or_builtin_name : Error<

Hmm, I thought there was a way you could do:
```
InGroup>;
```
but it seems I've got the order reversed and you'd have to add a new diagnostic 
group that `IgnoredAttributes` could subsume. We don't do that for other 
attributes, so I think you should just do:
```
InGroup>;
```
(Feel free to pick a better diagnostic group name if you have a better idea, 
I'm not tied to my suggestion.)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
krasimir edited the summary of this revision.
krasimir added a reviewer: MyDeveloperDay.

r373922 added checks for a few tokens that, following an `)` make it
unlikely that the `)` is the closing paren of a cast expression. The
specific check for `tok::l_square` there introduced a regression for
casts of Obj-C calls, like:

  (cast)[func arg]

>From the tests added in r373922, I believe the `tok::l_square` case is added to
capture the case where a non-cast `)` is directly followed by an
attribute specifier, like:

  int f(int x) [[noreturn]];

I've specialized the code to look for such attribute specifier instead
of `tok::l_square` in general. Also, I added a regression test and moved
the test cases added in r373922 to an already existing place documenting
other instances of historically misidentified casts.


Repository:
  rC Clang

https://reviews.llvm.org/D69164

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


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7541,6 +7541,8 @@
   verifyFormat("my_int a = (ns::my_int)-2;");
   verifyFormat("case (my_int)ONE:");
   verifyFormat("auto x = (X)this;");
+  // Casts in Obj-C style calls used to not be recognized as such.
+  verifyFormat("int a = [(type*)[((type*)val) arg] arg];", getGoogleStyle());
 
   // FIXME: single value wrapped with paren will be treated as cast.
   verifyFormat("void f(int i = (kValue)*kMask) {}");
@@ -7581,6 +7583,29 @@
   verifyFormat("int a = alignof(int *) + b;", getGoogleStyle());
   verifyFormat("bool b = f(g) && c;");
   verifyFormat("typedef void (*f)(int i) func;");
+  verifyFormat("void operator++(int) noexcept;");
+  verifyFormat("void operator++(int &) noexcept;");
+  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
+   "&) noexcept;");
+  verifyFormat(
+  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(foo &) noexcept;");
+  verifyFormat("void operator delete(foo) noexcept;");
+  verifyFormat("void operator delete(int) noexcept;");
+  verifyFormat("void operator delete(int &) noexcept;");
+  verifyFormat("void operator delete(int &) volatile noexcept;");
+  verifyFormat("void operator delete(int &) const");
+  verifyFormat("void operator delete(int &) = default");
+  verifyFormat("void operator delete(int &) = delete");
+  verifyFormat("void operator delete(int &) [[noreturn]]");
+  verifyFormat("void operator delete(int &) throw();");
+  verifyFormat("void operator delete(int &) throw(int);");
+  verifyFormat("auto operator delete(int &) -> int;");
+  verifyFormat("auto operator delete(int &) override");
+  verifyFormat("auto operator delete(int &) final");
 
   verifyFormat(" *foo = (a 
*)\n"
"bbb;");
@@ -14696,33 +14721,6 @@
   */
 }
 
-TEST_F(FormatTest, NotCastRPaen) {
-
-  verifyFormat("void operator++(int) noexcept;");
-  verifyFormat("void operator++(int &) noexcept;");
-  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
-   "&) noexcept;");
-  verifyFormat(
-  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(foo &) noexcept;");
-  verifyFormat("void operator delete(foo) noexcept;");
-  verifyFormat("void operator delete(int) noexcept;");
-  verifyFormat("void operator delete(int &) noexcept;");
-  verifyFormat("void operator delete(int &) volatile noexcept;");
-  verifyFormat("void operator delete(int &) const");
-  verifyFormat("void operator delete(int &) = default");
-  verifyFormat("void operator delete(int &) = delete");
-  verifyFormat("void operator delete(int &) [[noreturn]]");
-  verifyFormat("void operator delete(int &) throw();");
-  verifyFormat("void operator delete(int &) throw(int);");
-  verifyFormat("auto operator delete(int &) -> int;");
-  verifyFormat("auto operator delete(int &) override");
-  verifyFormat("auto operator delete(int &) final");
-}
-
 TEST_F(FormatTest, STLWhileNotDefineChed) {
   verifyFormat("#if defined(while)\n"
"#define while EMIT WARNING C4005\n"
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Form

[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-10-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: lib/AST/Decl.cpp:1543
+Ctx = ID;
+  }
 

Like you said in a private conversation, yes, support for `ObjCIvarDecl` also 
seems necessary.



Comment at: unittests/AST/NamedDeclPrinterTest.cpp:220
+"property",
+"Obj::property"));
+}

I don't think that `Obj::property` is the preferred syntax. `Obj.property`? I'd 
want a review from someone from Apple to confirm.


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D69165: [clangd] Store Index in Tweak::Selection

2019-10-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Incoming define out-of-line tweak requires access to index.

This patch simply propogates the index in ClangdServer to Tweak::Selection while
passing the AST. Also updates TweakTest to accommodate this change.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69165

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/unittests/TweakTesting.cpp
  clang-tools-extra/clangd/unittests/TweakTesting.h

Index: clang-tools-extra/clangd/unittests/TweakTesting.h
===
--- clang-tools-extra/clangd/unittests/TweakTesting.h
+++ clang-tools-extra/clangd/unittests/TweakTesting.h
@@ -10,6 +10,7 @@
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TWEAKTESTING_H
 
 #include "TestTU.h"
+#include "index/Index.h"
 #include "llvm/ADT/StringMap.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
@@ -66,6 +67,9 @@
   // Context in which snippets of code should be placed to run tweaks.
   CodeContext Context = File;
 
+  // Index to be passed into Tweak::Selection.
+  const SymbolIndex *Index = nullptr;
+
   // Apply the current tweak to the range (or point) in MarkedCode.
   // MarkedCode will be wrapped according to the Context.
   //  - if the tweak produces edits, returns the edited code (without markings)
Index: clang-tools-extra/clangd/unittests/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/TweakTesting.cpp
@@ -14,6 +14,7 @@
 #include "refactor/Tweak.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/Support/Error.h"
+#include "gmock/gmock.h"
 #include 
 
 namespace clang {
@@ -61,7 +62,7 @@
   cantFail(positionToOffset(A.code(), SelectionRng.end))};
 }
 
-MATCHER_P4(TweakIsAvailable, TweakID, Ctx, Header, ExtraFiles,
+MATCHER_P5(TweakIsAvailable, TweakID, Ctx, Header, ExtraFiles, Index,
(TweakID + (negation ? " is unavailable" : " is available")).str()) {
   std::string WrappedCode = wrap(Ctx, arg);
   Annotations Input(WrappedCode);
@@ -71,7 +72,7 @@
   TU.Code = Input.code();
   TU.AdditionalFiles = std::move(ExtraFiles);
   ParsedAST AST = TU.build();
-  Tweak::Selection S(AST, Selection.first, Selection.second);
+  Tweak::Selection S(AST, Selection.first, Selection.second, Index);
   auto PrepareResult = prepareTweak(TweakID, S);
   if (PrepareResult)
 return true;
@@ -93,7 +94,7 @@
   TU.Code = Input.code();
   TU.ExtraArgs = ExtraArgs;
   ParsedAST AST = TU.build();
-  Tweak::Selection S(AST, Selection.first, Selection.second);
+  Tweak::Selection S(AST, Selection.first, Selection.second, Index);
 
   auto T = prepareTweak(TweakID, S);
   if (!T) {
@@ -123,8 +124,8 @@
 }
 
 ::testing::Matcher TweakTest::isAvailable() const {
-  return TweakIsAvailable(llvm::StringRef(TweakID), Context, Header,
-  ExtraFiles);
+  return TweakIsAvailable(llvm::StringRef(TweakID), Context, Header, ExtraFiles,
+  Index);
 }
 
 std::vector TweakTest::expandCases(llvm::StringRef MarkedCode) {
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -24,6 +24,7 @@
 #include "Protocol.h"
 #include "Selection.h"
 #include "SourceCode.h"
+#include "index/Index.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringMap.h"
@@ -46,7 +47,8 @@
 public:
   /// Input to prepare and apply tweaks.
   struct Selection {
-Selection(ParsedAST &AST, unsigned RangeBegin, unsigned RangeEnd);
+Selection(ParsedAST &AST, unsigned RangeBegin, unsigned RangeEnd,
+  const SymbolIndex *Index);
 /// The text of the active document.
 llvm::StringRef Code;
 /// Parsed AST of the active file.
@@ -60,6 +62,8 @@
 unsigned SelectionEnd;
 /// The AST nodes that were selected.
 SelectionTree ASTSelection;
+/// The Index being used by ClangdServer.
+const SymbolIndex *Index = nullptr;
 // FIXME: provide a way to get sources and ASTs for other files.
   };
 
Index: clang-tools-extra/clangd/refactor/Tweak.cpp
===
--- clang-tools-extra/clangd/refactor/Tweak.cpp
+++ clang-tools-extra/clangd/refactor/Tweak.cpp
@@ -9,6 +9,7 @@
 #include "Logger.h"
 #include "Path.h"
 #include "SourceCode.h"
+#include "index/Index.h"
 #include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
 #include "llvm/ADT/STLExtras.h"
@@ -45,9 +46,10 @@
 } // namespace
 
 Tweak::Selection::Selection(P

[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

LGTM, thanks for the patch


Repository:
  rC Clang

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

https://reviews.llvm.org/D69164



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


[PATCH] D68818: [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

PING for review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68818



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


[PATCH] D68528: [Implicit Modules] Add -cc1 option -fmodules-strict-hash which includes search paths and diagnostics.

2019-10-18 Thread Bruno Cardoso Lopes via Phabricator via cfe-commits
bruno added a comment.



> While adding the documentation I realized that a better name for this option 
> would be `-fmodules-strict-context-hash` to make it clear which hash it's 
> referring to.

`-fmodules-strict-context-hash` SGTM!


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

https://reviews.llvm.org/D68528



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


[PATCH] D68885: Add a Ranges field to Diagnostic struct

2019-10-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

Please upload patches with context in future (`arc diff` will do that for you).

Please also merge this patch with the user, https://reviews.llvm.org/D68887. No 
need to add untested code.




Comment at: include/clang/Tooling/Core/Diagnostic.h:88
+
+
+  /// Extra source ranges associated with the diagnostic. By default, the

Extra empty line.



Comment at: include/clang/Tooling/Core/Diagnostic.h:92
+  /// `Message` field, but if `Ranges` is nonempty, they will be preferred
+  /// representation of the source code associated with the diagnostic.
+  ArrayRef Ranges;

I don't understand the "preferred" wording here. What do you mean?

Also, this is a departure from how compiler warnings and ClangTidy messages 
work. Additional ranges are used to highlight parts of the code relevant to the 
problem, not to reposition the diagnostic.


Repository:
  rC Clang

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

https://reviews.llvm.org/D68885



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


[PATCH] D69155: [analyzer] Fix off-by-one in operator call parameter binding.

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:325
 if (getKind() != CE_CXXAllocator)
   if (isArgumentConstructedDirectly(Idx))
 if (auto AdjIdx = getAdjustedParameterIndex(Idx))

Charusso wrote:
> What about this one? It smells the same issue.
Here `Idx` is an argument index to begin with, so it shouldn't be a problem.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69155



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


[PATCH] D69155: [analyzer] Fix off-by-one in operator call parameter binding.

2019-10-18 Thread Csaba Dabis via Phabricator via cfe-commits
Charusso accepted this revision.
Charusso marked an inline comment as done.
Charusso added a comment.
This revision is now accepted and ready to land.

I think it will be a great educational material how to touch the core. Good 
luck!




Comment at: clang/lib/StaticAnalyzer/Core/CallEvent.cpp:325
 if (getKind() != CE_CXXAllocator)
   if (isArgumentConstructedDirectly(Idx))
 if (auto AdjIdx = getAdjustedParameterIndex(Idx))

NoQ wrote:
> Charusso wrote:
> > What about this one? It smells the same issue.
> Here `Idx` is an argument index to begin with, so it shouldn't be a problem.
Okai, thanks!


Repository:
  rC Clang

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

https://reviews.llvm.org/D69155



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


[PATCH] D68885: Add a Ranges field to Diagnostic struct

2019-10-18 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh added inline comments.



Comment at: include/clang/Tooling/Core/Diagnostic.h:93
+  /// representation of the source code associated with the diagnostic.
+  ArrayRef Ranges;
 };

Please add YAML serialization/deserialization code for this. See 
include/clang/Tooling/DiagnosticsYaml.h


Repository:
  rC Clang

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

https://reviews.llvm.org/D68885



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


[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Ronald Wampler via Phabricator via cfe-commits
rdwampler added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1612
+  Keywords.kw_final) ||
+isCpp11AttributeSpecifier(*Tok.Next))
   return false;

I think the issue r373922 was fixing is only related to the `delete`. Can this 
check be move further up where we explicitly check if the token is the delete 
keyword? 



Repository:
  rC Clang

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

https://reviews.llvm.org/D69164



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


[PATCH] D68340: Add AIX toolchain and basic linker functionality

2019-10-18 Thread Jason Liu via Phabricator via cfe-commits
jasonliu added inline comments.



Comment at: clang/lib/Driver/ToolChains/AIX.h:19
+
+/// aix -- Directly call system default and linker.
+// TODO: Enable direct call to system default assembler.

remove "and".



Comment at: clang/lib/Driver/ToolChains/AIX.h:36
+
+} // end namespace aix.
+

Sorry, I don't think we need '.' for any of the "end namespace ..." comment. 



Comment at: clang/lib/Driver/ToolChains/AIX.h:63
+
+#endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_AIX_H.

We don't need '.' here as well. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68340



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet marked 4 inline comments as done.
gchatelet added inline comments.



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3609
+  "'%0' is not a valid builtin name for %1">,
+  InGroup; // Which group should it be in?
+def err_attribute_no_builtin_wildcard_or_builtin_name : Error<

aaron.ballman wrote:
> Hmm, I thought there was a way you could do:
> ```
> InGroup>;
> ```
> but it seems I've got the order reversed and you'd have to add a new 
> diagnostic group that `IgnoredAttributes` could subsume. We don't do that for 
> other attributes, so I think you should just do:
> ```
> InGroup>;
> ```
> (Feel free to pick a better diagnostic group name if you have a better idea, 
> I'm not tied to my suggestion.)
`"invalid-no-builtin-names"` LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028



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


[PATCH] D68028: [clang] Add no_builtin attribute

2019-10-18 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 225618.
gchatelet added a comment.

- Fix documentation and Warning category


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68028

Files:
  clang/include/clang/AST/Decl.h
  clang/include/clang/Basic/Attr.td
  clang/include/clang/Basic/AttrDocs.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/CodeGen/CGCall.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/test/CodeGen/no-builtin.cpp
  clang/test/Misc/pragma-attribute-supported-attributes-list.test
  clang/test/Sema/no-builtin.cpp

Index: clang/test/Sema/no-builtin.cpp
===
--- /dev/null
+++ clang/test/Sema/no-builtin.cpp
@@ -0,0 +1,51 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-unknown -fsyntax-only -verify %s
+
+/// Prevent use of all builtins.
+void valid_attribute_all_1() __attribute__((no_builtin)) {}
+void valid_attribute_all_2() __attribute__((no_builtin())) {}
+
+/// Prevent use of specific builtins.
+void valid_attribute_function() __attribute__((no_builtin("memcpy"))) {}
+void valid_attribute_functions() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcmp"))) {}
+
+/// Many times the same builtin is fine.
+void many_attribute_function_1() __attribute__((no_builtin)) __attribute__((no_builtin)) {}
+void many_attribute_function_2() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+void many_attribute_function_3() __attribute__((no_builtin("memcpy", "memcpy"))) {}
+void many_attribute_function_4() __attribute__((no_builtin("memcpy", "memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+/// Invalid builtin name.
+void invalid_builtin() __attribute__((no_builtin("not_a_builtin"))) {}
+// expected-warning@-1 {{'not_a_builtin' is not a valid builtin name for no_builtin}}
+
+/// Can't use bare no_builtin with a named one.
+void wildcard_and_functionname() __attribute__((no_builtin)) __attribute__((no_builtin("memcpy"))) {}
+// expected-error@-1 {{empty no_builtin cannot be composed with named ones}}
+
+/// Can't attach attribute to a variable.
+int __attribute__((no_builtin)) variable;
+// expected-warning@-1 {{'no_builtin' attribute only applies to functions}}
+
+/// Can't attach attribute to a declaration.
+void nobuiltin_on_declaration() __attribute__((no_builtin));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+
+struct S {
+  /// Can't attach attribute to a defaulted function,
+  S()
+  __attribute__((no_builtin)) = default;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  /// Can't attach attribute to a deleted function,
+  S(const S &)
+  __attribute__((no_builtin)) = delete;
+  // expected-error@-1 {{no_builtin attribute has no effect on defaulted or deleted functions}}
+
+  void whatever() __attribute__((no_builtin("memcpy")));
+  // expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
+};
+
+/// Can't attach attribute to an aliased function.
+void alised_function() {}
+void aliasing_function() __attribute__((no_builtin)) __attribute__((alias("alised_function")));
+// expected-error@-1 {{no_builtin attribute is permitted on definitions only}}
Index: clang/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- clang/test/Misc/pragma-attribute-supported-attributes-list.test
+++ clang/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -74,6 +74,7 @@
 // CHECK-NEXT: NSConsumed (SubjectMatchRule_variable_is_parameter)
 // CHECK-NEXT: NSConsumesSelf (SubjectMatchRule_objc_method)
 // CHECK-NEXT: Naked (SubjectMatchRule_function)
+// CHECK-NEXT: NoBuiltin (SubjectMatchRule_function)
 // CHECK-NEXT: NoCommon (SubjectMatchRule_variable)
 // CHECK-NEXT: NoDebug (SubjectMatchRule_type_alias, SubjectMatchRule_hasType_functionType, SubjectMatchRule_objc_method, SubjectMatchRule_variable_not_is_parameter)
 // CHECK-NEXT: NoDestroy (SubjectMatchRule_variable)
Index: clang/test/CodeGen/no-builtin.cpp
===
--- /dev/null
+++ clang/test/CodeGen/no-builtin.cpp
@@ -0,0 +1,64 @@
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK-LABEL: define void @foo_no_mempcy() #0
+extern "C" void foo_no_mempcy() __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_twice() #0
+extern "C" void foo_no_mempcy_twice() __attribute__((no_builtin("memcpy"))) __attribute__((no_builtin("memcpy"))) {}
+
+// CHECK-LABEL: define void @foo_no_builtins() #1
+extern "C" void foo_no_builtins() __attribute__((no_builtin)) {}
+
+// CHECK-LABEL: define void @foo_no_mempcy_memset() #2
+extern "C" void foo_no_mempcy_memset() __attribute__((no_builtin("memset", "memcpy"))) {}
+
+// CHECK-LABEL:

[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao added a comment.

In D69124#1713427 , @tra wrote:

> This is... rather oddly-structured output. My brain refuses to accept that 
> the most-indented phase is the input.
>  Perhaps we should do `llvm::errs().indent(MaxIdent-Ident)`. This should give 
> us something like this (withMaxIdent=9), which is somewhat easier to grok, 
> IMO:
>
>   0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
>1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
> 2: compiler, {1}, ir, (host-cuda)
>   3: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_30)
>4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
> 5: compiler, {4}, ir, (device-cuda, sm_30)
>  6: backend, {5}, assembler, (device-cuda, sm_30)
>   7: assembler, {6}, object, (device-cuda, sm_30)
>8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
>9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
>   10: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_60)
>11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_60)
> 12: compiler, {11}, ir, (device-cuda, sm_60)
>  13: backend, {12}, assembler, (device-cuda, sm_60)
>   14: assembler, {13}, object, (device-cuda, sm_60)
>15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, object
>16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, assembler
> 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
>  18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, 
> "device-cuda (nvptx64-nvidia-cuda)" {17}, ir
>   19: backend, {18}, assembler, (host-cuda)
>20: assembler, {19}, object, (host-cuda)
>


As the top-level actions are the last actions to be performed, they should have 
no indentation

In D69124#1713427 , @tra wrote:

> This is... rather oddly-structured output. My brain refuses to accept that 
> the most-indented phase is the input.
>  Perhaps we should do `llvm::errs().indent(MaxIdent-Ident)`. This should give 
> us something like this (withMaxIdent=9), which is somewhat easier to grok, 
> IMO:
>
>   0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
>1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
> 2: compiler, {1}, ir, (host-cuda)
>   3: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_30)
>4: preprocessor, {3}, cuda-cpp-output, (device-cuda, sm_30)
> 5: compiler, {4}, ir, (device-cuda, sm_30)
>  6: backend, {5}, assembler, (device-cuda, sm_30)
>   7: assembler, {6}, object, (device-cuda, sm_30)
>8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
>9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, assembler
>   10: input, "/home/michliao/dummy.cpp", cuda, (device-cuda, sm_60)
>11: preprocessor, {10}, cuda-cpp-output, (device-cuda, sm_60)
> 12: compiler, {11}, ir, (device-cuda, sm_60)
>  13: backend, {12}, assembler, (device-cuda, sm_60)
>   14: assembler, {13}, object, (device-cuda, sm_60)
>15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, object
>16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, assembler
> 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
>  18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, 
> "device-cuda (nvptx64-nvidia-cuda)" {17}, ir
>   19: backend, {18}, assembler, (host-cuda)
>20: assembler, {19}, object, (host-cuda)
>


it's difficult to choose a proper `MaxIdent` though to avoid unnecessary 
leading whitespaces or misalign the output. How about we draw the tree edges in 
the original output? It looks much easier for me to identify sibling actions.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 225620.
hliao added a comment.

revise the output by drawing tree lines. now, the output looks like

  $ clang -x cuda -ccc-print-phases --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_60 
-c dummy.cpp
  +- 0: input, "/home/michliao/dummy.cpp", cuda, (host-cuda)
   +- 1: preprocessor, {0}, cuda-cpp-output, (host-cuda)
+- 2: compiler, {1}, ir, (host-cuda)
| +- 3: input, "/home/michliao/dummy.cpp", cuda, 
(device-cuda, sm_30)
|  +- 4: preprocessor, {3}, cuda-cpp-output, (device-cuda, 
sm_30)
|   +- 5: compiler, {4}, ir, (device-cuda, sm_30)
|+- 6: backend, {5}, assembler, (device-cuda, sm_30)
| +- 7: assembler, {6}, object, (device-cuda, sm_30)
|  +- 8: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {7}, object
|  |- 9: offload, "device-cuda (nvptx64-nvidia-cuda:sm_30)" {6}, 
assembler
|  |  +- 10: input, "/home/michliao/dummy.cpp", cuda, 
(device-cuda, sm_60)
|  |   +- 11: preprocessor, {10}, cuda-cpp-output, 
(device-cuda, sm_60)
|  |+- 12: compiler, {11}, ir, (device-cuda, sm_60)
|  | +- 13: backend, {12}, assembler, (device-cuda, sm_60)
|  |  +- 14: assembler, {13}, object, (device-cuda, sm_60)
|  |- 15: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {14}, 
object
|  |- 16: offload, "device-cuda (nvptx64-nvidia-cuda:sm_60)" {13}, 
assembler
|- 17: linker, {8, 9, 15, 16}, cuda-fatbin, (device-cuda)
 +- 18: offload, "host-cuda (x86_64-unknown-linux-gnu)" {2}, "device-cuda 
(nvptx64-nvidia-cuda)" {17}, ir
  +- 19: backend, {18}, assembler, (host-cuda)
  20: assembler, {19}, object, (host-cuda)



  $ clang -x hip -ccc-print-phases --cuda-gpu-arch=gfx900 
--cuda-gpu-arch=gfx906 -c dummy.cpp
  +- 0: input, "/home/michliao/dummy.cpp", hip, (host-hip)
   +- 1: preprocessor, {0}, hip-cpp-output, (host-hip)
+- 2: compiler, {1}, ir, (host-hip)
|  +- 3: input, "/home/michliao/dummy.cpp", hip, 
(device-hip, gfx900)
|   +- 4: preprocessor, {3}, hip-cpp-output, (device-hip, 
gfx900)
|+- 5: compiler, {4}, ir, (device-hip, gfx900)
| +- 6: linker, {5}, image, (device-hip, gfx900)
|  +- 7: offload, "device-hip (amdgcn-amd-amdhsa:gfx900)" {6}, image
|  |   +- 8: input, "/home/michliao/dummy.cpp", hip, 
(device-hip, gfx906)
|  |+- 9: preprocessor, {8}, hip-cpp-output, (device-hip, 
gfx906)
|  | +- 10: compiler, {9}, ir, (device-hip, gfx906)
|  |  +- 11: linker, {10}, image, (device-hip, gfx906)
|  |- 12: offload, "device-hip (amdgcn-amd-amdhsa:gfx906)" {11}, image
|- 13: linker, {7, 12}, hip-fatbin, (device-hip)
 +- 14: offload, "host-hip (x86_64-unknown-linux-gnu)" {2}, "device-hip 
(amdgcn-amd-amdhsa)" {13}, ir
  +- 15: backend, {14}, assembler, (host-hip)
  16: assembler, {15}, object, (host-hip)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124

Files:
  clang/lib/Driver/Driver.cpp


Index: clang/lib/Driver/Driver.cpp
===
--- clang/lib/Driver/Driver.cpp
+++ clang/lib/Driver/Driver.cpp
@@ -1802,23 +1802,36 @@
   return true;
 }
 
+enum {
+  TopLevelAction = 0,
+  HeadSibAction = 1,
+  OtherSibAction = 2,
+};
+
 // Display an action graph human-readably.  Action A is the "sink" node
 // and latest-occuring action. Traversal is in pre-order, visiting the
 // inputs to each action before printing the action itself.
 static unsigned PrintActions1(const Compilation &C, Action *A,
-  std::map &Ids) {
+  std::map &Ids,
+  Twine Indent = {}, int Kind = TopLevelAction) {
   if (Ids.count(A)) // A was already visited.
 return Ids[A];
 
   std::string str;
   llvm::raw_string_ostream os(str);
 
+  auto getSibIndent = [](int K) -> Twine {
+return (K == HeadSibAction) ? "   " : (K == OtherSibAction) ? "|  " : "";
+  };
+
+  Twine SibIndent = Indent + getSibIndent(Kind);
+  int SibKind = HeadSibAction;
   os << Action::getClassName(A->getKind()) << ", ";
   if (InputAction *IA = dyn_cast(A)) {
 os << "\"" << IA->getInputArg().getValue() << "\"";
   } else if (BindArchAction *BIA = dyn_cast(A)) {
 os << '"' << BIA->getArchName() << '"' << ", {"
-   << PrintActions1(C, *BIA->input_begin(), Ids) << "}";
+   << PrintActions1(C, *BIA->input_begin(), Ids, SibIndent, SibKind) << 
"}";
   } else if (OffloadAction *OA = dyn_cast(A)) {
 bool IsFirst = true;
 OA->doOnEachDependence(
@@ -1841,8 +1854,9 @@
 os << ":" << BoundArch;
   os << ")";
   os << '"';
-  os << " {" << PrintActions1(C, A, Ids) << "}";
+   

[PATCH] D67545: [clang-tidy] Added DefaultOperatorNewCheck.

2019-10-18 Thread Balázs Kéri via Phabricator via cfe-commits
balazske updated this revision to Diff 225625.
balazske added a comment.

- Fixes from review comments, added C++ version test.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67545

Files:
  clang-tools-extra/clang-tidy/cert/CERTTidyModule.cpp
  clang-tools-extra/clang-tidy/cert/CMakeLists.txt
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.cpp
  clang-tools-extra/clang-tidy/cert/DefaultOperatorNewAlignmentCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cert-mem57-cpp.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp
  clang-tools-extra/test/clang-tidy/cert-mem57-cpp.cpp

Index: clang-tools-extra/test/clang-tidy/cert-mem57-cpp.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cert-mem57-cpp.cpp
@@ -0,0 +1,39 @@
+// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
+
+namespace std {
+typedef __typeof(sizeof(int)) size_t;
+void *aligned_alloc(size_t, size_t);
+void free(void *);
+} // namespace std
+
+struct alignas(32) Vector1 {
+  char elems[32];
+};
+
+struct Vector2 {
+  char elems[32];
+};
+
+struct alignas(32) Vector3 {
+  char elems[32];
+  static void *operator new(std::size_t nbytes) noexcept(true) {
+return std::aligned_alloc(alignof(Vector3), nbytes);
+  }
+  static void operator delete(void *p) {
+std::free(p);
+  }
+};
+
+struct alignas(8) Vector4 {
+  char elems[32];
+};
+
+void f() {
+  auto *V1 = new Vector1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+  auto *V2 = new Vector2;
+  auto *V3 = new Vector3;
+  auto *V4 = new Vector4;
+  auto *V1_Arr = new Vector1[2];
+  // CHECK-MESSAGES: :[[@LINE-1]]:18: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+}
Index: clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cert-mem57-cpp-cpp17.cpp
@@ -0,0 +1,12 @@
+// RUN: %check_clang_tidy %s -std=c++14 cert-mem57-cpp %t
+// RUN: clang-tidy --extra-arg='-std=c++17' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
+// RUN: clang-tidy --extra-arg='-std=c++2a' -checks='-*,cert-mem57-cpp' --warnings-as-errors='*' %s
+
+struct alignas(32) Vector {
+  char Elems[32];
+};
+
+void f() {
+  auto *V1 = new Vector;// CHECK-MESSAGES: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+  auto *V1_Arr = new Vector[2]; // CHECK-MESSAGES: warning: allocation function returns a pointer with alignment 16 but the over-aligned type being allocated requires alignment 32 [cert-mem57-cpp]
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -98,6 +98,7 @@
cert-err61-cpp (redirects to misc-throw-by-value-catch-by-reference) 
cert-fio38-c (redirects to misc-non-copyable-objects) 
cert-flp30-c
+   cert-mem57-cpp
cert-msc30-c (redirects to cert-msc50-cpp) 
cert-msc32-c (redirects to cert-msc51-cpp) 
cert-msc50-cpp
Index: clang-tools-extra/docs/clang-tidy/checks/cert-mem57-cpp.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/cert-mem57-cpp.rst
@@ -0,0 +1,16 @@
+.. title:: clang-tidy - cert-mem57-cpp
+
+cert-mem57-cpp
+==
+
+This check flags uses of default ``operator new`` where the type has extended
+alignment (an alignment greater than the fundamental alignment). (The default
+``operator new`` is guaranteed to provide the correct alignmment if the
+requested alignment is less or equal to the fundamental alignment).
+Only cases are detected (by design) where the ``operator new`` is not
+user-defined and is not a placement new (the reason is that in these cases we
+assume that the user provided the correct memory allocation).
+
+This check corresponds to the CERT C++ Coding Standard rule
+`MEM57-CPP. Avoid using default operator new for over-aligned types
+`_.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -73,6 +73,12 @@
   Finds instances where variables with static storage are initializ

r375245 - [tooling] Relax an assert when multiple GPU targets are specified.

2019-10-18 Thread Michael Liao via cfe-commits
Author: hliao
Date: Fri Oct 18 08:03:34 2019
New Revision: 375245

URL: http://llvm.org/viewvc/llvm-project?rev=375245&view=rev
Log:
[tooling] Relax an assert when multiple GPU targets are specified.

Modified:
cfe/trunk/lib/Tooling/Tooling.cpp

Modified: cfe/trunk/lib/Tooling/Tooling.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Tooling.cpp?rev=375245&r1=375244&r2=375245&view=diff
==
--- cfe/trunk/lib/Tooling/Tooling.cpp (original)
+++ cfe/trunk/lib/Tooling/Tooling.cpp Fri Oct 18 08:03:34 2019
@@ -105,7 +105,7 @@ static const llvm::opt::ArgStringList *g
 // tooling will consider host-compilation only. For tooling on device
 // compilation, device compilation only option, such as
 // `--cuda-device-only`, needs specifying.
-assert(Actions.size() == 2);
+assert(Actions.size() > 1);
 assert(
 isa(Actions.front()) ||
 // On MacOSX real actions may end up being wrapped in


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


[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-10-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added subscribers: jkorous, benlangmuir.
dexonsmith added inline comments.



Comment at: unittests/AST/NamedDeclPrinterTest.cpp:220
+"property",
+"Obj::property"));
+}

gribozavr wrote:
> I don't think that `Obj::property` is the preferred syntax. `Obj.property`? 
> I'd want a review from someone from Apple to confirm.
@arphaman, @jkorous, or @benlangmuir: can you check on this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D68340: Add AIX toolchain and basic linker functionality

2019-10-18 Thread Steven Wan via Phabricator via cfe-commits
stevewan updated this revision to Diff 225631.
stevewan marked 25 inline comments as done.
stevewan added reviewers: jasonliu, Xiangling_L.
stevewan added a comment.

Fix periods at the end of comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68340

Files:
  clang/lib/Driver/CMakeLists.txt
  clang/lib/Driver/Driver.cpp
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/AIX.h
  clang/test/Driver/Inputs/aix_ppc_tree/powerpc-ibm-aix7.1.0.0/dummy.a
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crt0_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crti.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/crti_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/gcrt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/gcrt0_64.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/mcrt0.o
  clang/test/Driver/Inputs/aix_ppc_tree/usr/lib/mcrt0_64.o
  clang/test/Driver/aix-ld.c

Index: clang/test/Driver/aix-ld.c
===
--- /dev/null
+++ clang/test/Driver/aix-ld.c
@@ -0,0 +1,177 @@
+// General tests that ld invocations on AIX targets are sane. Note that we use
+// sysroot to make these tests independent of the host system.
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32 %s
+// CHECK-LD32-NOT: warning:
+// CHECK-LD32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-NOT: "-bnso"
+// CHECK-LD32: "-b32" 
+// CHECK-LD32: "-bpT:0x1000" "-bpD:0x2000" 
+// CHECK-LD32: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32: "-L[[SYSROOT]]/usr/lib" 
+// CHECK-LD32: "-lc"
+
+// Check powerpc64-ibm-aix7.1.0.0, 64-bit.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD64 %s
+// CHECK-LD64-NOT: warning:
+// CHECK-LD64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD64-NOT: "-bnso"
+// CHECK-LD64: "-b64" 
+// CHECK-LD64: "-bpT:0x1" "-bpD:0x11000" 
+// CHECK-LD64: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64: "-L[[SYSROOT]]/usr/lib" 
+// CHECK-LD64: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable POSIX thread support.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -pthread \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-PTHREAD %s
+// CHECK-LD32-PTHREAD-NOT: warning:
+// CHECK-LD32-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-PTHREAD: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-PTHREAD-NOT: "-bnso"
+// CHECK-LD32-PTHREAD: "-b32" 
+// CHECK-LD32-PTHREAD: "-bpT:0x1000" "-bpD:0x2000" 
+// CHECK-LD32-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0.o"
+// CHECK-LD32-PTHREAD: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD32-PTHREAD: "-lpthreads"
+// CHECK-LD32-PTHREAD: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 64-bit. POSIX thread alias.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -pthreads \
+// RUN: -target powerpc64-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD64-PTHREAD %s
+// CHECK-LD64-PTHREAD-NOT: warning:
+// CHECK-LD64-PTHREAD: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc64-ibm-aix7.1.0.0"
+// CHECK-LD64-PTHREAD: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD64-PTHREAD: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD64-PTHREAD-NOT: "-bnso"
+// CHECK-LD64-PTHREAD: "-b64" 
+// CHECK-LD64-PTHREAD: "-bpT:0x1" "-bpD:0x11000" 
+// CHECK-LD64-PTHREAD: "[[SYSROOT]]/usr/lib{{/|}}crt0_64.o"
+// CHECK-LD64-PTHREAD: "-L[[SYSROOT]]/usr/lib"
+// CHECK-LD64-PTHREAD: "-lpthreads"
+// CHECK-LD64-PTHREAD: "-lc"
+
+// Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable profiling.
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -p \
+// RUN: -target powerpc-ibm-aix7.1.0.0 \
+// RUN: --sysroot %S/Inputs/aix_ppc_tree \
+// RUN:   | FileCheck --check-prefix=CHECK-LD32-PROF %s
+// CHECK-LD32-PROF-NOT: warning:
+// CHECK-LD32-PROF: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "powerpc-ibm-aix7.1.0.0"
+// CHECK-LD32-PROF: "-isysroot" "[[SYSROOT:[^"]+]]"
+// CHECK-LD32-PROF: "{{.*}}ld{{(.exe)?}}" 
+// CHECK-LD32-PROF-NOT: "-bn

r375247 - [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Krasimir Georgiev via cfe-commits
Author: krasimir
Date: Fri Oct 18 08:21:06 2019
New Revision: 375247

URL: http://llvm.org/viewvc/llvm-project?rev=375247&view=rev
Log:
[clang-format] fix regression recognizing casts in Obj-C calls

Summary:
r373922 added checks for a few tokens that, following an `)` make it
unlikely that the `)` is the closing paren of a cast expression. The
specific check for `tok::l_square` there introduced a regression for
casts of Obj-C calls, like:
```
(cast)[func arg]
```
From the tests added in r373922, I believe the `tok::l_square` case is added to
capture the case where a non-cast `)` is directly followed by an
attribute specifier, like:
```
int f(int x) [[noreturn]];
```

I've specialized the code to look for such attribute specifier instead
of `tok::l_square` in general. Also, I added a regression test and moved
the test cases added in r373922 to an already existing place documenting
other instances of historically misidentified casts.

Reviewers: MyDeveloperDay

Reviewed By: MyDeveloperDay

Subscribers: cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=375247&r1=375246&r2=375247&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Oct 18 08:21:06 2019
@@ -1607,8 +1607,9 @@ private:
 // Functions which end with decorations like volatile, noexcept are 
unlikely
 // to be casts.
 if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
-  tok::kw_throw, tok::l_square, tok::arrow,
-  Keywords.kw_override, Keywords.kw_final))
+  tok::kw_throw, tok::arrow, Keywords.kw_override,
+  Keywords.kw_final) ||
+isCpp11AttributeSpecifier(*Tok.Next))
   return false;
 
 // As Java has no function types, a "(" after the ")" likely means that 
this

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=375247&r1=375246&r2=375247&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Oct 18 08:21:06 2019
@@ -7541,6 +7541,8 @@ TEST_F(FormatTest, FormatsCasts) {
   verifyFormat("my_int a = (ns::my_int)-2;");
   verifyFormat("case (my_int)ONE:");
   verifyFormat("auto x = (X)this;");
+  // Casts in Obj-C style calls used to not be recognized as such.
+  verifyFormat("int a = [(type*)[((type*)val) arg] arg];", getGoogleStyle());
 
   // FIXME: single value wrapped with paren will be treated as cast.
   verifyFormat("void f(int i = (kValue)*kMask) {}");
@@ -7581,6 +7583,29 @@ TEST_F(FormatTest, FormatsCasts) {
   verifyFormat("int a = alignof(int *) + b;", getGoogleStyle());
   verifyFormat("bool b = f(g) && c;");
   verifyFormat("typedef void (*f)(int i) func;");
+  verifyFormat("void operator++(int) noexcept;");
+  verifyFormat("void operator++(int &) noexcept;");
+  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
+   "&) noexcept;");
+  verifyFormat(
+  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(foo &) noexcept;");
+  verifyFormat("void operator delete(foo) noexcept;");
+  verifyFormat("void operator delete(int) noexcept;");
+  verifyFormat("void operator delete(int &) noexcept;");
+  verifyFormat("void operator delete(int &) volatile noexcept;");
+  verifyFormat("void operator delete(int &) const");
+  verifyFormat("void operator delete(int &) = default");
+  verifyFormat("void operator delete(int &) = delete");
+  verifyFormat("void operator delete(int &) [[noreturn]]");
+  verifyFormat("void operator delete(int &) throw();");
+  verifyFormat("void operator delete(int &) throw(int);");
+  verifyFormat("auto operator delete(int &) -> int;");
+  verifyFormat("auto operator delete(int &) override");
+  verifyFormat("auto operator delete(int &) final");
 
   verifyFormat(" *foo = (a 
*)\n"
"bbb;");
@@ -14696,33 +14721,6 @@ TEST_F(FormatTest, AlternativeOperators)
   */
 }
 
-TEST_F(FormatTest, NotCastRPaen) {
-
-  verifyFormat("void operator++(int) noexcept;");
-  verifyFormat("void operator++(int &) noexcept;");
-  verifyFormat("void 

[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman created this revision.
Herald added subscribers: cfe-commits, jfb, mgorny.
Herald added a project: clang.

- Similar to that of `clang-fuzzer` itself but instead only targets Objective-C 
source files via cc1

- Also adds an example corpus directory containing some input for Objective-C


Repository:
  rC Clang

https://reviews.llvm.org/D69171

Files:
  tools/clang-fuzzer/CMakeLists.txt
  tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp
  tools/clang-fuzzer/Dockerfile
  tools/clang-fuzzer/README.txt
  tools/clang-fuzzer/corpus_examples/objc/BasicClass.m
  tools/clang-fuzzer/corpus_examples/objc/ClassCategory.m
  tools/clang-fuzzer/corpus_examples/objc/ClassExtension.m
  tools/clang-fuzzer/corpus_examples/objc/SharedInstance.m
  tools/clang-fuzzer/handle-objc/CMakeLists.txt
  tools/clang-fuzzer/handle-objc/handle_objc.cpp
  tools/clang-fuzzer/handle-objc/handle_objc.h

Index: tools/clang-fuzzer/handle-objc/handle_objc.h
===
--- /dev/null
+++ tools/clang-fuzzer/handle-objc/handle_objc.h
@@ -0,0 +1,24 @@
+//==-- handle_objc.h - Helper function for Clang fuzzers ---==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Defines HandleObjC for use by the Clang Objective-C fuzzers.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_CLANG_FUZZER_HANDLE_OBJC_HANDLEOBJC_H
+#define LLVM_CLANG_TOOLS_CLANG_FUZZER_HANDLE_OBJC_HANDLEOBJC_H
+
+#include 
+#include 
+
+namespace clang_fuzzer {
+void HandleObjC(const std::string &S,
+const std::vector &ExtraArgs);
+} // namespace clang_fuzzer
+
+#endif
Index: tools/clang-fuzzer/handle-objc/handle_objc.cpp
===
--- /dev/null
+++ tools/clang-fuzzer/handle-objc/handle_objc.cpp
@@ -0,0 +1,51 @@
+//==-- handle_objc.cpp - Helper function for Clang fuzzers -==//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// Implements HandleObjC for use by the Clang Objective-C fuzzers.
+//
+//===--===//
+
+#include "handle_objc.h"
+
+#include "clang/CodeGen/CodeGenAction.h"
+#include "clang/Frontend/CompilerInstance.h"
+#include "clang/Lex/PreprocessorOptions.h"
+#include "clang/Tooling/Tooling.h"
+#include "llvm/Option/Option.h"
+
+using namespace clang;
+
+void clang_fuzzer::HandleObjC(const std::string &S,
+  const std::vector &ExtraArgs) {
+  llvm::opt::ArgStringList CC1Args;
+  CC1Args.push_back("-cc1");
+  for (auto &A : ExtraArgs)
+CC1Args.push_back(A);
+  CC1Args.push_back("./test.m");
+
+  llvm::IntrusiveRefCntPtr Files(
+  new FileManager(FileSystemOptions()));
+  IgnoringDiagConsumer Diags;
+  IntrusiveRefCntPtr DiagOpts = new DiagnosticOptions();
+  DiagnosticsEngine Diagnostics(
+  IntrusiveRefCntPtr(new DiagnosticIDs()), &*DiagOpts,
+  &Diags, false);
+  std::unique_ptr Invocation(
+  tooling::newInvocation(&Diagnostics, CC1Args));
+  std::unique_ptr Input =
+  llvm::MemoryBuffer::getMemBuffer(S);
+  Invocation->getPreprocessorOpts().addRemappedFile("./test.m",
+Input.release());
+  std::unique_ptr action(
+  tooling::newFrontendActionFactory());
+  std::shared_ptr PCHContainerOps =
+  std::make_shared();
+  action->runInvocation(std::move(Invocation), Files.get(), PCHContainerOps,
+&Diags);
+}
+
Index: tools/clang-fuzzer/handle-objc/CMakeLists.txt
===
--- /dev/null
+++ tools/clang-fuzzer/handle-objc/CMakeLists.txt
@@ -0,0 +1,13 @@
+set(LLVM_LINK_COMPONENTS ${LLVM_TARGETS_TO_BUILD} Support)
+
+add_clang_library(clangHandleObjC
+  handle_objc.cpp
+
+  LINK_LIBS
+  clangBasic
+  clangCodeGen
+  clangFrontend
+  clangLex
+  clangSerialization
+  clangTooling
+  )
Index: tools/clang-fuzzer/corpus_examples/objc/SharedInstance.m
===
--- /dev/null
+++ tools/clang-fuzzer/corpus_examples/objc/SharedInstance.m
@@ -0,0 +1,34 @@
+@interface RootObject
++ (instancetype)alloc;
+
+- (instancetype)init;
+@end
+
+@interface BaseClass : RootObject
++ (instancetype)sharedInstance;
+
+- (instancetype)initWithFoo:(int)foo;
+@end
+
+static BaseClass *sharedInstance = (void *)0;
+static int counter = 0;
+
+@implementation BaseClass
++ (instance

[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGeff2a2ab2b51: [clang-format] fix regression recognizing 
casts in Obj-C calls (authored by krasimir).

Changed prior to commit:
  https://reviews.llvm.org/D69164?vs=225604&id=225635#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69164

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -7541,6 +7541,8 @@
   verifyFormat("my_int a = (ns::my_int)-2;");
   verifyFormat("case (my_int)ONE:");
   verifyFormat("auto x = (X)this;");
+  // Casts in Obj-C style calls used to not be recognized as such.
+  verifyFormat("int a = [(type*)[((type*)val) arg] arg];", getGoogleStyle());
 
   // FIXME: single value wrapped with paren will be treated as cast.
   verifyFormat("void f(int i = (kValue)*kMask) {}");
@@ -7581,6 +7583,29 @@
   verifyFormat("int a = alignof(int *) + b;", getGoogleStyle());
   verifyFormat("bool b = f(g) && c;");
   verifyFormat("typedef void (*f)(int i) func;");
+  verifyFormat("void operator++(int) noexcept;");
+  verifyFormat("void operator++(int &) noexcept;");
+  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
+   "&) noexcept;");
+  verifyFormat(
+  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(nothrow_t &) noexcept;");
+  verifyFormat("void operator delete(foo &) noexcept;");
+  verifyFormat("void operator delete(foo) noexcept;");
+  verifyFormat("void operator delete(int) noexcept;");
+  verifyFormat("void operator delete(int &) noexcept;");
+  verifyFormat("void operator delete(int &) volatile noexcept;");
+  verifyFormat("void operator delete(int &) const");
+  verifyFormat("void operator delete(int &) = default");
+  verifyFormat("void operator delete(int &) = delete");
+  verifyFormat("void operator delete(int &) [[noreturn]]");
+  verifyFormat("void operator delete(int &) throw();");
+  verifyFormat("void operator delete(int &) throw(int);");
+  verifyFormat("auto operator delete(int &) -> int;");
+  verifyFormat("auto operator delete(int &) override");
+  verifyFormat("auto operator delete(int &) final");
 
   verifyFormat(" *foo = (a 
*)\n"
"bbb;");
@@ -14696,33 +14721,6 @@
   */
 }
 
-TEST_F(FormatTest, NotCastRPaen) {
-
-  verifyFormat("void operator++(int) noexcept;");
-  verifyFormat("void operator++(int &) noexcept;");
-  verifyFormat("void operator delete(void *, std::size_t, const std::nothrow_t 
"
-   "&) noexcept;");
-  verifyFormat(
-  "void operator delete(std::size_t, const std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(const std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(std::nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(nothrow_t &) noexcept;");
-  verifyFormat("void operator delete(foo &) noexcept;");
-  verifyFormat("void operator delete(foo) noexcept;");
-  verifyFormat("void operator delete(int) noexcept;");
-  verifyFormat("void operator delete(int &) noexcept;");
-  verifyFormat("void operator delete(int &) volatile noexcept;");
-  verifyFormat("void operator delete(int &) const");
-  verifyFormat("void operator delete(int &) = default");
-  verifyFormat("void operator delete(int &) = delete");
-  verifyFormat("void operator delete(int &) [[noreturn]]");
-  verifyFormat("void operator delete(int &) throw();");
-  verifyFormat("void operator delete(int &) throw(int);");
-  verifyFormat("auto operator delete(int &) -> int;");
-  verifyFormat("auto operator delete(int &) override");
-  verifyFormat("auto operator delete(int &) final");
-}
-
 TEST_F(FormatTest, STLWhileNotDefineChed) {
   verifyFormat("#if defined(while)\n"
"#define while EMIT WARNING C4005\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1607,8 +1607,9 @@
 // Functions which end with decorations like volatile, noexcept are 
unlikely
 // to be casts.
 if (Tok.Next->isOneOf(tok::kw_noexcept, tok::kw_volatile, tok::kw_const,
-  tok::kw_throw, tok::l_square, tok::arrow,
-  Keywords.kw_override, Keywords.kw_final))
+  tok::kw_throw, tok::arrow, Keywords.kw_override,
+  Keywords.kw_fin

[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1714020 , @hsaito wrote:

> Personally, I like the intent. I don't foresee a clear (enough) path to get 
> there. This leads to hesitation of adding a new non-experimental pragma and 
> present it to programmers. If you call it experimental, it's easier for me to 
> swallow.


Is there anything more to do than mentioning as being it experimental in the 
(no-patch-available-yet) docs?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Rather than adding a new fuzzer binary, can we make the language an option?
The whole implementation seems almost identical down to handleobjc/handlecxx...


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


[PATCH] D56924: Special case ObjCPropertyDecl for printing

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman added inline comments.



Comment at: unittests/AST/NamedDeclPrinterTest.cpp:220
+"property",
+"Obj::property"));
+}

dexonsmith wrote:
> gribozavr wrote:
> > I don't think that `Obj::property` is the preferred syntax. `Obj.property`? 
> > I'd want a review from someone from Apple to confirm.
> @arphaman, @jkorous, or @benlangmuir: can you check on this?
For more context here: I'm seeing similar issues for Objective-C instance 
variables (they can be declared inside a class extension --> meaning the Decl 
has no name --> clangd fails with an assertion that the name shouldn't be 
empty).

It seems to me that for Objective-C we could do something like 
`Obj(Extension::property` or alternatively `Obj(Extension).property` and 
`Obj(class extension)->_instanceVar`, but I'm not sure about what relies upon 
this current behavior (if anything).


Repository:
  rC Clang

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

https://reviews.llvm.org/D56924



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


[PATCH] D69177: [clangd] Propogate FS into Tweak::Selection

2019-10-18 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: ilya-biryukov.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay.
Herald added a project: clang.
kadircet added a parent revision: D69165: [clangd] Store Index in 
Tweak::Selection.

Incoming define out-of-line code action needs to access files that
weren't touched during compilation of the translation unit. This patch passes FS
into Tweak::Selection to make files accessible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69177

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/refactor/Tweak.cpp
  clang-tools-extra/clangd/refactor/Tweak.h
  clang-tools-extra/clangd/unittests/TestTU.cpp
  clang-tools-extra/clangd/unittests/TestTU.h
  clang-tools-extra/clangd/unittests/TweakTesting.cpp

Index: clang-tools-extra/clangd/unittests/TweakTesting.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTesting.cpp
+++ clang-tools-extra/clangd/unittests/TweakTesting.cpp
@@ -72,7 +72,8 @@
   TU.Code = Input.code();
   TU.AdditionalFiles = std::move(ExtraFiles);
   ParsedAST AST = TU.build();
-  Tweak::Selection S(AST, Selection.first, Selection.second, Index);
+  auto FS = TU.getVFS();
+  Tweak::Selection S(AST, Selection.first, Selection.second, Index, FS.get());
   auto PrepareResult = prepareTweak(TweakID, S);
   if (PrepareResult)
 return true;
@@ -94,7 +95,9 @@
   TU.Code = Input.code();
   TU.ExtraArgs = ExtraArgs;
   ParsedAST AST = TU.build();
-  Tweak::Selection S(AST, Selection.first, Selection.second, Index);
+
+  auto FS = TU.getVFS();
+  Tweak::Selection S(AST, Selection.first, Selection.second, Index, FS.get());
 
   auto T = prepareTweak(TweakID, S);
   if (!T) {
Index: clang-tools-extra/clangd/unittests/TestTU.h
===
--- clang-tools-extra/clangd/unittests/TestTU.h
+++ clang-tools-extra/clangd/unittests/TestTU.h
@@ -20,7 +20,9 @@
 #include "ParsedAST.h"
 #include "Path.h"
 #include "index/Index.h"
+#include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/ADT/StringMap.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include "gtest/gtest.h"
 #include 
 #include 
@@ -67,6 +69,7 @@
   ParsedAST build() const;
   SymbolSlab headerSymbols() const;
   std::unique_ptr index() const;
+  llvm::IntrusiveRefCntPtr getVFS() const;
 };
 
 // Look up an index symbol by qualified name, which must be unique.
Index: clang-tools-extra/clangd/unittests/TestTU.cpp
===
--- clang-tools-extra/clangd/unittests/TestTU.cpp
+++ clang-tools-extra/clangd/unittests/TestTU.cpp
@@ -19,7 +19,7 @@
 namespace clang {
 namespace clangd {
 
-ParsedAST TestTU::build() const {
+llvm::IntrusiveRefCntPtr TestTU::getVFS() const {
   std::string FullFilename = testPath(Filename),
   FullHeaderName = testPath(HeaderFilename),
   ImportThunk = testPath("import_thunk.h");
@@ -32,6 +32,13 @@
   Files[FullFilename] = Code;
   Files[FullHeaderName] = HeaderCode;
   Files[ImportThunk] = ThunkContents;
+  return buildTestFS(Files);
+}
+
+ParsedAST TestTU::build() const {
+  std::string FullFilename = testPath(Filename),
+  FullHeaderName = testPath(HeaderFilename),
+  ImportThunk = testPath("import_thunk.h");
 
   std::vector Cmd = {"clang"};
   // FIXME: this shouldn't need to be conditional, but it breaks a
@@ -54,7 +61,7 @@
   Inputs.CompileCommand.CommandLine = {Cmd.begin(), Cmd.end()};
   Inputs.CompileCommand.Directory = testRoot();
   Inputs.Contents = Code;
-  Inputs.FS = buildTestFS(Files);
+  Inputs.FS = getVFS();
   Inputs.Opts = ParseOptions();
   Inputs.Opts.ClangTidyOpts.Checks = ClangTidyChecks;
   Inputs.Opts.ClangTidyOpts.WarningsAsErrors = ClangTidyWarningsAsErrors;
Index: clang-tools-extra/clangd/refactor/Tweak.h
===
--- clang-tools-extra/clangd/refactor/Tweak.h
+++ clang-tools-extra/clangd/refactor/Tweak.h
@@ -30,6 +30,7 @@
 #include "llvm/ADT/StringMap.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
+#include "llvm/Support/VirtualFileSystem.h"
 #include 
 
 namespace clang {
@@ -48,7 +49,7 @@
   /// Input to prepare and apply tweaks.
   struct Selection {
 Selection(ParsedAST &AST, unsigned RangeBegin, unsigned RangeEnd,
-  const SymbolIndex *Index);
+  const SymbolIndex *Index, llvm::vfs::FileSystem *FS);
 /// The text of the active document.
 llvm::StringRef Code;
 /// Parsed AST of the active file.
@@ -64,6 +65,9 @@
 SelectionTree ASTSelection;
 /// The Index being used by ClangdServer.
 const SymbolIndex *Index = nullptr;
+/// The FS to be used by actions that will need access to files that are not
+/// touched while building AST.
+llvm::vfs::FileSystem *FS = nullptr;
 // FIXME: provide a way to get sources an

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

2019-10-18 Thread Alina Sbirlea via cfe-commits
I only got a chance to look more into this now. I can reproduce it with
re-inserting the "static".

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

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

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


Thanks,
Alina


On Mon, Sep 30, 2019 at 4:30 AM David Chisnall 
wrote:

> Hi,
>
> Yes, I believe it does still reproduce (at least, with the most recent
> build that I tried).  We worked around the clang bug to make the test pass:
>
>
> https://github.com/gnustep/libobjc2/commit/eab35fce379eb6ab1423dbb6d7908cb782f13458#diff-7f1eea7fdb5c7c3bf21f08d1cfe98a19
>
> Reintroducing the 'static' on deallocCalled reduces the test case to
> unconditionally failing the assert immediately after the pop, and DCEs
> the rest of the code.
>
> David
>
> On 11/09/2019 01:17, Alina Sbirlea wrote:
> > Hi David,
> >
> > Does this still reproduce?
> > I'm seeing the load after the call to autoreleasePoolPop at ToT, but
> > perhaps I'm not using the proper flags?
> > I only checked out the github repo and did "clang
> > -fobjc-runtime=gnustep-2.0 -O3 -emit-llvm -S
> > libobjc2/Test/AssociatedObject.m" with a ToT clang.
> >
> > Thanks,
> > Alina
> >
> >
> > On Sun, Feb 24, 2019 at 9:56 AM Pete Cooper via llvm-commits
> > mailto:llvm-comm...@lists.llvm.org>>
> wrote:
> >
> > Hey David
> >
> > Thanks for letting me know, and analysing it this far!
> >
> > I also can't see anything wrong with the intrinsic.  Its just
> > defined as:
> >
> > def int_objc_autoreleasePoolPop : Intrinsic<[],
> > [llvm_ptr_ty]>;
> >
> >
> > which (I believe) means it has unmodelled side effects so it should
> > have been fine for your example.
> >
> > I'll try build the same file you did and see if I can reproduce.
> >
> > Cheers,
> > Pete
> >
> >> On Feb 24, 2019, at 7:48 AM, David Chisnall via Phabricator
> >> mailto:revi...@reviews.llvm.org>> wrote:
> >>
> >> theraven added a comment.
> >> Herald added a project: LLVM.
> >>
> >> After some bisection, it appears that this is the revision that
> >> introduced the regression in the GNUstep Objective-C runtime test
> >> suite that I reported on the list a few weeks ago.  In this is the
> >> test (compiled with `-fobjc-runtime=gnustep-2.0 -O3` and an ELF
> >> triple):
> >>
> >>
> https://github.com/gnustep/libobjc2/blob/master/Test/AssociatedObject.m
> >>
> >> After this change, Early CSE w/ MemorySSA is determining that the
> >> second load of `deallocCalled` is redundant.  The code goes from:
> >>
> >>%7 = load i1, i1* @deallocCalled, align 1
> >>br i1 %7, label %8, label %9
> >>
> >>  ; :8:  ; preds = %0
> >>call void @__assert(i8* getelementptr inbounds ([5 x i8], [5 x
> >> i8]* @__func__.main, i64 0, i64 0), i8* getelementptr inbounds
> >> ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26, i8*
> >> getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64
> >> 0)) #5
> >>unreachable
> >>
> >>  ; :9:  ; preds = %0
> >>call void @llvm.objc.autoreleasePoolPop(i8* %1)
> >>%10 = load i1, i1* @deallocCalled, align 1
> >>br i1 %10, label %12, label %11
> >>
> >>  ; :11: ; preds = %9
> >>call void @__assert(i8* getelementptr inbounds ([5 x i8], [5 x
> >> i8]* @__func__.main, i64 0, i64 0), i8* getelementptr inbounds
> >> ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 29, i8*
> >> getelementptr inbounds ([14 x i8], [14 x i8]* @.str.2, i64 0, i64
> >> 0)) #5
> >>unreachable
> >>
> >> to:
> >>
> >>%7 = load i1, i1* @deallocCalled, align 1
> >>br i1 %7, label %8, label %9
> >>
> >>  ; :8:  ; preds = %0
> >>call void @__assert(i8* getelementptr inbounds ([5 x i8], [5 x
> >> i8]* @__func__.main, i64 0, i64 0), i8* getelementptr inbounds
> >> ([27 x i8], [27 x i8]* @.str, i64 0, i64 0), i32 26, i8*
> >> getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64
> >> 0)) #5
> >>unreachable
> >>
> >>  ; :9:  ; preds = %0
> >>call void @llvm.objc.autoreleasePoolPop(i8* %1)
> >>br i1 %7, label %11, label %10
> >>
> >>  ; :10: ; preds = %9
> >>call void @__assert(i8* getelementptr inbounds ([5

r375224 - [ThinLTOCodeGenerator] Add support for index-based WPD

2019-10-18 Thread Eugene Leviant via cfe-commits
Author: evgeny777
Date: Fri Oct 18 04:58:21 2019
New Revision: 375224

URL: http://llvm.org/viewvc/llvm-project?rev=375224&view=rev
Log:
[ThinLTOCodeGenerator] Add support for index-based WPD

This is clang part of the patch. It adds -flto-unit flag for thin LTO
builds on Mac and PS4

Differential revision: https://reviews.llvm.org/D68950

Modified:
cfe/trunk/lib/Driver/ToolChains/Clang.cpp
cfe/trunk/test/Driver/lto-unit.c

Modified: cfe/trunk/lib/Driver/ToolChains/Clang.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Clang.cpp?rev=375224&r1=375223&r2=375224&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Clang.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Clang.cpp Fri Oct 18 04:58:21 2019
@@ -3631,13 +3631,7 @@ void Clang::ConstructJob(Compilation &C,
 
 if (D.isUsingLTO() && !isDeviceOffloadAction) {
   Args.AddLastArg(CmdArgs, options::OPT_flto, options::OPT_flto_EQ);
-
-  // The Darwin and PS4 linkers currently use the legacy LTO API, which
-  // does not support LTO unit features (CFI, whole program vtable opt)
-  // under ThinLTO.
-  if (!(RawTriple.isOSDarwin() || RawTriple.isPS4()) ||
-  D.getLTOMode() == LTOK_Full)
-CmdArgs.push_back("-flto-unit");
+  CmdArgs.push_back("-flto-unit");
 }
   }
 

Modified: cfe/trunk/test/Driver/lto-unit.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/lto-unit.c?rev=375224&r1=375223&r2=375224&view=diff
==
--- cfe/trunk/test/Driver/lto-unit.c (original)
+++ cfe/trunk/test/Driver/lto-unit.c Fri Oct 18 04:58:21 2019
@@ -1,9 +1,8 @@
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=full 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-unknown-linux -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=full 2>&1 | 
FileCheck --check-prefix=UNIT %s
-// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=NOUNIT %s
+// RUN: %clang -target x86_64-apple-darwin13.3.0 -### %s -flto=thin 2>&1 | 
FileCheck --check-prefix=UNIT %s
 // RUN: %clang -target x86_64-scei-ps4 -### %s -flto=full 2>&1 | FileCheck 
--check-prefix=UNIT %s
-// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin 2>&1 | FileCheck 
--check-prefix=NOUNIT %s
+// RUN: %clang -target x86_64-scei-ps4 -### %s -flto=thin 2>&1 | FileCheck 
--check-prefix=UNIT %s
 
 // UNIT: "-flto-unit"
-// NOUNIT-NOT: "-flto-unit"


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


[PATCH] D69179: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma created this revision.
Herald added subscribers: cfe-commits, modocache.
Herald added a project: clang.
jonathoma retitled this revision from "[Format] Add format check for throwing 
negative numbers" to "[Format] Add format check for coroutine keywords with 
negative numbers".
jonathoma edited the summary of this revision.
jonathoma abandoned this revision.

As a followup to D69144 , this diff fixes the 
coroutine keyword spacing
for `co_yield` / `co_return`ing negative numbers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69179

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1693,7 +1693,8 @@
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
tok::equal, tok::kw_delete, tok::kw_sizeof,
-   tok::kw_throw) ||
+   tok::kw_throw, tok::kw_co_return,
+   tok::kw_co_yield) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
TT_UnaryOperator, TT_CastRParen))
   return TT_UnaryOperator;
@@ -1756,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1693,7 +1693,8 @@
 if (PrevToken->isOneOf(tok::l_paren, tok::l_square, tok::l_brace,
tok::comma, tok::semi, tok::kw_return, tok::colon,
tok::equal, tok::kw_delete, tok::kw_sizeof,
-   tok::kw_throw) ||
+   tok::kw_throw, tok::kw_co_return,
+   tok::kw_co_yield) ||
 PrevToken->isOneOf(TT_BinaryOperator, TT_ConditionalExpr,
TT_UnaryOperator, TT_CastRParen))
   return TT_UnaryOperator;
@@ -1756,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69180: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma created this revision.
jonathoma added reviewers: modocache, sammccall, Quuxplusone.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
jonathoma planned changes to this revision.

As a followup to D69144 , this diff fixes the 
coroutine keyword spacing
for co_yield / co_returning negative numbers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69180

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r375257 - [DOCS]Update list of implemented constructs, NFC.

2019-10-18 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Fri Oct 18 09:53:54 2019
New Revision: 375257

URL: http://llvm.org/viewvc/llvm-project?rev=375257&view=rev
Log:
[DOCS]Update list of implemented constructs, NFC.

Modified:
cfe/trunk/docs/OpenMPSupport.rst

Modified: cfe/trunk/docs/OpenMPSupport.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/OpenMPSupport.rst?rev=375257&r1=375256&r2=375257&view=diff
==
--- cfe/trunk/docs/OpenMPSupport.rst (original)
+++ cfe/trunk/docs/OpenMPSupport.rst Fri Oct 18 09:53:54 2019
@@ -181,9 +181,9 @@ implementation.
 
+--+--+--+---+
 | task extension   | master taskloop   
   | :good:`done` | 
  |
 
+--+--+--+---+
-| task extension   | parallel master taskloop  
   | :none:`unclaimed`| 
  |
+| task extension   | parallel master taskloop  
   | :none:`done` | 
  |
 
+--+--+--+---+
-| task extension   | master taskloop simd  
   | :none:`unclaimed`| 
  |
+| task extension   | master taskloop simd  
   | :none:`done` | 
  |
 
+--+--+--+---+
 | task extension   | parallel master taskloop simd 
   | :none:`unclaimed`| 
  |
 
+--+--+--+---+


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


LLVM buildmaster will be updated and restarted

2019-10-18 Thread Galina Kistanova via cfe-commits
 Hello everyone,

LLVM buildmaster will be updated and restarted in an hour.

Thanks

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


r375258 - [Format] Add format check for throwing negative numbers

2019-10-18 Thread Brian Gesiak via cfe-commits
Author: modocache
Date: Fri Oct 18 09:59:02 2019
New Revision: 375258

URL: http://llvm.org/viewvc/llvm-project?rev=375258&view=rev
Log:
[Format] Add format check for throwing negative numbers

Summary:
The code `throw -1;` is currently formatted by clang-format as
`throw - 1;`. This diff adds a fix for this edge case and a test to check
for this in the future.

For context, I am looking into a related bug in the clang-formatting of
coroutine keywords: `co_yield -1;` is also reformatted in this manner
as `co_yield - 1;`. A later diff will add these changes and tests for the
`co_yield` and `co_return` keywords.

Patch by Jonathan Thomas (jonathoma)!

Reviewers: modocache, sammccall, Quuxplusone

Reviewed By: sammccall

Subscribers: cfe-commits

Tags: #clang-format, #clang

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTest.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=375258&r1=375257&r2=375258&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Oct 18 09:59:02 2019
@@ -1757,7 +1757,7 @@ private:
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=375258&r1=375257&r2=375258&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Oct 18 09:59:02 2019
@@ -6912,6 +6912,7 @@ TEST_F(FormatTest, UnderstandsUnaryOpera
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"


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


[PATCH] D69144: [Format] Add format check for throwing negative numbers

2019-10-18 Thread Brian Gesiak via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7f704320b058: [Format] Add format check for throwing 
negative numbers (authored by modocache).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69144

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,7 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

In D69171#1714624 , @sammccall wrote:

> Rather than adding a new fuzzer binary, can we make the language an option?
>  The whole implementation seems almost identical down to 
> handleobjc/handlecxx...


It's similar at the moment (was initially going to add more flags), but I could 
swap it over to read an integer/Boolean to swap between the two languages. If 
we want to modify them in the future (which we might be interested in depending 
on how well this works) it probably makes sense to keep them separate though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


[PATCH] D69181: [clang-tidy] Adding misc-signal-terminated-thread check

2019-10-18 Thread Kocsis Ábel via Phabricator via cfe-commits
abelkocsis created this revision.
abelkocsis added reviewers: aaron.ballman, alexfh, JonasToth, steakhal, 
Charusso.
abelkocsis added a project: clang-tools-extra.
Herald added subscribers: cfe-commits, mgehre, jfb, dexonsmith, steven_wu, 
hiraditya, xazax.hun, mgorny, mehdi_amini.
Herald added a reviewer: jfb.
Herald added a project: clang.

According to 
https://wiki.sei.cmu.edu/confluence/display/c/POS44-C.+Do+not+use+signals+to+terminate+threads
misc-signal-terminated-thread check is created. The check warn if 
`pthread_kill` function is called with `SIGTERM` signal.


Repository:
  rCTE Clang Tools Extra

https://reviews.llvm.org/D69181

Files:
  clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp
  clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.h
  clang-tools-extra/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst
  clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp

Index: clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s misc-bad-signal-to-kill-thread %t
+
+#define SIGTERM 15
+using pthread_t = int;
+using pthread_attr_t = int;
+
+int pthread_create(pthread_t *thread, const pthread_attr_t *attr,
+   void *(*start_routine)(void *), void *arg);
+
+int pthread_kill(pthread_t thread, int sig);
+
+int pthread_cancel(pthread_t thread);
+
+void *test_func_return_a_pointer(void *foo);
+
+int main() {
+  int result;
+  pthread_t thread;
+
+  if ((result = pthread_create(&thread, nullptr, test_func_return_a_pointer, 0)) != 0) {
+  }
+  if ((result = pthread_kill(thread, SIGTERM)) != 0) {
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: Thread should not be terminated by signal. [misc-bad-signal-to-kill-thread]
+  }
+
+  if ((result = pthread_cancel(thread)) != 0) {
+  }
+
+  return 0;
+}
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst
@@ -0,0 +1,10 @@
+.. title:: clang-tidy - misc-bad-signal-to-kill-thread
+
+misc-bad-signal-to-kill-thread
+==
+
+Warn on uses of the ``pthread_kill`` function when thread is 
+terminated by ``SIGTERM`` signal.
+.. code-block: c++
+
+pthread_kill(thread, SIGTERM);
\ No newline at end of file
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -282,6 +282,7 @@
llvm-prefer-isa-or-dyn-cast-in-conditionals
llvm-prefer-register-over-unsigned
llvm-twine-local
+   misc-bad-signal-to-kill-thread
misc-definitions-in-headers
misc-misplaced-const
misc-new-delete-overloads
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -73,6 +73,13 @@
   Finds instances where variables with static storage are initialized
   dynamically in header files.
 
+- New :doc:`misc-signal-terminated-thread
+  ` check.
+
+  Do not send an uncaught signal to kill a thread because the signal kills the entire process, not just the individual thread. 
+  To learn more about this rule please visit the following page:
+  https://wiki.sei.cmu.edu/confluence/display/c/POS44-C.+Do+not+use+signals+to+terminate+threads
+
 - New :doc:`bugprone-infinite-loop
   ` check.
 
Index: clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tools-extra/clang-tidy/misc/MiscTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "BadSignalToKillThreadCheck.h"
 #include "DefinitionsInHeadersCheck.h"
 #include "MisplacedConstCheck.h"
 #include "NewDeleteOverloadsCheck.h"
@@ -30,6 +31,8 @@
 class MiscModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"misc-bad-signal-to-kill-thread");
 CheckFactories.registerCheck(
 "misc-definitions-in-headers");
 CheckFactories.registerCheck("misc-misplaced-const");
Index: clang-tools-extra/clang-tidy/misc/CMakeLists.txt
==

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

2019-10-18 Thread Melanie Blower via Phabricator via cfe-commits
mibintc added a comment.

Ping.  Hoping for code review so I can move this forward.  Affirmative or 
negative, please let me know.  Thank you! --Melanie


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


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

2019-10-18 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: gribozavr.
Herald added a project: clang.

This revision generalizes the (deprecated) `clang::tooling::text` combinator to
a `value` combinator, which works for any type. Aside from being more general,
it resolves the naming confict between `clang::tooling::text` and
`clang::transformer::text`, which has a subtly different meaning.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69184

Files:
  clang/include/clang/Tooling/Transformer/MatchConsumer.h
  clang/unittests/Tooling/TransformerTest.cpp

Index: clang/unittests/Tooling/TransformerTest.cpp
===
--- clang/unittests/Tooling/TransformerTest.cpp
+++ clang/unittests/Tooling/TransformerTest.cpp
@@ -21,6 +21,7 @@
 namespace {
 using ::testing::IsEmpty;
 using transformer::RewriteRule;
+using transformer::value;
 
 constexpr char KHeaderContents[] = R"cc(
   struct string {
@@ -147,7 +148,8 @@
   on(expr(hasType(isOrPointsTo(StringType)))
  .bind(StringExpr)),
   callee(cxxMethodDecl(hasName("c_str")),
-  change(text("REPLACED")), text("Use size() method directly on string."));
+  change(value("REPLACED")),
+  value("Use size() method directly on string."));
   return R;
 }
 
@@ -171,7 +173,7 @@
 hasName("proto::ProtoCommandLineFlag"
.bind(Flag)),
 unless(callee(cxxMethodDecl(hasName("GetProto"),
-  change(node(Flag), text("EXPR")));
+  change(node(Flag), value("EXPR")));
 
   std::string Input = R"cc(
 proto::ProtoCommandLineFlag flag;
@@ -189,7 +191,7 @@
 
 TEST_F(TransformerTest, AddIncludeQuoted) {
   RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f",
-  change(text("other()")));
+  change(value("other()")));
   addInclude(Rule, "clang/OtherLib.h");
 
   std::string Input = R"cc(
@@ -207,7 +209,7 @@
 
 TEST_F(TransformerTest, AddIncludeAngled) {
   RewriteRule Rule = makeRule(callExpr(callee(functionDecl(hasName("f",
-  change(text("other()")));
+  change(value("other()")));
   addInclude(Rule, "clang/OtherLib.h", transformer::IncludeFormat::Angled);
 
   std::string Input = R"cc(
@@ -226,7 +228,7 @@
 TEST_F(TransformerTest, NodePartNameNamedDecl) {
   StringRef Fun = "fun";
   RewriteRule Rule = makeRule(functionDecl(hasName("bad")).bind(Fun),
-  change(name(Fun), text("good")));
+  change(name(Fun), value("good")));
 
   std::string Input = R"cc(
 int bad(int x);
@@ -258,7 +260,7 @@
 
   StringRef Ref = "ref";
   testRule(makeRule(declRefExpr(to(functionDecl(hasName("bad".bind(Ref),
-change(name(Ref), text("good"))),
+change(name(Ref), value("good"))),
Input, Expected);
 }
 
@@ -276,7 +278,7 @@
 
   StringRef Ref = "ref";
   Transformer T(makeRule(declRefExpr(to(functionDecl())).bind(Ref),
- change(name(Ref), text("good"))),
+ change(name(Ref), value("good"))),
 consumer());
   T.registerMatchers(&MatchFinder);
   EXPECT_FALSE(rewrite(Input));
@@ -285,7 +287,7 @@
 TEST_F(TransformerTest, NodePartMember) {
   StringRef E = "expr";
   RewriteRule Rule = makeRule(memberExpr(member(hasName("bad"))).bind(E),
-  change(member(E), text("good")));
+  change(member(E), value("good")));
 
   std::string Input = R"cc(
 struct S {
@@ -338,7 +340,7 @@
   )cc";
 
   StringRef E = "expr";
-  testRule(makeRule(memberExpr().bind(E), change(member(E), text("good"))),
+  testRule(makeRule(memberExpr().bind(E), change(member(E), value("good"))),
Input, Expected);
 }
 
@@ -370,7 +372,7 @@
 
   StringRef MemExpr = "member";
   testRule(makeRule(memberExpr().bind(MemExpr),
-change(member(MemExpr), text("good"))),
+change(member(MemExpr), value("good"))),
Input, Expected);
 }
 
@@ -389,7 +391,7 @@
 
   StringRef Ret = "return";
   testRule(makeRule(returnStmt().bind(Ret),
-insertBefore(statement(Ret), text("int y = 3;"))),
+insertBefore(statement(Ret), value("int y = 3;"))),
Input, Expected);
 }
 
@@ -410,7 +412,7 @@
 
   StringRef Decl = "decl";
   testRule(makeRule(declStmt().bind(Decl),
-insertAfter(statement(Decl), text("int y = 3;"))),
+insertAfter(statement(Decl), value("int y = 3;"))),
Input, Expected);
 }
 
@@ -451,9 +453,9 @@
   StringRef C = "C", T = "T", E = "E";
   testRule(makeRule(ifStmt(hasCondition(expr().bind(C)),
hasThen(stmt().bi

[PATCH] D69186: Refactor DependencyScanningTool to its own file

2019-10-18 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk updated this revision to Diff 225667.
kousikk added a comment.

Lint fixes


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69186

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/lib/Tooling/DependencyScanning/CMakeLists.txt
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -10,6 +10,7 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Options.h"
@@ -38,101 +39,6 @@
   raw_ostream &OS;
 };
 
-/// The high-level implementation of the dependency discovery tool that runs on
-/// an individual worker thread.
-class DependencyScanningTool {
-public:
-  /// Construct a dependency scanning tool.
-  ///
-  /// \param Compilations The reference to the compilation database that's
-  /// used by the clang tool.
-  DependencyScanningTool(DependencyScanningService &Service,
- const tooling::CompilationDatabase &Compilations,
- SharedStream &OS, SharedStream &Errs)
-  : Worker(Service), Compilations(Compilations), OS(OS), Errs(Errs) {}
-
-  /// Print out the dependency information into a string using the dependency
-  /// file format that is specified in the options (-MD is the default) and
-  /// return it.
-  ///
-  /// \returns A \c StringError with the diagnostic output if clang errors
-  /// occurred, dependency file contents otherwise.
-  llvm::Expected getDependencyFile(const std::string &Input,
-StringRef CWD) {
-/// Prints out all of the gathered dependencies into a string.
-class DependencyPrinterConsumer : public DependencyConsumer {
-public:
-  void handleFileDependency(const DependencyOutputOptions &Opts,
-StringRef File) override {
-if (!this->Opts)
-  this->Opts = std::make_unique(Opts);
-Dependencies.push_back(File);
-  }
-
-  void printDependencies(std::string &S) {
-if (!Opts)
-  return;
-
-class DependencyPrinter : public DependencyFileGenerator {
-public:
-  DependencyPrinter(DependencyOutputOptions &Opts,
-ArrayRef Dependencies)
-  : DependencyFileGenerator(Opts) {
-for (const auto &Dep : Dependencies)
-  addDependency(Dep);
-  }
-
-  void printDependencies(std::string &S) {
-llvm::raw_string_ostream OS(S);
-outputDependencyFile(OS);
-  }
-};
-
-DependencyPrinter Generator(*Opts, Dependencies);
-Generator.printDependencies(S);
-  }
-
-private:
-  std::unique_ptr Opts;
-  std::vector Dependencies;
-};
-
-DependencyPrinterConsumer Consumer;
-auto Result =
-Worker.computeDependencies(Input, CWD, Compilations, Consumer);
-if (Result)
-  return std::move(Result);
-std::string Output;
-Consumer.printDependencies(Output);
-return Output;
-  }
-
-  /// Computes the dependencies for the given file and prints them out.
-  ///
-  /// \returns True on error.
-  bool runOnFile(const std::string &Input, StringRef CWD) {
-auto MaybeFile = getDependencyFile(Input, CWD);
-if (!MaybeFile) {
-  llvm::handleAllErrors(
-  MaybeFile.takeError(), [this, &Input](llvm::StringError &Err) {
-Errs.applyLocked([&](raw_ostream &OS) {
-  OS << "Error while scanning dependencies for " << Input << ":\n";
-  OS << Err.getMessage();
-});
-  });
-  return true;
-}
-OS.applyLocked([&](raw_ostream &OS) { OS << *MaybeFile; });
-return false;
-  }
-
-private:
-  DependencyScanningWorker Worker;
-  const tooling::CompilationDatabase &Compilations;
-  SharedStream &OS;
-  SharedStream &Errs;
-};
-
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -191,6 +97,28 @@
   return ObjFileName.str();
 }
 
+/// Takes the result of a dependency scan and prints error / dependency files
+/// based on the result.
+///
+/// \returns True on error.
+static bool handleDependencyToolResult(const std::string &Input,
+  llvm::Expected &MaybeFile,
+  SharedStream &OS,
+  Shar

[PATCH] D69186: Refactor DependencyScanningTool to its own file

2019-10-18 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk created this revision.
kousikk added reviewers: arphaman, jkorous, Bigcheese, dexonsmith.
Herald added subscribers: cfe-commits, mgorny.
Herald added a project: clang.
kousikk updated this revision to Diff 225667.
kousikk added a comment.

Lint fixes


There's no behavior change - just moving DependencyScanningTool to its own file 
since this tool can be reused across both clang-scan-deps binary and an 
interface
exposed as part of libClang APIs.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D69186

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningTool.h
  clang/lib/Tooling/DependencyScanning/CMakeLists.txt
  clang/lib/Tooling/DependencyScanning/DependencyScanningTool.cpp
  clang/tools/clang-scan-deps/ClangScanDeps.cpp

Index: clang/tools/clang-scan-deps/ClangScanDeps.cpp
===
--- clang/tools/clang-scan-deps/ClangScanDeps.cpp
+++ clang/tools/clang-scan-deps/ClangScanDeps.cpp
@@ -10,6 +10,7 @@
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningService.h"
 #include "clang/Tooling/DependencyScanning/DependencyScanningWorker.h"
+#include "clang/Tooling/DependencyScanning/DependencyScanningTool.h"
 #include "clang/Tooling/JSONCompilationDatabase.h"
 #include "llvm/Support/InitLLVM.h"
 #include "llvm/Support/Options.h"
@@ -38,101 +39,6 @@
   raw_ostream &OS;
 };
 
-/// The high-level implementation of the dependency discovery tool that runs on
-/// an individual worker thread.
-class DependencyScanningTool {
-public:
-  /// Construct a dependency scanning tool.
-  ///
-  /// \param Compilations The reference to the compilation database that's
-  /// used by the clang tool.
-  DependencyScanningTool(DependencyScanningService &Service,
- const tooling::CompilationDatabase &Compilations,
- SharedStream &OS, SharedStream &Errs)
-  : Worker(Service), Compilations(Compilations), OS(OS), Errs(Errs) {}
-
-  /// Print out the dependency information into a string using the dependency
-  /// file format that is specified in the options (-MD is the default) and
-  /// return it.
-  ///
-  /// \returns A \c StringError with the diagnostic output if clang errors
-  /// occurred, dependency file contents otherwise.
-  llvm::Expected getDependencyFile(const std::string &Input,
-StringRef CWD) {
-/// Prints out all of the gathered dependencies into a string.
-class DependencyPrinterConsumer : public DependencyConsumer {
-public:
-  void handleFileDependency(const DependencyOutputOptions &Opts,
-StringRef File) override {
-if (!this->Opts)
-  this->Opts = std::make_unique(Opts);
-Dependencies.push_back(File);
-  }
-
-  void printDependencies(std::string &S) {
-if (!Opts)
-  return;
-
-class DependencyPrinter : public DependencyFileGenerator {
-public:
-  DependencyPrinter(DependencyOutputOptions &Opts,
-ArrayRef Dependencies)
-  : DependencyFileGenerator(Opts) {
-for (const auto &Dep : Dependencies)
-  addDependency(Dep);
-  }
-
-  void printDependencies(std::string &S) {
-llvm::raw_string_ostream OS(S);
-outputDependencyFile(OS);
-  }
-};
-
-DependencyPrinter Generator(*Opts, Dependencies);
-Generator.printDependencies(S);
-  }
-
-private:
-  std::unique_ptr Opts;
-  std::vector Dependencies;
-};
-
-DependencyPrinterConsumer Consumer;
-auto Result =
-Worker.computeDependencies(Input, CWD, Compilations, Consumer);
-if (Result)
-  return std::move(Result);
-std::string Output;
-Consumer.printDependencies(Output);
-return Output;
-  }
-
-  /// Computes the dependencies for the given file and prints them out.
-  ///
-  /// \returns True on error.
-  bool runOnFile(const std::string &Input, StringRef CWD) {
-auto MaybeFile = getDependencyFile(Input, CWD);
-if (!MaybeFile) {
-  llvm::handleAllErrors(
-  MaybeFile.takeError(), [this, &Input](llvm::StringError &Err) {
-Errs.applyLocked([&](raw_ostream &OS) {
-  OS << "Error while scanning dependencies for " << Input << ":\n";
-  OS << Err.getMessage();
-});
-  });
-  return true;
-}
-OS.applyLocked([&](raw_ostream &OS) { OS << *MaybeFile; });
-return false;
-  }
-
-private:
-  DependencyScanningWorker Worker;
-  const tooling::CompilationDatabase &Compilations;
-  SharedStream &OS;
-  SharedStream &Errs;
-};
-
 llvm::cl::opt Help("h", llvm::cl::desc("Alias for -help"),
  llvm::cl::Hidden);
 
@@ -191,6 +97,28 @@
   return ObjFileName.str();
 }
 
+/// Takes the result of a dependency scan and pr

[PATCH] D69180: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma updated this revision to Diff 225672.
jonathoma added a comment.

Rebase properly


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69180

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6926,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6926,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1757,7 +1757,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69180: [Format] Add format check for coroutine keywords with negative numbers

2019-10-18 Thread Jonathan Thomas via Phabricator via cfe-commits
jonathoma updated this revision to Diff 225671.
jonathoma added a comment.

Rebase onto master


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69180

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -6912,6 +6912,7 @@
   verifyFormat("alignof(char);", getGoogleStyle());
 
   verifyFormat("return -1;");
+  verifyFormat("throw -1;");
   verifyFormat("switch (a) {\n"
"case -1:\n"
"  break;\n"
@@ -6925,6 +6926,9 @@
   verifyFormat("int a = /* confusing comment */ -1;");
   // FIXME: The space after 'i' is wrong, but hopefully, this is a rare case.
   verifyFormat("int a = i /* confusing comment */++;");
+
+  verifyFormat("co_yield -1;");
+  verifyFormat("co_return -1;");
 }
 
 TEST_F(FormatTest, DoesNotIndentRelativeToUnaryOperators) {
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -1756,7 +1756,8 @@
 // Use heuristics to recognize unary operators.
 if (PrevToken->isOneOf(tok::equal, tok::l_paren, tok::comma, tok::l_square,
tok::question, tok::colon, tok::kw_return,
-   tok::kw_case, tok::at, tok::l_brace))
+   tok::kw_case, tok::at, tok::l_brace, tok::kw_throw,
+   tok::kw_co_return, tok_kw_co_yield))
   return TT_UnaryOperator;
 
 // There can't be two consecutive binary operators.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2019-10-18 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: clang/docs/UsersManual.rst:1318
+   mode informs the compiler that it must not assume any particular
+   rounding mode.
+

rjmccall wrote:
> "represent *the* corresponding IEEE rounding rules"
A few points about this documentation that occurred to me since the last time I 
looked at it:

- It's weird to talk about LLVM here, since this is the Clang documentation.  
Clang's behavior is not specified in terms of the IR it generates; it's 
specified in terms of the formal behavior of the source code.  Therefore this 
documentation should talk about things using concepts from an appropriate 
language standard whenever possible; in this case, C99 works.

- It's weird to bring up all these different rounding modes when this option 
doesn't actually let you do anything with them.  If you want to talk about 
rounding modes in general that's fine as a way of informing the programmer, but 
we shouldn't give them information they can't use.

- I don't think `-fno-rounding-math` is actually equivalent to forcing the use 
of the `tonearest` rounding mode; I think it *assumes* that the rounding mode 
is set to `tonearest`.  (Or am I wrong and this is actually guaranteed by ABI?)

- I don't think we want to *define* `-frounding-math` as exactly equivalent to 
`-ffp-model=strict`.  That might be a convenient implementation for now, but it 
seems to me that `-frounding-math` still allows some optimizations that 
`-ffp-model=strict` wouldn't.

With that in mind, I'd suggest something like this:

> Force floating-point operations to honor the dynamically-set rounding mode by 
> default.
>
> The result of a floating-point operation often cannot be exactly represented 
> in the result type and therefore must be rounded.  IEEE 754 describes 
> different rounding modes that control how to perform this rounding, not all 
> of which are supported by all implementations.  C provides interfaces 
> (``fesetround`` and ``fesetenv``) for dynamically controlling the rounding 
> mode, and while it also recommends certain conventions for changing the 
> rounding mode, these conventions are not typically enforced in the ABI.  
> Since the rounding mode changes the numerical result of operations, the 
> compiler must understand something about it in order to optimize floating 
> point operations.
>
> Note that floating-point operations performed as part of constant 
> initialization are formally performed prior to the start of the program and 
> are therefore not subject to the current rounding mode.  This includes the 
> initialization of global variables and local ``static`` variables.  
> Floating-point operations in these contexts will be rounded using 
> ``FE_TONEAREST``.
>
> - The option ``-fno-rounding-math`` allows the compiler to assume that the 
> rounding mode is set to ``FE_TONEAREST``.  This is the default.
> - The option ``-frounding-math`` forces the compiler to honor the 
> dynamically-set rounding mode.  This prevents optimizations which might 
> affect results if the rounding mode changes or is different from the default; 
> for example, it prevents floating-point operations from being reordered 
> across most calls and prevents constant-folding when the result is not 
> exactly representable.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D62731



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


[PATCH] D69164: [clang-format] fix regression recognizing casts in Obj-C calls

2019-10-18 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir marked an inline comment as done.
krasimir added inline comments.



Comment at: lib/Format/TokenAnnotator.cpp:1612
+  Keywords.kw_final) ||
+isCpp11AttributeSpecifier(*Tok.Next))
   return false;

rdwampler wrote:
> I think the issue r373922 was fixing is only related to the `delete`. Can 
> this check be move further up where we explicitly check if the token is the 
> delete keyword? 
> 
Sorry, I didn't notice this comment until now. I can investigate whether all 
the other cases for non-delete methods are already covered, it would be 
interesting. + @MyDeveloperDay, who might have better insights into this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69164



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


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread David Goldman via Phabricator via cfe-commits
dgoldman added a comment.

Not sure who is best to review, feel free to add someone else instead.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


[PATCH] D69181: [clang-tidy] Adding misc-signal-terminated-thread check

2019-10-18 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:28
+
+namespace {
+static Preprocessor *PP;

static is enough, no need for anonymous namespace.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:33
+void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) 
{
+
+  Preprocessor::macro_iterator It = PP->macro_begin();

Unnecessary empty line.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:37
+if (It->first->getName() == "SIGTERM") {
+  const auto *MI = PP->getMacroInfo(It->first);
+  const auto &T = MI->tokens().back();

Please don't use auto unless type is spelled in same statement or iterator.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.cpp:67
+} // namespace clang
\ No newline at end of file


Please add new line.



Comment at: clang-tools-extra/clang-tidy/misc/BadSignalToKillThreadCheck.h:40
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_BADSIGNALTOKILLTHREADCHECK_H
\ No newline at end of file


Please add new line.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:76
 
+- New :doc:`misc-signal-terminated-thread
+  ` check.

Please keep alphabetical order in new checks list.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:79
+
+  Do not send an uncaught signal to kill a thread because the signal kills the 
entire process, not just the individual thread. 
+  To learn more about this rule please visit the following page:

Please synchronize with first sentence in documentation. Link belongs to 
documentation.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst:8
+terminated by ``SIGTERM`` signal.
+.. code-block: c++
+

Please separate with empty line.



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/misc-bad-signal-to-kill-thread.rst:11
+pthread_kill(thread, SIGTERM);
\ No newline at end of file


Please add new line.



Comment at: 
clang-tools-extra/test/clang-tidy/misc-bad-signal-to-kill-thread.cpp:31
+}
\ No newline at end of file


Please add new line.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D69181



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1713623 , @hsaito wrote:

> @Meinersbur, if I remember correctly, there was an RFC discussion on this 
> topic, right? If yes, would you post the pointer to that? I need a refresher 
> on what has been discussed/settled in the past.


My publications on this topic would also be useful here, available on arXiv. 
Here is an overview, also including previous discussions:

Loop optimization directives:

- A Proposal for Loop-Transformation Pragmas  
(IWOMP'19)
- User-Directed Loop-Transformations in Clang 
 (LLVM-HPC'18)
- Design and Use of Loop-Transformation Pragmas 
 (IWOMP'19)
- RFC: Extending #pragma clang loop 
 (cfe-dev)
- Prototype implementation using `#pragma clang loop` and attributes 
 (GitHub)

Loop attributes metadata:

- RFC: Extending loop metadata 
 (llvm-dev)
- D57978 : Metadata for follow-up 
transformations

Applying loop optimizations:

- Loop Optimization Framework  (LCPC'18)
- Loop Transformations in LLVM  (LLVM 
DevMtg'18)
- Prototype implementation for applying transformations using Polly 
 (GitHub)


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D68818: [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-18 Thread Michael Liao via Phabricator via cfe-commits
hliao updated this revision to Diff 225678.
hliao added a comment.

minor test case revising.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68818

Files:
  clang/include/clang/AST/DeclCXX.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriter.cpp
  clang/test/CodeGenCUDA/unnamed-types.cu

Index: clang/test/CodeGenCUDA/unnamed-types.cu
===
--- /dev/null
+++ clang/test/CodeGenCUDA/unnamed-types.cu
@@ -0,0 +1,39 @@
+// RUN: %clang_cc1 -std=c++11 -x hip -triple x86_64-linux-gnu -aux-triple amdgcn-amd-amdhsa -emit-llvm %s -o - | FileCheck %s --check-prefix=HOST
+// RUN: %clang_cc1 -std=c++11 -x hip -triple amdgcn-amd-amdhsa -fcuda-is-device -emit-llvm %s -o - | FileCheck %s --check-prefix=DEVICE
+
+#include "Inputs/cuda.h"
+
+// HOST: @0 = private unnamed_addr constant [43 x i8] c"_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_\00", align 1
+
+__device__ float d0(float x) {
+  return [](float x) { return x + 2.f; }(x);
+}
+
+__device__ float d1(float x) {
+  return [](float x) { return x * 2.f; }(x);
+}
+
+// DEVICE: amdgpu_kernel void @_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_(
+template 
+__global__ void k0(float *p, F f) {
+  p[0] = f(p[0]) + d0(p[1]) + d1(p[2]);
+}
+
+void f0(float *p) {
+  [](float *p) {
+*p = 1.f;
+  }(p);
+}
+
+// The inner/outer lambdas are required to be mangled following ODR but their
+// linkages are still required to keep the original `internal` linkage.
+
+// HOST: define internal void @_ZZ2f1PfENKUlS_E_clES_(
+// DEVICE: define internal float @_ZZZ2f1PfENKUlS_E_clES_ENKUlfE_clEf(
+void f1(float *p) {
+  [](float *p) {
+k0<<<1,1>>>(p, [] __device__ (float x) { return x + 1.f; });
+  }(p);
+}
+// HOST: @__hip_register_globals
+// HOST: __hipRegisterFunction{{.*}}@_Z2k0IZZ2f1PfENKUlS0_E_clES0_EUlfE_EvS0_T_{{.*}}@0
Index: clang/lib/Serialization/ASTWriter.cpp
===
--- clang/lib/Serialization/ASTWriter.cpp
+++ clang/lib/Serialization/ASTWriter.cpp
@@ -6223,6 +6223,7 @@
 Record->push_back(Lambda.CaptureDefault);
 Record->push_back(Lambda.NumCaptures);
 Record->push_back(Lambda.NumExplicitCaptures);
+Record->push_back(Lambda.HasKnownInternalLinkage);
 Record->push_back(Lambda.ManglingNumber);
 AddDeclRef(D->getLambdaContextDecl());
 AddTypeSourceInfo(Lambda.MethodTyInfo);
Index: clang/lib/Serialization/ASTReaderDecl.cpp
===
--- clang/lib/Serialization/ASTReaderDecl.cpp
+++ clang/lib/Serialization/ASTReaderDecl.cpp
@@ -1690,6 +1690,7 @@
 Lambda.CaptureDefault = Record.readInt();
 Lambda.NumCaptures = Record.readInt();
 Lambda.NumExplicitCaptures = Record.readInt();
+Lambda.HasKnownInternalLinkage = Record.readInt();
 Lambda.ManglingNumber = Record.readInt();
 Lambda.ContextDecl = ReadDeclID();
 Lambda.Captures = (Capture *)Reader.getContext().Allocate(
Index: clang/lib/Sema/TreeTransform.h
===
--- clang/lib/Sema/TreeTransform.h
+++ clang/lib/Sema/TreeTransform.h
@@ -11442,17 +11442,18 @@
 E->getCaptureDefault());
   getDerived().transformedLocalDecl(OldClass, {Class});
 
-  Optional> Mangling;
+  Optional> Mangling;
   if (getDerived().ReplacingOriginal())
-Mangling = std::make_pair(OldClass->getLambdaManglingNumber(),
-  OldClass->getLambdaContextDecl());
+Mangling = std::make_tuple(OldClass->getLambdaManglingNumber(),
+   OldClass->hasKnownInternalLinkage(),
+   OldClass->getLambdaContextDecl());
 
   // Build the call operator.
   CXXMethodDecl *NewCallOperator = getSema().startLambdaDefinition(
   Class, E->getIntroducerRange(), NewCallOpTSI,
   E->getCallOperator()->getEndLoc(),
   NewCallOpTSI->getTypeLoc().castAs().getParams(),
-  E->getCallOperator()->getConstexprKind(), Mangling);
+  E->getCallOperator()->getConstexprKind());
 
   LSI->CallOperator = NewCallOperator;
 
@@ -11472,6 +11473,9 @@
   getDerived().transformAttrs(E->getCallOperator(), NewCallOperator);
   getDerived().transformedLocalDecl(E->getCallOperator(), {NewCallOperator});
 
+  // Number the lambda for linkage purposes if necessary.
+  getSema().handleLambdaNumbering(Class, NewCallOperator, Mangling);
+
   // Introduce the context of the call operator.
   Sema::ContextRAII SavedContext(getSema(), NewCallOperator,
  /*NewThisContext*/false);
Index: clang/lib/Sema/SemaLambda.cpp
===
--- clang/lib/S

[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Hideki Saito via Phabricator via cfe-commits
hsaito added a comment.

In D69088#1714575 , @Meinersbur wrote:

> In D69088#1714020 , @hsaito wrote:
>
> > Personally, I like the intent. I don't foresee a clear (enough) path to get 
> > there. This leads to hesitation of adding a new non-experimental pragma and 
> > present it to programmers. If you call it experimental, it's easier for me 
> > to swallow.
>
>
> Is there anything more to do than mentioning as being it experimental in the 
> (no-patch-available-yet) docs?


If there is a precedence, just follow that. Else, how to spell an experimental 
clang pragma would be a good discussion topic by itself. If I need to provide a 
discussion starter, I'd say how about transform_experimental instead of 
transform. All I ask is somehow make it easier for programmers to know it is 
experimental so that they won't use it w/o first reading about the current 
state of support. I don't have a strong opinion about how to do so.

If others with stakes in loop optimizations foresee a clear enough path to get 
there, I won't insist this being experimental, but I would like to understand 
the path.

Thanks,
Hideki


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[libunwind] r375275 - [libunwind][Android] Fix findUnwindSections for ARM EHABI Bionic

2019-10-18 Thread Ryan Prichard via cfe-commits
Author: rprichard
Date: Fri Oct 18 12:59:22 2019
New Revision: 375275

URL: http://llvm.org/viewvc/llvm-project?rev=375275&view=rev
Log:
[libunwind][Android] Fix findUnwindSections for ARM EHABI Bionic

Summary:
Fix the arm_section_length count. The meaning of the arm_section_length
field changed from num-of-elements to num-of-bytes when the
dl_unwind_find_exidx special case was removed (D30306 and D30681). The
special case was restored in D39468, but that patch didn't account for the
change in arm_section_length's meaning.

That patch worked when it was applied to the NDK's fork of libunwind,
because it never removed the special case in the first place, and the
special case is probably disabled in the Android platform's copy of
libunwind, because __ANDROID_API__ is greater than 21.

Turn the dl_unwind_find_exidx special case on unconditionally for Bionic.
Bionic's dl_unwind_find_exidx is much faster than using dl_iterate_phdr.
(e.g. Bionic stores exidx info on an internal soinfo object.)

Reviewers: thomasanderson, srhines, danalbert, ed, keith.walker.arm, 
mclow.lists, compnerd

Reviewed By: srhines, danalbert

Subscribers: srhines, kristof.beyls, christof, libcxx-commits

Tags: #libc

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

Modified:
libunwind/trunk/src/AddressSpace.hpp
libunwind/trunk/src/UnwindCursor.hpp

Modified: libunwind/trunk/src/AddressSpace.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/AddressSpace.hpp?rev=375275&r1=375274&r2=375275&view=diff
==
--- libunwind/trunk/src/AddressSpace.hpp (original)
+++ libunwind/trunk/src/AddressSpace.hpp Fri Oct 18 12:59:22 2019
@@ -32,6 +32,13 @@
 #endif
 #endif
 
+#if defined(_LIBUNWIND_ARM_EHABI)
+struct EHABIIndexEntry {
+  uint32_t functionOffset;
+  uint32_t data;
+};
+#endif
+
 #ifdef __APPLE__
 #include 
 namespace libunwind {
@@ -462,12 +469,13 @@ inline bool LocalAddressSpace::findUnwin
   (void)targetAddr;
   (void)info;
   return true;
-#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__) &&  
\
-(__ANDROID_API__ < 21)
+#elif defined(_LIBUNWIND_ARM_EHABI) && defined(__BIONIC__)
+  // For ARM EHABI, Bionic didn't implement dl_iterate_phdr until API 21. After
+  // API 21, dl_iterate_phdr exists, but dl_unwind_find_exidx is much faster.
   int length = 0;
   info.arm_section =
   (uintptr_t)dl_unwind_find_exidx((_Unwind_Ptr)targetAddr, &length);
-  info.arm_section_length = (uintptr_t)length;
+  info.arm_section_length = (uintptr_t)length * sizeof(EHABIIndexEntry);
   if (info.arm_section && info.arm_section_length)
 return true;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)

Modified: libunwind/trunk/src/UnwindCursor.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindCursor.hpp?rev=375275&r1=375274&r2=375275&view=diff
==
--- libunwind/trunk/src/UnwindCursor.hpp (original)
+++ libunwind/trunk/src/UnwindCursor.hpp Fri Oct 18 12:59:22 2019
@@ -1222,11 +1222,6 @@ template  bool U
 #endif // defined(_LIBUNWIND_SUPPORT_SEH_UNWIND)
 
 #if defined(_LIBUNWIND_ARM_EHABI)
-struct EHABIIndexEntry {
-  uint32_t functionOffset;
-  uint32_t data;
-};
-
 template
 struct EHABISectionIterator {
   typedef EHABISectionIterator _Self;


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


[PATCH] D68818: [hip][cuda] Fix the extended lambda name mangling issue.

2019-10-18 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/AST/DeclCXX.h:1713
+  /// mangling number.
+  bool hasKnownInternalLinkage() const {
+assert(isLambda() && "Not a lambda closure type!");

This function name should mention that it's only applicable to lambdas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D68818



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


[PATCH] D69150: [analyzer] Fix hidden node traversal in exploded graph dumps.

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ marked an inline comment as done.
NoQ added inline comments.



Comment at: clang/test/Analysis/dump_egraph.c:46
 
 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, 
\"file\": \"{{(.+)}}dump_egraph.c\" \}
 

Charusso wrote:
> `\"file\": \"{{(.+)}}dump_egraph.c\" \}` is a cool workaround, but otherwise 
> if you do not want to end line 32, could you remove this line's ending please?
Interestingly, this doesn't work in my case but does work in this older case, 
due to greediness: the first `{(.+)}}dump_egraph.c` matches everything until 
the second `dump_egraph.c` and then it can't find the `PreStmtPurgeDeadSymbols` 
line after it because it was already skipped.

I tried to make it non-greedy: `{{(.+?)}}dump_egraph.c` but it says it's not 
allowed.

I'm pretty bad with regexps so i decided to screw it :) But let's keep at least 
this test in order to test that the filename is actually printed.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69150



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


r375278 - [analyzer] Fix hidden node traversal in exploded graph dumps.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:29 2019
New Revision: 375278

URL: http://llvm.org/viewvc/llvm-project?rev=375278&view=rev
Log:
[analyzer] Fix hidden node traversal in exploded graph dumps.

The joined nodes now actually have the same state. That was intended
from the start but the original implementation turned out to be buggy.

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

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=375278&r1=375277&r2=375278&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Oct 18 13:15:29 2019
@@ -3030,22 +3030,16 @@ struct DOTGraphTraits :
   llvm::function_ref PreCallback,
   llvm::function_ref PostCallback,
   llvm::function_ref Stop) {
-const ExplodedNode *FirstHiddenNode = N;
-while (FirstHiddenNode->pred_size() == 1 &&
-   isNodeHidden(*FirstHiddenNode->pred_begin())) {
-  FirstHiddenNode = *FirstHiddenNode->pred_begin();
-}
-const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  PreCallback(OtherNode);
-  if (Stop(OtherNode))
+  PreCallback(N);
+  if (Stop(N))
 return true;
 
-  if (OtherNode == N)
+  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
 break;
-  PostCallback(OtherNode);
+  PostCallback(N);
 
-  OtherNode = *OtherNode->succ_begin();
+  N = N->getFirstSucc();
 }
 return false;
   }

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=375278&r1=375277&r2=375278&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Fri Oct 18 13:15:29 2019
@@ -18,10 +18,30 @@ int foo() {
   return *x + *y;
 }
 
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": 
null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 
\}\l  ],\l  \"program_state\": null
-
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"BlockEntrance\", \"block_id\": 1
-
+// CHECK: \"program_points\": [\l
+// CHECK-SAME: \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1,
+// CHECK-SAME:\"terminator\": null, \"term_kind\": null, \"tag\": null,
+// CHECK-SAME:\"node_id\": 1, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"BlockEntrance\", \"block_id\": 1, \"tag\": null,
+// CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
+// CHECK-SAME:\"tag\": \"ExprEngine : Clean Node\", \"node_id\": 3,
+// CHECK-SAME:\"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PostStmt\", \"tag\": null,
+// CHECK-SAME:\"node_id\": 4, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \}
+// CHECK-SAME: ]
 
 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, 
\"file\": \"{{(.+)}}dump_egraph.c\" \}
 


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


r375280 - [analyzer] Drop the logic for collapsing the state if it's same as in preds.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:35 2019
New Revision: 375280

URL: http://llvm.org/viewvc/llvm-project?rev=375280&view=rev
Log:
[analyzer] Drop the logic for collapsing the state if it's same as in preds.

One of the first attempts to reduce the size of the exploded graph dumps
was to skip the state dump as long as the state is the same as in all of
the predecessor nodes. With all the new facilities in place (node joining,
diff dumps), this feature doesn't do much, and when it does,
it's more harmful than useful. Let's remove it.

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

Modified: cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp?rev=375280&r1=375279&r2=375280&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/ExprEngine.cpp Fri Oct 18 13:15:35 2019
@@ -3083,16 +3083,7 @@ struct DOTGraphTraits :
 Out << "\\l"; // Adds a new-line to the last program point.
 Indent(Out, Space, IsDot) << "],\\l";
 
-bool SameAsAllPredecessors =
-std::all_of(N->pred_begin(), N->pred_end(), [&](const ExplodedNode *P) 
{
-  return P->getState() == State;
-});
-
-if (!SameAsAllPredecessors) {
-  State->printDOT(Out, N->getLocationContext(), Space);
-} else {
-  Indent(Out, Space, IsDot) << "\"program_state\": null";
-}
+State->printDOT(Out, N->getLocationContext(), Space);
 
 Out << "\\l}\\l";
 return Out.str();

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=375280&r1=375279&r2=375280&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Fri Oct 18 13:15:35 2019
@@ -48,3 +48,5 @@ int foo() {
 // CHECK: \"pretty\": \"'x13'\"
 
 // CHECK: \"has_report\": 1
+
+// CHECK-NOT: \"program_state\": null


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


r375282 - [analyzer] exploded-graph-rewriter: Rename Environment to Expressions.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:41 2019
New Revision: 375282

URL: http://llvm.org/viewvc/llvm-project?rev=375282&view=rev
Log:
[analyzer] exploded-graph-rewriter: Rename Environment to Expressions.

It's less confusing for newcomers.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot?rev=375282&r1=375281&r2=375282&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/environment.dot Fri Oct 18 
13:15:41 2019
@@ -3,7 +3,7 @@
 // FIXME: Substitution doesn't seem to work on Windows.
 // UNSUPPORTED: system-windows
 
-// CHECK: Environment: 
+// CHECK: Expressions: 
 // CHECK-SAME: 
 // CHECK-SAME:   
 // CHECK-SAME: 

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c?rev=375282&r1=375281&r2=375282&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/escapes.c Fri Oct 18 
13:15:41 2019
@@ -12,7 +12,7 @@ void escapes() {
   // CHECK: Store:  (0x{{[0-9a-f]*}})
   // CHECK-SAME: foo0
   // CHECK-SAME: &Element\{"foo",0 S64b,char\}
-  // CHECK: Environment: 
+  // CHECK: Expressions: 
   // CHECK-SAME: "foo"
   // CHECK-SAME: &Element\{"foo",0 S64b,char\}
   const char *const foo = "\x66\x6f\x6f";

Modified: cfe/trunk/utils/analyzer/exploded-graph-rewriter.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/analyzer/exploded-graph-rewriter.py?rev=375282&r1=375281&r2=375282&view=diff
==
--- cfe/trunk/utils/analyzer/exploded-graph-rewriter.py (original)
+++ cfe/trunk/utils/analyzer/exploded-graph-rewriter.py Fri Oct 18 13:15:41 2019
@@ -792,7 +792,7 @@ class DotDumpVisitor(object):
 
 def visit_state(self, s, prev_s):
 self.visit_store_in_state(s, prev_s)
-self.visit_environment_in_state('environment', 'Environment',
+self.visit_environment_in_state('environment', 'Expressions',
 s, prev_s)
 self.visit_generic_map_in_state('constraints', 'Ranges',
 s, prev_s)


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


r375281 - [analyzer] Fix FieldRegion dumps.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:39 2019
New Revision: 375281

URL: http://llvm.org/viewvc/llvm-project?rev=375281&view=rev
Log:
[analyzer] Fix FieldRegion dumps.

The '->' thing has always been confusing; the actual operation '->'
translates to a pointer dereference together with adding a FieldRegion,
but FieldRegion on its own doesn't imply an additional pointer
dereference.

Modified:
cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
cfe/trunk/test/Analysis/dump_egraph.cpp

cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
cfe/trunk/test/Analysis/expr-inspection.c

Modified: cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp?rev=375281&r1=375280&r2=375281&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Core/MemRegion.cpp Fri Oct 18 13:15:39 2019
@@ -506,7 +506,7 @@ void ElementRegion::dumpToStream(raw_ost
 }
 
 void FieldRegion::dumpToStream(raw_ostream &os) const {
-  os << superRegion << "->" << *getDecl();
+  os << superRegion << "." << *getDecl();
 }
 
 void ObjCIvarRegion::dumpToStream(raw_ostream &os) const {

Modified: cfe/trunk/test/Analysis/dump_egraph.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.cpp?rev=375281&r1=375280&r2=375281&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.cpp (original)
+++ cfe/trunk/test/Analysis/dump_egraph.cpp Fri Oct 18 13:15:39 2019
@@ -20,7 +20,7 @@ void foo() {
 
 // CHECK: \"location_context\": \"#0 Call\", \"calling\": \"foo\", 
\"location\": null, \"items\": 
[\l\{ \"stmt_id\": {{[0-9]+}}, 
\"kind\": \"construct into local variable\", \"argument_index\": null, 
\"pretty\": \"T t;\", \"value\": \"&t\"
 
-// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"T::T\", 
\"location\": \{ \"line\": 16, \"column\": 5, \"file\": 
\"{{.*}}dump_egraph.cpp\" \}, \"items\": 
[\l\{ \"init_id\": {{[0-9]+}}, 
\"kind\": \"construct into member variable\", \"argument_index\": null, 
\"pretty\": \"s\", \"value\": \"&t-\>s\"
+// CHECK: \"location_context\": \"#0 Call\", \"calling\": \"T::T\", 
\"location\": \{ \"line\": 16, \"column\": 5, \"file\": 
\"{{.*}}dump_egraph.cpp\" \}, \"items\": 
[\l\{ \"init_id\": {{[0-9]+}}, 
\"kind\": \"construct into member variable\", \"argument_index\": null, 
\"pretty\": \"s\", \"value\": \"&t.s\"
 
 // CHECK: \"cluster\": \"t\", \"pointer\": \"{{0x[0-9a-f]+}}\", \"items\": 
[\l\{ \"kind\": \"Default\", 
\"offset\": 0, \"value\": \"conj_$2\{int, LC5, no stmt, #1\}\"
 

Modified: 
cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp?rev=375281&r1=375280&r2=375281&view=diff
==
--- 
cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
 (original)
+++ 
cfe/trunk/test/Analysis/exploded-graph-rewriter/initializers_under_construction.cpp
 Fri Oct 18 13:15:39 2019
@@ -20,6 +20,6 @@ struct B {
 void test() {
   // CHECK: (construct into member variable)
   // CHECK-SAME: a
-  // CHECK-SAME: &b->a
+  // CHECK-SAME: &b.a
   B b;
 }

Modified: cfe/trunk/test/Analysis/expr-inspection.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/expr-inspection.c?rev=375281&r1=375280&r2=375281&view=diff
==
--- cfe/trunk/test/Analysis/expr-inspection.c (original)
+++ cfe/trunk/test/Analysis/expr-inspection.c Fri Oct 18 13:15:39 2019
@@ -5,6 +5,7 @@
 // Self-tests for the debug.ExprInspection checker.
 
 void clang_analyzer_dump(int x);
+void clang_analyzer_dump_pointer(int *p);
 void clang_analyzer_printState();
 void clang_analyzer_numTimesReached();
 
@@ -30,7 +31,7 @@ void foo(int x) {
 // CHECK-NEXT: ]}
 // CHECK-NEXT:   ]},
 // CHECK-NEXT:   "environment": { "pointer": "{{0x[0-9a-f]+}}", "items": [
-// CHECK-NEXT: { "lctx_id": 1, "location_context": "#0 Call", "calling": 
"foo", "location": null, "items": [
+// CHECK-NEXT: { "lctx_id": {{[0-9]+}}, "location_context": "#0 Call", 
"calling": "foo", "location": null, "items": [
 // CHECK-NEXT:   { "stmt_id": {{[0-9]+}}, "pretty": 
"clang_analyzer_printState", "value": "&code{clang_analyzer_printState}" }
 // CHECK-NEXT: ]}
 // CHECK-NEXT:   ]},
@@ -43,3 +44,11 @@ void foo(int x) {
 // CHECK-NEXT:   "checker_messages": null
 // CHECK-NEXT: }
 
+struct S {
+  int x, y;
+};
+
+void test_field_dumps(struct S s, struct S *p) {
+  clang_analyzer_dump_pointer(&s.x); // expected-warning{{&s.x}}
+  clang_analyzer_dump_pointer(&p->x)

r375279 - [analyzer] exploded-graph-rewriter: Fix dump for state 0.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:15:32 2019
New Revision: 375279

URL: http://llvm.org/viewvc/llvm-project?rev=375279&view=rev
Log:
[analyzer] exploded-graph-rewriter: Fix dump for state 0.

It shouldn't say "unspecified" when the state is specified to be empty.

Modified:
cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot
cfe/trunk/utils/analyzer/exploded-graph-rewriter.py

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/edge.dot Fri Oct 18 
13:15:32 2019
@@ -5,7 +5,7 @@
 // UNSUPPORTED: system-windows
 
 Node0x1 [shape=record,label=
- "{{ "program_state": null, "program_points": [
+ "{{ "state_id": 0, "program_state": null, "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,
   "terminator": null, "term_kind": null,
@@ -19,7 +19,7 @@ Node0x1 [shape=record,label=
 Node0x1 -> Node0x2;
 
 Node0x2 [shape=record,label=
- "{{ "program_state": null, "program_points": [
+ "{{ "state_id": 0, "program_state": null, "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,
   "terminator": null, "term_kind": null,

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/node_labels.dot Fri Oct 18 
13:15:32 2019
@@ -15,13 +15,12 @@
 // CHECK-SAME:   
 // LIGHT-SAME: 
 // DARK-SAME:  
-// CHECK-SAME:   State Unspecified
+// CHECK-SAME:   State 0
 // CHECK-SAME: 
 // CHECK-SAME:   
 Node0x1 [shape=record,label=
  "{
-{ "node_id": 1, "pointer": "0x1", "has_report": false, "is_sink": false,
-  "program_state": null,
+{ "state_id": 0, "program_state": null,
   "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,
@@ -48,7 +47,7 @@ Node0x1 [shape=record,label=
 // CHECK-SAME: 
 Node0x2 [shape=record,label=
  "{
-{ "program_state": null,
+{ "state_id": 0, "program_state": null,
   "program_points": [
 {
   "kind": "BlockEntrance", "block_id": 1,

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot 
(original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/program_points.dot Fri Oct 
18 13:15:32 2019
@@ -29,7 +29,7 @@
 Node0x1 [shape=record,label=
  "{
 {
-  "program_state": null, "program_points": [
+  "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Edge",
 "src_id": 0,
@@ -80,7 +80,7 @@ Node0x1 [shape=record,label=
 // CHECK-SAME: 
 Node0x3 [shape=record,label=
  "{
-{ "program_state": null, "program_points": [
+{ "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Statement",
 "stmt_kind": "DeclRefExpr",
@@ -109,7 +109,7 @@ Node0x3 [shape=record,label=
 Node0x4 [shape=record,label=
  "{
 {
-  "program_state": null, "program_points": [
+  "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Statement",
 "stmt_kind": "CompoundStmt",
@@ -157,7 +157,7 @@ Node0x4 [shape=record,label=
 // CHECK-SAME: 
 Node0x5 [shape=record,label=
  "{
-{ "program_state": null, "program_points": [
+{ "state_id": 0, "program_state": null, "program_points": [
   {
 "kind": "Statement",
 "stmt_kind": "ImplicitCastExpr",

Modified: cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot?rev=375279&r1=375278&r2=375279&view=diff
==
--- cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot (original)
+++ cfe/trunk/test/Analysis/exploded-graph-rewriter/trimmers.dot Fri Oct 18 
13:15:32 2019
@@ -17,7 +17,7 @@
 // UNSUPPORTED: system-windows
 
 Node0x1 [shape=record,label=
- "{{ "pro

[PATCH] D69150: [analyzer] Fix hidden node traversal in exploded graph dumps.

2019-10-18 Thread Artem Dergachev via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG7a17f197093a: [analyzer] Fix hidden node traversal in 
exploded graph dumps. (authored by dergachev.a).

Changed prior to commit:
  https://reviews.llvm.org/D69150?vs=225547&id=225685#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69150

Files:
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/Analysis/dump_egraph.c


Index: clang/test/Analysis/dump_egraph.c
===
--- clang/test/Analysis/dump_egraph.c
+++ clang/test/Analysis/dump_egraph.c
@@ -18,10 +18,30 @@
   return *x + *y;
 }
 
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": 
null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 
\}\l  ],\l  \"program_state\": null
-
-// CHECK: \"program_points\": [\l\{ \"kind\": 
\"BlockEntrance\", \"block_id\": 1
-
+// CHECK: \"program_points\": [\l
+// CHECK-SAME: \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1,
+// CHECK-SAME:\"terminator\": null, \"term_kind\": null, \"tag\": null,
+// CHECK-SAME:\"node_id\": 1, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"BlockEntrance\", \"block_id\": 1, \"tag\": null,
+// CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
+// CHECK-SAME:\"tag\": \"ExprEngine : Clean Node\", \"node_id\": 3,
+// CHECK-SAME:\"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PostStmt\", \"tag\": null,
+// CHECK-SAME:\"node_id\": 4, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \}
+// CHECK-SAME: ]
 
 // CHECK: \"pretty\": \"*x\", \"location\": \{ \"line\": 18, \"column\": 10, 
\"file\": \"{{(.+)}}dump_egraph.c\" \}
 
Index: clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
===
--- clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
+++ clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
@@ -3030,22 +3030,16 @@
   llvm::function_ref PreCallback,
   llvm::function_ref PostCallback,
   llvm::function_ref Stop) {
-const ExplodedNode *FirstHiddenNode = N;
-while (FirstHiddenNode->pred_size() == 1 &&
-   isNodeHidden(*FirstHiddenNode->pred_begin())) {
-  FirstHiddenNode = *FirstHiddenNode->pred_begin();
-}
-const ExplodedNode *OtherNode = FirstHiddenNode;
 while (true) {
-  PreCallback(OtherNode);
-  if (Stop(OtherNode))
+  PreCallback(N);
+  if (Stop(N))
 return true;
 
-  if (OtherNode == N)
+  if (N->succ_size() != 1 || !isNodeHidden(N->getFirstSucc()))
 break;
-  PostCallback(OtherNode);
+  PostCallback(N);
 
-  OtherNode = *OtherNode->succ_begin();
+  N = N->getFirstSucc();
 }
 return false;
   }


Index: clang/test/Analysis/dump_egraph.c
===
--- clang/test/Analysis/dump_egraph.c
+++ clang/test/Analysis/dump_egraph.c
@@ -18,10 +18,30 @@
   return *x + *y;
 }
 
-// CHECK: \"program_points\": [\l\{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1, \"terminator\": null, \"term_kind\": null, \"tag\": null, \"node_id\": 1, \"is_sink\": 0, \"has_report\": 0 \}\l  ],\l  \"program_state\": null
-
-// CHECK: \"program_points\": [\l\{ \"kind\": \"BlockEntrance\", \"block_id\": 1
-
+// CHECK: \"program_points\": [\l
+// CHECK-SAME: \{ \"kind\": \"Edge\", \"src_id\": 2, \"dst_id\": 1,
+// CHECK-SAME:\"terminator\": null, \"term_kind\": null, \"tag\": null,
+// CHECK-SAME:\"node_id\": 1, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"BlockEntrance\", \"block_id\": 1, \"tag\": null,
+// CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
+// CHECK-SAME: \},
+// CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
+// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"pretty\": \"0\", \"location\": \{
+// CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
+// CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
+// CHECK-SAME:\"tag\": \"ExprEngine : Clean 

r375286 - [analyzer] exploded-graph-rewriter: Unforget to censor stmt_ids in the test.

2019-10-18 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Fri Oct 18 13:48:21 2019
New Revision: 375286

URL: http://llvm.org/viewvc/llvm-project?rev=375286&view=rev
Log:
[analyzer] exploded-graph-rewriter: Unforget to censor stmt_ids in the test.

They're not stable across machines.

Fixes buildbots after r375278.

Modified:
cfe/trunk/test/Analysis/dump_egraph.c

Modified: cfe/trunk/test/Analysis/dump_egraph.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/dump_egraph.c?rev=375286&r1=375285&r2=375286&view=diff
==
--- cfe/trunk/test/Analysis/dump_egraph.c (original)
+++ cfe/trunk/test/Analysis/dump_egraph.c Fri Oct 18 13:48:21 2019
@@ -27,7 +27,7 @@ int foo() {
 // CHECK-SAME:\"node_id\": 2, \"is_sink\": 0, \"has_report\": 0
 // CHECK-SAME: \},
 // CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
-// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"stmt_id\": {{[0-9]*}}, \"pointer\": \"0x{{[0-9a-f]*}}\",
 // CHECK-SAME:\"pretty\": \"0\", \"location\": \{
 // CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
 // CHECK-SAME:\}, \"stmt_point_kind\": \"PreStmtPurgeDeadSymbols\",
@@ -35,7 +35,7 @@ int foo() {
 // CHECK-SAME:\"is_sink\": 0, \"has_report\": 0
 // CHECK-SAME: \},
 // CHECK-SAME: \{ \"kind\": \"Statement\", \"stmt_kind\": \"IntegerLiteral\",
-// CHECK-SAME:\"stmt_id\": 597, \"pointer\": \"0x{{[0-9a-f]*}}\",
+// CHECK-SAME:\"stmt_id\": {{[0-9]*}}, \"pointer\": \"0x{{[0-9a-f]*}}\",
 // CHECK-SAME:\"pretty\": \"0\", \"location\": \{
 // CHECK-SAME:\"line\": 15, \"column\": 12, \"file\":
 // CHECK-SAME:\}, \"stmt_point_kind\": \"PostStmt\", \"tag\": null,


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


[PATCH] D67647: [Consumed] Refactor handleCall to take function argument list. NFC.

2019-10-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a comment.

In D67647#1713974 , @comex wrote:

> So, I landed this patch but had to revert it as it broke the build on MSVC 
> (and only MSVC).  That was almost a month ago, but I haven't gotten back 
> around to this until now – sorry :|
>
> In this updated patch, I switched is_random_iterator from a constexpr 
> function:
>
>   template 
>   constexpr bool is_random_iterator() {
> return std::is_same<
>   typename std::iterator_traits::iterator_category,
>   std::random_access_iterator_tag>::value;
>   }
>
>
> to a type alias:
>
>   template 
>   using is_random_iterator =
> std::is_same::iterator_category,
>  std::random_access_iterator_tag>;
>
>
> and changed the uses accordingly.  For some reason, MSVC thought the two 
> overloads of `drop_begin`, one with `enable_if()>` and 
> one with `enable_if()>`, were duplicate definitions.  
> But with `is_random_iterator` changed to a type alias, MSVC is fine with 
> them.  GCC and Clang think both versions are valid, so I think it's just an 
> MSVC bug.
>
> Simplified example for reference: https://gcc.godbolt.org/z/niXCy4


Sounds good to me. Maybe leave a comment explaining why a constexpr function 
was not used?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D67647



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


[PATCH] D69194: build: add clang-cl and clang++ symlinks in the build tree

2019-10-18 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd created this revision.
compnerd added reviewers: xiaobai, beanz, smeenai.
Herald added a subscriber: mgorny.
Herald added a project: clang.

This adds the clang-cl and clang++ symlinks.  Since there are no targets to 
depend on for this, we cannot force the creation of the symlinks.  Furthermore, 
the current build only installs the symbolic links in the install tree, not the 
build tree.  This enables the use of the clang driver without having adjust the 
C/C++ flags to add `--driver=...` to switch between driver modes.  Usage of 
this is present in Swift and there is some usage in lldb.


Repository:
  rC Clang

https://reviews.llvm.org/D69194

Files:
  tools/driver/CMakeLists.txt


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -49,6 +49,15 @@
   clangSerialization
   )
 
+if(CMAKE_VERSION VERSION_GREATER 3.7 OR NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
+  set(command create_symlink)
+else()
+  set(command copy)
+endif()
+add_custom_command(TARGET clang POST_BUILD
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ 
$/clang-cl${CMAKE_EXECUTABLE_SUFFIX}
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ 
$/clang++${CMAKE_EXECUTABLE_SUFFIX})
+
 if(WIN32 AND NOT CYGWIN)
   # Prevent versioning if the buildhost is targeting for Win32.
 else()


Index: tools/driver/CMakeLists.txt
===
--- tools/driver/CMakeLists.txt
+++ tools/driver/CMakeLists.txt
@@ -49,6 +49,15 @@
   clangSerialization
   )
 
+if(CMAKE_VERSION VERSION_GREATER 3.7 OR NOT CMAKE_SYSTEM_NAME STREQUAL Windows)
+  set(command create_symlink)
+else()
+  set(command copy)
+endif()
+add_custom_command(TARGET clang POST_BUILD
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ $/clang-cl${CMAKE_EXECUTABLE_SUFFIX}
+  COMMAND ${CMAKE_COMMAND} -E ${command} $ $/clang++${CMAKE_EXECUTABLE_SUFFIX})
+
 if(WIN32 AND NOT CYGWIN)
   # Prevent versioning if the buildhost is targeting for Win32.
 else()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69194: build: add clang-cl and clang++ symlinks in the build tree

2019-10-18 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai added a comment.

> Furthermore, the current build only installs the symbolic links in the 
> install tree, not the build tree

This isn't right ... if I look at my LLVM build tree, I have clang, clang++ and 
clang-cl symlinks, all pointing to the actual clang-10 binary.

Where are you seeing this?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69194



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


Re: Zorg migration to GitHub/monorepo

2019-10-18 Thread Vitaly Buka via cfe-commits
On Mon, Oct 14, 2019 at 6:16 PM Galina Kistanova via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hello everyone,
>
>
>
> We are in the middle of porting the majority of zorg to
> GitHub/monorepo. The following build factories will be ported and if you
> use one of those for your bots, you are all covered:
>
>
>
> * ClangBuilder.getClangCMakeBuildFactory (31 bots)
>
> * ClangBuilder.getClangCMakeGCSBuildFactory (2 bots)
>
> * LibcxxAndAbiBuilder (23 bots)
>
> * SphinxDocsBuilder (7 bots)
>
> * UnifiedTreeBuilder (11 bots)
>
> * ABITestsuitBuilder (1 bot) - based on UnifiedTreeBuilder
>
> * ClangLTOBuilder (2 bots) - based on UnifiedTreeBuilder
>
> * LLDPerformanceTesuiteBuilder (1 bot) - based on UnifiedTreeBuilder
>
>
>
> Some build factories will be deprecated. If you use one of these, please
> change your bot to use something else instead. Here is the list of
> deprecated build factories:
>
>
>
> * ClangBuilder.getClangBuildFactory (0 bots)
>
> * LLDBuilder (0 bots)
>
> * ClangAndLLDBuilder (0 bots)
>
>
>
> However, some special build factories and build factories with a few bots
> would need your attention.
>
> Here is the list of build factories in need of porting. Patches are
> welcome.
>
>
>
> * LLVMBuilder (3 bots)
>
> * PollyBuilder (3 bots)
>
> * LLDBBuilder (6 bots)
>
> * SanitizerBuilder (10 bots)
>

SanitizerBuilder already uses monorepo from github. Still it uses svn
BUILDBOT_REVISION. 'BUILDBOT_REVISION' is
WithProperties('%(revision:-None)s').
Not sure what is going to happen after migration.


> * CUDATestsuiteBuilder (1 bot) - depends on
> ClangBuilder.getClangBuildFactory
>
> * AOSPBuilder (1 bot) - depends on PollyBuilder
>
> * AnnotatedBuilder (2 bots)
>
> * OpenMPBuilder (2 bots)
>
> * FuchsiaBuilder (1 bot)
>
>
>
> Please feel free to ask if you have questions.
>
>
>
> Thanks
>
>
>
> Galina
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Michael Kruse via Phabricator via cfe-commits
Meinersbur added a comment.

In D69088#1715038 , @hsaito wrote:

> If there is a precedence, just follow that. Else, how to spell an 
> experimental clang pragma would be a good discussion topic by itself. If I 
> need to provide a discussion starter, I'd say how about 
> transform_experimental instead of transform. All I ask is somehow make it 
> easier for programmers to know it is experimental so that they won't use it 
> w/o first reading about the current state of support. I don't have a strong 
> opinion about how to do so.


The precedences I have found are `-fexperimental-pass-manager`, 
`-fexperimental-isel`, `std::experimental` and `clang-cl /openmp:experimental`, 
Modules  and a 
couple of features only mentioning "experimental" in their commit log.

I dislike changing the syntax syntax as it means that we will at one point 
break already written code or have to maintain two spellings. I'd rather just 
enable them with a command-line switch, such as `-fexperimental-transform`.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


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

2019-10-18 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

What are the use cases for non-text values?

I like the name `text` much better... If the name conflict is the issue, I 
think you could rename it to `toText` -- it would even read more fluently 
`change(toText("abc"))`, also making it obvious that we are not changing *the 
text abc*, but we are changing the code to say "abc".


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69184



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


[PATCH] D69088: [Lex] #pragma clang transform

2019-10-18 Thread Hideki Saito via Phabricator via cfe-commits
hsaito added a comment.

In D69088#1715210 , @Meinersbur wrote:

> I'd rather just enable them with a command-line switch, such as 
> `-fexperimental-transform`.


This direction works for me. `-fexperimental-transform-pragma` might be better, 
though.


Repository:
  rC Clang

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

https://reviews.llvm.org/D69088



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


[PATCH] D68117: [DWARF-5] Support for C++11 defaulted, deleted member functions.

2019-10-18 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added a subscriber: rsmith.
dblaikie added a comment.

In D68117#1714091 , @SouraVX wrote:

> Hi @probinson @dblaikie  @aprantl , I've was investigating and working on 
> your inputs regarding the problem with DW_at_defaulted once. I think clang 
> has also some issues.


You think clang has bugs, independent of the debug info?

>   Though I'm not able to precisely point out. I ranned into some problems in 
> CFE while marking out_of_class functions. i.e consider this for instance 
> "debug-info-defaulted-out_of_class.cpp" FIXME:.  Causing too much trouble and 
> possibly can introduce some bugs in clang/llvm. 
> 
> May be we'll reconsider this in future. Thanks for putting time in reviewing 
> and discussing this.

Yeah, I looked at it a bit & asked @rsmith for some thoughts. Eventually 
wrapped my head around it.

Clang's codegen occurs during parsing - rather than parsing/AST building 
entirely, then code generating. So to take a smaller example:

  struct foo {
foo();
// virtual
void f1();
void f2();
  };
  void foo::f2() { }
  foo::foo() = default;

Without the virtual keyword, the first time the debug info needs the type (when 
building the description for f1's definition's "this" parameter) the foo::foo() 
= default definition hasn't been parsed yet, so there is no definition of 
foo::foo() available. (so the out of class defaulting isn't visible)

The reason virtual matters is that the actual class definition of 'foo' is 
never built - check the DWARF and metadata, only a declaration of "foo" is 
built. And the declarations of the member functions are injected into the 
declaration as the definitions are parsed, not before - so they observe the 
correct defaulting state.

Another way to show the bug is with -fstandalone-debug, even with a virtual 
function it shows the problem.

And moving 'f2' around (before/after 'foo()') also shows the problem - because 
having f2 first means the type definition (without virtual, or while using 
-fstandalone-debug) is built before any defaulting is seen - so 'foo()' isn't 
shown as defaulted.

All of this somewhat goes to my point - out of line defaulting should be tested 
and recorded on the out of line definition, not on the declaration, of a 
special member.

> Anyway here's the next course of action I'm considering. I'll be marking this 
> review as abandoned. I'll raise a fresh new review for DW_AT_deleted feature, 
> that;s pretty straight forward, considering C++ spec. If it's deleted, it has 
> to be declared/defined{whatever} deleted in it's first declaration. This 
> feature also augments the consumer information regarding which spl member 
> functions are deleted, hence restrict their calling for user or do something 
> useful with this at it's disposal.
> 
> @probinson @dblaikie @aprantl Please share your thoughts/comments inclination 
> regarding adding this DW_AT_deleted to clang/llvm.

Sure, deleted support seems fine/reasonable/good to me.


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

https://reviews.llvm.org/D68117



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


[PATCH] D66437: Sema: Create a no-op implicit cast for lvalue function conversions.

2019-10-18 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66437



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


[PATCH] D69090: [Try 2] Include sanitize blacklist and other extra deps as part of scan-deps output

2019-10-18 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a comment.

In D69090#1713983 , @kousikk wrote:

> Thanks for the comment @jkorous.
>
> > I think you could've just used CHECK-DAG to fix the tests. It *might* be a 
> > bit more robust. Although just reordering checks seems perfectly fine too. 
> > https://llvm.org/docs/CommandGuide/FileCheck.html#the-check-dag-directive. 
> > Using std::set here sounds reasonable to me but I'd like @arphaman to be 
> > aware of this.
>
> Thanks for pointing me to it - I have a minor preference towards a `sorted` 
> order of outputs vs `order in which we visit the files`. I think a sorted 
> order is much more easy to reason about for a client. Having said that, 
> @arphaman what do you think? If you and Jan both feel that we should maintain 
> the current order, I'll stick to that and not change `Dependencies` to `set`.


Sorting seems reasonable to me, perhaps behind an option (I'll leave that up to 
others).  But you don't need a `std::set` for this, just run `llvm::sort` and 
`std::unique` once the dependencies are collected.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69090



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


[PATCH] D66983: [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

2019-10-18 Thread Heejin Ahn via Phabricator via cfe-commits
aheejin added inline comments.



Comment at: llvm/include/llvm/IR/IntrinsicsWebAssembly.td:117
+ llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty,
+ llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrSpeculatable]>;

i32 is bigger than `ImmLaneIdx32`. Should we model this into something smaller, 
like i8? What happens if we specify an index grater than 31? (I think this 
question also applies to other intrinsics and builtins. I don't think it 
matters a lot given than all integers are larger than lane types though.)



Comment at: llvm/lib/Target/WebAssembly/WebAssemblyISelLowering.cpp:1251
+return DAG.getNode(WebAssemblyISD::SHUFFLE, DL, Op.getValueType(), Ops);
+  }
   }

This looks rather straightforward... Can't we do this in TableGen?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D66983



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


[PATCH] D69124: [clang][driver] Print compilation phases with indentation.

2019-10-18 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Neat. I like the visual cues showing what gets passed on to the next processing 
stage.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D69124



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


r375301 - [profile] Do not cache __llvm_profile_get_filename result

2019-10-18 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Fri Oct 18 16:33:40 2019
New Revision: 375301

URL: http://llvm.org/viewvc/llvm-project?rev=375301&view=rev
Log:
[profile] Do not cache __llvm_profile_get_filename result

When the %m filename pattern is used, the filename is unique to each
image, so the cached value is wrong.

It struck me that the full filename isn't something that's recomputed
often, so perhaps it doesn't need to be cached at all. David Li pointed
out we can go further and just hide lprofCurFilename. This may regress
workflows that depend on using the set-filename API to change filenames
across all loaded DSOs, but this is expected to be very rare.

rdar://55137071

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

Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-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=375301&r1=375300&r2=375301&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Fri Oct 18 16:33:40 2019
@@ -1128,7 +1128,6 @@ void Darwin::addProfileRTLibs(const ArgL
 } else {
   addExportedSymbol(CmdArgs, "___llvm_profile_filename");
   addExportedSymbol(CmdArgs, "___llvm_profile_raw_version");
-  addExportedSymbol(CmdArgs, "_lprofCurFilename");
 }
 addExportedSymbol(CmdArgs, "_lprofDirMode");
   }

Modified: cfe/trunk/test/Driver/darwin-ld.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-ld.c?rev=375301&r1=375300&r2=375301&view=diff
==
--- cfe/trunk/test/Driver/darwin-ld.c (original)
+++ cfe/trunk/test/Driver/darwin-ld.c Fri Oct 18 16:33:40 2019
@@ -355,7 +355,7 @@
 // RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate -Xlinker 
-exported_symbols_list -Xlinker /dev/null -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=PROFILE_EXPORT %s < %t.log
-// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version" "-exported_symbol" 
"_lprofCurFilename"
+// PROFILE_EXPORT: "-exported_symbol" "___llvm_profile_filename" 
"-exported_symbol" "___llvm_profile_raw_version"
 //
 // RUN: %clang -target x86_64-apple-darwin12 -fprofile-instr-generate 
--coverage -### %t.o 2> %t.log
 // RUN: FileCheck -check-prefix=NO_PROFILE_EXPORT %s < %t.log


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


[PATCH] D69171: [clang-fuzzer] Add new fuzzer target for Objective-C

2019-10-18 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp:19
+
+extern "C" int LLVMFuzzerInitialize(int *argc, char ***argv) { return 0; }
+

Nit:  Since it does nothing, let's omit the `LLVMFuzzerInitialize` definition.



Comment at: tools/clang-fuzzer/ClangObjectiveCFuzzer.cpp:22
+extern "C" int LLVMFuzzerTestOneInput(uint8_t *data, size_t size) {
+  std::string s((const char *)data, size);
+  HandleObjC(s, {"-O2"});

Nit: reinterpret_cast



Comment at: tools/clang-fuzzer/handle-objc/handle_objc.cpp:50
+&Diags);
+}
+

Since this is ~identical to handle_cxx, I'd like to reuse the implementation.  
Can we make a more generic function (e.g., `handleLanguage(Language type, 
...)`) and use it for both?


Repository:
  rC Clang

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

https://reviews.llvm.org/D69171



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


  1   2   >