[PATCH] D61364: [libcxx] [test] Fix incorrect allocator::construct assertions in associative container tests

2019-05-01 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal created this revision.
BillyONeal added reviewers: EricWF, mclow.lists, ldionne.
Herald added a subscriber: dexonsmith.

In 
$:\Dev\msvc\src\qa\VC\Libs\libcxx\upstream\test\std\containers\map_allocator_requirement_test_templates.h
 and $\test\std\containers\set_allocator_requirement_test_templates.h, libcxx 
tests are asserting that the container's insert operation passes an incorrect 
type down to allocator::construct. Specifically, given something like:

  {
CHECKPOINT("Testing C::insert(value_type&)");
Container c;
ValueTp v(42, 1);

- cc->expect();** assert(c.insert(v).second); 
assert(!cc->unchecked()); { DisableAllocationGuard g; ValueTp v2(42, 1); 
assert(c.insert(v2).second == false); } }

This call to ::insert ends up calling the insert(P&&), not insert(const 
value_type&), because P is deduced to value_type&, meaning the insert(P&&) 
overload is an exact match, while insert(const value_type&) requires adding 
const. See http://eel.is/c++draft/associative#map.modifiers

When the insert(P&&) is called, it delegates to emplace, which only gets 
Cpp17EmplaceConstructible from the supplied parameters, not 
Cpp17EmplaceConstructible from add_const_t of the parameters. Thus, libcxx's 
test is asserting a condition the standard explicitly does not allow at this 
time. (Though it may be reasonable to fix the standard to make what libcxx is 
doing okay)

Unfortunately with the tests fixed to assert the correct allocator::construct 
call, libc++ will fail these tests. I'm looking for guidance on how libc++ 
maintainers would like to handle this.


https://reviews.llvm.org/D61364

Files:
  test/std/containers/map_allocator_requirement_test_templates.h
  test/std/containers/set_allocator_requirement_test_templates.h


Index: test/std/containers/set_allocator_requirement_test_templates.h
===
--- test/std/containers/set_allocator_requirement_test_templates.h
+++ test/std/containers/set_allocator_requirement_test_templates.h
@@ -128,7 +128,7 @@
 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
 Container c;
 ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
-cc->expect(3);
+cc->expect(3);
 c.insert(std::begin(ValueList), std::end(ValueList));
 assert(!cc->unchecked());
 {
Index: test/std/containers/map_allocator_requirement_test_templates.h
===
--- test/std/containers/map_allocator_requirement_test_templates.h
+++ test/std/containers/map_allocator_requirement_test_templates.h
@@ -51,7 +51,7 @@
 CHECKPOINT("Testing C::insert(value_type&)");
 Container c;
 ValueTp v(42, 1);
-cc->expect();
+cc->expect();
 assert(c.insert(v).second);
 assert(!cc->unchecked());
 {
@@ -77,7 +77,7 @@
 CHECKPOINT("Testing C::insert(const value_type&&)");
 Container c;
 const ValueTp v(42, 1);
-cc->expect();
+cc->expect();
 assert(c.insert(std::move(v)).second);
 assert(!cc->unchecked());
 {
@@ -141,7 +141,7 @@
 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
 Container c;
 ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) };
-cc->expect(3);
+cc->expect(3);
 c.insert(std::begin(ValueList), std::end(ValueList));
 assert(!cc->unchecked());
 {
@@ -184,7 +184,7 @@
 CHECKPOINT("Testing C::insert(p, value_type&)");
 Container c;
 ValueTp v(42, 1);
-cc->expect();
+cc->expect();
 It ret = c.insert(c.end(), v);
 assert(ret != c.end());
 assert(c.size() == 1);
@@ -233,7 +233,7 @@
 CHECKPOINT("Testing C::insert(p, const value_type&&)");
 Container c;
 const ValueTp v(42, 1);
-cc->expect();
+cc->expect();
 It ret = c.insert(c.end(), std::move(v));
 assert(ret != c.end());
 assert(c.size() == 1);


Index: test/std/containers/set_allocator_requirement_test_templates.h
===
--- test/std/containers/set_allocator_requirement_test_templates.h
+++ test/std/containers/set_allocator_requirement_test_templates.h
@@ -128,7 +128,7 @@
 CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&");
 Container c;
 ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) };
