[PATCH] D30805: [OpenCL] Add intel_reqd_sub_group_size attribute support

2017-05-04 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302125: [OpenCL] Add intel_reqd_sub_group_size attribute 
support (authored by pxl).

Changed prior to commit:
  https://reviews.llvm.org/D30805?vs=97772&id=97786#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30805

Files:
  cfe/trunk/include/clang/Basic/Attr.td
  cfe/trunk/include/clang/Basic/AttrDocs.td
  cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
  cfe/trunk/lib/CodeGen/CodeGenFunction.h
  cfe/trunk/lib/Sema/SemaDeclAttr.cpp
  cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
  cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
  cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl

Index: cfe/trunk/include/clang/Basic/AttrDocs.td
===
--- cfe/trunk/include/clang/Basic/AttrDocs.td
+++ cfe/trunk/include/clang/Basic/AttrDocs.td
@@ -2216,6 +2216,21 @@
   }];
 }
 
+def OpenCLIntelReqdSubGroupSizeDocs : Documentation {
+  let Category = DocCatStmt;
+  let Heading = "__attribute__((intel_reqd_sub_group_size))";
+  let Content = [{
+The optional attribute intel_reqd_sub_group_size can be used to indicate that
+the kernel must be compiled and executed with the specified subgroup size. When
+this attribute is present, get_max_sub_group_size() is guaranteed to return the
+specified integer value. This is important for the correctness of many subgroup
+algorithms, and in some cases may be used by the compiler to generate more optimal
+code. See `cl_intel_required_subgroup_size
+`
+for details.
+  }];
+}
+
 def OpenCLAccessDocs : Documentation {
   let Category = DocCatStmt;
   let Heading = "__read_only, __write_only, __read_write (read_only, write_only, read_write)";
Index: cfe/trunk/include/clang/Basic/Attr.td
===
--- cfe/trunk/include/clang/Basic/Attr.td
+++ cfe/trunk/include/clang/Basic/Attr.td
@@ -864,6 +864,13 @@
   let Documentation = [OpenCLUnrollHintDocs];
 }
 
+def OpenCLIntelReqdSubGroupSize: InheritableAttr {
+  let Spellings = [GNU<"intel_reqd_sub_group_size">];
+  let Args = [UnsignedArgument<"SubGroupSize">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
+}
+
 // This attribute is both a type attribute, and a declaration attribute (for
 // parameter variables).
 def OpenCLAccess : Attr {
Index: cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
===
--- cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
+++ cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
@@ -8,7 +8,11 @@
 kernel __attribute__((vec_type_hint(uint4))) __attribute__((work_group_size_hint(8,16,32))) void kernel2(int a) {}
 // CHECK: define void @kernel2(i32 {{[^%]*}}%a) {{[^{]+}} !vec_type_hint ![[MD3:[0-9]+]] !work_group_size_hint ![[MD4:[0-9]+]]
 
+kernel __attribute__((intel_reqd_sub_group_size(8))) void kernel3(int a) {}
+// CHECK: define void @kernel3(i32 {{[^%]*}}%a) {{[^{]+}} !intel_reqd_sub_group_size ![[MD5:[0-9]+]]
+
 // CHECK: [[MD1]] = !{i32 undef, i32 1}
 // CHECK: [[MD2]] = !{i32 1, i32 2, i32 4}
 // CHECK: [[MD3]] = !{<4 x i32> undef, i32 0}
 // CHECK: [[MD4]] = !{i32 8, i32 16, i32 32}
+// CHECK: [[MD5]] = !{i32 8}
Index: cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
===
--- cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
+++ cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
@@ -2,7 +2,7 @@
 
 // The number of supported attributes should never go down!
 
-// CHECK: #pragma clang attribute supports 59 attributes:
+// CHECK: #pragma clang attribute supports 60 attributes:
 // CHECK-NEXT: AMDGPUFlatWorkGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumSGPR (SubjectMatchRule_function)
 // CHECK-NEXT: AMDGPUNumVGPR (SubjectMatchRule_function)
@@ -42,6 +42,7 @@
 // CHECK-NEXT: ObjCRuntimeName (SubjectMatchRule_objc_interface, SubjectMatchRule_objc_protocol)
 // CHECK-NEXT: ObjCRuntimeVisible (SubjectMatchRule_objc_interface)
 // CHECK-NEXT: ObjCSubclassingRestricted (SubjectMatchRule_objc_interface)
+// CHECK-NEXT: OpenCLIntelReqdSubGroupSize (SubjectMatchRule_function)
 // CHECK-NEXT: OpenCLNoSVM (SubjectMatchRule_variable)
 // CHECK-NEXT: OptimizeNone (SubjectMatchRule_function, SubjectMatchRule_objc_method)
 // CHECK-NEXT: Overloadable (SubjectMatchRule_function)
Index: cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl
===
--- cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl
+++ cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl
@@ -33,3 +33,7 @@
 kernel __attribute__((reqd_work_group_size(1,2,0))) void kernel11(){} // expected-error {{'reqd_work_group_size' attribute mus

r302125 - [OpenCL] Add intel_reqd_sub_group_size attribute support

2017-05-04 Thread Xiuli Pan via cfe-commits
Author: pxl
Date: Thu May  4 02:31:20 2017
New Revision: 302125

URL: http://llvm.org/viewvc/llvm-project?rev=302125&view=rev
Log:
[OpenCL] Add intel_reqd_sub_group_size attribute support

Summary:
Add intel_reqd_sub_group_size attribute support as intel extension  
cl_intel_required_subgroup_size from
https://www.khronos.org/registry/OpenCL/extensions/intel/cl_intel_required_subgroup_size.txt

Reviewers: Anastasia, bader, hfinkel, pxli168

Reviewed By: Anastasia, bader, pxli168

Subscribers: cfe-commits, yaxunl

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

Modified:
cfe/trunk/include/clang/Basic/Attr.td
cfe/trunk/include/clang/Basic/AttrDocs.td
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
cfe/trunk/lib/Sema/SemaDeclAttr.cpp
cfe/trunk/test/CodeGenOpenCL/kernel-attributes.cl
cfe/trunk/test/Misc/pragma-attribute-supported-attributes-list.test
cfe/trunk/test/SemaOpenCL/invalid-kernel-attrs.cl

Modified: cfe/trunk/include/clang/Basic/Attr.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=302125&r1=302124&r2=302125&view=diff
==
--- cfe/trunk/include/clang/Basic/Attr.td (original)
+++ cfe/trunk/include/clang/Basic/Attr.td Thu May  4 02:31:20 2017
@@ -864,6 +864,13 @@ def OpenCLUnrollHint : InheritableAttr {
   let Documentation = [OpenCLUnrollHintDocs];
 }
 
+def OpenCLIntelReqdSubGroupSize: InheritableAttr {
+  let Spellings = [GNU<"intel_reqd_sub_group_size">];
+  let Args = [UnsignedArgument<"SubGroupSize">];
+  let Subjects = SubjectList<[Function], ErrorDiag>;
+  let Documentation = [OpenCLIntelReqdSubGroupSizeDocs];
+}
+
 // This attribute is both a type attribute, and a declaration attribute (for
 // parameter variables).
 def OpenCLAccess : Attr {

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=302125&r1=302124&r2=302125&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Thu May  4 02:31:20 2017
@@ -2216,6 +2216,21 @@ s6.11.5 for details.
   }];
 }
 
