[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-10 Thread Paul Robinson via Phabricator via cfe-commits
probinson added a comment.

In https://reviews.llvm.org/D29739#673971, @rjmccall wrote:

> In https://reviews.llvm.org/D29739#673933, @tigerleapgorge wrote:
>
> > Hi John,
> >
> > Here is the most recent discussion I can find on cfe-dev.
> >  “I'm guessing that Objective-C/C++ is kind of passe, so nobody is really 
> > interested in modernizing it”
> >  http://lists.llvm.org/pipermail/cfe-dev/2016-December/051844.html
> >
> > As far as I am aware, there appears to be no strong reason to bump or not 
> > to bump ObjC++.
>
>
> It certainly simplifies the message to say that we've changed the default C++ 
> dialect to C++11 across the board.  That should apply to ObjC++ as well.  I 
> would not describe ObjC++ as passé; it's a very important language for Apple 
> developers.


Nice to know, although nobody piped up on the earlier cited discussion.

Sony is invested in making the lit tests C++11 clean so that we can upstream a 
change to make it the default C++ dialect for PS4.  That will ensure that any 
new C++ tests are C++11 clean.  This is one step in the direction of making 
C++11 (or even something newer) the default dialect for everybody.
However we are not an Objective-C++ vendor.  We are neutral about changing the 
default dialect there; if you want to change the default dialect for 
Objective-C++, that's fine with us, but I don't think we can invest in learning 
enough about Objective-C++ to do the right thing with the existing 
Objective-C++ tests.  In particular I don't know whether forcing 98 on these 
tests is the "right" solution; all we know is that it made the tests pass, 
which is not particularly surprising.  I really think Apple would need to step 
up here if the default Objective-C++ dialect is going to change.

> It is likely that the Rewriter generates C++98-only code.  I believe the 
> Rewriter is no longer being actively maintained; I'm not sure we're ready to 
> propose removing it yet, but if there are specific problems with those tests, 
> I think it makes some sense to just pass -std=gnu++98 for them.
> 
> John.

I am pretty sure we already modified the Rewriter tests to explicitly compile 
the rewritten C++ as -98 code.  It's just the straight Objective-C++ tests 
where Charles has stepped back.

--paulr


https://reviews.llvm.org/D29739



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


[clang-tools-extra] r294823 - Fix memory leak by using unique_ptr

2017-02-10 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Fri Feb 10 23:25:21 2017
New Revision: 294823

URL: http://llvm.org/viewvc/llvm-project?rev=294823&view=rev
Log:
Fix memory leak by using unique_ptr

Modified:
clang-tools-extra/trunk/modularize/CoverageChecker.cpp
clang-tools-extra/trunk/modularize/CoverageChecker.h
clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp

Modified: clang-tools-extra/trunk/modularize/CoverageChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.cpp?rev=294823&r1=294822&r2=294823&view=diff
==
--- clang-tools-extra/trunk/modularize/CoverageChecker.cpp (original)
+++ clang-tools-extra/trunk/modularize/CoverageChecker.cpp Fri Feb 10 23:25:21 
2017
@@ -150,12 +150,12 @@ CoverageChecker::CoverageChecker(StringR
 
 // Create instance of CoverageChecker, to simplify setting up
 // subordinate objects.
-CoverageChecker *CoverageChecker::createCoverageChecker(
-  StringRef ModuleMapPath, std::vector &IncludePaths,
-  ArrayRef CommandLine, clang::ModuleMap *ModuleMap) {
+std::unique_ptr CoverageChecker::createCoverageChecker(
+StringRef ModuleMapPath, std::vector &IncludePaths,
+ArrayRef CommandLine, clang::ModuleMap *ModuleMap) {
 
-  return new CoverageChecker(ModuleMapPath, IncludePaths, CommandLine,
-ModuleMap);
+  return llvm::make_unique(ModuleMapPath, IncludePaths,
+CommandLine, ModuleMap);
 }
 
 // Do checks.

Modified: clang-tools-extra/trunk/modularize/CoverageChecker.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/CoverageChecker.h?rev=294823&r1=294822&r2=294823&view=diff
==
--- clang-tools-extra/trunk/modularize/CoverageChecker.h (original)
+++ clang-tools-extra/trunk/modularize/CoverageChecker.h Fri Feb 10 23:25:21 
2017
@@ -91,10 +91,9 @@ public:
   /// \param CommandLine Compile command line arguments.
   /// \param ModuleMap The module map to check.
   /// \returns Initialized CoverageChecker object.
-  static CoverageChecker *createCoverageChecker(
-llvm::StringRef ModuleMapPath, std::vector &IncludePaths,
-llvm::ArrayRef CommandLine,
-clang::ModuleMap *ModuleMap);
+  static std::unique_ptr createCoverageChecker(
+  llvm::StringRef ModuleMapPath, std::vector &IncludePaths,
+  llvm::ArrayRef CommandLine, clang::ModuleMap *ModuleMap);
 
   /// Do checks.
   /// Starting from the directory of the module.modulemap file,

Modified: clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp?rev=294823&r1=294822&r2=294823&view=diff
==
--- clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp (original)
+++ clang-tools-extra/trunk/modularize/ModularizeUtilities.cpp Fri Feb 10 
23:25:21 2017
@@ -120,8 +120,9 @@ std::error_code ModularizeUtilities::doC
   std::error_code EC;
   for (ModuleMapIndex = 0; ModuleMapIndex < ModuleMapCount; ++ModuleMapIndex) {
 std::unique_ptr &ModMap = ModuleMaps[ModuleMapIndex];
-CoverageChecker *Checker = CoverageChecker::createCoverageChecker(
-  InputFilePaths[ModuleMapIndex], IncludePaths, CommandLine, ModMap.get());
+auto Checker = CoverageChecker::createCoverageChecker(
+InputFilePaths[ModuleMapIndex], IncludePaths, CommandLine,
+ModMap.get());
 std::error_code LocalEC = Checker->doChecks();
 if (LocalEC.value() > 0)
   EC = LocalEC;


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


[PATCH] D15227: [analyzer] Valist checkers.

2017-02-10 Thread Anna Zaks via Phabricator via cfe-commits
zaks.anna added a comment.

@xazax.hun,

Can we move this out of alpha?

Have this checkers been tested on a large codebase? What are false positive 
rates?

Thanks!
Anna


Repository:
  rL LLVM

https://reviews.llvm.org/D15227



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


[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

2017-02-10 Thread Richard Smith via Phabricator via cfe-commits
rsmith added a comment.

Looks good, though there are some `value_type` constructors left. I've not 
checked the standard to see if they are all declared with `charT`.




Comment at: include/string:782
 _LIBCPP_INLINE_VISIBILITY
 basic_string(const value_type* __s, size_type __n);
 _LIBCPP_INLINE_VISIBILITY

Did you skip this one intentionally?



Comment at: include/string:788
 _LIBCPP_INLINE_VISIBILITY
 basic_string(size_type __n, value_type __c, const allocator_type& __a);
 basic_string(const basic_string& __str, size_type __pos, size_type __n,

Likewise these two.



Comment at: include/string:812
 _LIBCPP_INLINE_VISIBILITY
 basic_string(initializer_list __il, const allocator_type& __a);
 #endif  // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS

And these


https://reviews.llvm.org/D29863



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


[PATCH] D29863: [libc++] Fix PR 31938 - std::basic_string constructors use non-deductible parameter types.

2017-02-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF created this revision.

This patch fixes http://llvm.org/PR31938. The description below is copy/pasted 
from the bug:

The standard says:

template,

  class Allocator = allocator>

class basic_string {

  using value_type = typename traits::char_type;
  // ...
  basic_string(const charT* s, const Allocator& a = Allocator());

};

libc++ actually chooses to declare the constructor as

  basic_string(const value_type* s, const Allocator& a = Allocator());

The implicit deduction guides from class template argument deduction make what 
was previously an implementation detail visible:

std::basic_string s = "foo"; // error, can't deduce charT.

The constructor in question is in the libc++ DSO, but fortunately it looks like 
fixing this will not result in an ABI break.

@rsmith How does this look? I did more than just the constructors mentioned in 
the PR, but IDK how far to take it.


https://reviews.llvm.org/D29863

Files:
  include/string
  test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp

Index: test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
===
--- /dev/null
+++ test/std/strings/basic.string/string.cons/implicit_deduction_guides.pass.cpp
@@ -0,0 +1,59 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+
+// UNSUPPORTED: c++98, c++03, c++11, c++14
+
+// Clang does not implement deduction guides yet.
+// XFAIL: clang, apple-clang
+
+// 
+
+// Test that the constructors offered by std::basic_string are formulated
+// so they're compatible with implicit deduction guides.
+
+#include 
+#include 
+
+#include "test_macros.h"
+#include "test_allocator.h"
+
+
+template >
+using BStr = std::basic_string, Alloc>;
+
+
+int main()
+{
+  {
+std::basic_string s = "hello world";
+std::basic_string w(L"hello world");
+
+ASSERT_SAME_TYPE(decltype(s), std::basic_string);
+ASSERT_SAME_TYPE(decltype(w), std::basic_string);
+  }
+  {
+std::basic_string s("hello world", test_allocator{});
+ASSERT_SAME_TYPE(decltype(s), BStr>);
+  }
+  {
+std::basic_string s("hello world", 2ull, test_allocator{});
+std::basic_string w(L"hello world", 2ull, test_allocator{});
+ASSERT_SAME_TYPE(decltype(s), BStr>);
+ASSERT_SAME_TYPE(decltype(w), BStr>);
+
+  }
+  {
+std::string const s1;
+std::basic_string s(s1);
+ASSERT_SAME_TYPE(decltype(s), std::string);
+
+std::basic_string w = std::wstring{};
+ASSERT_SAME_TYPE(decltype(w), std::wstring);
+  }
+}
Index: include/string
===
--- include/string
+++ include/string
@@ -775,13 +775,13 @@
 _LIBCPP_INLINE_VISIBILITY
 basic_string(basic_string&& __str, const allocator_type& __a);
 #endif  // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-_LIBCPP_INLINE_VISIBILITY basic_string(const value_type* __s);
+_LIBCPP_INLINE_VISIBILITY basic_string(const _CharT* __s);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(const value_type* __s, const allocator_type& __a);
+basic_string(const _CharT* __s, const _Allocator& __a);
 _LIBCPP_INLINE_VISIBILITY
 basic_string(const value_type* __s, size_type __n);
 _LIBCPP_INLINE_VISIBILITY
-basic_string(const value_type* __s, size_type __n, const allocator_type& __a);
+basic_string(const _CharT* __s, size_type __n, const _Allocator& __a);
 _LIBCPP_INLINE_VISIBILITY
 basic_string(size_type __n, value_type __c);
 _LIBCPP_INLINE_VISIBILITY
@@ -1557,7 +1557,7 @@
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s)
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s)
 {
 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*) detected nullptr");
 __init(__s, traits_type::length(__s));
@@ -1568,7 +1568,7 @@
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, const allocator_type& __a)
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, const _Allocator& __a)
 : __r_(__a)
 {
 _LIBCPP_ASSERT(__s != nullptr, "basic_string(const char*, allocator) detected nullptr");
@@ -1591,7 +1591,7 @@
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
-basic_string<_CharT, _Traits, _Allocator>::basic_string(const value_type* __s, size_type __n, const allocator_type& __a)
+basic_string<_CharT, _Traits, _Allocator>::basic_string(const _CharT* __s, size_type __n, const _Allocator& __a)
 : __r_(__a)
 {
 _LIBCPP_ASSERT(__n == 0 || __s != nullptr, "basic_string(const char*, n, allocator) detecte

[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk updated this revision to Diff 88075.
vsk edited the summary of this revision.
vsk added a reviewer: arphaman.
vsk added a comment.

- Check 'this' once per method. This supports the partial sanitization use-case.
- Flesh out the predicate for avoiding null checks on object pointers. I 
couldn't use isImplicitCXXThis like I'd wanted, because we'd like to catch 
explicit this exprs as well.


https://reviews.llvm.org/D29530

Files:
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGExprCXX.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/catch-undef-behavior.c
  test/CodeGen/sanitize-recover.c
  test/CodeGenCXX/ubsan-suppress-null-checks.cpp

Index: test/CodeGenCXX/ubsan-suppress-null-checks.cpp
===
--- /dev/null
+++ test/CodeGenCXX/ubsan-suppress-null-checks.cpp
@@ -0,0 +1,135 @@
+// RUN: %clang_cc1 -std=c++11 -triple x86_64-apple-darwin10 -emit-llvm -o - %s -fsanitize=null | FileCheck %s
+
+struct A {
+  int foo;
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11load_memberEv
+  int load_member() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return foo;
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A11call_methodEv
+  int call_method() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_1Ev
+  void assign_member_1() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZN1A15assign_member_2Ev
+  void assign_member_2() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+(__extension__ (this))->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr void @_ZNK1A15assign_member_3Ev
+  void assign_member_3() const {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+const_cast(this)->foo = 0;
+// CHECK: ret void
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A22call_through_referenceERS_
+  static int call_through_reference(A &a) {
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return a.load_member();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1A20call_through_pointerEPS_
+  static int call_through_pointer(A *a) {
+// CHECK: call void @__ubsan_handle_type_mismatch
+return a->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct B {
+  operator A*() const { return nullptr; }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN1B11load_memberEv
+  static int load_member() {
+// Null-check &b before converting it to an A*.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// Null-check the result of the conversion before using it.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+B b;
+return static_cast(b)->load_member();
+// CHECK: ret i32
+  }
+};
+
+struct Base {
+  int foo;
+
+  virtual int load_member_1() = 0;
+};
+
+struct Derived : public Base {
+  int bar;
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_2Ev
+  int load_member_2() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// Null-check the result of the cast before using it.
+// CHECK: call void @__ubsan_handle_type_mismatch
+//
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return dynamic_cast(this)->load_member_1();
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_3Ev
+  int load_member_3() {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return reinterpret_cast(static_cast(this))->foo;
+// CHECK: ret i32
+  }
+
+  // CHECK-LABEL: define linkonce_odr i32 @_ZN7Derived13load_member_1Ev
+  int load_member_1() override {
+// CHECK: call void @__ubsan_handle_type_mismatch
+// CHECK-NOT: call void @__ubsan_handle_type_mismatch
+return foo + bar;
+// CHECK: ret i32
+  }
+};
+
+void force_irgen() {
+  A *a;
+  a->load_member();
+  a->call_method();
+  a->assign_member_1();
+  a->assign_member_2();
+  a->assign_member_3();
+  A::call_through_reference(*a);
+  A::call_through_pointer(a);
+
+  B::load_member();
+
+  Base *b = new Derived;
+  b->load_member_1();
+
+  Derived *d;
+  d->load_member_2();
+  d->load_member_3();
+}
Index: test/CodeGen/sanitize-recover.c
===
--- test/CodeGen/sanitize-recover.c
+++ test/CodeGen/sa

[PATCH] D29859: Make Lit tests C++11 compatible - nounwind noexcept

2017-02-10 Thread John McCall via Phabricator via cfe-commits
rjmccall accepted this revision.
rjmccall added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D29859



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


r294820 - Update XFAIL line after r294781.

2017-02-10 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Feb 10 20:00:03 2017
New Revision: 294820

URL: http://llvm.org/viewvc/llvm-project?rev=294820&view=rev
Log:
Update XFAIL line after r294781.

Modified:
cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c

Modified: cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c?rev=294820&r1=294819&r2=294820&view=diff
==
--- cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c (original)
+++ cfe/trunk/test/Driver/XRay/xray-instrument-cpu.c Fri Feb 10 20:00:03 2017
@@ -1,4 +1,4 @@
 // RUN: not %clang -o /dev/null -v -fxray-instrument -c %s
-// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64
+// XFAIL: amd64-, x86_64-, x86_64h-, arm, aarch64, arm64, powerpc64le-
 // REQUIRES: linux
 typedef int a;


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


[PATCH] D29859: Make Lit tests C++11 compatible - nounwind noexcept

2017-02-10 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge created this revision.

I am continuing to make Lit tests C++11 compatible.
There are 3 tests in this patch (previously in https://reviews.llvm.org/D24812).
All 3 tests relate to C++11 destructors being nonthrowing by default.

CodeGenCXX/linetable-cleanup.cpp

  C::~C() has an extra “nounwind” attribute in C++11.
  Relaxed the CHECK pattern matching for possible existence of “ #[0-9]”.

IR:

  C++98: call void @_ZN1CD1Ev(%class.C* %c), !dbg !21
  C++11: call void @_ZN1CD1Ev(%class.C* %c) #2, !dbg !21
 attributes #2 = { nounwind }

CodeGenCXX/lpad-linetable.cpp

  The purpose of this test is to verify landingpad line numbers when catching
  any exceptions thrown by the destructors for “longs” and “shorts” as they go 
out of scope.
  In C++11, “longs” and “short”’s destructors are nonthrowing, so no landingpad 
is generated.
  And since the purpose of this test is to verify for landingpad line table, I 
have restricted this test to C++98.
  
  C++11 IR:
 ~std::_Vector_base >() noexcept
 ~std::_Vector_base >() noexcept 

Index/comment-cplus-decls.cpp

  In C++11, ~Test() is nonthrowing.
  IR:
C++98: ~Test()
C++11: ~Test() noexcept


https://reviews.llvm.org/D29859

Files:
  test/CodeGenCXX/linetable-cleanup.cpp
  test/CodeGenCXX/lpad-linetable.cpp
  test/Index/comment-cplus-decls.cpp


Index: test/Index/comment-cplus-decls.cpp
===
--- test/Index/comment-cplus-decls.cpp
+++ test/Index/comment-cplus-decls.cpp
@@ -2,9 +2,15 @@
 // RUN: mkdir %t
 // RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 %s > %t/out
 // RUN: FileCheck %s < %t/out
+// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 -std=c++98 %s > %t/98
+// RUN: FileCheck %s < %t/98
+// RUN: c-index-test -test-load-source all 
-comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target 
x86_64-apple-darwin10 -std=c++11 %s > %t/11
+// RUN: FileCheck %s < %t/11
 
 // Ensure that XML we generate is not invalid.
 // RUN: FileCheck %s -check-prefix=WRONG < %t/out
+// RUN: FileCheck %s -check-prefix=WRONG < %t/98
+// RUN: FileCheck %s -check-prefix=WRONG < %t/11
 // WRONG-NOT: CommentXMLInvalid
 // rdar://12378714
 
@@ -42,7 +48,7 @@
 // CHECK: class Test {}
 // CHECK: Test() : reserved(new Test::data()) {}
 // CHECK: unsigned int getID() const
-// CHECK: ~Test()
+// CHECK: ~Test(){{( noexcept)?}}
 // CHECK: Test::data *reserved
 
 
Index: test/CodeGenCXX/lpad-linetable.cpp
===
--- test/CodeGenCXX/lpad-linetable.cpp
+++ test/CodeGenCXX/lpad-linetable.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm 
-debug-info-kind=limited -triple x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1  -fcxx-exceptions -fexceptions -emit-llvm 
-debug-info-kind=limited -triple x86_64-apple-darwin10 -std=c++98 %s -o - | 
FileCheck %s
 // The landing pad should have the line number of the closing brace of the 
function.
 // rdar://problem/13888152
 // CHECK: ret i32
Index: test/CodeGenCXX/linetable-cleanup.cpp
===
--- test/CodeGenCXX/linetable-cleanup.cpp
+++ test/CodeGenCXX/linetable-cleanup.cpp
@@ -1,10 +1,12 @@
 // RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 -std=c++98 %s -o - | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin10 -std=c++11 %s -o - | FileCheck %s
 
 // Check the line numbers for cleanup code with EH in combination with
 // simple return expressions.
 
 // CHECK: define {{.*}}foo
-// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}), !dbg ![[RET:[0-9]+]]
+// CHECK: call void @_ZN1CD1Ev(%class.C* {{.*}}){{( #[0-9])?}}, !dbg 
![[RET:[0-9]+]]
 // CHECK: ret i32 0, !dbg ![[RET]]
 
 // CHECK: define {{.*}}bar


Index: test/Index/comment-cplus-decls.cpp
===
--- test/Index/comment-cplus-decls.cpp
+++ test/Index/comment-cplus-decls.cpp
@@ -2,9 +2,15 @@
 // RUN: mkdir %t
 // RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 %s > %t/out
 // RUN: FileCheck %s < %t/out
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++98 %s > %t/98
+// RUN: FileCheck %s < %t/98
+// RUN: c-index-test -test-load-source all -comments-xml-schema=%S/../../bindings/xml/comment-xml-schema.rng -target x86_64-apple-darwin10 -std=c++11 %s > %t/11
+// RUN: FileCheck %s < %t/11
 
 // Ensure that XML we genera

r294815 - Move test include file from include/ to Inputs/

2017-02-10 Thread Richard Trieu via cfe-commits
Author: rtrieu
Date: Fri Feb 10 18:52:01 2017
New Revision: 294815

URL: http://llvm.org/viewvc/llvm-project?rev=294815&view=rev
Log:
Move test include file from include/ to Inputs/

The Inputs/ directory is the recommended location for extra files for test
cases.  No functional change.

Added:
cfe/trunk/test/CodeGen/Inputs/debug-info-macro.h
  - copied unchanged from r294802, 
cfe/trunk/test/CodeGen/include/debug-info-macro.h
Removed:
cfe/trunk/test/CodeGen/include/debug-info-macro.h
Modified:
cfe/trunk/test/CodeGen/debug-info-macro.c

Modified: cfe/trunk/test/CodeGen/debug-info-macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/debug-info-macro.c?rev=294815&r1=294814&r2=294815&view=diff
==
--- cfe/trunk/test/CodeGen/debug-info-macro.c (original)
+++ cfe/trunk/test/CodeGen/debug-info-macro.c Fri Feb 10 18:52:01 2017
@@ -1,10 +1,10 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=line-tables-only 
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/include/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,NO_PCH %s 
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited  
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/include/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,NO_PCH %s 
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone   
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/include/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,NO_PCH %s 
-// RUN: %clang_cc1 -emit-llvm   
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/include/debug-info-macro.h -UC1 | FileCheck -check-prefixes=NO_MACRO %s 
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=line-tables-only 
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/Inputs/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,NO_PCH %s 
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited  
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/Inputs/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,NO_PCH %s 
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=standalone   
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/Inputs/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,NO_PCH %s 
+// RUN: %clang_cc1 -emit-llvm   
-debug-info-macro %s -o - "-DC1(x)=( x  + 5 )" -DA -include 
%S/Inputs/debug-info-macro.h -UC1 | FileCheck -check-prefixes=NO_MACRO %s 
 
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -debug-info-macro 
%S/include/debug-info-macro.h -emit-pch -o %t.pch -DC3
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -debug-info-macro %s -o 
- -include-pch %t.pch "-DC1(x)=( x  + 5 )" -DA -include 
%S/include/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,PCH %s 
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -debug-info-macro 
%S/Inputs/debug-info-macro.h -emit-pch -o %t.pch -DC3
+// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -debug-info-macro %s -o 
- -include-pch %t.pch "-DC1(x)=( x  + 5 )" -DA -include 
%S/Inputs/debug-info-macro.h -UC1 | FileCheck -check-prefixes=CHECK,PCH %s 
 
 // This test checks that macro Debug info is correctly generated.
 
@@ -13,10 +13,10 @@
 
 #line 15
 /*Line 15*/ #define D1 1
-/*Line 16*/ #include  "include/debug-info-macro.h"
+/*Line 16*/ #include  "Inputs/debug-info-macro.h"
 /*Line 17*/ #undef D1
 /*Line 18*/ #define D2 2
-/*Line 19*/ #include  "include/debug-info-macro.h"
+/*Line 19*/ #include  "Inputs/debug-info-macro.h"
 /*Line 20*/ #undef D2
 
 // NO_MACRO-NOT: macros

Removed: cfe/trunk/test/CodeGen/include/debug-info-macro.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/include/debug-info-macro.h?rev=294814&view=auto
==
--- cfe/trunk/test/CodeGen/include/debug-info-macro.h (original)
+++ cfe/trunk/test/CodeGen/include/debug-info-macro.h (removed)
@@ -1,12 +0,0 @@
-
-#ifdef D1
-/*Line 3*/ #define A(x, y, z) (x)
-#endif
-
-#ifdef D2
-/*Line 7*/ #define A(x, y, z) (y)
-#endif
-
-#ifdef A
-/*Line 11*/ #undef A
-#endif


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


Re: r294800 - Don't let EvaluationModes dictate whether an invalid base is OK

2017-02-10 Thread Hans Wennborg via cfe-commits
Sgtm. Go ahead and merge when the bots have chewed on it for a bit,
otherwise I'll do it next week.

Thanks,
Hans

On Fri, Feb 10, 2017 at 3:06 PM, George Burgess IV
 wrote:
> Hi Hans!
>
> This fixes PR31843, which is a release blocker. Once the bots seem happy
> with it, can we merge this into the 4.0 branch, please?
>
> (Richard okayed this when he LGTM'ed the patch)
>
> Thanks,
> George
>
> On Fri, Feb 10, 2017 at 2:52 PM, George Burgess IV via cfe-commits
>  wrote:
>>
>> Author: gbiv
>> Date: Fri Feb 10 16:52:29 2017
>> New Revision: 294800
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=294800&view=rev
>> Log:
>> Don't let EvaluationModes dictate whether an invalid base is OK
>>
>> What we want to actually control this behavior is something more local
>> than an EvalutationMode. Please see the linked revision for more
>> discussion on why/etc.
>>
>> This fixes PR31843.
>>
>> Differential Revision: https://reviews.llvm.org/D29469
>>
>> Modified:
>> cfe/trunk/lib/AST/ExprConstant.cpp
>> cfe/trunk/test/CodeGen/object-size.c
>> cfe/trunk/test/Sema/builtin-object-size.c
>>
>> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=294800&r1=294799&r2=294800&view=diff
>>
>> ==
>> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
>> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb 10 16:52:29 2017
>> @@ -616,10 +616,12 @@ namespace {
>>/// gets a chance to look at it.
>>EM_PotentialConstantExpressionUnevaluated,
>>
>> -  /// Evaluate as a constant expression. Continue evaluating if
>> either:
>> -  /// - We find a MemberExpr with a base that can't be evaluated.
>> -  /// - We find a variable initialized with a call to a function that
>> has
>> -  ///   the alloc_size attribute on it.
>> +  /// Evaluate as a constant expression. In certain scenarios, if:
>> +  /// - we find a MemberExpr with a base that can't be evaluated, or
>> +  /// - we find a variable initialized with a call to a function that
>> has
>> +  ///   the alloc_size attribute on it
>> +  /// then we may consider evaluation to have succeeded.
>> +  ///
>>/// In either case, the LValue returned shall have an invalid base;
>> in the
>>/// former, the base will be the invalid MemberExpr, in the latter,
>> the
>>/// base will be either the alloc_size CallExpr or a CastExpr
>> wrapping
>> @@ -902,10 +904,6 @@ namespace {
>>return KeepGoing;
>>  }
>>
>> -bool allowInvalidBaseExpr() const {
>> -  return EvalMode == EM_OffsetFold;
>> -}
>> -
>>  class ArrayInitLoopIndex {
>>EvalInfo &Info;
>>uint64_t OuterIndex;
>> @@ -1416,8 +1414,10 @@ static bool Evaluate(APValue &Result, Ev
>>  static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
>>  const LValue &This, const Expr *E,
>>  bool AllowNonLiteralTypes = false);
>> -static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo
>> &Info);
>> -static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo
>> &Info);
>> +static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
>> +   bool InvalidBaseOK = false);
>> +static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo
>> &Info,
>> +bool InvalidBaseOK = false);
>>  static bool EvaluateMemberPointer(const Expr *E, MemberPtr &Result,
>>EvalInfo &Info);
>>  static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo
>> &Info);
>> @@ -4835,6 +4835,7 @@ class LValueExprEvaluatorBase
>>: public ExprEvaluatorBase {
>>  protected:
>>LValue &Result;
>> +  bool InvalidBaseOK;
>>typedef LValueExprEvaluatorBase LValueExprEvaluatorBaseTy;
>>typedef ExprEvaluatorBase ExprEvaluatorBaseTy;
>>
>> @@ -4843,9 +4844,14 @@ protected:
>>  return true;
>>}
>>
>> +  bool evaluatePointer(const Expr *E, LValue &Result) {
>> +return EvaluatePointer(E, Result, this->Info, InvalidBaseOK);
>> +  }
>> +
>>  public:
>> -  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result) :
>> -ExprEvaluatorBaseTy(Info), Result(Result) {}
>> +  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result, bool
>> InvalidBaseOK)
>> +  : ExprEvaluatorBaseTy(Info), Result(Result),
>> +InvalidBaseOK(InvalidBaseOK) {}
>>
>>bool Success(const APValue &V, const Expr *E) {
>>  Result.setFrom(this->Info.Ctx, V);
>> @@ -4857,7 +4863,7 @@ public:
>>  QualType BaseTy;
>>  bool EvalOK;
>>  if (E->isArrow()) {
>> -  EvalOK = EvaluatePointer(E->getBase(), Result, this->Info);
>> +  EvalOK = evaluatePointer(E->getBase(), Result);
>>BaseTy =
>> E->getBase()->getType()->castAs()->getPointeeType();
>>  } else if (E->getBase()->isRValue()) {
>>assert(E-

[PATCH] D29858: [clang-tidy] Catch trivially true statements like a != 1 || a != 3

2017-02-10 Thread Blaise Watson via Phabricator via cfe-commits
watsond created this revision.
Herald added a subscriber: JDevlieghere.

Catch trivially true statements of the form a != 1 || a != 3. Statements like
these are likely errors. They are particularly easy to miss when handling enums:

enum State {
RUNNING,
STOPPED,
STARTING,
ENDING
}

...
if (state != RUNNING || state != STARTING)
...


https://reviews.llvm.org/D29858

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  test/clang-tidy/misc-redundant-expression.cpp


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always 
true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;
+
   return false;
 }
 


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;
+
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29857: Catch trivially true statements of the form a != 1 || a != 3. Statements likethese are likely errors. They are particularly easy to miss when handling enums:enum State {RUNNING, STOPPE

2017-02-10 Thread Blaise Watson via Phabricator via cfe-commits
watsond abandoned this revision.
watsond added a comment.

Apologies all. I messed up the formatting. Resubmitting in a second.


https://reviews.llvm.org/D29857



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


[PATCH] D29857: Catch trivially true statements of the form a != 1 || a != 3. Statements likethese are likely errors. They are particularly easy to miss when handling enums:enum State {RUNNING, STOPPE

2017-02-10 Thread Blaise Watson via Phabricator via cfe-commits
watsond updated this revision to Diff 88072.
watsond added a comment.



Updating D29857: Catch trivially true statements of the form a != 1 || a != 3. 
Statements like
==

these are likely errors. They are particularly easy to miss when handling enums:

enum State {
RUNNING,
STOPPED,
STARTING,
ENDING
}

...
if (state != RUNNING || state !=...


https://reviews.llvm.org/D29857

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  test/clang-tidy/misc-redundant-expression.cpp


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always 
true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;
+
   return false;
 }
 


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;
+
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29857: Catch trivially true statements of the form a != 1 || a != 3. Statements likethese are likely errors. They are particularly easy to miss when handling enums:enum State {RUNNING, STOPPE

2017-02-10 Thread Blaise Watson via Phabricator via cfe-commits
watsond created this revision.

...ENDING)
...

[clang-tidy] Catch trivially true statements like a != 1 || a != 3


https://reviews.llvm.org/D29857

Files:
  clang-tidy/misc/RedundantExpressionCheck.cpp
  test/clang-tidy/misc-redundant-expression.cpp


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always 
true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always 
true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;
+
   return false;
 }
 


Index: test/clang-tidy/misc-redundant-expression.cpp
===
--- test/clang-tidy/misc-redundant-expression.cpp
+++ test/clang-tidy/misc-redundant-expression.cpp
@@ -321,6 +321,8 @@
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
   if (X <= 10 || X >= 11) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: logical expression is always true
+  if (X != 7 || X != 14) return 1;
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: logical expression is always true
 
   if (X < 7 && X < 6) return 1;
   // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: expression is redundant
Index: clang-tidy/misc/RedundantExpressionCheck.cpp
===
--- clang-tidy/misc/RedundantExpressionCheck.cpp
+++ clang-tidy/misc/RedundantExpressionCheck.cpp
@@ -239,6 +239,11 @@
   (OpcodeRHS == BO_LT || OpcodeRHS == BO_LE))
 return true;
 
+  // Handle cases where constants are different but both ops are !=, like:
+  // x != 5 || x != 10
+  if (OpcodeLHS == BO_NE || OpcodeLHS == BO_NE)
+return true;
+
   return false;
 }
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek accepted this revision.
phosek added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D29843



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


[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr updated this revision to Diff 88068.
mcgrathr added a comment.

This now passes check-clang.


https://reviews.llvm.org/D29843

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/global-init.cpp
  test/OpenMP/threadprivate_codegen.cpp


Index: test/OpenMP/threadprivate_codegen.cpp
===
--- test/OpenMP/threadprivate_codegen.cpp
+++ test/OpenMP/threadprivate_codegen.cpp
@@ -176,7 +176,7 @@
 // CHECK-TLS-DAG:  [[ST_S4_ST:@.+]] = linkonce_odr thread_local global 
%struct.S4 zeroinitializer
 // CHECK-TLS-DAG:  [[ST_S4_ST_GUARD:@_ZGVN2STI2S4E2stE]] = linkonce_odr 
thread_local global i64 0
 // CHECK-TLS-DAG:  @__tls_guard = internal thread_local global i8 0
-// CHECK-TLS-DAG:  @__dso_handle = external global i8
+// CHECK-TLS-DAG:  @__dso_handle = external hidden global i8
 // CHECK-TLS-DAG:  [[GS1_TLS_INIT:@_ZTHL3gs1]] = internal alias void (), void 
()* @__tls_init
 // CHECK-TLS-DAG:  [[ARR_X_TLS_INIT:@_ZTH5arr_x]] = alias void (), void ()* 
@__tls_init
 
Index: test/CodeGenCXX/global-init.cpp
===
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -15,7 +15,7 @@
 
 struct D { ~D(); };
 
-// CHECK: @__dso_handle = external global i8
+// CHECK: @__dso_handle = external hidden global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
 // PR6205: The casts should not require global initializers
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2162,7 +2162,7 @@
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle", true);
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -916,7 +916,8 @@
   llvm::AttributeSet());
   /// Create a new runtime global variable with the specified type and name.
   llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
-StringRef Name);
+StringRef Name,
+bool Hidden = false);
 
   ///@name Custom Blocks Runtime Interfaces
   ///@{
@@ -1220,7 +1221,8 @@
 llvm::PointerType *PTy,
 const VarDecl *D,
 ForDefinition_t IsForDefinition
-  = NotForDefinition);
+  = NotForDefinition,
+bool Hidden = false);
 
   void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2183,7 +2183,8 @@
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
  const VarDecl *D,
- ForDefinition_t IsForDefinition) {
+ ForDefinition_t IsForDefinition,
+ bool Hidden) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -2288,6 +2289,8 @@
 D->getType().isConstant(Context) &&
 isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
   GV->setSection(".cp.rodata");
+  } else if (Hidden) {
+GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
   }
 
   if (AddrSpace != Ty->getAddressSpace())
@@ -2393,8 +2396,10 @@
 /// specified type and name.
 llvm::Constant *
 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
- StringRef Name) {
-  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 
nullptr);
+ StringRef Name,
+ bool Hidden) {
+  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr,
+   NotForDefinition, Hidden);
 }
 
 void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {


Index: test/OpenMP/threadprivate_codegen.cpp
===
--- test/OpenMP/threadprivate_codegen.cpp
+++ test/OpenMP/threadprivate_codegen.cpp
@@ -176,7 +176,7 @@
 // CHECK-TLS-DAG:  [[ST_

[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr updated this revision to Diff 88067.

https://reviews.llvm.org/D29843

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp
  test/CodeGenCXX/global-init.cpp
  test/OpenMP/threadprivate_codegen.cpp


Index: test/OpenMP/threadprivate_codegen.cpp
===
--- test/OpenMP/threadprivate_codegen.cpp
+++ test/OpenMP/threadprivate_codegen.cpp
@@ -176,7 +176,7 @@
 // CHECK-TLS-DAG:  [[ST_S4_ST:@.+]] = linkonce_odr thread_local global 
%struct.S4 zeroinitializer
 // CHECK-TLS-DAG:  [[ST_S4_ST_GUARD:@_ZGVN2STI2S4E2stE]] = linkonce_odr 
thread_local global i64 0
 // CHECK-TLS-DAG:  @__tls_guard = internal thread_local global i8 0
-// CHECK-TLS-DAG:  @__dso_handle = external global i8
+// CHECK-TLS-DAG:  @__dso_handle = external hidden global i8
 // CHECK-TLS-DAG:  [[GS1_TLS_INIT:@_ZTHL3gs1]] = internal alias void (), void 
()* @__tls_init
 // CHECK-TLS-DAG:  [[ARR_X_TLS_INIT:@_ZTH5arr_x]] = alias void (), void ()* 
@__tls_init
 
Index: test/CodeGenCXX/global-init.cpp
===
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -15,7 +15,7 @@
 
 struct D { ~D(); };
 
-// CHECK: @__dso_handle = external global i8
+// CHECK: @__dso_handle = external hidden global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
 // PR6205: The casts should not require global initializers
Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2162,7 +2162,7 @@
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle", true);
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -916,7 +916,8 @@
   llvm::AttributeSet());
   /// Create a new runtime global variable with the specified type and name.
   llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
-StringRef Name);
+StringRef Name,
+bool Hidden = false);
 
   ///@name Custom Blocks Runtime Interfaces
   ///@{