-cc->expect(3);
+cc->expect(3);
 c.insert(std::begin(ValueList), std::end(ValueList));
 assert(!cc->unchecked());
 {
Index: test/std/containers/map_allocator_requirement_test_templates.h
===
--- test/std/containers/map_allocator_requirement_test_templates.h
+++ test/std/containers/map_allocator_requirement_test_templates.h
@@ -51,7 +51,7 @@
 CHECKPOINT("Testing C::insert(value_type&)");
 Container c;
 ValueTp v(42, 1);
-cc->expect();
+cc->expect();
 assert(c.insert(v).second);
 assert(!cc->u

[PATCH] D61365: [libcxx] [test] Suppress float->int narrowing warning in vector range-construction test.

2019-05-01 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal created this revision.
BillyONeal added reviewers: mclow.lists, EricWF, ldionne.
Herald added a subscriber: dexonsmith.

https://reviews.llvm.org/D61365

Files:
  test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp


Index: 
test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
===
--- 
test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ 
test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -156,6 +156,7 @@
 // Make sure initialization is performed with each element value, not with
 // a memory blob.
 float array[3] = {0.0f, 1.0f, 2.0f};
+#pragma warning(suppress: 4244) // narrowing float to int
 std::vector v(array, array + 3);
 assert(v[0] == 0);
 assert(v[1] == 1);


Index: test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
===
--- test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
+++ test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp
@@ -156,6 +156,7 @@
 // Make sure initialization is performed with each element value, not with
 // a memory blob.
 float array[3] = {0.0f, 1.0f, 2.0f};
+#pragma warning(suppress: 4244) // narrowing float to int
 std::vector v(array, array + 3);
 assert(v[0] == 0);
 assert(v[1] == 1);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61366: [libcxx] [test] Don't assert that moved-from containers with non-POCMA allocators are empty.

2019-05-01 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal created this revision.
BillyONeal added reviewers: mclow.lists, EricWF, ldionne.
Herald added a subscriber: dexonsmith.

The standard only requires that moved-from standard library types are in a 
'valid but unspecified state', not that any moved-from container is empty. When 
the container is using a POCMA allocator, asserting that the moved-from 
container is empty is reasonable because the target container needs to take 
ownership of the memory buffers allocated from the source container's 
allocator. However, when the allocator is non-POCMA, the destination container 
must not take over any buffers, and effectively must copy the contents of the 
source container.

In the MSVC++ implementation, in this non-POCMA case, we do not clear() the 
source container, so that subsequent operations can reuse memory if the 
container is not immediately destroyed.


https://reviews.llvm.org/D61366

Files:
  test/std/containers/associative/map/map.cons/move_assign.pass.cpp
  test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
  test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
  test/std/containers/associative/set/set.cons/move_assign.pass.cpp


Index: test/std/containers/associative/set/set.cons/move_assign.pass.cpp
===
--- test/std/containers/associative/set/set.cons/move_assign.pass.cpp
+++ test/std/containers/associative/set/set.cons/move_assign.pass.cpp
@@ -100,7 +100,7 @@
 assert(m3 == m2);
 assert(m3.get_allocator() == A(5));
 assert(m3.key_comp() == C(5));
-assert(m1.empty());
+LIBCPP_ASSERT(m1.empty());
 }
 {
 typedef MoveOnly V;
Index: 
test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
===
--- test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
+++ test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
@@ -100,7 +100,7 @@
 assert(m3 == m2);
 assert(m3.get_allocator() == A(5));
 assert(m3.key_comp() == C(5));
-assert(m1.empty());
+LIBCPP_ASSERT(m1.empty());
 }
 {
 typedef MoveOnly V;
Index: 
test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
===
--- test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
+++ test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
@@ -102,7 +102,7 @@
 assert(m3 == m2);
 assert(m3.get_allocator() == A(5));
 assert(m3.key_comp() == C(5));
-assert(m1.empty());
+LIBCPP_ASSERT(m1.empty());
 }
 {
 typedef std::pair V;
Index: test/std/containers/associative/map/map.cons/move_assign.pass.cpp
===
--- test/std/containers/associative/map/map.cons/move_assign.pass.cpp
+++ test/std/containers/associative/map/map.cons/move_assign.pass.cpp
@@ -102,7 +102,7 @@
 assert(m3 == m2);
 assert(m3.get_allocator() == A(5));
 assert(m3.key_comp() == C(5));
-assert(m1.empty());
+LIBCPP_ASSERT(m1.empty());
 }
 {
 typedef std::pair V;


Index: test/std/containers/associative/set/set.cons/move_assign.pass.cpp
===
--- test/std/containers/associative/set/set.cons/move_assign.pass.cpp
+++ test/std/containers/associative/set/set.cons/move_assign.pass.cpp
@@ -100,7 +100,7 @@
 assert(m3 == m2);
 assert(m3.get_allocator() == A(5));
 assert(m3.key_comp() == C(5));
-assert(m1.empty());
+LIBCPP_ASSERT(m1.empty());
 }
 {
 typedef MoveOnly V;
Index: test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
===
--- test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
+++ test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp
@@ -100,7 +100,7 @@
 assert(m3 == m2);
 assert(m3.get_allocator() == A(5));
 assert(m3.key_comp() == C(5));
-assert(m1.empty());
+LIBCPP_ASSERT(m1.empty());
 }
 {
 typedef MoveOnly V;
Index: test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
===
--- test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
+++ test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp
@@ -102,7 +102,7 @@
 assert(m3 == m2);
 assert(m3.get_allocator() == A(5));
 assert(m3.key_comp() == C(5));
-assert(m1.empty());
+LIBCPP_ASSERT(m1.empty());
 }
 {
 typedef std::pair V;
Index: test

[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer

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

I would suggest an IR test, especially since what you want to achieve is 
addrspacecast in IR output. We use AST dump only if there is no other good way 
to test something. In fact we already have a test with similar logic that tests 
various OpenCL address spaces: test/CodeGenOpenCLCXX/addrspace-of-this.cl. I 
think it should be reasonable enough to extend it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61319



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


[PATCH] D61318: [Sema] Prevent binding references with mismatching address spaces to temporaries

2019-05-01 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked an inline comment as done.
Anastasia added inline comments.



Comment at: lib/Sema/SemaInit.cpp:4836
+  if (T1Quals.hasAddressSpace()) {
+if (!T1Quals.isAddressSpaceSupersetOf(cv1T1IgnoreAS.getQualifiers())) {
+  Sequence.SetFailed(

rjmccall wrote:
> Isn't `cv1T1IgnoreAS.getQualifiers()` always `LangAS::Default`?
Yes, this is true currently. However, we don't have an overload of 
`isAddressSpaceSupersetOf` that takes `LangAS` as a parameter. Are you 
suggesting to add it?


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

https://reviews.llvm.org/D61318



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


[PATCH] D61304: [OpenCL][PR41609] Deduce static data members to __global addr space

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

In D61304#1485125 , @rjmccall wrote:

> Presumably a similar rule would apply to thread-locals if you supported them.


We don't support them in OpenCL.


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

https://reviews.llvm.org/D61304



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


r359662 - Change llvm-{objdump, readobj} -long-option to --long-option or well-known short options in tests. NFC

2019-05-01 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May  1 02:30:45 2019
New Revision: 359662

URL: http://llvm.org/viewvc/llvm-project?rev=359662&view=rev
Log:
Change llvm-{objdump,readobj} -long-option to --long-option or well-known short 
options in tests. NFC

Modified:
cfe/trunk/test/CodeGen/split-debug-filename.c
cfe/trunk/test/CodeGen/split-debug-single-file.c
cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
cfe/trunk/test/Driver/as-dwarf-cie.s
cfe/trunk/test/Driver/embed-bitcode.s
cfe/trunk/test/Modules/pch_container.m

Modified: cfe/trunk/test/CodeGen/split-debug-filename.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-debug-filename.c?rev=359662&r1=359661&r2=359662&view=diff
==
--- cfe/trunk/test/CodeGen/split-debug-filename.c (original)
+++ cfe/trunk/test/CodeGen/split-debug-filename.c Wed May  1 02:30:45 2019
@@ -1,8 +1,8 @@
 // REQUIRES: x86-registered-target
 // RUN: %clang_cc1 -debug-info-kind=limited -split-dwarf-file foo.dwo -S 
-emit-llvm -o - %s | FileCheck %s
 // RUN: %clang_cc1 -debug-info-kind=limited -enable-split-dwarf 
-split-dwarf-file foo.dwo -S -emit-llvm -o - %s | FileCheck 
--check-prefix=VANILLA %s
-// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited 
-enable-split-dwarf -split-dwarf-file %t.dwo -emit-obj -o - %s | llvm-objdump 
-section-headers - | FileCheck --check-prefix=O %s
-// RUN: llvm-objdump -section-headers %t.dwo | FileCheck --check-prefix=DWO %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux -debug-info-kind=limited 
-enable-split-dwarf -split-dwarf-file %t.dwo -emit-obj -o - %s | llvm-readobj 
-S - | FileCheck --check-prefix=O %s
+// RUN: llvm-readobj -S %t.dwo | FileCheck --check-prefix=DWO %s
 
 int main (void) {
   return 0;

Modified: cfe/trunk/test/CodeGen/split-debug-single-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/split-debug-single-file.c?rev=359662&r1=359661&r2=359662&view=diff
==
--- cfe/trunk/test/CodeGen/split-debug-single-file.c (original)
+++ cfe/trunk/test/CodeGen/split-debug-single-file.c Wed May  1 02:30:45 2019
@@ -3,13 +3,13 @@
 // Testing to ensure -enable-split-dwarf=single allows to place .dwo sections 
into regular output object.
 //  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
 //  RUN:   -enable-split-dwarf=single -split-dwarf-file %t.o -emit-obj -o %t.o 
%s
-//  RUN: llvm-objdump -section-headers %t.o | FileCheck 
--check-prefix=MODE-SINGLE %s
+//  RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SINGLE %s
 //  MODE-SINGLE: .dwo
 
 // Testing to ensure -enable-split-dwarf=split does not place .dwo sections 
into regular output object.
 //  RUN: %clang_cc1 -debug-info-kind=limited -triple x86_64-unknown-linux \
 //  RUN:   -enable-split-dwarf=split -split-dwarf-file %t.o -emit-obj -o %t.o 
%s
-//  RUN: llvm-objdump -section-headers %t.o | FileCheck 
--check-prefix=MODE-SPLIT %s
+//  RUN: llvm-readobj -S %t.o | FileCheck --check-prefix=MODE-SPLIT %s
 //  MODE-SPLIT-NOT: .dwo
 
 int main (void) {

Modified: cfe/trunk/test/CodeGen/thinlto-split-dwarf.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto-split-dwarf.c?rev=359662&r1=359661&r2=359662&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto-split-dwarf.c (original)
+++ cfe/trunk/test/CodeGen/thinlto-split-dwarf.c Wed May  1 02:30:45 2019
@@ -12,8 +12,8 @@
 // RUN:   -emit-obj -fthinlto-index=%t.o.thinlto.bc \
 // RUN:   -o %t.native.o -split-dwarf-file %t.native.dwo -x ir %t.o
 
-// RUN: llvm-readobj -sections %t.native.o | FileCheck --check-prefix=O %s
-// RUN: llvm-readobj -sections %t.native.dwo | FileCheck --check-prefix=DWO %s
+// RUN: llvm-readobj -S %t.native.o | FileCheck --check-prefix=O %s
+// RUN: llvm-readobj -S %t.native.dwo | FileCheck --check-prefix=DWO %s
 
 // O-NOT: .dwo
 // DWO: .dwo

Modified: cfe/trunk/test/Driver/as-dwarf-cie.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/as-dwarf-cie.s?rev=359662&r1=359661&r2=359662&view=diff
==
--- cfe/trunk/test/Driver/as-dwarf-cie.s (original)
+++ cfe/trunk/test/Driver/as-dwarf-cie.s Wed May  1 02:30:45 2019
@@ -1,7 +1,7 @@
 # REQUIRES: x86-registered-target
 # Test that there is a sane default CIE version.
 # RUN: %clang -cc1as -triple i386-apple-darwin -filetype obj %s -o %t
-# RUN: llvm-objdump -dwarf=frames %t | FileCheck %s
+# RUN: llvm-objdump --dwarf=frames %t | FileCheck %s
 # CHECK: .debug_frame contents:
 # CHECK: CIE
 # CHECK: Version:   1

Modified: cfe/trunk/test/Driver/embed-bitcode.s
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/embed-bitcode.s?rev=359662&r1=359661&r2=359662&view=diff

[PATCH] D61297: [clang-format] Fix bug that misses some function-like macro usages

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

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D61297



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


[PATCH] D61281: [clang-format] Fixed self assignment

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

Did this case some issue? Does this fix something if so can we add a test, 
because maybe the line isn't needed


Repository:
  rC Clang

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

https://reviews.llvm.org/D61281



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


[PATCH] D61276: [clang-format] Fix bug in block comment reflow that joins * and /

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

Thanks for the patch, is this case only limited to *


Repository:
  rC Clang

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

https://reviews.llvm.org/D61276



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


[PATCH] D61256: [clang-format][docs] Fix the Google C++ and Chromium style guide URLs

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

Thanks for the patch, thanks also for changing to https as I believe this was a 
change suggested in clang tidy docs too


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61256



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


[PATCH] D61370: Add a C2x mode and allow attributes in it

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, dblaikie.

WG14 has a working draft for C2x (WG14 N2346) and we've begun voting new 
features into it, so I think it's time for use to expose a C2x flag and use it. 
The new features we adopted this week that Clang already has support for are: 
the new attribute syntax (WG14 N2335), the `[[nodiscard]]` attribute (WG14 
N2267), the `[[maybe_unused]]` attribute (WG14 N2270), and the `[[deprecated]]` 
attribute (WG14 N2334).

This patch adds the new C2x language mode and flips a switch to allow 
double-square bracket attributes in that new mode.


https://reviews.llvm.org/D61370

Files:
  include/clang/Basic/LangOptions.def
  include/clang/Frontend/LangStandard.h
  include/clang/Frontend/LangStandards.def
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/unknown-std.c
  test/Parser/c2x-attributes.c
  test/Sema/attr-cx2.c
  test/Sema/attr-deprecated-c2x.c
  test/Sema/c2x-maybe_unused-errors.c
  test/Sema/c2x-maybe_unused.c
  test/Sema/c2x-nodiscard.c

Index: test/Sema/c2x-nodiscard.c
===
--- test/Sema/c2x-nodiscard.c
+++ test/Sema/c2x-nodiscard.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=c2x -verify %s
 
 struct [[nodiscard]] S1 { // ok
   int i;
Index: test/Sema/c2x-maybe_unused.c
===
--- test/Sema/c2x-maybe_unused.c
+++ test/Sema/c2x-maybe_unused.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
 
 struct [[maybe_unused]] S1 { // ok
   int a [[maybe_unused]];
Index: test/Sema/c2x-maybe_unused-errors.c
===
--- test/Sema/c2x-maybe_unused-errors.c
+++ test/Sema/c2x-maybe_unused-errors.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -Wunused -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -Wunused -std=c2x -verify %s
 
 struct [[maybe_unused]] S1 { // ok
   int a [[maybe_unused]];
Index: test/Sema/attr-deprecated-c2x.c
===
--- test/Sema/attr-deprecated-c2x.c
+++ test/Sema/attr-deprecated-c2x.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 %s -verify -fsyntax-only -fdouble-square-bracket-attributes
+// RUN: %clang_cc1 %s -verify -fsyntax-only --std=c2x
 
 int f() [[deprecated]]; // expected-note 2 {{'f' has been explicitly marked deprecated here}}
 void g() [[deprecated]];// expected-note {{'g' has been explicitly marked deprecated here}}
Index: test/Sema/attr-cx2.c
===
--- test/Sema/attr-cx2.c
+++ test/Sema/attr-cx2.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -fdouble-square-bracket-attributes %s
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fsyntax-only -verify -std=c2x %s
 
 struct S {};
 struct S * [[clang::address_space(1)]] Foo;
Index: test/Parser/c2x-attributes.c
===
--- test/Parser/c2x-attributes.c
+++ test/Parser/c2x-attributes.c
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -fdouble-square-bracket-attributes -verify %s
+// RUN: %clang_cc1 -fsyntax-only -std=gnu2x -verify %s
 
 enum [[]] E {
   One [[]],
Index: test/Driver/unknown-std.c
===
--- test/Driver/unknown-std.c
+++ test/Driver/unknown-std.c
@@ -16,6 +16,8 @@
 // CHECK-NEXT: note: use 'gnu11' for 'ISO C 2011 with GNU extensions' standard
 // CHECK-NEXT: note: use 'c17', 'iso9899:2017', 'c18', or 'iso9899:2018' for 'ISO C 2017' standard
 // CHECK-NEXT: note: use 'gnu17' or 'gnu18' for 'ISO C 2017 with GNU extensions' standard
+// CHECK-NEXT: note: use 'c2x' for 'Working Draft for ISO C2x' standard
+// CHECK-NEXT: note: use 'gnu2x' for 'Working Draft for ISO C2x with GNU extensions' standard
 
 // Make sure that no other output is present.
 // CHECK-NOT: {{^.+$}}
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -2118,6 +2118,7 @@
   Opts.C99 = Std.isC99();
   Opts.C11 = Std.isC11();
   Opts.C17 = Std.isC17();
+  Opts.C2x = Std.isC2x();
   Opts.CPlusPlus = Std.isCPlusPlus();
   Opts.CPlusPlus11 = Std.isCPlusPlus11();
   Opts.CPlusPlus14 = Std.isCPlusPlus14();
@@ -2589,10 +2590,10 @@
   Opts.BlocksRuntimeOptional = Args.hasArg(OPT_fblocks_runtime_optional);
   Opts.Coroutines = Opts.CPlusPlus2a || Args.hasArg(OPT_fcoroutines_ts);
 
-  // Enable [[]] attributes in C++11 by default.
-  Opts.DoubleSquareBracketAttributes =
-  Args.hasFlag(OPT_fdouble_square_bracket_attributes,
-   OPT_fn

[PATCH] D61097: [Sema] Emit warning for visibility attribute on internal-linkage declaration

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: lib/Sema/SemaDeclAttr.cpp:2621
+if (!ND->isExternallyVisible()) {
+  S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
+  return;

scott.linder wrote:
> aaron.ballman wrote:
> > I think it would be more helpful for users if we introduced a new 
> > diagnostic here that explained why the attribute is being ignored, 
> > otherwise the diagnostic is somewhat indecipherable.
> Sure, I am amenable to anything here. GCC uses the same short message, but it 
> does seem to indicate e.g. that the keyword `static` played some role by 
> using additional source ranges. I don't know how we would go about that with 
> the Sema/AST split? We could just go with a more explicit message. Do you 
> have any thoughts on the wording?
> 
> ```
> warning: 'visibility' attribute ignored on non-external symbol
> ```
Your suggested diagnostic text seems pretty close to me, but how about: 
`'visibility' attribute is ignore on a non-external symbol` in the 
`IgnoredAttributes` group.



Comment at: lib/Sema/SemaDeclAttr.cpp:2622
+  S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
+  return;
+}

scott.linder wrote:
> aaron.ballman wrote:
> > We shouldn't early return here (it's not an error, just a warning), so that 
> > the other diagnostics can also trigger if needed.
> Should I also fix the other early-return-on-warning's in the same function, 
> e.g. the function begins with:
> 
> ```
> // Visibility attributes don't mean anything on a typedef.
> if (isa(D)) {
>   S.Diag(AL.getRange().getBegin(), diag::warn_attribute_ignored) << AL;
>   return;
> }
> ```
> 
> I suppose the difference is that the attribute "can" be placed on the symbol 
> in this case, but it is ignored just the same.
That might be worth fixing as well, but as a separate patch because it's also 
kind of unrelated to the functionality in this patch. Good catch!


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

https://reviews.llvm.org/D61097



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


[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-05-01 Thread Tyker via Phabricator via cfe-commits
Tyker added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:2579
+assert(
+!ES.getExpr() ||
+CXXConstructorDeclBits.HasTrailingExplicitSpecifier &&

Rakete wrote:
> Your or needs parens or the disambiguation is wrong.
i don't understand. but there is no need for disambiguation, `a && true == a` 
so this will work regardless of operator priority.



Comment at: clang/include/clang/Serialization/ASTReader.h:2435
+uint64_t Kind = readInt();
+bool hasExpr = Kind & 0x1;
+Kind = Kind >> 1;

Rakete wrote:
> same here.
what is the issue



Comment at: clang/lib/Sema/SemaInit.cpp:9361
 // Only consider converting constructors.
-if (GD->isExplicit())
+if (!GD->isMaybeNotExplicit())
   continue;

rsmith wrote:
> Tyker wrote:
> > rsmith wrote:
> > > Tyker wrote:
> > > > rsmith wrote:
> > > > > We need to substitute into the deduction guide first to detect 
> > > > > whether it forms a "converting constructor", and that will need to be 
> > > > > done inside `AddTemplateOverloadCandidate`.
> > > > similarly as the previous if. this check removes deduction guide that 
> > > > are already resolve to be explicit when we are in a context that 
> > > > doesn't allow explicit.
> > > > every time the explicitness was checked before my change i replaced it 
> > > > by a check that removes already resolved explicit specifiers.
> > > Unlike in the previous case, we do //not// yet pass an `AllowExplicit` 
> > > flag into `AddTemplateOverloadCandidate` here, so this will incorrectly 
> > > allow dependent //explicit-specifier//s that evaluate to `true` in 
> > > copy-initialization contexts.
> > the default value for `AllowExplicit` is false. so the conversion will be 
> > removed in `AddTemplateOverloadCandidate`.
> That doesn't sound right: that'd mean we never use explicit deduction guides 
> (we never pass `AllowExplicit = true` to `AddTemplateOverloadCandidate`). Do 
> we have any test coverage that demonstrates that conditionally-explicit 
> deduction guides are handled properly?
my mistake. the default value for AllowExplicit is false. but 
AddTemplateOverloadCandidate will only remove conversions and constructors. 
dependent explicit specifier that are resolved to true on deduction guides are 
removed at line 9480. they are not removed from the overload set. CTAD just 
fails if a explicit deduction guide is selected in a CopyInitList. i agree this 
is weird but the behavior is the same as before the patch.
the result on clang is:
```
template
struct A {
  explicit A(T);
};
A a = 0; // error with explicit constructor meaning CTAD succeed.
A a = { 0 }; // error with explicit deduction guide
```
all compiler don't agree on this https://godbolt.org/z/ElHlkE. icc and clang 
have this behavior, gcc and msvc fail at CTAD time on both initialization. as 
of what the standard say from what i read, it isn't clear, the standard is 
clear when calling an explicit constructor should fail. but it doesn't appear 
to say for deduction guides.
as this was the previous behavior i did not change it with explicit(bool).



Comment at: clang/test/CXX/temp/temp.deduct.guide/p1.cpp:74
 virtual A(int(&)[28]) -> A; // expected-error {{'virtual' can only appear 
on non-static member functions}}
-const A(int(&)[28]) -> A; // expected-error {{deduction guide cannot be 
declared 'const'}}
+const A(int(&)[31]) -> A; // expected-error {{deduction guide cannot be 
declared 'const'}}
 

Rakete wrote:
> Is there a reason why you changed this?
yes. One of change that was made is making deduction guide redeclaration be an 
error. Without this change, this line was a redeclartion so the test didn't 
serve its purpose.


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

https://reviews.llvm.org/D60934



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


[PATCH] D61209: [clang-tidy] Fix readability-redundant-smartptr-get for MSVC STL

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

LGTM aside from a commenting nit.




Comment at: 
clang-tools-extra/clang-tidy/readability/RedundantSmartptrGetCheck.cpp:46
 
+  // Make sure we are not missing the known standard types
+  const auto Smartptr = anyOf(knownSmartptr(), QuacksLikeASmartptr);

Missing a full stop at the end of the comment.


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

https://reviews.llvm.org/D61209



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


[PATCH] D61260: [clang-tidy] Extend bugprone-sizeof-expression to check sizeof(pointers to structures)

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Aside from the testing request, this LGTM.




Comment at: test/clang-tidy/bugprone-sizeof-expression.cpp:231
+  sum += sizeof(MyStruct*);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 
'sizeof(A*)'; pointer to aggregate
+  sum += sizeof(PMyStruct);

whisperity wrote:
> Why is this printed at `sizeof(A*)`? Do we not print the name of the actual 
> type used in the expression?
The original check did this, so it's not really new behavior here. I don't 
recall the rationale off the top of my head, but I'd guess it's because the 
type is not really salient, but the fact that the type is a pointer is.


Repository:
  rCTE Clang Tools Extra

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

https://reviews.llvm.org/D61260



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


[PATCH] D61222: [clang-format] Fix a bug in AlignConsecutiveDeclarations

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

LGTM


Repository:
  rC Clang

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

https://reviews.llvm.org/D61222



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


[PATCH] D58404: [clang-format] Add basic support for formatting C# files

2019-05-01 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: lib/Format/FormatTokenLexer.cpp:249
+  Identifier->ColumnWidth += Question->ColumnWidth;
+  Identifier->Type = Identifier->Type;
+  Tokens.erase(Tokens.end() - 1);

RKSimon wrote:
> @MyDeveloperDay Should this be
> ```
> Identifier->Type = Question->Type;
> ```
> Reported in https://www.viva64.com/en/b/0629/
I think most likely  I want to keep it as an identifier so we are treating arg? 
as arg

I feel like this line is probably not needed, there is a review for this.. 
{D61281}


Repository:
  rC Clang

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

https://reviews.llvm.org/D58404



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


[PATCH] D59702: Unbreak the build of compiler-rt on Linux/mips64el

2019-05-01 Thread Sylvestre Ledru via Phabricator via cfe-commits
sylvestre.ledru added a comment.

@atanasyan, I tried with

  -DCMAKE_C_FLAGS="-mabi=32"
  -DCMAKE_CXX_FLAGS="-mabi=32"

but it still fails with:

  cd /<>/build-llvm/projects/compiler-rt/lib/sanitizer_common && 
/usr/bin/g++-8  -DHAVE_RPC_XDR_H=1 -D_GNU_SOURCE -D__STDC_CONSTANT_MACROS 
-D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS 
-I/<>/build-llvm/projects/compiler-rt/lib/sanitizer_common 
-I/<>/projects/compiler-rt/lib/sanitizer_common 
-I/<>/build-llvm/include -I/<>/include 
-I/<>/projects/compiler-rt/lib/sanitizer_common/..  -g -O2 
-fdebug-prefix-map=/<>=. -fstack-protector-strong -Wformat 
-Werror=format-security -fPIC -fvisibility-inlines-hidden -Werror=date-time 
-std=c++11 -Wall -Wextra -Wno-unused-parameter -Wwrite-strings -Wcast-qual 
-Wno-missing-field-initializers -pedantic -Wno-long-long -Wimplicit-fallthrough 
-Wno-maybe-uninitialized -Wno-class-memaccess -Wno-noexcept-type 
-Wdelete-non-virtual-dtor -Wno-comment -ffunction-sections -fdata-sections 
-Wall -std=c++11 -Wno-unused-parameter -O2 -DNDEBUG -g1-mips32r2 -mabi=32 
-fPIC -fno-builtin -fno-exceptions -fomit-frame-pointer -funwind-tables 
-fno-stack-protector -fvisibility=hidden -fno-lto -O3 -g -Wno-variadic-macros 
-Wno-non-virtual-dtor -fno-rtti -o 
CMakeFiles/RTSanitizerCommon.mipsel.dir/sanitizer_platform_limits_linux.cc.o -c 
/<>/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc
  In file included from 
/<>/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc:22:
  
/<>/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:343:72:
 error: size of array 'assertion_failed__73' is negative
   typedef char IMPL_PASTE(assertion_failed_##_, line)[2*(int)(pred)-1]
  ^
  
/<>/projects/compiler-rt/lib/sanitizer_common/sanitizer_internal_defs.h:337:30:
 note: in expansion of macro 'IMPL_COMPILER_ASSERT'
   #define COMPILER_CHECK(pred) IMPL_COMPILER_ASSERT(pred, __LINE__)
^~~~
  
/<>/projects/compiler-rt/lib/sanitizer_common/sanitizer_platform_limits_linux.cc:73:1:
 note: in expansion of macro 'COMPILER_CHECK'
   COMPILER_CHECK(struct_kernel_stat_sz == sizeof(struct stat));
   ^~

Full log:
https://buildd.debian.org/status/fetch.php?pkg=llvm-toolchain-8&arch=mips64el&ver=1%3A8-4&stamp=1556705174&raw=0
better idea? :)


Repository:
  rCRT Compiler Runtime

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

https://reviews.llvm.org/D59702



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


[clang-tools-extra] r359674 - [clangd] Delete an unused declaration

2019-05-01 Thread Fangrui Song via cfe-commits
Author: maskray
Date: Wed May  1 05:16:37 2019
New Revision: 359674

URL: http://llvm.org/viewvc/llvm-project?rev=359674&view=rev
Log:
[clangd] Delete an unused declaration

Modified:
clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp

Modified: clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp?rev=359674&r1=359673&r2=359674&view=diff
==
--- clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp (original)
+++ clang-tools-extra/trunk/clangd/index/BackgroundIndexStorage.cpp Wed May  1 
05:16:37 2019
@@ -137,9 +137,6 @@ public:
 return IndexStorage.get();
   }
 
-  // Creates or fetches to storage from cache for the specified CDB.
-  BackgroundIndexStorage *createStorage(llvm::StringRef CDBDirectory);
-
 private:
   std::unique_ptr create(llvm::StringRef CDBDirectory) 
{
 if (CDBDirectory.empty())


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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/Index/print-type-size.c:22
+
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+// CHECK: FieldDecl=size:2:9 (Definition) [type=int] [typekind=Int] [sizeof=4] 
[alignof=4] [offsetof=0]

This should be the first line of the file. I don't have strong opinions on 
where the CHECK lines go, but I usually prefer seeing them near the construct 
being checked.



Comment at: test/Index/print-type-size.c:31
+// CHECK: FieldDecl=data2:18:15 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
\ No newline at end of file


Please add a newline to the end of the file.



Comment at: tools/libclang/CXType.cpp:898
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (QT->isIncompleteType() && !QT->isIncompleteArrayType()) // IAT is okay 
here
 return CXTypeLayoutError_Incomplete;

I don't think IAT is a common enough acronym to use; I'd probably just drop the 
comment as it adds little value.



Comment at: tools/libclang/CXType.cpp:956
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (FQT->isIncompleteType() && !FQT->isIncompleteArrayType()) // IAT is 
okay here
   return CXTypeLayoutError_Incomplete;

Same here.



Comment at: tools/libclang/CXType.cpp:956
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (FQT->isIncompleteType() && !FQT->isIncompleteArrayType()) // IAT is 
okay here
   return CXTypeLayoutError_Incomplete;

aaron.ballman wrote:
> Same here.
I sort of wonder whether we want a helper function like 
`isTypeIncompleteForLayout()` or something, and then using that helper directly.


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

https://reviews.llvm.org/D61239



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


[PATCH] D59520: [WebAssembly] Address review comments on r352930

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang/Basic/DiagnosticIDs.h:39
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_SEMA  = 3504,
   DIAG_SIZE_ANALYSIS  =  100,

I think this should be a separate commit, and I'd recommend updating it to 
`4000` to give ourselves more wiggle room.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:9649-9656
+def warn_mismatched_import_module : Warning<
+  "import module does not match previous declaration">;
+def warn_mismatched_import_name : Warning<
+  "import name does not match previous declaration">;
+def warn_import_module_on_definition : Warning<
+  "import module cannot be applied to a function with a definition">;
+def warn_import_name_on_definition : Warning<

How about: `"import %select{module|name}0 does not match previous declaration"` 
and `"import %select{module|name}0 cannot be applied to a function with a 
definition"`?



Comment at: include/clang/Sema/Sema.h:2616-2621
+  WebAssemblyImportNameAttr *mergeImportNameAttr(
+  Decl *D, SourceRange Range, StringRef Name,
+  unsigned AttrSpellingListIndex);
+  WebAssemblyImportModuleAttr *mergeImportModuleAttr(
+  Decl *D, SourceRange Range, StringRef Name,
+  unsigned AttrSpellingListIndex);

I'd rather see the typical pattern used here: one taking a `ParsedAttr` and the 
other taking a semantic attribute.



Comment at: lib/Sema/SemaDeclAttr.cpp:5764-5765
+
+  if (WebAssemblyImportModuleAttr *ExistingAttr =
+  FD->getAttr()) {
+if (ExistingAttr->getImportModule() == Name)

`const auto *`



Comment at: lib/Sema/SemaDeclAttr.cpp:5769
+Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import_module);
+Diag(Range.getBegin(), diag::note_previous_attribute);
+return nullptr;

I don't see anything testing this note or the preceding warning, can you add 
some tests that exercise it?



Comment at: lib/Sema/SemaDeclAttr.cpp:5773
+  if (FD->hasBody()) {
+Diag(Range.getBegin(), diag::warn_import_module_on_definition);
+return nullptr;

I don't see any tests for this either.



Comment at: lib/Sema/SemaDeclAttr.cpp:5781-5783
+Sema::mergeImportNameAttr(Decl *D, SourceRange Range,
+  StringRef Name,
+  unsigned AttrSpellingListIndex) {

I wonder if we want to generalize this with a template (for the attribute type) 
if we could generalize the diagnostic text a bit more (or add an additional 
parameter for it)?



Comment at: lib/Sema/SemaDeclAttr.cpp:5786-5787
+
+  if (WebAssemblyImportNameAttr *ExistingAttr =
+  FD->getAttr()) {
+if (ExistingAttr->getImportName() == Name)

`const auto *`



Comment at: lib/Sema/SemaDeclAttr.cpp:5790-5791
+  return nullptr;
+Diag(ExistingAttr->getLocation(), diag::warn_mismatched_import_name);
+Diag(Range.getBegin(), diag::note_previous_attribute);
+return nullptr;

Missing tests.



Comment at: lib/Sema/SemaDeclAttr.cpp:5795
+  if (FD->hasBody()) {
+Diag(Range.getBegin(), diag::warn_import_name_on_definition);
+return nullptr;

Missing tests.


Repository:
  rC Clang

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

https://reviews.llvm.org/D59520



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


[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

2019-05-01 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 marked an inline comment as done.
xbolva00 added inline comments.



Comment at: include/clang/Basic/DiagnosticIDs.h:39
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_SEMA  = 3600,
   DIAG_SIZE_ANALYSIS  =  100,

riccibruno wrote:
> xbolva00 wrote:
> > @rsmith  maybe this should be a separate patch? I hit this limit in this 
> > patch.
> Is there any downside to just bumping it to, say, 4000 ?
I think it is fine to bump it more..


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

https://reviews.llvm.org/D61288



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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee updated this revision to Diff 197532.
JornVernee marked 2 inline comments as done.
JornVernee added a comment.

- Restructured test source file to put CHECK comments inline
- Removed IAT comments.

- holding of on adding helper method until hearing back.


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

https://reviews.llvm.org/D61239

Files:
  test/Index/print-type-size.c
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -895,7 +895,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (QT->isIncompleteType() && !QT->isIncompleteArrayType())
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -953,7 +953,7 @@
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (FQT->isIncompleteType() && !FQT->isIncompleteArrayType())
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,30 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+int size;
+// CHECK: FieldDecl=size:4:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+void* data[];
+// CHECK: FieldDecl=data:6:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+int size;
+// CHECK: FieldDecl=size:11:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+struct {
+int dummy;
+// CHECK: FieldDecl=dummy:14:13 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=64/0]
+void* data[];
+// CHECK: FieldDecl=data:16:15 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=128/64]
+};
+};
+
+struct Baz {
+int size;
+// CHECK: FieldDecl=size:22:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+union {
+void* data1[];
+// CHECK: FieldDecl=data1:25:15 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+void* data2[];
+// CHECK: FieldDecl=data2:27:15 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+};
+};


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -895,7 +895,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (QT->isIncompleteType() && !QT->isIncompleteArrayType())
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -953,7 +953,7 @@
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (FQT->isIncompleteType() && !FQT->isIncompleteArrayType())
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,30 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+int size;
+// CHECK: FieldDecl=size:4:9 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+void* data[];
+// CHECK: FieldDecl=data:6:11 (Definition) [type=void *[]] [typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+int size;
+// CHECK: FieldDecl=size:11:9 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+struct {
+int dummy;
+// CHECK: FieldDecl=dummy:14:13 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=64/0]
+void* data[];
+// CHECK: FieldDecl=data:16:15 (Definition) [type=void *[]] [typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=128/64]
+};
+};
+
+struct Baz {
+int size;
+// CHECK: FieldDecl=size:22:9 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+union {
+void* data1[];
+// CHECK: FieldDecl=data1:25:15 (Definition) [type=void *[]] [typekind=Incomplete

[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee updated this revision to Diff 197533.
JornVernee added a comment.

Add forgotten newline


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

https://reviews.llvm.org/D61239

Files:
  test/Index/print-type-size.c
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -895,7 +895,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (QT->isIncompleteType() && !QT->isIncompleteArrayType())
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -953,7 +953,7 @@
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (FQT->isIncompleteType() && !FQT->isIncompleteArrayType())
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+int size;
+// CHECK: FieldDecl=size:4:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+void* data[];
+// CHECK: FieldDecl=data:6:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+int size;
+// CHECK: FieldDecl=size:11:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+struct {
+int dummy;
+// CHECK: FieldDecl=dummy:14:13 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=64/0]
+void* data[];
+// CHECK: FieldDecl=data:16:15 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=128/64]
+};
+};
+
+struct Baz {
+int size;
+// CHECK: FieldDecl=size:22:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+union {
+void* data1[];
+// CHECK: FieldDecl=data1:25:15 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+void* data2[];
+// CHECK: FieldDecl=data2:27:15 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+};
+};
+


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -895,7 +895,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (QT->isIncompleteType() && !QT->isIncompleteArrayType())
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -953,7 +953,7 @@
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (FQT->isIncompleteType() && !FQT->isIncompleteArrayType())
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+int size;
+// CHECK: FieldDecl=size:4:9 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+void* data[];
+// CHECK: FieldDecl=data:6:11 (Definition) [type=void *[]] [typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+int size;
+// CHECK: FieldDecl=size:11:9 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+struct {
+int dummy;
+// CHECK: FieldDecl=dummy:14:13 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=64/0]
+void* data[];
+// CHECK: FieldDecl=data:16:15 (Definition) [type=void *[]] [typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=128/64]
+};
+};
+
+struct Baz {
+int size;
+// CHECK: FieldDecl=size:22:9 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+union {
+void* data1[];
+// CHECK: FieldDecl=data1:25:15 (Definition) [type=void *[]] [typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+void* data2[];
+// CHECK: FieldDecl=data2:27:15 (Definition) [type=void *[]] [typekind=IncompleteArr

[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

Do we have evidence of false positive vs true positive rates for this catching 
actual problems in real world code? I realize that this is for GCC 
compatibility, but because it's default-off, I'm wondering where the utilities 
lies.




Comment at: include/clang/Basic/DiagnosticIDs.h:39
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_SEMA  = 3600,
   DIAG_SIZE_ANALYSIS  =  100,

xbolva00 wrote:
> riccibruno wrote:
> > xbolva00 wrote:
> > > @rsmith  maybe this should be a separate patch? I hit this limit in this 
> > > patch.
> > Is there any downside to just bumping it to, say, 4000 ?
> I think it is fine to bump it more..
I think it should be done in a separate patch, and I agree that we should bump 
to 4000 for right now to give us some wiggle room.


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

https://reviews.llvm.org/D61288



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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D61239#1485994 , @JornVernee wrote:

> - holding of on adding helper method until hearing back.


My rationale for wanting a helper method is because we already have two places 
were incompleteness is important but has special cases. It's easier to maintain 
that with something that's a named function to explain what the predicate is 
actually doing. My concern is that we add another `isIncompleteType()` and not 
think about this issue.

Do we need this in `validateFieldParentType()`?


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

https://reviews.llvm.org/D61239



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


[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

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

Some coding guidelines may require switch to have always default label. Even if 
devs know that default is not reachable, they can add default: abort(); or 
assert to increase safety (and warning will be silenced).

Yes, it not suitable to be enabled by default, but I still think it is good to 
have it.


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

https://reviews.llvm.org/D61288



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


[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D61288#1486006 , @xbolva00 wrote:

> Some coding guidelines may require switch to have always default label. Even 
> if devs know that default is not reachable, they can add default: abort(); or 
> assert to increase safety (and warning will be silenced).
>
> Yes, it not suitable to be enabled by default, but I still think it is good 
> to have it.


We typically don't add new, default-off warnings because experience has shown 
that users don't enable them. The coding guidelines argument is somewhat 
persuasive, but I wonder whether this is better handled through clang-tidy 
checks rather than the compiler itself -- that's where we put other diagnostics 
that may not be suitable for the compiler. Have you thought about surfacing 
this functionality that way?


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

https://reviews.llvm.org/D61288



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


[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

2019-05-01 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D61288#1486008 , @aaron.ballman 
wrote:

> In D61288#1486006 , @xbolva00 wrote:
>
> > Some coding guidelines may require switch to have always default label. 
> > Even if devs know that default is not reachable, they can add default: 
> > abort(); or assert to increase safety (and warning will be silenced).
> >
> > Yes, it not suitable to be enabled by default, but I still think it is good 
> > to have it.
>
>
> We typically don't add new, default-off warnings because experience has shown 
> that users don't enable them. The coding guidelines argument is somewhat 
> persuasive, but I wonder whether this is better handled through clang-tidy 
> checks rather than the compiler itself -- that's where we put other 
> diagnostics that may not be suitable for the compiler. Have you thought about 
> surfacing this functionality that way?


I honestly have to agree. I think it would be best as a clang-tidy check, 
because i can fully envision the exact opposite guideline, "avoid `default` so 
you get notified about every switch that needs to be updated".


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

https://reviews.llvm.org/D61288



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


[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

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

I am not familiar with clang-tidy’s codebase and I personally prefer good 
compiler warnings than dependency on another tool (clang-tidy). I mean the 
cases when diagnostic check is easy to do in the compiler.

And in semaexpr we have all we need and it is simple to do it.

But if majority of reviewers disagree with compiler warning, I will close this 
revision.


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

https://reviews.llvm.org/D61288



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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee marked 4 inline comments as done.
JornVernee added a comment.

In D61239#1486005 , @aaron.ballman 
wrote:

> In D61239#1485994 , @JornVernee 
> wrote:
>
> > - holding of on adding helper method until hearing back.
>
>
> My rationale for wanting a helper method is because we already have two 
> places were incompleteness is important but has special cases. It's easier to 
> maintain that with something that's a named function to explain what the 
> predicate is actually doing. My concern is that we add another 
> `isIncompleteType()` and not think about this issue.
>
> Do we need this in `validateFieldParentType()`?


Thanks for the response, I misunderstood.

I usually go with naming my predicates in that way as well, but I misunderstood 
where you wanted to use it. I think adding the helper method for 
`validateFieldParentType()` is good. But, the check in 
`clang_Cursor_getAlignOf` is semantically different, since we basically want to 
check if the type has an alignment. (I actually realized we also need to check 
the element type for completeness in the case of incomplete arrays. Figuring 
that out now).




Comment at: test/Index/print-type-size.c:22
+
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+// CHECK: FieldDecl=size:2:9 (Definition) [type=int] [typekind=Int] [sizeof=4] 
[alignof=4] [offsetof=0]

aaron.ballman wrote:
> This should be the first line of the file. I don't have strong opinions on 
> where the CHECK lines go, but I usually prefer seeing them near the construct 
> being checked.
This style was taken from `print-type-size.cpp`, which also puts everything at 
the end. I'll put it at the front/inline instead (makes sense to me as well). I 
guess it's a legacy thing we're trying to move away from?



Comment at: tools/libclang/CXType.cpp:956
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (FQT->isIncompleteType() && !FQT->isIncompleteArrayType()) // IAT is 
okay here
   return CXTypeLayoutError_Incomplete;

aaron.ballman wrote:
> aaron.ballman wrote:
> > Same here.
> I sort of wonder whether we want a helper function like 
> `isTypeIncompleteForLayout()` or something, and then using that helper 
> directly.
Note that `clang_Type_getSizeOf` will (and AFAIK should) still return 
`CXTypeLayoutError_Incomplete` for incomplete arrays. I'd expect a potential 
`isTypeIncompleteForLayout()` to be used by all three functions (OffsetOf, 
SizeOf, AlignOf). So, I'm in favour of doing without such a helper method for 
the special OffsetOf and AlignOf cases.

It's a pretty unique case (but it appears a bunch of times in Windows API 
headers so we'd like to have support for it :) ).


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

https://reviews.llvm.org/D61239



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


[PATCH] D61288: [Diagnostics] Implemented support for -Wswitch-default

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D61288#1486034 , @xbolva00 wrote:

> I am not familiar with clang-tidy’s codebase and I personally prefer good 
> compiler warnings than dependency on another tool (clang-tidy). I mean the 
> cases when diagnostic check is easy to do in the compiler.
>
> And in semaexpr we have all we need and it is simple to do it.
>
> But if majority of reviewers disagree with compiler warning, I will close 
> this revision.


While it is easy to do in the compiler frontend, I am not yet convinced it's 
really worth having there compared to clang-tidy. FWIW, I'd be happy seeing it 
in clang-tidy.


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

https://reviews.llvm.org/D61288



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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee updated this revision to Diff 197543.
JornVernee marked an inline comment as done.
JornVernee added a comment.

- Replaced plane predicates with helper methods describing their function.
- Fixed test file indentation

Changing the logic for `clang_Type_getAlignOf` was not needed after all, since 
the use of incomplete type as array element type was already causing an error 
earlier on (so I think we can assume at that point it's safe?)


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

https://reviews.llvm.org/D61239

Files:
  test/Index/print-type-size.c
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -885,6 +885,10 @@
   return result;
 }
 
+static bool isIncompleteTypeWithAlignment(const QualType &QT) {
+  return QT->isIncompleteArrayType() || !QT->isIncompleteType();
+}
+
 long long clang_Type_getAlignOf(CXType T) {
   if (T.kind == CXType_Invalid)
 return CXTypeLayoutError_Invalid;
@@ -895,7 +899,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (!isIncompleteTypeWithAlignment(QT))
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -950,10 +954,14 @@
   return Ctx.getTypeSizeInChars(QT).getQuantity();
 }
 
+static bool isTypeIncompleteForLayout(const QualType &QT) {
+  return QT->isIncompleteType() && !QT->isIncompleteArrayType();
+}
+
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (isTypeIncompleteForLayout(FQT))
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+  int size;
+  // CHECK: FieldDecl=size:4:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  void* data[];
+  // CHECK: FieldDecl=data:6:9 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+  int size;
+  // CHECK: FieldDecl=size:11:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  struct {
+int dummy;
+// CHECK: FieldDecl=dummy:14:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=64/0]
+void* data[];
+// CHECK: FieldDecl=data:16:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=128/64]
+  };
+};
+
+struct Baz {
+  int size;
+  // CHECK: FieldDecl=size:22:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  union {
+void* data1[];
+// CHECK: FieldDecl=data1:25:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+void* data2[];
+// CHECK: FieldDecl=data2:27:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+  };
+};
+


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -885,6 +885,10 @@
   return result;
 }
 
+static bool isIncompleteTypeWithAlignment(const QualType &QT) {
+  return QT->isIncompleteArrayType() || !QT->isIncompleteType();
+}
+
 long long clang_Type_getAlignOf(CXType T) {
   if (T.kind == CXType_Invalid)
 return CXTypeLayoutError_Invalid;
@@ -895,7 +899,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (!isIncompleteTypeWithAlignment(QT))
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -950,10 +954,14 @@
   return Ctx.getTypeSizeInChars(QT).getQuantity();
 }
 
+static bool isTypeIncompleteForLayout(const QualType &QT) {
+  return QT->isIncompleteType() && !QT->isIncompleteArrayType();
+}
+
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (isTypeIncompleteForLayout(FQT))
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo 

[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: test/Index/print-type-size.c:6
+  // CHECK: FieldDecl=size:4:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  void* data[];
+  // CHECK: FieldDecl=data:6:9 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]

Can you run this through clang-format so it matches our usual formatting style 
rules?



Comment at: tools/libclang/CXType.cpp:888
 
+static bool isIncompleteTypeWithAlignment(const QualType &QT) {
+  return QT->isIncompleteArrayType() || !QT->isIncompleteType();

No need to use a reference here, just pass `QualType` (non-const).



Comment at: tools/libclang/CXType.cpp:957
 
+static bool isTypeIncompleteForLayout(const QualType &QT) {
+  return QT->isIncompleteType() && !QT->isIncompleteArrayType();

Similar here.


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

https://reviews.llvm.org/D61239



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


r359687 - [clang-format] Fix bug that misses some function-like macro usages

2019-05-01 Thread Owen Pan via cfe-commits
Author: owenpan
Date: Wed May  1 08:03:41 2019
New Revision: 359687

URL: http://llvm.org/viewvc/llvm-project?rev=359687&view=rev
Log:
[clang-format] Fix bug that misses some function-like macro usages

Fixes PR41483

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

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=359687&r1=359686&r2=359687&view=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Wed May  1 08:03:41 2019
@@ -1335,10 +1335,15 @@ void UnwrappedLineParser::parseStructura
   // See if the following token should start a new unwrapped line.
   StringRef Text = FormatTok->TokenText;
   nextToken();
-  if (Line->Tokens.size() == 1 &&
-  // JS doesn't have macros, and within classes colons indicate fields,
-  // not labels.
-  Style.Language != FormatStyle::LK_JavaScript) {
+
+  // JS doesn't have macros, and within classes colons indicate fields, not
+  // labels.
+  if (Style.Language == FormatStyle::LK_JavaScript)
+break;
+
+  TokenCount = Line->Tokens.size();
+  if (TokenCount == 1 ||
+  (TokenCount == 2 && Line->Tokens.front().Tok->is(tok::comment))) {
 if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) {
   Line->Tokens.begin()->Tok->MustBreakBefore = true;
   parseLabel();

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=359687&r1=359686&r2=359687&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May  1 08:03:41 2019
@@ -2584,6 +2584,12 @@ TEST_F(FormatTest, MacrosWithoutTrailing
   verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), "
"(n, buffers))\n",
getChromiumStyle(FormatStyle::LK_Cpp));
+
+  // See PR41483
+  EXPECT_EQ("/**/ FOO(a)\n"
+"FOO(b)",
+format("/**/ FOO(a)\n"
+   "FOO(b)"));
 }
 
 TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) {


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


[PATCH] D61297: [clang-format] Fix bug that misses some function-like macro usages

2019-05-01 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359687: [clang-format] Fix bug that misses some 
function-like macro usages (authored by owenpan, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61297?vs=197275&id=197553#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61297

Files:
  cfe/trunk/lib/Format/UnwrappedLineParser.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1335,10 +1335,15 @@
   // See if the following token should start a new unwrapped line.
   StringRef Text = FormatTok->TokenText;
   nextToken();
-  if (Line->Tokens.size() == 1 &&
-  // JS doesn't have macros, and within classes colons indicate fields,
-  // not labels.
-  Style.Language != FormatStyle::LK_JavaScript) {
+
+  // JS doesn't have macros, and within classes colons indicate fields, not
+  // labels.
+  if (Style.Language == FormatStyle::LK_JavaScript)
+break;
+
+  TokenCount = Line->Tokens.size();
+  if (TokenCount == 1 ||
+  (TokenCount == 2 && Line->Tokens.front().Tok->is(tok::comment))) {
 if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) {
   Line->Tokens.begin()->Tok->MustBreakBefore = true;
   parseLabel();
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -2584,6 +2584,12 @@
   verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), "
"(n, buffers))\n",
getChromiumStyle(FormatStyle::LK_Cpp));
+
+  // See PR41483
+  EXPECT_EQ("/**/ FOO(a)\n"
+"FOO(b)",
+format("/**/ FOO(a)\n"
+   "FOO(b)"));
 }
 
 TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -1335,10 +1335,15 @@
   // See if the following token should start a new unwrapped line.
   StringRef Text = FormatTok->TokenText;
   nextToken();
-  if (Line->Tokens.size() == 1 &&
-  // JS doesn't have macros, and within classes colons indicate fields,
-  // not labels.
-  Style.Language != FormatStyle::LK_JavaScript) {
+
+  // JS doesn't have macros, and within classes colons indicate fields, not
+  // labels.
+  if (Style.Language == FormatStyle::LK_JavaScript)
+break;
+
+  TokenCount = Line->Tokens.size();
+  if (TokenCount == 1 ||
+  (TokenCount == 2 && Line->Tokens.front().Tok->is(tok::comment))) {
 if (FormatTok->Tok.is(tok::colon) && !Line->MustBeDeclaration) {
   Line->Tokens.begin()->Tok->MustBreakBefore = true;
   parseLabel();
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -2584,6 +2584,12 @@
   verifyFormat("VISIT_GL_CALL(GenBuffers, void, (GLsizei n, GLuint* buffers), "
"(n, buffers))\n",
getChromiumStyle(FormatStyle::LK_Cpp));
+
+  // See PR41483
+  EXPECT_EQ("/**/ FOO(a)\n"
+"FOO(b)",
+format("/**/ FOO(a)\n"
+   "FOO(b)"));
 }
 
 TEST_F(FormatTest, MacroCallsWithoutTrailingSemicolon) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61276: [clang-format] Fix bug in block comment reflow that joins * and /

2019-05-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

@MyDeveloperDay In theory, any whitespace character other than a blank might 
trigger the bug, but in practice, we only need to handle the tab, IMO.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61276



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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee updated this revision to Diff 197557.
JornVernee marked an inline comment as done.
JornVernee added a comment.

- Removed const& QualType and passing by-value instead
- Ran print-type-size.c through clang-format

FWIW, clang-format was removing the newline at the end of the file, so I added 
it back manually.


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

https://reviews.llvm.org/D61239

Files:
  test/Index/print-type-size.c
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -885,6 +885,10 @@
   return result;
 }
 
+static bool isIncompleteTypeWithAlignment(QualType QT) {
+  return QT->isIncompleteArrayType() || !QT->isIncompleteType();
+}
+
 long long clang_Type_getAlignOf(CXType T) {
   if (T.kind == CXType_Invalid)
 return CXTypeLayoutError_Invalid;
@@ -895,7 +899,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (!isIncompleteTypeWithAlignment(QT))
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -950,10 +954,14 @@
   return Ctx.getTypeSizeInChars(QT).getQuantity();
 }
 
+static bool isTypeIncompleteForLayout(QualType QT) {
+  return QT->isIncompleteType() && !QT->isIncompleteArrayType();
+}
+
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (isTypeIncompleteForLayout(FQT))
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+  int size;
+  // CHECK: FieldDecl=size:4:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  void *data[];
+  // CHECK: FieldDecl=data:6:9 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+  int size;
+  // CHECK: FieldDecl=size:11:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  struct {
+int dummy;
+// CHECK: FieldDecl=dummy:14:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=64/0]
+void *data[];
+// CHECK: FieldDecl=data:16:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=128/64]
+  };
+};
+
+struct Baz {
+  int size;
+  // CHECK: FieldDecl=size:22:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  union {
+void *data1[];
+// CHECK: FieldDecl=data1:25:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+void *data2[];
+// CHECK: FieldDecl=data2:27:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+  };
+};
+


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -885,6 +885,10 @@
   return result;
 }
 
+static bool isIncompleteTypeWithAlignment(QualType QT) {
+  return QT->isIncompleteArrayType() || !QT->isIncompleteType();
+}
+
 long long clang_Type_getAlignOf(CXType T) {
   if (T.kind == CXType_Invalid)
 return CXTypeLayoutError_Invalid;
@@ -895,7 +899,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (!isIncompleteTypeWithAlignment(QT))
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -950,10 +954,14 @@
   return Ctx.getTypeSizeInChars(QT).getQuantity();
 }
 
+static bool isTypeIncompleteForLayout(QualType QT) {
+  return QT->isIncompleteType() && !QT->isIncompleteArrayType();
+}
+
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (isTypeIncompleteForLayout(FQT))
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+  int size;
+  // CHECK: FieldDecl=size:4:7 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+  void *data[];
+  // CHECK: Field

[PATCH] D61187: [clangd] Move clangd tests to clangd directory. check-clangd is no longer part of check-clang-tools.

2019-05-01 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In case anyone else runs into this: When doing incremental builds, the old 
ClangdTests binary stays around in `./tools/clang/tools/unittests/clangd` and 
is still run by `check-clang-tools`. In case you don't want that (it makes the 
old test target slower; or maybe your local ClangdTests binary was broken due 
to local changes and now your failing tests don't go away if you undo your 
local changes), you have to manually delete the stale executable at the old 
location.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61187



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


r359691 - [analyzer][tests] Use diff_plist, correct order of arguments for missed cases; NFC

2019-05-01 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed May  1 08:53:56 2019
New Revision: 359691

URL: http://llvm.org/viewvc/llvm-project?rev=359691&view=rev
Log:
[analyzer][tests] Use diff_plist, correct order of arguments for missed cases; 
NFC

For various files under `clang/test/Analysis`, D52036 applied
`%diff_plist` to replace `diff` invocations with certain options and
D56340 swapped the order of the arguments so that the reference file
comes first. The tests that used `tail` to filter the test output were
not modified accordingly. This patch applies the corresponding update
to those tests.

Modified:
cfe/trunk/test/Analysis/MismatchedDeallocator-path-notes.cpp
cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
cfe/trunk/test/Analysis/lambda-notes.cpp
cfe/trunk/test/Analysis/malloc-plist.c

Modified: cfe/trunk/test/Analysis/MismatchedDeallocator-path-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/MismatchedDeallocator-path-notes.cpp?rev=359691&r1=359690&r2=359691&view=diff
==
--- cfe/trunk/test/Analysis/MismatchedDeallocator-path-notes.cpp (original)
+++ cfe/trunk/test/Analysis/MismatchedDeallocator-path-notes.cpp Wed May  1 
08:53:56 2019
@@ -1,6 +1,6 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator 
-analyzer-output=text -verify %s
 // RUN: %clang_analyze_cc1 -analyzer-checker=core,unix.MismatchedDeallocator 
-analyzer-output=plist %s -o %t.plist
-// RUN: tail -n +11 %t.plist | diff -u -w -I "/" -I ".:" -I 
"version" - 
%S/copypaste/Inputs/expected-plists/MismatchedDeallocator-path-notes.cpp.plist
+// RUN: tail -n +11 %t.plist | %diff_plist 
%S/copypaste/Inputs/expected-plists/MismatchedDeallocator-path-notes.cpp.plist -
 
 void changePointee(int *p);
 int *allocIntArray(unsigned c) {

Modified: 
cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp?rev=359691&r1=359690&r2=359691&view=diff
==
--- cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp 
(original)
+++ cfe/trunk/test/Analysis/diagnostics/plist-diagnostics-include-check.cpp Wed 
May  1 08:53:56 2019
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=debug.ExprInspection 
-analyzer-output=plist-multi-file %s -o %t.plist
-// RUN: tail -n +11 %t.plist | diff -u -w -I "/" -I ".:" -I 
"version" - %S/Inputs/expected-plists/plist-diagnostics-include-check.cpp.plist
+// RUN: tail -n +11 %t.plist | %diff_plist 
%S/Inputs/expected-plists/plist-diagnostics-include-check.cpp.plist -
 
 #include "Inputs/include/plist-diagnostics-include-check-macro.h"
 

Modified: cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c?rev=359691&r1=359690&r2=359691&view=diff
==
--- cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c (original)
+++ cfe/trunk/test/Analysis/diagnostics/plist-multi-file.c Wed May  1 08:53:56 
2019
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -analyzer-checker=core -analyzer-output=plist-html 
-o %t.plist -verify %s
-// RUN: tail -n +11 %t.plist | diff -u -w -I "/" -I ".:" -I 
"version" --ignore-matching-lines=report - 
%S/Inputs/expected-plists/plist-multi-file.c.plist
+// RUN: tail -n +11 %t.plist | %diff_plist --ignore-matching-lines=report 
%S/Inputs/expected-plists/plist-multi-file.c.plist -
 
 #include "plist-multi-file.h"
 

Modified: cfe/trunk/test/Analysis/lambda-notes.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/lambda-notes.cpp?rev=359691&r1=359690&r2=359691&view=diff
==
--- cfe/trunk/test/Analysis/lambda-notes.cpp (original)
+++ cfe/trunk/test/Analysis/lambda-notes.cpp Wed May  1 08:53:56 2019
@@ -1,5 +1,5 @@
 // RUN: %clang_analyze_cc1 -std=c++11 -analyzer-checker=core.DivideZero 
-analyzer-config inline-lambdas=true -analyzer-output plist -verify %s -o %t
-// RUN: tail -n +11 %t | diff -u -w -I "/" -I ".:" -I 
"version" - %S/Inputs/expected-plists/lambda-notes.cpp.plist
+// RUN: tail -n +11 %t | %diff_plist 
%S/Inputs/expected-plists/lambda-notes.cpp.plist -
 
 
 // Diagnostic inside a lambda

Modified: cfe/trunk/test/Analysis/malloc-plist.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/malloc-plist.c?rev=359691&r1=359690&r2=359691&view=diff
==
--- cfe/trunk/test/Analysis/malloc-plist.c (original)
+++ cfe/trunk/test/Analysis/malloc-plist.c Wed May  1 08:53:56 2019
@@ -1,6 +1,6 @@
 // RUN: rm -f %t
 // RUN: %cl

r359692 - [analyzer][tests][NFC] Add EOF newlines, normalize reference expected files

2019-05-01 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed May  1 08:57:00 2019
New Revision: 359692

URL: http://llvm.org/viewvc/llvm-project?rev=359692&view=rev
Log:
[analyzer][tests][NFC] Add EOF newlines, normalize reference expected files

Reference expected files not ending with a newline are normalized to
have said newlines. Additionally `plist-macros-with-expansion.cpp.plist`
is modified to add a line that is ignored by `%diff_plist`, but not by
the more sensitive pattern proposed by
http://lists.llvm.org/pipermail/cfe-dev/2019-April/061904.html for
`%normalize_plist`.

Modified:

cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist

Modified: 
cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist?rev=359692&r1=359691&r2=359692&view=diff
==
--- 
cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
 (original)
+++ 
cfe/trunk/test/Analysis/Inputs/expected-plists/plist-macros-with-expansion.cpp.plist
 Wed May  1 08:57:00 2019
@@ -2,6 +2,7 @@
 http://www.apple.com/DTDs/PropertyList-1.0.dtd";>
 
 
+ clang_version
  diagnostics
  
   

Modified: 
cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist?rev=359692&r1=359691&r2=359692&view=diff
==
--- cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist 
(original)
+++ cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objc.plist 
Wed May  1 08:57:00 2019
@@ -26110,4 +26110,4 @@
   
/Volumes/Transcend/code/monorepo/llvm-project/clang/test/Analysis/retain-release.m
  
 
-
\ No newline at end of file
+

Modified: 
cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist?rev=359692&r1=359691&r2=359692&view=diff
==
--- 
cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist 
(original)
+++ 
cfe/trunk/test/Analysis/Inputs/expected-plists/retain-release.m.objcpp.plist 
Wed May  1 08:57:00 2019
@@ -26179,4 +26179,4 @@
   
/Volumes/Transcend/code/monorepo/llvm-project/clang/test/Analysis/retain-release.m
  
 
-
\ No newline at end of file
+


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


[PATCH] D61383: [Driver] Explicitly request platform rtlib in the Driver pic test

2019-05-01 Thread Petr Hosek via Phabricator via cfe-commits
phosek created this revision.
phosek added a reviewer: juliehockett.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This test checks whether crtbegin.o and crtend.o appear on the link
line, but names of these files may be affected by the choice of the
rtlib, specifically when compiler-rt is used as the default rtlib
the names will be clang_rt.crtbegin.o and clang_rt.crtend.o instead
of crtbeginS.o and crtendS.o. To avoid the test failure, explicitly
request to use the platform rtlib.


Repository:
  rC Clang

https://reviews.llvm.org/D61383

Files:
  clang/test/Driver/pic.c


Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -123,15 +123,15 @@
 // Make sure -pie is passed to along to ld and that the right *crt* files
 // are linked in.
 // RUN: %clang %s -target i386-unknown-freebsd -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIC -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 //


Index: clang/test/Driver/pic.c
===
--- clang/test/Driver/pic.c
+++ clang/test/Driver/pic.c
@@ -123,15 +123,15 @@
 // Make sure -pie is passed to along to ld and that the right *crt* files
 // are linked in.
 // RUN: %clang %s -target i386-unknown-freebsd -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIC -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61187: [clangd] Move clangd tests to clangd directory. check-clangd is no longer part of check-clang-tools.

2019-05-01 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

FYI, we had to disable clangd entirely after this patch, getting a weird 
problem with lit that we haven't figured out yet.
In case anybody else has seen something like this, and knows what's going on, 
please let us know.

Running all regression tests
llvm-lit.py: 
C:/j/w/opensource/opensource_to_sce_merge__2/o/llvm\utils\lit\lit\llvm\config.py:336:
 fatal: couldn't find 'clang' program, try setting CLANG in your environment
  C:\Program Files 
(x86)\MSBuild\Microsoft.Cpp\v4.0\V140\Microsoft.CppCommon.targets(171,5): error 
MSB6006: "cmd.exe" exited with code 2. 
[C:\j\w\opensource\opensource_to_sce_merge__2\build\check-all.vcxproj]


Repository:
  rL LLVM

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

https://reviews.llvm.org/D61187



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


[PATCH] D61097: [Sema] Emit warning for visibility attribute on internal-linkage declaration

2019-05-01 Thread Scott Linder via Phabricator via cfe-commits
scott.linder updated this revision to Diff 197570.
scott.linder added a comment.

Use distinct sema diagnostic and do not return early.

I am going to bump `DIAG_SIZE_SEMA` in another patch, as it seems like we have 
hit the current limit.


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

https://reviews.llvm.org/D61097

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDeclAttr.cpp
  test/Sema/attr-visibility.c
  test/SemaCXX/ast-print.cpp
  test/SemaCXX/attr-visibility.cpp


Index: test/SemaCXX/attr-visibility.cpp
===
--- test/SemaCXX/attr-visibility.cpp
+++ test/SemaCXX/attr-visibility.cpp
@@ -18,3 +18,9 @@
 struct x3 {
   static int y;
 } __attribute((visibility("default"))); // expected-warning {{attribute 
'visibility' after definition is ignored}}
+
+const int test4 __attribute__((visibility("default"))) = 0; // 
expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
+
+namespace {
+  int test5 __attribute__((visibility("default"))); // expected-warning 
{{'visibility' attribute is ignored on a non-external symbol}}
+};
Index: test/SemaCXX/ast-print.cpp
===
--- test/SemaCXX/ast-print.cpp
+++ test/SemaCXX/ast-print.cpp
@@ -209,10 +209,8 @@
 }
 }
 
-namespace {
 // CHECK: struct {{\[\[gnu::visibility\(\"hidden\"\)\]\]}} S;
 struct [[gnu::visibility("hidden")]] S;
-}
 
 // CHECK:  struct CXXFunctionalCastExprPrint {
 // CHECK-NEXT: } fce = CXXFunctionalCastExprPrint{};
Index: test/Sema/attr-visibility.c
===
--- test/Sema/attr-visibility.c
+++ test/Sema/attr-visibility.c
@@ -26,3 +26,9 @@
 int x __attribute__((type_visibility("default"))); // expected-error 
{{'type_visibility' attribute only applies to types and namespaces}}
 
 int PR17105 __attribute__((visibility(hidden))); // expected-error 
{{'visibility' attribute requires a string}}
+
+static int test8 __attribute__((visibility("default"))); // expected-warning 
{{'visibility' attribute is ignored on a non-external symbol}}
+static int test9 __attribute__((visibility("hidden"))); // expected-warning 
{{'visibility' attribute is ignored on a non-external symbol}}
+static int test10 __attribute__((visibility("internal"))); // expected-warning 
{{'visibility' attribute is ignored on a non-external symbol}}
+
+static int test11() __attribute__((visibility("default"))); // 
expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -2615,6 +2615,14 @@
 return;
   }
 
+  // Visibility attributes have no effect on symbols with internal linkage.
+  if (const auto *ND = dyn_cast(D)) {
+if (!ND->isExternallyVisible())
+  S.Diag(AL.getRange().getBegin(),
+ diag::warn_attribute_ignored_on_non_external)
+  << AL;
+  }
+
   // Check that the argument is a string literal.
   StringRef TypeStr;
   SourceLocation LiteralLoc;
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -2778,6 +2778,9 @@
 def warn_attribute_ignored_on_inline :
   Warning<"%0 attribute ignored on inline function">,
   InGroup;
+def warn_attribute_ignored_on_non_external :
+  Warning<"%0 attribute is ignored on a non-external symbol">,
+  InGroup;
 def warn_nocf_check_attribute_ignored :
   Warning<"'nocf_check' attribute ignored; use -fcf-protection to enable the 
attribute">,
   InGroup;


Index: test/SemaCXX/attr-visibility.cpp
===
--- test/SemaCXX/attr-visibility.cpp
+++ test/SemaCXX/attr-visibility.cpp
@@ -18,3 +18,9 @@
 struct x3 {
   static int y;
 } __attribute((visibility("default"))); // expected-warning {{attribute 'visibility' after definition is ignored}}
+
+const int test4 __attribute__((visibility("default"))) = 0; // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
+
+namespace {
+  int test5 __attribute__((visibility("default"))); // expected-warning {{'visibility' attribute is ignored on a non-external symbol}}
+};
Index: test/SemaCXX/ast-print.cpp
===
--- test/SemaCXX/ast-print.cpp
+++ test/SemaCXX/ast-print.cpp
@@ -209,10 +209,8 @@
 }
 }
 
-namespace {
 // CHECK: struct {{\[\[gnu::visibility\(\"hidden\"\)\]\]}} S;
 struct [[gnu::visibility("hidden")]] S;
-}
 
 // CHECK:  struct CXXFunctionalCastExprPrint {
 // CHECK-NEXT: } fce = CXXFunctionalCastExprPrint{};
Index: test/Sema/attr-visibility.c
===
--- test/Sema/attr-visibilit

[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel created this revision.
ymandel added a reviewer: aaron.ballman.
Herald added subscribers: cfe-commits, xazax.hun, mgorny.
Herald added a project: clang.

This revision introduces an adaptor from Transformer's rewrite rules
(`clang::tooling::RewriteRule`) to `ClangTidyCheck`.  For example, given a
RewriteRule `MyCheckAsRewriteRule`, it lets one define a tidy check as follows:

  class MyTidyCheck : public TransformerTidy {
   public:
MyTidyCheck(StringRef Name, ClangTidyContext *Context)
: TransformerTidy(MyCheckAsRewriteRule, Name, Context) {}
  };


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61386

Files:
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
  clang-tools-extra/clang-tidy/utils/TransformerTidy.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
@@ -0,0 +1,64 @@
+//=== TransformerTidyTest.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../clang-tidy/utils/TransformerTidy.h"
+
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/Stencil.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace {
+// Invert the code of an if-statement, while maintaining its semantics.
+tooling::RewriteRule invertIf() {
+  using namespace ::clang::ast_matchers;
+  using tooling::change;
+  using tooling::stencil::cat;
+  using tooling::stencil::node;
+  using tooling::stencil::sNode;
+
+  StringRef C = "C", "T", E = "E";
+  return tooling::makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(cat("if(!(", node(C), ")) ", sNode(E), " else ", sNode(T;
+}
+
+class IfInverterTidy : public TransformerTidy {
+public:
+  IfInverterTidy(StringRef Name, ClangTidyContext *Context)
+  : TransformerTidy(invertIf(), Name, Context) {}
+};
+
+// Basic test of using a rewrite rule as a ClangTidy.
+TEST(TransformerTidyTest, Basic) {
+  const std::string Input = R"cc(
+void log(const char* msg);
+void foo() {
+  if (10 > 1.0)
+log("oh no!");
+  else
+log("ok");
+}
+  )cc";
+  const std::string Expected = R"(
+void log(const char* msg);
+void foo() {
+  if(!(10 > 1.0)) log("ok"); else log("oh no!");
+}
+  )";
+  EXPECT_EQ(Expected, test::runCheckOnCode(Input));
+}
+} // namespace
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -17,6 +17,7 @@
   OverlappingReplacementsTest.cpp
   UsingInserterTest.cpp
   ReadabilityModuleTest.cpp
+  TransformerTidyTest.cpp
   )
 
 target_link_libraries(ClangTidyTests
@@ -36,4 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
+  clangToolingRefactor
   )
Index: clang-tools-extra/clang-tidy/utils/TransformerTidy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/TransformerTidy.h
@@ -0,0 +1,49 @@
+//===-- TransformerTidy.h - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+
+#include "../ClangTidy.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// A base class for defining a ClangTidy check based on a rewrite rule.
+//
+// For example, given a RewriteRule `MyCheckAsRewriteRule`, one can define your
+// tidy check as follows:
+//
+// class MyTidyCheck : public TransformerTidy {
+//  public:
+//   MyTidyCheck(StringRef Name, ClangTidyContext *Context)
+//   : TransformerTidy(MyCheckAsRewriteRule, Name, Context) {}
+// };
+class Tra

r359702 - Bump DIAG_SIZE_SEMA, as we've hit it.

2019-05-01 Thread Scott Linder via cfe-commits
Author: scott.linder
Date: Wed May  1 09:45:49 2019
New Revision: 359702

URL: http://llvm.org/viewvc/llvm-project?rev=359702&view=rev
Log:
Bump DIAG_SIZE_SEMA, as we've hit it.

$ grep 'DIAG_SIZE_SEMA  =' include/clang/Basic/DiagnosticIDs.h
  DIAG_SIZE_SEMA  = 4000,
$ grep DIAG $(build)/tools/clang/include/clang/Basic/DiagnosticSemaKinds.inc | 
wc -l
3499

Modified:
cfe/trunk/include/clang/Basic/DiagnosticIDs.h

Modified: cfe/trunk/include/clang/Basic/DiagnosticIDs.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticIDs.h?rev=359702&r1=359701&r2=359702&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticIDs.h (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticIDs.h Wed May  1 09:45:49 2019
@@ -36,7 +36,7 @@ namespace clang {
   DIAG_SIZE_AST   =  150,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_SEMA  = 4000,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };


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


r359706 - [Driver] Explicitly request platform rtlib in the Driver pic test

2019-05-01 Thread Petr Hosek via cfe-commits
Author: phosek
Date: Wed May  1 09:52:45 2019
New Revision: 359706

URL: http://llvm.org/viewvc/llvm-project?rev=359706&view=rev
Log:
[Driver] Explicitly request platform rtlib in the Driver pic test

This test checks whether crtbegin.o and crtend.o appear on the link
line, but names of these files may be affected by the choice of the
rtlib, specifically when compiler-rt is used as the default rtlib
the names will be clang_rt.crtbegin.o and clang_rt.crtend.o instead
of crtbeginS.o and crtendS.o. To avoid the test failure, explicitly
request to use the platform rtlib.

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

Modified:
cfe/trunk/test/Driver/pic.c

Modified: cfe/trunk/test/Driver/pic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/pic.c?rev=359706&r1=359705&r2=359706&view=diff
==
--- cfe/trunk/test/Driver/pic.c (original)
+++ cfe/trunk/test/Driver/pic.c Wed May  1 09:52:45 2019
@@ -123,15 +123,15 @@
 // Make sure -pie is passed to along to ld and that the right *crt* files
 // are linked in.
 // RUN: %clang %s -target i386-unknown-freebsd -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIC -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 //


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


[PATCH] D61383: [Driver] Explicitly request platform rtlib in the Driver pic test

2019-05-01 Thread Petr Hosek via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359706: [Driver] Explicitly request platform rtlib in the 
Driver pic test (authored by phosek, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61383?vs=197564&id=197579#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61383

Files:
  cfe/trunk/test/Driver/pic.c


Index: cfe/trunk/test/Driver/pic.c
===
--- cfe/trunk/test/Driver/pic.c
+++ cfe/trunk/test/Driver/pic.c
@@ -123,15 +123,15 @@
 // Make sure -pie is passed to along to ld and that the right *crt* files
 // are linked in.
 // RUN: %clang %s -target i386-unknown-freebsd -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIC -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 //


Index: cfe/trunk/test/Driver/pic.c
===
--- cfe/trunk/test/Driver/pic.c
+++ cfe/trunk/test/Driver/pic.c
@@ -123,15 +123,15 @@
 // Make sure -pie is passed to along to ld and that the right *crt* files
 // are linked in.
 // RUN: %clang %s -target i386-unknown-freebsd -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_freebsd_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIE -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 // RUN: %clang %s -target i386-linux-gnu -fPIC -pie -### \
-// RUN: --gcc-toolchain="" \
+// RUN: --gcc-toolchain="" -rtlib=platform \
 // RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
 // RUN:   | FileCheck %s --check-prefix=CHECK-PIE-LD
 //
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-01 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp:22
+  // Verify the existence and validity of the AST node that roots this rule.
+  auto &NodesMap = Result.Nodes.getMap();
+  auto Root = NodesMap.find(tooling::RewriteRule::RootId);

Please don't use auto when return type is not spelled at same statement or 
iterator. Same for other places. 



Comment at: clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp:10
+#include "../clang-tidy/utils/TransformerTidy.h"
+
+#include "ClangTidyTest.h"

Unnecessary empty line.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee updated this revision to Diff 197583.
JornVernee marked 3 inline comments as done.
JornVernee added a comment.

Removed spurious newline


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

https://reviews.llvm.org/D61239

Files:
  test/Index/print-type-size.c
  tools/libclang/CXType.cpp


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -885,6 +885,10 @@
   return result;
 }
 
+static bool isIncompleteTypeWithAlignment(QualType QT) {
+  return QT->isIncompleteArrayType() || !QT->isIncompleteType();
+}
+
 long long clang_Type_getAlignOf(CXType T) {
   if (T.kind == CXType_Invalid)
 return CXTypeLayoutError_Invalid;
@@ -895,7 +899,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (!isIncompleteTypeWithAlignment(QT))
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -950,10 +954,14 @@
   return Ctx.getTypeSizeInChars(QT).getQuantity();
 }
 
+static bool isTypeIncompleteForLayout(QualType QT) {
+  return QT->isIncompleteType() && !QT->isIncompleteArrayType();
+}
+
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (isTypeIncompleteForLayout(FQT))
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+  int size;
+  // CHECK: FieldDecl=size:4:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  void *data[];
+  // CHECK: FieldDecl=data:6:9 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+  int size;
+  // CHECK: FieldDecl=size:11:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  struct {
+int dummy;
+// CHECK: FieldDecl=dummy:14:9 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=64/0]
+void *data[];
+// CHECK: FieldDecl=data:16:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=128/64]
+  };
+};
+
+struct Baz {
+  int size;
+  // CHECK: FieldDecl=size:22:7 (Definition) [type=int] [typekind=Int] 
[sizeof=4] [alignof=4] [offsetof=0]
+  union {
+void *data1[];
+// CHECK: FieldDecl=data1:25:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+void *data2[];
+// CHECK: FieldDecl=data2:27:11 (Definition) [type=void *[]] 
[typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64/0]
+  };
+};
+


Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -885,6 +885,10 @@
   return result;
 }
 
+static bool isIncompleteTypeWithAlignment(QualType QT) {
+  return QT->isIncompleteArrayType() || !QT->isIncompleteType();
+}
+
 long long clang_Type_getAlignOf(CXType T) {
   if (T.kind == CXType_Invalid)
 return CXTypeLayoutError_Invalid;
@@ -895,7 +899,7 @@
   // [expr.alignof] p3: if reference type, return size of referenced type
   if (QT->isReferenceType())
 QT = QT.getNonReferenceType();
-  if (QT->isIncompleteType())
+  if (!isIncompleteTypeWithAlignment(QT))
 return CXTypeLayoutError_Incomplete;
   if (QT->isDependentType())
 return CXTypeLayoutError_Dependent;
@@ -950,10 +954,14 @@
   return Ctx.getTypeSizeInChars(QT).getQuantity();
 }
 
+static bool isTypeIncompleteForLayout(QualType QT) {
+  return QT->isIncompleteType() && !QT->isIncompleteArrayType();
+}
+
 static long long visitRecordForValidation(const RecordDecl *RD) {
   for (const auto *I : RD->fields()){
 QualType FQT = I->getType();
-if (FQT->isIncompleteType())
+if (isTypeIncompleteForLayout(FQT))
   return CXTypeLayoutError_Incomplete;
 if (FQT->isDependentType())
   return CXTypeLayoutError_Dependent;
Index: test/Index/print-type-size.c
===
--- /dev/null
+++ test/Index/print-type-size.c
@@ -0,0 +1,31 @@
+// RUN: c-index-test -test-print-type-size %s | FileCheck %s
+
+struct Foo {
+  int size;
+  // CHECK: FieldDecl=size:4:7 (Definition) [type=int] [typekind=Int] [sizeof=4] [alignof=4] [offsetof=0]
+  void *data[];
+  // CHECK: FieldDecl=data:6:9 (Definition) [type=void *[]] [typekind=IncompleteArray] [sizeof=-2] [alignof=8] [offsetof=64]
+};
+
+struct Bar {
+  int size;
+  // CHECK: FieldDecl=size:11:7 

[PATCH] D61304: [OpenCL][PR41609] Deduce static data members to __global addr space

2019-05-01 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

Okay.  This seems reasonable to me, then.


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

https://reviews.llvm.org/D61304



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


[PATCH] D61318: [Sema] Prevent binding references with mismatching address spaces to temporaries

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



Comment at: lib/Sema/SemaInit.cpp:4836
+  if (T1Quals.hasAddressSpace()) {
+if (!T1Quals.isAddressSpaceSupersetOf(cv1T1IgnoreAS.getQualifiers())) {
+  Sequence.SetFailed(

Anastasia wrote:
> rjmccall wrote:
> > Isn't `cv1T1IgnoreAS.getQualifiers()` always `LangAS::Default`?
> Yes, this is true currently. However, we don't have an overload of 
> `isAddressSpaceSupersetOf` that takes `LangAS` as a parameter. Are you 
> suggesting to add it?
I think it would be sensible if there was a function that could answer the 
superset question with just two `LangAS` values, yeah.  Even with the current 
API, it would at least be clearer if you just manufactured a `Qualifiers` with 
no address space, since there's no dependency on any of the other qualifiers 
from `cv1T1IgnoreAS`.


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

https://reviews.llvm.org/D61318



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


[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer

2019-05-01 Thread Kévin Petit via Phabricator via cfe-commits
kpet added a comment.

Ok, I'll replace the test with an IR-level test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61319



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


[PATCH] D60974: Clang IFSO driver action.

2019-05-01 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd added a comment.

@jakehehrlich - unfortunately, removing the attributes on the sections will 
make the content look different with `nm` which is something we do need to 
appear proper for consumers of the interface libraries.  Versioning has a 
number of problems inherent to it (unfortunately, its the closest to 
multi-level namespaces in ELF).  I think that getting something in tree and 
iterating on it is far better than continuing to argue over this in the dream 
of something that unifies the TAPI approach and this approach.  The section 
names are relevant (you can add attributes to put symbols into alternate 
sections and you can have section relative relocations).  I think that you are 
loosing fidelity in the final output which is sufficient for your needs, but I 
think that there are places where the full fidelity can be needed.

This currently works and allows us to generate the interface library which 
means that this is actually further than what you are proposing still.  Is 
there something technical that this is doing incorrectly or breaking something? 
 Otherwise, this really does seem like it is devolving into a bike shedding 
argument that isn't really going anywhere.  This is not a large amount of code 
and there is backing to maintain it, so it is not an issue of "this is adding 
un-maintained complexity" either.

Just like the LLVM APIs, this can/will evolve.  I don't see why this needs to 
be set in stone from the initial implementation.  There are use cases which can 
come up which require reworking the solution.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D61389: Bump DIAG_SIZE_SEMA up to 4000

2019-05-01 Thread Dan Gohman via Phabricator via cfe-commits
sunfish created this revision.
sunfish added a reviewer: aaron.ballman.
Herald added a subscriber: aheejin.
Herald added a project: clang.

https://reviews.llvm.org/D59520 adds a few new diagnostics, which happens to 
run into a limit with DIAG_SIZE_SEMA. As suggested here 
, here's a separate patch to 
bump the limit from 3500 to 4000.


Repository:
  rC Clang

https://reviews.llvm.org/D61389

Files:
  include/clang/Basic/DiagnosticIDs.h


Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -36,7 +36,7 @@
   DIAG_SIZE_AST   =  150,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_SEMA  = 4000,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };


Index: include/clang/Basic/DiagnosticIDs.h
===
--- include/clang/Basic/DiagnosticIDs.h
+++ include/clang/Basic/DiagnosticIDs.h
@@ -36,7 +36,7 @@
   DIAG_SIZE_AST   =  150,
   DIAG_SIZE_COMMENT   =  100,
   DIAG_SIZE_CROSSTU   =  100,
-  DIAG_SIZE_SEMA  = 3500,
+  DIAG_SIZE_SEMA  = 4000,
   DIAG_SIZE_ANALYSIS  =  100,
   DIAG_SIZE_REFACTORING   = 1000,
 };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D58321: Support for relative vtables

2019-05-01 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

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

Reduced use of auto.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386

Files:
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
  clang-tools-extra/clang-tidy/utils/TransformerTidy.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
@@ -0,0 +1,63 @@
+//=== TransformerTidyTest.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../clang-tidy/utils/TransformerTidy.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/Stencil.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace {
+// Invert the code of an if-statement, while maintaining its semantics.
+tooling::RewriteRule invertIf() {
+  using namespace ::clang::ast_matchers;
+  using tooling::change;
+  using tooling::stencil::cat;
+  using tooling::stencil::node;
+  using tooling::stencil::sNode;
+
+  StringRef C = "C", "T", E = "E";
+  return tooling::makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(cat("if(!(", node(C), ")) ", sNode(E), " else ", sNode(T;
+}
+
+class IfInverterTidy : public TransformerTidy {
+public:
+  IfInverterTidy(StringRef Name, ClangTidyContext *Context)
+  : TransformerTidy(invertIf(), Name, Context) {}
+};
+
+// Basic test of using a rewrite rule as a ClangTidy.
+TEST(TransformerTidyTest, Basic) {
+  const std::string Input = R"cc(
+void log(const char* msg);
+void foo() {
+  if (10 > 1.0)
+log("oh no!");
+  else
+log("ok");
+}
+  )cc";
+  const std::string Expected = R"(
+void log(const char* msg);
+void foo() {
+  if(!(10 > 1.0)) log("ok"); else log("oh no!");
+}
+  )";
+  EXPECT_EQ(Expected, test::runCheckOnCode(Input));
+}
+} // namespace
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -17,6 +17,7 @@
   OverlappingReplacementsTest.cpp
   UsingInserterTest.cpp
   ReadabilityModuleTest.cpp
+  TransformerTidyTest.cpp
   )
 
 target_link_libraries(ClangTidyTests
@@ -36,4 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
+  clangToolingRefactor
   )
Index: clang-tools-extra/clang-tidy/utils/TransformerTidy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/TransformerTidy.h
@@ -0,0 +1,49 @@
+//===-- TransformerTidy.h - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+
+#include "../ClangTidy.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// A base class for defining a ClangTidy check based on a rewrite rule.
+//
+// For example, given a RewriteRule `MyCheckAsRewriteRule`, one can define your
+// tidy check as follows:
+//
+// class MyTidyCheck : public TransformerTidy {
+//  public:
+//   MyTidyCheck(StringRef Name, ClangTidyContext *Context)
+//   : TransformerTidy(MyCheckAsRewriteRule, Name, Context) {}
+// };
+class TransformerTidy : public ClangTidyCheck {
+public:
+  TransformerTidy(tooling::RewriteRule R, StringRef Name,
+  ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+  tooling::RewriteRule Rule;
+};
+
+} //

[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp:22
+  // Verify the existence and validity of the AST node that roots this rule.
+  auto &NodesMap = Result.Nodes.getMap();
+  auto Root = NodesMap.find(tooling::RewriteRule::RootId);

Eugene.Zelenko wrote:
> Please don't use auto when return type is not spelled at same statement or 
> iterator. Same for other places. 
I left only the iterator's auto, expanded the rest.  Let me know if I've 
converted too many.   I wonder about this one here, for example, because the 
type of the map is essentially an internal detail of BoundNodes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-01 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp:51
+  DiagnosticBuilder Diag = diag(RootLoc, Message);
+  for (const tooling::Transformation &T : *Transformations) {
+Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);

It's iterator, so auto could be used instead of type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


[PATCH] D58321: Support for relative vtables

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



Comment at: clang/include/clang/AST/DeclCXX.h:531
+/// \brief Whether the class uses the relative C++ vtable ABI.
+unsigned IsRelativeCXXABI : 1;
+

Should we proactively generalize this as a "CXXABIVariant" enum, which for now 
can just be "Standard" and "RelativeVTables"?

Also, I don't want to pre-empt your secret plans, but if Fuchsia is just going 
to use this as its system C++ ABI, maybe we should plan for that, too.



Comment at: clang/include/clang/AST/VTableBuilder.h:267
 
+  VTableComponent &getVTableComponent(size_t i) const {
+return VTableComponents[i];

`const VTableComponent &`, I think.



Comment at: clang/include/clang/Basic/LangOptions.def:329
+"Whether to use clang's relative C++ ABI "
+"for classes with vtables")
+

Yeah, see, this plays into the question above.  I would not want to provide 
this as a language option for general use.  The attribute seems good enough for 
testing, and if you want a -cc1 option to apply the attribute by default for 
experimentation during Fuchsia bring-up that's fair, but I don't want something 
that suggests to users that it's okay to pass this attribute and change the 
system default.



Comment at: clang/include/clang/Sema/Sema.h:10976
+  /// Determine if this class can use the relative vtable ABI.
+  void checkClassABI(CXXRecordDecl *RD);
+

Comment / method-name mismatch?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

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

reinstated an auto


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386

Files:
  clang-tools-extra/clang-tidy/utils/CMakeLists.txt
  clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp
  clang-tools-extra/clang-tidy/utils/TransformerTidy.h
  clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
  clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp

Index: clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
===
--- /dev/null
+++ clang-tools-extra/unittests/clang-tidy/TransformerTidyTest.cpp
@@ -0,0 +1,63 @@
+//=== TransformerTidyTest.cpp - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "../clang-tidy/utils/TransformerTidy.h"
+#include "ClangTidyTest.h"
+#include "clang/ASTMatchers/ASTMatchers.h"
+#include "clang/Tooling/Refactoring/Stencil.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include "gtest/gtest.h"
+
+namespace clang {
+namespace tidy {
+namespace utils {
+namespace {
+// Invert the code of an if-statement, while maintaining its semantics.
+tooling::RewriteRule invertIf() {
+  using namespace ::clang::ast_matchers;
+  using tooling::change;
+  using tooling::stencil::cat;
+  using tooling::stencil::node;
+  using tooling::stencil::sNode;
+
+  StringRef C = "C", "T", E = "E";
+  return tooling::makeRule(
+  ifStmt(hasCondition(expr().bind(C)), hasThen(stmt().bind(T)),
+ hasElse(stmt().bind(E))),
+  change(cat("if(!(", node(C), ")) ", sNode(E), " else ", sNode(T;
+}
+
+class IfInverterTidy : public TransformerTidy {
+public:
+  IfInverterTidy(StringRef Name, ClangTidyContext *Context)
+  : TransformerTidy(invertIf(), Name, Context) {}
+};
+
+// Basic test of using a rewrite rule as a ClangTidy.
+TEST(TransformerTidyTest, Basic) {
+  const std::string Input = R"cc(
+void log(const char* msg);
+void foo() {
+  if (10 > 1.0)
+log("oh no!");
+  else
+log("ok");
+}
+  )cc";
+  const std::string Expected = R"(
+void log(const char* msg);
+void foo() {
+  if(!(10 > 1.0)) log("ok"); else log("oh no!");
+}
+  )";
+  EXPECT_EQ(Expected, test::runCheckOnCode(Input));
+}
+} // namespace
+} // namespace utils
+} // namespace tidy
+} // namespace clang
Index: clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
===
--- clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
+++ clang-tools-extra/unittests/clang-tidy/CMakeLists.txt
@@ -17,6 +17,7 @@
   OverlappingReplacementsTest.cpp
   UsingInserterTest.cpp
   ReadabilityModuleTest.cpp
+  TransformerTidyTest.cpp
   )
 
 target_link_libraries(ClangTidyTests
@@ -36,4 +37,5 @@
   clangTidyUtils
   clangTooling
   clangToolingCore
+  clangToolingRefactor
   )
Index: clang-tools-extra/clang-tidy/utils/TransformerTidy.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/utils/TransformerTidy.h
@@ -0,0 +1,49 @@
+//===-- TransformerTidy.h - clang-tidy ===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_TRANSFORMER_TIDY_H
+
+#include "../ClangTidy.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "clang/Tooling/Refactoring/Transformer.h"
+#include 
+#include 
+
+namespace clang {
+namespace tidy {
+namespace utils {
+
+// A base class for defining a ClangTidy check based on a rewrite rule.
+//
+// For example, given a RewriteRule `MyCheckAsRewriteRule`, one can define your
+// tidy check as follows:
+//
+// class MyTidyCheck : public TransformerTidy {
+//  public:
+//   MyTidyCheck(StringRef Name, ClangTidyContext *Context)
+//   : TransformerTidy(MyCheckAsRewriteRule, Name, Context) {}
+// };
+class TransformerTidy : public ClangTidyCheck {
+public:
+  TransformerTidy(tooling::RewriteRule R, StringRef Name,
+  ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context), Rule(std::move(R)) {}
+
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+
+private:
+

[PATCH] D61386: [clang-tidy] Add support writing a check as a Transformer rewrite rule.

2019-05-01 Thread Yitzhak Mandelbaum via Phabricator via cfe-commits
ymandel marked 2 inline comments as done.
ymandel added inline comments.



Comment at: clang-tools-extra/clang-tidy/utils/TransformerTidy.cpp:51
+  DiagnosticBuilder Diag = diag(RootLoc, Message);
+  for (const tooling::Transformation &T : *Transformations) {
+Diag << FixItHint::CreateReplacement(T.Range, T.Replacement);

Eugene.Zelenko wrote:
> It's iterator, so auto could be used instead of type.
great, i wasn't sure whether this counted as such.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61386



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


[PATCH] D61222: [clang-format] Fix a bug in AlignConsecutiveDeclarations

2019-05-01 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 197566.
owenpan added a comment.

Removed a redundant test case.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61222

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


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10575,6 +10575,13 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n"
+"foo(int a);",
+format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ foo (int a);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -463,9 +463,21 @@
   [](Change const &C) {
 // tok::kw_operator is necessary for aligning operator overload
 // definitions.
-return C.Tok->is(TT_StartOfName) ||
-   C.Tok->is(TT_FunctionDeclarationName) ||
-   C.Tok->is(tok::kw_operator);
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, tok::kw_operator))
+  return true;
+if (C.Tok->isNot(TT_StartOfName))
+  return false;
+// Check if there is a subsequent name that starts the same 
declaration.
+for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
+  if (Next->is(tok::comment))
+continue;
+  if (!Next->Tok.getIdentifierInfo())
+break;
+  if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName,
+tok::kw_operator))
+return false;
+}
+return true;
   },
   Changes, /*StartAt=*/0);
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -10575,6 +10575,13 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n"
+"foo(int a);",
+format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ foo (int a);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
Index: clang/lib/Format/WhitespaceManager.cpp
===
--- clang/lib/Format/WhitespaceManager.cpp
+++ clang/lib/Format/WhitespaceManager.cpp
@@ -463,9 +463,21 @@
   [](Change const &C) {
 // tok::kw_operator is necessary for aligning operator overload
 // definitions.
-return C.Tok->is(TT_StartOfName) ||
-   C.Tok->is(TT_FunctionDeclarationName) ||
-   C.Tok->is(tok::kw_operator);
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, tok::kw_operator))
+  return true;
+if (C.Tok->isNot(TT_StartOfName))
+  return false;
+// Check if there is a subsequent name that starts the same declaration.
+for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
+  if (Next->is(tok::comment))
+continue;
+  if (!Next->Tok.getIdentifierInfo())
+break;
+  if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName,
+tok::kw_operator))
+return false;
+}
+return true;
   },
   Changes, /*StartAt=*/0);
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D61324: Make check-clang depend on the clang-check binary always

2019-05-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D61324



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


[PATCH] D58321: Support for relative vtables

2019-05-01 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:531
+/// \brief Whether the class uses the relative C++ vtable ABI.
+unsigned IsRelativeCXXABI : 1;
+

rjmccall wrote:
> Should we proactively generalize this as a "CXXABIVariant" enum, which for 
> now can just be "Standard" and "RelativeVTables"?
> 
> Also, I don't want to pre-empt your secret plans, but if Fuchsia is just 
> going to use this as its system C++ ABI, maybe we should plan for that, too.
At this point I probably would remove this bitfield entirely. This 
implementation does not support enabling the ABI on a per-class basis, so 
everywhere that we are currently checking this field we should just be able to 
check `RelativeCXXABIVTables` in `LangOptions`.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D58321



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


[PATCH] D61222: [clang-format] Fix a bug in AlignConsecutiveDeclarations

2019-05-01 Thread Owen Pan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359711: [clang-format] Fix a bug in 
AlignConsecutiveDeclarations. (authored by owenpan, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D61222?vs=197566&id=197600#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61222

Files:
  cfe/trunk/lib/Format/WhitespaceManager.cpp
  cfe/trunk/unittests/Format/FormatTest.cpp


Index: cfe/trunk/lib/Format/WhitespaceManager.cpp
===
--- cfe/trunk/lib/Format/WhitespaceManager.cpp
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp
@@ -463,9 +463,21 @@
   [](Change const &C) {
 // tok::kw_operator is necessary for aligning operator overload
 // definitions.
-return C.Tok->is(TT_StartOfName) ||
-   C.Tok->is(TT_FunctionDeclarationName) ||
-   C.Tok->is(tok::kw_operator);
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, tok::kw_operator))
+  return true;
+if (C.Tok->isNot(TT_StartOfName))
+  return false;
+// Check if there is a subsequent name that starts the same 
declaration.
+for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
+  if (Next->is(tok::comment))
+continue;
+  if (!Next->Tok.getIdentifierInfo())
+break;
+  if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName,
+tok::kw_operator))
+return false;
+}
+return true;
   },
   Changes, /*StartAt=*/0);
 }
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -10581,6 +10581,13 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n"
+"foo(int a);",
+format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ foo (int a);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {


Index: cfe/trunk/lib/Format/WhitespaceManager.cpp
===
--- cfe/trunk/lib/Format/WhitespaceManager.cpp
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp
@@ -463,9 +463,21 @@
   [](Change const &C) {
 // tok::kw_operator is necessary for aligning operator overload
 // definitions.
-return C.Tok->is(TT_StartOfName) ||
-   C.Tok->is(TT_FunctionDeclarationName) ||
-   C.Tok->is(tok::kw_operator);
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, tok::kw_operator))
+  return true;
+if (C.Tok->isNot(TT_StartOfName))
+  return false;
+// Check if there is a subsequent name that starts the same declaration.
+for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
+  if (Next->is(tok::comment))
+continue;
+  if (!Next->Tok.getIdentifierInfo())
+break;
+  if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName,
+tok::kw_operator))
+return false;
+}
+return true;
   },
   Changes, /*StartAt=*/0);
 }
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -10581,6 +10581,13 @@
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n"
+"foo(int a);",
+format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ foo (int a);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r359711 - [clang-format] Fix a bug in AlignConsecutiveDeclarations.