+def OpenCLIntelReqdSubGroupSizeDocs : Documentation {
+  let Category = DocCatStmt;
+  let Heading = "__attribute__((intel_reqd_sub_group_size))";
+  let Content = [{
+The optional attribute intel_reqd_sub_group_size can be used to indicate that
+the kernel must be compiled and executed with the specified subgroup size. When
+this attribute is present, get_max_sub_group_size() is guaranteed to return the
+specified integer value. This is important for the correctness of many subgroup
+algorithms, and in some cases may be used by the compiler to generate more 
optimal
+code. See `cl_intel_required_subgroup_size
+`
+for details.
+  }];
+}
+
 def OpenCLAccessDocs : Documentation {
   let Category = DocCatStmt;
   let Heading = "__read_only, __write_only, __read_write (read_only, 
write_only, read_write)";

Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=302125&r1=302124&r2=302125&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Thu May  4 02:31:20 2017
@@ -658,34 +658,42 @@ void CodeGenFunction::EmitOpenCLKernelMe
   GenOpenCLArgMetadata(FD, Fn, CGM, Context, Builder, getContext());
 
   if (const VecTypeHintAttr *A = FD->getAttr()) {
-QualType hintQTy = A->getTypeHint();
-const ExtVectorType *hintEltQTy = hintQTy->getAs();
-bool isSignedInteger =
-hintQTy->isSignedIntegerType() ||
-(hintEltQTy && hintEltQTy->getElementType()->isSignedIntegerType());
-llvm::Metadata *attrMDArgs[] = {
+QualType HintQTy = A->getTypeHint();
+const ExtVectorType *HintEltQTy = HintQTy->getAs();
+bool IsSignedInteger =
+HintQTy->isSignedIntegerType() ||
+(HintEltQTy && HintEltQTy->getElementType()->isSignedIntegerType());
+llvm::Metadata *AttrMDArgs[] = {
 llvm::ConstantAsMetadata::get(llvm::UndefValue::get(
 CGM.getTypes().ConvertType(A->getTypeHint(,
 llvm::ConstantAsMetadata::get(llvm::ConstantInt::get(
 llvm::IntegerType::get(Context, 32),
-llvm::APInt(32, (uint64_t)(isSignedInteger ? 1 : 0};
-Fn->setMetadata("vec_type_hint", llvm::MDNode::get(Context, attrMDArgs));
+llvm::APInt(32, (uint64_t)(IsSignedInteger ? 1 : 0};
+Fn->setMetadata("vec_type_hint", llvm::MDNode::get(Context, AttrMDArgs));
   }
 
   if (const WorkGroupSizeHintAttr *A = FD->getAttr()) {
-llvm::Metadata *attrMDArgs[] = {

[libcxx] r302128 - Update Appveyor bot link to point to new llvm-mirror Appveyor account

2017-05-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May  4 02:40:23 2017
New Revision: 302128

URL: http://llvm.org/viewvc/llvm-project?rev=302128&view=rev
Log:
Update Appveyor bot link to point to new llvm-mirror Appveyor account

Modified:
libcxx/trunk/docs/index.rst

Modified: libcxx/trunk/docs/index.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/index.rst?rev=302128&r1=302127&r2=302128&view=diff
==
--- libcxx/trunk/docs/index.rst (original)
+++ libcxx/trunk/docs/index.rst Thu May  4 02:40:23 2017
@@ -145,7 +145,7 @@ Build Bots and Test Coverage
 
 * `LLVM Buildbot Builders `_
 * `Apple Jenkins Builders `_
-* `Windows Appveyor Builders `_
+* `Windows Appveyor Builders 
`_
 * `Code Coverage Results `_
 
 Getting Involved


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


[libcxx] r302129 - Fix incorrect usage of __libcpp_mutex_trylock. Patch from Andrey Khalyavin

2017-05-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May  4 02:45:09 2017
New Revision: 302129

URL: http://llvm.org/viewvc/llvm-project?rev=302129&view=rev
Log:
Fix incorrect usage of __libcpp_mutex_trylock. Patch from Andrey Khalyavin

Modified:
libcxx/trunk/src/memory.cpp

Modified: libcxx/trunk/src/memory.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/memory.cpp?rev=302129&r1=302128&r2=302129&view=diff
==
--- libcxx/trunk/src/memory.cpp (original)
+++ libcxx/trunk/src/memory.cpp Thu May  4 02:45:09 2017
@@ -154,7 +154,7 @@ __sp_mut::lock() _NOEXCEPT
 {
 auto m = static_cast<__libcpp_mutex_t*>(__lx);
 unsigned count = 0;
-while (__libcpp_mutex_trylock(m) != 0)
+while (!__libcpp_mutex_trylock(m))
 {
 if (++count > 16)
 {


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


[PATCH] D32727: [libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance shouldn't be mandated".

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added inline comments.
This revision is now accepted and ready to land.



Comment at: 
test/std/iterators/stream.iterators/istream.iterator/types.pass.cpp:42
 #include 
 
 int main()

Needs `#include "test_macros.h"`



Comment at: 
test/std/iterators/stream.iterators/ostream.iterator/types.pass.cpp:25
 #include 
 
 int main()

Needs `#include "test_macros.h"`



Comment at: 
test/std/iterators/stream.iterators/ostreambuf.iterator/types.pass.cpp:26
 #include 
 
 int main()

Needs `#include "test_macros.h"`


https://reviews.llvm.org/D32727



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


[PATCH] D32727: [libcxx] [test] Be compatible with LWG 2438 "std::iterator inheritance shouldn't be mandated".

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

LGTM minus inline comments.


https://reviews.llvm.org/D32727



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


[PATCH] D32574: [libcxx] [test] Fixed possible loss of data warnings in tests on amd64

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM after addressing inline comments.




Comment at: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp:39
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);

The cast should happen after the subtraction, not before.



Comment at: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp:71
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);

The cast should happen after the subtraction, not before.


https://reviews.llvm.org/D32574



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


[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

Could you commit all the changes *except* the trivial extensions tests, and 
then update this to contain only that?


https://reviews.llvm.org/D32671



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


[PATCH] D32510: [libcxx] Fix C1XX implementation of DoNotOptimize

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Oops. Thanks for the fix.


https://reviews.llvm.org/D32510



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


[PATCH] D32386: [libcxx] [test] Avoid P0138R2, direct-list-init of fixed enums from integers.

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

Could you add a separate test that performs  direct-list-init of fixed enums 
from integers, and XFAIL it accordingly? Testing it found a bug, so I don't 
want to complete eliminate that test coverage.

Other than that this LGTM.


https://reviews.llvm.org/D32386



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


[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:146
+auto res = std::gcd(static_cast(1234), INT32_MIN);
+static_assert(std::is_same>::value, "");
 assert(res == 2);

`std::common_type` here please. This test runs in C++03 where we don't have 
`std::foo_t`.


https://reviews.llvm.org/D32309



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


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

So Itanium ABI has this quirk where trivial types are passed using different 
conventions than non-trivial types. This means changing the triviality of 
`std::optional` for any instantiation is potentially ABI breaking. I'll need to 
do more investigation to find out how this will affect libc++, and if we can 
take this change.


https://reviews.llvm.org/D32385



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


[PATCH] D32743: [clang-tidy] Add new cert-dcl21-cpp check.

2017-05-04 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 97789.
xazax.hun marked 21 inline comments as done.
xazax.hun added a comment.

- Fixes according to the review comments.


https://reviews.llvm.org/D32743

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/PostfixOperatorCheck.cpp
  clang-tidy/cert/PostfixOperatorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-dcl21-cpp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-dcl21-cpp.cpp

Index: test/clang-tidy/cert-dcl21-cpp.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-dcl21-cpp.cpp
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s cert-dcl21-cpp %t
+
+class A {};
+
+A operator++(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a non-constant object instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const A operator++(A &, int);
+
+A operator--(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const A operator--(A &, int);
+
+class B {};
+
+B &operator++(B &);
+const B operator++(B &, int);
+
+B &operator--(B &);
+const B operator--(B &, int);
+
+
+class D {
+D &operator++();
+const D operator++(int);
+
+D &operator--();
+const D operator--(int);
+};
+
+class C {
+C operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a no
+// CHECK-FIXES: {{^}}const C operator++(int);
+
+C operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const C operator--(int);
+};
+
+class E {};
+
+E &operator++(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a reference instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const E operator++(E &, int);
+
+E &operator--(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const E operator--(E &, int);
+
+class G {
+G &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const G operator++(int);
+
+G &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const G operator--(int);
+};
+
+class F {};
+
+const F &operator++(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const F operator++(F &, int);
+
+const F &operator--(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const F operator--(F &, int);
+
+class H {
+const H &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const H operator++(int);
+
+const H &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const H operator--(int);
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 
+   cert-dcl21-cpp
cert-dcl50-cpp
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
cert-dcl58-cpp
Index: docs/clang-tidy/checks/cert-dcl21-cpp.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cert-dcl21-cpp.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - cert-dcl21-cpp
+
+cert-dcl21-cpp
+==
+
+This check flags postfix ``operator++`` and ``operator--`` declarations
+if the return type is not a const object. This also warns if the return type
+is a reference type.
+
+This check corresponds to the CERT C++ Coding Standard recommendation
+`DCL21-CPP. Overloaded postfix increment and decrement operators should return a const object
+`_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `cert-dcl21-cpp
+  `_ check
+
+  Checks if the overloaded postfix ``operator++/--`` returns a constant object.
+
 - New `cert-dcl58-cpp
   `_ check
 
Index: clang-tidy/cert/PostfixOperatorCheck.h
===
--- /dev/null
+++ clang-tidy/cert/PostfixOperatorCheck.h
@@ -0,0 +1,36 @@
+//===--- PostfixOperatorCheck.h - clang

[PATCH] D32743: [clang-tidy] Add new cert-dcl21-cpp check.

2017-05-04 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun updated this revision to Diff 97790.
xazax.hun added a comment.

- Fixed include order.


https://reviews.llvm.org/D32743

Files:
  clang-tidy/cert/CERTTidyModule.cpp
  clang-tidy/cert/CMakeLists.txt
  clang-tidy/cert/PostfixOperatorCheck.cpp
  clang-tidy/cert/PostfixOperatorCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cert-dcl21-cpp.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cert-dcl21-cpp.cpp

Index: test/clang-tidy/cert-dcl21-cpp.cpp
===
--- /dev/null
+++ test/clang-tidy/cert-dcl21-cpp.cpp
@@ -0,0 +1,78 @@
+// RUN: %check_clang_tidy %s cert-dcl21-cpp %t
+
+class A {};
+
+A operator++(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a non-constant object instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const A operator++(A &, int);
+
+A operator--(A &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const A operator--(A &, int);
+
+class B {};
+
+B &operator++(B &);
+const B operator++(B &, int);
+
+B &operator--(B &);
+const B operator--(B &, int);
+
+
+class D {
+D &operator++();
+const D operator++(int);
+
+D &operator--();
+const D operator--(int);
+};
+
+class C {
+C operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a no
+// CHECK-FIXES: {{^}}const C operator++(int);
+
+C operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a no
+// CHECK-FIXES: {{^}}const C operator--(int);
+};
+
+class E {};
+
+E &operator++(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a reference instead of a constant object type [cert-dcl21-cpp]
+// CHECK-FIXES: {{^}}const E operator++(E &, int);
+
+E &operator--(E &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const E operator--(E &, int);
+
+class G {
+G &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const G operator++(int);
+
+G &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:1: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const G operator--(int);
+};
+
+class F {};
+
+const F &operator++(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const F operator++(F &, int);
+
+const F &operator--(F &, int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const F operator--(F &, int);
+
+class H {
+const H &operator++(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator++' returns a re
+// CHECK-FIXES: {{^}}const H operator++(int);
+
+const H &operator--(int);
+// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: overloaded 'operator--' returns a re
+// CHECK-FIXES: {{^}}const H operator--(int);
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -6,6 +6,7 @@
 .. toctree::
boost-use-to-string
cert-dcl03-c (redirects to misc-static-assert) 
+   cert-dcl21-cpp
cert-dcl50-cpp
cert-dcl54-cpp (redirects to misc-new-delete-overloads) 
cert-dcl58-cpp
Index: docs/clang-tidy/checks/cert-dcl21-cpp.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/cert-dcl21-cpp.rst
@@ -0,0 +1,12 @@
+.. title:: clang-tidy - cert-dcl21-cpp
+
+cert-dcl21-cpp
+==
+
+This check flags postfix ``operator++`` and ``operator--`` declarations
+if the return type is not a const object. This also warns if the return type
+is a reference type.
+
+This check corresponds to the CERT C++ Coding Standard recommendation
+`DCL21-CPP. Overloaded postfix increment and decrement operators should return a const object
+`_.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -57,6 +57,11 @@
 Improvements to clang-tidy
 --
 
+- New `cert-dcl21-cpp
+  `_ check
+
+  Checks if the overloaded postfix ``operator++/--`` returns a constant object.
+
 - New `cert-dcl58-cpp
   `_ check
 
Index: clang-tidy/cert/PostfixOperatorCheck.h
===
--- /dev/null
+++ clang-tidy/cert/PostfixOperatorCheck.h
@@ -0,0 +1,36 @@
+//===--- PostfixOperatorCheck.h - clang-tidy-*- C++ -*-===//
+//
+//   

r302131 - [ARM] ACLE Chapter 9 intrinsics

2017-05-04 Thread Sam Parker via cfe-commits
Author: sam_parker
Date: Thu May  4 03:37:59 2017
New Revision: 302131

URL: http://llvm.org/viewvc/llvm-project?rev=302131&view=rev
Log:
[ARM] ACLE Chapter 9 intrinsics

Implemented the remaining integer data processing intrinsics from
the ARM ACLE v2.1 spec, such as parallel arithemtic and DSP style
multiplications.

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsARM.def
cfe/trunk/lib/Headers/arm_acle.h
cfe/trunk/test/CodeGen/arm_acle.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsARM.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsARM.def?rev=302131&r1=302130&r2=302131&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsARM.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsARM.def Thu May  4 03:37:59 2017
@@ -25,11 +25,93 @@
 // In libgcc
 BUILTIN(__clear_cache, "vv*v*", "i")
 
+// 16-bit multiplications
+BUILTIN(__builtin_arm_smulbb, "iii", "nc")
+BUILTIN(__builtin_arm_smulbt, "iii", "nc")
+BUILTIN(__builtin_arm_smultb, "iii", "nc")
+BUILTIN(__builtin_arm_smultt, "iii", "nc")
+BUILTIN(__builtin_arm_smulwb, "iii", "nc")
+BUILTIN(__builtin_arm_smulwt, "iii", "nc")
+
 // Saturating arithmetic
 BUILTIN(__builtin_arm_qadd, "iii", "nc")
 BUILTIN(__builtin_arm_qsub, "iii", "nc")
 BUILTIN(__builtin_arm_ssat, "iiUi", "nc")
-BUILTIN(__builtin_arm_usat, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_usat, "UiiUi", "nc")
+
+BUILTIN(__builtin_arm_smlabb, "", "nc")
+BUILTIN(__builtin_arm_smlabt, "", "nc")
+BUILTIN(__builtin_arm_smlatb, "", "nc")
+BUILTIN(__builtin_arm_smlatt, "", "nc")
+BUILTIN(__builtin_arm_smlawb, "", "nc")
+BUILTIN(__builtin_arm_smlawt, "", "nc")
+
+BUILTIN(__builtin_arm_ssat16, "iii", "nc")
+BUILTIN(__builtin_arm_usat16, "iii", "nc")
+
+BUILTIN(__builtin_arm_sxtab16, "iii", "nc")
+BUILTIN(__builtin_arm_sxtb16, "ii", "nc")
+BUILTIN(__builtin_arm_uxtab16, "iii", "nc")
+BUILTIN(__builtin_arm_uxtb16, "ii", "nc")
+
+BUILTIN(__builtin_arm_sel, "iii", "nc")
+
+BUILTIN(__builtin_arm_qadd8, "iii", "nc")
+BUILTIN(__builtin_arm_qsub8, "iii", "nc")
+BUILTIN(__builtin_arm_sadd8, "iii", "nc")
+BUILTIN(__builtin_arm_shadd8, "iii", "nc")
+BUILTIN(__builtin_arm_shsub8, "iii", "nc")
+BUILTIN(__builtin_arm_ssub8, "iii", "nc")
+BUILTIN(__builtin_arm_uadd8, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uhadd8, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uhsub8, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uqadd8, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uqsub8, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_usub8, "UiUiUi", "nc")
+
+// Sum of 8-bit absolute differences
+BUILTIN(__builtin_arm_usad8, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_usada8, "UiUiUiUi", "nc")
+
+// Parallel 16-bit addition and subtraction
+BUILTIN(__builtin_arm_qadd16, "iii", "nc")
+BUILTIN(__builtin_arm_qasx, "iii", "nc")
+BUILTIN(__builtin_arm_qsax, "iii", "nc")
+BUILTIN(__builtin_arm_qsub16, "iii", "nc")
+BUILTIN(__builtin_arm_sadd16, "iii", "nc")
+BUILTIN(__builtin_arm_sasx, "iii", "nc")
+BUILTIN(__builtin_arm_shadd16, "iii", "nc")
+BUILTIN(__builtin_arm_shasx, "iii", "nc")
+BUILTIN(__builtin_arm_shsax, "iii", "nc")
+BUILTIN(__builtin_arm_shsub16, "iii", "nc")
+BUILTIN(__builtin_arm_ssax, "iii", "nc")
+BUILTIN(__builtin_arm_ssub16, "iii", "nc")
+BUILTIN(__builtin_arm_uadd16, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uasx, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uhadd16, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uhasx, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uhsax, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uhsub16, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uqadd16, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uqasx, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uqsax, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_uqsub16, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_usax, "UiUiUi", "nc")
+BUILTIN(__builtin_arm_usub16, "UiUiUi", "nc")
+
+// Parallel 16-bit multiplication
+BUILTIN(__builtin_arm_smlad, "", "nc")
+BUILTIN(__builtin_arm_smladx, "", "nc")
+BUILTIN(__builtin_arm_smlald, "LLiiiLLi", "nc")
+BUILTIN(__builtin_arm_smlaldx, "LLiiiLLi", "nc")
+BUILTIN(__builtin_arm_smlsd, "", "nc")
+BUILTIN(__builtin_arm_smlsdx, "", "nc")
+BUILTIN(__builtin_arm_smlsld, "LLiiiLLi", "nc")
+BUILTIN(__builtin_arm_smlsldx, "LLiiiLLi", "nc")
+BUILTIN(__builtin_arm_smuad, "iii", "nc")
+BUILTIN(__builtin_arm_smuadx, "iii", "nc")
+BUILTIN(__builtin_arm_smusd, "iii", "nc")
+BUILTIN(__builtin_arm_smusdx, "iii", "nc")
 
 // Bit manipulation
 BUILTIN(__builtin_arm_rbit, "UiUi", "nc")

Modified: cfe/trunk/lib/Headers/arm_acle.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/arm_acle.h?rev=302131&r1=302130&r2=302131&view=diff
==
--- cfe/trunk/lib/Headers/arm_acle.h (original)
+++ cfe/trunk/lib/Headers/arm_acle.h Thu May  4 03:37:59 2017
@@ -225,19 +225,49 @@ __rbitl(unsigned long __t) {
 }
 
 /*
+ * 9.3 16-bit multiplicatio

[PATCH] D32309: [libcxx] [test] Resolve compiler warnings in LCM/GCD tests

2017-05-04 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added inline comments.



Comment at: test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp:146
+auto res = std::gcd(static_cast(1234), INT32_MIN);
+static_assert(std::is_same>::value, "");
 assert(res == 2);

EricWF wrote:
> `std::common_type` here please. This test runs in C++03 where we don't have 
> `std::foo_t`.
C++17 library features in C++03?!? :(

OK, will fix.



https://reviews.llvm.org/D32309



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


[PATCH] D32574: [libcxx] [test] Fixed possible loss of data warnings in tests on amd64

2017-05-04 Thread Billy Robert O'Neal III via Phabricator via cfe-commits
BillyONeal added inline comments.



Comment at: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp:39
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);

EricWF wrote:
> The cast should happen after the subtraction, not before.
The cast happens before the subtraction because the invariant that size() is 
less than unsigned max is established on line 36 (by passing in an unsigned as 
the length).

Alternately, would it be better to just pass around size_ts here so that no 
casts would be necessary any longer?



https://reviews.llvm.org/D32574



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


[PATCH] D32574: [libcxx] [test] Fixed possible loss of data warnings in tests on amd64

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added inline comments.



Comment at: test/std/strings/basic.string/string.cons/T_size_size.pass.cpp:39
 assert(pos <= sv.size());
-unsigned rlen = std::min(sv.size() - pos, n);
+unsigned rlen = std::min(static_cast(sv.size()) - pos, n);
 assert(s2.size() == rlen);

BillyONeal wrote:
> EricWF wrote:
> > The cast should happen after the subtraction, not before.
> The cast happens before the subtraction because the invariant that size() is 
> less than unsigned max is established on line 36 (by passing in an unsigned 
> as the length).
> 
> Alternately, would it be better to just pass around size_ts here so that no 
> casts would be necessary any longer?
> 
Alternately, would it be better to just pass around size_ts here so that no 
casts would be necessary any longer?

Yeah, that seems more correct to me. Good catch.


https://reviews.llvm.org/D32574



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


[PATCH] D32592: [Analyzer] Iterator Checker - Part1: Minimal Checker for a Simple Test Case

2017-05-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

I see the checker going towards what we call "metadata symbols", which seems 
logical.

I still feel the checker deserves a lot more comments around the code. In 
particular, i'd definitely love to see a human-readable explanation of what 
kinds of iterators are supported (from plain pointers or integers to opaque 
structures): you did great job abstracting away these differences in the 
high-level logic, but i'd like to demonstrate how does the low-level logic (eg. 
offsets and comparisons, i.e. these moments when you're operating on various 
`SVal` objects directly) works in all these cases, because this part of the 
checker requires the most ingenuity to handle, while the rest is more or less 
straightforward.




Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:211-214
+std::pair
+createDifference(SymbolManager &SymMgr, SymbolRef Sym1, SymbolRef Sym2);
+const llvm::APSInt *getDifference(ProgramStateRef State, SymbolRef Sym1,
+  SymbolRef Sym2);

These functions are currently unused; my compiler warns about that, and 
buildbots would probably yell at us when we commit it, so i guess it's better 
to add them when they are actually used; they'd also be tested as well.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:219
+  OutOfRangeBugType.reset(
+  new BugType(this, "Iterator of out Range", "Misuse of STL APIs"));
+  OutOfRangeBugType->setSuppressOnSink(true);

Before we forget: Range -> range. As we've noticed recently in D32702 :), we 
don't capitalize every word in bug types and categories.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:294-297
+// Assumption: if return value is an iterator which is not yet bound to a
+// container, then look for the first iterator argument, and
+// bind the return value to the same container. This approach
+// works for STL algorithms.

I guess this deserves a test case (we could split this out as a separate 
feature as well).

I'm also afraid that we can encounter false positives on functions that are not 
STL algorithms. I suggest doing this by default only for STL functions (or 
maybe for other specific classes of functions for which we know it works this 
way) and do this for other functions under a checker option (i.e. something 
like `-analyzer-config IteratorChecker:AggressiveAssumptions=true`, similar to 
`MallocChecker`'s "Optimistic" option).



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:323-324
+
+void IteratorChecker::checkLiveSymbols(ProgramStateRef State,
+   SymbolReaper &SR) const {
+  // Keep symbolic expressions of iterator positions, container begins and ends

This callback is currently untested as well. I'm doing this bit of manual 
"mutation testing" by removing pieces of code and re-running tests because not 
only we'd rather keep every commit self-sufficient, but also we'd rather make 
sure we didn't forget anything, which is much easier to do patch-by-patch.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:478-479
+auto &SymMgr = C.getSymbolManager();
+EndSym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
+  C.getASTContext().LongTy, C.blockCount());
+State = createContainerEnd(State, ContReg, EndSym);

I see what you did here! And i suggest considering `SymbolMetadata` here 
instead of `SymbolConjured`, because it was designed for this purpose: the 
checker for some reason knows there's a special property of an object he wants 
to track, the checker doesn't have a ready-made symbolic value to represent 
this property (because the engine didn't know this property even exists, so it 
didn't denote its value), so the checker comes up with its own notation. 
`SymbolMetadata` is used, for example, in `CStringChecker` to denote an unknown 
string length for a given null-terminated string region.

This symbol carries the connection to the region (you may use it to 
reverse-lookup the region if necessary), and in particular it is considered to 
be live as long as the base region is live (so you don't have to deal with 
liveness manually; see also comments around `SymbolReaper::MarkInUse`). It's 
also easier to debug, because we can track the symbol back to the checker. 
Generally, symbol class hierarchy is cool because we know a lot about the 
symbol by just looking at it, and `SymbolConjured` is a sad fallback we use 
when we didn't care or manage to come up with a better symbol.

I'm not sure if `LongTy` is superior to `IntTy` here, since we don't know what 
to expect from the container anyway.

Also, please de-duplicate the symbol creation code. Birth of a symbol is 
something so rare it deserves a drum roll :)

I'd take a pause

[PATCH] D32856: [OpenCL] Check that global samplers are const

2017-05-04 Thread Sven van Haastregt via Phabricator via cfe-commits
svenvh created this revision.

Patch by Simon Perretta.


https://reviews.llvm.org/D32856

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaDecl.cpp
  test/SemaOpenCL/sampler_t.cl


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -9,7 +9,7 @@
 
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 constant sampler_t glb_smp2; // expected-error{{variable in constant address 
space must be initialized}}
-global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler 
type cannot be used with the __local and __global address space qualifiers}} 
expected-error {{global sampler requires a const qualifier}}
 
 constant sampler_t glb_smp4 = 0;
 #ifdef CHECK_SAMPLER_VALUE
@@ -38,6 +38,8 @@
 
 sampler_t bad(void); //expected-error{{declaring function return value of type 
'sampler_t' is not allowed}}
 
+sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires 
a const qualifier}}
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the 
__local and __global address space qualifiers}}
   const sampler_t const_smp = CLK_ADDRESS_CLAMP_TO_EDGE | 
CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -6070,12 +6070,24 @@
   }
 }
 
-// OpenCL v1.2 s6.9.b p4:
-// The sampler type cannot be used with the __local and __global address
-// space qualifiers.
-if (R->isSamplerT() && (R.getAddressSpace() == LangAS::opencl_local ||
-  R.getAddressSpace() == LangAS::opencl_global)) {
-  Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
+if (R->isSamplerT()) {
+  // OpenCL v1.2 s6.9.b p4:
+  // The sampler type cannot be used with the __local and __global address
+  // space qualifiers.
+  if (R.getAddressSpace() == LangAS::opencl_local ||
+  R.getAddressSpace() == LangAS::opencl_global) {
+Diag(D.getIdentifierLoc(), diag::err_wrong_sampler_addressspace);
+  }
+
+  // OpenCL v1.2 s6.12.14.1:
+  // A global sampler must be declared with either the constant address
+  // space qualifier or with the const qualifier.
+  if (DC->isTranslationUnit() &&
+  !(R.getAddressSpace() == LangAS::opencl_constant ||
+  R.isConstQualified())) {
+Diag(D.getIdentifierLoc(), diag::err_opencl_sampler_qualifier);
+D.setInvalidType();
+  }
 }
 
 // OpenCL v1.2 s6.9.r:
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8297,6 +8297,8 @@
   "sampler_t variable required - got %0">;
 def err_wrong_sampler_addressspace: Error<
   "sampler type cannot be used with the __local and __global address space 
qualifiers">;
+def err_opencl_sampler_qualifier : Error<
+  "global sampler requires a const qualifier">;
 def err_opencl_cast_non_zero_to_event_t : Error<
   "cannot cast non-zero value '%0' to 'event_t'">;
 def err_opencl_global_invalid_addr_space : Error<


Index: test/SemaOpenCL/sampler_t.cl
===
--- test/SemaOpenCL/sampler_t.cl
+++ test/SemaOpenCL/sampler_t.cl
@@ -9,7 +9,7 @@
 
 constant sampler_t glb_smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_LINEAR;
 constant sampler_t glb_smp2; // expected-error{{variable in constant address space must be initialized}}
-global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}}
+global sampler_t glb_smp3 = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_NORMALIZED_COORDS_TRUE | CLK_FILTER_NEAREST; // expected-error{{sampler type cannot be used with the __local and __global address space qualifiers}} expected-error {{global sampler requires a const qualifier}}
 
 constant sampler_t glb_smp4 = 0;
 #ifdef CHECK_SAMPLER_VALUE
@@ -38,6 +38,8 @@
 
 sampler_t bad(void); //expected-error{{declaring function return value of type 'sampler_t' is not allowed}}
 
+sampler_t global_nonconst_smp = 0; // expected-error {{global sampler requires a const qualifier}}
+
 void kernel ker(sampler_t argsmp) {
   local sampler_t smp; // expected-error{{sampler type cannot be used with the __local and __global address 

r302136 - [Index] The relation between the declarations in template

2017-05-04 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu May  4 05:42:06 2017
New Revision: 302136

URL: http://llvm.org/viewvc/llvm-project?rev=302136&view=rev
Log:
[Index] The relation between the declarations in template
specializations that 'override' declarations in the base template should use
the 'specializationOf' relation instead of 'specializationOf | overrideOf'.

The indexer relations are meant to be orthogonal, so 'specializationOf' is
better than the combined relation.

Modified:
cfe/trunk/lib/Index/IndexDecl.cpp
cfe/trunk/test/Index/Core/index-source.cpp

Modified: cfe/trunk/lib/Index/IndexDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/IndexDecl.cpp?rev=302136&r1=302135&r2=302136&view=diff
==
--- cfe/trunk/lib/Index/IndexDecl.cpp (original)
+++ cfe/trunk/lib/Index/IndexDecl.cpp Thu May  4 05:42:06 2017
@@ -184,9 +184,7 @@ public:
 continue;
 }
 Relations.emplace_back(
-SymbolRoleSet(SymbolRole::RelationOverrideOf) |
-SymbolRoleSet(SymbolRole::RelationSpecializationOf),
-ND);
+SymbolRoleSet(SymbolRole::RelationSpecializationOf), ND);
   }
 }
   }

Modified: cfe/trunk/test/Index/Core/index-source.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/Core/index-source.cpp?rev=302136&r1=302135&r2=302136&view=diff
==
--- cfe/trunk/test/Index/Core/index-source.cpp (original)
+++ cfe/trunk/test/Index/Core/index-source.cpp Thu May  4 05:42:06 2017
@@ -139,13 +139,13 @@ class PseudoOverridesInSpecializations {
 template<>
 class PseudoOverridesInSpecializations {
   void function() { }
-// CHECK: [[@LINE-1]]:8 | instance-method/C++ | function | 
c:@S@PseudoOverridesInSpecializations>#d#I@F@function# | 
__ZN32PseudoOverridesInSpecializationsIdiE8functionEv | 
Def,RelChild,RelOver,RelSpecialization | rel: 2
+// CHECK: [[@LINE-1]]:8 | instance-method/C++ | function | 
c:@S@PseudoOverridesInSpecializations>#d#I@F@function# | 
__ZN32PseudoOverridesInSpecializationsIdiE8functionEv | 
Def,RelChild,RelSpecialization | rel: 2
 // CHECK-NEXT: RelChild
-// CHECK-NEXT: RelOver,RelSpecialization | function | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@F@function#
+// CHECK-NEXT: RelSpecialization | function | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@F@function#
 
   void staticFunction() { }
 // CHECK: [[@LINE-1]]:8 | instance-method/C++ | staticFunction | 
c:@S@PseudoOverridesInSpecializations>#d#I@F@staticFunction# | 
__ZN32PseudoOverridesInSpecializationsIdiE14staticFunctionEv | Def,RelChild | 
rel: 1
-// CHECK-NOT: RelOver
+// CHECK-NOT: RelSpecialization
 
   int notOverridingField = 0;
 
@@ -153,57 +153,56 @@ class PseudoOverridesInSpecializations#d#I@FI@field |  | 
Def,RelChild,RelOver,RelSpecialization | rel: 2
+// CHECK: [[@LINE-1]]:7 | field/C++ | field | 
c:@S@PseudoOverridesInSpecializations>#d#I@FI@field |  | 
Def,RelChild,RelSpecialization | rel: 2
 // CHECK-NEXT: RelChild
-// CHECK-NEXT: RelOver,RelSpecialization | field | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@FI@field
+// CHECK-NEXT: RelSpecialization | field | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@FI@field
 
   static double variable;
-// CHECK: [[@LINE-1]]:17 | static-property/C++ | variable | 
c:@S@PseudoOverridesInSpecializations>#d#I@variable | 
__ZN32PseudoOverridesInSpecializationsIdiE8variableE | 
Decl,RelChild,RelOver,RelSpecialization | rel: 2
+// CHECK: [[@LINE-1]]:17 | static-property/C++ | variable | 
c:@S@PseudoOverridesInSpecializations>#d#I@variable | 
__ZN32PseudoOverridesInSpecializationsIdiE8variableE | 
Decl,RelChild,RelSpecialization | rel: 2
 // CHECK-NEXT: RelChild
-// CHECK-NEXT: RelOver,RelSpecialization | variable | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@variable
+// CHECK-NEXT: RelSpecialization | variable | 
c:@ST>2#T#T@PseudoOverridesInSpecializations@variable
 
   typedef double TypeDef;
-// CHECK: [[@LINE-1]]:18 | type-alias/C | TypeDef | 
c:index-source.cpp@S@PseudoOverridesInSpecializations>#d#I@T@TypeDef | 
 | Def,RelChild,RelOver,RelSpecialization | rel: 2
+// CHECK: [[@LINE-1]]:18 | type-alias/C | TypeDef | 
c:index-source.cpp@S@PseudoOverridesInSpecializations>#d#I@T@TypeDef | 
 | Def,RelChild,RelSpecialization | rel: 2
 // CHECK-NEXT: RelChild
-// CHECK-NEXT: RelOver,RelSpecialization | TypeDef | 
c:index-source.cpp@ST>2#T#T@PseudoOverridesInSpecializations@T@TypeDef
+// CHECK-NEXT: RelSpecialization | TypeDef | 
c:index-source.cpp@ST>2#T#T@PseudoOverridesInSpecializations@T@TypeDef
 
   using TypeAlias = int;
-// CHECK: [[@LINE-1]]:9 | type-alias/C++ | TypeAlias | 
c:@S@PseudoOverridesInSpecializations>#d#I@TypeAlias |  | 
Def,RelChild,RelOver,RelSpecialization | rel: 2
+// CHECK: [[@LINE-1]]:9 | type-alias/C++ | TypeAlias | 
c:@S@PseudoOverridesInSpecializations>#d#I@TypeAlias |  | 
Def,RelChild,RelSpecialization | rel: 2
 // CH

[PATCH] D32592: [Analyzer] Iterator Checker - Part1: Minimal Checker for a Simple Test Case

2017-05-04 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:211-214
+std::pair
+createDifference(SymbolManager &SymMgr, SymbolRef Sym1, SymbolRef Sym2);
+const llvm::APSInt *getDifference(ProgramStateRef State, SymbolRef Sym1,
+  SymbolRef Sym2);

NoQ wrote:
> These functions are currently unused; my compiler warns about that, and 
> buildbots would probably yell at us when we commit it, so i guess it's better 
> to add them when they are actually used; they'd also be tested as well.
Sorry, I forgot to delete it. I will do it.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:219
+  OutOfRangeBugType.reset(
+  new BugType(this, "Iterator of out Range", "Misuse of STL APIs"));
+  OutOfRangeBugType->setSuppressOnSink(true);

NoQ wrote:
> Before we forget: Range -> range. As we've noticed recently in D32702 :), we 
> don't capitalize every word in bug types and categories.
Agree.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:294-297
+// Assumption: if return value is an iterator which is not yet bound to a
+// container, then look for the first iterator argument, and
+// bind the return value to the same container. This approach
+// works for STL algorithms.

NoQ wrote:
> I guess this deserves a test case (we could split this out as a separate 
> feature as well).
> 
> I'm also afraid that we can encounter false positives on functions that are 
> not STL algorithms. I suggest doing this by default only for STL functions 
> (or maybe for other specific classes of functions for which we know it works 
> this way) and do this for other functions under a checker option (i.e. 
> something like `-analyzer-config IteratorChecker:AggressiveAssumptions=true`, 
> similar to `MallocChecker`'s "Optimistic" option).
I will check whether this piece of code could be moved in a later part of the 
checker. However, I suggest to first wait for the first false positives before 
we introduce such an option. This far the false positives in my initial tests 
had different reasons, not this one.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:478-479
+auto &SymMgr = C.getSymbolManager();
+EndSym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
+  C.getASTContext().LongTy, C.blockCount());
+State = createContainerEnd(State, ContReg, EndSym);

NoQ wrote:
> I see what you did here! And i suggest considering `SymbolMetadata` here 
> instead of `SymbolConjured`, because it was designed for this purpose: the 
> checker for some reason knows there's a special property of an object he 
> wants to track, the checker doesn't have a ready-made symbolic value to 
> represent this property (because the engine didn't know this property even 
> exists, so it didn't denote its value), so the checker comes up with its own 
> notation. `SymbolMetadata` is used, for example, in `CStringChecker` to 
> denote an unknown string length for a given null-terminated string region.
> 
> This symbol carries the connection to the region (you may use it to 
> reverse-lookup the region if necessary), and in particular it is considered 
> to be live as long as the base region is live (so you don't have to deal with 
> liveness manually; see also comments around `SymbolReaper::MarkInUse`). It's 
> also easier to debug, because we can track the symbol back to the checker. 
> Generally, symbol class hierarchy is cool because we know a lot about the 
> symbol by just looking at it, and `SymbolConjured` is a sad fallback we use 
> when we didn't care or manage to come up with a better symbol.
> 
> I'm not sure if `LongTy` is superior to `IntTy` here, since we don't know 
> what to expect from the container anyway.
> 
> Also, please de-duplicate the symbol creation code. Birth of a symbol is 
> something so rare it deserves a drum roll :)
> 
> I'd take a pause to figure out if the same logic should be applied to the map 
> from containers to end-iterators.
SymbolMetaData is bound to a MemRegion. Iterators are sometimes symbols and 
sometimes memory regions, this was one of the first lessons I learned from my 
first iterator checker.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:513
+
+bool isLess(ProgramStateRef State, SymbolRef Sym1, SymbolRef Sym2);
+bool isGreaterOrEqual(ProgramStateRef State, SymbolRef Sym1, SymbolRef Sym2);

NoQ wrote:
> One more unused function.
OK.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:515-516
+bool isGreaterOrEqual(ProgramStateRef State, SymbolRef Sym1, SymbolRef Sym2);
+bool compareToZero(ProgramStateRef State, const NonLoc &Val,
+   BinaryOperator::Opcode Opc);
+bool compare(ProgramStateRef St

Re: r301992 - [modules] Round-trip -Werror flag through explicit module build.

2017-05-04 Thread Alex L via cfe-commits
On 3 May 2017 at 22:23, Richard Smith  wrote:

> On 3 May 2017 at 07:29, Alex L  wrote:
>
>> Hi Richard,
>>
>> This commit has caused an infinite loop in one of our internal libclang
>> based tooling tests. It keeps repeating the following frames:
>>
>> frame #33528: 0x000109db2edf libclang.dylib`clang::Diagnost
>> icsEngine::ReportDelayed(this=0x00011c002c00) at Diagnostic.cpp:149
>> frame #33529: 0x000109db5a36 libclang.dylib`clang::Diagnost
>> icsEngine::EmitCurrentDiagnostic(this=0x00011c002c00, Force=false)
>> at Diagnostic.cpp:428
>> frame #33530: 0x00010a33f93c libclang.dylib`clang::Diagnost
>> icBuilder::Emit(this=0x78d4bfd8) at Diagnostic.h:1013
>> frame #33531: 0x00010a33f8e5 libclang.dylib`clang::Diagnost
>> icBuilder::~DiagnosticBuilder(this=0x78d4bfd8) at
>> Diagnostic.h:1036
>> frame #33532: 0x00010a335015 libclang.dylib`clang::Diagnost
>> icBuilder::~DiagnosticBuilder(this=0x78d4bfd8) at
>> Diagnostic.h:1035
>>
>> It doesn't really look like a regression though, it seems that this has
>> just uncovered a bug in Clang: DiagnosticsEngine::ReportDelayed is
>> clearing DelayedDiagID *after* reporting the issue which causes the
>> infinite recursion, when it should clear it before. Is that right?
>>
>
> EmitCurrentDiagnostic checks "DelayedDiagID != DiagID" before making the
> recursive call, which should be preventing the infinite recursion.
>
> It looks like the immediate bug is that EmitCurrentDiagnostic grabs
> CurDiagID *after* calling EmitDiag / ProcessDiag, which clear CurDiagID
> when they succeed in emitting the diagnostic. But I agree, the right thing
> to do is clear DelayedDiagID before emitting the delayed diagnostic, not
> after. You should also be able to delete the incorrect recursion check in
> EmitCurrentDiagnostic too.
>

Thanks, that makes sense.

Unfortunately I had to revert my fix as it uncovered two issues in
Misc/error-limit-multiple-notes.cpp and Misc/error-limit.c . It looks like
your commit caused the infinite recursion in both of them, but the bots
didn't catch that because they invoked not clang, and emitted the
diagnostics that were checked (using FileCheck) before crashing, so they
"passed". However, my fix causes the tests to fail, seemingly because now
Clang doesn't suppress multiple notes after reaching the error limit (it
suppresses just the first note). It looks like this is a regression
introduced in this commit.



>
>
>> I will commit a fix for this now.
>>
>
> Thank you!
>
>
>> Alex
>>
>>
>> On 3 May 2017 at 01:28, Richard Smith via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: rsmith
>>> Date: Tue May  2 19:28:49 2017
>>> New Revision: 301992
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=301992&view=rev
>>> Log:
>>> [modules] Round-trip -Werror flag through explicit module build.
>>>
>>> The intent for an explicit module build is that the diagnostics produced
>>> within
>>> the module are those that were configured when the module was built, not
>>> those
>>> that are enabled within a user of the module. This includes diagnostics
>>> that
>>> don't actually show up until the module is used (for instance,
>>> diagnostics
>>> produced during template instantiation and weird cases like -Wpadded).
>>>
>>> We serialized and restored the diagnostic state for individual warning
>>> groups,
>>> but previously did not track the state for flags like -Werror and
>>> -Weverything,
>>> which are implemented as separate bits rather than as part of the
>>> diagnostics
>>> mapping information.
>>>
>>> Modified:
>>> cfe/trunk/include/clang/Basic/Diagnostic.h
>>> cfe/trunk/include/clang/Basic/DiagnosticIDs.h
>>> cfe/trunk/lib/Basic/Diagnostic.cpp
>>> cfe/trunk/lib/Basic/DiagnosticIDs.cpp
>>> cfe/trunk/lib/Serialization/ASTReader.cpp
>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>> cfe/trunk/test/Index/keep-going.cpp
>>> cfe/trunk/test/Modules/diag-flags.cpp
>>> cfe/trunk/tools/libclang/CIndex.cpp
>>> cfe/trunk/unittests/Basic/DiagnosticTest.cpp
>>>
>>> Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
>>> Basic/Diagnostic.h?rev=301992&r1=301991&r2=301992&view=diff
>>> 
>>> ==
>>> --- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
>>> +++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue May  2 19:28:49 2017
>>> @@ -178,12 +178,7 @@ public:
>>>
>>>  private:
>>>unsigned char AllExtensionsSilenced; // Used by __extension__
>>> -  bool IgnoreAllWarnings;// Ignore all warnings: -w
>>> -  bool WarningsAsErrors; // Treat warnings like errors.
>>> -  bool EnableAllWarnings;// Enable all warnings.
>>> -  bool ErrorsAsFatal;// Treat errors like fatal errors.
>>> -  bool FatalsAsError; // Treat fatal errors like errors.
>>> -  bool SuppressSys

Re: r301992 - [modules] Round-trip -Werror flag through explicit module build.

2017-05-04 Thread Alex L via cfe-commits
On 4 May 2017 at 12:43, Alex L  wrote:

>
>
> On 3 May 2017 at 22:23, Richard Smith  wrote:
>
>> On 3 May 2017 at 07:29, Alex L  wrote:
>>
>>> Hi Richard,
>>>
>>> This commit has caused an infinite loop in one of our internal libclang
>>> based tooling tests. It keeps repeating the following frames:
>>>
>>> frame #33528: 0x000109db2edf libclang.dylib`clang::Diagnost
>>> icsEngine::ReportDelayed(this=0x00011c002c00) at Diagnostic.cpp:149
>>> frame #33529: 0x000109db5a36 libclang.dylib`clang::Diagnost
>>> icsEngine::EmitCurrentDiagnostic(this=0x00011c002c00, Force=false)
>>> at Diagnostic.cpp:428
>>> frame #33530: 0x00010a33f93c libclang.dylib`clang::Diagnost
>>> icBuilder::Emit(this=0x78d4bfd8) at Diagnostic.h:1013
>>> frame #33531: 0x00010a33f8e5 libclang.dylib`clang::Diagnost
>>> icBuilder::~DiagnosticBuilder(this=0x78d4bfd8) at
>>> Diagnostic.h:1036
>>> frame #33532: 0x00010a335015 libclang.dylib`clang::Diagnost
>>> icBuilder::~DiagnosticBuilder(this=0x78d4bfd8) at
>>> Diagnostic.h:1035
>>>
>>> It doesn't really look like a regression though, it seems that this has
>>> just uncovered a bug in Clang: DiagnosticsEngine::ReportDelayed is
>>> clearing DelayedDiagID *after* reporting the issue which causes the
>>> infinite recursion, when it should clear it before. Is that right?
>>>
>>
>> EmitCurrentDiagnostic checks "DelayedDiagID != DiagID" before making the
>> recursive call, which should be preventing the infinite recursion.
>>
>> It looks like the immediate bug is that EmitCurrentDiagnostic grabs
>> CurDiagID *after* calling EmitDiag / ProcessDiag, which clear CurDiagID
>> when they succeed in emitting the diagnostic. But I agree, the right thing
>> to do is clear DelayedDiagID before emitting the delayed diagnostic, not
>> after. You should also be able to delete the incorrect recursion check in
>> EmitCurrentDiagnostic too.
>>
>
> Thanks, that makes sense.
>
> Unfortunately I had to revert my fix as it uncovered two issues in
> Misc/error-limit-multiple-notes.cpp and Misc/error-limit.c . It looks
> like your commit caused the infinite recursion in both of them, but the
> bots didn't catch that because they invoked not clang, and emitted the
> diagnostics that were checked (using FileCheck) before crashing, so they
> "passed". However, my fix causes the tests to fail, seemingly because now
> Clang doesn't suppress multiple notes after reaching the error limit (it
> suppresses just the first note). It looks like this is a regression
> introduced in this commit.
>
> Sorry, I was wrong in my analysis. It's not a regression introduced by
your commit, it's just a problem with my fix.


>
>
>>
>>
>>> I will commit a fix for this now.
>>>
>>
>> Thank you!
>>
>>
>>> Alex
>>>
>>>
>>> On 3 May 2017 at 01:28, Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rsmith
 Date: Tue May  2 19:28:49 2017
 New Revision: 301992

 URL: http://llvm.org/viewvc/llvm-project?rev=301992&view=rev
 Log:
 [modules] Round-trip -Werror flag through explicit module build.

 The intent for an explicit module build is that the diagnostics
 produced within
 the module are those that were configured when the module was built,
 not those
 that are enabled within a user of the module. This includes diagnostics
 that
 don't actually show up until the module is used (for instance,
 diagnostics
 produced during template instantiation and weird cases like -Wpadded).

 We serialized and restored the diagnostic state for individual warning
 groups,
 but previously did not track the state for flags like -Werror and
 -Weverything,
 which are implemented as separate bits rather than as part of the
 diagnostics
 mapping information.

 Modified:
 cfe/trunk/include/clang/Basic/Diagnostic.h
 cfe/trunk/include/clang/Basic/DiagnosticIDs.h
 cfe/trunk/lib/Basic/Diagnostic.cpp
 cfe/trunk/lib/Basic/DiagnosticIDs.cpp
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/test/Index/keep-going.cpp
 cfe/trunk/test/Modules/diag-flags.cpp
 cfe/trunk/tools/libclang/CIndex.cpp
 cfe/trunk/unittests/Basic/DiagnosticTest.cpp

 Modified: cfe/trunk/include/clang/Basic/Diagnostic.h
 URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/
 Basic/Diagnostic.h?rev=301992&r1=301991&r2=301992&view=diff
 
 ==
 --- cfe/trunk/include/clang/Basic/Diagnostic.h (original)
 +++ cfe/trunk/include/clang/Basic/Diagnostic.h Tue May  2 19:28:49 2017
 @@ -178,12 +178,7 @@ public:

  private:
unsigned char AllExtensionsSilenced; // Used by __extension__
 -  bool IgnoreAllWarnings;// Ignore all warnings: -w
 - 

[PATCH] D32592: [Analyzer] Iterator Checker - Part1: Minimal Checker for a Simple Test Case

2017-05-04 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added inline comments.



Comment at: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp:478-479
+auto &SymMgr = C.getSymbolManager();
+EndSym = SymMgr.conjureSymbol(CE, C.getLocationContext(),
+  C.getASTContext().LongTy, C.blockCount());
+State = createContainerEnd(State, ContReg, EndSym);

baloghadamsoftware wrote:
> NoQ wrote:
> > I see what you did here! And i suggest considering `SymbolMetadata` here 
> > instead of `SymbolConjured`, because it was designed for this purpose: the 
> > checker for some reason knows there's a special property of an object he 
> > wants to track, the checker doesn't have a ready-made symbolic value to 
> > represent this property (because the engine didn't know this property even 
> > exists, so it didn't denote its value), so the checker comes up with its 
> > own notation. `SymbolMetadata` is used, for example, in `CStringChecker` to 
> > denote an unknown string length for a given null-terminated string region.
> > 
> > This symbol carries the connection to the region (you may use it to 
> > reverse-lookup the region if necessary), and in particular it is considered 
> > to be live as long as the base region is live (so you don't have to deal 
> > with liveness manually; see also comments around 
> > `SymbolReaper::MarkInUse`). It's also easier to debug, because we can track 
> > the symbol back to the checker. Generally, symbol class hierarchy is cool 
> > because we know a lot about the symbol by just looking at it, and 
> > `SymbolConjured` is a sad fallback we use when we didn't care or manage to 
> > come up with a better symbol.
> > 
> > I'm not sure if `LongTy` is superior to `IntTy` here, since we don't know 
> > what to expect from the container anyway.
> > 
> > Also, please de-duplicate the symbol creation code. Birth of a symbol is 
> > something so rare it deserves a drum roll :)
> > 
> > I'd take a pause to figure out if the same logic should be applied to the 
> > map from containers to end-iterators.
> SymbolMetaData is bound to a MemRegion. Iterators are sometimes symbols and 
> sometimes memory regions, this was one of the first lessons I learned from my 
> first iterator checker.
Oh. Hmm. Ok. Right.

To be sure: in what cases do you need to create a new symbol when the iterator 
is already a symbol? How broken do we become if we try to say that the symbolic 
iterator and its own offset are the same thing?


https://reviews.llvm.org/D32592



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


r302141 - Revert "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."

2017-05-04 Thread Eric Liu via cfe-commits
Author: ioeric
Date: Thu May  4 07:05:40 2017
New Revision: 302141

URL: http://llvm.org/viewvc/llvm-project?rev=302141&view=rev
Log:
Revert "IR: Use pointers instead of GUIDs to represent edges in the module 
summary. NFCI."

This reverts commit r302108.

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

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=302141&r1=302140&r2=302141&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu May  4 07:05:40 2017
@@ -975,9 +975,9 @@ static void runThinLTOBackend(ModuleSumm
   FunctionImporter::ImportMapTy ImportList;
   for (auto &GlobalList : *CombinedIndex) {
 auto GUID = GlobalList.first;
-assert(GlobalList.second.SummaryList.size() == 1 &&
+assert(GlobalList.second.size() == 1 &&
"Expected individual combined index to have one summary per GUID");
-auto &Summary = GlobalList.second.SummaryList[0];
+auto &Summary = GlobalList.second[0];
 // Skip the summaries for the importing module. These are included to
 // e.g. record required linkage changes.
 if (Summary->modulePath() == M->getModuleIdentifier())


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


[PATCH] D32859: [Analyzer] Iterator Checker - Part 5: Move Assignment of Containers

2017-05-04 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.

If a container is moved by its move assignment operator, according to the 
standard all their iterators except the past-end iterators remain valid but 
refer to the new container. This patch introduces support for this case in the 
iterator checkers.


https://reviews.llvm.org/D32859

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/mismatched-iterator.cpp

Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -15,11 +15,23 @@
   std::copy(v1.cbegin(), v1.cend(), v2.begin()); // no-warning
 }
 
+void good_move_find(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cbegin();
+  v1 = std::move(v2);
+  std::find(i0, v1.cend(), n); // no-warning
+}
+
 void bad_find(std::vector &v1, std::vector &v2, int n) {
   std::find(v1.cbegin(), v2.cend(), n); // expected-warning{{Iterator access mismatched}}
 }
 
 void bad_find_first_of(std::vector &v1, std::vector &v2) {
   std::find_first_of(v1.cbegin(), v2.cend(), v2.cbegin(), v2.cend()); // expected-warning{{Iterator access mismatched}}
   std::find_first_of(v1.cbegin(), v1.cend(), v2.cbegin(), v1.cend()); // expected-warning{{Iterator access mismatched}}
 }
+
+void bad_move_find(std::vector &v1, std::vector &v2, int n) {
+  auto i0 = v2.cbegin();
+  v1 = std::move(v2);
+  std::find(i0, v2.cend(), n); // expected-warning{{Iterator access mismatched}}
+}
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -51,6 +51,10 @@
 return IteratorPosition(Cont, Valid, NewOf);
   }
 
+  IteratorPosition reAssign(const MemRegion *NewCont) const {
+return IteratorPosition(NewCont, Valid, Offset);
+  }
+
   bool operator==(const IteratorPosition &X) const {
 return Cont == X.Cont && Valid == X.Valid && Offset == X.Offset;
   }
@@ -153,7 +157,9 @@
  const SVal &Cont) const;
   void assignToContainer(CheckerContext &C, const Expr *CE, const SVal &RetVal,
  const MemRegion *Cont) const;
-  void handleAssign(CheckerContext &C, const SVal &Cont) const;
+  void handleAssign(CheckerContext &C, const SVal &Cont,
+const Expr *CE = nullptr,
+const SVal &OldCont = UndefinedVal()) const;
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
@@ -257,6 +263,17 @@
 bool Equal);
 ProgramStateRef invalidateAllIteratorPositions(ProgramStateRef State,
const MemRegion *Cont);
+ProgramStateRef reassignAllIteratorPositions(ProgramStateRef State,
+ const MemRegion *Cont,
+ const MemRegion *NewCont);
+ProgramStateRef reassignAllIteratorPositionsUnless(ProgramStateRef State,
+   const MemRegion *Cont,
+   const MemRegion *NewCont,
+   SymbolRef Offset,
+   BinaryOperator::Opcode Opc);
+ProgramStateRef replaceSymbolInIteratorPositionsIf(
+ProgramStateRef State, SymbolManager &SymMgr, SymbolRef OldSym,
+SymbolRef NewSym, SymbolRef CondSym, BinaryOperator::Opcode Opc);
 const ContainerData *getContainerData(ProgramStateRef State,
   const MemRegion *Cont);
 ProgramStateRef setContainerData(ProgramStateRef State, const MemRegion *Cont,
@@ -386,7 +403,12 @@
 const auto Op = Func->getOverloadedOperator();
 if (isAssignmentOperator(Op)) {
   const auto *InstCall = dyn_cast(&Call);
-  handleAssign(C, InstCall->getCXXThisVal());
+  if (Func->getParamDecl(0)->getType()->isRValueReferenceType()) {
+handleAssign(C, InstCall->getCXXThisVal(), Call.getOriginExpr(),
+ Call.getArgSVal(0));
+  } else {
+handleAssign(C, InstCall->getCXXThisVal());
+  }
 } else if (isSimpleComparisonOperator(Op)) {
   if (const auto *InstCall = dyn_cast(&Call)) {
 handleComparison(C, Call.getReturnValue(), InstCall->getCXXThisVal(),
@@ -873,7 +895,8 @@
   C.addTransition(State);
 }
 
-void IteratorChecker::handleAssign(CheckerContext &C, const SVal &Cont) const {
+void IteratorChecker::handleAssign(CheckerContext &C, const SVal &Cont,
+   const Expr *CE, const SVal &OldCont) const {
   const auto *ContReg = Cont.getAsRegion();
   if (!ContReg)
 return;
@@ -889,6 +912,51 @@
   if (CData) {
 State

r302143 - Add support of the next Ubuntu (Ubuntu 17.10 - Artful Aardvark)

2017-05-04 Thread Sylvestre Ledru via cfe-commits
Author: sylvestre
Date: Thu May  4 07:46:38 2017
New Revision: 302143

URL: http://llvm.org/viewvc/llvm-project?rev=302143&view=rev
Log:
Add support of the next Ubuntu (Ubuntu 17.10 - Artful Aardvark)


Modified:
cfe/trunk/include/clang/Driver/Distro.h
cfe/trunk/lib/Driver/Distro.cpp

Modified: cfe/trunk/include/clang/Driver/Distro.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Distro.h?rev=302143&r1=302142&r2=302143&view=diff
==
--- cfe/trunk/include/clang/Driver/Distro.h (original)
+++ cfe/trunk/include/clang/Driver/Distro.h Thu May  4 07:46:38 2017
@@ -57,6 +57,7 @@ public:
 UbuntuXenial,
 UbuntuYakkety,
 UbuntuZesty,
+UbuntuArtful,
 UnknownDistro
   };
 
@@ -110,9 +111,9 @@ public:
   }
 
   bool IsUbuntu() const {
-return DistroVal >= UbuntuHardy && DistroVal <= UbuntuZesty;
+return DistroVal >= UbuntuHardy && DistroVal <= UbuntuArtful;
   }
- 
+
   /// @}
 };
 

Modified: cfe/trunk/lib/Driver/Distro.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Distro.cpp?rev=302143&r1=302142&r2=302143&view=diff
==
--- cfe/trunk/lib/Driver/Distro.cpp (original)
+++ cfe/trunk/lib/Driver/Distro.cpp Thu May  4 07:46:38 2017
@@ -47,6 +47,7 @@ static Distro::DistroType DetectDistro(v
   .Case("xenial", Distro::UbuntuXenial)
   .Case("yakkety", Distro::UbuntuYakkety)
   .Case("zesty", Distro::UbuntuZesty)
+  .Case("artful", Distro::UbuntuArtful)
   .Default(Distro::UnknownDistro);
 if (Version != Distro::UnknownDistro)
   return Version;


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


[PATCH] D32860: [Analyzer] Iterator Checker - Part 6: Mismatched iterator checker for constructors and comparisons

2017-05-04 Thread Balogh , Ádám via Phabricator via cfe-commits
baloghadamsoftware created this revision.

Extension of the mismatched iterator checker for constructors taking range of 
first..last (first and last must be iterators of the same container) and also 
for comparisons of iterators of different containers (one does not compare 
iterators of different containers, since the set of iterators is partially 
ordered, there are no relations between iterators of different containers, 
except that they are always non-equal).


https://reviews.llvm.org/D32860

Files:
  lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
  test/Analysis/mismatched-iterator.cpp

Index: test/Analysis/mismatched-iterator.cpp
===
--- test/Analysis/mismatched-iterator.cpp
+++ test/Analysis/mismatched-iterator.cpp
@@ -3,6 +3,10 @@
 
 #include "Inputs/system-header-simulator-cxx.h"
 
+void good_ctor(std::vector &v) {
+  std::vector new_v(v.cbegin(), v.cend()); // no-warning
+}
+
 void good_find(std::vector &v, int n) {
   std::find(v.cbegin(), v.cend(), n); // no-warning
 }
@@ -21,6 +25,14 @@
   std::find(i0, v1.cend(), n); // no-warning
 }
 
+void good_comparison(std::vector &v) {
+  if (v.cbegin() == v.cend()) {} // no-warning
+}
+
+void bad_ctor(std::vector &v1, std::vector &v2) {
+  std::vector new_v(v1.cbegin(), v2.cend()); // expected-warning{{Iterator access mismatched}}
+}
+
 void bad_find(std::vector &v1, std::vector &v2, int n) {
   std::find(v1.cbegin(), v2.cend(), n); // expected-warning{{Iterator access mismatched}}
 }
@@ -35,3 +47,9 @@
   v1 = std::move(v2);
   std::find(i0, v2.cend(), n); // expected-warning{{Iterator access mismatched}}
 }
+
+void bad_comparison(std::vector &v1, std::vector &v2) {
+  if (v1.cbegin() != v2.cend()) { // expected-warning{{Iterator access mismatched}}
+*v1.cbegin();
+  }
+}
Index: lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
+++ lib/StaticAnalyzer/Checkers/IteratorChecker.cpp
@@ -131,6 +131,7 @@
 
 class IteratorChecker
 : public Checker,
  check::PreStmt,
  check::PostStmt,
  check::LiveSymbols, check::DeadSymbols,
@@ -163,6 +164,8 @@
   void verifyRandomIncrOrDecr(CheckerContext &C, OverloadedOperatorKind Op,
   const SVal &RetVal, const SVal &LHS,
   const SVal &RHS) const;
+  void verifyMatch(CheckerContext &C, const SVal &Iter,
+   const MemRegion *Cont) const;
   void verifyMatch(CheckerContext &C, const SVal &Iter1,
const SVal &Iter2) const;
 
@@ -188,7 +191,10 @@
 
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
   void checkPostCall(const CallEvent &Call, CheckerContext &C) const;
+  void checkPreStmt(const CXXConstructExpr *CCE, CheckerContext &C) const;
   void checkPreStmt(const CXXOperatorCallExpr *COCE, CheckerContext &C) const;
+  void checkPostStmt(const CXXConstructExpr *CCE, CheckerContext &C) const;
+  void checkPostStmt(const DeclStmt *DS, CheckerContext &C) const;
   void checkPostStmt(const MaterializeTemporaryExpr *MTE,
  CheckerContext &C) const;
   void checkLiveSymbols(ProgramStateRef State, SymbolReaper &SR) const;
@@ -218,6 +224,7 @@
 
 bool isIteratorType(const QualType &Type);
 bool isIterator(const CXXRecordDecl *CRD);
+bool isComparisonOperator(OverloadedOperatorKind OK);
 bool isBeginCall(const FunctionDecl *Func);
 bool isEndCall(const FunctionDecl *Func);
 bool isAssignmentOperator(OverloadedOperatorKind OK);
@@ -341,6 +348,28 @@
   } else {
 verifyDereference(C, Call.getArgSVal(0));
   }
+} else if (ChecksEnabled[CK_MismatchedIteratorChecker] &&
+   isComparisonOperator(Func->getOverloadedOperator())) {
+  // Check for comparisons of iterators of different containers
+  if (const auto *InstCall = dyn_cast(&Call)) {
+if (Call.getNumArgs() < 1)
+  return;
+
+if (!isIteratorType(InstCall->getCXXThisExpr()->getType()) ||
+!isIteratorType(Call.getArgExpr(0)->getType()))
+  return;
+
+verifyMatch(C, InstCall->getCXXThisVal(), Call.getArgSVal(0));
+  } else {
+if (Call.getNumArgs() < 2)
+  return;
+
+if (!isIteratorType(Call.getArgExpr(0)->getType()) ||
+!isIteratorType(Call.getArgExpr(1)->getType()))
+  return;
+
+verifyMatch(C, Call.getArgSVal(0), Call.getArgSVal(1));
+  }
 }
   } else if (!isa(&Call)) {
 // The main purpose of iterators is to abstract away from different
@@ -501,6 +530,31 @@
   }
 }
 
+void IteratorChecker::checkPreStmt(const CXXConstructExpr *CCE,
+   CheckerContext &C) const {
+  // Check match of first-last iterator pair in a constructor of a container
+  if (CCE->getNumArgs() < 2)
+return;
+
+  const auto *Ctr = CCE->getConst

r302151 - DiagnosticsEngine should clear DelayedDiagID before reporting the

2017-05-04 Thread Alex Lorenz via cfe-commits
Author: arphaman
Date: Thu May  4 08:56:51 2017
New Revision: 302151

URL: http://llvm.org/viewvc/llvm-project?rev=302151&view=rev
Log:
DiagnosticsEngine should clear DelayedDiagID before reporting the
delayed diagnostic

This fix avoids an infinite recursion that was uncovered in one of our internal
tests by r301992. The testcase is the most reduced version of that
auto-generated test.

This is an improved version of the reverted commit r302037. The previous fix
actually managed to expose another subtle bug whereby `fatal_too_many_errors`
error was reported twice, with the second report setting the
`FatalErrorOccurred` flag. That prevented the notes that followed the diagnostic
the caused `fatal_too_many_errors` to be emitted. This commit ensures that notes
that follow `fatal_too_many_errors` but that belong to the diagnostic that
caused `fatal_too_many_errors` won't be emitted by setting the
`FatalErrorOccurred` when emitting `fatal_too_many_errors`.

rdar://31962618

Added:
cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm
Modified:
cfe/trunk/lib/Basic/Diagnostic.cpp
cfe/trunk/lib/Basic/DiagnosticIDs.cpp

Modified: cfe/trunk/lib/Basic/Diagnostic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Diagnostic.cpp?rev=302151&r1=302150&r2=302151&view=diff
==
--- cfe/trunk/lib/Basic/Diagnostic.cpp (original)
+++ cfe/trunk/lib/Basic/Diagnostic.cpp Thu May  4 08:56:51 2017
@@ -146,10 +146,9 @@ void DiagnosticsEngine::SetDelayedDiagno
 }
 
 void DiagnosticsEngine::ReportDelayed() {
-  Report(DelayedDiagID) << DelayedDiagArg1 << DelayedDiagArg2;
+  unsigned ID = DelayedDiagID;
   DelayedDiagID = 0;
-  DelayedDiagArg1.clear();
-  DelayedDiagArg2.clear();
+  Report(ID) << DelayedDiagArg1 << DelayedDiagArg2;
 }
 
 void DiagnosticsEngine::DiagStateMap::appendFirst(
@@ -420,11 +419,10 @@ bool DiagnosticsEngine::EmitCurrentDiagn
   }
 
   // Clear out the current diagnostic object.
-  unsigned DiagID = CurDiagID;
   Clear();
 
   // If there was a delayed diagnostic, emit it now.
-  if (!Force && DelayedDiagID && DelayedDiagID != DiagID)
+  if (!Force && DelayedDiagID)
 ReportDelayed();
 
   return Emitted;

Modified: cfe/trunk/lib/Basic/DiagnosticIDs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/DiagnosticIDs.cpp?rev=302151&r1=302150&r2=302151&view=diff
==
--- cfe/trunk/lib/Basic/DiagnosticIDs.cpp (original)
+++ cfe/trunk/lib/Basic/DiagnosticIDs.cpp Thu May  4 08:56:51 2017
@@ -666,6 +666,10 @@ bool DiagnosticIDs::ProcessDiag(Diagnost
 }
   }
 
+  // Make sure we set FatalErrorOccurred to ensure that the notes from the
+  // diagnostic that caused `fatal_too_many_errors` won't be emitted.
+  if (Diag.CurDiagID == diag::fatal_too_many_errors)
+Diag.FatalErrorOccurred = true;
   // Finally, report it.
   EmitDiag(Diag, DiagLevel);
   return true;

Added: cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm?rev=302151&view=auto
==
--- cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm (added)
+++ cfe/trunk/test/Index/KeepGoingWithLotsOfErrors.mm Thu May  4 08:56:51 2017
@@ -0,0 +1,29 @@
+// RUN: env CINDEXTEST_KEEP_GOING=1 c-index-test -code-completion-at=%s:25:1 %s
+// Shouldn't crash!
+// This is the minimized test that triggered an infinite recursion:
+
++(BOOL) onEntity {
+}
+
+-(const Object &) a_200 {
+}
+
+-(int) struct {
+}
+
+-(int) bar {
+}
+
+-(int) part {
+}
+
++(some_type_t) piece {
+}
+
++(void) z_Z_42 {
+  ([self onEntity: [] { 42];
+  } class: ^ {  }
+];
+  [super];
+  BOOL struct;
+}


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


Re: r301992 - [modules] Round-trip -Werror flag through explicit module build.

2017-05-04 Thread Alex L via cfe-commits
On 4 May 2017 at 12:52, Alex L  wrote:

>
>
> On 4 May 2017 at 12:43, Alex L  wrote:
>
>>
>>
>> On 3 May 2017 at 22:23, Richard Smith  wrote:
>>
>>> On 3 May 2017 at 07:29, Alex L  wrote:
>>>
 Hi Richard,

 This commit has caused an infinite loop in one of our internal libclang
 based tooling tests. It keeps repeating the following frames:

 frame #33528: 0x000109db2edf libclang.dylib`clang::Diagnost
 icsEngine::ReportDelayed(this=0x00011c002c00) at Diagnostic.cpp:149
 frame #33529: 0x000109db5a36 libclang.dylib`clang::Diagnost
 icsEngine::EmitCurrentDiagnostic(this=0x00011c002c00, Force=false)
 at Diagnostic.cpp:428
 frame #33530: 0x00010a33f93c libclang.dylib`clang::Diagnost
 icBuilder::Emit(this=0x78d4bfd8) at Diagnostic.h:1013
 frame #33531: 0x00010a33f8e5 libclang.dylib`clang::Diagnost
 icBuilder::~DiagnosticBuilder(this=0x78d4bfd8) at
 Diagnostic.h:1036
 frame #33532: 0x00010a335015 libclang.dylib`clang::Diagnost
 icBuilder::~DiagnosticBuilder(this=0x78d4bfd8) at
 Diagnostic.h:1035

 It doesn't really look like a regression though, it seems that this has
 just uncovered a bug in Clang: DiagnosticsEngine::ReportDelayed is
 clearing DelayedDiagID *after* reporting the issue which causes the
 infinite recursion, when it should clear it before. Is that right?

>>>
>>> EmitCurrentDiagnostic checks "DelayedDiagID != DiagID" before making the
>>> recursive call, which should be preventing the infinite recursion.
>>>
>>> It looks like the immediate bug is that EmitCurrentDiagnostic grabs
>>> CurDiagID *after* calling EmitDiag / ProcessDiag, which clear CurDiagID
>>> when they succeed in emitting the diagnostic. But I agree, the right thing
>>> to do is clear DelayedDiagID before emitting the delayed diagnostic, not
>>> after. You should also be able to delete the incorrect recursion check in
>>> EmitCurrentDiagnostic too.
>>>
>>
>> Thanks, that makes sense.
>>
>> Unfortunately I had to revert my fix as it uncovered two issues in
>> Misc/error-limit-multiple-notes.cpp and Misc/error-limit.c . It looks
>> like your commit caused the infinite recursion in both of them, but the
>> bots didn't catch that because they invoked not clang, and emitted the
>> diagnostics that were checked (using FileCheck) before crashing, so they
>> "passed". However, my fix causes the tests to fail, seemingly because now
>> Clang doesn't suppress multiple notes after reaching the error limit (it
>> suppresses just the first note). It looks like this is a regression
>> introduced in this commit.
>>
>> Sorry, I was wrong in my analysis. It's not a regression introduced by
> your commit, it's just a problem with my fix.
>

I figured out what was wrong, turns out there was another subtle bug -
Clang was actually reporting `fatal_too_many_errors` twice (recursively),
and the second invocation set `FatalErrorOccurred`, and thus prevented the
notes from the diagnostic that caused `fatal_too_many_errors` to get
emitted. But my fix fixed that subtle bug as well, so I had to explicitly
set `FatalErrorOccurred` when reporting `fatal_too_many_errors`. It should
be fixed now in r302151.


>
>
>>
>>
>>>
>>>
 I will commit a fix for this now.

>>>
>>> Thank you!
>>>
>>>
 Alex


 On 3 May 2017 at 01:28, Richard Smith via cfe-commits <
 cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue May  2 19:28:49 2017
> New Revision: 301992
>
> URL: http://llvm.org/viewvc/llvm-project?rev=301992&view=rev
> Log:
> [modules] Round-trip -Werror flag through explicit module build.
>
> The intent for an explicit module build is that the diagnostics
> produced within
> the module are those that were configured when the module was built,
> not those
> that are enabled within a user of the module. This includes
> diagnostics that
> don't actually show up until the module is used (for instance,
> diagnostics
> produced during template instantiation and weird cases like -Wpadded).
>
> We serialized and restored the diagnostic state for individual warning
> groups,
> but previously did not track the state for flags like -Werror and
> -Weverything,
> which are implemented as separate bits rather than as part of the
> diagnostics
> mapping information.
>
> Modified:
> cfe/trunk/include/clang/Basic/Diagnostic.h
> cfe/trunk/include/clang/Basic/DiagnosticIDs.h
> cfe/trunk/lib/Basic/Diagnostic.cpp
> cfe/trunk/lib/Basic/DiagnosticIDs.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/Index/keep-going.cpp
> cfe/trunk/test/Modules/diag-flags.cpp
> cfe/trunk/tools/libclang/CIndex.cpp
> cfe/trunk/unittests/Basic/DiagnosticTest.cpp

[PATCH] D32864: clang-format: [JS] exponentiation operator

2017-05-04 Thread Martin Probst via Phabricator via cfe-commits
mprobst created this revision.
Herald added a subscriber: klimek.

While its precedence should be higher than multiplicative, LLVM does not have a 
level for that, so for the time being just treat it as multiplicative.


https://reviews.llvm.org/D32864

Files:
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1786,5 +1786,10 @@
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
 }
+
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,8 @@
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
 static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
   return;
@@ -83,6 +85,8 @@
   return;
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
+if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+  return;
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -53,6 +53,7 @@
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
   TYPE(JsComputedPropertyName) \
+  TYPE(JsExponentiation) \
   TYPE(JsFatArrow) \
   TYPE(JsNonNullAssertion) \
   TYPE(JsTypeColon) \


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1786,5 +1786,10 @@
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
 }
+
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,8 @@
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
 static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
   return;
@@ -83,6 +85,8 @@
   return;
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
+if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+  return;
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -53,6 +53,7 @@
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
   TYPE(JsComputedPropertyName) \
+  TYPE(JsExponentiation) \
   TYPE(JsFatArrow) \
   TYPE(JsNonNullAssertion) \
   TYPE(JsTypeColon) \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32864: clang-format: [JS] exponentiation operator

2017-05-04 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added inline comments.
This revision is now accepted and ready to land.



Comment at: unittests/Format/FormatTestJS.cpp:1791
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+}

Also make this handle **= ?


https://reviews.llvm.org/D32864



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


[PATCH] D32856: [OpenCL] Check that global samplers are const

2017-05-04 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: include/clang/Basic/DiagnosticSemaKinds.td:8301
+def err_opencl_sampler_qualifier : Error<
+  "global sampler requires a const qualifier">;
 def err_opencl_cast_non_zero_to_event_t : Error<

global sampler requires a const or constant address space qualifier



Comment at: lib/Sema/SemaDecl.cpp:6085
+  // space qualifier or with the const qualifier.
+  if (DC->isTranslationUnit() &&
+  !(R.getAddressSpace() == LangAS::opencl_constant ||

should be else if ?

if the previous error already happens, it is unnecessary to do the next check


https://reviews.llvm.org/D32856



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


[PATCH] D32864: clang-format: [JS] exponentiation operator

2017-05-04 Thread Martin Probst via Phabricator via cfe-commits
mprobst updated this revision to Diff 97829.
mprobst added a comment.

- support **=


https://reviews.llvm.org/D32864

Files:
  lib/Format/FormatToken.h
  lib/Format/FormatTokenLexer.cpp
  unittests/Format/FormatTestJS.cpp


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1786,5 +1786,11 @@
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
 }
+
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+  verifyFormat("squared **= 2;");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,10 @@
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
 static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
+   tok::starequal};
+
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
   return;
@@ -83,6 +87,12 @@
   return;
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
+if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+  return;
+if (tryMergeTokens(JSExponentiationEqual, TT_JsExponentiationEqual)) {
+  Tokens.back()->Tok.setKind(tok::starequal);
+  return;
+}
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -53,6 +53,8 @@
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
   TYPE(JsComputedPropertyName) \
+  TYPE(JsExponentiation) \
+  TYPE(JsExponentiationEqual) \
   TYPE(JsFatArrow) \
   TYPE(JsNonNullAssertion) \
   TYPE(JsTypeColon) \


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1786,5 +1786,11 @@
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
 }
+
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+  verifyFormat("squared **= 2;");
+}
+
 } // end namespace tooling
 } // end namespace clang
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,10 @@
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
 static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
+   tok::starequal};
+
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
   return;
@@ -83,6 +87,12 @@
   return;
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
+if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+  return;
+if (tryMergeTokens(JSExponentiationEqual, TT_JsExponentiationEqual)) {
+  Tokens.back()->Tok.setKind(tok::starequal);
+  return;
+}
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
Index: lib/Format/FormatToken.h
===
--- lib/Format/FormatToken.h
+++ lib/Format/FormatToken.h
@@ -53,6 +53,8 @@
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
   TYPE(JsComputedPropertyName) \
+  TYPE(JsExponentiation) \
+  TYPE(JsExponentiationEqual) \
   TYPE(JsFatArrow) \
   TYPE(JsNonNullAssertion) \
   TYPE(JsTypeColon) \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32864: clang-format: [JS] exponentiation operator

2017-05-04 Thread Daniel Jasper via Phabricator via cfe-commits
djasper accepted this revision.
djasper added a comment.

Thanks


https://reviews.llvm.org/D32864



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


[PATCH] D32864: clang-format: [JS] exponentiation operator

2017-05-04 Thread Martin Probst via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302156: clang-format: [JS] exponentiation operator (authored 
by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D32864?vs=97829&id=97830#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32864

Files:
  cfe/trunk/lib/Format/FormatToken.h
  cfe/trunk/lib/Format/FormatTokenLexer.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp


Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -53,6 +53,8 @@
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
   TYPE(JsComputedPropertyName) \
+  TYPE(JsExponentiation) \
+  TYPE(JsExponentiationEqual) \
   TYPE(JsFatArrow) \
   TYPE(JsNonNullAssertion) \
   TYPE(JsTypeColon) \
Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,10 @@
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
 static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
+   tok::starequal};
+
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
   return;
@@ -83,6 +87,12 @@
   return;
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
+if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+  return;
+if (tryMergeTokens(JSExponentiationEqual, TT_JsExponentiationEqual)) {
+  Tokens.back()->Tok.setKind(tok::starequal);
+  return;
+}
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1786,5 +1786,11 @@
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
 }
+
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+  verifyFormat("squared **= 2;");
+}
+
 } // end namespace tooling
 } // end namespace clang


Index: cfe/trunk/lib/Format/FormatToken.h
===
--- cfe/trunk/lib/Format/FormatToken.h
+++ cfe/trunk/lib/Format/FormatToken.h
@@ -53,6 +53,8 @@
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
   TYPE(JsComputedPropertyName) \
+  TYPE(JsExponentiation) \
+  TYPE(JsExponentiationEqual) \
   TYPE(JsFatArrow) \
   TYPE(JsNonNullAssertion) \
   TYPE(JsTypeColon) \
Index: cfe/trunk/lib/Format/FormatTokenLexer.cpp
===
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp
@@ -74,6 +74,10 @@
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
 static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
+   tok::starequal};
+
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
   return;
@@ -83,6 +87,12 @@
   return;
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
+if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+  return;
+if (tryMergeTokens(JSExponentiationEqual, TT_JsExponentiationEqual)) {
+  Tokens.back()->Tok.setKind(tok::starequal);
+  return;
+}
   }
 
   if (Style.Language == FormatStyle::LK_Java) {
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1786,5 +1786,11 @@
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
 }
+
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+  verifyFormat("squared **= 2;");
+}
+
 } // end namespace tooling
 } // end namespace clang
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302156 - clang-format: [JS] exponentiation operator

2017-05-04 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Thu May  4 10:04:04 2017
New Revision: 302156

URL: http://llvm.org/viewvc/llvm-project?rev=302156&view=rev
Log:
clang-format: [JS] exponentiation operator

Summary: While its precedence should be higher than multiplicative, LLVM does 
not have a level for that, so for the time being just treat it as 
multiplicative.

Reviewers: djasper

Subscribers: cfe-commits, klimek

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

Modified:
cfe/trunk/lib/Format/FormatToken.h
cfe/trunk/lib/Format/FormatTokenLexer.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=302156&r1=302155&r2=302156&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Thu May  4 10:04:04 2017
@@ -53,6 +53,8 @@ namespace format {
   TYPE(InlineASMColon) \
   TYPE(JavaAnnotation) \
   TYPE(JsComputedPropertyName) \
+  TYPE(JsExponentiation) \
+  TYPE(JsExponentiationEqual) \
   TYPE(JsFatArrow) \
   TYPE(JsNonNullAssertion) \
   TYPE(JsTypeColon) \

Modified: cfe/trunk/lib/Format/FormatTokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatTokenLexer.cpp?rev=302156&r1=302155&r2=302156&view=diff
==
--- cfe/trunk/lib/Format/FormatTokenLexer.cpp (original)
+++ cfe/trunk/lib/Format/FormatTokenLexer.cpp Thu May  4 10:04:04 2017
@@ -74,6 +74,10 @@ void FormatTokenLexer::tryMergePreviousT
 static const tok::TokenKind JSShiftEqual[] = {tok::greater, tok::greater,
   tok::greaterequal};
 static const tok::TokenKind JSRightArrow[] = {tok::equal, tok::greater};
+static const tok::TokenKind JSExponentiation[] = {tok::star, tok::star};
+static const tok::TokenKind JSExponentiationEqual[] = {tok::star,
+   tok::starequal};
+
 // FIXME: Investigate what token type gives the correct operator priority.
 if (tryMergeTokens(JSIdentity, TT_BinaryOperator))
   return;
@@ -83,6 +87,12 @@ void FormatTokenLexer::tryMergePreviousT
   return;
 if (tryMergeTokens(JSRightArrow, TT_JsFatArrow))
   return;
+if (tryMergeTokens(JSExponentiation, TT_JsExponentiation))
+  return;
+if (tryMergeTokens(JSExponentiationEqual, TT_JsExponentiationEqual)) {
+  Tokens.back()->Tok.setKind(tok::starequal);
+  return;
+}
   }
 
   if (Style.Language == FormatStyle::LK_Java) {

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=302156&r1=302155&r2=302156&view=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Thu May  4 10:04:04 2017
@@ -1786,5 +1786,11 @@ TEST_F(FormatTestJS, ImportComments) {
getGoogleJSStyleWithColumns(25));
   verifyFormat("// taze: x from 'location'", getGoogleJSStyleWithColumns(10));
 }
+
+TEST_F(FormatTestJS, Exponentiation) {
+  verifyFormat("squared = x ** 2;");
+  verifyFormat("squared **= 2;");
+}
+
 } // end namespace tooling
 } // end namespace clang


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


[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target

2017-05-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Should we add a test to test/CodeGen/X86/constructor.ll   that test appears to 
have been modified when NAcl was added to the line you changed.


https://reviews.llvm.org/D32543



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


[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target

2017-05-04 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

It looksl ike UseInitArray is connected to -use-ctors command line option to 
llc so we should be able to test this without a frontend test.


https://reviews.llvm.org/D32543



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


[libcxx] r302158 - [test] variant: enable constexpr construction tests on MSVC STL

2017-05-04 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Thu May  4 10:32:54 2017
New Revision: 302158

URL: http://llvm.org/viewvc/llvm-project?rev=302158&view=rev
Log:
[test] variant: enable constexpr construction tests on MSVC STL

* Add a new macro _MSVC_STL_VER to detect when the MSVC STL is being tested
* Workaround C1XX __is_trivially_copyable bug

Added:

libcxx/trunk/test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
Modified:

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp

libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
libcxx/trunk/test/support/test_workarounds.h

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp?rev=302158&r1=302157&r2=302158&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
 Thu May  4 10:32:54 2017
@@ -21,6 +21,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct NonT {
   NonT(int v) : value(v) {}
@@ -137,14 +138,21 @@ constexpr bool test_constexpr_copy_ctor_
   auto v2 = v;
   return v2.index() == v.index() &&
  v2.index() == Idx &&
-std::get(v2) == std::get(v);
+ std::get(v2) == std::get(v);
 }
 
 void test_constexpr_copy_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
-  static_assert(std::is_trivially_copyable::value, "");
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
   static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
+  static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(test_constexpr_copy_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_copy_ctor_extension_imp<1>(V(nullptr)), "");
   static_assert(test_constexpr_copy_ctor_extension_imp<2>(V(101)), "");

Modified: 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp?rev=302158&r1=302157&r2=302158&view=diff
==
--- 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
 Thu May  4 10:32:54 2017
@@ -22,6 +22,7 @@
 #include 
 
 #include "test_macros.h"
+#include "test_workarounds.h"
 
 struct ThrowsMove {
   ThrowsMove(ThrowsMove &&) noexcept(false) {}
@@ -178,9 +179,17 @@ constexpr bool test_constexpr_ctor_exten
 }
 
 void test_constexpr_move_ctor_extension() {
-#ifdef _LIBCPP_VERSION
+#if defined(_LIBCPP_VER) || defined(_MSVC_STL_VER)
   using V = std::variant;
+#ifdef TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE
+  static_assert(std::is_trivially_destructible::value, "");
+  static_assert(std::is_trivially_copy_constructible::value, "");
+  static_assert(std::is_trivially_move_constructible::value, "");
+  static_assert(!std::is_copy_assignable::value, "");
+  static_assert(!std::is_move_assignable::value, "");
+#else
   static_assert(std::is_trivially_copyable::value, "");
+#endif
   static_assert(std::is_trivially_move_constructible::value, "");
   static_assert(test_constexpr_ctor_extension_imp<0>(V(42l)), "");
   static_assert(test_constexpr_ctor_extension_imp<1>(V(nullptr)), "");

Modified: libcxx/trunk/test/support/msvc_stdlib_force_include.hpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/msvc_stdlib_force_include.hpp?rev=302158&r1=302157&r2=302158&view=diff
==
--- libcxx/trunk/test/support/msvc_stdlib_force_include.hpp (original)
+++ libcxx/trunk/test/support/msvc_stdlib_force_include.hpp Thu May  4 10:32:54 
2017
@@ -26,6 +26,11 @@
 #error This header may not be used when targeting libc++
 #endif
 
+// Indicates that we are using the MSVC standard library.
+#ifndef _MSVC_STL_VER
+#define _MSVC_STL_VER 42
+#endif
+
 struct AssertionDialogAvoider {
 AssertionDialogAvoider() {
 _CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);

Added: 
libcxx/trunk/test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk

r302159 - [Tooling] add a createReplacement overload for StringRef

2017-05-04 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May  4 10:34:06 2017
New Revision: 302159

URL: http://llvm.org/viewvc/llvm-project?rev=302159&view=rev
Log:
[Tooling] add a createReplacement overload for StringRef

Modified:
cfe/trunk/include/clang/Tooling/FixIt.h

Modified: cfe/trunk/include/clang/Tooling/FixIt.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/FixIt.h?rev=302159&r1=302158&r2=302159&view=diff
==
--- cfe/trunk/include/clang/Tooling/FixIt.h (original)
+++ cfe/trunk/include/clang/Tooling/FixIt.h Thu May  4 10:34:06 2017
@@ -65,6 +65,13 @@ FixItHint createReplacement(const D &Des
   getText(Source, Context));
 }
 
+// \brief Returns a FixItHint to replace \p Destination by \p Source.
+template 
+FixItHint createReplacement(const D &Destination, StringRef Source) {
+  return FixItHint::CreateReplacement(internal::getSourceRange(Destination),
+  Source);
+}
+
 } // end namespace fixit
 } // end namespace tooling
 } // end namespace clang


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


[clang-tools-extra] r302160 - [clang-tidy] Code cleanup, (almost) NFC (*).

2017-05-04 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May  4 10:34:23 2017
New Revision: 302160

URL: http://llvm.org/viewvc/llvm-project?rev=302160&view=rev
Log:
[clang-tidy] Code cleanup, (almost) NFC (*).

(*) Printed types of member pointers don't use elaborated type specifiers
(`int struct S::*` -> `int S::*`).

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-allow-conditional-casts.cpp

clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast-cxx98.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=302160&r1=302159&r2=302160&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
Thu May  4 10:34:23 2017
@@ -11,6 +11,7 @@
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
+#include "clang/Tooling/FixIt.h"
 #include 
 
 using namespace clang::ast_matchers;
@@ -32,7 +33,7 @@ bool isNULLMacroExpansion(const Stmt *St
   const LangOptions &LO = Context.getLangOpts();
   SourceLocation Loc = Statement->getLocStart();
   return SM.isMacroBodyExpansion(Loc) &&
- clang::Lexer::getImmediateMacroName(Loc, SM, LO) == "NULL";
+ Lexer::getImmediateMacroName(Loc, SM, LO) == "NULL";
 }
 
 AST_MATCHER(Stmt, isNULLMacroExpansion) {
@@ -57,17 +58,15 @@ StatementMatcher createImplicitCastFromB
   hasSourceExpression(expr(hasType(qualType(booleanType());
 }
 
-StringRef
-getZeroLiteralToCompareWithForGivenType(CastKind CastExpressionKind,
-QualType CastSubExpressionType,
-ASTContext &Context) {
-  switch (CastExpressionKind) {
+StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
+ QualType Type,
+ ASTContext &Context) {
+  switch (CastExprKind) {
   case CK_IntegralToBoolean:
-return CastSubExpressionType->isUnsignedIntegerType() ? "0u" : "0";
+return Type->isUnsignedIntegerType() ? "0u" : "0";
 
   case CK_FloatingToBoolean:
-return Context.hasSameType(CastSubExpressionType, Context.FloatTy) ? "0.0f"
-   : "0.0";
+return Context.hasSameType(Type, Context.FloatTy) ? "0.0f" : "0.0";
 
   case CK_PointerToBoolean:
   case CK_MemberPointerToBoolean: // Fall-through on purpose.
@@ -79,10 +78,8 @@ getZeroLiteralToCompareWithForGivenType(
 }
 
 bool isUnaryLogicalNotOperator(const Stmt *Statement) {
-  const auto *UnaryOperatorExpression =
-  llvm::dyn_cast(Statement);
-  return UnaryOperatorExpression != nullptr &&
- UnaryOperatorExpression->getOpcode() == UO_LNot;
+  const auto *UnaryOperatorExpr = dyn_cast(Statement);
+  return UnaryOperatorExpr && UnaryOperatorExpr->getOpcode() == UO_LNot;
 }
 
 bool areParensNeededForOverloadedOperator(OverloadedOperatorKind OperatorKind) 
{
@@ -103,39 +100,35 @@ bool areParensNeededForOverloadedOperato
 }
 
 bool areParensNeededForStatement(const Stmt *Statement) {
-  if (const auto *OverloadedOperatorCall =
-  llvm::dyn_cast(Statement)) {
-return areParensNeededForOverloadedOperator(
-OverloadedOperatorCall->getOperator());
+  if (const auto *OperatorCall = dyn_cast(Statement)) {
+return areParensNeededForOverloadedOperator(OperatorCall->getOperator());
   }
 
-  return llvm::isa(Statement) ||
- llvm::isa(Statement);
+  return isa(Statement) || isa(Statement);
 }
 
-void addFixItHintsForGenericExpressionCastToBool(
-DiagnosticBuilder &Diagnostic, const ImplicitCastExpr *CastExpression,
-const Stmt *ParentStatement, ASTContext &Context) {
+void fixGenericExprCastToBool(DiagnosticBuilder &Diag,
+  const ImplicitCastExpr *Cast, const Stmt *Parent,
+  ASTContext &Context) {
   // In case of expressions like (! integer), we should remove the redundant 
not
   // operator and use inverted comparison (integer == 0).
   bool InvertComparison =
-  ParentStatement != nullptr && isUnaryLogicalNotOperator(ParentStatement);
+  Parent != nullptr && isUnaryLogicalNotOperator(Parent);
   if (InvertComparison) {
-SourceLocation ParentStartLoc = ParentStatement->getLocStart();
+SourceLocation ParentStartLoc = Parent->getLocStart();
 SourceLocation ParentEndLoc =
-
llvm::cast(ParentStatement)->getSubExpr()->getLocStart();
-Diagnostic.AddFixItHint(FixItHint::CreateRemoval(
-CharSourceR

cfe-commits@lists.llvm.org

2017-05-04 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May  4 10:34:31 2017
New Revision: 302161

URL: http://llvm.org/viewvc/llvm-project?rev=302161&view=rev
Log:
[clang-tidy] fix readability-implicit-bool-cast false alarm on |=, &=

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=302161&r1=302160&r2=302161&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
Thu May  4 10:34:31 2017
@@ -40,24 +40,6 @@ AST_MATCHER(Stmt, isNULLMacroExpansion)
   return isNULLMacroExpansion(&Node, Finder->getASTContext());
 }
 
-ast_matchers::internal::Matcher createExceptionCasesMatcher() {
-  return expr(anyOf(hasParent(explicitCastExpr()),
-allOf(isMacroExpansion(), unless(isNULLMacroExpansion())),
-isInTemplateInstantiation(),
-hasAncestor(functionTemplateDecl(;
-}
-
-StatementMatcher createImplicitCastFromBoolMatcher() {
-  return implicitCastExpr(
-  unless(createExceptionCasesMatcher()),
-  anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating),
-// Prior to C++11 cast from bool literal to pointer was allowed.
-allOf(anyOf(hasCastKind(CK_NullToPointer),
-hasCastKind(CK_NullToMemberPointer)),
-  hasSourceExpression(cxxBoolLiteral(,
-  hasSourceExpression(expr(hasType(qualType(booleanType());
-}
-
 StringRef getZeroLiteralToCompareWithForType(CastKind CastExprKind,
  QualType Type,
  ASTContext &Context) {
@@ -284,10 +266,15 @@ void ImplicitBoolCastCheck::registerMatc
 return;
   }
 
+  auto exceptionCases = expr(
+  anyOf(hasParent(explicitCastExpr()),
+allOf(isMacroExpansion(), unless(isNULLMacroExpansion())),
+isInTemplateInstantiation(), hasAncestor(functionTemplateDecl(;
+
   Finder->addMatcher(
   implicitCastExpr(
   // Exclude cases common to implicit cast to and from bool.
-  unless(createExceptionCasesMatcher()),
+  unless(exceptionCases),
   // Exclude case of using if or while statements with variable
   // declaration, e.g.:
   //   if (int var = functionCall()) {}
@@ -303,17 +290,30 @@ void ImplicitBoolCastCheck::registerMatc
   .bind("implicitCastToBool"),
   this);
 
+  auto implicitCastFromBool = implicitCastExpr(
+  unless(exceptionCases),
+  anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating),
+// Prior to C++11 cast from bool literal to pointer was allowed.
+allOf(anyOf(hasCastKind(CK_NullToPointer),
+hasCastKind(CK_NullToMemberPointer)),
+  hasSourceExpression(cxxBoolLiteral(,
+  hasSourceExpression(expr(hasType(booleanType();
+
+  auto boolComparison = binaryOperator(
+  anyOf(hasOperatorName("=="), hasOperatorName("!=")),
+  hasLHS(implicitCastFromBool), hasRHS(implicitCastFromBool));
+  auto boolOpAssignment = binaryOperator(
+  anyOf(hasOperatorName("|="), hasOperatorName("&=")),
+  hasLHS(expr(hasType(booleanType(, hasRHS(implicitCastFromBool));
   Finder->addMatcher(
   implicitCastExpr(
-  createImplicitCastFromBoolMatcher(),
+  implicitCastFromBool,
   // Exclude comparisons of bools, as they are always cast to integers
   // in such context:
   //   bool_expr_a == bool_expr_b
   //   bool_expr_a != bool_expr_b
-  unless(hasParent(binaryOperator(
-  anyOf(hasOperatorName("=="), hasOperatorName("!=")),
-  hasLHS(createImplicitCastFromBoolMatcher()),
-  hasRHS(createImplicitCastFromBoolMatcher(),
+  unless(hasParent(
+  binaryOperator(anyOf(boolComparison, boolOpAssignment,
   // Check also for nested casts, for example: bool -> int -> float.
   anyOf(hasParent(implicitCastExpr().bind("furtherImplicitCast")),
 anything()))

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=302161&r1=302160&r2=302161&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-imp

[PATCH] D32671: [libcxx] [test] variant: test coverage for P0602 extension

2017-05-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter updated this revision to Diff 97834.
CaseyCarter added a comment.

The constexpr variant tests were enabled separate commit 
(https://reviews.llvm.org/rL302158). This differential now contains only the 
fine-grained SMF triviality extension test.


https://reviews.llvm.org/D32671

Files:
  test/std/utilities/variant/variant.variant/variant.assign/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
  test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp

Index: test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/move.pass.cpp
@@ -197,10 +197,30 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_move_constructible>::value ==
+std::conjunction...>::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_move_ctor_basic();
   test_move_ctor_valueless_by_exception();
   test_move_noexcept();
   test_move_ctor_sfinae();
   test_constexpr_move_ctor_extension();
+  test_triviality_extension();
 }
Index: test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.ctor/copy.pass.cpp
@@ -159,9 +159,27 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  std::is_trivially_copy_constructible>::value ==
+std::conjunction...>::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+#endif
+}
+
 int main() {
   test_copy_ctor_basic();
   test_copy_ctor_valueless_by_exception();
   test_copy_ctor_sfinae();
   test_constexpr_copy_ctor_extension();
+  test_triviality_extension();
 }
Index: test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
===
--- test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
+++ test/std/utilities/variant/variant.variant/variant.assign/move.pass.cpp
@@ -308,12 +308,63 @@
 #endif
 }
 
+template
+constexpr bool triviality_test =
+  // move assignment of variant is trivial when
+  std::is_trivially_move_assignable>::value ==
+std::conjunction<
+  // All Ts are trivially destructible and
+  std::is_trivially_destructible...,
+  // either
+  std::disjunction<
+// All Ts are trivially move (constructible and assignable) so that
+// variant's move assignment operator is non-deleted and trivial, or
+std::conjunction<
+  std::is_trivially_move_constructible...,
+  std::is_trivially_move_assignable...>,
+// At least one of the Ts is not move (constructible or assignable) so
+// that variant's move assignment operator is *implicitly* deleted but
+// all of the Ts are trivially *copy* (constructible and assignable) so
+// that move assignment actually invokes the trivial copy assignment
+// operator.
+std::conjunction<
+  std::disjunction<
+std::negation>...,
+std::negation>...>,
+  std::is_trivially_copy_constructible...,
+  std::is_trivially_copy_assignable...>>>::value;
+
+void test_triviality_extension() {
+#if defined(_MSVC_STL_VER)
+  struct TrivialCopyNontrivialMove {
+TrivialCopyNontrivialMove(TrivialCopyNontrivialMove const&) = default;
+TrivialCopyNontrivialMove(TrivialCopyNontrivialMove&&) noexcept {}
+TrivialCopyNontrivialMove& operator=(TrivialCopyNontrivialMove const&) = default;
+TrivialCopyNontrivialMove& operator=(TrivialCopyNontrivialMove&&) noexcept {
+  return *this;
+}
+  };
+
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_assert(triviality_test, "");
+  static_as

[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-05-04 Thread Casey Carter via Phabricator via cfe-commits
CaseyCarter added a comment.

In https://reviews.llvm.org/D32385#745771, @EricWF wrote:

> So Itanium ABI has this quirk where trivial types are passed using different 
> conventions than non-trivial types. This means changing the triviality of 
> `std::optional` for any instantiation is potentially ABI breaking. I'll need 
> to do more investigation to find out how this will affect libc++, and if we 
> can take this change.


libc++ committed to ABI stability for `optional`, a new feature of C++17, 
before the standard shipped?


https://reviews.llvm.org/D32385



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


[libcxx] r302162 - [test] Name the local variable in the C1XX implementation of DoNotOptmize

2017-05-04 Thread Casey Carter via cfe-commits
Author: caseycarter
Date: Thu May  4 10:54:09 2017
New Revision: 302162

URL: http://llvm.org/viewvc/llvm-project?rev=302162&view=rev
Log:
[test] Name the local variable in the C1XX implementation of DoNotOptmize

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

Modified:
libcxx/trunk/test/support/test_macros.h

Modified: libcxx/trunk/test/support/test_macros.h
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test_macros.h?rev=302162&r1=302161&r2=302162&view=diff
==
--- libcxx/trunk/test/support/test_macros.h (original)
+++ libcxx/trunk/test/support/test_macros.h Thu May  4 10:54:09 2017
@@ -209,7 +209,8 @@ inline void DoNotOptimize(Tp const& valu
 #include 
 template 
 inline void DoNotOptimize(Tp const& value) {
-  const volatile void* volatile = __builtin_addressof(value);
+  const volatile void* volatile unused = __builtin_addressof(value);
+  static_cast(unused);
   _ReadWriteBarrier();
 }
 #endif


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


[PATCH] D32510: [libcxx] Fix C1XX implementation of DoNotOptimize

2017-05-04 Thread Casey Carter via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302162: [test] Name the local variable in the C1XX 
implementation of DoNotOptmize (authored by CaseyCarter).

Changed prior to commit:
  https://reviews.llvm.org/D32510?vs=96648&id=97837#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32510

Files:
  libcxx/trunk/test/support/test_macros.h


Index: libcxx/trunk/test/support/test_macros.h
===
--- libcxx/trunk/test/support/test_macros.h
+++ libcxx/trunk/test/support/test_macros.h
@@ -209,7 +209,8 @@
 #include 
 template 
 inline void DoNotOptimize(Tp const& value) {
-  const volatile void* volatile = __builtin_addressof(value);
+  const volatile void* volatile unused = __builtin_addressof(value);
+  static_cast(unused);
   _ReadWriteBarrier();
 }
 #endif


Index: libcxx/trunk/test/support/test_macros.h
===
--- libcxx/trunk/test/support/test_macros.h
+++ libcxx/trunk/test/support/test_macros.h
@@ -209,7 +209,8 @@
 #include 
 template 
 inline void DoNotOptimize(Tp const& value) {
-  const volatile void* volatile = __builtin_addressof(value);
+  const volatile void* volatile unused = __builtin_addressof(value);
+  static_cast(unused);
   _ReadWriteBarrier();
 }
 #endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r302164 - [clang-tidy] fix readability-implicit-bool-cast false positive with xor

2017-05-04 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Thu May  4 11:06:08 2017
New Revision: 302164

URL: http://llvm.org/viewvc/llvm-project?rev=302164&view=rev
Log:
[clang-tidy] fix readability-implicit-bool-cast false positive with xor

Modified:
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp?rev=302164&r1=302163&r2=302164&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/readability/ImplicitBoolCastCheck.cpp 
Thu May  4 11:06:08 2017
@@ -270,11 +270,22 @@ void ImplicitBoolCastCheck::registerMatc
   anyOf(hasParent(explicitCastExpr()),
 allOf(isMacroExpansion(), unless(isNULLMacroExpansion())),
 isInTemplateInstantiation(), hasAncestor(functionTemplateDecl(;
-
+  auto implicitCastFromBool = implicitCastExpr(
+  unless(exceptionCases),
+  anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating),
+// Prior to C++11 cast from bool literal to pointer was allowed.
+allOf(anyOf(hasCastKind(CK_NullToPointer),
+hasCastKind(CK_NullToMemberPointer)),
+  hasSourceExpression(cxxBoolLiteral(,
+  hasSourceExpression(expr(hasType(booleanType();
+  auto boolXor =
+  binaryOperator(hasOperatorName("^"), hasLHS(implicitCastFromBool),
+ hasRHS(implicitCastFromBool));
   Finder->addMatcher(
   implicitCastExpr(
   // Exclude cases common to implicit cast to and from bool.
   unless(exceptionCases),
+  unless(has(boolXor)),
   // Exclude case of using if or while statements with variable
   // declaration, e.g.:
   //   if (int var = functionCall()) {}
@@ -290,21 +301,12 @@ void ImplicitBoolCastCheck::registerMatc
   .bind("implicitCastToBool"),
   this);
 
-  auto implicitCastFromBool = implicitCastExpr(
-  unless(exceptionCases),
-  anyOf(hasCastKind(CK_IntegralCast), hasCastKind(CK_IntegralToFloating),
-// Prior to C++11 cast from bool literal to pointer was allowed.
-allOf(anyOf(hasCastKind(CK_NullToPointer),
-hasCastKind(CK_NullToMemberPointer)),
-  hasSourceExpression(cxxBoolLiteral(,
-  hasSourceExpression(expr(hasType(booleanType();
-
   auto boolComparison = binaryOperator(
   anyOf(hasOperatorName("=="), hasOperatorName("!=")),
   hasLHS(implicitCastFromBool), hasRHS(implicitCastFromBool));
-  auto boolOpAssignment = binaryOperator(
-  anyOf(hasOperatorName("|="), hasOperatorName("&=")),
-  hasLHS(expr(hasType(booleanType(, hasRHS(implicitCastFromBool));
+  auto boolOpAssignment =
+  binaryOperator(anyOf(hasOperatorName("|="), hasOperatorName("&=")),
+ hasLHS(expr(hasType(booleanType();
   Finder->addMatcher(
   implicitCastExpr(
   implicitCastFromBool,
@@ -312,8 +314,8 @@ void ImplicitBoolCastCheck::registerMatc
   // in such context:
   //   bool_expr_a == bool_expr_b
   //   bool_expr_a != bool_expr_b
-  unless(hasParent(
-  binaryOperator(anyOf(boolComparison, boolOpAssignment,
+  unless(hasParent(binaryOperator(
+  anyOf(boolComparison, boolXor, boolOpAssignment,
   // Check also for nested casts, for example: bool -> int -> float.
   anyOf(hasParent(implicitCastExpr().bind("furtherImplicitCast")),
 anything()))

Modified: 
clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp?rev=302164&r1=302163&r2=302164&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-implicit-bool-cast.cpp 
Thu May  4 11:06:08 2017
@@ -50,9 +50,12 @@ float implicitCastFromBoolInReturnValue(
 
 void implicitCastFromBoolInSingleBoolExpressions(bool b1, bool b2) {
   bool boolean = true;
+  boolean = b1 ^ b2;
   boolean = b1 && b2;
   boolean |= !b1 || !b2;
   boolean &= b1;
+  boolean = b1 == true;
+  boolean = b2 != false;
 
   int integer = boolean - 3;
   // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: implicit cast bool -> 'int'


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


[PATCH] D32424: Add a fix-it for -Wunguarded-availability

2017-05-04 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington added a comment.

Hi Alex, thanks for working on this! This looks right, but I have a couple of 
comments.
Thanks,
Erik




Comment at: lib/Sema/SemaDeclAttr.cpp:7151
+Visitor.Scope = Scope;
+Visitor.TraverseStmt(const_cast(Scope));
+return Visitor.LastMatchingDREFirstNonScopeStmt;

I think this could be simplified: If we iterate backwards through the 
CompoundStmt::body(), calling `RecursiveASTVisitor::TraverseStmt()`, and bail 
out if we encounter a `DeclRefExpr` to D, returning the current Stmt. This also 
has the advantage that we don't have to iterate forward through the 
CompoundStmt when we're looking for the last Child Stmt. Have you considered 
this option?



Comment at: lib/Sema/SemaDeclAttr.cpp:7249
+auto FixitDiag =
+SemaRef.Diag(Range.getBegin(), diag::note_unguarded_available_silence)
 << Range << D;

Since we emit a fixit to use `__builtin_available` in non objective-c modes, 
this diagnostic should take another argument to suggest using the right form of 
@available depending on the source language. (Currently it's hard-coded to 
suggest @available).


Repository:
  rL LLVM

https://reviews.llvm.org/D32424



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


[PATCH] D32385: [libcxx] optional: Implement LWG 2900 and P0602

2017-05-04 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

> libc++ committed to ABI stability for optional, a new feature of C++17, 
> before the standard shipped?

Libc++ doesn't commit to anything, the vendors such as Apple and FreeBSD do. I 
don't think either of them
have shipped a release with std::optional yet, but I need to be sure they don't 
have ABI obligations before I break it.

I certainly agree that nobody should be expecting ABI stability for features 
not yet standardized, and I should
take steps to ensure vendors understand that.


https://reviews.llvm.org/D32385



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


[libcxx] r302168 - Use lgamma_r instead of lgamma in binomial_distribution, because freakin' POSIX took a perfectly fine call and made it not thread safe.

2017-05-04 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Thu May  4 11:36:39 2017
New Revision: 302168

URL: http://llvm.org/viewvc/llvm-project?rev=302168&view=rev
Log:
Use lgamma_r instead of lgamma in binomial_distribution, because freakin' POSIX 
took a perfectly fine call and made it not thread safe.


Modified:
libcxx/trunk/include/random

Modified: libcxx/trunk/include/random
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=302168&r1=302167&r2=302168&view=diff
==
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Thu May  4 11:36:39 2017
@@ -3997,16 +3997,20 @@ public:
 {return !(__x == __y);}
 };
 
+extern "C" double lgamma_r(double, int *);
+
 template
-binomial_distribution<_IntType>::param_type::param_type(result_type __t, 
double __p)
+binomial_distribution<_IntType>::param_type::param_type(const result_type __t, 
const double __p)
 : __t_(__t), __p_(__p)
 {
 if (0 < __p_ && __p_ < 1)
 {
+   int __sign;
 __r0_ = static_cast((__t_ + 1) * __p_);
-__pr_ = _VSTD::exp(_VSTD::lgamma(__t_ + 1.) - _VSTD::lgamma(__r0_ + 
1.) -
-  _VSTD::lgamma(__t_ - __r0_ + 1.) + __r0_ * 
_VSTD::log(__p_) +
-  (__t_ - __r0_) * _VSTD::log(1 - __p_));
+__pr_ = _VSTD::exp(lgamma_r(__t_ + 1., &__sign) - 
+   lgamma_r(__r0_ + 1., &__sign) -
+   lgamma_r(__t_ - __r0_ + 1., &__sign) + __r0_ * 
_VSTD::log(__p_) +
+   (__t_ - __r0_) * _VSTD::log(1 - __p_));
 __odds_ratio_ = __p_ / (1 - __p_);
 }
 }


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


[PATCH] D29647: [OpenMP] Extend CLANG target options with device offloading kind.

2017-05-04 Thread Jonas Hahnfeld via Phabricator via cfe-commits
Hahnfeld added a comment.

One minor drive-by comment. I think there is still one outstanding from 
Justin...




Comment at: lib/Driver/ToolChains/Cuda.cpp:368
+  assert(!GpuArch.empty() && "Must have an explicit GPU arch.");
+  std::string LibDeviceFile;
 

You can move the declaration down to the initialization


Repository:
  rL LLVM

https://reviews.llvm.org/D29647



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


r302176 - Re-apply r302108, "IR: Use pointers instead of GUIDs to represent edges in the module summary. NFCI."

2017-05-04 Thread Peter Collingbourne via cfe-commits
Author: pcc
Date: Thu May  4 13:03:25 2017
New Revision: 302176

URL: http://llvm.org/viewvc/llvm-project?rev=302176&view=rev
Log:
Re-apply r302108, "IR: Use pointers instead of GUIDs to represent edges in the 
module summary. NFCI."
with a fix for the clang backend.

Modified:
cfe/trunk/lib/CodeGen/BackendUtil.cpp
cfe/trunk/test/CodeGen/thinlto_backend.ll

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=302176&r1=302175&r2=302176&view=diff
==
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Thu May  4 13:03:25 2017
@@ -974,10 +974,14 @@ static void runThinLTOBackend(ModuleSumm
   // via a WriteIndexesThinBackend.
   FunctionImporter::ImportMapTy ImportList;
   for (auto &GlobalList : *CombinedIndex) {
+// Ignore entries for undefined references.
+if (GlobalList.second.SummaryList.empty())
+  continue;
+
 auto GUID = GlobalList.first;
-assert(GlobalList.second.size() == 1 &&
+assert(GlobalList.second.SummaryList.size() == 1 &&
"Expected individual combined index to have one summary per GUID");
-auto &Summary = GlobalList.second[0];
+auto &Summary = GlobalList.second.SummaryList[0];
 // Skip the summaries for the importing module. These are included to
 // e.g. record required linkage changes.
 if (Summary->modulePath() == M->getModuleIdentifier())

Modified: cfe/trunk/test/CodeGen/thinlto_backend.ll
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/thinlto_backend.ll?rev=302176&r1=302175&r2=302176&view=diff
==
--- cfe/trunk/test/CodeGen/thinlto_backend.ll (original)
+++ cfe/trunk/test/CodeGen/thinlto_backend.ll Thu May  4 13:03:25 2017
@@ -35,8 +35,12 @@ target datalayout = "e-m:e-i64:64-f80:12
 target triple = "x86_64-unknown-linux-gnu"
 
 declare void @f2()
+declare i8* @f3()
 
 define void @f1() {
   call void @f2()
+  ; Make sure that the backend can handle undefined references.
+  ; Do an indirect call so that the undefined ref shows up in the combined 
index.
+  call void bitcast (i8*()* @f3 to void()*)()
   ret void
 }


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


r302179 - [ms-inline-asm] Use the frontend size only for ambiguous instructions

2017-05-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu May  4 13:19:52 2017
New Revision: 302179

URL: http://llvm.org/viewvc/llvm-project?rev=302179&view=rev
Log:
[ms-inline-asm] Use the frontend size only for ambiguous instructions

This avoids problems on code like this:
  char buf[16];
  __asm {
movups xmm0, [buf]
mov [buf], eax
  }

The frontend size in this case (1) is wrong, and the register makes the
instruction matching unambiguous. There are also enough bytes available
that we shouldn't complain to the user that they are potentially using
an incorrectly sized instruction to access the variable.

Supersedes D32636 and D26586 and fixes PR28266

Modified:
cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
cfe/trunk/test/CodeGen/ms-inline-asm-64.c
cfe/trunk/test/CodeGen/ms-inline-asm-avx512.c
cfe/trunk/test/CodeGen/ms-inline-asm.c
cfe/trunk/test/CodeGen/ms-inline-asm.cpp
cfe/trunk/test/CodeGenCXX/ms-inline-asm-fields.cpp

Modified: cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c?rev=302179&r1=302178&r2=302179&view=diff
==
--- cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c (original)
+++ cfe/trunk/test/CodeGen/mozilla-ms-inline-asm.c Thu May  4 13:19:52 2017
@@ -18,25 +18,25 @@ void invoke(void* that, unsigned methodI
 // CHECK: store i32 %2, i32* %7, align 4
 // CHECK: store i8* %3, i8** %8, align 4
 // CHECK: call void asm sideeffect inteldialect
-// CHECK: mov edx,dword ptr $1
-// CHECK: test edx,edx
-// CHECK: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams
-// ^ Can't use {{.*}} here because the matching is greedy.
-// CHECK: mov eax,edx
-// CHECK: shl eax,$$3
-// CHECK: sub esp,eax
-// CHECK: mov ecx,esp
-// CHECK: push dword ptr $0
-// CHECK: call dword ptr $2
-// CHECK: {{.*}}__MSASMLABEL_.${:uid}__noparams:
-// CHECK: mov ecx,dword ptr $3
-// CHECK: push ecx
-// CHECK: mov edx,[ecx]
-// CHECK: mov eax,dword ptr $4
-// CHECK: call dword ptr[edx+eax*$$4]
-// CHECK: mov esp,ebp
-// CHECK: pop ebp
-// CHECK: ret
+// CHECK-SAME: mov edx,$1
+// CHECK-SAME: test edx,edx
+// CHECK-SAME: jz {{[^_]*}}__MSASMLABEL_.${:uid}__noparams
+//^ Can't use {{.*}} here because the matching is greedy.
+// CHECK-SAME: mov eax,edx
+// CHECK-SAME: shl eax,$$3
+// CHECK-SAME: sub esp,eax
+// CHECK-SAME: mov ecx,esp
+// CHECK-SAME: push $0
+// CHECK-SAME: call dword ptr $2
+// CHECK-SAME: {{.*}}__MSASMLABEL_.${:uid}__noparams:
+// CHECK-SAME: mov ecx,$3
+// CHECK-SAME: push ecx
+// CHECK-SAME: mov edx,[ecx]
+// CHECK-SAME: mov eax,$4
+// CHECK-SAME: call dword ptr[edx+eax*$$4]
+// CHECK-SAME: mov esp,ebp
+// CHECK-SAME: pop ebp
+// CHECK-SAME: ret
 // CHECK: 
"=*m,*m,*m,*m,*m,~{eax},~{ebp},~{ecx},~{edx},~{flags},~{esp},~{dirflag},~{fpsr},~{flags}"
 // CHECK: (i8** %8, i32* %7, void (...)* bitcast (void ()* 
@invoke_copy_to_stack to void (...)*), i8** %5, i32* %6)
 // CHECK: ret void

Modified: cfe/trunk/test/CodeGen/ms-inline-asm-64.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/ms-inline-asm-64.c?rev=302179&r1=302178&r2=302179&view=diff
==
--- cfe/trunk/test/CodeGen/ms-inline-asm-64.c (original)
+++ cfe/trunk/test/CodeGen/ms-inline-asm-64.c Thu May  4 13:19:52 2017
@@ -5,14 +5,18 @@ void t1() {
   int var = 10;
   __asm mov rax, offset var ; rax = address of myvar
 // CHECK: t1
-// CHECK: call void asm sideeffect inteldialect "mov rax, $0", 
"r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect
+// CHECK-SAME: mov rax, $0
+// CHECK-SAME: "r,~{rax},~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
 }
 
 void t2() {
   int var = 10;
   __asm mov [eax], offset var
 // CHECK: t2
-// CHECK: call void asm sideeffect inteldialect "mov [eax], $0", 
"r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect
+// CHECK-SAME: mov [eax], $0
+// CHECK-SAME: "r,~{dirflag},~{fpsr},~{flags}"(i32* %{{.*}})
 }
 
 struct t3_type { int a, b; };
@@ -28,7 +32,11 @@ int t3() {
   }
   return foo.b;
 // CHECK: t3
-// CHECK: call void asm sideeffect inteldialect "lea ebx, qword ptr 
$0\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", 
"*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect
+// CHECK-SAME: lea ebx, $0
+// CHECK-SAME: mov eax, [ebx].0
+// CHECK-SAME: mov [ebx].4, ecx
+// CHECK-SAME: "*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* 
%{{.*}})
 }
 
 int t4() {
@@ -44,5 +52,9 @@ int t4() {
   }
   return foo.b;
 // CHECK: t4
-// CHECK: call void asm sideeffect inteldialect "lea ebx, qword ptr 
$0\0A\09mov eax, [ebx].0\0A\09mov [ebx].4, ecx", 
"*m,~{eax},~{ebx},~{dirflag},~{fpsr},~{flags}"(%struct.t3_type* %{{.*}})
+// CHECK: call void asm sideeffect inteldialect
+// CHECK-SAME: lea ebx, $0
+// CHECK-SAME: m

[PATCH] D19201: [clang-tidy] misc-throw-with-noexcept

2017-05-04 Thread Stanisław Barzowski via Phabricator via cfe-commits
sbarzowski updated this revision to Diff 97859.
sbarzowski added a comment.
Herald added a subscriber: xazax.hun.

Fixed false positive issues


https://reviews.llvm.org/D19201

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/ThrowWithNoexceptCheck.cpp
  clang-tidy/misc/ThrowWithNoexceptCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-throw-with-noexcept.rst
  test/clang-tidy/misc-throw-with-noexcept.cpp

Index: test/clang-tidy/misc-throw-with-noexcept.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-throw-with-noexcept.cpp
@@ -0,0 +1,191 @@
+// RUN: %check_clang_tidy %s misc-throw-with-noexcept %t
+
+void f_throw_with_ne() noexcept(true) {
+  {
+throw 5;
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-6]]:24: note: in a function declared no-throw here:
+// CHECK-FIXES: void f_throw_with_ne() {
+
+void f_noexcept_false() noexcept(false) {
+  throw 5;
+}
+
+void f_decl_only() noexcept;
+
+
+void throw_and_catch() noexcept(true) {
+  try {
+throw 5;
+  } catch (...) {
+  }
+}
+
+struct A{};
+struct B{};
+
+void throw_and_catch_something_else() noexcept(true) {
+  try {
+throw A();
+  } catch (B b) {
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-7]]:39: note: in a function declared no-throw here:
+// CHECK-FIXES: void throw_and_catch_something_else() {
+
+
+void throw_and_catch_the_same_thing() noexcept {
+  try {
+throw A();
+  } catch (A a) {
+  }
+}
+
+
+void throw_and_catch_int() noexcept {
+  try {
+throw 42;
+  } catch (int a) {
+  }
+}
+
+
+void throw_and_catch_() noexcept {
+  try {
+throw 42;
+  } catch (int a) {
+  }
+}
+
+
+void throw_and_catch_pointer() noexcept {
+  try {
+throw A();
+  } catch (A *a) {
+  }
+}
+
+class Base{};
+class Derived: public Base {};
+
+void throw_and_catch_base_class() noexcept {
+  try {
+throw Derived();
+  } catch (Base &x) {
+  }
+}
+
+void throw_and_catch_derived_class() noexcept {
+  try {
+throw Base();
+  } catch (Derived &x) {
+  }
+}
+// CHECK-MESSAGES: :[[@LINE-4]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-7]]:38: note: in a function declared no-throw here:
+// CHECK-FIXES: void throw_and_catch_derived_class() {
+
+
+class Class {
+  void InClass() const noexcept(true) {
+throw 42;
+  }
+};
+// CHECK-MESSAGES: :[[@LINE-3]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-5]]:24: note: in a function declared no-throw here:
+// CHECK-FIXES: void InClass() const {
+
+
+void forward_declared() noexcept;
+
+void forward_declared() noexcept {
+	throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:2: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:25: note: in a function declared no-throw here:
+// CHECK-MESSAGES: :[[@LINE-7]]:25: note: in a function declared no-throw here:
+// CHECK-FIXES: void forward_declared() ;
+// CHECK-FIXES: void forward_declared() {
+
+void getFunction() noexcept {
+  struct X {
+static void inner()
+{
+throw 42;
+}
+  };
+}
+
+void dynamic_exception_spec() throw() {
+  throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:31: note: in a function declared no-throw here:
+// CHECK-FIXES: void dynamic_exception_spec() {
+
+#define NOEXCEPT noexcept
+
+void with_macro() NOEXCEPT {
+  throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:19: note: in a function declared no-throw here:
+// CHECK-FIXES: void with_macro() {
+
+template int template_function() noexcept {
+  throw 42;
+}
+// CHECK-MESSAGES: :[[@LINE-2]]:3: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+// CHECK-MESSAGES: :[[@LINE-4]]:46: note: in a function declared no-throw here:
+// CHECK-FIXES: template int template_function() {
+
+template class template_class {
+  int throw_in_member() noexcept {
+throw 42;
+  }
+  // CHECK-MESSAGES: :[[@LINE-2]]:5: warning: 'throw' expression in a function declared with a non-throwing exception specification [misc-throw-with-noexcept]
+  // CHECK-MESSAGES: :

[PATCH] D31370: [clang-tidy] Prototype to check for exception specification

2017-05-04 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

this check is somewhat duplicated to a check currently in review, which seemed 
to be abondened?

https://reviews.llvm.org/D19201

I will read that one first and try to coordinate with the author.


Repository:
  rL LLVM

https://reviews.llvm.org/D31370



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


[libcxx] r302181 - Change Appveyor to download Clang from llvm.org instead of my private server

2017-05-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May  4 14:04:50 2017
New Revision: 302181

URL: http://llvm.org/viewvc/llvm-project?rev=302181&view=rev
Log:
Change Appveyor to download Clang from llvm.org instead of my private server

Modified:
libcxx/trunk/appveyor.yml
libcxx/trunk/install-appveyor-reqs.cmd

Modified: libcxx/trunk/appveyor.yml
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/appveyor.yml?rev=302181&r1=302180&r2=302181&view=diff
==
--- libcxx/trunk/appveyor.yml (original)
+++ libcxx/trunk/appveyor.yml Thu May  4 14:04:50 2017
@@ -65,4 +65,4 @@ artifacts:
 cache:
  - C:\projects\deps\ninja
  - C:\projects\deps\cmake
- - C:\projects\deps\llvm
+ - C:\projects\deps\llvm-installer.exe

Modified: libcxx/trunk/install-appveyor-reqs.cmd
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/install-appveyor-reqs.cmd?rev=302181&r1=302180&r2=302181&view=diff
==
--- libcxx/trunk/install-appveyor-reqs.cmd (original)
+++ libcxx/trunk/install-appveyor-reqs.cmd Thu May  4 14:04:50 2017
@@ -7,11 +7,11 @@ cd C:\projects\deps
 ::###
 :: Setup the path to Clang-cl
 ::###
+if NOT EXIST llvm-installer.exe (
+  appveyor DownloadFile 
http://llvm.org/pre-releases/win-snapshots/LLVM-5.0.0-r301646-win32.exe 
-FileName llvm-installer.exe
+)
 if "%CLANG_VERSION%"=="ToT" (
-appveyor DownloadFile http://efcs.ca/downloads/llvm-tot-win32.zip 
-FileName llvm-package.zip
-move "C:\Program Files\LLVM" "C:\Program Files\LLVM_BAK"
-7z x llvm-package.zip -o"C:\Program Files\LLVM" > nul
-rm llvm-package.zip
+START /WAIT llvm-installer.exe /S /D=C:\"Program Files\LLVM"
 )
 @set PATH="C:\Program Files\LLVM\bin";%PATH%
 clang-cl -v
@@ -42,10 +42,6 @@ ninja --version
 ::###
 :: Setup the cached copy of LLVM
 ::###
-if NOT EXIST llvm (
-  git clone --depth=1 http://llvm.org/git/llvm.git
-) ELSE (
-  git -C llvm pull --rebase=true --ff-only
-)
+git clone --depth=1 http://llvm.org/git/llvm.git
 
 @echo off


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


[libcxx] r302182 - Fix test failure with GCC 4.9

2017-05-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu May  4 14:13:28 2017
New Revision: 302182

URL: http://llvm.org/viewvc/llvm-project?rev=302182&view=rev
Log:
Fix test failure with GCC 4.9

Modified:

libcxx/trunk/test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp

Modified: 
libcxx/trunk/test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp?rev=302182&r1=302181&r2=302182&view=diff
==
--- 
libcxx/trunk/test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
 (original)
+++ 
libcxx/trunk/test/support/test.workarounds/c1xx_broken_is_trivially_copyable.pass.cpp
 Thu May  4 14:13:28 2017
@@ -9,6 +9,10 @@
 
 // UNSUPPORTED: c++98, c++03
 
+// This workaround option is specific to MSVC's C1XX, so we don't care that
+// it isn't set for older GCC versions.
+// XFAIL: gcc-4.9
+
 // Verify TEST_WORKAROUND_C1XX_BROKEN_IS_TRIVIALLY_COPYABLE.
 
 #include 


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


r302184 - Driver: only inject libstdc++ paths when needed on CrossWindows

2017-05-04 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Thu May  4 14:18:21 2017
New Revision: 302184

URL: http://llvm.org/viewvc/llvm-project?rev=302184&view=rev
Log:
Driver: only inject libstdc++ paths when needed on CrossWindows

When building with libc++ don't bother with injecting the libstdc++
search paths into the linker search path.  This will make it easier to
switch between ld and lld.

Modified:
cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
cfe/trunk/test/Driver/windows-cross.c

Modified: cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp?rev=302184&r1=302183&r2=302184&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/CrossWindows.cpp Thu May  4 14:18:21 2017
@@ -204,7 +204,7 @@ CrossWindowsToolChain::CrossWindowsToolC
  const llvm::Triple &T,
  const llvm::opt::ArgList &Args)
 : Generic_GCC(D, T, Args) {
-  if (GetCXXStdlibType(Args) == ToolChain::CST_Libstdcxx) {
+  if (D.CCCIsCXX() && GetCXXStdlibType(Args) == ToolChain::CST_Libstdcxx) {
 const std::string &SysRoot = D.SysRoot;
 
 // libstdc++ resides in /usr/lib, but depends on libgcc which is placed in

Modified: cfe/trunk/test/Driver/windows-cross.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/windows-cross.c?rev=302184&r1=302183&r2=302184&view=diff
==
--- cfe/trunk/test/Driver/windows-cross.c (original)
+++ cfe/trunk/test/Driver/windows-cross.c Thu May  4 14:18:21 2017
@@ -1,12 +1,17 @@
-// RUN: %clang -### -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld 
-stdlib=libstdc++ -rtlib=platform -o /dev/null %s 2>&1 \
-// RUN:   | FileCheck %s --check-prefix CHECK-BASIC
+// RUN: %clang -### --driver-mode=g++ -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld 
-stdlib=libstdc++ -rtlib=platform -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-BASIC-LIBSTDCXX
 
-// CHECK-BASIC: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" "-lgcc" 
"--as-needed" "-lgcc_s" "--no-as-needed"
+// CHECK-BASIC-LIBSTDCXX: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lstdc++" "-lmingw32" 
"-lmingwex" "-lgcc" "-lmoldname" "-lmingw32" "-lmsvcrt" "-lgcc_s" "-lgcc"
+
+// RUN: %clang -### -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld 
-stdlib=libstdc++ -rtlib=compiler-rt -o /dev/null %s 2>&1 \
+// RUN:   | FileCheck %s --check-prefix CHECK-BASIC-LIBCXX
+
+// CHECK-BASIC-LIBCXX: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{[^"]*}}.o" 
"-lmsvcrt"
 
 // RUN: %clang -### -target armv7-windows-itanium --sysroot 
%s/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld 
-rtlib=compiler-rt -stdlib=libstdc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-RTLIB
 
-// CHECK-RTLIB: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib" 
"-L{{.*}}/Inputs/Windows/ARM/8.1/usr/lib/gcc" "{{.*}}.o" "-lmsvcrt" 
"{{.*[\\/]}}clang_rt.builtins-arm.lib"
+// CHECK-RTLIB: armv7-windows-itanium-ld" 
"--sysroot={{.*}}/Inputs/Windows/ARM/8.1" "-m" "thumb2pe" "-Bdynamic" "--entry" 
"mainCRTStartup" "--allow-multiple-definition" "-o" "{{[^"]*}}" "{{.*}}.o" 
"-lmsvcrt" "{{.*[\\/]}}clang_rt.builtins-arm.lib"
 
 // RUN: %clang -### -target armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin -fuse-ld=ld 
-rtlib=compiler-rt -stdlib=libc++ -o /dev/null %s 2>&1 \
 // RUN:   | FileCheck %s --check-prefix CHECK-C-LIBCXX


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


[PATCH] D32543: [X86] Clang option -fuse-init-array has no effect when generating for MCU target

2017-05-04 Thread Andrei via Phabricator via cfe-commits
AndreiGrischenko updated this revision to Diff 97866.
AndreiGrischenko added a comment.

Thanks Craig for the good advice. You are right I can check llc with MCU triple 
using option -use-ctors. Please see updated patch.


https://reviews.llvm.org/D32543

Files:
  llvm/lib/Target/X86/X86TargetMachine.cpp
  llvm/test/CodeGen/X86/constructor.ll


Index: llvm/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -87,7 +87,7 @@
 
   if (TT.isOSFreeBSD())
 return llvm::make_unique();
-  if (TT.isOSLinux() || TT.isOSNaCl())
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
 return llvm::make_unique();
   if (TT.isOSFuchsia())
 return llvm::make_unique();
Index: llvm/test/CodeGen/X86/constructor.ll
===
--- llvm/test/CodeGen/X86/constructor.ll
+++ llvm/test/CodeGen/X86/constructor.ll
@@ -3,6 +3,8 @@
 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY 
%s
 ; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck 
--check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
+; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s 
--check-prefix=MCU-CTORS
+; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s 
--check-prefix=MCU-INIT-ARRAY
 @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, 
void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { 
i32 15, void ()* @g, i8* @v }]
 
 @v = weak_odr global i8 0
@@ -37,3 +39,6 @@
 ; NACL-NEXT:   .section.init_array,"aw",@init_array
 ; NACL-NEXT:   .p2align2
 ; NACL-NEXT:   .long   f
+
+; MCU-CTORS: .section.ctors,"aw",@progbits
+; MCU-INIT-ARRAY:.section.init_array,"aw",@init_array


Index: llvm/lib/Target/X86/X86TargetMachine.cpp
===
--- llvm/lib/Target/X86/X86TargetMachine.cpp
+++ llvm/lib/Target/X86/X86TargetMachine.cpp
@@ -87,7 +87,7 @@
 
   if (TT.isOSFreeBSD())
 return llvm::make_unique();
-  if (TT.isOSLinux() || TT.isOSNaCl())
+  if (TT.isOSLinux() || TT.isOSNaCl() || TT.isOSIAMCU())
 return llvm::make_unique();
   if (TT.isOSFuchsia())
 return llvm::make_unique();
Index: llvm/test/CodeGen/X86/constructor.ll
===
--- llvm/test/CodeGen/X86/constructor.ll
+++ llvm/test/CodeGen/X86/constructor.ll
@@ -3,6 +3,8 @@
 ; RUN: llc -mtriple x86_64-pc-linux < %s | FileCheck --check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-freebsd < %s | FileCheck --check-prefix=INIT-ARRAY %s
 ; RUN: llc -mtriple x86_64-unknown-nacl < %s | FileCheck --check-prefix=NACL %s
+; RUN: llc -mtriple i586-intel-elfiamcu -use-ctors < %s | FileCheck %s --check-prefix=MCU-CTORS
+; RUN: llc -mtriple i586-intel-elfiamcu < %s | FileCheck %s --check-prefix=MCU-INIT-ARRAY
 @llvm.global_ctors = appending global [2 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @f, i8* null}, { i32, void ()*, i8* } { i32 15, void ()* @g, i8* @v }]
 
 @v = weak_odr global i8 0
@@ -37,3 +39,6 @@
 ; NACL-NEXT:	.section	.init_array,"aw",@init_array
 ; NACL-NEXT:	.p2align	2
 ; NACL-NEXT:	.long	f
+
+; MCU-CTORS: .section.ctors,"aw",@progbits
+; MCU-INIT-ARRAY:.section.init_array,"aw",@init_array
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302187 - Turn -Wmicrosoft-enum-value off by default.

2017-05-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu May  4 14:36:26 2017
New Revision: 302187

URL: http://llvm.org/viewvc/llvm-project?rev=302187&view=rev
Log:
Turn -Wmicrosoft-enum-value off by default.

The warning is currently way too noisy to be useful. The plan is
to make it warn when an MS enum that's negative is compared to
something, but until that's done the warning shouldn't default
to on.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302187&r1=302186&r2=302187&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May  4 14:36:26 
2017
@@ -2088,7 +2088,7 @@ def err_enum_invalid_underlying : Error<
   "non-integral type %0 is an invalid underlying type">;
 def err_enumerator_too_large : Error<
   "enumerator value is not representable in the underlying type %0">;
-def ext_enumerator_too_large : ExtWarn<
+def ext_enumerator_too_large : Extension<
   "enumerator value is not representable in the underlying type %0">,
   InGroup;
 def err_enumerator_wrapped : Error<


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


r302188 - Fix bugs checking va_start in lambdas and erroneous contexts

2017-05-04 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu May  4 14:51:05 2017
New Revision: 302188

URL: http://llvm.org/viewvc/llvm-project?rev=302188&view=rev
Log:
Fix bugs checking va_start in lambdas and erroneous contexts

Summary:
First, getCurFunction looks through blocks and lambdas, which is wrong.
Inside a lambda, va_start should refer to the lambda call operator
prototype. This fixes PR32737.

Second, we shouldn't use any of the getCur* methods, because they look
through contexts that we don't want to look through (EnumDecl,
CapturedStmtDecl). We can use CurContext directly as the calling
context.

Finally, this code assumed that CallExprs would never appear outside of
code contexts (block, function, obj-c method), which is wrong. Struct
member initializers are an easy way to create and parse exprs in a
non-code context.

Reviewers: rsmith

Subscribers: cfe-commits

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

Added:
cfe/trunk/test/OpenMP/varargs.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/SemaCXX/varargs.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302188&r1=302187&r2=302188&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May  4 14:51:05 
2017
@@ -7920,7 +7920,11 @@ def warn_empty_switch_body : Warning<
 def note_empty_body_on_separate_line : Note<
   "put the semicolon on a separate line to silence this warning">;
 
-def err_va_start_used_in_non_variadic_function : Error<
+def err_va_start_captured_stmt : Error<
+  "'va_start' cannot be used in a captured statement">;
+def err_va_start_outside_function : Error<
+  "'va_start' cannot be used outside a function">;
+def err_va_start_fixed_function : Error<
   "'va_start' used in function with fixed args">;
 def err_va_start_used_in_wrong_abi_function : Error<
   "'va_start' used in %select{System V|Win64}0 ABI function">;

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=302188&r1=302187&r2=302188&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Thu May  4 14:51:05 2017
@@ -3652,22 +3652,29 @@ static bool checkVAStartIsInVariadicFunc
   // and get its parameter list.
   bool IsVariadic = false;
   ArrayRef Params;
-  if (BlockScopeInfo *CurBlock = S.getCurBlock()) {
-IsVariadic = CurBlock->TheDecl->isVariadic();
-Params = CurBlock->TheDecl->parameters();
-  } else if (FunctionDecl *FD = S.getCurFunctionDecl()) {
+  DeclContext *Caller = S.CurContext;
+  if (auto *Block = dyn_cast(Caller)) {
+IsVariadic = Block->isVariadic();
+Params = Block->parameters();
+  } else if (auto *FD = dyn_cast(Caller)) {
 IsVariadic = FD->isVariadic();
 Params = FD->parameters();
-  } else if (ObjCMethodDecl *MD = S.getCurMethodDecl()) {
+  } else if (auto *MD = dyn_cast(Caller)) {
 IsVariadic = MD->isVariadic();
 // FIXME: This isn't correct for methods (results in bogus warning).
 Params = MD->parameters();
+  } else if (isa(Caller)) {
+// We don't support va_start in a CapturedDecl.
+S.Diag(Fn->getLocStart(), diag::err_va_start_captured_stmt);
+return true;
   } else {
-llvm_unreachable("unknown va_start context");
+// This must be some other declcontext that parses exprs.
+S.Diag(Fn->getLocStart(), diag::err_va_start_outside_function);
+return true;
   }
 
   if (!IsVariadic) {
-S.Diag(Fn->getLocStart(), 
diag::err_va_start_used_in_non_variadic_function);
+S.Diag(Fn->getLocStart(), diag::err_va_start_fixed_function);
 return true;
   }
 

Added: cfe/trunk/test/OpenMP/varargs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/varargs.cpp?rev=302188&view=auto
==
--- cfe/trunk/test/OpenMP/varargs.cpp (added)
+++ cfe/trunk/test/OpenMP/varargs.cpp Thu May  4 14:51:05 2017
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+void f(int a, ...) {
+#pragma omp parallel for
+  for (int i = 0; i < 100; ++i) {
+__builtin_va_list ap;
+__builtin_va_start(ap, a); // expected-error {{'va_start' cannot be used 
in a captured statement}}
+  }
+};

Modified: cfe/trunk/test/SemaCXX/varargs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/varargs.cpp?rev=302188&r1=302187&r2=302188&view=diff
==
--- cfe/trunk/test/SemaCXX/varargs.cpp (original)
+++ cfe/trunk/test/SemaCXX/varargs.cpp Thu May  4 14:51:05 2017
@@ -1,12 +1,59 @@
-// RUN: %clang_cc1 -fsyntax-onl

[PATCH] D32761: Fix bugs checking va_start in lambdas and erroneous contexts

2017-05-04 Thread Reid Kleckner via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302188: Fix bugs checking va_start in lambdas and erroneous 
contexts (authored by rnk).

Changed prior to commit:
  https://reviews.llvm.org/D32761?vs=97503&id=97868#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D32761

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaChecking.cpp
  cfe/trunk/test/OpenMP/varargs.cpp
  cfe/trunk/test/SemaCXX/varargs.cpp

Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -7920,7 +7920,11 @@
 def note_empty_body_on_separate_line : Note<
   "put the semicolon on a separate line to silence this warning">;
 
-def err_va_start_used_in_non_variadic_function : Error<
+def err_va_start_captured_stmt : Error<
+  "'va_start' cannot be used in a captured statement">;
+def err_va_start_outside_function : Error<
+  "'va_start' cannot be used outside a function">;
+def err_va_start_fixed_function : Error<
   "'va_start' used in function with fixed args">;
 def err_va_start_used_in_wrong_abi_function : Error<
   "'va_start' used in %select{System V|Win64}0 ABI function">;
Index: cfe/trunk/test/SemaCXX/varargs.cpp
===
--- cfe/trunk/test/SemaCXX/varargs.cpp
+++ cfe/trunk/test/SemaCXX/varargs.cpp
@@ -1,12 +1,59 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++03 -verify %s
+// RUN: %clang_cc1 -std=c++03 -verify %s
+// RUN: %clang_cc1 -std=c++11 -verify %s
+
+__builtin_va_list ap;
 
 class string;
 void f(const string& s, ...) {  // expected-note {{parameter of type 'const string &' is declared here}}
-  __builtin_va_list ap;
   __builtin_va_start(ap, s); // expected-warning {{passing an object of reference type to 'va_start' has undefined behavior}}
 }
 
 void g(register int i, ...) {
-  __builtin_va_list ap;
-  __builtin_va_start(ap, i); // okay
+  __builtin_va_start(ap, i); // UB in C, OK in C++
+}
+
+// Don't crash when there is no last parameter.
+void no_params(...) {
+  int a;
+  __builtin_va_start(ap, a); // expected-warning {{second argument to 'va_start' is not the last named parameter}}
+}
+
+// Reject this. The __builtin_va_start would execute in Foo's non-variadic
+// default ctor.
+void record_context(int a, ...) {
+  struct Foo {
+// expected-error@+1 {{'va_start' cannot be used outside a function}}
+void meth(int a, int b = (__builtin_va_start(ap, a), 0)) {}
+  };
+}
+
+#if __cplusplus >= 201103L
+// We used to have bugs identifying the correct enclosing function scope in a
+// lambda.
+
+void fixed_lambda_varargs_function(int a, ...) {
+  [](int b) {
+__builtin_va_start(ap, b); // expected-error {{'va_start' used in function with fixed args}}
+  }(42);
+}
+void varargs_lambda_fixed_function(int a) {
+  [](int b, ...) {
+__builtin_va_start(ap, b); // correct
+  }(42);
+}
+
+auto fixed_lambda_global = [](int f) {
+  __builtin_va_start(ap, f); // expected-error {{'va_start' used in function with fixed args}}
+};
+auto varargs_lambda_global = [](int f, ...) {
+  __builtin_va_start(ap, f); // correct
+};
+
+void record_member_init(int a, ...) {
+  struct Foo {
+int a = 0;
+// expected-error@+1 {{'va_start' cannot be used outside a function}}
+int b = (__builtin_va_start(ap, a), 0);
+  };
 }
+#endif
Index: cfe/trunk/test/OpenMP/varargs.cpp
===
--- cfe/trunk/test/OpenMP/varargs.cpp
+++ cfe/trunk/test/OpenMP/varargs.cpp
@@ -0,0 +1,8 @@
+// RUN: %clang_cc1 -verify -fopenmp %s
+void f(int a, ...) {
+#pragma omp parallel for
+  for (int i = 0; i < 100; ++i) {
+__builtin_va_list ap;
+__builtin_va_start(ap, a); // expected-error {{'va_start' cannot be used in a captured statement}}
+  }
+};
Index: cfe/trunk/lib/Sema/SemaChecking.cpp
===
--- cfe/trunk/lib/Sema/SemaChecking.cpp
+++ cfe/trunk/lib/Sema/SemaChecking.cpp
@@ -3652,22 +3652,29 @@
   // and get its parameter list.
   bool IsVariadic = false;
   ArrayRef Params;
-  if (BlockScopeInfo *CurBlock = S.getCurBlock()) {
-IsVariadic = CurBlock->TheDecl->isVariadic();
-Params = CurBlock->TheDecl->parameters();
-  } else if (FunctionDecl *FD = S.getCurFunctionDecl()) {
+  DeclContext *Caller = S.CurContext;
+  if (auto *Block = dyn_cast(Caller)) {
+IsVariadic = Block->isVariadic();
+Params = Block->parameters();
+  } else if (auto *FD = dyn_cast(Caller)) {
 IsVariadic = FD->isVariadic();
 Params = FD->parameters();
-  } else if (ObjCMethodDecl *MD = S.getCurMethodDecl()) {
+  } else if (auto *MD = dyn_cast(Caller)) {
 IsVariadic = MD->isVariadic();
 // FIXME: This isn't correct for methods (results in bogus warning).
 Params = MD->parameters();
+  } else if (

r302190 - Turn on -Wmicrosoft-enum-forward-reference by default.

2017-05-04 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu May  4 14:54:50 2017
New Revision: 302190

URL: http://llvm.org/viewvc/llvm-project?rev=302190&view=rev
Log:
Turn on -Wmicrosoft-enum-forward-reference by default.

clang-cl already errs or warns on everything that cl
warns on in /permissive- mode, except for enum foward
declarations (and ATL attributes).
So warn on enum forward declarations by default.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=302190&r1=302189&r2=302190&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Thu May  4 14:54:50 
2017
@@ -4759,7 +4759,7 @@ def ext_forward_ref_enum : Extension<
   "ISO C forbids forward references to 'enum' types">;
 def err_forward_ref_enum : Error<
   "ISO C++ forbids forward references to 'enum' types">;
-def ext_ms_forward_ref_enum : Extension<
+def ext_ms_forward_ref_enum : ExtWarn<
   "forward references to 'enum' types are a Microsoft extension">,
   InGroup;
 def ext_forward_ref_enum_def : Extension<


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


[clang-tools-extra] r302191 - [clangd] Add documentation page

2017-05-04 Thread Marc-Andre Laperle via cfe-commits
Author: malaperle
Date: Thu May  4 14:57:53 2017
New Revision: 302191

URL: http://llvm.org/viewvc/llvm-project?rev=302191&view=rev
Log:
[clangd] Add documentation page

Summary:
Add a simple documentation page for Clangd.
This will be useful for interested users and contributors to get basic 
information about how
to get started and the progress of Clangd.

Reviewers: krasimir, bkramer

Reviewed By: krasimir

Subscribers: Prazek, jbcoe, JDevlieghere, mgehre, JonasToth, kromanenkov, 
xazax.hun, cfe-commits

Tags: #clang-tools-extra

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

Added:
clang-tools-extra/trunk/docs/clangd.rst
Modified:
clang-tools-extra/trunk/docs/index.rst

Added: clang-tools-extra/trunk/docs/clangd.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clangd.rst?rev=302191&view=auto
==
--- clang-tools-extra/trunk/docs/clangd.rst (added)
+++ clang-tools-extra/trunk/docs/clangd.rst Thu May  4 14:57:53 2017
@@ -0,0 +1,106 @@
+
+Clangd
+
+
+.. contents::
+
+.. toctree::
+   :maxdepth: 1
+
+:program:`Clangd` is an implementation of the `Language Server Protocol
+`_ leveraging Clang.
+Clangd's goal is to provide language "smartness" features like code completion,
+find references, etc. for clients such as C/C++ Editors.
+
+Using Clangd
+==
+
+:program:`Clangd` is not meant to be used by C/C++ developers directly but
+rather from a client implementing the protocol. A client would be typically
+implemented in an IDE or an editor.
+
+At the moment, `Visual Studio Code `_ is mainly
+used in order to test :program:`Clangd` but more clients are likely to make
+use of :program:`Clangd` in the future as it matures and becomes a production
+quality tool. If you are interested in trying :program:`Clangd` in combination
+with Visual Studio Code, you can start by `building Clangd`_, then open Visual
+Studio Code in the clangd-vscode folder and launch the extension.
+
+Building Clangd
+==
+
+You can follow the instructions for `building Clang
+`_ but "extra Clang tools" is **not**
+optional.
+
+Current Status
+==
+
+Many features could be implemented in :program:`Clangd`.
+Here is a list of features that could be useful with the status of whether or
+not they are already implemented in :program:`Clangd` and specified in the
+Language Server Protocol. Note that for some of the features, it is not clear
+whether or not they should be part of the Language Server Protocol, so those
+features might be eventually developed outside :program:`Clangd`.
+
++-++--+
+| C/C++ Editor feature|  LSP   |  Clangd  |
++=++==+
+| Formatting  | Yes|   Yes|
++-++--+
+| Completion  | Yes|   Yes|
++-++--+
+| Diagnostics | Yes|   Yes|
++-++--+ 
+| Fix-its | Yes|   Yes|
++-++--+
+| Go to Definition| Yes|   No |
++-++--+
+| Source hover| Yes|   No |
++-++--+
+| Signature Help  | Yes|   No |
++-++--+
+| Find References | Yes|   No |
++-++--+
+| Document Highlights | Yes|   No |
++-++--+
+| Rename  | Yes|   No |
++-++--+
+| Code Lens   | Yes|   No |
++-++--+
+| Syntax and Semantic Coloring| No |   No |
++-++--+
+| Code folding| No |   No |
++-++--+
+| Call hierarchy  | No |   No |
++-++--+
+| Type hierarchy  | No |   No |
++-++--+
+| Organize Includes   | No   

[PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

2017-05-04 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
Herald added a subscriber: javed.absar.

https://reviews.llvm.org/D32879

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Parser/MicrosoftExtensions.cpp
  test/Parser/ms-square-bracket-attributes.mm
  test/SemaCXX/ms-uuid.cpp


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s 
-Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/ms-square-bracket-attributes.mm
===
--- test/Parser/ms-square-bracket-attributes.mm
+++ test/Parser/ms-square-bracket-attributes.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s 
-Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -60,7 +60,7 @@
 struct __declspec(uuid("00A0---C000-0049"))
 struct_with_uuid2;
 
-[uuid("00A0---C000-0049")] struct struct_with_uuid3;
+[uuid("00A0---C000-0049")] struct struct_with_uuid3; // 
expected-warning{{specifying uuid as ATL attribute is deprecated, use 
__declspec instead}}
 
 struct
 struct_with_uuid2 {} ;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5079,6 +5079,15 @@
 }
   }
 
+  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if it's
+  // the only thing in the [] list, the [] too), and add an insertion of
+  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the commas
+  // separating attributes nor of the [ and the ] are in the AST.
+  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]] etc"
+  // on cfe-dev.
+  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
+S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
+
   UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
  Attr.getAttributeSpellingListIndex(), StrRef);
   if (UA)
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -4151,8 +4151,6 @@
   }
 
   if (!T.consumeClose()) {
-// FIXME: Warn that this syntax is deprecated, with a Fix-It suggesting
-// using __declspec(uuid()) instead.
 Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()), 
nullptr,
  SourceLocation(), ArgExprs.data(), ArgExprs.size(),
  AttributeList::AS_Microsoft);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -730,6 +730,9 @@
 def warn_pragma_unused_undeclared_var : Warning<
   "undeclared variable %0 used as an argument for '#pragma unused'">,
   InGroup;
+def warn_atl_uuid_deprecated : Warning<
+  "specifying uuid as ATL attribute is deprecated, use __declspec instead">,
+  InGroup;
 def warn_pragma_unused_expected_var_arg : Warning<
   "only variables can be arguments to '#pragma unused'">,
   InGroup;


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s -Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/ms-square-bracket-attributes.mm
===
--- test/Parser/ms-square-bracket-attributes.mm
+++ test/Parser/ms-square-bracket-attributes.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s -Wno-deprecated-declarations
 
 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -60,7 +60,7 @@
 struct __declspec(uuid("00A0---C000-0049"))
 struct_with_uuid2;
 
-[uuid("00A0---C000-0049")] struct struct_with_uuid3;
+[uuid("00A0---C000-000

[PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

2017-05-04 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D32879



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


r302195 - Fix whitespace before token-paste of an argument.

2017-05-04 Thread James Y Knight via cfe-commits
Author: jyknight
Date: Thu May  4 16:31:17 2017
New Revision: 302195

URL: http://llvm.org/viewvc/llvm-project?rev=302195&view=rev
Log:
Fix whitespace before token-paste of an argument.

The whitespace should come from the argument name in the macro
expansion, rather than from the token passed to the macro (same as it
does when not pasting).

Added a new test case for the change in behavior to stringize_space.c.

FileCheck'ized macro_paste_commaext.c, tweaked the test case, and
added a comment; no behavioral change to this test.

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

Modified:
cfe/trunk/lib/Lex/TokenLexer.cpp
cfe/trunk/test/Preprocessor/macro_paste_commaext.c
cfe/trunk/test/Preprocessor/stringize_space.c

Modified: cfe/trunk/lib/Lex/TokenLexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/TokenLexer.cpp?rev=302195&r1=302194&r2=302195&view=diff
==
--- cfe/trunk/lib/Lex/TokenLexer.cpp (original)
+++ cfe/trunk/lib/Lex/TokenLexer.cpp Thu May  4 16:31:17 2017
@@ -183,6 +183,12 @@ void TokenLexer::ExpandFunctionArguments
 // preprocessor already verified that the following token is a macro name
 // when the #define was parsed.
 const Token &CurTok = Tokens[i];
+// We don't want a space for the next token after a paste
+// operator.  In valid code, the token will get smooshed onto the
+// preceding one anyway. In assembler-with-cpp mode, invalid
+// pastes are allowed through: in this case, we do not want the
+// extra whitespace to be added.  For example, we want ". ## foo"
+// -> ".foo" not ". foo".
 if (i != 0 && !Tokens[i-1].is(tok::hashhash) && CurTok.hasLeadingSpace())
   NextTokGetsSpace = true;
 
@@ -317,6 +323,7 @@ void TokenLexer::ExpandFunctionArguments
 const Token *ArgToks = ActualArgs->getUnexpArgument(ArgNo);
 unsigned NumToks = MacroArgs::getArgLength(ArgToks);
 if (NumToks) {  // Not an empty argument?
+  bool VaArgsPseudoPaste = false;
   // If this is the GNU ", ## __VA_ARGS__" extension, and we just learned
   // that __VA_ARGS__ expands to multiple tokens, avoid a pasting error 
when
   // the expander trys to paste ',' with the first token of the __VA_ARGS__
@@ -325,6 +332,7 @@ void TokenLexer::ExpandFunctionArguments
   ResultToks[ResultToks.size()-2].is(tok::comma) &&
   (unsigned)ArgNo == Macro->getNumArgs()-1 &&
   Macro->isVariadic()) {
+VaArgsPseudoPaste = true;
 // Remove the paste operator, report use of the extension.
 PP.Diag(ResultToks.pop_back_val().getLocation(), 
diag::ext_paste_comma);
   }
@@ -344,18 +352,16 @@ void TokenLexer::ExpandFunctionArguments
ResultToks.end()-NumToks, ResultToks.end());
   }
 
-  // If this token (the macro argument) was supposed to get leading
-  // whitespace, transfer this information onto the first token of the
-  // expansion.
-  //
-  // Do not do this if the paste operator occurs before the macro argument,
-  // as in "A ## MACROARG".  In valid code, the first token will get
-  // smooshed onto the preceding one anyway (forming AMACROARG).  In
-  // assembler-with-cpp mode, invalid pastes are allowed through: in this
-  // case, we do not want the extra whitespace to be added.  For example,
-  // we want ". ## foo" -> ".foo" not ". foo".
-  if (NextTokGetsSpace)
-ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace);
+  // Transfer the leading whitespace information from the token
+  // (the macro argument) onto the first token of the
+  // expansion. Note that we don't do this for the GNU
+  // pseudo-paste extension ", ## __VA_ARGS__".
+  if (!VaArgsPseudoPaste) {
+ResultToks[ResultToks.size() - 
NumToks].setFlagValue(Token::StartOfLine,
+ false);
+ResultToks[ResultToks.size() - NumToks].setFlagValue(
+Token::LeadingSpace, NextTokGetsSpace);
+  }
 
   NextTokGetsSpace = false;
   continue;

Modified: cfe/trunk/test/Preprocessor/macro_paste_commaext.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Preprocessor/macro_paste_commaext.c?rev=302195&r1=302194&r2=302195&view=diff
==
--- cfe/trunk/test/Preprocessor/macro_paste_commaext.c (original)
+++ cfe/trunk/test/Preprocessor/macro_paste_commaext.c Thu May  4 16:31:17 2017
@@ -1,13 +1,20 @@
-// RUN: %clang_cc1 %s -E | grep 'V);'
-// RUN: %clang_cc1 %s -E | grep 'W, 1, 2);'
-// RUN: %clang_cc1 %s -E | grep 'X, 1, 2);'
-// RUN: %clang_cc1 %s -E | grep 'Y,);'
-// RUN: %clang_cc1 %s -E | grep 'Z,);'
+// RUN: %clang_cc1 %s -E | FileCheck --strict-whitespace --match-full-lines %s
+
+// In the following tests, note that the output is sensitive to the
+// 

[PATCH] D30427: Fix whitespace before token-paste of an argument.

2017-05-04 Thread James Y Knight via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL302195: Fix whitespace before token-paste of an argument. 
(authored by jyknight).

Changed prior to commit:
  https://reviews.llvm.org/D30427?vs=89918&id=97881#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D30427

Files:
  cfe/trunk/lib/Lex/TokenLexer.cpp
  cfe/trunk/test/Preprocessor/macro_paste_commaext.c
  cfe/trunk/test/Preprocessor/stringize_space.c

Index: cfe/trunk/test/Preprocessor/macro_paste_commaext.c
===
--- cfe/trunk/test/Preprocessor/macro_paste_commaext.c
+++ cfe/trunk/test/Preprocessor/macro_paste_commaext.c
@@ -1,13 +1,20 @@
-// RUN: %clang_cc1 %s -E | grep 'V);'
-// RUN: %clang_cc1 %s -E | grep 'W, 1, 2);'
-// RUN: %clang_cc1 %s -E | grep 'X, 1, 2);'
-// RUN: %clang_cc1 %s -E | grep 'Y,);'
-// RUN: %clang_cc1 %s -E | grep 'Z,);'
+// RUN: %clang_cc1 %s -E | FileCheck --strict-whitespace --match-full-lines %s
+
+// In the following tests, note that the output is sensitive to the
+// whitespace *preceeding* the varargs argument, as well as to
+// interior whitespace. AFAIK, this is the only case where whitespace
+// preceeding an argument matters, and might be considered a bug in
+// GCC. Nevertheless, since this feature is a GCC extension in the
+// first place, we'll follow along.
 
 #define debug(format, ...) format, ## __VA_ARGS__)
+// CHECK:V);
 debug(V);
-debug(W, 1, 2);
+// CHECK:W,1, 2);
+debug(W,1, 2);
+// CHECK:X, 1, 2);
 debug(X, 1, 2 );
+// CHECK:Y,);
 debug(Y, );
+// CHECK:Z,);
 debug(Z,);
-
Index: cfe/trunk/test/Preprocessor/stringize_space.c
===
--- cfe/trunk/test/Preprocessor/stringize_space.c
+++ cfe/trunk/test/Preprocessor/stringize_space.c
@@ -18,3 +18,14 @@
 1)
 
 // CHECK: {{^}}"-1"
+
+#define paste(a,b) str(a ".foo" not ". foo".
 if (i != 0 && !Tokens[i-1].is(tok::hashhash) && CurTok.hasLeadingSpace())
   NextTokGetsSpace = true;
 
@@ -317,14 +323,16 @@
 const Token *ArgToks = ActualArgs->getUnexpArgument(ArgNo);
 unsigned NumToks = MacroArgs::getArgLength(ArgToks);
 if (NumToks) {  // Not an empty argument?
+  bool VaArgsPseudoPaste = false;
   // If this is the GNU ", ## __VA_ARGS__" extension, and we just learned
   // that __VA_ARGS__ expands to multiple tokens, avoid a pasting error when
   // the expander trys to paste ',' with the first token of the __VA_ARGS__
   // expansion.
   if (NonEmptyPasteBefore && ResultToks.size() >= 2 &&
   ResultToks[ResultToks.size()-2].is(tok::comma) &&
   (unsigned)ArgNo == Macro->getNumArgs()-1 &&
   Macro->isVariadic()) {
+VaArgsPseudoPaste = true;
 // Remove the paste operator, report use of the extension.
 PP.Diag(ResultToks.pop_back_val().getLocation(), diag::ext_paste_comma);
   }
@@ -344,18 +352,16 @@
ResultToks.end()-NumToks, ResultToks.end());
   }
 
-  // If this token (the macro argument) was supposed to get leading
-  // whitespace, transfer this information onto the first token of the
-  // expansion.
-  //
-  // Do not do this if the paste operator occurs before the macro argument,
-  // as in "A ## MACROARG".  In valid code, the first token will get
-  // smooshed onto the preceding one anyway (forming AMACROARG).  In
-  // assembler-with-cpp mode, invalid pastes are allowed through: in this
-  // case, we do not want the extra whitespace to be added.  For example,
-  // we want ". ## foo" -> ".foo" not ". foo".
-  if (NextTokGetsSpace)
-ResultToks[ResultToks.size()-NumToks].setFlag(Token::LeadingSpace);
+  // Transfer the leading whitespace information from the token
+  // (the macro argument) onto the first token of the
+  // expansion. Note that we don't do this for the GNU
+  // pseudo-paste extension ", ## __VA_ARGS__".
+  if (!VaArgsPseudoPaste) {
+ResultToks[ResultToks.size() - NumToks].setFlagValue(Token::StartOfLine,
+ false);
+ResultToks[ResultToks.size() - NumToks].setFlagValue(
+Token::LeadingSpace, NextTokGetsSpace);
+  }
 
   NextTokGetsSpace = false;
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D32879: Warn that the [] spelling of uuid(...) is deprecated.

2017-05-04 Thread Aaron Ballman via cfe-commits
On May 4, 2017 4:55 PM, "Nico Weber via Phabricator" <
revi...@reviews.llvm.org> wrote:

thakis created this revision.
Herald added a subscriber: javed.absar.

https://reviews.llvm.org/D32879

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Parse/ParseDeclCXX.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Parser/MicrosoftExtensions.cpp
  test/Parser/ms-square-bracket-attributes.mm
  test/SemaCXX/ms-uuid.cpp


Index: test/SemaCXX/ms-uuid.cpp
===
--- test/SemaCXX/ms-uuid.cpp
+++ test/SemaCXX/ms-uuid.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -verify -fms-extensions %s
-Wno-deprecated-declarations

 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/ms-square-bracket-attributes.mm
===
--- test/Parser/ms-square-bracket-attributes.mm
+++ test/Parser/ms-square-bracket-attributes.mm
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
+// RUN: %clang_cc1 -fsyntax-only -std=c++14 -verify -fms-extensions %s
-Wno-deprecated-declarations

 typedef struct _GUID {
   unsigned long Data1;
Index: test/Parser/MicrosoftExtensions.cpp
===
--- test/Parser/MicrosoftExtensions.cpp
+++ test/Parser/MicrosoftExtensions.cpp
@@ -60,7 +60,7 @@
 struct __declspec(uuid("00A0---C000-0049"))
 struct_with_uuid2;

-[uuid("00A0---C000-0049")] struct struct_with_uuid3;
+[uuid("00A0---C000-0049")] struct struct_with_uuid3;
// expected-warning{{specifying uuid as ATL attribute is deprecated, use
__declspec instead}}

 struct
 struct_with_uuid2 {} ;
Index: lib/Sema/SemaDeclAttr.cpp
===
--- lib/Sema/SemaDeclAttr.cpp
+++ lib/Sema/SemaDeclAttr.cpp
@@ -5079,6 +5079,15 @@
 }
   }

+  // FIXME: It'd be nice to also emit a fixit removing uuid(...) (and, if
it's
+  // the only thing in the [] list, the [] too), and add an insertion of
+  // __declspec(uuid(...)).  But sadly, neither the SourceLocs of the
commas
+  // separating attributes nor of the [ and the ] are in the AST.
+  // Cf "SourceLocations of attribute list delimiters – [[ ... , ... ]]
etc"
+  // on cfe-dev.
+  if (Attr.isMicrosoftAttribute()) // Check for [uuid(...)] spelling.
+S.Diag(Attr.getLoc(), diag::warn_atl_uuid_deprecated);
+
   UuidAttr *UA = S.mergeUuidAttr(D, Attr.getRange(),
  Attr.getAttributeSpellingListIndex(),
StrRef);
   if (UA)
Index: lib/Parse/ParseDeclCXX.cpp
===
--- lib/Parse/ParseDeclCXX.cpp
+++ lib/Parse/ParseDeclCXX.cpp
@@ -4151,8 +4151,6 @@
   }

   if (!T.consumeClose()) {
-// FIXME: Warn that this syntax is deprecated, with a Fix-It suggesting
-// using __declspec(uuid()) instead.
 Attrs.addNew(UuidIdent, SourceRange(UuidLoc, T.getCloseLocation()),
nullptr,
  SourceLocation(), ArgExprs.data(), ArgExprs.size(),
  AttributeList::AS_Microsoft);
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -730,6 +730,9 @@
 def warn_pragma_unused_undeclared_var : Warning<
   "undeclared variable %0 used as an argument for '#pragma unused'">,
   InGroup;
+def warn_atl_uuid_deprecated : Warning<
+  "specifying uuid as ATL attribute is deprecated, use __declspec
instead">,


as an ATL attribute

Please quoute uuid.

Replace the comma with a semicolon.

+  InGroup;
 def warn_pragma_unused_expected_var_arg : Warning<
   "only variables can be arguments to '#pragma unused'">,
   InGroup;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r302207 - Document that Multilib flags must be actual flags

2017-05-04 Thread Jonathan Roelofs via cfe-commits
Author: jroelofs
Date: Thu May  4 19:18:27 2017
New Revision: 302207

URL: http://llvm.org/viewvc/llvm-project?rev=302207&view=rev
Log:
Document that Multilib flags must be actual flags

This is because -print-multi-lib depends on them being flags for correctness.

Fixes a case of this in the arm-android multilib selection logic.

Modified:
cfe/trunk/include/clang/Driver/Multilib.h
cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
cfe/trunk/test/Driver/android-ndk-standalone.cpp

Modified: cfe/trunk/include/clang/Driver/Multilib.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Multilib.h?rev=302207&r1=302206&r2=302207&view=diff
==
--- cfe/trunk/include/clang/Driver/Multilib.h (original)
+++ cfe/trunk/include/clang/Driver/Multilib.h Thu May  4 19:18:27 2017
@@ -70,7 +70,14 @@ public:
   /// All elements begin with either '+' or '-'
   const flags_list &flags() const { return Flags; }
   flags_list &flags() { return Flags; }
+
   /// Add a flag to the flags list
+  /// \p Flag must be a flag accepted by the driver with its leading '-' 
removed,
+  /// and replaced with either:
+  ///   '-' which contraindicates using this multilib with that flag
+  /// or:
+  ///   '+' which promotes using this multilib in the presence of that flag
+  /// otherwise '-print-multi-lib' will not emit them correctly.
   Multilib &flag(StringRef F) {
 assert(F.front() == '+' || F.front() == '-');
 Flags.push_back(F);

Modified: cfe/trunk/lib/Driver/ToolChains/Gnu.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Gnu.cpp?rev=302207&r1=302206&r2=302207&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Gnu.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Gnu.cpp Thu May  4 19:18:27 2017
@@ -893,6 +893,8 @@ static bool isSoftFloatABI(const ArgList
   A->getValue() == StringRef("soft"));
 }
 
+/// \p Flag must be a flag accepted by the driver with its leading '-' removed,
+// otherwise '-print-multi-lib' will not emit them correctly.
 static void addMultilibFlag(bool Enabled, const char *const Flag,
 std::vector &Flags) {
   if (Enabled)
@@ -1437,17 +1439,17 @@ static void findAndroidArmMultilibs(cons
   // Find multilibs with subdirectories like armv7-a, thumb, armv7-a/thumb.
   FilterNonExistent NonExistent(Path, "/crtbegin.o", D.getVFS());
   Multilib ArmV7Multilib = makeMultilib("/armv7-a")
-   .flag("+armv7")
-   .flag("-thumb");
+   .flag("+march=armv7-a")
+   .flag("-mthumb");
   Multilib ThumbMultilib = makeMultilib("/thumb")
-   .flag("-armv7")
-   .flag("+thumb");
+   .flag("-march=armv7-a")
+   .flag("+mthumb");
   Multilib ArmV7ThumbMultilib = makeMultilib("/armv7-a/thumb")
-   .flag("+armv7")
-   .flag("+thumb");
+   .flag("+march=armv7-a")
+   .flag("+mthumb");
   Multilib DefaultMultilib = makeMultilib("")
-   .flag("-armv7")
-   .flag("-thumb");
+   .flag("-march=armv7-a")
+   .flag("-mthumb");
   MultilibSet AndroidArmMultilibs =
   MultilibSet()
   .Either(ThumbMultilib, ArmV7Multilib,
@@ -1465,8 +1467,8 @@ static void findAndroidArmMultilibs(cons
   bool IsArmV7Mode = (IsArmArch || IsThumbArch) &&
   (llvm::ARM::parseArchVersion(Arch) == 7 ||
(IsArmArch && Arch == "" && IsV7SubArch));
-  addMultilibFlag(IsArmV7Mode, "armv7", Flags);
-  addMultilibFlag(IsThumbMode, "thumb", Flags);
+  addMultilibFlag(IsArmV7Mode, "march=armv7-a", Flags);
+  addMultilibFlag(IsThumbMode, "mthumb", Flags);
 
   if (AndroidArmMultilibs.select(Flags, Result.SelectedMultilib))
 Result.Multilibs = AndroidArmMultilibs;

Modified: cfe/trunk/test/Driver/android-ndk-standalone.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/android-ndk-standalone.cpp?rev=302207&r1=302206&r2=302207&view=diff
==
--- cfe/trunk/test/Driver/android-ndk-standalone.cpp (original)
+++ cfe/trunk/test/Driver/android-ndk-standalone.cpp Thu May  4 19:18:27 2017
@@ -172,6 +172,20 @@
 // CHECK-ARMV7THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ 
]*}}/lib/armv7-a"
 // CHECK-ARMV7THUMB-NOT: "-L{{.*}}/lib/gcc/arm-linux-androideabi/4.9/../{{[^ 
]*}}/lib"
 // CHECK-ARMV7THUMB: "-L{{.*}}/sysroot/usr/lib"
+
+// RUN: %clang -no-canonical-prefixes %s -### -o %t.o 2>&1 \
+// RUN: -target arm-linux-androideabi -stdlib=libstdc++ \
+//

[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-04 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis created this revision.

This feature is subtly broken when the linker is gold 2.26 or
earlier. See the following bug for details:

  https://sourceware.org/bugzilla/show_bug.cgi?id=19002

Since the decision needs to be made at compilation time, we can not
test the linker version. The flag is off by default on ELF targets,
and on otherwise.


Repository:
  rL LLVM

https://reviews.llvm.org/D32886

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/asan-globals-gc.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -126,6 +126,13 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-globals-live-support %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -fsanitize-address-globals-live-support -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-live-support
+// CHECK-NO-ASAN-GLOBALS-NOT: -cc1{{.*}}-fsanitize-address-globals-live-support
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
 
Index: test/CodeGen/asan-globals-gc.cpp
===
--- test/CodeGen/asan-globals-gc.cpp
+++ test/CodeGen/asan-globals-gc.cpp
@@ -1,5 +1,16 @@
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-data-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-data-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITHOUT-GC
 
 int global;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -777,6 +777,8 @@
 Opts.SanitizeAddressUseAfterScope =
 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
   }
+  Opts.SanitizeAddressGlobalsLiveSupport =
+  Args.hasArg(OPT_fsanitize_address_globals_live_support);
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Ar

[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-04 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis updated this revision to Diff 97901.

Repository:
  rL LLVM

https://reviews.llvm.org/D32886

Files:
  include/clang/Driver/Options.td
  include/clang/Driver/SanitizerArgs.h
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/BackendUtil.cpp
  lib/Driver/SanitizerArgs.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/asan-globals-gc.cpp
  test/Driver/fsanitize.c

Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -126,6 +126,13 @@
 // RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE
 // CHECK-ASAN-WITHOUT-USE-AFTER-SCOPE: -cc1{{.*}}address-use-after-scope
 
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address -fsanitize-address-globals-live-support %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang -target x86_64-linux-gnu -fsanitize=address %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-NO-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -fsanitize-address-globals-live-support -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// RUN: %clang_cl -target x86_64-windows-msvc -fsanitize=address -### -- %s 2>&1 | FileCheck %s --check-prefix=CHECK-ASAN-GLOBALS
+// CHECK-ASAN-GLOBALS: -cc1{{.*}}-fsanitize-address-globals-live-support
+// CHECK-NO-ASAN-GLOBALS-NOT: -cc1{{.*}}-fsanitize-address-globals-live-support
+
 // RUN: %clang -target x86_64-linux-gnu -fsanitize-memory-track-origins -pie %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-ONLY-TRACK-ORIGINS
 // CHECK-ONLY-TRACK-ORIGINS: warning: argument unused during compilation: '-fsanitize-memory-track-origins'
 
Index: test/CodeGen/asan-globals-gc.cpp
===
--- test/CodeGen/asan-globals-gc.cpp
+++ test/CodeGen/asan-globals-gc.cpp
@@ -1,5 +1,16 @@
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
-// RUN: %clang_cc1 -fsanitize=address -emit-llvm -o - -triple x86_64-windows-msvc -fdata-sections %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-integrated-as -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-integrated-as -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-linux %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-data-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-windows-msvc %s | FileCheck %s --check-prefix=WITHOUT-GC
+
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fno-data-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fsanitize-address-globals-live-support -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITH-GC
+// RUN: %clang_cc1 -fsanitize=address -fdata-sections -emit-llvm -o - -triple x86_64-apple-macosx11 %s | FileCheck %s --check-prefix=WITHOUT-GC
 
 int global;
 
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -777,6 +777,8 @@
 Opts.SanitizeAddressUseAfterScope =
 A->getOption().getID() == OPT_fsanitize_address_use_after_scope;
   }
+  Opts.SanitizeAddressGlobalsLiveSupport =
+  Args.hasArg(OPT_fsanitize_address_globals_live_support);
   Opts.SSPBufferSize =
   getLastArgIntValue(Args, OPT_stack_protector_buffer_size, 8, Diags);
   Opts.StackRealignment = Args.hasArg(OPT_mstackrealign);
Index: lib/Driver/SanitizerArgs.cpp
===
--- lib/Driver/SanitizerArgs.cpp
+++ lib/Driver/SanitizerArgs.cpp
@@ -568,6 +568,12 @@
   AsanUseAfterScope = A->getOption().getID() ==
   optio

[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-04 Thread Chandler Carruth via Phabricator via cfe-commits
chandlerc accepted this revision.
chandlerc added a comment.
This revision is now accepted and ready to land.

Generally makes sense. A question about the name. Feel free to land with a name 
that you and other sanitizer folks are happy with.




Comment at: include/clang/Driver/Options.td:830
HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
+def fsanitize_address_globals_live_support : Flag<["-"], 
"fsanitize-address-globals-live-support">,
+Group,

Would the name "-fsanitize-address-globals-dead-stripping" be a bit easier to 
understand? not sure.


Repository:
  rL LLVM

https://reviews.llvm.org/D32886



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


[PATCH] D32886: [asan] A clang flag to enable ELF globals-gc

2017-05-04 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added inline comments.



Comment at: include/clang/Driver/Options.td:830
HelpText<"Disable use-after-scope 
detection in AddressSanitizer">;
+def fsanitize_address_globals_live_support : Flag<["-"], 
"fsanitize-address-globals-live-support">,
+Group,

chandlerc wrote:
> Would the name "-fsanitize-address-globals-dead-stripping" be a bit easier to 
> understand? not sure.
It does sound a little bit better.
The current name is copied from the -mllvm flag, which was initially 
OSX-specific, where "live_support" is part of the section name.


Repository:
  rL LLVM

https://reviews.llvm.org/D32886



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


[PATCH] D32891: [Sema][ObjC++] Objective-C++ support for __is_base_of(B, D)

2017-05-04 Thread Erik Pilkington via Phabricator via cfe-commits
erik.pilkington created this revision.

This patch adds Objective-C interfaces support for the type trait `is_base_of`, 
so that `__is_base_of(NSString, NSMutableString)` is true.

rdar://24308607

Thanks for taking a look!
Erik


https://reviews.llvm.org/D32891

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaObjCXX/is-base-of.mm


Index: test/SemaObjCXX/is-base-of.mm
===
--- test/SemaObjCXX/is-base-of.mm
+++ test/SemaObjCXX/is-base-of.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+@interface NSObj
+@end
+
+@interface NSChild : NSObj
+@end
+
+static_assert(__is_base_of(NSObj, NSChild), "");
+static_assert(!__is_base_of(NSChild, NSObj), "");
+
+static_assert(__is_base_of(NSObj, NSObj), "");
+
+static_assert(!__is_base_of(NSObj *, NSChild *), "");
+static_assert(!__is_base_of(NSChild *, NSObj *), "");
+
+static_assert(__is_base_of(const volatile NSObj, NSChild), "");
+static_assert(__is_base_of(NSObj, const volatile NSChild), "");
+
+@class NSForward; // expected-note{{forward declaration of class}}
+
+static_assert(!__is_base_of(NSForward, NSObj), "");
+static_assert(!__is_base_of(NSObj, NSForward), ""); // 
expected-error{{incomplete type 'NSForward'}}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4720,10 +4720,24 @@
 // regard to cv-qualifiers.
 
 const RecordType *lhsRecord = LhsT->getAs();
-if (!lhsRecord) return false;
-
 const RecordType *rhsRecord = RhsT->getAs();
-if (!rhsRecord) return false;
+if (!rhsRecord || !lhsRecord) {
+  const ObjCObjectType *lhsObjTy = LhsT->getAs();
+  const ObjCObjectType *rhsObjTy = RhsT->getAs();
+  if (!lhsObjTy || !rhsObjTy)
+return false;
+
+  ObjCInterfaceDecl *BaseInterface = lhsObjTy->getInterface();
+  ObjCInterfaceDecl *DerivedInterface = rhsObjTy->getInterface();
+  if (!BaseInterface || !DerivedInterface)
+return false;
+
+  if (Self.RequireCompleteType(
+  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+return false;
+
+  return BaseInterface->isSuperClassOf(DerivedInterface);
+}
 
 assert(Self.Context.hasSameUnqualifiedType(LhsT, RhsT)
  == (lhsRecord == rhsRecord));


Index: test/SemaObjCXX/is-base-of.mm
===
--- test/SemaObjCXX/is-base-of.mm
+++ test/SemaObjCXX/is-base-of.mm
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
+
+@interface NSObj
+@end
+
+@interface NSChild : NSObj
+@end
+
+static_assert(__is_base_of(NSObj, NSChild), "");
+static_assert(!__is_base_of(NSChild, NSObj), "");
+
+static_assert(__is_base_of(NSObj, NSObj), "");
+
+static_assert(!__is_base_of(NSObj *, NSChild *), "");
+static_assert(!__is_base_of(NSChild *, NSObj *), "");
+
+static_assert(__is_base_of(const volatile NSObj, NSChild), "");
+static_assert(__is_base_of(NSObj, const volatile NSChild), "");
+
+@class NSForward; // expected-note{{forward declaration of class}}
+
+static_assert(!__is_base_of(NSForward, NSObj), "");
+static_assert(!__is_base_of(NSObj, NSForward), ""); // expected-error{{incomplete type 'NSForward'}}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -4720,10 +4720,24 @@
 // regard to cv-qualifiers.
 
 const RecordType *lhsRecord = LhsT->getAs();
-if (!lhsRecord) return false;
-
 const RecordType *rhsRecord = RhsT->getAs();
-if (!rhsRecord) return false;
+if (!rhsRecord || !lhsRecord) {
+  const ObjCObjectType *lhsObjTy = LhsT->getAs();
+  const ObjCObjectType *rhsObjTy = RhsT->getAs();
+  if (!lhsObjTy || !rhsObjTy)
+return false;
+
+  ObjCInterfaceDecl *BaseInterface = lhsObjTy->getInterface();
+  ObjCInterfaceDecl *DerivedInterface = rhsObjTy->getInterface();
+  if (!BaseInterface || !DerivedInterface)
+return false;
+
+  if (Self.RequireCompleteType(
+  KeyLoc, RhsT, diag::err_incomplete_type_used_in_type_trait_expr))
+return false;
+
+  return BaseInterface->isSuperClassOf(DerivedInterface);
+}
 
 assert(Self.Context.hasSameUnqualifiedType(LhsT, RhsT)
  == (lhsRecord == rhsRecord));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D32411: [libcxx] Provide #include_next alternative for MSVC

2017-05-04 Thread Ben Craig via Phabricator via cfe-commits
bcraig added a comment.

I'm still working on this.

Things I've learned: A clang install is bundled with re-implementations of 
several of these headers.  The default #include_next behavior ends up pulling 
in lots of those.

I have been able to get things working with a VC include path and a UCRT 
include path, but the default include paths set by the compiler driver cause 
the clang versions of stdarg.h and vadefs.h to get pulled in.  The combination 
of clang include path and ucrt include path also works.

I did end up running into the same errno problems that were mentioned earlier, 
and ended up coming to the same workaround.


https://reviews.llvm.org/D32411



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


[libcxx] r302213 - Document XFAIL's with the relevent bug number

2017-05-04 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri May  5 00:19:21 2017
New Revision: 302213

URL: http://llvm.org/viewvc/llvm-project?rev=302213&view=rev
Log:
Document XFAIL's with the relevent bug number

Modified:
libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp

Modified: libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp?rev=302213&r1=302212&r2=302213&view=diff
==
--- libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/ctor.pass.cpp Fri May  5 
00:19:21 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// See bugs.llvm.org/PR20183
+//
 // XFAIL: with_system_cxx_lib=macosx10.11
 // XFAIL: with_system_cxx_lib=macosx10.10
 // XFAIL: with_system_cxx_lib=macosx10.9

Modified: libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp?rev=302213&r1=302212&r2=302213&view=diff
==
--- libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp (original)
+++ libcxx/trunk/test/std/numerics/rand/rand.device/eval.pass.cpp Fri May  5 
00:19:21 2017
@@ -7,6 +7,8 @@
 //
 
//===--===//
 
+// See bugs.llvm.org/PR20183
+//
 // XFAIL: with_system_cxx_lib=macosx10.11
 // XFAIL: with_system_cxx_lib=macosx10.10
 // XFAIL: with_system_cxx_lib=macosx10.9


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