@@ -1220,7 +1221,8 @@
 llvm::PointerType *PTy,
 const VarDecl *D,
 ForDefinition_t IsForDefinition
-  = NotForDefinition);
+  = NotForDefinition,
+bool Hidden = false);
 
   void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2183,7 +2183,8 @@
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
  const VarDecl *D,
- ForDefinition_t IsForDefinition) {
+ ForDefinition_t IsForDefinition,
+ bool Hidden) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -2288,6 +2289,8 @@
 D->getType().isConstant(Context) &&
 isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
   GV->setSection(".cp.rodata");
+  } else if (Hidden) {
+GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
   }
 
   if (AddrSpace != Ty->getAddressSpace())
@@ -2393,8 +2396,10 @@
 /// specified type and name.
 llvm::Constant *
 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
- StringRef Name) {
-  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 
nullptr);
+ StringRef Name,
+ bool Hidden) {
+  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr,
+   NotForDefinition, Hidden);
 }
 
 void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {


Index: test/OpenMP/threadprivate_codegen.cpp
===
--- test/OpenMP/threadprivate_codegen.cpp
+++ test/OpenMP/threadprivate_codegen.cpp
@@ -176,7 +176,7 @@
 // CHECK-TLS-DAG:  [[ST_S4_ST:@.+]] = linkonce_odr thread_local global %struct.S4

[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

You can use `ninja check-clang` to run Clang tests, if those pass you can use 
`ninja check-all` to run all tests. Testing guide 
 has details about testing in LLVM.


https://reviews.llvm.org/D29843



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


[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr added a comment.

This was just the first crack, my first attempt at any change in LLVMland.  I 
don't know how to run the tests yet.


https://reviews.llvm.org/D29843



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


[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

Did you run all tests? I'd suspect that this might break 
`test/OpenMP/threadprivate_codegen.cpp` which is expecting `@__dso_handle = 
external global i8` which will now be `hidden global`?


https://reviews.llvm.org/D29843



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


r294802 - [c++1z] Tests for class template argument deduction in dependent contexts.

2017-02-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 10 17:10:17 2017
New Revision: 294802

URL: http://llvm.org/viewvc/llvm-project?rev=294802&view=rev
Log:
[c++1z] Tests for class template argument deduction in dependent contexts.

Modified:
cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp

Modified: cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp?rev=294802&r1=294801&r2=294802&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp 
(original)
+++ cfe/trunk/test/SemaCXX/cxx1z-class-template-argument-deduction.cpp Fri Feb 
10 17:10:17 2017
@@ -87,3 +87,33 @@ namespace deprecated {
   [[deprecated]] A(int) -> A; // expected-note {{marked deprecated here}}
   A a = 0; // expected-warning {{'' is deprecated}}
 }
+
+namespace dependent {
+  template typename A> decltype(auto) a = A{1, 2, 3};
+  static_assert(has_type>(a));
+  static_assert(has_type>(a));
+
+  struct B {
+template struct X { X(T); };
+X(int) -> X;
+template using Y = X; // expected-note {{template}}
+  };
+  template void f() {
+typename T::X tx = 0;
+typename T::Y ty = 0; // expected-error {{alias template 'Y' requires 
template arguments; argument deduction only allowed for class templates}}
+  }
+  template void f(); // expected-note {{in instantiation of}}
+
+  template struct C { C(T); };
+  template C(T) -> C;
+  template void g(T a) {
+C b = 0;
+C c = a;
+using U = decltype(b); // expected-note {{previous}}
+using U = decltype(c); // expected-error {{different types ('C' vs 'C')}}
+  }
+  void h() {
+g(0);
+g("foo"); // expected-note {{instantiation of}}
+  }
+}


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


[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Roland McGrath via Phabricator via cfe-commits
mcgrathr updated this revision to Diff 88064.

https://reviews.llvm.org/D29843

Files:
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/ItaniumCXXABI.cpp


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2162,7 +2162,7 @@
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle", true);
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -916,7 +916,8 @@
   llvm::AttributeSet());
   /// Create a new runtime global variable with the specified type and name.
   llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
-StringRef Name);
+StringRef Name,
+bool Hidden = false);
 
   ///@name Custom Blocks Runtime Interfaces
   ///@{
@@ -1220,7 +1221,8 @@
 llvm::PointerType *PTy,
 const VarDecl *D,
 ForDefinition_t IsForDefinition
-  = NotForDefinition);
+  = NotForDefinition,
+bool Hidden = false);
 
   void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *GO);
 
Index: lib/CodeGen/CodeGenModule.cpp
===
--- lib/CodeGen/CodeGenModule.cpp
+++ lib/CodeGen/CodeGenModule.cpp
@@ -2183,7 +2183,8 @@
 CodeGenModule::GetOrCreateLLVMGlobal(StringRef MangledName,
  llvm::PointerType *Ty,
  const VarDecl *D,
- ForDefinition_t IsForDefinition) {
+ ForDefinition_t IsForDefinition,
+ bool Hidden) {
   // Lookup the entry, lazily creating it if necessary.
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);
   if (Entry) {
@@ -2288,6 +2289,8 @@
 D->getType().isConstant(Context) &&
 isExternallyVisible(D->getLinkageAndVisibility().getLinkage()))
   GV->setSection(".cp.rodata");
+  } else if (Hidden) {
+GV->setVisibility(llvm::GlobalValue::HiddenVisibility);
   }
 
   if (AddrSpace != Ty->getAddressSpace())
@@ -2393,8 +2396,10 @@
 /// specified type and name.
 llvm::Constant *
 CodeGenModule::CreateRuntimeVariable(llvm::Type *Ty,
- StringRef Name) {
-  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), 
nullptr);
+ StringRef Name,
+ bool Hidden) {
+  return GetOrCreateLLVMGlobal(Name, llvm::PointerType::getUnqual(Ty), nullptr,
+   NotForDefinition, Hidden);
 }
 
 void CodeGenModule::EmitTentativeDefinition(const VarDecl *D) {


Index: lib/CodeGen/ItaniumCXXABI.cpp
===
--- lib/CodeGen/ItaniumCXXABI.cpp
+++ lib/CodeGen/ItaniumCXXABI.cpp
@@ -2162,7 +2162,7 @@
 
   // Create a variable that binds the atexit to this shared object.
   llvm::Constant *handle =
-CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle");
+CGF.CGM.CreateRuntimeVariable(CGF.Int8Ty, "__dso_handle", true);
 
   llvm::Value *args[] = {
 llvm::ConstantExpr::getBitCast(dtor, dtorTy),
Index: lib/CodeGen/CodeGenModule.h
===
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -916,7 +916,8 @@
   llvm::AttributeSet());
   /// Create a new runtime global variable with the specified type and name.
   llvm::Constant *CreateRuntimeVariable(llvm::Type *Ty,
-StringRef Name);
+StringRef Name,
+bool Hidden = false);
 
   ///@name Custom Blocks Runtime Interfaces
   ///@{
@@ -1220,7 +1221,8 @@
 llvm::PointerType *PTy,
 const VarDecl *D,
 ForDefinition_t IsForDefinition
-  = NotForDefinition);
+  = NotForDefinition,
+bool Hidden = false);
 
   void setNonAliasAttributes(const Decl *D, llvm::GlobalObject *

[PATCH] D29843: [CodeGen] Treat auto-generated __dso_handle symbol as HiddenVisibility

2017-02-10 Thread Petr Hosek via Phabricator via cfe-commits
phosek added a comment.

In https://reviews.llvm.org/D29843#674111, @mcgrathr wrote:

> This is for clang, not llvm.  Should it be cfe-commits instead of 
> llvm-commits?


Right, my mistake.


https://reviews.llvm.org/D29843



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


Re: r294800 - Don't let EvaluationModes dictate whether an invalid base is OK

2017-02-10 Thread George Burgess IV via cfe-commits
Hi Hans!

This fixes PR31843, which is a release blocker. Once the bots seem happy
with it, can we merge this into the 4.0 branch, please?

(Richard okayed this when he LGTM'ed the patch)

Thanks,
George

On Fri, Feb 10, 2017 at 2:52 PM, George Burgess IV via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: gbiv
> Date: Fri Feb 10 16:52:29 2017
> New Revision: 294800
>
> URL: http://llvm.org/viewvc/llvm-project?rev=294800&view=rev
> Log:
> Don't let EvaluationModes dictate whether an invalid base is OK
>
> What we want to actually control this behavior is something more local
> than an EvalutationMode. Please see the linked revision for more
> discussion on why/etc.
>
> This fixes PR31843.
>
> Differential Revision: https://reviews.llvm.org/D29469
>
> Modified:
> cfe/trunk/lib/AST/ExprConstant.cpp
> cfe/trunk/test/CodeGen/object-size.c
> cfe/trunk/test/Sema/builtin-object-size.c
>
> Modified: cfe/trunk/lib/AST/ExprConstant.cpp
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprCo
> nstant.cpp?rev=294800&r1=294799&r2=294800&view=diff
> 
> ==
> --- cfe/trunk/lib/AST/ExprConstant.cpp (original)
> +++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb 10 16:52:29 2017
> @@ -616,10 +616,12 @@ namespace {
>/// gets a chance to look at it.
>EM_PotentialConstantExpressionUnevaluated,
>
> -  /// Evaluate as a constant expression. Continue evaluating if
> either:
> -  /// - We find a MemberExpr with a base that can't be evaluated.
> -  /// - We find a variable initialized with a call to a function that
> has
> -  ///   the alloc_size attribute on it.
> +  /// Evaluate as a constant expression. In certain scenarios, if:
> +  /// - we find a MemberExpr with a base that can't be evaluated, or
> +  /// - we find a variable initialized with a call to a function that
> has
> +  ///   the alloc_size attribute on it
> +  /// then we may consider evaluation to have succeeded.
> +  ///
>/// In either case, the LValue returned shall have an invalid base;
> in the
>/// former, the base will be the invalid MemberExpr, in the latter,
> the
>/// base will be either the alloc_size CallExpr or a CastExpr
> wrapping
> @@ -902,10 +904,6 @@ namespace {
>return KeepGoing;
>  }
>
> -bool allowInvalidBaseExpr() const {
> -  return EvalMode == EM_OffsetFold;
> -}
> -
>  class ArrayInitLoopIndex {
>EvalInfo &Info;
>uint64_t OuterIndex;
> @@ -1416,8 +1414,10 @@ static bool Evaluate(APValue &Result, Ev
>  static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
>  const LValue &This, const Expr *E,
>  bool AllowNonLiteralTypes = false);
> -static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info);
> -static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo
> &Info);
> +static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
> +   bool InvalidBaseOK = false);
> +static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
> +bool InvalidBaseOK = false);
>  static bool EvaluateMemberPointer(const Expr *E, MemberPtr &Result,
>EvalInfo &Info);
>  static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo
> &Info);
> @@ -4835,6 +4835,7 @@ class LValueExprEvaluatorBase
>: public ExprEvaluatorBase {
>  protected:
>LValue &Result;
> +  bool InvalidBaseOK;
>typedef LValueExprEvaluatorBase LValueExprEvaluatorBaseTy;
>typedef ExprEvaluatorBase ExprEvaluatorBaseTy;
>
> @@ -4843,9 +4844,14 @@ protected:
>  return true;
>}
>
> +  bool evaluatePointer(const Expr *E, LValue &Result) {
> +return EvaluatePointer(E, Result, this->Info, InvalidBaseOK);
> +  }
> +
>  public:
> -  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result) :
> -ExprEvaluatorBaseTy(Info), Result(Result) {}
> +  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result, bool
> InvalidBaseOK)
> +  : ExprEvaluatorBaseTy(Info), Result(Result),
> +InvalidBaseOK(InvalidBaseOK) {}
>
>bool Success(const APValue &V, const Expr *E) {
>  Result.setFrom(this->Info.Ctx, V);
> @@ -4857,7 +4863,7 @@ public:
>  QualType BaseTy;
>  bool EvalOK;
>  if (E->isArrow()) {
> -  EvalOK = EvaluatePointer(E->getBase(), Result, this->Info);
> +  EvalOK = evaluatePointer(E->getBase(), Result);
>BaseTy = E->getBase()->getType()->castA
> s()->getPointeeType();
>  } else if (E->getBase()->isRValue()) {
>assert(E->getBase()->getType()->isRecordType());
> @@ -4868,7 +4874,7 @@ public:
>BaseTy = E->getBase()->getType();
>  }
>  if (!EvalOK) {
> -  if (!this->Info.allowInvalidBaseExpr())
> +  if (!InvalidBaseOK)
>  return false;
>Result.setInvalid(E);
>  

[PATCH] D29469: Fix PR31843: Clang-4.0 crashes/assert while evaluating __builtin_object_size

2017-02-10 Thread George Burgess IV via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294800: Don't let EvaluationModes dictate whether an invalid 
base is OK (authored by gbiv).

Changed prior to commit:
  https://reviews.llvm.org/D29469?vs=86870&id=88061#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29469

Files:
  cfe/trunk/lib/AST/ExprConstant.cpp
  cfe/trunk/test/CodeGen/object-size.c
  cfe/trunk/test/Sema/builtin-object-size.c

Index: cfe/trunk/lib/AST/ExprConstant.cpp
===
--- cfe/trunk/lib/AST/ExprConstant.cpp
+++ cfe/trunk/lib/AST/ExprConstant.cpp
@@ -616,10 +616,12 @@
   /// gets a chance to look at it.
   EM_PotentialConstantExpressionUnevaluated,
 
-  /// Evaluate as a constant expression. Continue evaluating if either:
-  /// - We find a MemberExpr with a base that can't be evaluated.
-  /// - We find a variable initialized with a call to a function that has
-  ///   the alloc_size attribute on it.
+  /// Evaluate as a constant expression. In certain scenarios, if:
+  /// - we find a MemberExpr with a base that can't be evaluated, or
+  /// - we find a variable initialized with a call to a function that has
+  ///   the alloc_size attribute on it
+  /// then we may consider evaluation to have succeeded.
+  ///
   /// In either case, the LValue returned shall have an invalid base; in the
   /// former, the base will be the invalid MemberExpr, in the latter, the
   /// base will be either the alloc_size CallExpr or a CastExpr wrapping
@@ -902,10 +904,6 @@
   return KeepGoing;
 }
 
-bool allowInvalidBaseExpr() const {
-  return EvalMode == EM_OffsetFold;
-}
-
 class ArrayInitLoopIndex {
   EvalInfo &Info;
   uint64_t OuterIndex;
@@ -1416,8 +1414,10 @@
 static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
 const LValue &This, const Expr *E,
 bool AllowNonLiteralTypes = false);
-static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info);
-static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info);
+static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
+   bool InvalidBaseOK = false);
+static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
+bool InvalidBaseOK = false);
 static bool EvaluateMemberPointer(const Expr *E, MemberPtr &Result,
   EvalInfo &Info);
 static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info);