2019-05-01 Thread Owen Pan via cfe-commits
Author: owenpan
Date: Wed May  1 11:23:44 2019
New Revision: 359711

URL: http://llvm.org/viewvc/llvm-project?rev=359711&view=rev
Log:
[clang-format] Fix a bug in AlignConsecutiveDeclarations.

Fixes PR37175

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

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

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=359711&r1=359710&r2=359711&view=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Wed May  1 11:23:44 2019
@@ -463,9 +463,21 @@ void WhitespaceManager::alignConsecutive
   [](Change const &C) {
 // tok::kw_operator is necessary for aligning operator overload
 // definitions.
-return C.Tok->is(TT_StartOfName) ||
-   C.Tok->is(TT_FunctionDeclarationName) ||
-   C.Tok->is(tok::kw_operator);
+if (C.Tok->isOneOf(TT_FunctionDeclarationName, tok::kw_operator))
+  return true;
+if (C.Tok->isNot(TT_StartOfName))
+  return false;
+// Check if there is a subsequent name that starts the same 
declaration.
+for (FormatToken *Next = C.Tok->Next; Next; Next = Next->Next) {
+  if (Next->is(tok::comment))
+continue;
+  if (!Next->Tok.getIdentifierInfo())
+break;
+  if (Next->isOneOf(TT_StartOfName, TT_FunctionDeclarationName,
+tok::kw_operator))
+return false;
+}
+return true;
   },
   Changes, /*StartAt=*/0);
 }

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=359711&r1=359710&r2=359711&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Wed May  1 11:23:44 2019
@@ -10581,6 +10581,13 @@ TEST_F(FormatTest, AlignConsecutiveDecla
"  unsigned c;\n"
"}",
Alignment);
+
+  // See PR37175
+  FormatStyle Style = getMozillaStyle();
+  Style.AlignConsecutiveDeclarations = true;
+  EXPECT_EQ("DECOR1 /**/ int8_t /**/ DECOR2 /**/\n"
+"foo(int a);",
+format("DECOR1 /**/ int8_t /**/ DECOR2 /**/ foo (int a);", Style));
 }
 
 TEST_F(FormatTest, LinuxBraceBreaking) {


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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-05-01 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a comment.

Ping! Is this good to go?


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

https://reviews.llvm.org/D61046



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


[PATCH] D61392: [clang] Handle lround/llround builtins

2019-05-01 Thread Adhemerval Zanella via Phabricator via cfe-commits
zatrazz created this revision.
zatrazz added reviewers: efriedma, rengolin, javed.absar, huntergr, 
SjoerdMeijer, t.p.northover, echristo, evandro.
zatrazz added a project: clang.
Herald added subscribers: kristina, kristof.beyls.

As for other floating-point rounding builtins that can be optimized
when build with -fno-math-errno, this patch adds support for lround
and llround.  It currently only optimized for AArch64 backend.

This patch depends on https://reviews.llvm.org/D61390


Repository:
  rC Clang

https://reviews.llvm.org/D61392

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGen/builtins.c
  clang/test/CodeGen/math-builtins.c
  clang/test/CodeGen/math-libcalls.c

Index: clang/test/CodeGen/math-libcalls.c
===
--- clang/test/CodeGen/math-libcalls.c
+++ clang/test/CodeGen/math-libcalls.c
@@ -317,9 +317,9 @@
 
   llround(f);llroundf(f);   llroundl(f);
 
-// NO__ERRNO: declare i64 @llround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llround.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundl(x86_fp80) [[NOT_READNONE]]
@@ -380,9 +380,9 @@
 
   lround(f); lroundf(f);lroundl(f);
 
-// NO__ERRNO: declare i64 @lround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/math-builtins.c
===
--- clang/test/CodeGen/math-builtins.c
+++ clang/test/CodeGen/math-builtins.c
@@ -362,9 +362,9 @@
 
   __builtin_llround(f);__builtin_llroundf(f);   __builtin_llroundl(f);
 
-// NO__ERRNO: declare i64 @llround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @llroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.llround.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.llround.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @llround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @llroundl(x86_fp80) [[NOT_READNONE]]
@@ -425,9 +425,9 @@
 
   __builtin_lround(f); __builtin_lroundf(f);__builtin_lroundl(f);
 
-// NO__ERRNO: declare i64 @lround(double) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundf(float) [[READNONE]]
-// NO__ERRNO: declare i64 @lroundl(x86_fp80) [[READNONE]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f64(double) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f32(float) [[READNONE_INTRINSIC]]
+// NO__ERRNO: declare i64 @llvm.lround.i64.f80(x86_fp80) [[READNONE_INTRINSIC]]
 // HAS_ERRNO: declare i64 @lround(double) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundf(float) [[NOT_READNONE]]
 // HAS_ERRNO: declare i64 @lroundl(x86_fp80) [[NOT_READNONE]]
Index: clang/test/CodeGen/builtins.c
===
--- clang/test/CodeGen/builtins.c
+++ clang/test/CodeGen/builtins.c
@@ -256,6 +256,8 @@
   volatile float resf;
   volatile double resd;
   volatile long double resld;
+  volatile long int resli;
+  volatile long long int reslli;
 
   resf = __builtin_fmodf(F,F);
   // CHECK: frem float
@@ -380,6 +382,14 @@
   resld = __builtin_roundl(LD);
   // CHECK: call x86_fp80 @llvm.round.f80
 
+  resli = __builtin_lroundf (F);
+  // CHECK: call i64 @llvm.lround.i64.f32
+
+  resli = __builtin_lround (D);
+  // CHECK: call i64 @llvm.lround.i64.f64
+
+  resli = __builtin_lroundl (LD);
+  // CHECK: call i64 @llvm.lround.i64.f80
 }
 
 // __builtin_longjmp isn't supported on all platforms, so only test it on X86.