@@ -4835,17 +4835,23 @@
   : public ExprEvaluatorBase {
 protected:
   LValue &Result;
+  bool InvalidBaseOK;
   typedef LValueExprEvaluatorBase LValueExprEvaluatorBaseTy;
   typedef ExprEvaluatorBase ExprEvaluatorBaseTy;
 
   bool Success(APValue::LValueBase B) {
 Result.set(B);
 return true;
   }
 
+  bool evaluatePointer(const Expr *E, LValue &Result) {
+return EvaluatePointer(E, Result, this->Info, InvalidBaseOK);
+  }
+
 public:
-  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result) :
-ExprEvaluatorBaseTy(Info), Result(Result) {}
+  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result, bool InvalidBaseOK)
+  : ExprEvaluatorBaseTy(Info), Result(Result),
+InvalidBaseOK(InvalidBaseOK) {}
 
   bool Success(const APValue &V, const Expr *E) {
 Result.setFrom(this->Info.Ctx, V);
@@ -4857,7 +4863,7 @@
 QualType BaseTy;
 bool EvalOK;
 if (E->isArrow()) {
-  EvalOK = EvaluatePointer(E->getBase(), Result, this->Info);
+  EvalOK = evaluatePointer(E->getBase(), Result);
   BaseTy = E->getBase()->getType()->castAs()->getPointeeType();
 } else if (E->getBase()->isRValue()) {
   assert(E->getBase()->getType()->isRecordType());
@@ -4868,7 +4874,7 @@
   BaseTy = E->getBase()->getType();
 }
 if (!EvalOK) {
-  if (!this->Info.allowInvalidBaseExpr())
+  if (!InvalidBaseOK)
 return false;
   Result.setInvalid(E);
   return true;
@@ -4962,8 +4968,8 @@
 class LValueExprEvaluator
   : public LValueExprEvaluatorBase {
 public:
-  LValueExprEvaluator(EvalInfo &Info, LValue &Result) :
-LValueExprEvaluatorBaseTy(Info, Result) {}
+  LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
+LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
 
   bool VisitVarDecl(const Expr *E, const VarDecl *VD);
   bool VisitUnaryPreIncDec(const UnaryOperator *UO);
@@ -5016,10 +5022,11 @@
 ///  * function designators in C, and
 ///  * "extern void" objects
 ///  * @selector() expressions in Objective-C
-static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info) {
+static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
+   bool InvalidBaseOK) {
   assert(E->isGLValue() || E->getType()->isFunctionType() ||
  E->getType()->isVoidTy

[PATCH] D29469: Fix PR31843: Clang-4.0 crashes/assert while evaluating __builtin_object_size

2017-02-10 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv marked an inline comment as done.
george.burgess.iv added a comment.

Thanks!


https://reviews.llvm.org/D29469



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


r294800 - Don't let EvaluationModes dictate whether an invalid base is OK

2017-02-10 Thread George Burgess IV via cfe-commits
Author: gbiv
Date: Fri Feb 10 16:52:29 2017
New Revision: 294800

URL: http://llvm.org/viewvc/llvm-project?rev=294800&view=rev
Log:
Don't let EvaluationModes dictate whether an invalid base is OK

What we want to actually control this behavior is something more local
than an EvalutationMode. Please see the linked revision for more
discussion on why/etc.

This fixes PR31843.

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

Modified:
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/test/CodeGen/object-size.c
cfe/trunk/test/Sema/builtin-object-size.c

Modified: cfe/trunk/lib/AST/ExprConstant.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ExprConstant.cpp?rev=294800&r1=294799&r2=294800&view=diff
==
--- cfe/trunk/lib/AST/ExprConstant.cpp (original)
+++ cfe/trunk/lib/AST/ExprConstant.cpp Fri Feb 10 16:52:29 2017
@@ -616,10 +616,12 @@ namespace {
   /// gets a chance to look at it.
   EM_PotentialConstantExpressionUnevaluated,
 
-  /// Evaluate as a constant expression. Continue evaluating if either:
-  /// - We find a MemberExpr with a base that can't be evaluated.
-  /// - We find a variable initialized with a call to a function that has
-  ///   the alloc_size attribute on it.
+  /// Evaluate as a constant expression. In certain scenarios, if:
+  /// - we find a MemberExpr with a base that can't be evaluated, or
+  /// - we find a variable initialized with a call to a function that has
+  ///   the alloc_size attribute on it
+  /// then we may consider evaluation to have succeeded.
+  ///
   /// In either case, the LValue returned shall have an invalid base; in 
the
   /// former, the base will be the invalid MemberExpr, in the latter, the
   /// base will be either the alloc_size CallExpr or a CastExpr wrapping
@@ -902,10 +904,6 @@ namespace {
   return KeepGoing;
 }
 
-bool allowInvalidBaseExpr() const {
-  return EvalMode == EM_OffsetFold;
-}
-
 class ArrayInitLoopIndex {
   EvalInfo &Info;
   uint64_t OuterIndex;
@@ -1416,8 +1414,10 @@ static bool Evaluate(APValue &Result, Ev
 static bool EvaluateInPlace(APValue &Result, EvalInfo &Info,
 const LValue &This, const Expr *E,
 bool AllowNonLiteralTypes = false);
-static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info);
-static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info);
+static bool EvaluateLValue(const Expr *E, LValue &Result, EvalInfo &Info,
+   bool InvalidBaseOK = false);
+static bool EvaluatePointer(const Expr *E, LValue &Result, EvalInfo &Info,
+bool InvalidBaseOK = false);
 static bool EvaluateMemberPointer(const Expr *E, MemberPtr &Result,
   EvalInfo &Info);
 static bool EvaluateTemporary(const Expr *E, LValue &Result, EvalInfo &Info);
@@ -4835,6 +4835,7 @@ class LValueExprEvaluatorBase
   : public ExprEvaluatorBase {
 protected:
   LValue &Result;
+  bool InvalidBaseOK;
   typedef LValueExprEvaluatorBase LValueExprEvaluatorBaseTy;
   typedef ExprEvaluatorBase ExprEvaluatorBaseTy;
 
@@ -4843,9 +4844,14 @@ protected:
 return true;
   }
 
+  bool evaluatePointer(const Expr *E, LValue &Result) {
+return EvaluatePointer(E, Result, this->Info, InvalidBaseOK);
+  }
+
 public:
-  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result) :
-ExprEvaluatorBaseTy(Info), Result(Result) {}
+  LValueExprEvaluatorBase(EvalInfo &Info, LValue &Result, bool InvalidBaseOK)
+  : ExprEvaluatorBaseTy(Info), Result(Result),
+InvalidBaseOK(InvalidBaseOK) {}
 
   bool Success(const APValue &V, const Expr *E) {
 Result.setFrom(this->Info.Ctx, V);
@@ -4857,7 +4863,7 @@ public:
 QualType BaseTy;
 bool EvalOK;
 if (E->isArrow()) {
-  EvalOK = EvaluatePointer(E->getBase(), Result, this->Info);
+  EvalOK = evaluatePointer(E->getBase(), Result);
   BaseTy = 
E->getBase()->getType()->castAs()->getPointeeType();
 } else if (E->getBase()->isRValue()) {
   assert(E->getBase()->getType()->isRecordType());
@@ -4868,7 +4874,7 @@ public:
   BaseTy = E->getBase()->getType();
 }
 if (!EvalOK) {
-  if (!this->Info.allowInvalidBaseExpr())
+  if (!InvalidBaseOK)
 return false;
   Result.setInvalid(E);
   return true;
@@ -4962,8 +4968,8 @@ namespace {
 class LValueExprEvaluator
   : public LValueExprEvaluatorBase {
 public:
-  LValueExprEvaluator(EvalInfo &Info, LValue &Result) :
-LValueExprEvaluatorBaseTy(Info, Result) {}
+  LValueExprEvaluator(EvalInfo &Info, LValue &Result, bool InvalidBaseOK) :
+LValueExprEvaluatorBaseTy(Info, Result, InvalidBaseOK) {}
 
   bool VisitVarDecl(const Expr *E, const VarDecl *VD);
   bool VisitUnaryPreIncDec(const UnaryOperator *UO);
@@ -5016,10 +5022,11 @@ public:
 ///  * function desig

[libcxx] r294798 - Fix a bug I introduced in the tests for experimental::lcm and experimental::gcd.

2017-02-10 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Feb 10 16:44:14 2017
New Revision: 294798

URL: http://llvm.org/viewvc/llvm-project?rev=294798&view=rev
Log:
Fix a bug I introduced in the tests for experimental::lcm and experimental::gcd.

Modified:

libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp

libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp

Modified: 
libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp?rev=294798&r1=294797&r2=294798&view=diff
==
--- 
libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
 Fri Feb 10 16:44:14 2017
@@ -132,7 +132,7 @@ int main()
 
 //  LWG#2792
 {
-auto res = std::gcd((int64_t)1234, (int32_t)-2147483648);
+auto res = std::experimental::gcd((int64_t)1234, (int32_t)-2147483648);
 static_assert( std::is_same::type>::value, "");
 assert(res == 2);
 }

Modified: 
libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp?rev=294798&r1=294797&r2=294798&view=diff
==
--- 
libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
 (original)
+++ 
libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
 Fri Feb 10 16:44:14 2017
@@ -131,8 +131,8 @@ int main()
 
 //  LWG#2792
 {
-auto res1 = std::lcm((int64_t)1234, (int32_t)-2147483648);
-(void) std::lcm(INT_MIN, 2);   // this used to trigger 
UBSAN
+auto res1 = std::experimental::lcm((int64_t)1234, (int32_t)-2147483648);
+(void) std::experimental::lcm(INT_MIN, 2); // this 
used to trigger UBSAN
 static_assert( std::is_same::type>::value, "");
assert(res1 == 1324997410816LL);
 }


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


r294796 - [c++1z] Diagnose attempts to use variables with deduced class template

2017-02-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 10 16:35:37 2017
New Revision: 294796

URL: http://llvm.org/viewvc/llvm-project?rev=294796&view=rev
Log:
[c++1z] Diagnose attempts to use variables with deduced class template
specialization types from within their own initializers.

Added:
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1z.cpp
Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
cfe/trunk/test/Sema/auto-type.c
cfe/trunk/test/SemaCXX/cxx1y-deduced-return-type.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=294796&r1=294795&r2=294796&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 10 16:35:37 
2017
@@ -1861,8 +1861,8 @@ def warn_cxx98_compat_auto_type_specifie
   "'auto' type specifier is incompatible with C++98">,
   InGroup, DefaultIgnore;
 def err_auto_variable_cannot_appear_in_own_initializer : Error<
-  "variable %0 declared with %select{'auto'|'decltype(auto)'|'__auto_type'}1 "
-  "type cannot appear in its own initializer">;
+  "variable %0 declared with deduced type %1 "
+  "cannot appear in its own initializer">;
 def err_binding_cannot_appear_in_own_initializer : Error<
   "binding %0 cannot appear in the initializer of its own "
   "decomposition declaration">;

Modified: cfe/trunk/include/clang/Sema/DeclSpec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/DeclSpec.h?rev=294796&r1=294795&r2=294796&view=diff
==
--- cfe/trunk/include/clang/Sema/DeclSpec.h (original)
+++ cfe/trunk/include/clang/Sema/DeclSpec.h Fri Feb 10 16:35:37 2017
@@ -519,7 +519,7 @@ public:
   SourceRange getTypeofParensRange() const { return TypeofParensRange; }
   void setTypeofParensRange(SourceRange range) { TypeofParensRange = range; }
 
-  bool containsPlaceholderType() const {
+  bool hasAutoTypeSpec() const {
 return (TypeSpecType == TST_auto || TypeSpecType == TST_auto_type ||
 TypeSpecType == TST_decltype_auto);
   }

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=294796&r1=294795&r2=294796&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 10 16:35:37 2017
@@ -6120,7 +6120,7 @@ NamedDecl *Sema::ActOnVariableDeclarator
 D.getIdentifierLoc(), II,
 R, TInfo, SC);
 
-if (D.getDeclSpec().containsPlaceholderType() && R->getContainedAutoType())
+if (R->getContainedDeducedType())
   ParsingInitForAutoVars.insert(NewVD);
 
 if (D.isInvalidType())
@@ -6256,7 +6256,7 @@ NamedDecl *Sema::ActOnVariableDeclarator
 
 // If this decl has an auto type in need of deduction, make a note of the
 // Decl so we can diagnose uses of it in its own initializer.
-if (D.getDeclSpec().containsPlaceholderType() && R->getContainedAutoType())
+if (R->getContainedDeducedType())
   ParsingInitForAutoVars.insert(NewVD);
 
 if (D.isInvalidType() || Invalid) {
@@ -11202,7 +11202,7 @@ Sema::DeclGroupPtrTy Sema::FinalizeDecla
   FirstDeclaratorInGroup = DD;
 if (!FirstDecompDeclaratorInGroup)
   FirstDecompDeclaratorInGroup = dyn_cast(D);
-if (!FirstNonDeducedAutoInGroup && DS.containsPlaceholderType() &&
+if (!FirstNonDeducedAutoInGroup && DS.hasAutoTypeSpec() &&
 !hasDeducedAuto(DD))
   FirstNonDeducedAutoInGroup = DD;
 
@@ -11935,7 +11935,7 @@ bool Sema::canDelayFunctionBody(const De
 
   // We can't delay parsing the body of a function template with a deduced
   // return type (yet).
-  if (D.getDeclSpec().containsPlaceholderType()) {
+  if (D.getDeclSpec().hasAutoTypeSpec()) {
 // If the placeholder introduces a non-deduced trailing return type,
 // we can still delay parsing it.
 if (D.getNumTypeObjects()) {

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=294796&r1=294795&r2=294796&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Feb 10 16:35:37 2017
@@ -333,10 +333,8 @@ bool Sema::DiagnoseUseOfDecl(NamedDecl *
   Diag(Lo

[PATCH] D29469: Fix PR31843: Clang-4.0 crashes/assert while evaluating __builtin_object_size

2017-02-10 Thread Richard Smith via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, I think this is also OK for Clang 4 if Hans is willing to take it.




Comment at: lib/AST/ExprConstant.cpp:607-612
+  /// Evaluate as a constant expression. In certain scenarios, if:
+  /// - We find a MemberExpr with a base that can't be evaluated, or
   /// - We find a variable initialized with a call to a function that has
-  ///   the alloc_size attribute on it.
+  ///   the alloc_size attribute on it
+  ///
+  /// Then we may consider evaluation to have succeeded.

[nit] "We", "We", "Then" should not be capitalized, and please remove blank 
line prior to "Then we [...]"


https://reviews.llvm.org/D29469



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


[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.

2017-02-10 Thread Joerg Sonnenberger via Phabricator via cfe-commits
joerg added a comment.

Please fix the spelling errors in the titel / summary before commit.

I somewhat agree with Hal -- I think this is too aggressive. Common use cases 
for local volatile include atomic ops or returns-twice functions like 
setjmp/longjmp.
Disabling the warning in those cases has a high chance of hiding real problems. 
I would find it much more useful to move this case into a warning subgroup, so 
that
it can be selectively disabled by command line or pragma.


https://reviews.llvm.org/D28543



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


[PATCH] D29851: [clang-tools-extra] [test] Fix test dependencies when using installed tools

2017-02-10 Thread Michał Górny via Phabricator via cfe-commits
mgorny created this revision.
mgorny added a project: clang-tools-extra.

Use the LLVM_UTILS_PROVIDED variable to determine whether test tool
dependencies should be exposed for clang-tools-extra tests. If clang is
being built stand-alone and LLVM test tools (FileCheck, count and not)
are installed, the top-level CMakeLists.txt of clang sets this variable
to indicate that they will not be built as a part of this build,
and therefore no dependencies should be emitted for them. This fixes
the dependency errors when building clang stand-alone with tests
enabled.


Repository:
  rL LLVM

https://reviews.llvm.org/D29851

Files:
  test/CMakeLists.txt


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -31,9 +31,6 @@
 endif()
 
 set(CLANG_TOOLS_TEST_DEPS
-  # Base line deps.
-  FileCheck count not
-
   # clang-tidy tests require it.
   clang-headers
 
@@ -58,6 +55,13 @@
   ExtraToolsUnitTests
   )
 
+if(NOT LLVM_UTILS_PROVIDED)
+  list(APPEND CLANG_TOOLS_TEST_DEPS
+# Base line deps.
+FileCheck count not
+)
+endif()
+
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression 
tests"
   ${CMAKE_CURRENT_BINARY_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}


Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -31,9 +31,6 @@
 endif()
 
 set(CLANG_TOOLS_TEST_DEPS
-  # Base line deps.
-  FileCheck count not
-
   # clang-tidy tests require it.
   clang-headers
 
@@ -58,6 +55,13 @@
   ExtraToolsUnitTests
   )
 
+if(NOT LLVM_UTILS_PROVIDED)
+  list(APPEND CLANG_TOOLS_TEST_DEPS
+# Base line deps.
+FileCheck count not
+)
+endif()
+
 add_lit_testsuite(check-clang-tools "Running the Clang extra tools' regression tests"
   ${CMAKE_CURRENT_BINARY_DIR}
   DEPENDS ${CLANG_TOOLS_TEST_DEPS}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D28835: [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.

2017-02-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF added a comment.

This LGTM after applying the fixes.




Comment at: lib/Sema/SemaCoroutine.cpp:719
+
+  if (!PromiseRecordDecl)
+return true;

I figured out what's going on. `PromiseRecordDecl` doesn't get initialized to 
null when `IsPromiseDependentType` is false. Initializing `PromiseRecordDecl` 
fixes the problem.


https://reviews.llvm.org/D28835



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


[PATCH] D29827: [AVR] Add -mmcu option to the driver

2017-02-10 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added inline comments.



Comment at: include/clang/Driver/Options.td:1613
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group;
+def mmcu_EQ : Joined<["-"], "mmcu=">, Group;
 def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group;

dylanmckay wrote:
> Lekensteyn wrote:
> > jroelofs wrote:
> > > Would it make sense to have mcu be an alias for mcpu instead?
> > That would deviate from the GCC interface, so I have chosen for the current 
> > situation:
> > ```
> > $ avr-gcc -mmcu=avr2 -o /dev/null x.c
> > $ avr-gcc -mcpu=avr2 -o /dev/null x.c
> > avr-gcc: error: unrecognized command line option '-mcpu=avr2'
> > $ avr-gcc -march=avr2 -o /dev/null x.c
> > avr-gcc: error: unrecognized command line option '-march=avr2'
> > $ avr-gcc -v
> > ...
> > gcc version 6.3.0 (GCC)
> > ```
> I think @jroelofs  means that it is possible to make `mmcu` an alias of 
> `mmcu` internally. This would mean we wouldn't need to add AVR-specific 
> `getCPUName` handling.
If mmcu is made an alias of mcpu, wouldn't that mean that both `-mcpu` and 
`-mmcu` would be accepted by driver (undesirable)?
As far as I can see, `-target-cpu` must be passed to the frontend and 
assembler, `-mcpu=` is not recognized as option. And ensuring that `getCPUName` 
returns a non-empty string ensures that `-target-cpu` is passed.

I am quite new to the internals, so please let me know if I misunderstood 
something :-)


https://reviews.llvm.org/D29827



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


[PATCH] D28835: [coroutines] NFC: Refactor Sema::CoroutineBodyStmt construction.

2017-02-10 Thread Eric Fiselier via Phabricator via cfe-commits
EricWF requested changes to this revision.
EricWF added a comment.
This revision now requires changes to proceed.

This currently segfaults on my machine. Here is the full output of running 
`SemaCXX/coroutines.cpp`.
https://gist.github.com/EricWF/81dc332e21c3e5c6bdc024cda87b846f

I'm not sure exactly what's going on, but it should be fixed before committing.


https://reviews.llvm.org/D28835



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


[PATCH] D29827: [AVR] Add -mmcu option to the driver

2017-02-10 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added inline comments.



Comment at: include/clang/Driver/Options.td:1613
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group;
+def mmcu_EQ : Joined<["-"], "mmcu=">, Group;
 def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group;

Lekensteyn wrote:
> jroelofs wrote:
> > Would it make sense to have mcu be an alias for mcpu instead?
> That would deviate from the GCC interface, so I have chosen for the current 
> situation:
> ```
> $ avr-gcc -mmcu=avr2 -o /dev/null x.c
> $ avr-gcc -mcpu=avr2 -o /dev/null x.c
> avr-gcc: error: unrecognized command line option '-mcpu=avr2'
> $ avr-gcc -march=avr2 -o /dev/null x.c
> avr-gcc: error: unrecognized command line option '-march=avr2'
> $ avr-gcc -v
> ...
> gcc version 6.3.0 (GCC)
> ```
I think @jroelofs  means that it is possible to make `mmcu` an alias of `mmcu` 
internally. This would mean we wouldn't need to add AVR-specific `getCPUName` 
handling.


https://reviews.llvm.org/D29827



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


[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

In https://reviews.llvm.org/D29739#673933, @tigerleapgorge wrote:

> Hi John,
>
> Here is the most recent discussion I can find on cfe-dev.
>  “I'm guessing that Objective-C/C++ is kind of passe, so nobody is really 
> interested in modernizing it”
>  http://lists.llvm.org/pipermail/cfe-dev/2016-December/051844.html
>
> As far as I am aware, there appears to be no strong reason to bump or not to 
> bump ObjC++.


It certainly simplifies the message to say that we've changed the default C++ 
dialect to C++11 across the board.  That should apply to ObjC++ as well.  I 
would not describe ObjC++ as passé; it's a very important language for Apple 
developers.

It is likely that the Rewriter generates C++98-only code.  I believe the 
Rewriter is no longer being actively maintained; I'm not sure we're ready to 
propose removing it yet, but if there are specific problems with those tests, I 
think it makes some sense to just pass -std=gnu++98 for them.

John.


https://reviews.llvm.org/D29739



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


r294785 - [c++1z] Require an initializer for deduced class template specialization types.

2017-02-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 10 15:40:29 2017
New Revision: 294785

URL: http://llvm.org/viewvc/llvm-project?rev=294785&view=rev
Log:
[c++1z] Require an initializer for deduced class template specialization types.

It's actually meaningful and useful to allow such variables to have no
initializer, but we are strictly following the standard here until the C++
committee reaches consensus on allowing this.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p4.cpp
cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.type.class.deduct/p1.cpp
cfe/trunk/test/Parser/cxx1z-class-template-argument-deduction.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=294785&r1=294784&r2=294785&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 10 15:40:29 
2017
@@ -1893,7 +1893,7 @@ def err_dependent_deduced_tst : Error<
 def err_auto_not_allowed_var_inst : Error<
   "'auto' variable template instantiation is not allowed">;
 def err_auto_var_requires_init : Error<
-  "declaration of variable %0 with type %1 requires an initializer">;
+  "declaration of variable %0 with deduced type %1 requires an initializer">;
 def err_auto_new_requires_ctor_arg : Error<
   "new expression for type %0 requires a constructor argument">;
 def err_auto_new_list_init : Error<

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=294785&r1=294784&r2=294785&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Fri Feb 10 15:40:29 2017
@@ -9816,7 +9816,15 @@ QualType Sema::deduceVarTypeFromInitiali
   DeducedType *Deduced = Type->getContainedDeducedType();
   assert(Deduced && "deduceVarTypeFromInitializer for non-deduced type");
 
-  ArrayRef DeduceInits = Init ? ArrayRef(Init) : None;
+  // C++11 [dcl.spec.auto]p3
+  if (!Init) {
+assert(VDecl && "no init for init capture deduction?");
+Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
+  << VDecl->getDeclName() << Type;
+return QualType();
+  }
+
+  ArrayRef DeduceInits = Init;
   if (DirectInit) {
 if (auto *PL = dyn_cast_or_null(Init))
   DeduceInits = PL->exprs();
@@ -9833,14 +9841,6 @@ QualType Sema::deduceVarTypeFromInitiali
InitsCopy);
   }
 
-  // C++11 [dcl.spec.auto]p3
-  if (!Init) {
-assert(VDecl && "no init for init capture deduction?");
-Diag(VDecl->getLocation(), diag::err_auto_var_requires_init)
-  << VDecl->getDeclName() << Type;
-return QualType();
-  }
-
   if (DirectInit) {
 if (auto *IL = dyn_cast(Init))
   DeduceInits = IL->inits();

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp?rev=294785&r1=294784&r2=294785&view=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp 
(original)
+++ cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3-1y.cpp Fri 
Feb 10 15:40:29 2017
@@ -9,9 +9,9 @@ void f() {
 }
 
 void g() {
-  decltype(auto) a; // expected-error{{declaration of variable 'a' with type 
'decltype(auto)' requires an initializer}}
+  decltype(auto) a; // expected-error{{declaration of variable 'a' with 
deduced type 'decltype(auto)' requires an initializer}}
   
-  decltype(auto) *b; // expected-error{{cannot form pointer to 
'decltype(auto)'}} expected-error{{declaration of variable 'b' with type 
'decltype(auto) *' requires an initializer}}
+  decltype(auto) *b; // expected-error{{cannot form pointer to 
'decltype(auto)'}} expected-error{{declaration of variable 'b' with deduced 
type 'decltype(auto) *' requires an initializer}}
 
   if (decltype(auto) b) {} // expected-error {{must have an initializer}}
   for (;decltype(auto) b;) {} // expected-error {{must have an initializer}}

Modified: cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.type/dcl.spec.auto/p3.cpp?rev=294785&r1=294784&r2=294785&view=diff
==
--- cfe/trunk/test/CXX/dcl.dcl/dcl.spec/dcl.t

[PATCH] D29724: [Driver] Report available language standards on user error

2017-02-10 Thread Richard Smith via Phabricator via cfe-commits
rsmith added inline comments.



Comment at: include/clang/Basic/DiagnosticDriverKinds.td:233
   "AddressSanitizer doesn't support linking with debug runtime libraries yet">;
+def note_drv_supported_values : Note<"supported values are:">;
+def note_drv_supported_value_with_description : Note<"'%0' for standard '%1'">;

Please remove this note and instead add "use " to the start of the next note. 
(That is more consistent with how we add notes to other diagnostics.)



Comment at: lib/Frontend/CompilerInvocation.cpp:1709
+Diags.Report(diag::note_drv_supported_value_with_description)
+  << Std.getName() << Std.getDescription();
+  }

idlecode wrote:
> ahatanak wrote:
> > Is it possible to change the diagnostic so that it's easier to tell which 
> > part is the supported value and which part is the description?
> > 
> > The diagnostic looks like this, and I found it a little hard to tell at a 
> > quick glance:
> > 
> > "c89 - ISO C 1990" 
> Sure, I have tried few formats with quotes/colons but how about this (a bit 
> verbose) version:
> ```
> note: supported values are:
> note: 'c89' for standard 'ISO C 1990'
> note: 'c90' for standard 'ISO C 1990'
> note: 'iso9899:1990' for standard 'ISO C 1990'
> ...
> ```
> What do you think about it? Do you have any suggestions?
We should probably suppress the notes for standards that aren't applicable to 
the current language.


https://reviews.llvm.org/D29724



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


[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-10 Thread Samuel Benzaquen via Phabricator via cfe-commits
sbenza added inline comments.



Comment at: include/clang/Tooling/RefactoringCallbacks.h:61
+MatchFinder.addMatcher(Matcher, Callback);
+Callbacks.emplace_back(Callback);
+  }

jbangert wrote:
> sbenza wrote:
> > Why emplace_back instead of push_back?
> Changed to push_back.  Is there ever an advantage to using push_back over 
> emplace_back (the latter falls back to a copy constructor). 
push_back and emplace_back are equivalent when the value you are passing is 
already a T.
In that case, push_back should be used from the principle of using the least 
powerful tool that can do the job you want.
emplace_back allows for calls to explicit constructors, which makes it more 
powerful in ways that might be surprising to the reader.
Eg:

std::vector> v;
... many lines below ...
v.push_back(1);  // fails
v.emplace_back(1);  // works, but it didn't add a 1 to the vector.


https://reviews.llvm.org/D29621



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


[PATCH] D29839: [clang-tidy] New misc-istream-overflow check

2017-02-10 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad updated this revision to Diff 88048.
cryptoad added a comment.

Missing line separators.


https://reviews.llvm.org/D29839

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/IstreamOverflowCheck.cpp
  clang-tidy/misc/IstreamOverflowCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-istream-overflow.rst
  test/clang-tidy/misc-istream-overflow.cpp

Index: test/clang-tidy/misc-istream-overflow.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-istream-overflow.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s misc-istream-overflow %t
+
+// Quick mock of std::istream and what we need to test our plug-in.
+namespace std {
+struct _Setw { int _M_n; };
+inline _Setw setw(int __n) { return { __n }; }
+typedef long int streamsize;
+template
+class basic_istream {
+ public:
+  typedef basic_istream<_CharT, _Traits> __istream_type;
+  basic_istream();
+  ~basic_istream();
+  bool eof() const { return false; }
+  streamsize width() const { return _M_width; }
+  streamsize width(streamsize __wide) {
+streamsize __old = _M_width;
+_M_width = __wide;
+return __old;
+  }
+ protected:
+  streamsize _M_width;
+};
+template struct char_traits {};
+template >
+  class basic_istream;
+typedef basic_istream istream;
+  template
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
+{ return __in; }
+template
+  inline basic_istream<_CharT, _Traits>&
+  operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f)
+  {
+__is.width(__f._M_n);
+return __is;
+  }
+}
+
+void bad_1(std::istream &is) {
+  char s[8];
+  is >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: istream::operator>> used without setting width
+}
+
+void bad_2(std::istream &is) {
+  char s[8];
+  is.width(16);
+  is >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: width set for istream::operator>> (16) is greater than the destination buffer capacity (8)
+}
+
+void bad_3(std::istream &is) {
+  char s[8];
+  is >> std::setw(16) >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: width set for istream::operator>> (16) is greater than the destination buffer capacity (8)
+}
+
+// The stream's width is reset to 0 at the end of operator>>, it is typically
+// not sufficient to set it prior to a loop, but it should be set within.
+void bad_3() {
+  std::istream is;
+  char s[8];
+  is.width(8);
+  while (!is.eof()) {
+is >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: istream::operator>> used without setting width
+  }
+}
+
+void good_1(std::istream &is) {
+  char s[8];
+  is.width(8);
+  is >> s;
+}
+
+void good_2(std::istream &is) {
+  char s[8];
+  is >> std::setw(8) >> s;
+}
+
+void good_3() {
+  std::istream is;
+  char s[8];
+  while (!is.eof()) {
+is.width(8);
+is >> s;
+  }
+}
Index: docs/clang-tidy/checks/misc-istream-overflow.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-istream-overflow.rst
@@ -0,0 +1,48 @@
+.. title:: clang-tidy - misc-istream-overflow
+
+misc-istream-overflow
+=
+
+This check finds calls to ``istream::operator>>`` (and derived classes) into a
+character buffer, that haven't set previously a width. This could result in a
+buffer overflow as the function will keep on reading until it reaches a space
+or EOF. If it finds an operation setting the width of the stream, the check
+will attempt to verify that the size fits the destination buffer.
+
+There are several ways to not have this problem surface:
+
+- call the ``width`` member function prior to using ``operator>>``, this will
+  ensure that only the given number of characters will be stored in the
+  destination buffer. Note that the width of the stream is reset to 0 after
+  each call to ``operator>>``, hence it must be set repeatedly if in a loop for
+  example.
+
+- use ``std::setw``, which in turns will set the width of the stream.
+
+- use an ``std::string`` as a destination instead of a character array, as this
+  will prevent any possibility of overflow.
+
+Given:
+
+.. code-block:: c++
+
+  std::istream is;
+  char s[8];
+
+It will trigger on:
+
+.. code-block:: c++
+
+  // The stream's width hasn't been set
+  is >> s;
+
+but not on:
+
+.. code-block:: c++
+
+  // The stream's width has been set through width()
+  is.width(8);
+  is >> s;
+
+  // The stream's width has been set through std::setw()
+  is >> std::setw(8) >> s;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -66,6 +66,7 @@
misc-inaccurate-erase
misc-incorrect-roundings
misc-inefficient-algorithm
+   misc-istream-overflow
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-const
Index: clang-tidy/misc/MiscTidyModule.cpp

[PATCH] D29839: [clang-tidy] New misc-istream-overflow check

2017-02-10 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad updated this revision to Diff 88047.
cryptoad added a comment.

Addressing first batch of comments.


https://reviews.llvm.org/D29839

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/IstreamOverflowCheck.cpp
  clang-tidy/misc/IstreamOverflowCheck.h
  clang-tidy/misc/MiscTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-istream-overflow.rst
  test/clang-tidy/misc-istream-overflow.cpp

Index: test/clang-tidy/misc-istream-overflow.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-istream-overflow.cpp
@@ -0,0 +1,90 @@
+// RUN: %check_clang_tidy %s misc-istream-overflow %t
+
+// Quick mock of std::istream and what we need to test our plug-in.
+namespace std {
+struct _Setw { int _M_n; };
+inline _Setw setw(int __n) { return { __n }; }
+typedef long int streamsize;
+template
+class basic_istream {
+ public:
+  typedef basic_istream<_CharT, _Traits> __istream_type;
+  basic_istream();
+  ~basic_istream();
+  bool eof() const { return false; }
+  streamsize width() const { return _M_width; }
+  streamsize width(streamsize __wide) {
+streamsize __old = _M_width;
+_M_width = __wide;
+return __old;
+  }
+ protected:
+  streamsize _M_width;
+};
+template struct char_traits {};
+template >
+  class basic_istream;
+typedef basic_istream istream;
+  template
+basic_istream<_CharT, _Traits>&
+operator>>(basic_istream<_CharT, _Traits>& __in, _CharT* __s)
+{ return __in; }
+template
+  inline basic_istream<_CharT, _Traits>&
+  operator>>(basic_istream<_CharT, _Traits>& __is, _Setw __f)
+  {
+__is.width(__f._M_n);
+return __is;
+  }
+}
+
+void bad_1(std::istream &is) {
+  char s[8];
+  is >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: istream::operator>> used without setting width
+}
+
+void bad_2(std::istream &is) {
+  char s[8];
+  is.width(16);
+  is >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: width set for istream::operator>> (16) is greater than the destination buffer capacity (8)
+}
+
+void bad_3(std::istream &is) {
+  char s[8];
+  is >> std::setw(16) >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: width set for istream::operator>> (16) is greater than the destination buffer capacity (8)
+}
+
+// The stream's width is reset to 0 at the end of operator>>, it is typically
+// not sufficient to set it prior to a loop, but it should be set within.
+void bad_3() {
+  std::istream is;
+  char s[8];
+  is.width(8);
+  while (!is.eof()) {
+is >> s;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: istream::operator>> used without setting width
+  }
+}
+
+void good_1(std::istream &is) {
+  char s[8];
+  is.width(8);
+  is >> s;
+}
+
+void good_2(std::istream &is) {
+  char s[8];
+  is >> std::setw(8) >> s;
+}
+
+void good_3() {
+  std::istream is;
+  char s[8];
+  while (!is.eof()) {
+is.width(8);
+is >> s;
+  }
+}
Index: docs/clang-tidy/checks/misc-istream-overflow.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-istream-overflow.rst
@@ -0,0 +1,46 @@
+.. title:: clang-tidy - misc-istream-overflow
+
+misc-istream-overflow
+=
+
+This check finds calls to ``istream::operator>>`` (and derived classes) into a
+character buffer, that haven't set previously a width. This could result in a
+buffer overflow as the function will keep on reading until it reaches a space
+or EOF. If it finds an operation setting the width of the stream, the check
+will attempt to verify that the size fits the destination buffer.
+
+There are several ways to not have this problem surface:
+
+- call the ``width`` member function prior to using ``operator>>``, this will
+  ensure that only the given number of characters will be stored in the
+  destination buffer. Note that the width of the stream is reset to 0 after
+  each call to ``operator>>``, hence it must be set repeatedly if in a loop for
+  example.
+
+- use ``std::setw``, which in turns will set the width of the stream.
+
+- use an ``std::string`` as a destination instead of a character array, as this
+  will prevent any possibility of overflow.
+
+Given:
+
+.. code-block:: c++
+
+  std::istream is;
+  char s[8];
+
+It will trigger on:
+
+.. code-block:: c++
+  // The stream's width hasn't been set
+  is >> s;
+
+but not on:
+
+.. code-block:: c++
+  // The stream's width has been set through width()
+  is.width(8);
+  is >> s;
+
+  // The stream's width has been set through std::setw()
+  is >> std::setw(8) >> s;
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -66,6 +66,7 @@
misc-inaccurate-erase
misc-incorrect-roundings
misc-inefficient-algorithm
+   misc-istream-overflow
misc-macro-parentheses
misc-macro-repeated-side-effects
misc-misplaced-const
Index: clang-tidy/misc/MiscTidyModule.cpp
=

[PATCH] D29739: Make Lit tests C++11 compatible - Objective-C++

2017-02-10 Thread Charles Li via Phabricator via cfe-commits
tigerleapgorge added a comment.

Hi John,

Here is the most recent discussion I can find on cfe-dev.
“I'm guessing that Objective-C/C++ is kind of passe, so nobody is really 
interested in modernizing it”
http://lists.llvm.org/pipermail/cfe-dev/2016-December/051844.html

As far as I am aware, there appears to be no strong reason to bump or not to 
bump ObjC++.

Cheers
Charles Li


https://reviews.llvm.org/D29739



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


[PATCH] D29839: [clang-tidy] New misc-istream-overflow check

2017-02-10 Thread Kostya Kortchinsky via Phabricator via cfe-commits
cryptoad marked 5 inline comments as done.
cryptoad added inline comments.



Comment at: clang-tidy/misc/IstreamOverflowCheck.cpp:78-80
+if (!Arg->isIntegerConstantExpr(WidthSize, Context)) {
+  llvm::errs() << "Couldn't get width() size.\n";
+}

Prazek wrote:
> debug?
Oops!
I'd like to somehow keep that in there (for debug purposes). Any preferred way> 
(ifdef DEBUG or other).


Repository:
  rL LLVM

https://reviews.llvm.org/D29839



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


r294781 - [XRay] Implement powerpc64le xray.

2017-02-10 Thread Tim Shen via cfe-commits
Author: timshen
Date: Fri Feb 10 15:03:24 2017
New Revision: 294781

URL: http://llvm.org/viewvc/llvm-project?rev=294781&view=rev
Log:
[XRay] Implement powerpc64le xray.

Summary:
powerpc64 big-endian is not supported, but I believe that most logic can
be shared, except for xray_powerpc64.cc.

Also add a function InvalidateInstructionCache to xray_util.h, which is
copied from llvm/Support/Memory.cpp. I'm not sure if I need to add a unittest,
and I don't know how.

Reviewers: dberris, echristo, iteratee, kbarton, hfinkel

Subscribers: mehdi_amini, nemanjai, mgorny, llvm-commits

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

Modified:
cfe/trunk/lib/Driver/Tools.cpp

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=294781&r1=294780&r2=294781&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Fri Feb 10 15:03:24 2017
@@ -5064,6 +5064,7 @@ void Clang::ConstructJob(Compilation &C,
   case llvm::Triple::x86_64:
   case llvm::Triple::arm:
   case llvm::Triple::aarch64:
+  case llvm::Triple::ppc64le:
 // Supported.
 break;
   default:


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


[PATCH] D28543: Elliminates uninitialized warning for volitile varibles.

2017-02-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

In https://reviews.llvm.org/D28543#671953, @hfinkel wrote:

> What's the motivation for this? The placement of a local volatile variable is 
> still under the compiler's direction, and unless the address escapes, we 
> still assume we can reason about its aliasing (and, thus, whether or not it 
> is initialized).


volatile means that the value can change at any time, which might initialize 
the variable, no?


https://reviews.llvm.org/D28543



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


[PATCH] D29469: Fix PR31843: Clang-4.0 crashes/assert while evaluating __builtin_object_size

2017-02-10 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added a reviewer: nlopes.
dexonsmith added a comment.

+Nuno, who worked on objectsize in the past.


https://reviews.llvm.org/D29469



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


[libcxx] r294779 - Make lcm/gcd work better in edge cases. Fixes a UBSAN failure.

2017-02-10 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Fri Feb 10 14:49:08 2017
New Revision: 294779

URL: http://llvm.org/viewvc/llvm-project?rev=294779&view=rev
Log:
Make lcm/gcd work better in edge cases. Fixes a UBSAN failure.

Modified:
libcxx/trunk/include/experimental/numeric
libcxx/trunk/include/numeric

libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp

libcxx/trunk/test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
libcxx/trunk/test/std/numerics/numeric.ops/numeric.ops.lcm/lcm.pass.cpp

Modified: libcxx/trunk/include/experimental/numeric
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/experimental/numeric?rev=294779&r1=294778&r2=294779&view=diff
==
--- libcxx/trunk/include/experimental/numeric (original)
+++ libcxx/trunk/include/experimental/numeric Fri Feb 10 14:49:08 2017
@@ -45,18 +45,23 @@ inline namespace fundamentals_v2 {
 
 _LIBCPP_BEGIN_NAMESPACE_LFTS_V2
 
-template ::value> struct __abs;
+template ::value> struct __abs;
 
-template 
-struct __abs<_Tp, true> {
+template 
+struct __abs<_Result, _Source, true> {
 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Tp operator()(_Tp __t) const noexcept { return __t >= 0 ? __t : -__t; }
+_Result operator()(_Source __t) const noexcept
+{
+if (__t >= 0) return __t;
+if (__t == numeric_limits<_Source>::min()) return 
-static_cast<_Result>(__t);
+return -__t;
+}
 };
 
-template 
-struct __abs<_Tp, false> {
+template 
+struct __abs<_Result, _Source, false> {
 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Tp operator()(_Tp __t) const noexcept { return __t; }
+_Result operator()(_Source __t) const noexcept { return __t; }
 };
 
 
@@ -79,8 +84,8 @@ gcd(_Tp __m, _Up __n)
 static_assert((!is_same::type, bool>::value), 
"Second argument to gcd cannot be bool" );
 using _Rp = common_type_t<_Tp,_Up>;
 using _Wp = make_unsigned_t<_Rp>;
-return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Tp>()(__m)),
-  static_cast<_Wp>(__abs<_Up>()(__n;
+return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
+  static_cast<_Wp>(__abs<_Rp, _Up>()(__n;
 }
 
 template
@@ -95,8 +100,8 @@ lcm(_Tp __m, _Up __n)
 return 0;
 
 using _Rp = common_type_t<_Tp,_Up>;
-_Rp __val1 = __abs<_Tp>()(__m) / gcd(__m,__n);
-_Up __val2 = __abs<_Up>()(__n);
+_Rp __val1 = __abs<_Rp, _Tp>()(__m) / gcd(__m, __n);
+_Rp __val2 = __abs<_Rp, _Up>()(__n);
 _LIBCPP_ASSERT((numeric_limits<_Rp>::max() / __val1 > __val2), "Overflow 
in lcm");
 return __val1 * __val2;
 }

Modified: libcxx/trunk/include/numeric
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/numeric?rev=294779&r1=294778&r2=294779&view=diff
==
--- libcxx/trunk/include/numeric (original)
+++ libcxx/trunk/include/numeric Fri Feb 10 14:49:08 2017
@@ -201,18 +201,23 @@ iota(_ForwardIterator __first, _ForwardI
 
 
 #if _LIBCPP_STD_VER > 14
-template ::value> struct __abs;
+template ::value> struct __abs;
 
-template 
-struct __abs<_Tp, true> {
+template 
+struct __abs<_Result, _Source, true> {
 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Tp operator()(_Tp __t) const noexcept { return __t >= 0 ? __t : -__t; }
+_Result operator()(_Source __t) const noexcept
+{
+if (__t >= 0) return __t;
+if (__t == numeric_limits<_Source>::min()) return 
-static_cast<_Result>(__t);
+return -__t;
+}
 };
 
-template 
-struct __abs<_Tp, false> {
+template 
+struct __abs<_Result, _Source, false> {
 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
-_Tp operator()(_Tp __t) const noexcept { return __t; }
+_Result operator()(_Source __t) const noexcept { return __t; }
 };
 
 
@@ -220,7 +225,7 @@ template
 _LIBCPP_CONSTEXPR _LIBCPP_INLINE_VISIBILITY
 _Tp __gcd(_Tp __m, _Tp __n)
 {
-static_assert((!is_signed<_Tp>::value), "" );
+static_assert((!is_signed<_Tp>::value), "");
 return __n == 0 ? __m : __gcd<_Tp>(__n, __m % __n);
 }
 
@@ -235,8 +240,8 @@ gcd(_Tp __m, _Up __n)
 static_assert((!is_same::type, bool>::value), 
"Second argument to gcd cannot be bool" );
 using _Rp = common_type_t<_Tp,_Up>;
 using _Wp = make_unsigned_t<_Rp>;
-return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Tp>()(__m)),
-  static_cast<_Wp>(__abs<_Up>()(__n;
+return static_cast<_Rp>(__gcd(static_cast<_Wp>(__abs<_Rp, _Tp>()(__m)),
+  static_cast<_Wp>(__abs<_Rp, _Up>()(__n;
 }
 
 template
@@ -251,8 +256,8 @@ lcm(_Tp __m, _Up __n)
 return 0;
 
 using _Rp = common_type_t<_Tp,_Up>;
-_Rp __val1 = __abs<_Tp>()(__m) / gcd(__m,__n);
-_Up __val2 = __abs<_Up>()(__n);
+_

r294778 - [c++1z] Enforce restriction that deduction guide is declared in the same scope as its template.

2017-02-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 10 14:39:58 2017
New Revision: 294778

URL: http://llvm.org/viewvc/llvm-project?rev=294778&view=rev
Log:
[c++1z] Enforce restriction that deduction guide is declared in the same scope 
as its template.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/test/CXX/temp/temp.deduct.guide/p3.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=294778&r1=294777&r2=294778&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 10 14:39:58 
2017
@@ -1993,6 +1993,8 @@ def err_deduction_guide_name_not_class_t
   "cannot specify deduction guide for "
   "%select{|function template|variable template|alias template|"
   "template template parameter|dependent template name}0 %1">;
+def err_deduction_guide_wrong_scope : Error<
+  "deduction guide must be declared in the same scope as template %q0">;
 def err_deduction_guide_defines_function : Error<
   "deduction guide cannot have a function definition">;
 def err_deduction_guide_explicit_mismatch : Error<

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=294778&r1=294777&r2=294778&view=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Fri Feb 10 14:39:58 2017
@@ -5831,17 +5831,7 @@ public:
   /// deduction-guide declaration.
   bool isDeductionGuideName(Scope *S, const IdentifierInfo &Name,
 SourceLocation NameLoc,
-ParsedTemplateTy *Template = nullptr) {
-CXXScopeSpec SS;
-UnqualifiedId Id;
-Id.setIdentifier(&Name, NameLoc);
-TemplateTy TemplateFallback;
-bool MemberOfUnknownSpecialization;
-// FIXME: Use redeclaration lookup!
-return isTemplateName(S, SS, false, Id, ParsedType(), false,
-  Template ? *Template : TemplateFallback,
-  MemberOfUnknownSpecialization) == TNK_Type_template;
-  }
+ParsedTemplateTy *Template = nullptr);
 
   bool DiagnoseUnknownTemplateName(const IdentifierInfo &II,
SourceLocation IILoc,

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=294778&r1=294777&r2=294778&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 10 14:39:58 2017
@@ -8137,6 +8137,20 @@ struct BadSpecifierDiagnoser {
 /// grammar.
 void Sema::CheckDeductionGuideDeclarator(Declarator &D, QualType &R,
  StorageClass &SC) {
+  TemplateName GuidedTemplate = D.getName().TemplateName.get().get();
+  TemplateDecl *GuidedTemplateDecl = GuidedTemplate.getAsTemplateDecl();
+  assert(GuidedTemplateDecl && "missing template decl for deduction guide");
+
+  // C++ [temp.deduct.guide]p3:
+  //   A deduction-gide shall be declared in the same scope as the
+  //   corresponding class template.
+  if (!CurContext->getRedeclContext()->Equals(
+  GuidedTemplateDecl->getDeclContext()->getRedeclContext())) {
+Diag(D.getIdentifierLoc(), diag::err_deduction_guide_wrong_scope)
+  << GuidedTemplateDecl;
+Diag(GuidedTemplateDecl->getLocation(), diag::note_template_decl_here);
+  }
+
   auto &DS = D.getMutableDeclSpec();
   // We leave 'friend' and 'virtual' to be rejected in the normal way.
   if (DS.hasTypeSpecifier() || DS.getTypeQualifiers() ||
@@ -8196,7 +8210,6 @@ void Sema::CheckDeductionGuideDeclarator
 // Check that the return type is written as a specialization of
 // the template specified as the deduction-guide's name.
 ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
-TemplateName GuidedTemplate = D.getName().TemplateName.get().get();
 TypeSourceInfo *TSI = nullptr;
 QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
 assert(TSI && "deduction guide has valid type but invalid return type?");

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=294778&r1=294777&r2=294778&view=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Fri Feb 10 14:39:58 2017
@@ -242,6 +242,37 @@ TemplateNameKind Sema::isTemplateName(Sc
   return TemplateKi

r294773 - [c++1z] Disallow deduction guides with deduced types that don't syntactically match the template being deduced.

2017-02-10 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Fri Feb 10 13:49:50 2017
New Revision: 294773

URL: http://llvm.org/viewvc/llvm-project?rev=294773&view=rev
Log:
[c++1z] Disallow deduction guides with deduced types that don't syntactically 
match the template being deduced.

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CXX/temp/temp.deduct.guide/p3.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=294773&r1=294772&r2=294773&view=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Feb 10 13:49:50 
2017
@@ -1981,6 +1981,9 @@ def err_deduced_class_template_explicit
   "%select{constructor|deduction guide}1 for copy-list-initialization">;
 def err_deduction_guide_no_trailing_return_type : Error<
   "deduction guide declaration without trailing return type">;
+def err_deduction_guide_bad_trailing_return_type : Error<
+  "deduced type %1 of deduction guide is not %select{|written as }2"
+  "a specialization of template %0">;
 def err_deduction_guide_with_complex_decl : Error<
   "cannot specify any part of a return type in the "
   "declaration of a deduction guide">;

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=294773&r1=294772&r2=294773&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Fri Feb 10 13:49:50 2017
@@ -8192,12 +8192,46 @@ void Sema::CheckDeductionGuideDeclarator
diag::err_deduction_guide_no_trailing_return_type);
   break;
 }
+
+// Check that the return type is written as a specialization of
+// the template specified as the deduction-guide's name.
+ParsedType TrailingReturnType = Chunk.Fun.getTrailingReturnType();
+TemplateName GuidedTemplate = D.getName().TemplateName.get().get();
+TypeSourceInfo *TSI = nullptr;
+QualType RetTy = GetTypeFromParser(TrailingReturnType, &TSI);
+assert(TSI && "deduction guide has valid type but invalid return type?");
+bool AcceptableReturnType = false;
+bool MightInstantiateToSpecialization = false;
+if (auto RetTST =
+TSI->getTypeLoc().getAs()) {
+  TemplateName SpecifiedName = RetTST.getTypePtr()->getTemplateName();
+  bool TemplateMatches =
+  Context.hasSameTemplateName(SpecifiedName, GuidedTemplate);
+  if (SpecifiedName.getKind() == TemplateName::Template && TemplateMatches)
+AcceptableReturnType = true;
+  else {
+// This could still instantiate to the right type, unless we know it
+// names the wrong class template.
+auto *TD = SpecifiedName.getAsTemplateDecl();
+MightInstantiateToSpecialization = !(TD && isa(TD) 
&&
+ !TemplateMatches);
+  }
+} else if (!RetTy.hasQualifiers() && RetTy->isDependentType()) {
+  MightInstantiateToSpecialization = true;
+}
+
+if (!AcceptableReturnType) {
+  Diag(TSI->getTypeLoc().getLocStart(),
+   diag::err_deduction_guide_bad_trailing_return_type)
+<< GuidedTemplate << TSI->getType() << MightInstantiateToSpecialization
+<< TSI->getTypeLoc().getSourceRange();
+}
+
+// Keep going to check that we don't have any inner declarator pieces (we
+// could still have a function returning a pointer to a function).
 FoundFunction = true;
   }
 
-  // FIXME: Check that the return type can instantiate to a specialization of
-  // the template specified as the deduction-guide's name.
-
   if (D.isFunctionDefinition())
 Diag(D.getIdentifierLoc(), diag::err_deduction_guide_defines_function);
 }

Modified: cfe/trunk/test/CXX/temp/temp.deduct.guide/p3.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/temp/temp.deduct.guide/p3.cpp?rev=294773&r1=294772&r2=294773&view=diff
==
--- cfe/trunk/test/CXX/temp/temp.deduct.guide/p3.cpp (original)
+++ cfe/trunk/test/CXX/temp/temp.deduct.guide/p3.cpp Fri Feb 10 13:49:50 2017
@@ -32,11 +32,9 @@ template typename TT>
   TT(int) -> TT; // expected-error 2{{cannot specify deduction guide for 
template template parameter 'TT'}} expected-error {{requires an identifier}}
 };
 
-// FIXME: Even if the DR is applied as we hope, we should still warn if the
-// trailing-return-type can obviously never produce a specialization of the
-// named template.
-A(int) -> int;
-template A(T) -> T*;
+A(int) -> int; // expected-error {{deduced type 'int' of deduction guide is 
not a specialization of template 'A'}}
+template A(T) -> B; // expected-error {{deduced type

[PATCH] D29839: [clang-tidy] New misc-istream-overflow check

2017-02-10 Thread Piotr Padlewski via Phabricator via cfe-commits
Prazek added a comment.

Nice check! :)




Comment at: clang-tidy/misc/IstreamOverflowCheck.cpp:59-61
+  if (ConstType) {
+ArraySize = ConstType->getSize();
+  }

same here



Comment at: clang-tidy/misc/IstreamOverflowCheck.cpp:78-80
+if (!Arg->isIntegerConstantExpr(WidthSize, Context)) {
+  llvm::errs() << "Couldn't get width() size.\n";
+}

debug?



Comment at: clang-tidy/misc/IstreamOverflowCheck.cpp:111-116
+if (HasWidthCall && WidthSize != 0) {
+  Width = WidthSize;
+}
+if (HasSetwCall && SetwSize != 0) {
+  Width = SetwSize;
+}

please remove unnecessary braces



Comment at: clang-tidy/misc/IstreamOverflowCheck.cpp:125-132
+  if (HasSetwCall) {
+diag(SetwCall->getLocation(), "std::setw called here",
+ DiagnosticIDs::Note);
+  }
+  if (HasWidthCall) {
+diag(WidthCall->getExprLoc(), "width called here",
+ DiagnosticIDs::Note);

same here


Repository:
  rL LLVM

https://reviews.llvm.org/D29839



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


r294772 - clang-format: don't break code using __has_include, PR31908

2017-02-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Fri Feb 10 13:36:52 2017
New Revision: 294772

URL: http://llvm.org/viewvc/llvm-project?rev=294772&view=rev
Log:
clang-format: don't break code using __has_include, PR31908

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

Modified: cfe/trunk/lib/Format/FormatToken.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/FormatToken.h?rev=294772&r1=294771&r2=294772&view=diff
==
--- cfe/trunk/lib/Format/FormatToken.h (original)
+++ cfe/trunk/lib/Format/FormatToken.h Fri Feb 10 13:36:52 2017
@@ -630,6 +630,8 @@ struct AdditionalKeywords {
 kw_synchronized = &IdentTable.get("synchronized");
 kw_throws = &IdentTable.get("throws");
 kw___except = &IdentTable.get("__except");
+kw___has_include = &IdentTable.get("__has_include");
+kw___has_include_next = &IdentTable.get("__has_include_next");
 
 kw_mark = &IdentTable.get("mark");
 
@@ -656,6 +658,8 @@ struct AdditionalKeywords {
   IdentifierInfo *kw_NS_ENUM;
   IdentifierInfo *kw_NS_OPTIONS;
   IdentifierInfo *kw___except;
+  IdentifierInfo *kw___has_include;
+  IdentifierInfo *kw___has_include_next;
 
   // JavaScript keywords.
   IdentifierInfo *kw_as;

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=294772&r1=294771&r2=294772&view=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Feb 10 13:36:52 2017
@@ -684,6 +684,12 @@ private:
   if (Contexts.back().IsForEachMacro)
 Contexts.back().IsExpression = true;
   break;
+case tok::identifier:
+  if (Tok->isOneOf(Keywords.kw___has_include,
+   Keywords.kw___has_include_next)) {
+parseHasInclude();
+  }
+  break;
 default:
   break;
 }
@@ -727,6 +733,14 @@ private:
 }
   }
 
+  void parseHasInclude() {
+if (!CurrentToken || !CurrentToken->is(tok::l_paren))
+  return;
+next();  // '('
+parseIncludeDirective();
+next();  // ')'
+  }
+
   LineType parsePreprocessorDirective() {
 bool IsFirstToken = CurrentToken->IsFirst;
 LineType Type = LT_PreprocessorDirective;
@@ -777,8 +791,14 @@ private:
 default:
   break;
 }
-while (CurrentToken)
+while (CurrentToken) {
+  FormatToken *Tok = CurrentToken;
   next();
+  if (Tok->isOneOf(Keywords.kw___has_include,
+   Keywords.kw___has_include_next)) {
+parseHasInclude();
+  }
+}
 return Type;
   }
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=294772&r1=294771&r2=294772&view=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Fri Feb 10 13:36:52 2017
@@ -5364,6 +5364,11 @@ TEST_F(FormatTest, HandlesIncludeDirecti
 
   verifyFormat("#define MY_IMPORT ");
 
+  verifyFormat("#if __has_include()");
+  verifyFormat("#if __has_include_next()");
+  verifyFormat("#define F __has_include()");
+  verifyFormat("#define F __has_include_next()");
+
   // Protocol buffer definition or missing "#".
   verifyFormat("import \"a/aaa\";",
getLLVMStyleWithColumns(30));


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


[PATCH] D29724: [Driver] Report available language standards on user error

2017-02-10 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode added a comment.

Indeed, thanks :)
I ran `make check-all` and had no errors so I thought there are no tests.




Comment at: lib/Frontend/CompilerInvocation.cpp:1709
+Diags.Report(diag::note_drv_supported_value_with_description)
+  << Std.getName() << Std.getDescription();
+  }

ahatanak wrote:
> Is it possible to change the diagnostic so that it's easier to tell which 
> part is the supported value and which part is the description?
> 
> The diagnostic looks like this, and I found it a little hard to tell at a 
> quick glance:
> 
> "c89 - ISO C 1990" 
Sure, I have tried few formats with quotes/colons but how about this (a bit 
verbose) version:
```
note: supported values are:
note: 'c89' for standard 'ISO C 1990'
note: 'c90' for standard 'ISO C 1990'
note: 'iso9899:1990' for standard 'ISO C 1990'
...
```
What do you think about it? Do you have any suggestions?


https://reviews.llvm.org/D29724



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


[PATCH] D29724: [Driver] Report available language standards on user error

2017-02-10 Thread Paweł Żukowski via Phabricator via cfe-commits
idlecode updated this revision to Diff 88029.
idlecode added a comment.

Added test, changed printout style a bit (but this still needs to be checked)


https://reviews.llvm.org/D29724

Files:
  include/clang/Basic/DiagnosticDriverKinds.td
  lib/Frontend/CompilerInvocation.cpp
  test/Driver/unknown-std.c


Index: test/Driver/unknown-std.c
===
--- /dev/null
+++ test/Driver/unknown-std.c
@@ -0,0 +1,42 @@
+// RUN: not %clang %s -std=foobar -c 2>&1 | \
+// RUN: FileCheck %s
+
+// CHECK: error: invalid value 'foobar' in '-std=foobar'
+// CHECK: note: supported values are:
+// CHECK: note: 'c89' for standard 'ISO C 1990'
+// CHECK: note: 'c90' for standard 'ISO C 1990'
+// CHECK: note: 'iso9899:1990' for standard 'ISO C 1990'
+// CHECK: note: 'iso9899:199409' for standard 'ISO C 1990 with amendment 1'
+// CHECK: note: 'gnu89' for standard 'ISO C 1990 with GNU extensions'
+// CHECK: note: 'gnu90' for standard 'ISO C 1990 with GNU extensions'
+// CHECK: note: 'c99' for standard 'ISO C 1999'
+// CHECK: note: 'c9x' for standard 'ISO C 1999'
+// CHECK: note: 'iso9899:1999' for standard 'ISO C 1999'
+// CHECK: note: 'iso9899:199x' for standard 'ISO C 1999'
+// CHECK: note: 'gnu99' for standard 'ISO C 1999 with GNU extensions'
+// CHECK: note: 'gnu9x' for standard 'ISO C 1999 with GNU extensions'
+// CHECK: note: 'c11' for standard 'ISO C 2011'
+// CHECK: note: 'c1x' for standard 'ISO C 2011'
+// CHECK: note: 'iso9899:2011' for standard 'ISO C 2011'
+// CHECK: note: 'iso9899:201x' for standard 'ISO C 2011'
+// CHECK: note: 'gnu11' for standard 'ISO C 2011 with GNU extensions'
+// CHECK: note: 'gnu1x' for standard 'ISO C 2011 with GNU extensions'
+// CHECK: note: 'c++98' for standard 'ISO C++ 1998 with amendments'
+// CHECK: note: 'c++03' for standard 'ISO C++ 1998 with amendments'
+// CHECK: note: 'gnu++98' for standard 'ISO C++ 1998 with amendments and GNU 
extensions'
+// CHECK: note: 'c++0x' for standard 'ISO C++ 2011 with amendments'
+// CHECK: note: 'c++11' for standard 'ISO C++ 2011 with amendments'
+// CHECK: note: 'gnu++0x' for standard 'ISO C++ 2011 with amendments and GNU 
extensions'
+// CHECK: note: 'gnu++11' for standard 'ISO C++ 2011 with amendments and GNU 
extensions'
+// CHECK: note: 'c++1y' for standard 'ISO C++ 2014 with amendments'
+// CHECK: note: 'c++14' for standard 'ISO C++ 2014 with amendments'
+// CHECK: note: 'gnu++1y' for standard 'ISO C++ 2014 with amendments and GNU 
extensions'
+// CHECK: note: 'gnu++14' for standard 'ISO C++ 2014 with amendments and GNU 
extensions'
+// CHECK: note: 'c++1z' for standard 'Working draft for ISO C++ 2017'
+// CHECK: note: 'gnu++1z' for standard 'Working draft for ISO C++ 2017 with 
GNU extensions'
+// CHECK: note: 'cl' for standard 'OpenCL 1.0'
+// CHECK: note: 'cl1.1' for standard 'OpenCL 1.1'
+// CHECK: note: 'cl1.2' for standard 'OpenCL 1.2'
+// CHECK: note: 'cl2.0' for standard 'OpenCL 2.0'
+// CHECK: note: 'cuda' for standard 'NVIDIA CUDA(tm)'
+
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -1694,10 +1694,21 @@
   .Case(alias, LangStandard::lang_##id)
 #include "clang/Frontend/LangStandards.def"
   .Default(LangStandard::lang_unspecified);
-if (LangStd == LangStandard::lang_unspecified)
+if (LangStd == LangStandard::lang_unspecified) {
   Diags.Report(diag::err_drv_invalid_value)
 << A->getAsString(Args) << A->getValue();
-else {
+  // Report all supported standards with description.
+  Diags.Report(diag::note_drv_supported_values);
+  for (unsigned KindValue = 0;
+  KindValue != LangStandard::lang_unspecified;
+  ++KindValue)
+  {
+const LangStandard &Std = LangStandard::getLangStandardForKind(
+  static_cast(KindValue));
+Diags.Report(diag::note_drv_supported_value_with_description)
+  << Std.getName() << Std.getDescription();
+  }
+} else {
   // Valid standard, check to make sure language and standard are
   // compatible.
   const LangStandard &Std = LangStandard::getLangStandardForKind(LangStd);
Index: include/clang/Basic/DiagnosticDriverKinds.td
===
--- include/clang/Basic/DiagnosticDriverKinds.td
+++ include/clang/Basic/DiagnosticDriverKinds.td
@@ -230,6 +230,8 @@
   "The last /TC or /TP option takes precedence over earlier instances">;
 def note_drv_address_sanitizer_debug_runtime : Note<
   "AddressSanitizer doesn't support linking with debug runtime libraries yet">;
+def note_drv_supported_values : Note<"supported values are:">;
+def note_drv_supported_value_with_description : Note<"'%0' for standard '%1'">;
 
 def err_analyzer_config_no_value : Error<
   "analyzer-config option '%0' has a key but no value">;


Index: test/Driver/unknown-std.c
=

[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman requested changes to this revision.
aaron.ballman added inline comments.
This revision now requires changes to proceed.



Comment at: include/clang/Basic/Attr.td:532
+  let Spellings = [GNU<"external_source_symbol">,
+   CXX11<"gnu", "external_source_symbol">];
+  let Args = [IdentifierArgument<"language", 1>,

Is this supported by GCC? If not, it should be under the clang namespace 
instead of the gnu namespace. If it is supported by GCC, then you should just 
use a single GCC spelling.



Comment at: include/clang/Basic/AttrDocs.td:1007
+
+defined_in=\ *string-literal*
+  The name of the source container in which the declaration was defined. The

Would this hold something like a file name? If so, I worry about conflicts 
between the comma separator and a file name -- you might want to pick a 
separator that can't be used in a file name (like | or :).



Comment at: include/clang/Basic/AttrDocs.td:1015
+  This declaration was automatically generated by some tool.
+  }];
+}

Are these clauses parsed in a strict order? If so, you may want to mention that 
the order matters (or doesn't).

Also, the code in SemaDeclAttr.cpp implies that some of these are optional. It 
should be made clear which (if any) arguments are optional.



Comment at: include/clang/Basic/DiagnosticParseKinds.td:863
+def err_external_source_symbol_expected_language : Error<
+  "expected a source language , e.g., 'Swift'">;
+

I would drop the e.g. and instead describe what's really expected: an 
identifier. The e.g. muddies the water because it suggests there's a list of 
supported languages, and it shows something that looks kind of like a string 
when it isn't one. Something like: `expected an identifier representing the 
source language` or some such?



Comment at: lib/Parse/ParseDecl.cpp:1141
+} else {
+  // Keyword must be 'Ident_defined_in'.
+  if (Tok.isNot(tok::string_literal)) {

You may want to assert this.



Comment at: lib/Sema/SemaDeclAttr.cpp:2414
+   const AttributeList &Attr) {
+  if (!checkAttributeAtLeastNumArgs(S, Attr, 1))
+return;

You should also diagnose if there's more than 3 arguments, no?



Comment at: lib/Sema/SemaDeclAttr.cpp:2418
+  if (!isa(D)) {
+S.Diag(Attr.getLoc(), diag::warn_attribute_ignored) << Attr.getName();
+return;

This isn't really the right diagnostic for a mismatched attribute subject. It 
should be using `warn_attribute_wrong_decl_type` instead so that the user is 
more clear on why the attribute is ignored.



Comment at: lib/Sema/SemaDeclAttr.cpp:2428
+DefinedIn = SE->getString();
+  bool IsGeneratedDeclaration = Attr.getArgAsIdent(2);
+

Rather than rely on the implicit conversion to bool, I think this is a case 
where it should be tested against `nullptr` explicitly.



Comment at: test/Parser/attr-external-source-symbol-cxx11.cpp:6
+
+// expected-no-diagnostics

Please put this directly below the RUN line.



Comment at: test/Parser/attr-external-source-symbol.m:26
+void f6()
+__attribute__((external_source_symbol(defined_in=20))); // expected-error 
{{expected string literal for source container name in 'external_source_symbol' 
attribute}}

I think you can currently get away with writing 
`external_source_symbol(generated_declaration, generated_declaration, 
generated_declaration, defined_in="module"))` and other odd combinations.

There should be additional parser tests for totally crazy parsing scenarios. 
You may want to consider running a fuzzer to generate some of them.



Comment at: test/Sema/attr-external-source-symbol.c:5
+
+void f2() __attribute__((external_source_symbol(generated_declaration)));
+

Should also have a sema test for when there are 2 args, and 4 args.

There should also be a test under Misc that also checks that the args are 
properly lowered into the AST in the correct way with differing argument 
orders. e.g, `external_source_symbol(generated_declaration, language=Swift, 
defined_in="module")` vs `external_source_symbol(language=Swift, 
generated_declaration, defined_in="module")` vs 
`external_source_symbol(defined_in="module", language=Swift, 
generated_declaration)`, etc.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819



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


[PATCH] D29817: [AVR] Fix __AVR_xxx macro definitions

2017-02-10 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn updated this revision to Diff 88025.
Lekensteyn marked an inline comment as done.
Lekensteyn added a comment.

Good catch! I just checked again and confirmed that there is only one line that 
had this issue (there are no other occurrences of `___"`).


https://reviews.llvm.org/D29817

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/avr/target-cpu-defines/atmega328p.c
  test/CodeGen/avr/target-cpu-defines/attiny104.c

Index: test/CodeGen/avr/target-cpu-defines/attiny104.c
===
--- test/CodeGen/avr/target-cpu-defines/attiny104.c
+++ test/CodeGen/avr/target-cpu-defines/attiny104.c
@@ -3,5 +3,5 @@
 
 // CHECK: #define AVR 1
 // CHECK: #define __AVR 1
-// CHECK: #define __AVR_ATtiny104 1
+// CHECK: #define __AVR_ATtiny104__ 1
 // CHECK: #define __AVR__ 1
Index: test/CodeGen/avr/target-cpu-defines/atmega328p.c
===
--- test/CodeGen/avr/target-cpu-defines/atmega328p.c
+++ test/CodeGen/avr/target-cpu-defines/atmega328p.c
@@ -3,5 +3,5 @@
 
 // CHECK: #define AVR 1
 // CHECK: #define __AVR 1
-// CHECK: #define __AVR_ATmega328P 1
+// CHECK: #define __AVR_ATmega328P__ 1
 // CHECK: #define __AVR__ 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8462,244 +8462,244 @@
 // This list should be kept up-to-date with AVRDevices.td in LLVM.
 static ArrayRef AVRMcus = {
   { "at90s1200", "__AVR_AT90S1200__" },
-  { "attiny11", "__AVR_ATtiny11" },
-  { "attiny12", "__AVR_ATtiny12" },
-  { "attiny15", "__AVR_ATtiny15" },
-  { "attiny28", "__AVR_ATtiny28" },
-  { "at90s2313", "__AVR_AT90S2313" },
-  { "at90s2323", "__AVR_AT90S2323" },
-  { "at90s2333", "__AVR_AT90S2333" },
-  { "at90s2343", "__AVR_AT90S2343" },
-  { "attiny22", "__AVR_ATtiny22" },
-  { "attiny26", "__AVR_ATtiny26" },
-  { "at86rf401", "__AVR_AT86RF401" },
-  { "at90s4414", "__AVR_AT90S4414" },
-  { "at90s4433", "__AVR_AT90S4433" },
-  { "at90s4434", "__AVR_AT90S4434" },
-  { "at90s8515", "__AVR_AT90S8515" },
-  { "at90c8534", "__AVR_AT90c8534" },
-  { "at90s8535", "__AVR_AT90S8535" },
-  { "ata5272", "__AVR_ATA5272" },
-  { "attiny13", "__AVR_ATtiny13" },
-  { "attiny13a", "__AVR_ATtiny13A" },
-  { "attiny2313", "__AVR_ATtiny2313" },
-  { "attiny2313a", "__AVR_ATtiny2313A" },
-  { "attiny24", "__AVR_ATtiny24" },
-  { "attiny24a", "__AVR_ATtiny24A" },
-  { "attiny4313", "__AVR_ATtiny4313" },
-  { "attiny44", "__AVR_ATtiny44" },
-  { "attiny44a", "__AVR_ATtiny44A" },
-  { "attiny84", "__AVR_ATtiny84" },
-  { "attiny84a", "__AVR_ATtiny84A" },
-  { "attiny25", "__AVR_ATtiny25" },
-  { "attiny45", "__AVR_ATtiny45" },
-  { "attiny85", "__AVR_ATtiny85" },
-  { "attiny261", "__AVR_ATtiny261" },
-  { "attiny261a", "__AVR_ATtiny261A" },
-  { "attiny461", "__AVR_ATtiny461" },
-  { "attiny461a", "__AVR_ATtiny461A" },
-  { "attiny861", "__AVR_ATtiny861" },
-  { "attiny861a", "__AVR_ATtiny861A" },
-  { "attiny87", "__AVR_ATtiny87" },
-  { "attiny43u", "__AVR_ATtiny43U" },
-  { "attiny48", "__AVR_ATtiny48" },
-  { "attiny88", "__AVR_ATtiny88" },
-  { "attiny828", "__AVR_ATtiny828" },
-  { "at43usb355", "__AVR_AT43USB355" },
-  { "at76c711", "__AVR_AT76C711" },
-  { "atmega103", "__AVR_ATmega103" },
-  { "at43usb320", "__AVR_AT43USB320" },
-  { "attiny167", "__AVR_ATtiny167" },
-  { "at90usb82", "__AVR_AT90USB82" },
-  { "at90usb162", "__AVR_AT90USB162" },
-  { "ata5505", "__AVR_ATA5505" },
-  { "atmega8u2", "__AVR_ATmega8U2" },
-  { "atmega16u2", "__AVR_ATmega16U2" },
-  { "atmega32u2", "__AVR_ATmega32U2" },
-  { "attiny1634", "__AVR_ATtiny1634" },
-  { "atmega8", "__AVR_ATmega8" },
-  { "ata6289", "__AVR_ATA6289" },
-  { "atmega8a", "__AVR_ATmega8A" },
-  { "ata6285", "__AVR_ATA6285" },
-  { "ata6286", "__AVR_ATA6286" },
-  { "atmega48", "__AVR_ATmega48" },
-  { "atmega48a", "__AVR_ATmega48A" },
-  { "atmega48pa", "__AVR_ATmega48PA" },
-  { "atmega48p", "__AVR_ATmega48P" },
-  { "atmega88", "__AVR_ATmega88" },
-  { "atmega88a", "__AVR_ATmega88A" },
-  { "atmega88p", "__AVR_ATmega88P" },
-  { "atmega88pa", "__AVR_ATmega88PA" },
-  { "atmega8515", "__AVR_ATmega8515" },
-  { "atmega8535", "__AVR_ATmega8535" },
-  { "atmega8hva", "__AVR_ATmega8HVA" },
-  { "at90pwm1", "__AVR_AT90PWM1" },
-  { "at90pwm2", "__AVR_AT90PWM2" },
-  { "at90pwm2b", "__AVR_AT90PWM2B" },
-  { "at90pwm3", "__AVR_AT90PWM3" },
-  { "at90pwm3b", "__AVR_AT90PWM3B" },
-  { "at90pwm81", "__AVR_AT90PWM81" },
-  { "ata5790", "__AVR_ATA5790" },
-  { "ata5795", "__AVR_ATA5795" },
-  { "atmega16", "__AVR_ATmega16" },
-  { "atmega16a", "__AVR_ATmega16A" },
-  { "atmega161", "__AVR_ATmega161" },
-  { "atmega162", "__AVR_ATmega162" },
-  { "atmega163", "__AVR_ATmega163" },
-  { "atmega164a", "__AVR_ATmega164A" },
-  { "atmega164p", "__AVR_ATmega164P" },
-  { "atmega164pa", "__AVR_ATmega164PA" },
-  { "atmega165", "__AVR_ATmega165" },
-  { "atmega165a", "__AVR_ATmega165A" },
-  { "atme

[PATCH] D28404: IRGen: Add optnone attribute on function during O0

2017-02-10 Thread Hal Finkel via Phabricator via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D28404#673260, @mehdi_amini wrote:

> Ping :)


To clarify my understanding of this thread, it seems like there are three ways 
forward here:

1. To have -O0 add optnone to the generated functions (enabling some degree of 
lack of optimization of those functions even when used with -flto)
2. To have -O0 -flto essentially turn off LTO (so that we get unoptimized 
objects directly for things we're debugging)
3. Add a separate flag to make optnone the default

(1) is this patch. The disadvantage of (2) is that it also precludes CFI (and 
other whole-program transformations). This seems highly unfortunate at best and 
a non-starter in the general case. The disadvantage of (3) is that it might 
seems confusing to users (i.e. how to explain the difference between -O0 and 
-foptimize-off?) and is an unnecessary exposure to users of implementation 
details. On this point I agree.

It is true that -O0 != optnone, in a technical sense, but in the end, both are 
best effort. Moreover, there is a tradeoff between disabling optimization of 
the functions you don't want to optimize and keeping the remainder of the code 
as similar as possible to how it would be if everything were being optimized. 
What optnone provides seems like a reasonable point in that tradeoff space. I 
think that we should move forward with this approach.


https://reviews.llvm.org/D28404



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


[PATCH] D29764: [OpenCL] Blocks cannot capture/reference another block

2017-02-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In https://reviews.llvm.org/D29764#673548, @Nicola wrote:

> Looking at "Example 4" in the standard it looks like this should also be 
> illegal.
>
>   int (^block1)(void) = ^int {return 1;};
>   int foo() { return block1(); }
>  
>   __kernel void k(global int *z)
>   {
>int (^block2)(void) = ^int {
> return foo(); // expected-error {{cannot refer to a block inside block}}
>}; 
>   }
>  
>
>
> Unless I missed something it's not erroring in this case.


To diagnose this needs to traverse the AST tree. I think it is too much to do 
it during parsing.

It may be done through static analysis though.


https://reviews.llvm.org/D29764



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


[PATCH] D29817: [AVR] Fix __AVR_xxx macro definitions

2017-02-10 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Basic/Targets.cpp:8464
 static ArrayRef AVRMcus = {
-  { "at90s1200", "__AVR_AT90S1200__" },
-  { "attiny11", "__AVR_ATtiny11" },
-  { "attiny12", "__AVR_ATtiny12" },
-  { "attiny15", "__AVR_ATtiny15" },
-  { "attiny28", "__AVR_ATtiny28" },
-  { "at90s2313", "__AVR_AT90S2313" },
-  { "at90s2323", "__AVR_AT90S2323" },
-  { "at90s2333", "__AVR_AT90S2333" },
-  { "at90s2343", "__AVR_AT90S2343" },
-  { "attiny22", "__AVR_ATtiny22" },
-  { "attiny26", "__AVR_ATtiny26" },
-  { "at86rf401", "__AVR_AT86RF401" },
-  { "at90s4414", "__AVR_AT90S4414" },
-  { "at90s4433", "__AVR_AT90S4433" },
-  { "at90s4434", "__AVR_AT90S4434" },
-  { "at90s8515", "__AVR_AT90S8515" },
-  { "at90c8534", "__AVR_AT90c8534" },
-  { "at90s8535", "__AVR_AT90S8535" },
-  { "ata5272", "__AVR_ATA5272" },
-  { "attiny13", "__AVR_ATtiny13" },
-  { "attiny13a", "__AVR_ATtiny13A" },
-  { "attiny2313", "__AVR_ATtiny2313" },
-  { "attiny2313a", "__AVR_ATtiny2313A" },
-  { "attiny24", "__AVR_ATtiny24" },
-  { "attiny24a", "__AVR_ATtiny24A" },
-  { "attiny4313", "__AVR_ATtiny4313" },
-  { "attiny44", "__AVR_ATtiny44" },
-  { "attiny44a", "__AVR_ATtiny44A" },
-  { "attiny84", "__AVR_ATtiny84" },
-  { "attiny84a", "__AVR_ATtiny84A" },
-  { "attiny25", "__AVR_ATtiny25" },
-  { "attiny45", "__AVR_ATtiny45" },
-  { "attiny85", "__AVR_ATtiny85" },
-  { "attiny261", "__AVR_ATtiny261" },
-  { "attiny261a", "__AVR_ATtiny261A" },
-  { "attiny461", "__AVR_ATtiny461" },
-  { "attiny461a", "__AVR_ATtiny461A" },
-  { "attiny861", "__AVR_ATtiny861" },
-  { "attiny861a", "__AVR_ATtiny861A" },
-  { "attiny87", "__AVR_ATtiny87" },
-  { "attiny43u", "__AVR_ATtiny43U" },
-  { "attiny48", "__AVR_ATtiny48" },
-  { "attiny88", "__AVR_ATtiny88" },
-  { "attiny828", "__AVR_ATtiny828" },
-  { "at43usb355", "__AVR_AT43USB355" },
-  { "at76c711", "__AVR_AT76C711" },
-  { "atmega103", "__AVR_ATmega103" },
-  { "at43usb320", "__AVR_AT43USB320" },
-  { "attiny167", "__AVR_ATtiny167" },
-  { "at90usb82", "__AVR_AT90USB82" },
-  { "at90usb162", "__AVR_AT90USB162" },
-  { "ata5505", "__AVR_ATA5505" },
-  { "atmega8u2", "__AVR_ATmega8U2" },
-  { "atmega16u2", "__AVR_ATmega16U2" },
-  { "atmega32u2", "__AVR_ATmega32U2" },
-  { "attiny1634", "__AVR_ATtiny1634" },
-  { "atmega8", "__AVR_ATmega8" },
-  { "ata6289", "__AVR_ATA6289" },
-  { "atmega8a", "__AVR_ATmega8A" },
-  { "ata6285", "__AVR_ATA6285" },
-  { "ata6286", "__AVR_ATA6286" },
-  { "atmega48", "__AVR_ATmega48" },
-  { "atmega48a", "__AVR_ATmega48A" },
-  { "atmega48pa", "__AVR_ATmega48PA" },
-  { "atmega48p", "__AVR_ATmega48P" },
-  { "atmega88", "__AVR_ATmega88" },
-  { "atmega88a", "__AVR_ATmega88A" },
-  { "atmega88p", "__AVR_ATmega88P" },
-  { "atmega88pa", "__AVR_ATmega88PA" },
-  { "atmega8515", "__AVR_ATmega8515" },
-  { "atmega8535", "__AVR_ATmega8535" },
-  { "atmega8hva", "__AVR_ATmega8HVA" },
-  { "at90pwm1", "__AVR_AT90PWM1" },
-  { "at90pwm2", "__AVR_AT90PWM2" },
-  { "at90pwm2b", "__AVR_AT90PWM2B" },
-  { "at90pwm3", "__AVR_AT90PWM3" },
-  { "at90pwm3b", "__AVR_AT90PWM3B" },
-  { "at90pwm81", "__AVR_AT90PWM81" },
-  { "ata5790", "__AVR_ATA5790" },
-  { "ata5795", "__AVR_ATA5795" },
-  { "atmega16", "__AVR_ATmega16" },
-  { "atmega16a", "__AVR_ATmega16A" },
-  { "atmega161", "__AVR_ATmega161" },
-  { "atmega162", "__AVR_ATmega162" },
-  { "atmega163", "__AVR_ATmega163" },
-  { "atmega164a", "__AVR_ATmega164A" },
-  { "atmega164p", "__AVR_ATmega164P" },
-  { "atmega164pa", "__AVR_ATmega164PA" },
-  { "atmega165", "__AVR_ATmega165" },
-  { "atmega165a", "__AVR_ATmega165A" },
-  { "atmega165p", "__AVR_ATmega165P" },
-  { "atmega165pa", "__AVR_ATmega165PA" },
-  { "atmega168", "__AVR_ATmega168" },
-  { "atmega168a", "__AVR_ATmega168A" },
-  { "atmega168p", "__AVR_ATmega168P" },
-  { "atmega168pa", "__AVR_ATmega168PA" },
-  { "atmega169", "__AVR_ATmega169" },
-  { "atmega169a", "__AVR_ATmega169A" },
-  { "atmega169p", "__AVR_ATmega169P" },
-  { "atmega169pa", "__AVR_ATmega169PA" },
-  { "atmega32", "__AVR_ATmega32" },
-  { "atmega32a", "__AVR_ATmega32A" },
-  { "atmega323", "__AVR_ATmega323" },
-  { "atmega324a", "__AVR_ATmega324A" },
-  { "atmega324p", "__AVR_ATmega324P" },
-  { "atmega324pa", "__AVR_ATmega324PA" },
-  { "atmega325", "__AVR_ATmega325" },
-  { "atmega325a", "__AVR_ATmega325A" },
-  { "atmega325p", "__AVR_ATmega325P" },
-  { "atmega325pa", "__AVR_ATmega325PA" },
-  { "atmega3250", "__AVR_ATmega3250" },
-  { "atmega3250a", "__AVR_ATmega3250A" },
-  { "atmega3250p", "__AVR_ATmega3250P" },
-  { "atmega3250pa", "__AVR_ATmega3250PA" },
-  { "atmega328", "__AVR_ATmega328" },
-  { "atmega328p", "__AVR_ATmega328P" },
-  { "atmega329", "__AVR_ATmega329" },
-  { "atmega329a", "__AVR_ATmega329A" },
-  { "atmega329p", "__AVR_ATmega329P" },
-  { "atmega329pa", "__AVR_ATmega329PA" },
-  { "atmega3290", "__AVR_ATmega3290" },
-  { "atmega3290a", "__AVR_ATmega3290A" },
-  { "atmega3290p", "__AVR_ATmega3290P" },
-  { "atmega3290pa", "__AVR_ATmega3290PA" }

[PATCH] D29830: [OpenCL][Doc] Relase 4.0 notes for OpenCL

2017-02-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D29830



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


[PATCH] D29469: Fix PR31843: Clang-4.0 crashes/assert while evaluating __builtin_object_size

2017-02-10 Thread George Burgess IV via Phabricator via cfe-commits
george.burgess.iv added a comment.

End of week ping :)


https://reviews.llvm.org/D29469



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


[PATCH] D29530: [ubsan] Reduce null checking of C++ object pointers (PR27581)

2017-02-10 Thread Vedant Kumar via Phabricator via cfe-commits
vsk added a comment.

Ah, I did miss ParenExpr. Maybe it would be better to use 
Expr::isImplicitCXXThis, since it handles this case and some more. Later, we 
can go back and see if it's feasible to handle static/const casts in 
isImplicitCXXThis to catch more cases.

In https://reviews.llvm.org/D29530#671816, @arphaman wrote:

> Btw, you mentioned that 'this' must have been null-checked before the method 
> is called. But what if it's called from some part of code that was compiled 
> without `-fsanitize=null`? Wouldn't we still want at least one check to see 
> if 'this' is null in a method?


That's fair, I think that would address the concerns about the partial 
sanitization use case brought up in the original PR.


https://reviews.llvm.org/D29530



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


Re: Patch for Bug 30413

2017-02-10 Thread Vedant Kumar via cfe-commits

> On Feb 10, 2017, at 8:29 AM, Lobron, David  wrote:
> 
> Hi Vedant,
> 
> Thanks for the reply!  Yes, I have a small test case- I actually attached it 
> to the original bug report (https://llvm.org/bugs/show_bug.cgi?id=30413), but 
> I will go ahead and try adding it to clang/test/CodeGenObjC, or extend a case 
> if possible.

Great!


> Is it OK to make changes to CodeGenObjC directly, or should I submit a diff 
> of those changes to this list, along with my original patch?

Ideally we'd get your fix + your test case checked in with one patch.

vedant


> Thanks!
> 
> --David
> 
>> On Feb 9, 2017, at 8:22 PM, Vedant Kumar  wrote:
>> 
>> Hi David,
>> 
>> Thanks for tracking this down.
>> 
>> Do you have a small reproducer to use as a test case? Ideally, you'd add a 
>> regression test to clang/test/CodeGenObjC, or extend an existing one.
>> 
>> vedant
>> 
>>> On Feb 7, 2017, at 6:42 PM, Lobron, David via cfe-commits 
>>>  wrote:
>>> 
>>> Hello clang developers,
>>> 
>>> I discovered a bug that affects Objective-C programs compiled with clang on 
>>> Linux.  The current code was not emitting Objective-C class name metadata, 
>>> which made it impossible for programs to do runtime type introspection.  I 
>>> opened a bug report that describes the problem and provides a test program 
>>> that reproduces it:
>>> 
>>> https://llvm.org/bugs/show_bug.cgi?id=30413
>>> 
>>> I've attached an svn-generated patch file: the patch changes one argument 
>>> to the getObjCEncodingForTypeImpl function from false to true, so that 
>>> Objective-C class names are encoded.  If this looks OK, it would be great 
>>> if it could be added to the trunk.  Once that is done, the bug can of 
>>> course be closed.
>>> 
>>> Thank you.
>>> 
>>> Sincerely,
>>> 
>>> David Lobron
>>> 
>>> ___
>>> cfe-commits mailing list
>>> cfe-commits@lists.llvm.org
>>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>> 
> 

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


[PATCH] D29827: [AVR] Add -mmcu option to the driver

2017-02-10 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added inline comments.



Comment at: include/clang/Driver/Options.td:1613
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group;
+def mmcu_EQ : Joined<["-"], "mmcu=">, Group;
 def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group;

jroelofs wrote:
> Would it make sense to have mcu be an alias for mcpu instead?
That would deviate from the GCC interface, so I have chosen for the current 
situation:
```
$ avr-gcc -mmcu=avr2 -o /dev/null x.c
$ avr-gcc -mcpu=avr2 -o /dev/null x.c
avr-gcc: error: unrecognized command line option '-mcpu=avr2'
$ avr-gcc -march=avr2 -o /dev/null x.c
avr-gcc: error: unrecognized command line option '-march=avr2'
$ avr-gcc -v
...
gcc version 6.3.0 (GCC)
```


https://reviews.llvm.org/D29827



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


[clang-tools-extra] r294760 - [clangd] Move isDone from the JSONOutput to ShutdownHandler.

2017-02-10 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Feb 10 11:25:38 2017
New Revision: 294760

URL: http://llvm.org/viewvc/llvm-project?rev=294760&view=rev
Log:
[clangd] Move isDone from the JSONOutput to ShutdownHandler.

This is just as easy to check from main but prevents random code from
shutting down the server.

Modified:
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.h

Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=294760&r1=294759&r2=294760&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Fri Feb 10 11:25:38 2017
@@ -30,8 +30,9 @@ int main(int argc, char *argv[]) {
   JSONRPCDispatcher Dispatcher(llvm::make_unique(Out));
   Dispatcher.registerHandler("initialize",
  llvm::make_unique(Out));
-  Dispatcher.registerHandler("shutdown",
- llvm::make_unique(Out));
+  auto ShutdownPtr = llvm::make_unique(Out);
+  auto *ShutdownHandler = ShutdownPtr.get();
+  Dispatcher.registerHandler("shutdown",std::move(ShutdownPtr));
   Dispatcher.registerHandler(
   "textDocument/didOpen",
   llvm::make_unique(Out, Store));
@@ -92,7 +93,7 @@ int main(int argc, char *argv[]) {
 Logs << "JSON dispatch failed!\n";
 
   // If we're done, exit the loop.
-  if (Out.isDone())
+  if (ShutdownHandler->isDone())
 break;
 }
   }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=294760&r1=294759&r2=294760&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Fri Feb 10 11:25:38 2017
@@ -31,17 +31,10 @@ public:
   /// Get the logging stream.
   llvm::raw_ostream &logs() { return Logs; }
 
-  /// Use this to indicate that the output stream should be closed and the
-  /// process should terminate.
-  void setDone() { Done = true; }
-  bool isDone() const { return Done; }
-
 private:
   llvm::raw_ostream &Outs;
   llvm::raw_ostream &Logs;
 
-  bool Done = false;
-
   std::mutex StreamMutex;
 };
 

Modified: clang-tools-extra/trunk/clangd/ProtocolHandlers.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ProtocolHandlers.h?rev=294760&r1=294759&r2=294760&view=diff
==
--- clang-tools-extra/trunk/clangd/ProtocolHandlers.h (original)
+++ clang-tools-extra/trunk/clangd/ProtocolHandlers.h Fri Feb 10 11:25:38 2017
@@ -42,8 +42,13 @@ struct ShutdownHandler : Handler {
   ShutdownHandler(JSONOutput &Output) : Handler(Output) {}
 
   void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
-Output.setDone();
+IsDone = true;
   }
+
+  bool isDone() const { return IsDone; }
+
+private:
+  bool IsDone = false;
 };
 
 struct TextDocumentDidOpenHandler : Handler {


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


Re: [PATCH] D29758: [OpenMP] Parallel reduction on the NVPTX device.

2017-02-10 Thread Alexey Bataev via cfe-commits
Arpith, see the comment in CGOpenMPRuntime.cpp

   // if SimpleReduction is true, only the next code is generated:
   //  ...
   //  [i] = RedOp(*[i], *[i]);
   //  ...

and is used for omp simd directive only.

-
Best regards,
Alexey Bataev

10.02.2017 18:49, Arpith Jacob via Phabricator пишет:
> arpith-jacob added inline comments.
>
>
> 
> Comment at: lib/CodeGen/CGOpenMPRuntime.h:956-962
> virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
>ArrayRef Privates,
>ArrayRef LHSExprs,
>ArrayRef RHSExprs,
>ArrayRef ReductionOps,
> - bool WithNowait, bool SimpleReduction);
> + bool WithNowait, bool SimpleReduction,
> + OpenMPDirectiveKind ReductionKind);
> 
> ABataev wrote:
>> Number of parameters is getting too big, maybe it is better to aggregate 
>> them into a struct/class?
> Thanks Alexey for your comments.  I can place 'WithNoWait, SimpleReduction, 
> ReductionKind' in a struct.
>
> Can you explain what 'SimpleReduction' stands for?  It isn't create to me 
> when the reduction is simple...
>
> Thanks.
>
>
> https://reviews.llvm.org/D29758
>
>
>

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


[PATCH] D29827: [AVR] Add -mmcu option to the driver

2017-02-10 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: include/clang/Driver/Options.td:1613
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group;
+def mmcu_EQ : Joined<["-"], "mmcu=">, Group;
 def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group;

Would it make sense to have mcu be an alias for mcpu instead?


https://reviews.llvm.org/D29827



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


[PATCH] D29829: [OpenCL][Doc] Description for adding OpenCL vendor extension in user manual

2017-02-10 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


https://reviews.llvm.org/D29829



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


[PATCH] D29830: [OpenCL][Doc] Relase 4.0 notes for OpenCL

2017-02-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.

https://reviews.llvm.org/D29830

Files:
  docs/ReleaseNotes.rst


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -17,7 +17,7 @@
 Introduction
 
 
-This document contains the release notes for the Clang C/C++/Objective-C
+This document contains the release notes for the Clang C/C++/Objective-C/OpenCL
 frontend, part of the LLVM Compiler Infrastructure, release 4.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
@@ -139,7 +139,76 @@
 OpenCL C Language Changes in Clang
 --
 
-...
+**The following bugs in the OpenCL header have been fixed:**
+
+* Added missing ``overloadable`` and ``convergent`` attributes.
+* Removed some erroneous extra ``native_*`` functions.
+
+**The following bugs in the generation of metadata have been fixed:**
+
+* Corrected the SPIR version depending on the OpenCL version.
+* Source level address spaces are taken from the SPIR specification.
+* Image types now contain no access qualifier.
+
+**The following bugs in the AMD target have been fixed:**
+
+* Corrected the bitwidth of ``size_t`` and NULL pointer value with respect to
+  address spaces.
+* Added ``cl_khr_subgroups``, ``cl_amd_media_ops`` and ``cl_amd_media_ops2``
+  extensions.
+* Added ``cl-denorms-are-zero`` support.
+* Changed address spaces for image objects to be ``constant``.
+* Added little-endian.
+
+**The following bugs in OpenCL 2.0 have been fixed:**
+
+* Fixed pipe builtin function return type, added extra argument to generated
+  IR intrinsics to propagate size and alignment information of the pipe packed
+  type.
+* Improved pipe type to accommodate access qualifiers.
+* Added correct address space to the ObjC block generation and 
``enqueue_kernel``
+  prototype.
+* Improved handling of integer parameters of ``enqueue_kernel`` prototype. We
+  now allow ``size_t`` instead of ``int`` for specifying block parameter sizes.
+* Allow using NULL (aka ``CLK_NULL_QUEUE``) with ``queue_t``.
+
+
+**Improved the following diagnostics:**
+
+* Disallow address spaces other than ``global`` for kernel pointer parameters.
+* Correct the use of half type argument and pointer assignment with
+  dereferencing.
+* Disallow variadic arguments in functions and blocks.
+* Allow partial initializer for array and struct.
+
+**Some changes to OpenCL extensions have been made:**
+
+* Added ``cl_khr_mipmap_image``.
+* Added ``-cl-ext`` flag to allow overwriting supported extensions otherwise
+  set by the target compiled for (Example: ``-cl-ext=-all,+cl_khr_fp16``).
+* New types and functions can now be flexibly added to extensions using the
+  following pragmas instead of modifying the Clang source code:
+
+  .. code-block:: c
+
+   #pragma OPENCL EXTENSION the_new_extension_name : begin
+   // declare types and functions associated with the extension here
+   #pragma OPENCL EXTENSION the_new_extension_name : end
+
+
+**Miscellaneous changes:**
+
+* Fix ``__builtin_astype`` to cast between different address space objects.
+* Allow using ``opencl_unroll_hint`` with earlier OpenCL versions than 2.0.
+* Improved handling of floating point literal to default to single precision if
+  fp64 extension is not enabled.
+* Refactor ``sampler_t`` implementation to simplify initializer representation
+  which is now handled as a compiler builtin function with an integer value
+  passed into it.
+* Change fake address space map to use the SPIR convention.
+* Added `the OpenCL manual
+  `_ to Clang
+  documentation.
 
 OpenMP Support in Clang
 --


Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -17,7 +17,7 @@
 Introduction
 
 
-This document contains the release notes for the Clang C/C++/Objective-C
+This document contains the release notes for the Clang C/C++/Objective-C/OpenCL
 frontend, part of the LLVM Compiler Infrastructure, release 4.0.0. Here we
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
@@ -139,7 +139,76 @@
 OpenCL C Language Changes in Clang
 --
 
-...
+**The following bugs in the OpenCL header have been fixed:**
+
+* Added missing ``overloadable`` and ``convergent`` attributes.
+* Removed some erroneous extra ``native_*`` functions.
+
+**The following bugs in the generation of metadata have been fixed:**
+
+* Corrected the SPIR version depending on the OpenCL version.
+* Source level address spaces are taken from the SPIR specification.
+* Image types now contain no access qualifier.
+
+**The following bugs in the AMD target have 

[PATCH] D29829: [OpenCL][Doc] Description for adding OpenCL vendor extension in user manual

2017-02-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia created this revision.

Adding a description of a new feature that allows to specify vendor extension 
in flexible way using compiler pragma instead of modifying source code directly.

Feature committed in Clang@r289979.


https://reviews.llvm.org/D29829

Files:
  docs/UsersManual.rst


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2056,6 +2056,8 @@
 In this case the kernel code should contain ``#include `` just as a
 regular C include.
 
+.. _opencl_cl_ext:
+
 .. option:: -cl-ext
 
 Disables support of OpenCL extensions. All OpenCL targets provide a list
@@ -2177,6 +2179,41 @@
 
  $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang 
-finclude-default-header -fmodules -fimplicit-module-maps 
-fmodules-cache-path= test.cl
 
+OpenCL Extensions
+-
+
+All of the ``cl_khr_*`` extensions from `the official OpenCL specification
+`_
+up to and including version 2.0 are available and set per target depending on 
the
+support available in the specific architecture.
+
+It is possible to alter the default extensions setting per target using
+``-cl-ext`` flag. (See :ref:`flags description ` for more 
details).
+
+Vendor extensions can be added flexibly by declaring the list of types and
+functions associated with each extensions enclosed within the following
+compiler pragma directives:
+
+  .. code-block:: c
+
+   #pragma OPENCL EXTENSION the_new_extension_name : begin
+   // declare types and functions associated with the extension here
+   #pragma OPENCL EXTENSION the_new_extension_name : end
+
+For example, parsing the following code adds ``my_t`` type and ``my_func``
+function to the custom ``my_ext`` extension.
+
+  .. code-block:: c
+
+   #pragma OPENCL EXTENSION my_ext : begin
+   typedef struct{
+ int a;
+   }my_t;
+   void my_func(my_t);
+   #pragma OPENCL EXTENSION my_ext : end
+
+Declaring the same types in different vendor extensions is disallowed.
+
 OpenCL Metadata
 ---
 
@@ -2215,7 +2252,7 @@
 `_
 
 
-opencl_hint_unroll
+opencl_unroll_hint
 ^^
 
 The implementation of this feature mirrors the unroll hint for C.


Index: docs/UsersManual.rst
===
--- docs/UsersManual.rst
+++ docs/UsersManual.rst
@@ -2056,6 +2056,8 @@
 In this case the kernel code should contain ``#include `` just as a
 regular C include.
 
+.. _opencl_cl_ext:
+
 .. option:: -cl-ext
 
 Disables support of OpenCL extensions. All OpenCL targets provide a list
@@ -2177,6 +2179,41 @@
 
  $ clang -target spir-unknown-unknown -c -emit-llvm -Xclang -finclude-default-header -fmodules -fimplicit-module-maps -fmodules-cache-path= test.cl
 
+OpenCL Extensions
+-
+
+All of the ``cl_khr_*`` extensions from `the official OpenCL specification
+`_
+up to and including version 2.0 are available and set per target depending on the
+support available in the specific architecture.
+
+It is possible to alter the default extensions setting per target using
+``-cl-ext`` flag. (See :ref:`flags description ` for more details).
+
+Vendor extensions can be added flexibly by declaring the list of types and
+functions associated with each extensions enclosed within the following
+compiler pragma directives:
+
+  .. code-block:: c
+
+   #pragma OPENCL EXTENSION the_new_extension_name : begin
+   // declare types and functions associated with the extension here
+   #pragma OPENCL EXTENSION the_new_extension_name : end
+
+For example, parsing the following code adds ``my_t`` type and ``my_func``
+function to the custom ``my_ext`` extension.
+
+  .. code-block:: c
+
+   #pragma OPENCL EXTENSION my_ext : begin
+   typedef struct{
+ int a;
+   }my_t;
+   void my_func(my_t);
+   #pragma OPENCL EXTENSION my_ext : end
+
+Declaring the same types in different vendor extensions is disallowed.
+
 OpenCL Metadata
 ---
 
@@ -2215,7 +2252,7 @@
 `_
 
 
-opencl_hint_unroll
+opencl_unroll_hint
 ^^
 
 The implementation of this feature mirrors the unroll hint for C.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: Patch for Bug 30413

2017-02-10 Thread Lobron, David via cfe-commits
Hi Vedant,

Thanks for the reply!  Yes, I have a small test case- I actually attached it to 
the original bug report (https://llvm.org/bugs/show_bug.cgi?id=30413), but I 
will go ahead and try adding it to clang/test/CodeGenObjC, or extend a case if 
possible.

Is it OK to make changes to CodeGenObjC directly, or should I submit a diff of 
those changes to this list, along with my original patch?  

Thanks!

--David

> On Feb 9, 2017, at 8:22 PM, Vedant Kumar  wrote:
> 
> Hi David,
> 
> Thanks for tracking this down.
> 
> Do you have a small reproducer to use as a test case? Ideally, you'd add a 
> regression test to clang/test/CodeGenObjC, or extend an existing one.
> 
> vedant
> 
>> On Feb 7, 2017, at 6:42 PM, Lobron, David via cfe-commits 
>>  wrote:
>> 
>> Hello clang developers,
>> 
>> I discovered a bug that affects Objective-C programs compiled with clang on 
>> Linux.  The current code was not emitting Objective-C class name metadata, 
>> which made it impossible for programs to do runtime type introspection.  I 
>> opened a bug report that describes the problem and provides a test program 
>> that reproduces it:
>> 
>> https://llvm.org/bugs/show_bug.cgi?id=30413
>> 
>> I've attached an svn-generated patch file: the patch changes one argument to 
>> the getObjCEncodingForTypeImpl function from false to true, so that 
>> Objective-C class names are encoded.  If this looks OK, it would be great if 
>> it could be added to the trunk.  Once that is done, the bug can of course be 
>> closed.
>> 
>> Thank you.
>> 
>> Sincerely,
>> 
>> David Lobron
>> 
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> 

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


[PATCH] D29817: [AVR] Fix __AVR_xxx macro definitions

2017-02-10 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D29817



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


[PATCH] D29764: [OpenCL] Blocks cannot capture/reference another block

2017-02-10 Thread Nicola Zaghen via Phabricator via cfe-commits
Nicola added a comment.

Looking at "Example 4" in the standard it looks like this should also be 
illegal.

  int (^block1)(void) = ^int {return 1;};
  int foo() { return block1(); }
  
  __kernel void k(global int *z)
  {
   int (^block2)(void) = ^int {
return foo(); // expected-error {{cannot refer to a block inside block}}
   }; 
  }

Unless I missed something it's not erroring in this case.


https://reviews.llvm.org/D29764



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


[PATCH] D29718: [libclang] [OpenCL] Expose half type

2017-02-10 Thread Joey Gouly via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL294754: [libclang] [OpenCL] Expose half type. (authored by 
joey).

Changed prior to commit:
  https://reviews.llvm.org/D29718?vs=87654&id=88002#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D29718

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/test/Index/opencl-types.cl
  cfe/trunk/tools/libclang/CXType.cpp


Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -3011,8 +3011,9 @@
   CXType_ObjCClass = 28,
   CXType_ObjCSel = 29,
   CXType_Float128 = 30,
+  CXType_Half = 31,
   CXType_FirstBuiltin = CXType_Void,
-  CXType_LastBuiltin  = CXType_ObjCSel,
+  CXType_LastBuiltin  = CXType_Half,
 
   CXType_Complex = 100,
   CXType_Pointer = 101,
Index: cfe/trunk/test/Index/opencl-types.cl
===
--- cfe/trunk/test/Index/opencl-types.cl
+++ cfe/trunk/test/Index/opencl-types.cl
@@ -0,0 +1,24 @@
+// RUN: c-index-test -test-print-type %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+typedef half half4 __attribute__((ext_vector_type(4)));
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+
+void kernel testFloatTypes() {
+  half scalarHalf;
+  half4 vectorHalf;
+  float scalarFloat;
+  float4 vectorFloat;
+  double scalarDouble;
+  double4 vectorDouble;
+}
+
+// CHECK: VarDecl=scalarHalf:11:8 (Definition) [type=half] [typekind=Half] 
[isPOD=1]
+// CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] 
[canonicaltype=half __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarFloat:13:9 (Definition) [type=float] [typekind=Float] 
[isPOD=1]
+// CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] 
[typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarDouble:15:10 (Definition) [type=double] 
[typekind=Double] [isPOD=1]
+// CHECK: VarDecl=vectorDouble:16:11 (Definition) [type=double4] 
[typekind=Typedef] [canonicaltype=double __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]
Index: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/tools/libclang/CXType.cpp
@@ -48,6 +48,7 @@
 BTCASE(Long);
 BTCASE(LongLong);
 BTCASE(Int128);
+BTCASE(Half);
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
@@ -503,6 +504,7 @@
 TKIND(Long);
 TKIND(LongLong);
 TKIND(Int128);
+TKIND(Half);
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);
Index: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1887,6 +1887,7 @@
 TypeKind.OBJCCLASS = TypeKind(28)
 TypeKind.OBJCSEL = TypeKind(29)
 TypeKind.FLOAT128 = TypeKind(30)
+TypeKind.HALF = TypeKind(31)
 TypeKind.COMPLEX = TypeKind(100)
 TypeKind.POINTER = TypeKind(101)
 TypeKind.BLOCKPOINTER = TypeKind(102)


Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -3011,8 +3011,9 @@
   CXType_ObjCClass = 28,
   CXType_ObjCSel = 29,
   CXType_Float128 = 30,
+  CXType_Half = 31,
   CXType_FirstBuiltin = CXType_Void,
-  CXType_LastBuiltin  = CXType_ObjCSel,
+  CXType_LastBuiltin  = CXType_Half,
 
   CXType_Complex = 100,
   CXType_Pointer = 101,
Index: cfe/trunk/test/Index/opencl-types.cl
===
--- cfe/trunk/test/Index/opencl-types.cl
+++ cfe/trunk/test/Index/opencl-types.cl
@@ -0,0 +1,24 @@
+// RUN: c-index-test -test-print-type %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+typedef half half4 __attribute__((ext_vector_type(4)));
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+
+void kernel testFloatTypes() {
+  half scalarHalf;
+  half4 vectorHalf;
+  float scalarFloat;
+  float4 vectorFloat;
+  double scalarDouble;
+  double4 vectorDouble;
+}
+
+// CHECK: VarDecl=scalarHalf:11:8 (Definition) [type=half] [typekind=Half] [isPOD=1]
+// CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] [canonicaltype=half __attribute__((ext_vector_type(4)))] [canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarFloat:13:9 (Definition) [type=float] [typekind=Float] [isPO

r294754 - [libclang] [OpenCL] Expose half type.

2017-02-10 Thread Joey Gouly via cfe-commits
Author: joey
Date: Fri Feb 10 09:51:11 2017
New Revision: 294754

URL: http://llvm.org/viewvc/llvm-project?rev=294754&view=rev
Log:
[libclang] [OpenCL] Expose half type.

Expose the half type (fp16) through libclang and the python bindings.

It seems CXType_LastBuiltin was not updated in b2ea6d9 ("Enable
support for __float128 in Clang", 2016-04-13), so update it now.

Add an Index test for OpenCL types; in the future we will add other
OpenCL types such as images to this test.

Patch by Sven van Haastregt.

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

Added:
cfe/trunk/test/Index/opencl-types.cl
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=294754&r1=294753&r2=294754&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Fri Feb 10 09:51:11 2017
@@ -1887,6 +1887,7 @@ TypeKind.OBJCID = TypeKind(27)
 TypeKind.OBJCCLASS = TypeKind(28)
 TypeKind.OBJCSEL = TypeKind(29)
 TypeKind.FLOAT128 = TypeKind(30)
+TypeKind.HALF = TypeKind(31)
 TypeKind.COMPLEX = TypeKind(100)
 TypeKind.POINTER = TypeKind(101)
 TypeKind.BLOCKPOINTER = TypeKind(102)

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=294754&r1=294753&r2=294754&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Fri Feb 10 09:51:11 2017
@@ -3011,8 +3011,9 @@ enum CXTypeKind {
   CXType_ObjCClass = 28,
   CXType_ObjCSel = 29,
   CXType_Float128 = 30,
+  CXType_Half = 31,
   CXType_FirstBuiltin = CXType_Void,
-  CXType_LastBuiltin  = CXType_ObjCSel,
+  CXType_LastBuiltin  = CXType_Half,
 
   CXType_Complex = 100,
   CXType_Pointer = 101,

Added: cfe/trunk/test/Index/opencl-types.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/opencl-types.cl?rev=294754&view=auto
==
--- cfe/trunk/test/Index/opencl-types.cl (added)
+++ cfe/trunk/test/Index/opencl-types.cl Fri Feb 10 09:51:11 2017
@@ -0,0 +1,24 @@
+// RUN: c-index-test -test-print-type %s | FileCheck %s
+
+#pragma OPENCL EXTENSION cl_khr_fp16 : enable
+#pragma OPENCL EXTENSION cl_khr_fp64 : enable
+
+typedef half half4 __attribute__((ext_vector_type(4)));
+typedef float float4 __attribute__((ext_vector_type(4)));
+typedef double double4 __attribute__((ext_vector_type(4)));
+
+void kernel testFloatTypes() {
+  half scalarHalf;
+  half4 vectorHalf;
+  float scalarFloat;
+  float4 vectorFloat;
+  double scalarDouble;
+  double4 vectorDouble;
+}
+
+// CHECK: VarDecl=scalarHalf:11:8 (Definition) [type=half] [typekind=Half] 
[isPOD=1]
+// CHECK: VarDecl=vectorHalf:12:9 (Definition) [type=half4] [typekind=Typedef] 
[canonicaltype=half __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarFloat:13:9 (Definition) [type=float] [typekind=Float] 
[isPOD=1]
+// CHECK: VarDecl=vectorFloat:14:10 (Definition) [type=float4] 
[typekind=Typedef] [canonicaltype=float __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]
+// CHECK: VarDecl=scalarDouble:15:10 (Definition) [type=double] 
[typekind=Double] [isPOD=1]
+// CHECK: VarDecl=vectorDouble:16:11 (Definition) [type=double4] 
[typekind=Typedef] [canonicaltype=double __attribute__((ext_vector_type(4)))] 
[canonicaltypekind=Unexposed] [isPOD=1]

Modified: cfe/trunk/tools/libclang/CXType.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXType.cpp?rev=294754&r1=294753&r2=294754&view=diff
==
--- cfe/trunk/tools/libclang/CXType.cpp (original)
+++ cfe/trunk/tools/libclang/CXType.cpp Fri Feb 10 09:51:11 2017
@@ -48,6 +48,7 @@ static CXTypeKind GetBuiltinTypeKind(con
 BTCASE(Long);
 BTCASE(LongLong);
 BTCASE(Int128);
+BTCASE(Half);
 BTCASE(Float);
 BTCASE(Double);
 BTCASE(LongDouble);
@@ -503,6 +504,7 @@ CXString clang_getTypeKindSpelling(enum
 TKIND(Long);
 TKIND(LongLong);
 TKIND(Int128);
+TKIND(Half);
 TKIND(Float);
 TKIND(Double);
 TKIND(LongDouble);


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


[PATCH] D29758: [OpenMP] Parallel reduction on the NVPTX device.

2017-02-10 Thread Arpith Jacob via Phabricator via cfe-commits
arpith-jacob added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:956-962
   virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
  ArrayRef Privates,
  ArrayRef LHSExprs,
  ArrayRef RHSExprs,
  ArrayRef ReductionOps,
- bool WithNowait, bool SimpleReduction);
+ bool WithNowait, bool SimpleReduction,
+ OpenMPDirectiveKind ReductionKind);

ABataev wrote:
> Number of parameters is getting too big, maybe it is better to aggregate them 
> into a struct/class?
Thanks Alexey for your comments.  I can place 'WithNoWait, SimpleReduction, 
ReductionKind' in a struct.

Can you explain what 'SimpleReduction' stands for?  It isn't create to me when 
the reduction is simple...

Thanks.


https://reviews.llvm.org/D29758



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


[PATCH] D29827: [AVR] Add -mmcu option to the driver

2017-02-10 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn created this revision.

Add the AVR-specific -mmcu option for compatibility with GCC (GCC does not use
-mcpu nor -march for AVR). This option is needed to inform the frontend to
define some macros (for example) and the inform the assembler of the allowed
features, so add a test to check that.

Fixes PR#31569


https://reviews.llvm.org/D29827

Files:
  include/clang/Driver/Options.td
  lib/Driver/Tools.cpp
  test/Driver/avr-mmcu.c


Index: test/Driver/avr-mmcu.c
===
--- /dev/null
+++ test/Driver/avr-mmcu.c
@@ -0,0 +1,5 @@
+// A test for the propagation of the -mmcu option to -cc1 and -cc1as
+
+// RUN: %clang -### -target avr -mmcu=atmega328p -save-temps %s 2>&1 | 
FileCheck %s
+// CHECK: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega328p"
+// CHECK: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega328p"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2136,6 +2136,12 @@
 getARMArchCPUFromArgs(Args, MArch, MCPU, FromAs);
 return arm::getARMTargetCPU(MCPU, MArch, T);
   }
+
+  case llvm::Triple::avr:
+if (const Arg *A = Args.getLastArg(options::OPT_mmcu_EQ))
+  return A->getValue();
+return "";
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1610,6 +1610,7 @@
 def municode : Joined<["-"], "municode">, Group, 
Flags<[DriverOption]>;
 def mthreads : Joined<["-"], "mthreads">, Group, 
Flags<[DriverOption]>;
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group;
+def mmcu_EQ : Joined<["-"], "mmcu=">, Group;
 def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group;
 def mfix_and_continue : Flag<["-"], "mfix-and-continue">, 
Group;
 def mieee_fp : Flag<["-"], "mieee-fp">, Group;


Index: test/Driver/avr-mmcu.c
===
--- /dev/null
+++ test/Driver/avr-mmcu.c
@@ -0,0 +1,5 @@
+// A test for the propagation of the -mmcu option to -cc1 and -cc1as
+
+// RUN: %clang -### -target avr -mmcu=atmega328p -save-temps %s 2>&1 | FileCheck %s
+// CHECK: clang{{.*}} "-cc1" {{.*}} "-target-cpu" "atmega328p"
+// CHECK: clang{{.*}} "-cc1as" {{.*}} "-target-cpu" "atmega328p"
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2136,6 +2136,12 @@
 getARMArchCPUFromArgs(Args, MArch, MCPU, FromAs);
 return arm::getARMTargetCPU(MCPU, MArch, T);
   }
+
+  case llvm::Triple::avr:
+if (const Arg *A = Args.getLastArg(options::OPT_mmcu_EQ))
+  return A->getValue();
+return "";
+
   case llvm::Triple::mips:
   case llvm::Triple::mipsel:
   case llvm::Triple::mips64:
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1610,6 +1610,7 @@
 def municode : Joined<["-"], "municode">, Group, Flags<[DriverOption]>;
 def mthreads : Joined<["-"], "mthreads">, Group, Flags<[DriverOption]>;
 def mcpu_EQ : Joined<["-"], "mcpu=">, Group;
+def mmcu_EQ : Joined<["-"], "mmcu=">, Group;
 def mdynamic_no_pic : Joined<["-"], "mdynamic-no-pic">, Group;
 def mfix_and_continue : Flag<["-"], "mfix-and-continue">, Group;
 def mieee_fp : Flag<["-"], "mieee-fp">, Group;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D29758: [OpenMP] Parallel reduction on the NVPTX device.

2017-02-10 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: lib/CodeGen/CGOpenMPRuntime.h:956-962
   virtual void emitReduction(CodeGenFunction &CGF, SourceLocation Loc,
  ArrayRef Privates,
  ArrayRef LHSExprs,
  ArrayRef RHSExprs,
  ArrayRef ReductionOps,
- bool WithNowait, bool SimpleReduction);
+ bool WithNowait, bool SimpleReduction,
+ OpenMPDirectiveKind ReductionKind);

Number of parameters is getting too big, maybe it is better to aggregate them 
into a struct/class?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:118-133
+// GPU Configuration:  This information can be derived from cuda registers,
+// however, providing compile time constants helps generate more efficient
+// code.  For all practical purposes this is fine because the configuration
+// is the same for all known NVPTX architectures.
+enum MachineConfiguration : unsigned {
+  WarpSize = 32,
+  // Number of bits required to represent a lane identifier, which is

It's better to use `///` style of comments here



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:653-675
+/// Build int32_t __kmpc_shuffle_int32(int32_t element,
+/// int16_t lane_offset, int16_t warp_size);
+llvm::Type *TypeParams[] = {CGM.Int32Ty, CGM.Int16Ty, CGM.Int16Ty};
+llvm::FunctionType *FnTy =
+llvm::FunctionType::get(CGM.Int32Ty, TypeParams, /*isVarArg*/ false);
+RTLFn = CGM.CreateRuntimeFunction(FnTy, "__kmpc_shuffle_int32");
+break;

Use `//` instead of `///`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:963-965
+enum CopyAction : unsigned {
+  RemoteLaneToThread,
+  ThreadCopy,

Comments here?



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:969-974
+// Emit instructions to copy a Reduce list, which contains partially
+// aggregated values, in the specified direction.
+//
+// RemoteLaneToThread: Copy over a Reduce list from a remote lane in
+//   the warp using shuffle instructions.
+// ThreadCopy: Make a copy of a Reduce list on the thread's stack.

Use `///`



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1272
+
+// Emit a helper that reduces data across two OpenMP threads (lanes)
+// in the same warp.  It uses shuffle instructions to copy over data from

`///` style here



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.cpp:1488
+
+//
+// Design of OpenMP reductions on the GPU

`///` here



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.h:245
 
-public:
+  /// \brief Emit a code for reduction clause.
+  ///

Bo \brief



Comment at: lib/CodeGen/CGOpenMPRuntimeNVPTX.h:263
+
+  /// \brief Returns specified OpenMP runtime function for the current OpenMP
+  /// implementation.  Specialized for the NVPTX device.

No \brief


https://reviews.llvm.org/D29758



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


[PATCH] D29221: clang-format-vsix: "format on save" feature

2017-02-10 Thread Antonio Maiorano via Phabricator via cfe-commits
amaiorano updated this revision to Diff 88000.
amaiorano added a comment.

- Renamed VsixUtils to Vsix and TypeConverterUtils to TypeConversion
- Removed format on save mode

The change is simpler now without the "mode" (current or all documents). Now 
I'm wondering whether I should rename the feature to Format _Document_ On Save, 
and reflect this name at least in the options grid, if not the related variable 
names.


https://reviews.llvm.org/D29221

Files:
  tools/clang-format-vs/ClangFormat/ClangFormat.csproj
  tools/clang-format-vs/ClangFormat/ClangFormatPackage.cs
  tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs
  tools/clang-format-vs/ClangFormat/Vsix.cs

Index: tools/clang-format-vs/ClangFormat/Vsix.cs
===
--- /dev/null
+++ tools/clang-format-vs/ClangFormat/Vsix.cs
@@ -0,0 +1,96 @@
+using EnvDTE;
+using Microsoft.VisualStudio.Editor;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using Microsoft.VisualStudio.Text;
+using Microsoft.VisualStudio.Text.Editor;
+using Microsoft.VisualStudio.TextManager.Interop;
+using System;
+using System.IO;
+
+namespace LLVM.ClangFormat
+{
+internal sealed class Vsix
+{
+/// 
+/// Returns the currently active view if it is a IWpfTextView.
+/// 
+public static IWpfTextView GetCurrentView()
+{
+// The SVsTextManager is a service through which we can get the active view.
+var textManager = (IVsTextManager)Package.GetGlobalService(typeof(SVsTextManager));
+IVsTextView textView;
+textManager.GetActiveView(1, null, out textView);
+
+// Now we have the active view as IVsTextView, but the text interfaces we need
+// are in the IWpfTextView.
+return VsToWpfTextView(textView);
+}
+
+public static bool IsDocumentDirty(Document document)
+{
+var textView = GetDocumentView(document);
+var textDocument = GetTextDocument(textView);
+return textDocument?.IsDirty == true;
+}
+
+public static IWpfTextView GetDocumentView(Document document)
+{
+var textView = GetVsTextViewFrompPath(document.FullName);
+return VsToWpfTextView(textView);
+}
+
+public static IWpfTextView VsToWpfTextView(IVsTextView textView)
+{
+var userData = (IVsUserData)textView;
+if (userData == null)
+return null;
+Guid guidWpfViewHost = DefGuidList.guidIWpfTextViewHost;
+object host;
+userData.GetData(ref guidWpfViewHost, out host);
+return ((IWpfTextViewHost)host).TextView;
+}
+
+public static IVsTextView GetVsTextViewFrompPath(string filePath)
+{
+// From http://stackoverflow.com/a/2427368/4039972
+var dte2 = (EnvDTE80.DTE2)Package.GetGlobalService(typeof(SDTE));
+var sp = (Microsoft.VisualStudio.OLE.Interop.IServiceProvider)dte2;
+var serviceProvider = new Microsoft.VisualStudio.Shell.ServiceProvider(sp);
+
+IVsUIHierarchy uiHierarchy;
+uint itemID;
+IVsWindowFrame windowFrame;
+if (VsShellUtilities.IsDocumentOpen(serviceProvider, filePath, Guid.Empty,
+out uiHierarchy, out itemID, out windowFrame))
+{
+// Get the IVsTextView from the windowFrame.
+return VsShellUtilities.GetTextView(windowFrame);
+}
+return null;
+}
+
+public static ITextDocument GetTextDocument(IWpfTextView view)
+{
+ITextDocument document;
+if (view != null && view.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out document))
+return document;
+return null;
+}
+
+public static string GetDocumentParent(IWpfTextView view)
+{
+ITextDocument document = GetTextDocument(view);
+if (document != null)
+{
+return Directory.GetParent(document.FilePath).ToString();
+}
+return null;
+}
+
+public static string GetDocumentPath(IWpfTextView view)
+{
+return GetTextDocument(view)?.FilePath;
+}
+}
+}
Index: tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs
===
--- /dev/null
+++ tools/clang-format-vs/ClangFormat/RunningDocTableEventsDispatcher.cs
@@ -0,0 +1,79 @@
+using EnvDTE;
+using Microsoft.VisualStudio;
+using Microsoft.VisualStudio.Shell;
+using Microsoft.VisualStudio.Shell.Interop;
+using System.Linq;
+
+namespace LLVM.ClangFormat
+{
+// Exposes event sources for IVsRunningDocTableEvents3 events.
+internal sealed class RunningDocTableEventsDispatcher : IVsRunnin

[PATCH] D29806: [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-10 Thread Ehsan Akhgari via Phabricator via cfe-commits
ehsan added a comment.

In https://reviews.llvm.org/D29806#673329, @alexfh wrote:

> What's your use case? Can it be addressed by just forwarding the -p flag to 
> clang-tidy?


I just need to pass the full path to the compilation DB to clang-tidy.  The 
problem is that invoking `clang-tidy-diff.py -- -p PATH` will run `clang-tidy 
-- -p PATH`, in order words adding -p to the compiler command line, not 
clang-tidy's.

> The script shouldn't know anything about implementation details of the 
> compilation database being used (since it can be something other than JSON 
> compilation database).

I copied the code to look for the DB verbatim from run-clang-tidy.py.  I 
personally don't need the search logic, and just tried to keep this consistent 
with run-clang-tidy.py.  I'd be happy to remove the search logic if you prefer 
that.


https://reviews.llvm.org/D29806



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


[PATCH] D28286: [CodeCompletion] Code complete the missing C++11 keywords

2017-02-10 Thread Ben Langmuir via Phabricator via cfe-commits
benlangmuir accepted this revision.
benlangmuir added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

https://reviews.llvm.org/D28286



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


[clang-tools-extra] r294751 - [clang-tidy] Fix handling of function types in google-readability-casting

2017-02-10 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Fri Feb 10 08:57:19 2017
New Revision: 294751

URL: http://llvm.org/viewvc/llvm-project?rev=294751&view=rev
Log:
[clang-tidy] Fix handling of function types in google-readability-casting

Modified:
clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp

Modified: clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp?rev=294751&r1=294750&r2=294751&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/google/AvoidCStyleCastsCheck.cpp Fri Feb 
10 08:57:19 2017
@@ -73,14 +73,26 @@ void AvoidCStyleCastsCheck::check(const
   QualType SourceType = CastExpr->getSubExprAsWritten()->getType();
   QualType DestType = CastExpr->getTypeAsWritten();
 
-  if (SourceType == DestType) {
+  auto isFunction = [](QualType T) {
+T = T.getCanonicalType().getNonReferenceType();
+return T->isFunctionType() || T->isFunctionPointerType() ||
+   T->isMemberFunctionPointerType();
+  };
+
+  bool FnToFnCast = isFunction(SourceType) && isFunction(DestType);
+
+  // Function pointer/reference casts may be needed to resolve ambiguities in
+  // case of overloaded functions, so detection of redundant casts is trickier
+  // in this case. Don't emit "redundant cast" warnings for function
+  // pointer/reference types.
+  if (SourceType == DestType && !FnToFnCast) {
 diag(CastExpr->getLocStart(), "redundant cast to the same type")
 << FixItHint::CreateRemoval(ParenRange);
 return;
   }
   SourceType = SourceType.getCanonicalType();
   DestType = DestType.getCanonicalType();
-  if (SourceType == DestType) {
+  if (SourceType == DestType && !FnToFnCast) {
 diag(CastExpr->getLocStart(),
  "possibly redundant cast between typedefs of the same type");
 return;
@@ -111,27 +123,34 @@ void AvoidCStyleCastsCheck::check(const
CastExpr->getRParenLoc().getLocWithOffset(-1)),
SM, getLangOpts());
 
-  auto diag_builder =
+  auto Diag =
   diag(CastExpr->getLocStart(), "C-style casts are discouraged; use %0");
 
   auto ReplaceWithCast = [&](StringRef CastType) {
-diag_builder << CastType;
+Diag << CastType;
 
 const Expr *SubExpr = CastExpr->getSubExprAsWritten()->IgnoreImpCasts();
 std::string CastText = (CastType + "<" + DestTypeString + ">").str();
 if (!isa(SubExpr)) {
   CastText.push_back('(');
-  diag_builder << FixItHint::CreateInsertion(
+  Diag << FixItHint::CreateInsertion(
   Lexer::getLocForEndOfToken(SubExpr->getLocEnd(), 0, SM,
  getLangOpts()),
   ")");
 }
-diag_builder << FixItHint::CreateReplacement(ParenRange, CastText);
+Diag << FixItHint::CreateReplacement(ParenRange, CastText);
   };
 
   // Suggest appropriate C++ cast. See [expr.cast] for cast notation semantics.
   switch (CastExpr->getCastKind()) {
+  case CK_FunctionToPointerDecay:
+ReplaceWithCast("static_cast");
+return;
   case CK_NoOp:
+if (FnToFnCast) {
+  ReplaceWithCast("static_cast");
+  return;
+}
 if (needsConstCast(SourceType, DestType) &&
 pointedTypesAreEqual(SourceType, DestType)) {
   ReplaceWithCast("const_cast");
@@ -166,7 +185,7 @@ void AvoidCStyleCastsCheck::check(const
 break;
   }
 
-  diag_builder << "static_cast/const_cast/reinterpret_cast";
+  Diag << "static_cast/const_cast/reinterpret_cast";
 }
 
 } // namespace readability

Modified: clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp?rev=294751&r1=294750&r2=294751&view=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/google-readability-casting.cpp Fri 
Feb 10 08:57:19 2017
@@ -148,3 +148,77 @@ struct A {
   static const E ee = e;
 };
 struct B : public A {};
+
+
+void overloaded_function();
+void overloaded_function(int);
+
+template
+void g(Fn fn) {
+  fn();
+}
+
+void function_casts() {
+  typedef void (*FnPtrVoid)();
+  typedef void (&FnRefVoid)();
+  typedef void (&FnRefInt)(int);
+
+  g((void (*)())overloaded_function);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; 
use static_cast [
+  // CHECK-FIXES: g(static_cast(overloaded_function));
+  g((void (*)())&overloaded_function);
+  // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: C-style casts are discouraged; 
use static_cast [
+  // CHECK-FIXES: g(static_cast(&overloaded_function));
+  g((vo

[clang-tools-extra] r294747 - [clangd] Refactor stream output into a single thread-safe output object.

2017-02-10 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Fri Feb 10 08:08:40 2017
New Revision: 294747

URL: http://llvm.org/viewvc/llvm-project?rev=294747&view=rev
Log:
[clangd] Refactor stream output into a single thread-safe output object.

This abstracts away the passing of raw_ostreams everywhere, thread
safety will be used soon.

Modified:
clang-tools-extra/trunk/clangd/ClangDMain.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/ProtocolHandlers.cpp
clang-tools-extra/trunk/clangd/ProtocolHandlers.h

Modified: clang-tools-extra/trunk/clangd/ClangDMain.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangDMain.cpp?rev=294747&r1=294746&r2=294747&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangDMain.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangDMain.cpp Fri Feb 10 08:08:40 2017
@@ -19,6 +19,7 @@ using namespace clang::clangd;
 int main(int argc, char *argv[]) {
   llvm::raw_ostream &Outs = llvm::outs();
   llvm::raw_ostream &Logs = llvm::errs();
+  JSONOutput Out(Outs, Logs);
 
   // Change stdin to binary to not lose \r\n on windows.
   llvm::sys::ChangeStdinToBinary();
@@ -26,24 +27,24 @@ int main(int argc, char *argv[]) {
   // Set up a document store and intialize all the method handlers for JSONRPC
   // dispatching.
   DocumentStore Store;
-  JSONRPCDispatcher Dispatcher(llvm::make_unique(Outs, Logs));
+  JSONRPCDispatcher Dispatcher(llvm::make_unique(Out));
   Dispatcher.registerHandler("initialize",
- llvm::make_unique(Outs, Logs));
+ llvm::make_unique(Out));
   Dispatcher.registerHandler("shutdown",
- llvm::make_unique(Outs, Logs));
+ llvm::make_unique(Out));
   Dispatcher.registerHandler(
   "textDocument/didOpen",
-  llvm::make_unique(Outs, Logs, Store));
+  llvm::make_unique(Out, Store));
   // FIXME: Implement textDocument/didClose.
   Dispatcher.registerHandler(
   "textDocument/didChange",
-  llvm::make_unique(Outs, Logs, Store));
+  llvm::make_unique(Out, Store));
   Dispatcher.registerHandler(
   "textDocument/rangeFormatting",
-  llvm::make_unique(Outs, Logs, 
Store));
+  llvm::make_unique(Out, Store));
   Dispatcher.registerHandler(
   "textDocument/formatting",
-  llvm::make_unique(Outs, Logs, Store));
+  llvm::make_unique(Out, Store));
 
   while (std::cin.good()) {
 // A Language Server Protocol message starts with a HTTP header, delimited
@@ -89,6 +90,10 @@ int main(int argc, char *argv[]) {
   // Finally, execute the action for this JSON message.
   if (!Dispatcher.call(JSONRef))
 Logs << "JSON dispatch failed!\n";
+
+  // If we're done, exit the loop.
+  if (Out.isDone())
+break;
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=294747&r1=294746&r2=294747&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Fri Feb 10 08:08:40 
2017
@@ -15,10 +15,11 @@
 using namespace clang;
 using namespace clangd;
 
-void Handler::writeMessage(const Twine &Message) {
+void JSONOutput::writeMessage(const Twine &Message) {
   llvm::SmallString<128> Storage;
   StringRef M = Message.toStringRef(Storage);
 
+  std::lock_guard Guard(StreamMutex);
   // Log without headers.
   Logs << "--> " << M << '\n';
   Logs.flush();
@@ -29,7 +30,7 @@ void Handler::writeMessage(const Twine &
 }
 
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
-  Logs << "Method ignored.\n";
+  Output.logs() << "Method ignored.\n";
   // Return that this method is unsupported.
   writeMessage(
   R"({"jsonrpc":"2.0","id":)" + ID +
@@ -37,7 +38,7 @@ void Handler::handleMethod(llvm::yaml::M
 }
 
 void Handler::handleNotification(llvm::yaml::MappingNode *Params) {
-  Logs << "Notification ignored.\n";
+  Output.logs() << "Notification ignored.\n";
 }
 
 void JSONRPCDispatcher::registerHandler(StringRef Method,

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=294747&r1=294746&r2=294747&view=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Fri Feb 10 08:08:40 2017
@@ -13,15 +13,42 @@
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
 #include "llvm/Support/YAMLParser.h"
+#include 
 
 namespace clang {
 namespace clangd {
 
+/// Encapsulates output and logs stream

[PATCH] D29817: [AVR] Fix __AVR_xxx macro definitions

2017-02-10 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn updated this revision to Diff 87986.
Lekensteyn added a comment.

Oops, missed the avrtiny patch. After updating that, it now actually passes the 
clang-test tests.


https://reviews.llvm.org/D29817

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/avr/target-cpu-defines/atmega328p.c
  test/CodeGen/avr/target-cpu-defines/attiny104.c

Index: test/CodeGen/avr/target-cpu-defines/attiny104.c
===
--- test/CodeGen/avr/target-cpu-defines/attiny104.c
+++ test/CodeGen/avr/target-cpu-defines/attiny104.c
@@ -3,5 +3,5 @@
 
 // CHECK: #define AVR 1
 // CHECK: #define __AVR 1
-// CHECK: #define __AVR_ATtiny104 1
+// CHECK: #define __AVR_ATtiny104__ 1
 // CHECK: #define __AVR__ 1
Index: test/CodeGen/avr/target-cpu-defines/atmega328p.c
===
--- test/CodeGen/avr/target-cpu-defines/atmega328p.c
+++ test/CodeGen/avr/target-cpu-defines/atmega328p.c
@@ -3,5 +3,5 @@
 
 // CHECK: #define AVR 1
 // CHECK: #define __AVR 1
-// CHECK: #define __AVR_ATmega328P 1
+// CHECK: #define __AVR_ATmega328P__ 1
 // CHECK: #define __AVR__ 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8461,245 +8461,245 @@
 
 // This list should be kept up-to-date with AVRDevices.td in LLVM.
 static ArrayRef AVRMcus = {
-  { "at90s1200", "__AVR_AT90S1200__" },
-  { "attiny11", "__AVR_ATtiny11" },
-  { "attiny12", "__AVR_ATtiny12" },
-  { "attiny15", "__AVR_ATtiny15" },
-  { "attiny28", "__AVR_ATtiny28" },
-  { "at90s2313", "__AVR_AT90S2313" },
-  { "at90s2323", "__AVR_AT90S2323" },
-  { "at90s2333", "__AVR_AT90S2333" },
-  { "at90s2343", "__AVR_AT90S2343" },
-  { "attiny22", "__AVR_ATtiny22" },
-  { "attiny26", "__AVR_ATtiny26" },
-  { "at86rf401", "__AVR_AT86RF401" },
-  { "at90s4414", "__AVR_AT90S4414" },
-  { "at90s4433", "__AVR_AT90S4433" },
-  { "at90s4434", "__AVR_AT90S4434" },
-  { "at90s8515", "__AVR_AT90S8515" },
-  { "at90c8534", "__AVR_AT90c8534" },
-  { "at90s8535", "__AVR_AT90S8535" },
-  { "ata5272", "__AVR_ATA5272" },
-  { "attiny13", "__AVR_ATtiny13" },
-  { "attiny13a", "__AVR_ATtiny13A" },
-  { "attiny2313", "__AVR_ATtiny2313" },
-  { "attiny2313a", "__AVR_ATtiny2313A" },
-  { "attiny24", "__AVR_ATtiny24" },
-  { "attiny24a", "__AVR_ATtiny24A" },
-  { "attiny4313", "__AVR_ATtiny4313" },
-  { "attiny44", "__AVR_ATtiny44" },
-  { "attiny44a", "__AVR_ATtiny44A" },
-  { "attiny84", "__AVR_ATtiny84" },
-  { "attiny84a", "__AVR_ATtiny84A" },
-  { "attiny25", "__AVR_ATtiny25" },
-  { "attiny45", "__AVR_ATtiny45" },
-  { "attiny85", "__AVR_ATtiny85" },
-  { "attiny261", "__AVR_ATtiny261" },
-  { "attiny261a", "__AVR_ATtiny261A" },
-  { "attiny461", "__AVR_ATtiny461" },
-  { "attiny461a", "__AVR_ATtiny461A" },
-  { "attiny861", "__AVR_ATtiny861" },
-  { "attiny861a", "__AVR_ATtiny861A" },
-  { "attiny87", "__AVR_ATtiny87" },
-  { "attiny43u", "__AVR_ATtiny43U" },
-  { "attiny48", "__AVR_ATtiny48" },
-  { "attiny88", "__AVR_ATtiny88" },
-  { "attiny828", "__AVR_ATtiny828" },
-  { "at43usb355", "__AVR_AT43USB355" },
-  { "at76c711", "__AVR_AT76C711" },
-  { "atmega103", "__AVR_ATmega103" },
-  { "at43usb320", "__AVR_AT43USB320" },
-  { "attiny167", "__AVR_ATtiny167" },
-  { "at90usb82", "__AVR_AT90USB82" },
-  { "at90usb162", "__AVR_AT90USB162" },
-  { "ata5505", "__AVR_ATA5505" },
-  { "atmega8u2", "__AVR_ATmega8U2" },
-  { "atmega16u2", "__AVR_ATmega16U2" },
-  { "atmega32u2", "__AVR_ATmega32U2" },
-  { "attiny1634", "__AVR_ATtiny1634" },
-  { "atmega8", "__AVR_ATmega8" },
-  { "ata6289", "__AVR_ATA6289" },
-  { "atmega8a", "__AVR_ATmega8A" },
-  { "ata6285", "__AVR_ATA6285" },
-  { "ata6286", "__AVR_ATA6286" },
-  { "atmega48", "__AVR_ATmega48" },
-  { "atmega48a", "__AVR_ATmega48A" },
-  { "atmega48pa", "__AVR_ATmega48PA" },
-  { "atmega48p", "__AVR_ATmega48P" },
-  { "atmega88", "__AVR_ATmega88" },
-  { "atmega88a", "__AVR_ATmega88A" },
-  { "atmega88p", "__AVR_ATmega88P" },
-  { "atmega88pa", "__AVR_ATmega88PA" },
-  { "atmega8515", "__AVR_ATmega8515" },
-  { "atmega8535", "__AVR_ATmega8535" },
-  { "atmega8hva", "__AVR_ATmega8HVA" },
-  { "at90pwm1", "__AVR_AT90PWM1" },
-  { "at90pwm2", "__AVR_AT90PWM2" },
-  { "at90pwm2b", "__AVR_AT90PWM2B" },
-  { "at90pwm3", "__AVR_AT90PWM3" },
-  { "at90pwm3b", "__AVR_AT90PWM3B" },
-  { "at90pwm81", "__AVR_AT90PWM81" },
-  { "ata5790", "__AVR_ATA5790" },
-  { "ata5795", "__AVR_ATA5795" },
-  { "atmega16", "__AVR_ATmega16" },
-  { "atmega16a", "__AVR_ATmega16A" },
-  { "atmega161", "__AVR_ATmega161" },
-  { "atmega162", "__AVR_ATmega162" },
-  { "atmega163", "__AVR_ATmega163" },
-  { "atmega164a", "__AVR_ATmega164A" },
-  { "atmega164p", "__AVR_ATmega164P" },
-  { "atmega164pa", "__AVR_ATmega164PA" },
-  { "atmega165", "__AVR_ATmega165" },
-  { "atmega165a", "__AVR_ATmega165A" },
-  { "atmega165p", "__AVR_ATmega165P" },
-  { "atmega165pa", "__AVR_ATmega165PA" },
-  { "atme

[PATCH] D29819: Introduce an 'external_source_symbol' attribute that describes the origin and the nature of a declaration

2017-02-10 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch adds an `external_source_symbol` attribute to Clang. This attribute 
specifies that a declaration originates
from an external source and describes the nature of that source.

This attribute is useful for mixed-language projects or project that use 
auto-generated code. For instance, Xcode can use this attribute to provide a 
correct 'jump-to-definition' feature.  For a concrete example, consider a 
protocol that's defined in a Swift file:

  @objc public protocol SwiftProtocol {
func method()
  }

This protocol can be used from Objective-C code by including a header file that 
was generated by the Swift compiler. The declarations in that header can use 
the ``external_source_symbol`` attribute to make Clang aware of the fact that 
``SwiftProtocol`` actually originates from a Swift module:

  __attribute__((external_source_symbol(language=Swift,defined_in="module")))
  @protocol SwiftProtocol
  @required
  - (void) method;
  @end

Consequently, when 'jump-to-definition' is performed at a location that 
references `SwiftProtocol`, Xcode can jump to the original definition in the 
Swift source file rather than jumping to the Objective-C declaration in the 
auto-generated header file.

his attribute uses custom parsing to specify a varying number of clauses such 
as 'language', 'defined_in' or 'generated_declaration'. The 'language' clause 
specifies the source language from which the declaration originates. The 
'defined_in' clause specifies the name of the source container in which the 
declaration was defined (the exact definition of source container is 
language-specific, e.g. Swift's source containers are modules, so 
``defined_in`` should specify the Swift module name). The 
'generated_declaration' is a flag that specifies that whether this declaration 
was automatically generated by some tool or not.


Repository:
  rL LLVM

https://reviews.llvm.org/D29819

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticCommonKinds.td
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/Parser.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/Parser/attr-external-source-symbol-cxx11.cpp
  test/Parser/attr-external-source-symbol.m
  test/Sema/attr-external-source-symbol.c

Index: test/Sema/attr-external-source-symbol.c
===
--- /dev/null
+++ test/Sema/attr-external-source-symbol.c
@@ -0,0 +1,15 @@
+// RUN: %clang_cc1 -fsyntax-only -fblocks -verify %s
+
+void f1() __attribute__((external_source_symbol(language=Swift, defined_in="module", generated_declaration)));
+
+void f2() __attribute__((external_source_symbol(generated_declaration)));
+
+void f3()
+__attribute__((external_source_symbol)); // expected-error {{'external_source_symbol' attribute takes at least 1 argument}}
+
+void f4() {
+  int (^block)(void) = ^ (void)
+__attribute__((external_source_symbol(language=Swift))) { // expected-warning {{'external_source_symbol' attribute ignored}}
+  return 1;
+  };
+}
Index: test/Parser/attr-external-source-symbol.m
===
--- /dev/null
+++ test/Parser/attr-external-source-symbol.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+void function() __attribute__((external_source_symbol(language=Swift, defined_in="module", generated_declaration)));
+
+__attribute__((external_source_symbol(language=Swift, defined_in="module")))
+@interface I
+
+- (void)method __attribute__((external_source_symbol(defined_in= "module")));
+
+@end
+
+enum E {
+  CaseA __attribute__((external_source_symbol(generated_declaration))),
+  CaseB __attribute__((external_source_symbol(generated_declaration, language=Swift)))
+} __attribute__((external_source_symbol(language = Swift)));
+
+void f2()
+__attribute__((external_source_symbol())); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f3()
+__attribute__((external_source_symbol(invalid))); // expected-error {{expected 'language', 'defined_in', or 'generated_declaration'}}
+void f4()
+__attribute__((external_source_symbol(language))); // expected-error {{expected '=' after language}}
+void f5()
+__attribute__((external_source_symbol(language=))); // expected-error {{expected a source language , e.g., 'Swift'}}
+void f6()
+__attribute__((external_source_symbol(defined_in=20))); // expected-error {{expected string literal for source container name in 'external_source_symbol' attribute}}
Index: test/Parser/attr-external-source-symbol-cxx11.cpp
===
--- /dev/null
+++ test/Parser/attr-external-source-symbol-cxx11.cpp
@@ -0,0 +1,6 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+
+[[gnu::external_source_symbol(language=Swift, defined_in="module")]]
+void function() { }
+
+// expected-no-diagnostic

[PATCH] D29817: [AVR] Fix __AVR_xxx macro definitions

2017-02-10 Thread Dylan McKay via Phabricator via cfe-commits
dylanmckay added a comment.

Nice catch, unsure why I didn't catch this earlier.

Do we also need to modify the other tests inside `target-cpu-defines`?


https://reviews.llvm.org/D29817



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


r294740 - Wdocumentation fixes

2017-02-10 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Fri Feb 10 06:14:01 2017
New Revision: 294740

URL: http://llvm.org/viewvc/llvm-project?rev=294740&view=rev
Log:
Wdocumentation fixes

Modified:
cfe/trunk/lib/CodeGen/MacroPPCallbacks.h

Modified: cfe/trunk/lib/CodeGen/MacroPPCallbacks.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MacroPPCallbacks.h?rev=294740&r1=294739&r2=294740&view=diff
==
--- cfe/trunk/lib/CodeGen/MacroPPCallbacks.h (original)
+++ cfe/trunk/lib/CodeGen/MacroPPCallbacks.h Fri Feb 10 06:14:01 2017
@@ -78,12 +78,11 @@ class MacroPPCallbacks : public PPCallba
   /// Handle the case when entering a file.
   ///
   /// \param Loc Indicates the new location.
-  /// \Return true if file scope status should be updated.
   void FileEntered(SourceLocation Loc);
 
   /// Handle the case when exiting a file.
   ///
-  /// \Return true if file scope status should be updated.
+  /// \param Loc Indicates the new location.
   void FileExited(SourceLocation Loc);
 
 public:


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


[PATCH] D29818: [libcxx] Threading support: Attempt to externalize system_clock::now() and steady_clock::now() implementations

2017-02-10 Thread Asiri Rathnayake via Phabricator via cfe-commits
rmaprath created this revision.

These implementations depend heavily on the underlying platform. It would be 
good to put them behind a porting function within the threading API as quite a 
bit of threading functionality depend on the clocks.

The `steady_clock::now()` implementation was difficult to pluck out for 
`__APPLE__` because it uses some static functions within the library sources.

I have tested these changes on linux, I will test them on Windows and Mac 
before committing (if this gets approved).


https://reviews.llvm.org/D29818

Files:
  include/__threading_support
  src/chrono.cpp

Index: src/chrono.cpp
===
--- src/chrono.cpp
+++ src/chrono.cpp
@@ -10,50 +10,7 @@
 #include "chrono"
 #include "cerrno"// errno
 #include "system_error"  // __throw_system_error
-#include // clock_gettime, CLOCK_MONOTONIC and CLOCK_REALTIME
-
-#if (__APPLE__)
-#if defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ >= 101200
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_IPHONE_OS_VERSION_MIN_REQUIRED__ >= 10
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_TV_OS_VERSION_MIN_REQUIRED__ >= 10
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#elif defined(__ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__)
-#if __ENVIRONMENT_WATCH_OS_VERSION_MIN_REQUIRED__ >= 3
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif
-#endif // __ENVIRONMENT_.*_VERSION_MIN_REQUIRED__
-#else
-#define _LIBCXX_USE_CLOCK_GETTIME
-#endif // __APPLE__
-
-#if defined(_LIBCPP_WIN32API)
-#define WIN32_LEAN_AND_MEAN
-#define VC_EXTRA_LEAN
-#include 
-#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
-#include 
-#endif
-#else
-#if !defined(CLOCK_REALTIME) || !defined(_LIBCXX_USE_CLOCK_GETTIME)
-#include // for gettimeofday and timeval
-#endif // !defined(CLOCK_REALTIME)
-#endif // defined(_LIBCPP_WIN32API)
-
-#if !defined(_LIBCPP_HAS_NO_MONOTONIC_CLOCK)
-#if __APPLE__
-#include   // mach_absolute_time, mach_timebase_info_data_t
-#elif !defined(_LIBCPP_WIN32API) && !defined(CLOCK_MONOTONIC)
-#error "Monotonic clock not implemented"
-#endif
-#endif
+#include "__threading_support"
 
 _LIBCPP_BEGIN_NAMESPACE_STD
 
@@ -67,42 +24,7 @@
 system_clock::time_point
 system_clock::now() _NOEXCEPT
 {
-#if defined(_LIBCPP_WIN32API)
-  // FILETIME is in 100ns units
-  using filetime_duration =
-  _VSTD::chrono::duration<__int64,
-  _VSTD::ratio_multiply<_VSTD::ratio<100, 1>,
-nanoseconds::period>>;
-
-  // The Windows epoch is Jan 1 1601, the Unix epoch Jan 1 1970.
-  static _LIBCPP_CONSTEXPR const seconds nt_to_unix_epoch{11644473600};
-
-  FILETIME ft;
-#if _WIN32_WINNT >= _WIN32_WINNT_WIN8
-#if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
-  GetSystemTimePreciseAsFileTime(&ft);
-#else
-  GetSystemTimeAsFileTime(&ft);
-#endif
-#else
-  GetSystemTimeAsFileTime(&ft);
-#endif
-
-  filetime_duration d{(static_cast<__int64>(ft.dwHighDateTime) << 32) |
-   static_cast<__int64>(ft.dwLowDateTime)};
-  return time_point(duration_cast(d - nt_to_unix_epoch));
-#else
-#if defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_REALTIME)
-struct timespec tp;
-if (0 != clock_gettime(CLOCK_REALTIME, &tp))
-__throw_system_error(errno, "clock_gettime(CLOCK_REALTIME) failed");
-return time_point(seconds(tp.tv_sec) + microseconds(tp.tv_nsec / 1000));
-#else
-timeval tv;
-gettimeofday(&tv, 0);
-return time_point(seconds(tv.tv_sec) + microseconds(tv.tv_usec));
-#endif // _LIBCXX_USE_CLOCK_GETTIME && CLOCK_REALTIME
-#endif
+return __libcpp_clock_system_now();
 }
 
 time_t
@@ -193,42 +115,15 @@
 }
 #endif // defined(_LIBCXX_USE_CLOCK_GETTIME) && defined(CLOCK_UPTIME_RAW)
 
-#elif defined(_LIBCPP_WIN32API)
-
-steady_clock::time_point
-steady_clock::now() _NOEXCEPT
-{
-  static LARGE_INTEGER freq;
-  static BOOL initialized = FALSE;
-  if (!initialized)
-initialized = QueryPerformanceFrequency(&freq); // always succceeds
-
-  LARGE_INTEGER counter;
-  QueryPerformanceCounter(&counter);
-  return time_point(duration(counter.QuadPart * nano::den / freq.QuadPart));
-}
-
-#elif defined(CLOCK_MONOTONIC)
-
-// On Apple platforms only CLOCK_UPTIME_RAW or mach_absolute_time are able to
-// time functions in the nanosecond range. Thus, they are the only acceptable
-// implementations of steady_clock.
-#ifdef __APPLE__
-#error "Never use CLOCK_MONOTONIC for steady_clock::now on Apple platforms"
-#endif
+#else
 
 steady_clock::time_point
 steady_clock::now() _NOEXCEPT
 {
-struct timespec tp;
-if (0 != clock_gettime(CLOCK_MONOTONIC, &tp))
-__throw_system_error(errno, "clock_gettime(CLOCK_MONOTONIC) failed");
-return time_point(seconds(tp.tv_sec) + nanoseconds(tp.tv_

[PATCH] D29806: [clang-tidy] Add -path option to clang-tidy-diff.py

2017-02-10 Thread Alexander Kornienko via Phabricator via cfe-commits
alexfh requested changes to this revision.
alexfh added a comment.
This revision now requires changes to proceed.

What's your use case? Can it be addressed by just forwarding the -p flag to 
clang-tidy?

The script shouldn't know anything about implementation details of the 
compilation database being used (since it can be something other than JSON 
compilation database).


https://reviews.llvm.org/D29806



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


[PATCH] D29817: [AVR} Fix __AVR_xxx macro definitions

2017-02-10 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn added a comment.

Without this patch, compilation of a program using avr/io.h fails. Tested with:

  clang --target=avr -Xclang -target-cpu -Xclang atmega328p -I/usr/avr/include 
-Os led.c -c -o /dev/null

Btw, it seems that avr-libc 2.0.0 also uses `__AVR_ARCH__`, `__AVR_XMEGA__` and 
`__AVR_3_BYTE_PC__` in some places, but these are not defined in Clang.


https://reviews.llvm.org/D29817



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


[PATCH] D29817: [AVR} Fix __AVR_xxx macro definitions

2017-02-10 Thread Peter Wu via Phabricator via cfe-commits
Lekensteyn created this revision.

The -mmcu option for GCC sets macros like __AVR_ATmega328P__ (with the trailing
underscores), be sure to include these underscores for Clangs -mcpu option.

See "AVR Built-in Macros" in https://gcc.gnu.org/onlinedocs/gcc/AVR-Options.html


https://reviews.llvm.org/D29817

Files:
  lib/Basic/Targets.cpp
  test/CodeGen/avr/target-cpu-defines/atmega328p.c

Index: test/CodeGen/avr/target-cpu-defines/atmega328p.c
===
--- test/CodeGen/avr/target-cpu-defines/atmega328p.c
+++ test/CodeGen/avr/target-cpu-defines/atmega328p.c
@@ -3,5 +3,5 @@
 
 // CHECK: #define AVR 1
 // CHECK: #define __AVR 1
-// CHECK: #define __AVR_ATmega328P 1
+// CHECK: #define __AVR_ATmega328P__ 1
 // CHECK: #define __AVR__ 1
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -8461,245 +8461,245 @@
 
 // This list should be kept up-to-date with AVRDevices.td in LLVM.
 static ArrayRef AVRMcus = {
-  { "at90s1200", "__AVR_AT90S1200__" },
-  { "attiny11", "__AVR_ATtiny11" },
-  { "attiny12", "__AVR_ATtiny12" },
-  { "attiny15", "__AVR_ATtiny15" },
-  { "attiny28", "__AVR_ATtiny28" },
-  { "at90s2313", "__AVR_AT90S2313" },
-  { "at90s2323", "__AVR_AT90S2323" },
-  { "at90s2333", "__AVR_AT90S2333" },
-  { "at90s2343", "__AVR_AT90S2343" },
-  { "attiny22", "__AVR_ATtiny22" },
-  { "attiny26", "__AVR_ATtiny26" },
-  { "at86rf401", "__AVR_AT86RF401" },
-  { "at90s4414", "__AVR_AT90S4414" },
-  { "at90s4433", "__AVR_AT90S4433" },
-  { "at90s4434", "__AVR_AT90S4434" },
-  { "at90s8515", "__AVR_AT90S8515" },
-  { "at90c8534", "__AVR_AT90c8534" },
-  { "at90s8535", "__AVR_AT90S8535" },
-  { "ata5272", "__AVR_ATA5272" },
-  { "attiny13", "__AVR_ATtiny13" },
-  { "attiny13a", "__AVR_ATtiny13A" },
-  { "attiny2313", "__AVR_ATtiny2313" },
-  { "attiny2313a", "__AVR_ATtiny2313A" },
-  { "attiny24", "__AVR_ATtiny24" },
-  { "attiny24a", "__AVR_ATtiny24A" },
-  { "attiny4313", "__AVR_ATtiny4313" },
-  { "attiny44", "__AVR_ATtiny44" },
-  { "attiny44a", "__AVR_ATtiny44A" },
-  { "attiny84", "__AVR_ATtiny84" },
-  { "attiny84a", "__AVR_ATtiny84A" },
-  { "attiny25", "__AVR_ATtiny25" },
-  { "attiny45", "__AVR_ATtiny45" },
-  { "attiny85", "__AVR_ATtiny85" },
-  { "attiny261", "__AVR_ATtiny261" },
-  { "attiny261a", "__AVR_ATtiny261A" },
-  { "attiny461", "__AVR_ATtiny461" },
-  { "attiny461a", "__AVR_ATtiny461A" },
-  { "attiny861", "__AVR_ATtiny861" },
-  { "attiny861a", "__AVR_ATtiny861A" },
-  { "attiny87", "__AVR_ATtiny87" },
-  { "attiny43u", "__AVR_ATtiny43U" },
-  { "attiny48", "__AVR_ATtiny48" },
-  { "attiny88", "__AVR_ATtiny88" },
-  { "attiny828", "__AVR_ATtiny828" },
-  { "at43usb355", "__AVR_AT43USB355" },
-  { "at76c711", "__AVR_AT76C711" },
-  { "atmega103", "__AVR_ATmega103" },
-  { "at43usb320", "__AVR_AT43USB320" },
-  { "attiny167", "__AVR_ATtiny167" },
-  { "at90usb82", "__AVR_AT90USB82" },
-  { "at90usb162", "__AVR_AT90USB162" },
-  { "ata5505", "__AVR_ATA5505" },
-  { "atmega8u2", "__AVR_ATmega8U2" },
-  { "atmega16u2", "__AVR_ATmega16U2" },
-  { "atmega32u2", "__AVR_ATmega32U2" },
-  { "attiny1634", "__AVR_ATtiny1634" },
-  { "atmega8", "__AVR_ATmega8" },
-  { "ata6289", "__AVR_ATA6289" },
-  { "atmega8a", "__AVR_ATmega8A" },
-  { "ata6285", "__AVR_ATA6285" },
-  { "ata6286", "__AVR_ATA6286" },
-  { "atmega48", "__AVR_ATmega48" },
-  { "atmega48a", "__AVR_ATmega48A" },
-  { "atmega48pa", "__AVR_ATmega48PA" },
-  { "atmega48p", "__AVR_ATmega48P" },
-  { "atmega88", "__AVR_ATmega88" },
-  { "atmega88a", "__AVR_ATmega88A" },
-  { "atmega88p", "__AVR_ATmega88P" },
-  { "atmega88pa", "__AVR_ATmega88PA" },
-  { "atmega8515", "__AVR_ATmega8515" },
-  { "atmega8535", "__AVR_ATmega8535" },
-  { "atmega8hva", "__AVR_ATmega8HVA" },
-  { "at90pwm1", "__AVR_AT90PWM1" },
-  { "at90pwm2", "__AVR_AT90PWM2" },
-  { "at90pwm2b", "__AVR_AT90PWM2B" },
-  { "at90pwm3", "__AVR_AT90PWM3" },
-  { "at90pwm3b", "__AVR_AT90PWM3B" },
-  { "at90pwm81", "__AVR_AT90PWM81" },
-  { "ata5790", "__AVR_ATA5790" },
-  { "ata5795", "__AVR_ATA5795" },
-  { "atmega16", "__AVR_ATmega16" },
-  { "atmega16a", "__AVR_ATmega16A" },
-  { "atmega161", "__AVR_ATmega161" },
-  { "atmega162", "__AVR_ATmega162" },
-  { "atmega163", "__AVR_ATmega163" },
-  { "atmega164a", "__AVR_ATmega164A" },
-  { "atmega164p", "__AVR_ATmega164P" },
-  { "atmega164pa", "__AVR_ATmega164PA" },
-  { "atmega165", "__AVR_ATmega165" },
-  { "atmega165a", "__AVR_ATmega165A" },
-  { "atmega165p", "__AVR_ATmega165P" },
-  { "atmega165pa", "__AVR_ATmega165PA" },
-  { "atmega168", "__AVR_ATmega168" },
-  { "atmega168a", "__AVR_ATmega168A" },
-  { "atmega168p", "__AVR_ATmega168P" },
-  { "atmega168pa", "__AVR_ATmega168PA" },
-  { "atmega169", "__AVR_ATmega169" },
-  { "atmega169a", "__AVR_ATmega169A" },
-  { "atmega169p", "__AVR_ATmega169P" },
-  { "atmega169pa", "__AVR_ATmega169PA" },
-  { "atmega32", "__AVR_ATmega32" },

[libcxx] r294732 - Fix yet another Apple buildit bug

2017-02-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb 10 03:25:15 2017
New Revision: 294732

URL: http://llvm.org/viewvc/llvm-project?rev=294732&view=rev
Log:
Fix yet another Apple buildit bug

Modified:
libcxx/trunk/src/typeinfo.cpp

Modified: libcxx/trunk/src/typeinfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/typeinfo.cpp?rev=294732&r1=294731&r2=294732&view=diff
==
--- libcxx/trunk/src/typeinfo.cpp (original)
+++ libcxx/trunk/src/typeinfo.cpp Fri Feb 10 03:25:15 2017
@@ -9,8 +9,10 @@
 
 #include "typeinfo"
 
+// FIXME: Remove __APPLE__ default here once buildit is gone.
 #if (!defined(_LIBCPP_ABI_MICROSOFT) && !defined(LIBCXX_BUILDING_LIBCXXABI) && 
\
-!defined(LIBCXXRT) && !defined(__GLIBCXX__)) || \
+!defined(LIBCXXRT) && !defined(__GLIBCXX__) && \
+!defined(__APPLE__)) || \
 defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY) // FIXME: remove this 
configuration.
 std::type_info::~type_info()
 {


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


[PATCH] D29621: Add ASTMatchRefactorer and ReplaceNodeWithTemplate to RefactoringCallbacks

2017-02-10 Thread Eric Liu via Phabricator via cfe-commits
ioeric accepted this revision.
ioeric added a comment.
This revision is now accepted and ready to land.

Looks good. Could you also add test cases where 
`ReplaceNodeWithTemplate::create` fails to parse templates?


https://reviews.llvm.org/D29621



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


[libcxx] r294731 - Attempt to fix Apple buildit bots

2017-02-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb 10 03:16:29 2017
New Revision: 294731

URL: http://llvm.org/viewvc/llvm-project?rev=294731&view=rev
Log:
Attempt to fix Apple buildit bots

Modified:
libcxx/trunk/src/new.cpp

Modified: libcxx/trunk/src/new.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/src/new.cpp?rev=294731&r1=294730&r2=294731&view=diff
==
--- libcxx/trunk/src/new.cpp (original)
+++ libcxx/trunk/src/new.cpp Fri Feb 10 03:16:29 2017
@@ -23,7 +23,11 @@
 #elif defined(__GLIBCXX__)
 // nothing todo
 #else
-#include "support/runtime/new_handler_fallback.ipp"
+# if defined(__APPLE__) && !defined(_LIBCPP_BUILDING_HAS_NO_ABI_LIBRARY)
+#   include  // FIXME: remove this once buildit is gone.
+# else
+#   include "support/runtime/new_handler_fallback.ipp"
+# endif
 #endif
 
 namespace std


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


[libcxx] r294730 - Recommit "Split exception.cpp and new.cpp implementation into different files for different runtimes."

2017-02-10 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Fri Feb 10 02:57:35 2017
New Revision: 294730

URL: http://llvm.org/viewvc/llvm-project?rev=294730&view=rev
Log:
Recommit "Split exception.cpp and new.cpp implementation into different files 
for different runtimes."

This recommits r294707 with additional fixes. The main difference is
libc++ now correctly builds without any ABI library.

exception.cpp is a bloody mess. It's full of confusing #ifdef branches for
each different ABI library we support, and it's getting unmaintainable.

This patch breaks down exception.cpp into multiple different header files,
roughly one per implementation. Additionally it moves the definitions of
exceptions in new.cpp into the correct implementation header.

This patch also removes an unmaintained libc++abi configuration.
This configuration may still be used by Apple internally but there
are no other possible users. If it turns out that Apple still uses
this configuration internally I will re-add it in a later commit.
See http://llvm.org/PR31904.

Added:
libcxx/trunk/src/support/runtime/exception_fallback.ipp
libcxx/trunk/src/support/runtime/exception_glibcxx.ipp
libcxx/trunk/src/support/runtime/exception_libcxxabi.ipp
libcxx/trunk/src/support/runtime/exception_libcxxrt.ipp
libcxx/trunk/src/support/runtime/exception_msvc.ipp
libcxx/trunk/src/support/runtime/exception_pointer_cxxabi.ipp
libcxx/trunk/src/support/runtime/exception_pointer_glibcxx.ipp
libcxx/trunk/src/support/runtime/exception_pointer_unimplemented.ipp
libcxx/trunk/src/support/runtime/new_handler_fallback.ipp
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
libcxx/trunk/include/exception
libcxx/trunk/include/new
libcxx/trunk/include/typeinfo
libcxx/trunk/src/exception.cpp
libcxx/trunk/src/new.cpp
libcxx/trunk/src/typeinfo.cpp

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=294730&r1=294729&r2=294730&view=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Fri Feb 10 02:57:35 2017
@@ -125,6 +125,9 @@ if (LIBCXX_CXX_ABI STREQUAL "default")
 if (LIBCXX_TARGETING_MSVC)
   # FIXME: Figure out how to configure the ABI library on Windows.
   set(LIBCXX_CXX_ABI_LIBNAME "vcruntime")
+elseif(APPLE)
+  set(LIBCXX_CXX_ABI_LIBNAME "libcxxabi")
+  set(LIBCXX_CXX_ABI_SYSTEM 1)
 else()
   set(LIBCXX_CXX_ABI_LIBNAME "default")
 endif()

Modified: libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake?rev=294730&r1=294729&r2=294730&view=diff
==
--- libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleLibCXXABI.cmake Fri Feb 10 02:57:35 2017
@@ -103,9 +103,11 @@ elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STRE
 # Assume c++abi is installed in the system, rely on -lc++abi link flag.
 set(CXXABI_LIBNAME "c++abi")
   endif()
-  setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI"
-${CXXABI_LIBNAME} "cxxabi.h;__cxxabi_config.h" ""
-)
+  set(HEADERS "cxxabi.h;__cxxabi_config.h")
+  if (LIBCXX_CXX_ABI_SYSTEM)
+set(HEADERS "")
+  endif()
+  setup_abi_lib("-DLIBCXX_BUILDING_LIBCXXABI" ${CXXABI_LIBNAME} "${HEADERS}" 
"")
 elseif ("${LIBCXX_CXX_ABI_LIBNAME}" STREQUAL "libcxxrt")
   setup_abi_lib("-DLIBCXXRT"
 "cxxrt" "cxxabi.h;unwind.h;unwind-arm.h;unwind-itanium.h" ""

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=294730&r1=294729&r2=294730&view=diff
==
--- libcxx/trunk/include/exception (original)
+++ libcxx/trunk/include/exception Fri Feb 10 02:57:35 2017
@@ -82,6 +82,10 @@ template  void rethrow_if_neste
 #include 
 #include 
 
+#if defined(_LIBCPP_ABI_MICROSOFT)
+#include 
+#endif
+
 #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
 #pragma GCC system_header
 #endif
@@ -89,6 +93,7 @@ template  void rethrow_if_neste
 namespace std  // purposefully not using versioning namespace
 {
 
+#if !defined(_LIBCPP_ABI_MICROSOFT)
 class _LIBCPP_EXCEPTION_ABI exception
 {
 public:
@@ -105,6 +110,7 @@ public:
 virtual ~bad_exception() _NOEXCEPT;
 virtual const char* what() const _NOEXCEPT;
 };
+#endif // !_LIBCPP_ABI_MICROSOFT
 
 typedef void (*unexpected_handler)();
 _LIBCPP_FUNC_VIS unexpected_handler set_unexpected(unexpected_handler) 
_NOEXCEPT;

Modified: libcxx/trunk/include/new
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/new?rev=294730&r1=294729&r2=294730&view=diff
==
--- libcxx/trunk/include/new (original)
+++ libcxx/trunk/include/new Fri Feb 10 02:57:35 20