Index: clang/lib/CodeGen/CGBuiltin.cpp
===
--- clang/lib/CodeGen/CGBuiltin.cpp
+++ clang/lib/CodeGen/CGBuiltin.cpp
@@ -1721,6 +1721,27 @@
 case Builtin::BI__builtin_truncl:
   return RValue::get(emitUnaryBuiltin(*this, E, Intrinsic::trunc));
 
+case Builtin::BIlround:
+case Builtin::BIlroundf:
+case Builtin::BIlroundl:
+case Bui

[PATCH] D61392: [clang] Handle lround/llround builtins

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

Looks fine, once the LLVM changes are settled.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61392



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


[PATCH] D61389: Bump DIAG_SIZE_SEMA up to 4000

2019-05-01 Thread Bruno Ricci via Phabricator via cfe-commits
riccibruno added a comment.

Already done in r359702 :)


Repository:
  rC Clang

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

https://reviews.llvm.org/D61389



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


r359713 - [Parser] Avoid correcting delayed typos in array subscript multiple times.

2019-05-01 Thread Volodymyr Sapsai via cfe-commits
Author: vsapsai
Date: Wed May  1 12:24:50 2019
New Revision: 359713

URL: http://llvm.org/viewvc/llvm-project?rev=359713&view=rev
Log:
[Parser] Avoid correcting delayed typos in array subscript multiple times.

We correct some typos in `ActOnArraySubscriptExpr` and
`ActOnOMPArraySectionExpr`, so when their result is `ExprError`, we can
end up correcting delayed typos in the same expressions again. In
general it is OK but when `NumTypos` is incorrect, we can hit the
assertion

> Assertion failed: (Entry != DelayedTypos.end() && "Failed to get the state 
> for a TypoExpr!"), function getTypoExprState, file 
> clang/lib/Sema/SemaLookup.cpp, line 5219.

Fix by replacing some subscript `ExprResult` with typo-corrected expressions
instead of keeping the original expressions. Thus if original expressions
contained `TypoExpr`, we'll use corrected expressions instead of trying to
correct them again.

rdar://problem/47403222

Reviewers: rsmith, erik.pilkington, majnemer

Reviewed By: erik.pilkington

Subscribers: jkorous, dexonsmith, cfe-commits

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


Added:
cfe/trunk/test/SemaObjC/typo-correction-subscript.m
Modified:
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/test/SemaCXX/typo-correction.cpp

Modified: cfe/trunk/lib/Parse/ParseExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseExpr.cpp?rev=359713&r1=359712&r2=359713&view=diff
==
--- cfe/trunk/lib/Parse/ParseExpr.cpp (original)
+++ cfe/trunk/lib/Parse/ParseExpr.cpp Wed May  1 12:24:50 2019
@@ -1582,7 +1582,9 @@ Parser::ParsePostfixExpressionSuffix(Exp
 
   SourceLocation RLoc = Tok.getLocation();
 
-  ExprResult OrigLHS = LHS;
+  LHS = Actions.CorrectDelayedTyposInExpr(LHS);
+  Idx = Actions.CorrectDelayedTyposInExpr(Idx);
+  Length = Actions.CorrectDelayedTyposInExpr(Length);
   if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() &&
   Tok.is(tok::r_square)) {
 if (ColonLoc.isValid()) {
@@ -1594,12 +1596,6 @@ Parser::ParsePostfixExpressionSuffix(Exp
 }
   } else {
 LHS = ExprError();
-  }
-  if (LHS.isInvalid()) {
-(void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
-(void)Actions.CorrectDelayedTyposInExpr(Idx);
-(void)Actions.CorrectDelayedTyposInExpr(Length);
-LHS = ExprError();
 Idx = ExprError();
   }
 

Modified: cfe/trunk/test/SemaCXX/typo-correction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/typo-correction.cpp?rev=359713&r1=359712&r2=359713&view=diff
==
--- cfe/trunk/test/SemaCXX/typo-correction.cpp (original)
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp Wed May  1 12:24:50 2019
@@ -678,7 +678,7 @@ namespace {
 struct a0is0 {};
 struct b0is0 {};
 int g() {
-  0 [ // expected-error {{subscripted value is not an array}}
+  0 [
   sizeof(c0is0)]; // expected-error {{use of undeclared identifier}}
 };
 }

Added: cfe/trunk/test/SemaObjC/typo-correction-subscript.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/typo-correction-subscript.m?rev=359713&view=auto
==
--- cfe/trunk/test/SemaObjC/typo-correction-subscript.m (added)
+++ cfe/trunk/test/SemaObjC/typo-correction-subscript.m Wed May  1 12:24:50 2019
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only 
-Wno-objc-root-class %s -verify -disable-free
+
+@class Dictionary;
+
+@interface Test
+@end
+@implementation Test
+// rdar://problem/47403222
+- (void)rdar47403222:(Dictionary *)opts {
+  [self undeclaredMethod:undeclaredArg];
+  // expected-error@-1{{no visible @interface for 'Test' declares the selector 
'undeclaredMethod:'}}
+  opts[(__bridge id)undeclaredKey] = 0;
+  // expected-error@-1{{use of undeclared identifier 'undeclaredKey'}}
+}
+@end


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


[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-05-01 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added inline comments.



Comment at: clang/include/clang/AST/DeclCXX.h:2579
+assert(
+!ES.getExpr() ||
+CXXConstructorDeclBits.HasTrailingExplicitSpecifier &&

Tyker wrote:
> Rakete wrote:
> > Your or needs parens or the disambiguation is wrong.
> i don't understand. but there is no need for disambiguation, `a && true == a` 
> so this will work regardless of operator priority.
Yeah sorry you're right, I meant that the parens are needed to shut up -Wparens 
warning about disambiguation.



Comment at: clang/include/clang/Serialization/ASTReader.h:2435
+uint64_t Kind = readInt();
+bool hasExpr = Kind & 0x1;
+Kind = Kind >> 1;

Tyker wrote:
> Rakete wrote:
> > same here.
> what is the issue
> For consistency with nearby code, please name this variable starting with a 
> capital letter.


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

https://reviews.llvm.org/D60934



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


[PATCH] D60848: [Parser] Avoid correcting delayed typos in array subscript multiple times.

2019-05-01 Thread Volodymyr Sapsai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359713: [Parser] Avoid correcting delayed typos in array 
subscript multiple times. (authored by vsapsai, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60848?vs=197421&id=197608#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60848

Files:
  cfe/trunk/lib/Parse/ParseExpr.cpp
  cfe/trunk/test/SemaCXX/typo-correction.cpp
  cfe/trunk/test/SemaObjC/typo-correction-subscript.m


Index: cfe/trunk/lib/Parse/ParseExpr.cpp
===
--- cfe/trunk/lib/Parse/ParseExpr.cpp
+++ cfe/trunk/lib/Parse/ParseExpr.cpp
@@ -1582,7 +1582,9 @@
 
   SourceLocation RLoc = Tok.getLocation();
 
-  ExprResult OrigLHS = LHS;
+  LHS = Actions.CorrectDelayedTyposInExpr(LHS);
+  Idx = Actions.CorrectDelayedTyposInExpr(Idx);
+  Length = Actions.CorrectDelayedTyposInExpr(Length);
   if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() &&
   Tok.is(tok::r_square)) {
 if (ColonLoc.isValid()) {
@@ -1594,12 +1596,6 @@
 }
   } else {
 LHS = ExprError();
-  }
-  if (LHS.isInvalid()) {
-(void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
-(void)Actions.CorrectDelayedTyposInExpr(Idx);
-(void)Actions.CorrectDelayedTyposInExpr(Length);
-LHS = ExprError();
 Idx = ExprError();
   }
 
Index: cfe/trunk/test/SemaCXX/typo-correction.cpp
===
--- cfe/trunk/test/SemaCXX/typo-correction.cpp
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp
@@ -678,7 +678,7 @@
 struct a0is0 {};
 struct b0is0 {};
 int g() {
-  0 [ // expected-error {{subscripted value is not an array}}
+  0 [
   sizeof(c0is0)]; // expected-error {{use of undeclared identifier}}
 };
 }
Index: cfe/trunk/test/SemaObjC/typo-correction-subscript.m
===
--- cfe/trunk/test/SemaObjC/typo-correction-subscript.m
+++ cfe/trunk/test/SemaObjC/typo-correction-subscript.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only 
-Wno-objc-root-class %s -verify -disable-free
+
+@class Dictionary;
+
+@interface Test
+@end
+@implementation Test
+// rdar://problem/47403222
+- (void)rdar47403222:(Dictionary *)opts {
+  [self undeclaredMethod:undeclaredArg];
+  // expected-error@-1{{no visible @interface for 'Test' declares the selector 
'undeclaredMethod:'}}
+  opts[(__bridge id)undeclaredKey] = 0;
+  // expected-error@-1{{use of undeclared identifier 'undeclaredKey'}}
+}
+@end


Index: cfe/trunk/lib/Parse/ParseExpr.cpp
===
--- cfe/trunk/lib/Parse/ParseExpr.cpp
+++ cfe/trunk/lib/Parse/ParseExpr.cpp
@@ -1582,7 +1582,9 @@
 
   SourceLocation RLoc = Tok.getLocation();
 
-  ExprResult OrigLHS = LHS;
+  LHS = Actions.CorrectDelayedTyposInExpr(LHS);
+  Idx = Actions.CorrectDelayedTyposInExpr(Idx);
+  Length = Actions.CorrectDelayedTyposInExpr(Length);
   if (!LHS.isInvalid() && !Idx.isInvalid() && !Length.isInvalid() &&
   Tok.is(tok::r_square)) {
 if (ColonLoc.isValid()) {
@@ -1594,12 +1596,6 @@
 }
   } else {
 LHS = ExprError();
-  }
-  if (LHS.isInvalid()) {
-(void)Actions.CorrectDelayedTyposInExpr(OrigLHS);
-(void)Actions.CorrectDelayedTyposInExpr(Idx);
-(void)Actions.CorrectDelayedTyposInExpr(Length);
-LHS = ExprError();
 Idx = ExprError();
   }
 
Index: cfe/trunk/test/SemaCXX/typo-correction.cpp
===
--- cfe/trunk/test/SemaCXX/typo-correction.cpp
+++ cfe/trunk/test/SemaCXX/typo-correction.cpp
@@ -678,7 +678,7 @@
 struct a0is0 {};
 struct b0is0 {};
 int g() {
-  0 [ // expected-error {{subscripted value is not an array}}
+  0 [
   sizeof(c0is0)]; // expected-error {{use of undeclared identifier}}
 };
 }
Index: cfe/trunk/test/SemaObjC/typo-correction-subscript.m
===
--- cfe/trunk/test/SemaObjC/typo-correction-subscript.m
+++ cfe/trunk/test/SemaObjC/typo-correction-subscript.m
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -triple i386-apple-macosx10.10 -fobjc-arc -fsyntax-only -Wno-objc-root-class %s -verify -disable-free
+
+@class Dictionary;
+
+@interface Test
+@end
+@implementation Test
+// rdar://problem/47403222
+- (void)rdar47403222:(Dictionary *)opts {
+  [self undeclaredMethod:undeclaredArg];
+  // expected-error@-1{{no visible @interface for 'Test' declares the selector 'undeclaredMethod:'}}
+  opts[(__bridge id)undeclaredKey] = 0;
+  // expected-error@-1{{use of undeclared identifier 'undeclar

[PATCH] D60925: [analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden

2019-05-01 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus updated this revision to Diff 197609.
Szelethus edited the summary of this revision.
Szelethus added a comment.

Hide `security.insecureAPI.SecuritySyntaxChecker` by default.


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

https://reviews.llvm.org/D60925

Files:
  include/clang/Driver/CC1Options.td
  include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
  include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  lib/Frontend/CompilerInvocation.cpp
  lib/FrontendTool/ExecuteCompilerInvocation.cpp
  lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  test/Analysis/show-checker-list.c
  utils/TableGen/ClangSACheckersEmitter.cpp

Index: utils/TableGen/ClangSACheckersEmitter.cpp
===
--- utils/TableGen/ClangSACheckersEmitter.cpp
+++ utils/TableGen/ClangSACheckersEmitter.cpp
@@ -110,6 +110,16 @@
   return "";
 }
 
+static bool isHidden(const Record *R) {
+  if (R->getValueAsBit("Hidden"))
+return true;
+  // Not declared as hidden, check the parent package if it is hidden.
+  if (DefInit *DI = dyn_cast(R->getValueInit("ParentPackage")))
+return isHidden(DI->getDef());
+
+  return false;
+}
+
 static void printChecker(llvm::raw_ostream &OS, const Record &R) {
 OS << "CHECKER(" << "\"";
 OS.write_escaped(getCheckerFullName(&R)) << "\", ";
@@ -118,7 +128,14 @@
 OS.write_escaped(getStringValue(R, "HelpText")) << "\", ";
 OS << "\"";
 OS.write_escaped(getCheckerDocs(R));
-OS << "\"";
+OS << "\", ";
+
+if (!isHidden(&R))
+  OS << "false";
+else
+  OS << "true";
+
+OS << ")\n";
 }
 
 namespace clang {
@@ -206,7 +223,6 @@
 "\n";
   for (const Record *checker : checkers) {
 printChecker(OS, *checker);
-OS << ")\n";
   }
   OS << "\n"
 "#endif // GET_CHECKERS\n"
Index: test/Analysis/show-checker-list.c
===
--- /dev/null
+++ test/Analysis/show-checker-list.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -analyzer-checker-help \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK
+
+// RUN: %clang_cc1 -analyzer-checker-help-hidden \
+// RUN:   2>&1 | FileCheck %s -check-prefix=CHECK-HIDDEN
+
+// CHECK: core.DivideZero
+// CHECK-HIDDEN: core.DivideZero
+
+// CHECK-NOT: unix.DynamicMemoryModeling
+// CHECK-HIDDEN: unix.DynamicMemoryModeling
Index: lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
===
--- lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
+++ lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
@@ -115,9 +115,9 @@
 
   // Register builtin checkers.
 #define GET_CHECKERS
-#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI)\
+#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \
   addChecker(register##CLASS, shouldRegister##CLASS, FULLNAME, HELPTEXT,   \
- DOC_URI);
+ DOC_URI, IS_HIDDEN);
 
 #define GET_PACKAGES
 #define PACKAGE(FULLNAME) addPackage(FULLNAME);
@@ -350,8 +350,9 @@
 
 void CheckerRegistry::addChecker(InitializationFunction Rfn,
  ShouldRegisterFunction Sfn, StringRef Name,
- StringRef Desc, StringRef DocsUri) {
-  Checkers.emplace_back(Rfn, Sfn, Name, Desc, DocsUri);
+ StringRef Desc, StringRef DocsUri,
+ bool IsHidden) {
+  Checkers.emplace_back(Rfn, Sfn, Name, Desc, DocsUri, IsHidden);
 
   // Record the presence of the checker in its packages.
   StringRef PackageName, LeafName;
@@ -421,6 +422,9 @@
 
   const size_t InitialPad = 2;
   for (const auto &Checker : Checkers) {
+if (!AnOpts.ShowCheckerHelpHidden && Checker.IsHidden)
+  continue;
+
 Out.indent(InitialPad) << Checker.FullName;
 
 int Pad = OptionFieldWidth - Checker.FullName.size();
Index: lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
===
--- lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
+++ lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
@@ -256,7 +256,7 @@
 static StringRef getRuleDescription(StringRef CheckName) {
   return llvm::StringSwitch(CheckName)
 #define GET_CHECKERS
-#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI)\
+#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) \
   .Case(FULLNAME, HELPTEXT)
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef CHECKER
@@ -267,7 +267,7 @@
 static StringRef getRuleHelpURIStr(StringRef CheckName) {
   return llvm::StringSwitch(CheckName)
 #define GET_CHECKERS
-#define CHECKER(FULLNAME, CLASS, HELPTEXT,

r359717 - Make check-clang depend on the clang-check binary always

2019-05-01 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed May  1 12:34:00 2019
New Revision: 359717

URL: http://llvm.org/viewvc/llvm-project?rev=359717&view=rev
Log:
Make check-clang depend on the clang-check binary always

check-clang (the target that runs all clang tests) used to
only depend on clang-check (a binary like clang-tidy,
clang-refactor, etc) if the static analyzer is enabled.
However, several lit tests call clang-check unconditionally,
so always depend on it.

Fixes a "could not find clang-check" lit warning in clean builds with
the static analyzer disabled.

Also sort the deps in the CMake file and put just one dep on each line.

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

Modified:
cfe/trunk/test/CMakeLists.txt

Modified: cfe/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CMakeLists.txt?rev=359717&r1=359716&r2=359717&view=diff
==
--- cfe/trunk/test/CMakeLists.txt (original)
+++ cfe/trunk/test/CMakeLists.txt Wed May  1 12:34:00 2019
@@ -46,21 +46,23 @@ if(CLANG_TEST_USE_VG)
 endif ()
 
 list(APPEND CLANG_TEST_DEPS
-  clang clang-resource-headers
+  c-index-test
+  clang
+  clang-resource-headers
+  clang-check
   clang-format
-  c-index-test diagtool
   clang-tblgen
   clang-offload-bundler
   clang-import-test
   clang-rename
   clang-refactor
   clang-diff
+  diagtool
   hmaptool
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)
   list(APPEND CLANG_TEST_DEPS
-clang-check
 clang-extdef-mapping
 )
 endif()


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


[PATCH] D61324: Make check-clang depend on the clang-check binary always

2019-05-01 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359717: Make check-clang depend on the clang-check binary 
always (authored by nico, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D61324?vs=197370&id=197614#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D61324

Files:
  cfe/trunk/test/CMakeLists.txt
  llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn


Index: llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
@@ -108,6 +108,7 @@
 ":lit_unit_site_cfg",
 "//clang/lib/Headers",
 "//clang/tools/c-index-test",
+"//clang/tools/clang-check",
 "//clang/tools/clang-diff",
 "//clang/tools/clang-format",
 "//clang/tools/clang-import-test",
@@ -147,7 +148,6 @@
   }
   if (clang_enable_static_analyzer) {
 deps += [
-  "//clang/tools/clang-check",
   "//clang/tools/clang-extdef-mapping",
 ]
   }
Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -46,21 +46,23 @@
 endif ()
 
 list(APPEND CLANG_TEST_DEPS
-  clang clang-resource-headers
+  c-index-test
+  clang
+  clang-resource-headers
+  clang-check
   clang-format
-  c-index-test diagtool
   clang-tblgen
   clang-offload-bundler
   clang-import-test
   clang-rename
   clang-refactor
   clang-diff
+  diagtool
   hmaptool
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)
   list(APPEND CLANG_TEST_DEPS
-clang-check
 clang-extdef-mapping
 )
 endif()


Index: llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
===
--- llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
+++ llvm/trunk/utils/gn/secondary/clang/test/BUILD.gn
@@ -108,6 +108,7 @@
 ":lit_unit_site_cfg",
 "//clang/lib/Headers",
 "//clang/tools/c-index-test",
+"//clang/tools/clang-check",
 "//clang/tools/clang-diff",
 "//clang/tools/clang-format",
 "//clang/tools/clang-import-test",
@@ -147,7 +148,6 @@
   }
   if (clang_enable_static_analyzer) {
 deps += [
-  "//clang/tools/clang-check",
   "//clang/tools/clang-extdef-mapping",
 ]
   }
Index: cfe/trunk/test/CMakeLists.txt
===
--- cfe/trunk/test/CMakeLists.txt
+++ cfe/trunk/test/CMakeLists.txt
@@ -46,21 +46,23 @@
 endif ()
 
 list(APPEND CLANG_TEST_DEPS
-  clang clang-resource-headers
+  c-index-test
+  clang
+  clang-resource-headers
+  clang-check
   clang-format
-  c-index-test diagtool
   clang-tblgen
   clang-offload-bundler
   clang-import-test
   clang-rename
   clang-refactor
   clang-diff
+  diagtool
   hmaptool
   )
   
 if(CLANG_ENABLE_STATIC_ANALYZER)
   list(APPEND CLANG_TEST_DEPS
-clang-check
 clang-extdef-mapping
 )
 endif()
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D60974: Clang IFSO driver action.

2019-05-01 Thread Jake Ehrlich via Phabricator via cfe-commits
jakehehrlich added a comment.

In D60974#1486384 , @compnerd wrote:

> @jakehehrlich - unfortunately, removing the attributes on the sections will 
> make the content look different with `nm` which is something we do need to 
> appear proper for consumers of the interface libraries.  Versioning has a 
> number of problems inherent to it (unfortunately, its the closest to 
> multi-level namespaces in ELF).  I think that getting something in tree and 
> iterating on it is far better than continuing to argue over this in the dream 
> of something that unifies the TAPI approach and this approach.  The section 
> names are relevant (you can add attributes to put symbols into alternate 
> sections and you can have section relative relocations).  I think that you 
> are loosing fidelity in the final output which is sufficient for your needs, 
> but I think that there are places where the full fidelity can be needed.
>
> This currently works and allows us to generate the interface library which 
> means that this is actually further than what you are proposing still.  Is 
> there something technical that this is doing incorrectly or breaking 
> something?  Otherwise, this really does seem like it is devolving into a bike 
> shedding argument that isn't really going anywhere.  This is not a large 
> amount of code and there is backing to maintain it, so it is not an issue of 
> "this is adding un-maintained complexity" either.
>
> Just like the LLVM APIs, this can/will evolve.  I don't see why this needs to 
> be set in stone from the initial implementation.  There are use cases which 
> can come up which require reworking the solution.




1. The output of nm when you give it what exactly is different? What output are 
you expecting? You aren't making that specific. Passing the unmerged output 
though nm doesn't make any sense. If you have a precise use case for section 
names you should mention it. We can always add symbol information back as 
needed if we first start with something more minimal. What output of nm are you 
expecting a

2. We're basically in agreement on what should happen here. I don't think it's 
a dream of unifying these things. It looks like a very close reality to me.

3. You mention sections and relocation as being relevant information. Can you 
give a specific use case? Section names in general are not meaningful 
information. They're just there for humans to debug things. Putting symbols in 
different sections lets the linker treat them specially but in the end binary 
sections are not relevant to much of anything.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D60974



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


[PATCH] D61319: [PR41674] [OpenCL] Fix initialisation of this via pointer

2019-05-01 Thread Kévin Petit via Phabricator via cfe-commits
kpet updated this revision to Diff 197617.
kpet added a comment.

Replaced the AST dump test with an IR test.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61319

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


Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -59,7 +59,8 @@
 
 __kernel void test__global() {
   int i = c.get();
-  int i2 = c.outside();
+  int i2 = (&c)->get();
+  int i3 = c.outside();
   C c1(c);
   C c2;
   c2 = c1;
@@ -86,9 +87,11 @@
 
 // Test the address space of 'this' when invoking a method.
 // COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* 
addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
+// Test the address space of 'this' when invoking a method using a pointer to 
the object.
+// COMMON: %call1 = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* 
addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
 
 // Test the address space of 'this' when invoking a method that is declared in 
the file contex.
-// COMMON: %call1 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* 
addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
+// COMMON: %call2 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* 
addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
 
 // Test the address space of 'this' when invoking copy-constructor.
 // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C 
addrspace(4)*
@@ -130,7 +133,7 @@
 // Test the address space of 'this' when invoking the move assignment
 // COMMON: [[C5GEN:%[0-9]+]] = addrspacecast %class.C* %c5 to %class.C 
addrspace(4)*
 // COMMON: [[CALL:%call[0-9]+]] = call spir_func dereferenceable(4) %class.C 
addrspace(4)* @_Z3foov()
-// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* 
[[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call4)
+// EXPL: call void @_ZNU3AS41CC1EOU3AS4S_(%class.C addrspace(4)* 
[[C5GEN:%[0-9]+]], %class.C addrspace(4)* dereferenceable(4) %call5)
 // IMPL: [[C5VOID:%[0-9]+]] = bitcast %class.C* %c5 to i8*
 // IMPL: [[CALLVOID:%[0-9]+]] = bitcast %class.C addrspace(4)* [[CALL]] to i8 
addrspace(4)*
 // IMPL: call void @llvm.memcpy.p0i8.p4i8.i32(i8* {{.*}}[[C5VOID]], i8 
addrspace(4)* {{.*}}[[CALLVOID]]
Index: lib/Sema/SemaOverload.cpp
===
--- lib/Sema/SemaOverload.cpp
+++ lib/Sema/SemaOverload.cpp
@@ -5278,12 +5278,12 @@
   }
 
   if (!Context.hasSameType(From->getType(), DestType)) {
-if (From->getType().getAddressSpace() != DestType.getAddressSpace())
-  From = ImpCastExprToType(From, DestType, CK_AddressSpaceConversion,
- From->getValueKind()).get();
+CastKind CK;
+if (FromRecordType.getAddressSpace() != DestType.getAddressSpace())
+  CK = CK_AddressSpaceConversion;
 else
-  From = ImpCastExprToType(From, DestType, CK_NoOp,
- From->getValueKind()).get();
+  CK = CK_NoOp;
+From = ImpCastExprToType(From, DestType, CK, From->getValueKind()).get();
   }
   return From;
 }


Index: test/CodeGenOpenCLCXX/addrspace-of-this.cl
===
--- test/CodeGenOpenCLCXX/addrspace-of-this.cl
+++ test/CodeGenOpenCLCXX/addrspace-of-this.cl
@@ -59,7 +59,8 @@
 
 __kernel void test__global() {
   int i = c.get();
-  int i2 = c.outside();
+  int i2 = (&c)->get();
+  int i3 = c.outside();
   C c1(c);
   C c2;
   c2 = c1;
@@ -86,9 +87,11 @@
 
 // Test the address space of 'this' when invoking a method.
 // COMMON: %call = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
+// Test the address space of 'this' when invoking a method using a pointer to the object.
+// COMMON: %call1 = call i32 @_ZNU3AS41C3getEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
 
 // Test the address space of 'this' when invoking a method that is declared in the file contex.
-// COMMON: %call1 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
+// COMMON: %call2 = call i32 @_ZNU3AS41C7outsideEv(%class.C addrspace(4)* addrspacecast (%class.C addrspace(1)* @c to %class.C addrspace(4)*))
 
 // Test the address space of 'this' when invoking copy-constructor.
 // COMMON: [[C1GEN:%[0-9]+]] = addrspacecast %class.C* %c1 to %class.C addrspace(4)*
@@ -130,7 +133,7 @@
 // Test the address space of 'this' when invoking the move assignment
 // COMMON: [[C5GEN:%[0-9]+]] = addrspacecast %class.C* %c5 to %class.C addrspace(4)*
 // COMMON: [[CALL:%call[0-9]+]] = call spir_func dereferenceable(4)

[PATCH] D61097: [Sema] Emit warning for visibility attribute on internal-linkage declaration

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

LGTM, thank you!


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

https://reviews.llvm.org/D61097



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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

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

LGTM, thank you! That's strange that clang-format would remove the newline from 
the end of the file. I don't get that behavior when I try it, so it makes me 
wonder what's different.


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

https://reviews.llvm.org/D61239



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


r359720 - [analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden

2019-05-01 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Wed May  1 12:56:47 2019
New Revision: 359720

URL: http://llvm.org/viewvc/llvm-project?rev=359720&view=rev
Log:
[analyzer] Don't display implementation checkers under -analyzer-checker-help, 
but do under the new flag -analyzer-checker-help-hidden

During my work on analyzer dependencies, I created a great amount of new
checkers that emitted no diagnostics at all, and were purely modeling some
function or another.

However, the user shouldn't really disable/enable these by hand, hence this
patch, which hides these by default. I intentionally chose not to hide alpha
checkers, because they have a scary enough name, in my opinion, to cause no
surprise when they emit false positives or cause crashes.

The patch introduces the Hidden bit into the TableGen files (you may remember
it before I removed it in D53995), and checkers that are either marked as
hidden, or are in a package that is marked hidden won't be displayed under
-analyzer-checker-help. -analyzer-checker-help-hidden, a new flag meant for
developers only, displays the full list.

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

Added:
cfe/trunk/test/Analysis/show-checker-list.c
Modified:
cfe/trunk/include/clang/Driver/CC1Options.td
cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
cfe/trunk/lib/Frontend/CompilerInvocation.cpp
cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp

Modified: cfe/trunk/include/clang/Driver/CC1Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CC1Options.td?rev=359720&r1=359719&r2=359720&view=diff
==
--- cfe/trunk/include/clang/Driver/CC1Options.td (original)
+++ cfe/trunk/include/clang/Driver/CC1Options.td Wed May  1 12:56:47 2019
@@ -107,7 +107,7 @@ def analyzer_checker : Separate<["-"], "
   ValuesCode<[{
 const char *Values =
 #define GET_CHECKERS
-#define CHECKER(FULLNAME, CLASS, HT, DOC_URI)  FULLNAME ","
+#define CHECKER(FULLNAME, CLASS, HT, DOC_URI, IS_HIDDEN)  FULLNAME ","
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"
 #undef GET_CHECKERS
 #define GET_PACKAGES
@@ -130,6 +130,10 @@ def analyzer_disable_all_checks : Flag<[
 def analyzer_checker_help : Flag<["-"], "analyzer-checker-help">,
   HelpText<"Display the list of analyzer checkers that are available">;
 
+def analyzer_checker_help_hidden : Flag<["-"], "analyzer-checker-help-hidden">,
+  HelpText<"Display the list of analyzer checkers that are available, "
+   "including modeling checkers">;
+
 def analyzer_config_help : Flag<["-"], "analyzer-config-help">,
   HelpText<"Display the list of -analyzer-config options">;
 

Modified: 
cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h?rev=359720&r1=359719&r2=359720&view=diff
==
--- 
cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h 
(original)
+++ 
cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h 
Wed May  1 12:56:47 2019
@@ -26,7 +26,7 @@ class CheckerManager;
 class CheckerRegistry;
 
 #define GET_CHECKERS
-#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI)
\
+#define CHECKER(FULLNAME, CLASS, HELPTEXT, DOC_URI, IS_HIDDEN) 
\
   void register##CLASS(CheckerManager &mgr);   
\
   bool shouldRegister##CLASS(const LangOptions &LO);
 #include "clang/StaticAnalyzer/Checkers/Checkers.inc"

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td?rev=359720&r1=359719&r2=359720&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td Wed May  1 
12:56:47 2019
@@ -49,6 +49,7 @@ class Package {
   // This field is optional.
   list PackageOptions;
   Package ParentPackage;
+  bit Hidden = 0;
 }
 
 /// Describes a 'super' package that holds another package inside it. This is
@@ -91,6 +92,7 @@ class Checker {
   list   Dependenc

[PATCH] D60925: [analyzer] Don't display implementation checkers under -analyzer-checker-help, but do under the new flag -analyzer-checker-help-hidden

2019-05-01 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL359720: [analyzer] Don't display implementation 
checkers under -analyzer-checker-help… (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D60925?vs=197609&id=197620#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D60925

Files:
  cfe/trunk/include/clang/Driver/CC1Options.td
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/BuiltinCheckerRegistration.h
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
  cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
  cfe/trunk/lib/Frontend/CompilerInvocation.cpp
  cfe/trunk/lib/FrontendTool/ExecuteCompilerInvocation.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/AnalyzerOptions.cpp
  cfe/trunk/lib/StaticAnalyzer/Core/SarifDiagnostics.cpp
  cfe/trunk/lib/StaticAnalyzer/Frontend/CheckerRegistry.cpp
  cfe/trunk/test/Analysis/show-checker-list.c
  cfe/trunk/utils/TableGen/ClangSACheckersEmitter.cpp

Index: cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h
@@ -137,6 +137,7 @@
 StringRef Desc;
 StringRef DocumentationUri;
 CmdLineOptionList CmdLineOptions;
+bool IsHidden = false;
 StateFromCmdLine State = StateFromCmdLine::State_Unspecified;
 
 ConstCheckerInfoList Dependencies;
@@ -150,9 +151,10 @@
 }
 
 CheckerInfo(InitializationFunction Fn, ShouldRegisterFunction sfn,
-StringRef Name, StringRef Desc, StringRef DocsUri)
+StringRef Name, StringRef Desc, StringRef DocsUri,
+bool IsHidden)
 : Initialize(Fn), ShouldRegister(sfn), FullName(Name), Desc(Desc),
-  DocumentationUri(DocsUri) {}
+  DocumentationUri(DocsUri), IsHidden(IsHidden) {}
 
 // Used for lower_bound.
 explicit CheckerInfo(StringRef FullName) : FullName(FullName) {}
@@ -190,16 +192,19 @@
   /// Adds a checker to the registry. Use this non-templated overload when your
   /// checker requires custom initialization.
   void addChecker(InitializationFunction Fn, ShouldRegisterFunction sfn,
-  StringRef FullName, StringRef Desc, StringRef DocsUri);
+  StringRef FullName, StringRef Desc, StringRef DocsUri,
+  bool IsHidden);
 
   /// Adds a checker to the registry. Use this templated overload when your
   /// checker does not require any custom initialization.
   template 
-  void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri) {
+  void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri,
+  bool IsHidden = false) {
 // Avoid MSVC's Compiler Error C2276:
 // http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx
 addChecker(&CheckerRegistry::initializeManager,
-   &CheckerRegistry::returnTrue, FullName, Desc, DocsUri);
+   &CheckerRegistry::returnTrue, FullName, Desc, DocsUri,
+   IsHidden);
   }
 
   /// Makes the checker with the full name \p fullName depends on the checker
Index: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
===
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
@@ -197,6 +197,7 @@
   unsigned DisableAllChecks : 1;
 
   unsigned ShowCheckerHelp : 1;
+  unsigned ShowCheckerHelpHidden : 1;
   unsigned ShowEnabledCheckerList : 1;
   unsigned ShowConfigOptionsList : 1;
   unsigned ShouldEmitErrorsOnInvalidConfigValue : 1;
Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/CheckerBase.td
@@ -49,6 +49,7 @@
   // This field is optional.
   list PackageOptions;
   Package ParentPackage;
+  bit Hidden = 0;
 }
 
 /// Describes a 'super' package that holds another package inside it. This is
@@ -91,6 +92,7 @@
   list   Dependencies;
   bits<2> Documentation;
   Package ParentPackage;
+  bit Hidden = 0;
 }
 
 /// Describes a list of checker options.
@@ -108,3 +110,7 @@
 class Dependencies Deps = []> {
   list Dependencies = Deps;
 }
+
+/// Marks a checker or a package hidden. Hidden entries won't be displayed in
+/// -analyzer-checker-help, which is desirable for alpha or modeling c

[PATCH] D60934: [clang] adding explicit(bool) from c++2a

2019-05-01 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: clang/lib/Sema/SemaInit.cpp:9361
 // Only consider converting constructors.
-if (GD->isExplicit())
+if (!GD->isMaybeNotExplicit())
   continue;

Tyker wrote:
> rsmith wrote:
> > Tyker wrote:
> > > rsmith wrote:
> > > > Tyker wrote:
> > > > > rsmith wrote:
> > > > > > We need to substitute into the deduction guide first to detect 
> > > > > > whether it forms a "converting constructor", and that will need to 
> > > > > > be done inside `AddTemplateOverloadCandidate`.
> > > > > similarly as the previous if. this check removes deduction guide that 
> > > > > are already resolve to be explicit when we are in a context that 
> > > > > doesn't allow explicit.
> > > > > every time the explicitness was checked before my change i replaced 
> > > > > it by a check that removes already resolved explicit specifiers.
> > > > Unlike in the previous case, we do //not// yet pass an `AllowExplicit` 
> > > > flag into `AddTemplateOverloadCandidate` here, so this will incorrectly 
> > > > allow dependent //explicit-specifier//s that evaluate to `true` in 
> > > > copy-initialization contexts.
> > > the default value for `AllowExplicit` is false. so the conversion will be 
> > > removed in `AddTemplateOverloadCandidate`.
> > That doesn't sound right: that'd mean we never use explicit deduction 
> > guides (we never pass `AllowExplicit = true` to 
> > `AddTemplateOverloadCandidate`). Do we have any test coverage that 
> > demonstrates that conditionally-explicit deduction guides are handled 
> > properly?
> my mistake. the default value for AllowExplicit is false. but 
> AddTemplateOverloadCandidate will only remove conversions and constructors. 
> dependent explicit specifier that are resolved to true on deduction guides 
> are removed at line 9480. they are not removed from the overload set. CTAD 
> just fails if a explicit deduction guide is selected in a CopyInitList. i 
> agree this is weird but the behavior is the same as before the patch.
> the result on clang is:
> ```
> template
> struct A {
>   explicit A(T);
> };
> A a = 0; // error with explicit constructor meaning CTAD succeed.
> A a = { 0 }; // error with explicit deduction guide
> ```
> all compiler don't agree on this https://godbolt.org/z/ElHlkE. icc and clang 
> have this behavior, gcc and msvc fail at CTAD time on both initialization. as 
> of what the standard say from what i read, it isn't clear, the standard is 
> clear when calling an explicit constructor should fail. but it doesn't appear 
> to say for deduction guides.
> as this was the previous behavior i did not change it with explicit(bool).
> the standard is clear when calling an explicit constructor should fail. but 
> it doesn't appear to say for deduction guides

The standard says that you take the set of deduction guides and notionally form 
a set of constructors from them (see [over.match.class.deduct]). So the 
constructor rules apply to deduction guides too.

> as this was the previous behavior i did not change it with explicit(bool).

I don't think that's correct. We filter out explicit deduction guides for 
non-list copy-initialization on line ~9239 (prior to this change). Today we get 
this result:

```
template struct X { X(int); };

explicit X(int) -> X; // #1

X a = 0; // error: no viable deduction guide, #1 is not a candidate
X b = {0}; // error: selected explicit deduction guide #1
X c{0}; // ok
X d(0); // ok
```

... which is correct. If we change the deduction guide to have a dependent 
`explicit(bool)` specifier:

```
template
explicit(E) X(int) -> X;
```

... we should get the same result, but I think we won't get that result with 
this patch: I think we'll incorrectly select an explicit deduction guide for 
the declaration of `a`, because we never filter out explicit deduction guides.

`DeduceTemplateSpecializationFromInitializer` should compute an `AllowExplicit` 
flag (`= !Kind.isCopyInit() || ListInit`), pass it into 
`AddTemplateOverloadCandidate`, and that should filter out explicit deduction 
guide specializations if it's `true`.


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

https://reviews.llvm.org/D60934



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


[PATCH] D59744: Fix i386 ABI "__m64" type bug

2019-05-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: lib/CodeGen/TargetInfo.cpp:919
 /// IsX86_MMXType - Return true if this is an MMX type.
 bool IsX86_MMXType(llvm::Type *IRType) {
-  // Return true if the type is an MMX type <2 x i32>, <4 x i16>, or <8 x i8>.

wxiao3 wrote:
> rnk wrote:
> > I think looking at the LLVM type to decide how something should be passed 
> > is a bad pattern to follow. We should look at the clang AST to decide how 
> > things will be passed, not LLVM types. Would that be complicated? Are there 
> > aggregate types that end up getting passed directly in MMX registers?
> For x86 32 bit target, no aggregate types end up getting passed in MMX 
> register.
> The only type passed by MMX is 
> 
> > __m64
> 
>  which is defined in header file (mmintrin.h):
> 
> 
> ```
> typedef long long __m64 __attribute__((__vector_size__(8), __aligned__(8)));
> ```
> 
> Yes, it would be good if we define _m64 as a builtin type and handle it in 
> AST level. But I'm afraid that it won't be a trivial work. Since GCC also 
> handles __m64 in the same way as Clang currently does, can we just keep 
> current implementation as it is?
> 
That's not quite what I'm suggesting. I'm saying that IsX86_MMXType should take 
a QualType parameter, and it should check if that qualtype looks like the __m64 
vector type, instead of converting the QualType to llvm::Type and then checking 
if the llvm::Type is a 64-bit vector. Does that seem reasonable? See the code 
near the call site conditionalized on IsDarwinVectorABI which already has 
similar logic.


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

https://reviews.llvm.org/D59744



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


[PATCH] D61396: [hip] Fix ambiguity from `>>>` of CUDA.

2019-05-01 Thread Michael Liao via Phabricator via cfe-commits
hliao created this revision.
hliao added reviewers: tra, yaxunl.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

- For template arguments ending with `>>>`, we should cease lookahead and treat 
it as type-id firstly, so that deduction could work properly.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D61396

Files:
  clang/lib/Parse/ParseTentative.cpp
  clang/test/Parser/cuda-kernel-call-c++11.cu


Index: clang/test/Parser/cuda-kernel-call-c++11.cu
===
--- clang/test/Parser/cuda-kernel-call-c++11.cu
+++ clang/test/Parser/cuda-kernel-call-c++11.cu
@@ -3,6 +3,8 @@
 template struct S {};
 template void f();
 
+template struct S {};
+
 
 void foo(void) {
   // In C++11 mode, all of these are expected to parse correctly, and the CUDA
@@ -21,4 +23,6 @@
 
   (void)(&f>>==0);
   (void)(&f>>==0);
+
+  S>> s6;
 }
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -593,7 +593,8 @@
  (Tok.is(tok::greatergreater) ||
   (Tok.is(tok::ellipsis) &&
NextToken().isOneOf(tok::greater, tok::greatergreater,
-   tok::comma)) {
+   tok::comma ||
+(getLangOpts().CUDA && Tok.is(tok::greatergreatergreater {
   TPR = TPResult::True;
   isAmbiguous = true;
 


Index: clang/test/Parser/cuda-kernel-call-c++11.cu
===
--- clang/test/Parser/cuda-kernel-call-c++11.cu
+++ clang/test/Parser/cuda-kernel-call-c++11.cu
@@ -3,6 +3,8 @@
 template struct S {};
 template void f();
 
+template struct S {};
+
 
 void foo(void) {
   // In C++11 mode, all of these are expected to parse correctly, and the CUDA
@@ -21,4 +23,6 @@
 
   (void)(&f>>==0);
   (void)(&f>>==0);
+
+  S>> s6;
 }
Index: clang/lib/Parse/ParseTentative.cpp
===
--- clang/lib/Parse/ParseTentative.cpp
+++ clang/lib/Parse/ParseTentative.cpp
@@ -593,7 +593,8 @@
  (Tok.is(tok::greatergreater) ||
   (Tok.is(tok::ellipsis) &&
NextToken().isOneOf(tok::greater, tok::greatergreater,
-   tok::comma)) {
+   tok::comma ||
+(getLangOpts().CUDA && Tok.is(tok::greatergreatergreater {
   TPR = TPResult::True;
   isAmbiguous = true;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r359722 - Make clang/utils/creduce-clang-crash.py executable

2019-05-01 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Wed May  1 13:15:39 2019
New Revision: 359722

URL: http://llvm.org/viewvc/llvm-project?rev=359722&view=rev
Log:
Make clang/utils/creduce-clang-crash.py executable

Modified:
cfe/trunk/utils/creduce-clang-crash.py   (props changed)

Propchange: cfe/trunk/utils/creduce-clang-crash.py
--
svn:executable = *


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


[PATCH] D61239: [libclang] Allow field offset lookups in types with incomplete arrays.

2019-05-01 Thread Jorn Vernee via Phabricator via cfe-commits
JornVernee added a comment.

In D61239#1486634 , @aaron.ballman 
wrote:

> LGTM, thank you! That's strange that clang-format would remove the newline 
> from the end of the file. I don't get that behavior when I try it, so it 
> makes me wonder what's different.


Yeah, my mistake. It was there after all. The output from clang-format looked 
the same as what I had before, but I think I just didn't catch the newline when 
copy-pasting the diff the first time :)

Also, I don't have committer access. Would you mind committing this?


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

https://reviews.llvm.org/D61239



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


[PATCH] D60349: [COFF, ARM64] Fix ABI implementation of struct returns

2019-05-01 Thread Richard Townsend (Arm) via Phabricator via cfe-commits
richard.townsend.arm added a comment.

And with those modifications, everything seems to work correctly. I'd be fine 
with the LLVM portion landing at this stage, but one more rev and another test 
cycle for this patch would be ideal.




Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1085
+return true;
+  if (IsSizeGreaterThan128(RD))
+return true;

So... to get the latest diff working, I had to remove this check...



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1096
+  bool isAArch64 = CGM.getTarget().getTriple().isAArch64();
+  bool isIndirectReturn = isAArch64 ?
+(passClassIndirect(RD) || hasMicrosoftABIRestrictions(RD)) :

I also had to amend this to:

```bool isIndirectReturn = isAArch64 ?
(passClassIndirect(RD) || hasMicrosoftABIRestrictions(RD)
   || IsSizeGreaterThan128(RD)) :
!RD->isPOD();```



Comment at: lib/CodeGen/MicrosoftCXXABI.cpp:1106
+
+FI.getReturnInfo().setInReg(isAArch64 && !IsSizeGreaterThan128(RD));
 

... and also amend this to `FI.getReturnInfo().setInReg(isAArch64 && 
!(isAggregate && IsSizeGreaterThan128(RD)));` 


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

https://reviews.llvm.org/D60349



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


[PATCH] D61396: [hip] Fix ambiguity from `>>>` of CUDA.

2019-05-01 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

LGTM, but I've added @rsmith who is way more familiar with this code.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61396



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


[PATCH] D61396: [hip] Fix ambiguity from `>>>` of CUDA.

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

In D61396#1486706 , @tra wrote:

> LGTM, but I've added @rsmith who is way more familiar with this code.


sure, no rush, let's wait for comments from @rsmith


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61396



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


[PATCH] D42642: [CUDA] Detect installation in PATH

2019-05-01 Thread Alexandre Ganea via Phabricator via cfe-commits
aganea added a subscriber: rnk.
aganea added a comment.

So it turns out this is a symlink issue. The file 
`clang/trunk/test/Driver/Inputs/CUDA-symlinks/usr/bin/ptxas` has been 
synchronized on my Windows 10 PC as a regular text file, not a symlink. It 
looks like TortoiseSVN doesn't implement symlinks. As WSL inherits of my file 
system, it will not find the symbolic link. I suppose `REQUIRES: 
!system-windows` isn't enough for `cuda-detect-path.cu`, and it would need 
something like `REQUIRES: symlinks` along with support in lit. @rnk


Repository:
  rL LLVM

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

https://reviews.llvm.org/D42642



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-01 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea created this revision.
gtbercea added reviewers: hfinkel, caomhin, ABataev, tra.
Herald added subscribers: cfe-commits, guansong, mgorny.
Herald added a project: clang.

In this patch we propose a temporary solution to resolving math functions for 
the NVPTX toolchain, temporary until OpenMP variant is supported by Clang.

We intercept the inclusion of math.h and cmath headers and if we are in the 
OpenMP-NVPTX case, we re-use CUDA's math function resolution mechanism.

Authors:
gbercea
@jdoerfert


Repository:
  rC Clang

https://reviews.llvm.org/D61399

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h

Index: lib/Headers/openmp_wrappers/math.h
===
--- /dev/null
+++ lib/Headers/openmp_wrappers/math.h
@@ -0,0 +1,9 @@
+// File: clang/lib/Headers/math.h
+
+#include <__clang_openmp_math.h>
+
+#ifndef __NO_HOST_MATH__
+#include_next 
+#else
+#undef __NO_HOST_MATH__
+#endif
\ No newline at end of file
Index: lib/Headers/openmp_wrappers/cmath
===
--- /dev/null
+++ lib/Headers/openmp_wrappers/cmath
@@ -0,0 +1,7 @@
+#include <__clang_openmp_math.h>
+
+#ifndef __NO_HOST_MATH__
+#include_next 
+#else
+#undef __NO_HOST_MATH__
+#endif
Index: lib/Headers/openmp_wrappers/__clang_openmp_math.h
===
--- /dev/null
+++ lib/Headers/openmp_wrappers/__clang_openmp_math.h
@@ -0,0 +1,50 @@
+/*=== __clang_openmp_math.h - OpenMP target math support ---===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#if defined(__NVPTX__) && defined(_OPENMP)
+/// TODO:
+/// We are currently reusing the functionality of the Clang-CUDA code path
+/// as an alternative to the host declarations provided by math.h and cmath.
+/// This is suboptimal.
+///
+/// We should instead declare the device functions in a similar way, e.g.,
+/// through OpenMP 5.0 variants, and afterwards populate the module with the
+/// host declarations by unconditionally including the host math.h or cmath,
+/// respectively. This is actually what the Clang-CUDA code path does, using
+/// __device__ instead of variants to avoid redeclarations and get the desired
+/// overload resolution.
+
+#define __CUDA__
+
+#if defined(__cplusplus)
+  #include <__clang_cuda_math_forward_declares.h>
+#endif
+
+#define __forceinline__ __attribute__((always_inline))
+
+// CUDA 9.1 no longer provides declarations for libdevice functions, so we need
+// to provide our own.
+#include <__clang_cuda_libdevice_declares.h>
+
+// Wrappers for many device-side standard library functions became compiler
+// builtins in CUDA-9 and have been removed from the CUDA headers. Clang now
+// provides its own implementation of the wrappers.
+// #if CUDA_VERSION >= 9000
+#include <__clang_cuda_device_functions.h>
+
+#if defined(__cplusplus)
+  #include <__clang_cuda_cmath.h>
+#endif
+
+#undef __CUDA__
+
+/// Magic macro for stopping the math.h/cmath host header from being included.
+#define __NO_HOST_MATH__
+
+#endif
\ No newline at end of file
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -20,8 +20,12 @@
 // would preclude the use of our own __device__ overloads for these functions.
 
 #pragma push_macro("__DEVICE__")
+#ifdef _OPENMP
+#define __DEVICE__ static __inline__ __attribute__((always_inline))
+#else
 #define __DEVICE__ \
   static __inline__ __attribute__((always_inline)) __attribute__((device))
+#endif
 
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
Index: lib/Headers/__clang_cuda_libdevice_declares.h
===
--- lib/Headers/__clang_cuda_libdevice_declares.h
+++ lib/Headers/__clang_cuda_libdevice_declares.h
@@ -10,443 +10,453 @@
 #ifndef __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 #define __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 
+#if defined(__cplusplus)
 extern "C" {
+#endif
 
-__device__ int __nv_abs(int __a);
-__device__ double __nv_acos(double __a);
-__device__ float __nv_acosf(float __a);
-__device__ double __nv_acosh(double __a);
-__device__ float __nv_acoshf(float __a);
-__device__ double __nv_asin(double _

r359727 - [analyzer] Fix buildbot failures caused by a forgotten initialization

2019-05-01 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Wed May  1 14:09:32 2019
New Revision: 359727

URL: http://llvm.org/viewvc/llvm-project?rev=359727&view=rev
Log:
[analyzer] Fix buildbot failures caused by a forgotten initialization

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h?rev=359727&r1=359726&r2=359727&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/AnalyzerOptions.h Wed May  1 
14:09:32 2019
@@ -261,11 +261,12 @@ public:
 
   AnalyzerOptions()
   : DisableAllChecks(false), ShowCheckerHelp(false),
-ShowEnabledCheckerList(false), ShowConfigOptionsList(false),
-AnalyzeAll(false), AnalyzerDisplayProgress(false),
-AnalyzeNestedBlocks(false), eagerlyAssumeBinOpBifurcation(false),
-TrimGraph(false), visualizeExplodedGraphWithGraphViz(false),
-UnoptimizedCFG(false), PrintStats(false), NoRetryExhausted(false) {
+ShowCheckerHelpHidden(false), ShowEnabledCheckerList(false),
+ShowConfigOptionsList(false), AnalyzeAll(false),
+AnalyzerDisplayProgress(false), AnalyzeNestedBlocks(false),
+eagerlyAssumeBinOpBifurcation(false), TrimGraph(false),
+visualizeExplodedGraphWithGraphViz(false), UnoptimizedCFG(false),
+PrintStats(false), NoRetryExhausted(false) {
 llvm::sort(AnalyzerConfigCmdFlags);
   }
 


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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-01 Thread Gheorghe-Teodor Bercea via Phabricator via cfe-commits
gtbercea updated this revision to Diff 197638.
gtbercea edited the summary of this revision.
gtbercea added a comment.

- Minor fixes.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399

Files:
  lib/Driver/ToolChains/Clang.cpp
  lib/Headers/CMakeLists.txt
  lib/Headers/__clang_cuda_cmath.h
  lib/Headers/__clang_cuda_device_functions.h
  lib/Headers/__clang_cuda_libdevice_declares.h
  lib/Headers/__clang_cuda_math_forward_declares.h
  lib/Headers/openmp_wrappers/__clang_openmp_math.h
  lib/Headers/openmp_wrappers/cmath
  lib/Headers/openmp_wrappers/math.h

Index: lib/Headers/openmp_wrappers/math.h
===
--- /dev/null
+++ lib/Headers/openmp_wrappers/math.h
@@ -0,0 +1,10 @@
+// File: clang/lib/Headers/math.h
+
+#include <__clang_openmp_math.h>
+
+#ifndef __NO_HOST_MATH__
+#include_next 
+#else
+#undef __NO_HOST_MATH__
+#endif
+
Index: lib/Headers/openmp_wrappers/cmath
===
--- /dev/null
+++ lib/Headers/openmp_wrappers/cmath
@@ -0,0 +1,7 @@
+#include <__clang_openmp_math.h>
+
+#ifndef __NO_HOST_MATH__
+#include_next 
+#else
+#undef __NO_HOST_MATH__
+#endif
Index: lib/Headers/openmp_wrappers/__clang_openmp_math.h
===
--- /dev/null
+++ lib/Headers/openmp_wrappers/__clang_openmp_math.h
@@ -0,0 +1,51 @@
+/*=== __clang_openmp_math.h - OpenMP target math support ---===
+ *
+ * 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
+ *
+ *===---===
+ */
+
+#if defined(__NVPTX__) && defined(_OPENMP)
+/// TODO:
+/// We are currently reusing the functionality of the Clang-CUDA code path
+/// as an alternative to the host declarations provided by math.h and cmath.
+/// This is suboptimal.
+///
+/// We should instead declare the device functions in a similar way, e.g.,
+/// through OpenMP 5.0 variants, and afterwards populate the module with the
+/// host declarations by unconditionally including the host math.h or cmath,
+/// respectively. This is actually what the Clang-CUDA code path does, using
+/// __device__ instead of variants to avoid redeclarations and get the desired
+/// overload resolution.
+
+#define __CUDA__
+
+#if defined(__cplusplus)
+  #include <__clang_cuda_math_forward_declares.h>
+#endif
+
+#define __forceinline__ __attribute__((always_inline))
+
+// CUDA 9.1 no longer provides declarations for libdevice functions, so we need
+// to provide our own.
+#include <__clang_cuda_libdevice_declares.h>
+
+// Wrappers for many device-side standard library functions became compiler
+// builtins in CUDA-9 and have been removed from the CUDA headers. Clang now
+// provides its own implementation of the wrappers.
+// #if CUDA_VERSION >= 9000
+#include <__clang_cuda_device_functions.h>
+
+#if defined(__cplusplus)
+  #include <__clang_cuda_cmath.h>
+#endif
+
+#undef __CUDA__
+
+/// Magic macro for stopping the math.h/cmath host header from being included.
+#define __NO_HOST_MATH__
+
+#endif
+
Index: lib/Headers/__clang_cuda_math_forward_declares.h
===
--- lib/Headers/__clang_cuda_math_forward_declares.h
+++ lib/Headers/__clang_cuda_math_forward_declares.h
@@ -20,8 +20,12 @@
 // would preclude the use of our own __device__ overloads for these functions.
 
 #pragma push_macro("__DEVICE__")
+#ifdef _OPENMP
+#define __DEVICE__ static __inline__ __attribute__((always_inline))
+#else
 #define __DEVICE__ \
   static __inline__ __attribute__((always_inline)) __attribute__((device))
+#endif
 
 __DEVICE__ double abs(double);
 __DEVICE__ float abs(float);
Index: lib/Headers/__clang_cuda_libdevice_declares.h
===
--- lib/Headers/__clang_cuda_libdevice_declares.h
+++ lib/Headers/__clang_cuda_libdevice_declares.h
@@ -10,443 +10,453 @@
 #ifndef __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 #define __CLANG_CUDA_LIBDEVICE_DECLARES_H__
 
+#if defined(__cplusplus)
 extern "C" {
+#endif
 
-__device__ int __nv_abs(int __a);
-__device__ double __nv_acos(double __a);
-__device__ float __nv_acosf(float __a);
-__device__ double __nv_acosh(double __a);
-__device__ float __nv_acoshf(float __a);
-__device__ double __nv_asin(double __a);
-__device__ float __nv_asinf(float __a);
-__device__ double __nv_asinh(double __a);
-__device__ float __nv_asinhf(float __a);
-__device__ double __nv_atan2(double __a, double __b);
-__device__ float __nv_atan2f(float __a, float __b);
-__device__ double __nv_atan(double __a);
-__device__ float __nv_atanf(float __a);
-__device__ double __nv_atanh(double __a

[PATCH] D61396: [hip] Fix ambiguity from `>>>` of CUDA.

2019-05-01 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

LGTM too. Thanks Michael for fixing this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61396



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


[PATCH] D61046: Fix compilation warnings when compiling with GCC 7.3

2019-05-01 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm

The only remaining change I find questionable is the R600 backend change, but 
on the whole I think it's fine and you don't need to wait for more review. 
Better to fix the warnings and people with concerns can repaint the bikeshed as 
they like.




Comment at: llvm/trunk/unittests/IR/ConstantRangeTest.cpp:462
 
+// Silence warning: variable 'HaveInterrupt3' set but not used
+(void)HaveInterrupt3;

I don't think a comment here is necessary, casting something to avoid before an 
assert is a pretty standard idiom for "suppress -Wunused-variable".


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

https://reviews.llvm.org/D61046



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


[PATCH] D61399: [OpenMP][Clang] Support for target math functions

2019-05-01 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

For the record, this is an implementation of the scheme proposed in 
https://reviews.llvm.org/D60907#1484756.
There are drawbacks, see the TODO, but it will give most people a short term 
solution until we get OpenMP 5.0 variants.

Finally, there is a remote chance this will cause trouble to people that use 
math.h/cmath functions, e.g. with the old SSE hack, which are not available 
anymore.
I don't suspect that to happen but if it does we can, again as a short term 
solution, selectively extract declarations from the host cmath into the device 
cmath.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61399



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


Re: [PATCH] D42642: [CUDA] Detect installation in PATH

2019-05-01 Thread Michael Kruse via cfe-commits
Hi,

I had my own difficulties with this. It depends on how the repository
containing the symlink has been checked-out. For instance:

1. Using a windows git (such as git extensions, mingw-git, git for windows)
2. Using git inside wsl on a drvfs mount (i.e. a windows folder
mounted into the Unix filesystem)
3. Using git inside wsl on a lxfs mount (I.e. native mount such as '/')

In case 1. git does not create a Ubuntu symlink. Also, there are no
Unix symlinks in Windows filesystems, so when Unix tools (such as git)
request to create a symlink, it creates something else (AFAIR it's a
text file containing the symlink path, but having lost its symlink
properties). Case 3 should work.

I still managed to make cases 1 and 2 work by deleting the text file
and re-creating it with windows's "mklink" tool (which requires either
admin rights or developer mode turned on). It seems the WSL layer
translates this as a symlink to the Linux environment.

Michael





Am Mi., 1. Mai 2019 um 16:59 Uhr schrieb Alexandre Ganea via
Phabricator via llvm-commits :
>
> aganea added a subscriber: rnk.
> aganea added a comment.
>
> So it turns out this is a symlink issue. The file 
> `clang/trunk/test/Driver/Inputs/CUDA-symlinks/usr/bin/ptxas` has been 
> synchronized on my Windows 10 PC as a regular text file, not a symlink. It 
> looks like TortoiseSVN doesn't implement symlinks. As WSL inherits of my file 
> system, it will not find the symbolic link. I suppose `REQUIRES: 
> !system-windows` isn't enough for `cuda-detect-path.cu`, and it would need 
> something like `REQUIRES: symlinks` along with support in lit. @rnk
>
>
> Repository:
>   rL LLVM
>
> CHANGES SINCE LAST ACTION
>   https://reviews.llvm.org/D42642/new/
>
> https://reviews.llvm.org/D42642
>
>
>
> ___
> llvm-commits mailing list
> llvm-comm...@lists.llvm.org
> https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >