Re: r266186 - Enable support for __float128 in Clang

2016-04-14 Thread Hal Finkel via cfe-commits
- Original Message -
> From: "Hans Wennborg via cfe-commits" 
> To: "Nemanja Ivanovic" , "Nico Weber" 
> 
> Cc: "cfe-commits" 
> Sent: Thursday, April 14, 2016 8:07:58 PM
> Subject: Re: r266186 - Enable support for __float128 in Clang
> 
> On Wed, Apr 13, 2016 at 2:49 AM, Nemanja Ivanovic via cfe-commits
>  wrote:
> > Author: nemanjai
> > Date: Wed Apr 13 04:49:45 2016
> > New Revision: 266186
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=266186=rev
> > Log:
> > Enable support for __float128 in Clang
> >
> > This patch corresponds to review:
> > http://reviews.llvm.org/D15120
> >
> > It adds support for the __float128 keyword, literals and a target
> > feature to
> > enable it. This support is disabled by default on all targets and
> > any target
> > that has support for this type is free to add it.
> >
> > Based on feedback that I've received from target maintainers, this
> > appears to
> > be the right thing for most targets. I have not heard from the
> > maintainers of
> > X86 which I believe supports this type. I will subsequently
> > investigate the
> > impact of enabling this on X86.
> 
> We're seeing build errors when targeting Android, which I think may
> be
> caused by this:
> 
> [...]
> In file included from ../../v8/src/base/functional.cc:11:
> In file included from ../../v8/src/base/functional.h:13:
> In file included from
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/functional:55:
> In file included from
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/tuple:38:
> In file included from
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/utility:70:
> In file included from
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_pair.h:59:
> In file included from
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/move.h:57:
> /usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:269:39:
> error: __float128 is not supported on this target
> struct __is_floating_point_helper<__float128>
>   ^
> 
> (From
> https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/54128/steps/compile%20%28with%20patch%29/logs/stdio)
> 
> Any idea what might be breaking here?

Yep, see: http://reviews.llvm.org/D19125

 -Hal

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

-- 
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19006: [libcxx] Remove the "reduced-arity-initialization" extension from the uses-allocator constructors

2016-04-14 Thread Eric Fiselier via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266409: [libcxx] Remove the "reduced-arity-initialization" 
extension from the uses… (authored by EricWF).

Changed prior to commit:
  http://reviews.llvm.org/D19006?vs=53813=53835#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19006

Files:
  libcxx/trunk/include/tuple
  libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
  
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp

Index: libcxx/trunk/include/tuple
===
--- libcxx/trunk/include/tuple
+++ libcxx/trunk/include/tuple
@@ -384,6 +384,9 @@
 : is_same<__all<_Pred...>, __all<(_Pred, true)...>>
 { };
 
+template 
+struct __lazy_all : __all<_Tp::value...> {};
+
 template 
 struct __all_default_constructible;
 
@@ -523,6 +526,19 @@
 _LIBCPP_CONSTEXPR tuple()
 _NOEXCEPT_(__all::value...>::value) {}
 
+template ,
+__lazy_all<__dependent_type, _Dummy>...>
+   >::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+tuple(_AllocArgT, _Alloc const& __a)
+  : base_(allocator_arg_t(), __a,
+__tuple_indices<>(), __tuple_types<>(),
+typename __make_tuple_indices::type(),
+__tuple_types<_Tp...>()) {}
+
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 explicit tuple(const _Tp& ... __t) _NOEXCEPT_((__all::value...>::value)) 
 : base_(typename __make_tuple_indices::type(),
@@ -631,21 +647,8 @@
 template ,
-typename __make_tuple_types::type
- >::value &&
- __all_default_constructible<
-typename __make_tuple_types::type
- >::value
+ sizeof...(_Up) == sizeof...(_Tp) &&
+ __tuple_convertible, tuple>::value
   >::type
  >
 _LIBCPP_INLINE_VISIBILITY
Index: libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
===
--- libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
+++ libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
@@ -24,67 +24,51 @@
 #include "../alloc_first.h"
 #include "../alloc_last.h"
 
-struct NoDefault { NoDefault() = delete; };
+template 
+struct DefaultCtorBlowsUp {
+  constexpr DefaultCtorBlowsUp() {
+  static_assert(!std::is_same::value, "Default Ctor instantiated");
+  }
 
-// Make sure the _Up... constructor SFINAEs out when the types that
-// are not explicitly initialized are not all default constructible.
-// Otherwise, std::is_constructible would return true but instantiating
-// the constructor would fail.
-void test_default_constructible_extension_sfinae()
+  explicit constexpr DefaultCtorBlowsUp(int x) : value(x) {}
+
+  int value;
+};
+
+
+struct DerivedFromAllocArgT : std::allocator_arg_t {};
+
+
+// Make sure the _Up... constructor SFINAEs out when the number of initializers
+// is less that the number of elements in the tuple. Previously libc++ would
+// offer these constructers as an extension but they broke conforming code.
+void test_uses_allocator_sfinae_evaluation()
 {
+ using BadDefault = DefaultCtorBlowsUp<>;
 {
-typedef std::tuple Tuple;
+typedef std::tuple Tuple;
 
 static_assert(!std::is_constructible<
 Tuple,
 std::allocator_arg_t, A1, MoveOnly
 >::value, "");
 
 static_assert(std::is_constructible<
 Tuple,
-std::allocator_arg_t, A1, MoveOnly, NoDefault
+std::allocator_arg_t, A1, MoveOnly, MoveOnly, BadDefault
 >::value, "");
 }
 {
-typedef std::tuple Tuple;
+typedef std::tuple Tuple;
 
 static_assert(!std::is_constructible<
 Tuple,
 std::allocator_arg_t, A1, MoveOnly, MoveOnly
 >::value, "");
 
 static_assert(std::is_constructible<
 Tuple,
-std::allocator_arg_t, A1, MoveOnly, MoveOnly, NoDefault
->::value, "");
-}
-{
-

[libcxx] r266409 - [libcxx] Remove the "reduced-arity-initialization" extension from the uses-allocator constructors

2016-04-14 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Thu Apr 14 22:29:40 2016
New Revision: 266409

URL: http://llvm.org/viewvc/llvm-project?rev=266409=rev
Log:
[libcxx] Remove the "reduced-arity-initialization" extension from the 
uses-allocator constructors

Summary:
A default uses-allocator constructor has been added since that overload was 
previously provided by the extended constructor.

Since Clang does implicit conversion checking after substitution this 
constructor has to deduce the allocator_arg_t parameter so that it can prevent 
the evaluation of "is_default_constructible" if the first argument doesn't 
match. See http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1391 
for more information.

This patch fixes PR24779 (https://llvm.org/bugs/show_bug.cgi?id=24779)

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19006

Modified:
libcxx/trunk/include/tuple
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp

libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp

Modified: libcxx/trunk/include/tuple
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/tuple?rev=266409=266408=266409=diff
==
--- libcxx/trunk/include/tuple (original)
+++ libcxx/trunk/include/tuple Thu Apr 14 22:29:40 2016
@@ -384,6 +384,9 @@ struct __all
 : is_same<__all<_Pred...>, __all<(_Pred, true)...>>
 { };
 
+template 
+struct __lazy_all : __all<_Tp::value...> {};
+
 template 
 struct __all_default_constructible;
 
@@ -523,6 +526,19 @@ public:
 _LIBCPP_CONSTEXPR tuple()
 
_NOEXCEPT_(__all::value...>::value) {}
 
+template ,
+__lazy_all<__dependent_type, 
_Dummy>...>
+   >::value
+>::type>
+_LIBCPP_INLINE_VISIBILITY
+tuple(_AllocArgT, _Alloc const& __a)
+  : base_(allocator_arg_t(), __a,
+__tuple_indices<>(), __tuple_types<>(),
+typename __make_tuple_indices::type(),
+__tuple_types<_Tp...>()) {}
+
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 explicit tuple(const _Tp& ... __t) 
_NOEXCEPT_((__all::value...>::value)) 
 : base_(typename __make_tuple_indices::type(),
@@ -631,21 +647,8 @@ public:
 template ,
-typename __make_tuple_types::type
- >::value &&
- __all_default_constructible<
-typename __make_tuple_types::type
- >::value
+ sizeof...(_Up) == sizeof...(_Tp) &&
+ __tuple_convertible, tuple>::value
   >::type
  >
 _LIBCPP_INLINE_VISIBILITY

Modified: 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp?rev=266409=266408=266409=diff
==
--- 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp 
Thu Apr 14 22:29:40 2016
@@ -24,12 +24,28 @@
 #include "../alloc_first.h"
 #include "../alloc_last.h"
 
+template 
+struct NonDefaultConstructible {
+  constexpr NonDefaultConstructible() {
+  static_assert(!std::is_same::value, "Default Ctor instantiated");
+  }
+
+  explicit constexpr NonDefaultConstructible(int) {}
+};
+
+
+struct DerivedFromAllocArgT : std::allocator_arg_t {};
+
 int main()
 {
 {
 std::tuple<> t(std::allocator_arg, A1());
 }
 {
+DerivedFromAllocArgT tag;
+std::tuple<> t(tag, A1());
+}
+{
 std::tuple t(std::allocator_arg, A1());
 assert(std::get<0>(t) == 0);
 }
@@ -78,4 +94,29 @@ int main()
 assert(!alloc_last::allocator_constructed);
 assert(std::get<2>(t) == alloc_last());
 }
+{
+// Test that allocator construction is selected when the user provides
+// a custom tag type which derives from allocator_arg_t.
+DerivedFromAllocArgT tag;
+alloc_first::allocator_constructed = false;
+alloc_last::allocator_constructed = false;
+
+std::tuple t(tag, A1(5));
+
+

[PATCH] D19146: [clang-tidy] New checker to detect suspicious string constructor.

2016-04-14 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

Checker to validate string constructor parameters.

A common mistake is to swap parameter for the fill-constructor.
```
  std::string str('x', 4);
  std::string str('4', x);
```

http://reviews.llvm.org/D19146

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/StringConstructorCheck.cpp
  clang-tidy/misc/StringConstructorCheck.h
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-string-constructor.rst
  test/clang-tidy/misc-string-constructor.cpp

Index: test/clang-tidy/misc-string-constructor.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-string-constructor.cpp
@@ -0,0 +1,50 @@
+// RUN: %check_clang_tidy %s misc-string-constructor %t
+
+namespace std {
+template 
+class allocator {};
+template 
+class char_traits {};
+template , typename A = std::allocator >
+struct basic_string {
+  basic_string();
+  basic_string(const C*, unsigned int size);
+  basic_string(unsigned int size, C c);
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+const char* kText = "";
+const char kText2[] = "";
+extern const char kText3[];
+
+void Test() {
+  std::string str('x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor parameters are probably swapped [misc-string-constructor]
+  std::wstring wstr(L'x', 4);
+  // CHECK-MESSAGES: [[@LINE-1]]:16: warning: constructor parameters are probably swapped
+  std::string s0(0, 'x');
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
+  std::string s1(-4, 'x');
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
+  
+  std::string q0("test", 0);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: constructor creating an empty string
+  std::string q1(kText, -4);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: negative value used as length parameter
+  std::string q2("test", 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
+  std::string q3(kText, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
+  std::string q4(kText2, 200);
+  // CHECK-MESSAGES: [[@LINE-1]]:15: warning: length is bigger then string literal size
+}
+
+void Valid() {
+  std::string empty();
+  std::string str(4, 'x');
+  std::wstring wstr(4, L'x');
+  std::string s1("test", 4);
+  std::string s2("test", 3);
+}
Index: docs/clang-tidy/checks/misc-string-constructor.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-string-constructor.rst
@@ -0,0 +1,36 @@
+.. title:: clang-tidy - misc-string-constructor
+
+misc-string-constructor
+===
+
+Finds string constructors that are suspicious and probably errors.
+
+
+A common mistake is to swap parameters to the 'fill' string-constructor.
+
+Examples:
+
+.. code:: c++
+
+  std::string('x', 50) str // should be std::string(50, 'x') 
+
+
+Calling the string-literal constructor with a length bigger than the literal is
+suspicious and adds extra random characters to the string.
+
+Examples:
+
+.. code:: c++
+
+  std::string("test", 200);   // Will include random characters after "test".
+
+
+Creating an empty string from constructors with parameters is considered
+suspicious. The programmer should use the empty constructor instead.
+
+Examples:
+
+.. code:: c++
+
+  std::string("test", 0);   // Creation of an empty string.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -67,6 +67,7 @@
misc-non-copyable-objects
misc-sizeof-container
misc-static-assert
+   misc-string-constructor
misc-string-integer-assignment
misc-string-literal-with-embedded-nul
misc-suspicious-missing-comma
Index: clang-tidy/misc/StringConstructorCheck.h
===
--- /dev/null
+++ clang-tidy/misc/StringConstructorCheck.h
@@ -0,0 +1,39 @@
+//===--- StringConstructorCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_CONSTRUCTOR_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_STRING_CONSTRUCTOR_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Finds suspicious string constructor and check their parameters.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-string-constructor.html

[PATCH] D19144: Handle TemplateArgument in DynTypedNode comparison operations.

2016-04-14 Thread Alexander Kornienko via cfe-commits
alexfh created this revision.
alexfh added reviewers: sbenza, bkramer.
alexfh added a subscriber: cfe-commits.

This patch fixes an assertion failure on some matchers containing
templateArgument() on some code in some configurations. I couldn't come up with 
a
consistent repro, since the failure depens on the order of elements in a map.
http://reviews.llvm.org/D18136 contains a matcher that causes the issue at least
on some configurations.

The fix turned out to require non-trivial amount of code, very similar to
TemplateArgument::structurallyEquals. I'd prefer to use
TemplateArgument::Profile, if it was possible without ASTContext. Another
alternative would be to add operator< for TemplateArgument, but since it's only
needed in DynTypedNode, I decided to make this code private to DynTypedNode.

http://reviews.llvm.org/D19144

Files:
  include/clang/AST/ASTTypeTraits.h
  lib/AST/ASTTypeTraits.cpp
  unittests/AST/ASTTypeTraitsTest.cpp

Index: unittests/AST/ASTTypeTraitsTest.cpp
===
--- unittests/AST/ASTTypeTraitsTest.cpp
+++ unittests/AST/ASTTypeTraitsTest.cpp
@@ -180,5 +180,65 @@
   EXPECT_FALSE(Node < Node);
 }
 
+TEST(DynTypedNode, TemplateArgumentNull) {
+  TemplateArgument T;
+  DynTypedNode Node = DynTypedNode::create(T);
+  EXPECT_TRUE(Node == Node);
+  EXPECT_FALSE(Node < Node);
+}
+
+TEST(DynTypedNode, TemplateArgumentQualType) {
+  QualType QT;
+  TemplateArgument T(QT);
+  DynTypedNode Node = DynTypedNode::create(T);
+  EXPECT_TRUE(Node == Node);
+  EXPECT_FALSE(Node < Node);
+}
+
+TEST(DynTypedNode, TemplateArgumentNullPtr) {
+  QualType QT;
+  TemplateArgument T(QT, true);
+  DynTypedNode Node = DynTypedNode::create(T);
+  EXPECT_TRUE(Node == Node);
+  EXPECT_FALSE(Node < Node);
+}
+
+TEST(DynTypedNode, TemplateArgumentExpr) {
+  BuiltinType Void(BuiltinType::Void);
+  QualType QT(, 0);
+  NoInitExpr E(QT);
+  TemplateArgument T();
+  DynTypedNode Node = DynTypedNode::create(T);
+  EXPECT_TRUE(Node == Node);
+  EXPECT_FALSE(Node < Node);
+}
+
+TEST(DynTypedNode, TemplateArgumentTemplate) {
+  TemplateName TN;
+  TemplateArgument T(TN);
+  DynTypedNode Node = DynTypedNode::create(T);
+  EXPECT_TRUE(Node == Node);
+  EXPECT_FALSE(Node < Node);
+}
+
+TEST(DynTypedNode, TemplateArgumentTemplateExpansion) {
+  TemplateName TN;
+  TemplateArgument T(TN, llvm::Optional(0u));
+  DynTypedNode Node = DynTypedNode::create(T);
+  EXPECT_TRUE(Node == Node);
+  EXPECT_FALSE(Node < Node);
+}
+
+TEST(DynTypedNode, TemplateArgumentPack) {
+  TemplateArgument TP[1];
+  TemplateArgument T(TP);
+  DynTypedNode Node = DynTypedNode::create(T);
+  EXPECT_TRUE(Node == Node);
+  EXPECT_FALSE(Node < Node);
+}
+
+// FIXME: Figure out how to test TemplateArgument of the Declaration and
+// Integral kinds.
+
 }  // namespace ast_type_traits
 }  // namespace clang
Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -150,5 +150,54 @@
   return SourceRange();
 }
 
+bool DynTypedNode::TemplateArgumentLess(const TemplateArgument ,
+const TemplateArgument ) {
+  if (LHS.getKind() != RHS.getKind()) return LHS.getKind() < RHS.getKind();
+
+  switch (LHS.getKind()) {
+case TemplateArgument::Null:
+  return false;
+
+case TemplateArgument::Type:
+  return LHS.getAsType().getAsOpaquePtr() <
+ RHS.getAsType().getAsOpaquePtr();
+
+case TemplateArgument::Expression:
+  return LHS.getAsExpr() < RHS.getAsExpr();
+
+case TemplateArgument::Template:
+case TemplateArgument::TemplateExpansion:
+  return LHS.getAsTemplateOrTemplatePattern().getAsVoidPointer() <
+ RHS.getAsTemplateOrTemplatePattern().getAsVoidPointer();
+
+case TemplateArgument::NullPtr:
+  return LHS.getNullPtrType().getAsOpaquePtr() <
+ RHS.getNullPtrType().getAsOpaquePtr();
+
+case TemplateArgument::Pack: {
+  if (LHS.pack_size() != RHS.pack_size())
+return LHS.pack_size() < RHS.pack_size();
+  auto PackA = LHS.getPackAsArray();
+  auto PackB = RHS.getPackAsArray();
+  for (unsigned I = 0, E = PackA.size(); I != E; ++I)
+if (!PackA[I].structurallyEquals(PackB[I]))
+  return TemplateArgumentLess(PackA[I], PackB[I]);
+  return false;
+}
+
+case TemplateArgument::Declaration:
+  return (LHS.getAsDecl() ? LHS.getAsDecl()->getCanonicalDecl() : nullptr) <
+ (RHS.getAsDecl() ? RHS.getAsDecl()->getCanonicalDecl() : nullptr);
+
+case TemplateArgument::Integral:
+  return std::make_pair(LHS.getIntegralType().getAsOpaquePtr(),
+LHS.getAsIntegral()) <
+ std::make_pair(RHS.getIntegralType().getAsOpaquePtr(),
+RHS.getAsIntegral());
+
+  }
+  llvm_unreachable("Unsupported or invalid TemplateArgument kind");
+}
+
 } // end namespace ast_type_traits
 } // 

Re: r266186 - Enable support for __float128 in Clang

2016-04-14 Thread Hans Wennborg via cfe-commits
On Wed, Apr 13, 2016 at 2:49 AM, Nemanja Ivanovic via cfe-commits
 wrote:
> Author: nemanjai
> Date: Wed Apr 13 04:49:45 2016
> New Revision: 266186
>
> URL: http://llvm.org/viewvc/llvm-project?rev=266186=rev
> Log:
> Enable support for __float128 in Clang
>
> This patch corresponds to review:
> http://reviews.llvm.org/D15120
>
> It adds support for the __float128 keyword, literals and a target feature to
> enable it. This support is disabled by default on all targets and any target
> that has support for this type is free to add it.
>
> Based on feedback that I've received from target maintainers, this appears to
> be the right thing for most targets. I have not heard from the maintainers of
> X86 which I believe supports this type. I will subsequently investigate the
> impact of enabling this on X86.

We're seeing build errors when targeting Android, which I think may be
caused by this:

[...]
In file included from ../../v8/src/base/functional.cc:11:
In file included from ../../v8/src/base/functional.h:13:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/functional:55:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/tuple:38:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/utility:70:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/stl_pair.h:59:
In file included from
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/bits/move.h:57:
/usr/lib/gcc/x86_64-linux-gnu/4.8/../../../../include/c++/4.8/type_traits:269:39:
error: __float128 is not supported on this target
struct __is_floating_point_helper<__float128>
  ^

(From 
https://build.chromium.org/p/tryserver.chromium.android/builders/linux_android_rel_ng/builds/54128/steps/compile%20%28with%20patch%29/logs/stdio)

Any idea what might be breaking here?

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


r266395 - clang-cl: Make /link accept an optional joined argument.

2016-04-14 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Thu Apr 14 19:24:15 2016
New Revision: 266395

URL: http://llvm.org/viewvc/llvm-project?rev=266395=rev
Log:
clang-cl: Make /link accept an optional joined argument.

For example, "cl.exe a.c /linkfoo bar" is a valid invocation and
forwards "foo" and "bar" to link.exe. This makes clang-cl handle
that kind of invocation.

Depends on LLVM r266394.

Modified:
cfe/trunk/include/clang/Driver/CLCompatOptions.td
cfe/trunk/test/Driver/cl-link.c

Modified: cfe/trunk/include/clang/Driver/CLCompatOptions.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/CLCompatOptions.td?rev=266395=266394=266395=diff
==
--- cfe/trunk/include/clang/Driver/CLCompatOptions.td (original)
+++ cfe/trunk/include/clang/Driver/CLCompatOptions.td Thu Apr 14 19:24:15 2016
@@ -45,8 +45,8 @@ class CLCompileJoinedOrSeparate, Group,
   Flags<[CLOption, DriverOption]>;
 
-class CLRemainingArgs : Option<["/", "-"], name,
-  KIND_REMAINING_ARGS>, Group, Flags<[CLOption, DriverOption]>;
+class CLRemainingArgsJoined : Option<["/", "-"], name,
+  KIND_REMAINING_ARGS_JOINED>, Group, Flags<[CLOption, 
DriverOption]>;
 
 // Aliases:
 // (We don't put any of these in cl_compile_Group as the options they alias are
@@ -215,7 +215,7 @@ def _SLASH_imsvc : CLJoinedOrSeparate<"i
   MetaVarName<"">;
 def _SLASH_LD : CLFlag<"LD">, HelpText<"Create DLL">;
 def _SLASH_LDd : CLFlag<"LDd">, HelpText<"Create debug DLL">;
-def _SLASH_link : CLRemainingArgs<"link">,
+def _SLASH_link : CLRemainingArgsJoined<"link">,
   HelpText<"Forward options to the linker">, MetaVarName<"">;
 def _SLASH_MD : Option<["/", "-"], "MD", KIND_FLAG>, Group<_SLASH_M_Group>,
   Flags<[CLOption, DriverOption]>, HelpText<"Use DLL run-time">;

Modified: cfe/trunk/test/Driver/cl-link.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-link.c?rev=266395=266394=266395=diff
==
--- cfe/trunk/test/Driver/cl-link.c (original)
+++ cfe/trunk/test/Driver/cl-link.c Thu Apr 14 19:24:15 2016
@@ -3,6 +3,7 @@
 // under /Users.
 
 // RUN: %clang_cl /Tc%s -### /link foo bar baz 2>&1 | FileCheck 
--check-prefix=LINK %s
+// RUN: %clang_cl /Tc%s -### /linkfoo bar baz 2>&1 | FileCheck 
--check-prefix=LINK %s
 // LINK: link.exe
 // LINK: "foo"
 // LINK: "bar"


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


Re: [PATCH] D18271: Avoid -Wshadow warnings about constructor parameters named after fields

2016-04-14 Thread Richard Smith via cfe-commits
rsmith added inline comments.


Comment at: lib/Sema/SemaDecl.cpp:6417-6425
@@ +6416,11 @@
+if (isa(NewDC) && isa(D)) {
+  if (Diags.isIgnored(diag::warn_ctor_parm_shadows_field, R.getNameLoc())) 
{
+D = D->getCanonicalDecl();
+ShadowingDecls.insert({D, FD});
+  } else {
+Diag(R.getNameLoc(), diag::warn_ctor_parm_shadows_field)
+<< D << FD << FD->getParent();
+Diag(FD->getLocation(), diag::note_previous_declaration);
+  }
+  return;
+}

I would prefer for us to produce the -Wshadow "modifying shadowed" warning 
where it applies, even when -Wshadow-all is enabled. The usual model is to act 
as if -W* flags are just a filter over the diagnostic output, and this diverges 
from that.

Is the goal to ensure that -Wshadow-field-in-constructor diagnoses all 
constructor parameter / field shadowing, even if -Wshadow is not enabled?


http://reviews.llvm.org/D18271



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


Re: [PATCH] D19131: Lit C++11 Compatibility Patch #8

2016-04-14 Thread Charles Li via cfe-commits
tigerleapgorge closed this revision.
tigerleapgorge added a comment.

Committed to Trunk in r266387


http://reviews.llvm.org/D19131



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


r266387 - Lit C++11 Compatibility Patch #8

2016-04-14 Thread Charles Li via cfe-commits
Author: lcharles
Date: Thu Apr 14 18:47:07 2016
New Revision: 266387

URL: http://llvm.org/viewvc/llvm-project?rev=266387=rev
Log:
Lit C++11 Compatibility Patch #8

24 tests have been updated for C++11 compatibility.

Modified:
cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
cfe/trunk/test/CXX/class/class.friend/p1.cpp
cfe/trunk/test/CXX/class/class.friend/p2.cpp
cfe/trunk/test/CXX/stmt.stmt/stmt.dcl/p3.cpp
cfe/trunk/test/CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
cfe/trunk/test/CXX/temp/temp.arg/temp.arg.type/p2.cpp
cfe/trunk/test/CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
cfe/trunk/test/CXX/temp/temp.spec/no-body.cpp
cfe/trunk/test/CodeGenCXX/const-init.cpp
cfe/trunk/test/Parser/cxx-class.cpp
cfe/trunk/test/Parser/cxx-decl.cpp
cfe/trunk/test/Parser/cxx-friend.cpp
cfe/trunk/test/SemaCXX/anonymous-struct.cpp
cfe/trunk/test/SemaCXX/class.cpp
cfe/trunk/test/SemaCXX/conversion-function.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_in_class.cpp
cfe/trunk/test/SemaCXX/cxx1y-variable-templates_top_level.cpp
cfe/trunk/test/SemaCXX/exceptions.cpp
cfe/trunk/test/SemaCXX/qual-id-test.cpp
cfe/trunk/test/SemaCXX/unused.cpp
cfe/trunk/test/SemaCXX/warn-unused-value.cpp
cfe/trunk/test/SemaTemplate/member-access-expr.cpp
cfe/trunk/test/SemaTemplate/recovery-crash.cpp
cfe/trunk/test/SemaTemplate/temp_arg_type.cpp

Modified: cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp?rev=266387=266386=266387=diff
==
--- cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp 
(original)
+++ cfe/trunk/test/CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp Thu Apr 
14 18:47:07 2016
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify %s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++98 
%s
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-show-option -verify -std=c++11 
%s
 
 // C++98 [basic.lookup.classref]p1:
 //   In a class member access expression (5.2.5), if the . or -> token is
@@ -21,10 +23,16 @@
 
 // From PR 7247
 template
-struct set{};  // expected-note{{lookup from the current scope refers here}}
+struct set{};
+#if __cplusplus <= 199711L
+// expected-note@-2 {{lookup from the current scope refers here}}
+#endif
 struct Value {
   template
-  void set(T value) {}  // expected-note{{lookup in the object type 'Value' 
refers here}}
+  void set(T value) {}
+#if __cplusplus <= 199711L
+  // expected-note@-2 {{lookup in the object type 'Value' refers here}}
+#endif
 
   void resolves_to_same() {
 Value v;
@@ -36,7 +44,10 @@ void resolves_to_different() {
 Value v;
 // The fact that the next line is a warning rather than an error is an
 // extension.
-v.set(3.2);  // expected-warning{{lookup of 'set' in member access 
expression is ambiguous; using member of 'Value'}}
+v.set(3.2);
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{lookup of 'set' in member access expression is 
ambiguous; using member of 'Value'}}
+#endif
   }
   {
 int set;  // Non-template.

Modified: cfe/trunk/test/CXX/class/class.friend/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.friend/p1.cpp?rev=266387=266386=266387=diff
==
--- cfe/trunk/test/CXX/class/class.friend/p1.cpp (original)
+++ cfe/trunk/test/CXX/class/class.friend/p1.cpp Thu Apr 14 18:47:07 2016
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 struct Outer {
   struct Inner {
@@ -41,7 +43,10 @@ class A {
   UndeclaredSoFar x; // expected-error {{unknown type name 'UndeclaredSoFar'}}
 
   void a_member();
-  friend void A::a_member(); // expected-error {{friends cannot be members of 
the declaring class}}
+  friend void A::a_member();
+#if __cplusplus <= 199711L
+  // expected-error@-2 {{friends cannot be members of the declaring class}}
+#endif
   friend void a_member(); // okay (because we ignore class scopes when looking 
up friends)
   friend class A::AInner; // this is okay as an extension
   friend class AInner; // okay, refers to ::AInner

Modified: cfe/trunk/test/CXX/class/class.friend/p2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class/class.friend/p2.cpp?rev=266387=266386=266387=diff
==
--- cfe/trunk/test/CXX/class/class.friend/p2.cpp (original)
+++ cfe/trunk/test/CXX/class/class.friend/p2.cpp Thu Apr 14 18:47:07 2016
@@ -1,10 +1,18 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s

Re: [PATCH] D19006: [libcxx] Remove the "reduced-arity-initialization" extension from the uses-allocator constructors

2016-04-14 Thread Eric Fiselier via cfe-commits
EricWF updated the summary for this revision.
EricWF updated this revision to Diff 53811.

http://reviews.llvm.org/D19006

Files:
  include/tuple
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc.pass.cpp
  test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp

Index: test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
===
--- test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
+++ test/std/utilities/tuple/tuple.tuple/tuple.cnstr/alloc_UTypes.pass.cpp
@@ -24,16 +24,29 @@
 #include "../alloc_first.h"
 #include "../alloc_last.h"
 
-struct NoDefault { NoDefault() = delete; };
+template 
+struct DefaultCtorBlowsUp {
+  constexpr DefaultCtorBlowsUp() {
+  static_assert(!std::is_same::value, "Default Ctor instantiated");
+  }
 
-// Make sure the _Up... constructor SFINAEs out when the types that
-// are not explicitly initialized are not all default constructible.
-// Otherwise, std::is_constructible would return true but instantiating
-// the constructor would fail.
-void test_default_constructible_extension_sfinae()
+  explicit constexpr DefaultCtorBlowsUp(int x) : value(x) {}
+
+  int value;
+};
+
+
+struct DerivedFromAllocArgT : std::allocator_arg_t {};
+
+
+// Make sure the _Up... constructor SFINAEs out when the number of initializers
+// is less that the number of elements in the tuple. Previously libc++ would
+// offer these constructers as an extension but they broke conforming code.
+void test_default_constructible_sfinae()
 {
+ using BadDefault = DefaultCtorBlowsUp<>;
 {
-typedef std::tuple Tuple;
+typedef std::tuple Tuple;
 
 static_assert(!std::is_constructible<
 Tuple,
@@ -42,11 +55,11 @@
 
 static_assert(std::is_constructible<
 Tuple,
-std::allocator_arg_t, A1, MoveOnly, NoDefault
+std::allocator_arg_t, A1, MoveOnly, MoveOnly, BadDefault
 >::value, "");
 }
 {
-typedef std::tuple Tuple;
+typedef std::tuple Tuple;
 
 static_assert(!std::is_constructible<
 Tuple,
@@ -55,36 +68,7 @@
 
 static_assert(std::is_constructible<
 Tuple,
-std::allocator_arg_t, A1, MoveOnly, MoveOnly, NoDefault
->::value, "");
-}
-{
-// Same idea as above but with a nested tuple
-typedef std::tuple Tuple;
-typedef std::tuple NestedTuple;
-
-static_assert(!std::is_constructible<
-NestedTuple,
-std::allocator_arg_t, A1, MoveOnly, MoveOnly, MoveOnly, MoveOnly
->::value, "");
-
-static_assert(std::is_constructible<
-NestedTuple,
-std::allocator_arg_t, A1, MoveOnly, Tuple, MoveOnly, MoveOnly
->::value, "");
-}
-{
-typedef std::tuple Tuple;
-typedef std::tuple NestedTuple;
-
-static_assert(std::is_constructible<
-NestedTuple,
-std::allocator_arg_t, A1, MoveOnly, MoveOnly, MoveOnly, MoveOnly
->::value, "");
-
-static_assert(std::is_constructible<
-NestedTuple,
-std::allocator_arg_t, A1, MoveOnly, Tuple, MoveOnly, MoveOnly
+std::allocator_arg_t, A1, MoveOnly, MoveOnly, BadDefault, BadDefault
 >::value, "");
 }
 }
@@ -96,12 +80,23 @@
 assert(std::get<0>(t) == 0);
 }
 {
+using T = DefaultCtorBlowsUp<>;
+std::tuple t(std::allocator_arg, A1(), T(42));
+assert(std::get<0>(t).value == 42);
+}
+{
 std::tuple t(std::allocator_arg, A1(),
  MoveOnly(0), MoveOnly(1));
 assert(std::get<0>(t) == 0);
 assert(std::get<1>(t) == 1);
 }
 {
+using T = DefaultCtorBlowsUp<>;
+std::tuple t(std::allocator_arg, A1(), T(42), T(43));
+assert(std::get<0>(t).value == 42);
+assert(std::get<1>(t).value == 43);
+}
+{
 std::tuple t(std::allocator_arg, A1(),
MoveOnly(0),
1, 2);
@@ -110,6 +105,13 @@
 assert(std::get<2>(t) == 2);
 }
 {
+using T = DefaultCtorBlowsUp<>;
+std::tuple t(std::allocator_arg, A1(), T(1), T(2), T(3));
+assert(std::get<0>(t).value == 1);
+assert(std::get<1>(t).value == 2);
+assert(std::get<2>(t).value == 3);
+}
+{
 alloc_first::allocator_constructed = false;
 alloc_last::allocator_constructed = false;
 std::tuple 

Re: [PATCH] D19118: [clang-tidy] Add checker for operations between integrals and pointers

2016-04-14 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added a subscriber: Eugene.Zelenko.


Comment at: docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst:9
@@ +8,3 @@
+object is compare to an object with integral type.
+
+

Looks like excessive line.


Comment at: docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst:22
@@ +21,3 @@
+
+  void Prcess(std::string path, bool* error) {
+[...]

Process?


http://reviews.llvm.org/D19118



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


r266383 - AMDGPU: Add test for generic builtin behavior

2016-04-14 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Thu Apr 14 17:34:39 2016
New Revision: 266383

URL: http://llvm.org/viewvc/llvm-project?rev=266383=rev
Log:
AMDGPU: Add test for generic builtin behavior

Added:
cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl

Added: cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl?rev=266383=auto
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-generic-amdgcn.cl Thu Apr 14 17:34:39 
2016
@@ -0,0 +1,16 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK-LABEL: @test_builtin_clz(
+// CHECK: tail call i32 @llvm.ctlz.i32(i32 %a, i1 true)
+void test_builtin_clz(global int* out, int a)
+{
+  *out = __builtin_clz(a);
+}
+
+// CHECK-LABEL: @test_builtin_clzl(
+// CHECK: tail call i64 @llvm.ctlz.i64(i64 %a, i1 true)
+void test_builtin_clzl(global long* out, long a)
+{
+  *out = __builtin_clzl(a);
+}


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


Re: [PATCH] D18473: AMDGPU: Add test for generic builtin behavior

2016-04-14 Thread Matt Arsenault via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r266383


http://reviews.llvm.org/D18473



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


Re: [PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-14 Thread Joerg Sonnenberger via cfe-commits
On Thu, Apr 14, 2016 at 03:02:31PM +, Taewook Oh via cfe-commits wrote:
> Thank you for your comments. I submitted a new patch
> (http://reviews.llvm.org/D19062) with a new test that checks attributes
> but not types. I think this should cover both cases. What do you think?

I think just picking two backends like ARM and X86 is less likely to
create volatile IR and covers both aspects at the same time. It feels
more robust that way.

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


Re: [PATCH] D18766: [clang-tidy] Add check misc-multiple-statement-macro

2016-04-14 Thread Samuel Benzaquen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266369: [clang-tidy] Add check misc-multiple-statement-macro 
(authored by sbenza).

Changed prior to commit:
  http://reviews.llvm.org/D18766?vs=53398=53786#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18766

Files:
  clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
  clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp
  clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.h
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-multiple-statement-macro.rst
  clang-tools-extra/trunk/test/clang-tidy/misc-multiple-statement-macro.cpp

Index: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
@@ -25,6 +25,7 @@
 #include "MisplacedWideningCastCheck.h"
 #include "MoveConstantArgumentCheck.h"
 #include "MoveConstructorInitCheck.h"
+#include "MultipleStatementMacroCheck.h"
 #include "NewDeleteOverloadsCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
 #include "NonCopyableObjects.h"
@@ -79,6 +80,8 @@
 "misc-move-const-arg");
 CheckFactories.registerCheck(
 "misc-move-constructor-init");
+CheckFactories.registerCheck(
+"misc-multiple-statement-macro");
 CheckFactories.registerCheck(
 "misc-new-delete-overloads");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.h
+++ clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.h
@@ -0,0 +1,37 @@
+//===--- MultipleStatementMacroCheck.h - clang-tidy--*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLE_STATEMENT_MACRO_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLE_STATEMENT_MACRO_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+/// Detect multiple statement macros that are used in unbraced conditionals.
+/// Only the first statement of the macro will be inside the conditional and the
+/// other ones will be executed unconditionally.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/misc-multiple-statement-macro.html
+class MultipleStatementMacroCheck : public ClangTidyCheck {
+public:
+  MultipleStatementMacroCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult ) override;
+};
+
+} // namespace misc
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_MISC_MULTIPLE_STATEMENT_MACRO_H
Index: clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp
@@ -0,0 +1,106 @@
+//===--- MultipleStatementMacroCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MultipleStatementMacroCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+AST_MATCHER(Expr, isInMacro) { return Node.getLocStart().isMacroID(); }
+
+/// \brief Find the next statement after `S`.
+const Stmt *nextStmt(const MatchFinder::MatchResult , const Stmt *S) {
+  auto Parents = Result.Context->getParents(*S);
+  if (Parents.empty())
+return nullptr;
+  const Stmt *Parent = Parents[0].get();
+  if (!Parent)
+return nullptr;
+  const Stmt* Prev = nullptr;
+  for (const Stmt *Child : Parent->children()) {
+if (Prev == S)
+  return Child;
+Prev = Child;
+  }
+  return nextStmt(Result, Parent);
+}
+
+using ExpansionRanges = std::vector>;
+
+/// \bried Get all the macro expansion ranges related to `Loc`.

[clang-tools-extra] r266369 - [clang-tidy] Add check misc-multiple-statement-macro

2016-04-14 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Thu Apr 14 16:15:57 2016
New Revision: 266369

URL: http://llvm.org/viewvc/llvm-project?rev=266369=rev
Log:
[clang-tidy] Add check misc-multiple-statement-macro

Summary:
The check detects multi-statement macros that are used in unbraced conditionals.
Only the first statement will be part of the conditionals and the rest will fall
outside of it and executed unconditionally.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D18766

Added:
clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp
clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-multiple-statement-macro.rst
clang-tools-extra/trunk/test/clang-tidy/misc-multiple-statement-macro.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt?rev=266369=266368=266369=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/CMakeLists.txt Thu Apr 14 16:15:57 
2016
@@ -17,6 +17,7 @@ add_clang_library(clangTidyMiscModule
   MisplacedWideningCastCheck.cpp
   MoveConstantArgumentCheck.cpp
   MoveConstructorInitCheck.cpp
+  MultipleStatementMacroCheck.cpp
   NewDeleteOverloadsCheck.cpp
   NoexceptMoveConstructorCheck.cpp
   NonCopyableObjects.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp?rev=266369=266368=266369=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MiscTidyModule.cpp Thu Apr 14 
16:15:57 2016
@@ -25,6 +25,7 @@
 #include "MisplacedWideningCastCheck.h"
 #include "MoveConstantArgumentCheck.h"
 #include "MoveConstructorInitCheck.h"
+#include "MultipleStatementMacroCheck.h"
 #include "NewDeleteOverloadsCheck.h"
 #include "NoexceptMoveConstructorCheck.h"
 #include "NonCopyableObjects.h"
@@ -79,6 +80,8 @@ public:
 "misc-move-const-arg");
 CheckFactories.registerCheck(
 "misc-move-constructor-init");
+CheckFactories.registerCheck(
+"misc-multiple-statement-macro");
 CheckFactories.registerCheck(
 "misc-new-delete-overloads");
 CheckFactories.registerCheck(

Added: clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp?rev=266369=auto
==
--- clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/misc/MultipleStatementMacroCheck.cpp Thu 
Apr 14 16:15:57 2016
@@ -0,0 +1,106 @@
+//===--- MultipleStatementMacroCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "MultipleStatementMacroCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace misc {
+
+namespace {
+
+AST_MATCHER(Expr, isInMacro) { return Node.getLocStart().isMacroID(); }
+
+/// \brief Find the next statement after `S`.
+const Stmt *nextStmt(const MatchFinder::MatchResult , const Stmt *S) {
+  auto Parents = Result.Context->getParents(*S);
+  if (Parents.empty())
+return nullptr;
+  const Stmt *Parent = Parents[0].get();
+  if (!Parent)
+return nullptr;
+  const Stmt* Prev = nullptr;
+  for (const Stmt *Child : Parent->children()) {
+if (Prev == S)
+  return Child;
+Prev = Child;
+  }
+  return nextStmt(Result, Parent);
+}
+
+using ExpansionRanges = std::vector>;
+
+/// \bried Get all the macro expansion ranges related to `Loc`.
+///
+/// The result is ordered from most inner to most outer.
+ExpansionRanges getExpansionRanges(SourceLocation Loc,
+   const MatchFinder::MatchResult ) {
+  ExpansionRanges Locs;
+  while (Loc.isMacroID()) {
+Locs.push_back(Result.SourceManager->getImmediateExpansionRange(Loc));
+Loc = Locs.back().first;
+  }
+  return Locs;
+}
+
+}  // namespace
+
+void 

[PATCH] D19131: Lit C++11 Compatibility Patch #8

2016-04-14 Thread Charles Li via cfe-commits
tigerleapgorge created this revision.
tigerleapgorge added a reviewer: rsmith.
tigerleapgorge added a subscriber: cfe-commits.

24 tests have been updated for C++11 compatibility.


CXX/basic/basic.lookup/basic.lookup.classref/p1.cpp
  Ambiguous class member lookup has been fixed in C++11
  http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#
  Restrict the following diagnostics to C++98.
C++98: warning: lookup of 'set' in member access expression is ambiguous; 
using member of 'Value'
   note: lookup in the object type 'Value' refers here
   note: lookup from the current scope refers here

CXX/class/class.friend/p1.cpp
  Restrict the following diagnostics to C++98.
C++98 error: friends cannot be members of the declaring class

CXX/class/class.friend/p2.cpp
  Restrict the following 2 diagnostics to C++98.
C++98: warning: non-class friend type 'int' is a C++11 extension
C++98: warning: unelaborated friend declaration is a C++11 extension; 
specify 'struct' to befriend 'B0'

CXX/stmt.stmt/stmt.dcl/p3.cpp
  Definition of POD has been relaxed in C++11 such that a struct with 
  a trivial copy assignment operator is still considered POD.

  http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2294.html
  In the above paper, the following clause has been crossed out.
“and has no user-declared copy assignment operator and no user-declared 
destructor” 

  For this test, struct Z is still a POD struct in C++11.
  Therefore goto can jump over Z’s instantiation without causing a compiler 
Error.
  Restrict the following to C++98
C++98: error: cannot jump from this goto statement to its label
C++98: note: jump bypasses initialization of non-POD variable

CXX/temp/temp.arg/temp.arg.nontype/p1.cpp
  C++11 accepts arbitrary literal types for non-type template parameters
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3413.html

  Change in diagnostics.
C++98: error: non-type template argument for template parameter of pointer 
type 'int *' must have its address taken
C++11: error: non-type template argument of type 'int' is not a constant 
expression
   note: read of non-const variable 'i' is not allowed in a constant 
expression
   note: declared here

  Restrict the following to C++98
C++98: warning: non-type template argument referring to object 'ki' with 
internal linkage is a C++11 extension
   Note: non-type template argument refers to object here

  Change in diagnostics.
C++98: error: non-type template argument refers to thread-local object
   note: non-type template argument refers here
C++11: error: non-type template argument of type 'int *' is not a constant 
expression
   note: template parameter is declared here

  Restrict the following to C++98
C++98: non-type template argument referring to function 'f_internal' with 
internal linkage is a C++11 extension
   note: non-type template argument refers to function here

  Change in diagnostics
C++98: error: non-type template argument refers to object 'n' that does not 
have linkage
   note: non-type template argument refers to object here
C++11: error: non-type template argument of type 'int *' is not a constant 
expression
   note: pointer to 'n' is not a constant expression
   note: declared here
   note: template parameter is declared here

  Change in diagnostics 
C++98: error: non-type template argument for template parameter of pointer 
type 'int *' must have its address taken
C++11: error: non-type template argument of type 'int *' is not a constant 
expression
   note: read of non-constexpr variable 'iptr' is not allowed in a 
constant expression
   note: declared here

CXX/temp/temp.arg/temp.arg.type/p2.cpp
  Unnamed types can now be used as template arguments in C++11
  http://stackoverflow.com/questions/5131691/what-is-an-unnamed-type-in-c
  Restrict the following diagnostics to C++98.
C++98: Warning: template argument uses unnamed type

CXX/temp/temp.fct.spec/temp.deduct/p9.cpp
  Template argument constant expression narrowing is not allowed.
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#1809
  Restrict the following diagnostics to C++98.
C++98:  error: call to 'f' is ambiguous
note: candidate function
note: candidate function

CXX/temp/temp.spec/no-body.cpp
  Explicit instantiation of a template inside a nested namespace is an Error in 
C++11.
  This could be the result of the following defect fix.
http://www.open-std.org/jtc1/sc22/wg21/docs/cwg_defects.html#995

  Added 3 instances of the following diagnostics.
C++11: error: explicit instantiation of 'x' must occur at global scope
   note: explicit instantiation refers here

  Also remove these 3 explicit instantiations from the -fixit runs.

CodeGenCXX/const-init.cpp
  Use constexpr instead of const in C++11 so the 

r266366 - In vector comparisons, handle scalar LHS just as we handle scalar RHS

2016-04-14 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Thu Apr 14 16:03:38 2016
New Revision: 266366

URL: http://llvm.org/viewvc/llvm-project?rev=266366=rev
Log:
In vector comparisons, handle scalar LHS just as we handle scalar RHS

Summary: Fixes PR27258

Reviewers: rsmith

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19123

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGen/vector.c
cfe/trunk/test/Sema/vector-cast.c

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=266366=266365=266366=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Apr 14 16:03:38 2016
@@ -7929,14 +7929,16 @@ QualType Sema::CheckVectorOperands(ExprR
   return RHSType;
   }
 
-  // If we're allowing lax vector conversions, only the total (data) size
-  // needs to be the same.
-  // FIXME: Should we really be allowing this?
-  // FIXME: We really just pick the LHS type arbitrarily?
-  if (isLaxVectorConversion(RHSType, LHSType)) {
-QualType resultType = LHSType;
-RHS = ImpCastExprToType(RHS.get(), resultType, CK_BitCast);
-return resultType;
+  // If we're allowing lax vector conversions, only the total (data) size needs
+  // to be the same. If one of the types is scalar, the result is always the
+  // vector type. Don't allow this if the scalar operand is an lvalue.
+  QualType VecType = LHSVecType ? LHSType : RHSType;
+  QualType ScalarType = LHSVecType ? RHSType : LHSType;
+  ExprResult *ScalarExpr = LHSVecType ?  : 
+  if (isLaxVectorConversion(ScalarType, VecType) &&
+  !ScalarExpr->get()->isLValue()) {
+*ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast);
+return VecType;
   }
 
   // Okay, the expression is invalid.
@@ -9480,7 +9482,7 @@ QualType Sema::CheckVectorCompareOperand
   }
   
   // Return a signed type for the vector.
-  return GetSignedVectorType(LHSType);
+  return GetSignedVectorType(vType);
 }
 
 QualType Sema::CheckVectorLogicalOperands(ExprResult , ExprResult ,

Modified: cfe/trunk/test/CodeGen/vector.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/vector.c?rev=266366=266365=266366=diff
==
--- cfe/trunk/test/CodeGen/vector.c (original)
+++ cfe/trunk/test/CodeGen/vector.c Thu Apr 14 16:03:38 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu pentium4 
-target-feature +sse4.1 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu core2 
-debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
 typedef short __v4hi __attribute__ ((__vector_size__ (8)));
 
 void test1() {
@@ -62,3 +62,23 @@ void extractinttypes() {
   extern __typeof(_mm_extract_epi16(_mm_setzero_si128(), 3)) check_result_int;
   extern __typeof(_mm_extract_epi32(_mm_setzero_si128(), 3)) check_result_int;
 }
+
+// Test some logic around our lax vector comparison rules with integers.
+
+typedef int vec_int1 __attribute__((vector_size(4)));
+vec_int1 lax_vector_compare1(int x, vec_int1 y) {
+  y = x == y;
+  return y;
+}
+
+// CHECK: define i32 @lax_vector_compare1(i32 {{.*}}, i32 {{.*}})
+// CHECK: icmp eq <1 x i32>
+
+typedef int vec_int2 __attribute__((vector_size(8)));
+vec_int2 lax_vector_compare2(long long x, vec_int2 y) {
+  y = x == y;
+  return y;
+}
+
+// CHECK: define void @lax_vector_compare2(<2 x i32>* {{.*sret.*}}, i64 
{{.*}}, i64 {{.*}})
+// CHECK: icmp eq <2 x i32>

Modified: cfe/trunk/test/Sema/vector-cast.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/vector-cast.c?rev=266366=266365=266366=diff
==
--- cfe/trunk/test/Sema/vector-cast.c (original)
+++ cfe/trunk/test/Sema/vector-cast.c Thu Apr 14 16:03:38 2016
@@ -50,7 +50,12 @@ void f4() {
   float2 f2;
   double d;
   f2 += d;
-  d += f2;
+  // We used to allow the next statement, but we've always rejected the next 
two
+  // statements
+  // FIXME: This diagnostic is inaccurate.
+  d += f2; // expected-error {{cannot convert between vector values of 
different size}}
+  d = f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
+  d = d + f2; // expected-error {{assigning to 'double' from incompatible type 
'float2'}}
 }
 
 // rdar://15931426


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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL 1.2/2.0 header files.

2016-04-14 Thread Yaxun Liu via cfe-commits
yaxunl marked 4 inline comments as done.


Comment at: lib/Headers/opencl.h:15636-15637
@@ +15635,4 @@
+#if defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 200
+#define PIPE_RESERVE_ID_VALID_BIT (1U << 30)
+#define CLK_NULL_RESERVE_ID 
(__builtin_astype(((void*)(~PIPE_RESERVE_ID_VALID_BIT)), reserve_id_t))
+bool __attribute__((overloadable)) is_valid_reserve_id(reserve_id_t 
reserve_id);

yaxunl wrote:
> pxli168 wrote:
> > Is this macro needed in this header?
> > And what happens to spir32 and spir64 difference?
> The spec requires to define this macro.
> 
> I agree this definition seems arbitrary since the spec does not define 
> PIPE_RESERVE_ID_VALID_BIT.
> 
> How about
> 
>   // Define an internally used macro for the maximum value of size_t.
>   #if defined(__SPIR32__)
>   #define _SIZET_MAX UINT_MAX
>   #elif defined(__SPIR64__ )
>   #define _SIZET_MAX ULONG_MAX
>   #endif
> 
> and use it for defining CLK_NULL_RESERVE_ID.
Actually there is a predefined macro `__SIZE_MAX__` by Clang which is just for 
this purpose.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL 1.2/2.0 header files.

2016-04-14 Thread Yaxun Liu via cfe-commits
yaxunl marked 8 inline comments as done.


Comment at: lib/Headers/opencl.h:11-13
@@ +10,5 @@
+
+#if !defined(__SPIR32__) && !defined(__SPIR64__)
+#error "This header file should be used with SPIR target only."
+#endif
+

tstellarAMD wrote:
> This should be removed so they can be used with any target.
Agree.


Comment at: lib/Headers/opencl.h:53-57
@@ +52,7 @@
+ */
+#if defined(__SPIR32__)
+typedef uint size_t;
+#elif defined(__SPIR64__)
+typedef ulong size_t;
+#endif
+

tstellarAMD wrote:
> This needs to be removed too.
clang does not define size_t for OpenCL but defines `__SIZE_TYPE__`, so I can 
use

  #define size_t __SIZE_TYPE__

since `__SIZE_TYPE__` is defined based on pointer width of the architecture, we 
will get a size_t definition consistent with target pointer width.


Comment at: lib/Headers/opencl.h:65-69
@@ +64,7 @@
+ */
+#if defined(__SPIR32__)
+typedef int ptrdiff_t;
+#elif defined(__SPIR64__ )
+typedef long ptrdiff_t;
+#endif
+

tstellarAMD wrote:
> And this.
Clang does not define ptrdiff_t for OpenCL but I can define it as 
`__PTRDIFF_TYPE__` which is defined by Clang.


Comment at: lib/Headers/opencl.h:70-84
@@ +69,17 @@
+#endif
+
+/**
+* A signed integer type with the property that any valid pointer to
+* void can be converted to this type, then converted back to pointer
+* to void, and the result will compare equal to the original pointer.
+*/
+typedef ptrdiff_t intptr_t;
+
+/**
+* An unsigned integer type with the property that any valid pointer to
+* void can be converted to this type, then converted back to pointer
+* to void, and the result will compare equal to the original pointer.
+*/
+typedef size_t uintptr_t;
+
+// built-in vector data types:

tstellarAMD wrote:
> Do we actually need these typdefs?  I thought clang automatically set these 
> for OpenCL.
Clang does not define intptr_t nor uintptr_t, but it defines `__INTPTR_TYPE__` 
and `__UINTPTR_TYPE__`. I can use them.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL 1.2/2.0 header files.

2016-04-14 Thread Tom Stellard via cfe-commits
tstellarAMD added inline comments.


Comment at: lib/Headers/opencl.h:11-13
@@ +10,5 @@
+
+#if !defined(__SPIR32__) && !defined(__SPIR64__)
+#error "This header file should be used with SPIR target only."
+#endif
+

This should be removed so they can be used with any target.


Comment at: lib/Headers/opencl.h:53-57
@@ +52,7 @@
+ */
+#if defined(__SPIR32__)
+typedef uint size_t;
+#elif defined(__SPIR64__)
+typedef ulong size_t;
+#endif
+

This needs to be removed too.


Comment at: lib/Headers/opencl.h:65-69
@@ +64,7 @@
+ */
+#if defined(__SPIR32__)
+typedef int ptrdiff_t;
+#elif defined(__SPIR64__ )
+typedef long ptrdiff_t;
+#endif
+

And this.


Comment at: lib/Headers/opencl.h:70-84
@@ +69,17 @@
+#endif
+
+/**
+* A signed integer type with the property that any valid pointer to
+* void can be converted to this type, then converted back to pointer
+* to void, and the result will compare equal to the original pointer.
+*/
+typedef ptrdiff_t intptr_t;
+
+/**
+* An unsigned integer type with the property that any valid pointer to
+* void can be converted to this type, then converted back to pointer
+* to void, and the result will compare equal to the original pointer.
+*/
+typedef size_t uintptr_t;
+
+// built-in vector data types:

Do we actually need these typdefs?  I thought clang automatically set these for 
OpenCL.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D18698: [C11] PR24451: Allow restrict _Atomic pointers

2016-04-14 Thread Richard Smith via cfe-commits
rsmith added a comment.

I mailed WG14 asking for clarification on how these rules are supposed to work 
(10 days ago) and am yet to hear anything in response. Is this apparent GCC 
extension/bug seeing much use in the wild? If not, I think our path forward is 
to file this as a bug against GCC and see if they want to fix it or accept it 
as an extension.


http://reviews.llvm.org/D18698



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


Re: [PATCH] D18956: [Sema] Fix assertion failure at vector comparison

2016-04-14 Thread Richard Smith via cfe-commits
rsmith requested changes to this revision.
rsmith added a comment.
This revision now requires changes to proceed.

I agree. In the example, the type of `y == z` should be `vec`, not `int` -- we 
should "promote" to the vector type.


Repository:
  rL LLVM

http://reviews.llvm.org/D18956



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


r266359 - Make this code less brittle. The benefits of a fixed-size array aren't worth the maintenance cost.

2016-04-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 14 14:45:19 2016
New Revision: 266359

URL: http://llvm.org/viewvc/llvm-project?rev=266359=rev
Log:
Make this code less brittle. The benefits of a fixed-size array aren't worth 
the maintenance cost.

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=266359=266358=266359=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Apr 14 14:45:19 2016
@@ -704,13 +704,10 @@ class ASTRecordWriter {
   /// declaration or type.
   SmallVector StmtsToEmit;
 
-  /// Worst case: bases, vbases, visible and lexical contents, local redecls.
-  static const int MaxOffsetIndices = 5;
   /// \brief Indices of record elements that describe offsets within the
   /// bitcode. These will be converted to offsets relative to the current
   /// record when emitted.
-  unsigned OffsetIndices[MaxOffsetIndices];
-  unsigned NumOffsetIndices = 0;
+  SmallVector OffsetIndices;
 
   /// \brief Flush all of the statements and expressions that have
   /// been added to the queue via AddStmt().
@@ -719,13 +716,13 @@ class ASTRecordWriter {
 
   void PrepareToEmit(uint64_t MyOffset) {
 // Convert offsets into relative form.
-for (unsigned I = 0; I != NumOffsetIndices; ++I) {
-  auto  = (*Record)[OffsetIndices[I]];
+for (unsigned I : OffsetIndices) {
+  auto  = (*Record)[I];
   assert(StoredOffset < MyOffset && "invalid offset");
   if (StoredOffset)
 StoredOffset = MyOffset - StoredOffset;
 }
-NumOffsetIndices = 0;
+OffsetIndices.clear();
   }
 
 public:
@@ -779,8 +776,7 @@ public:
   /// \brief Add a bit offset into the record. This will be converted into an
   /// offset relative to the current record when emitted.
   void AddOffset(uint64_t BitOffset) {
-assert(NumOffsetIndices != MaxOffsetIndices && "too many offset indices");
-OffsetIndices[NumOffsetIndices++] = Record->size();
+OffsetIndices.push_back(Record->size());
 Record->push_back(BitOffset);
   }
 


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


Re: [PATCH] D18369: [OpenCL] Upstreaming khronos OpenCL 1.2/2.0 header files.

2016-04-14 Thread Yaxun Liu via cfe-commits
yaxunl marked 4 inline comments as done.


Comment at: lib/Headers/opencl.h:13721-13726
@@ +13720,8 @@
+
+/**
+ * Queue a memory fence to ensure correct ordering of memory
+ * operations between work-items of a work-group to
+ * image memory.
+ */
+#define CLK_IMAGE_MEM_FENCE  0x04
+

pxli168 wrote:
> Move this to the barrier part with worg_group_barrier maybe better.
Will do.


Comment at: lib/Headers/opencl.h:15636-15637
@@ +15635,4 @@
+#if defined(__OPENCL_C_VERSION__) && __OPENCL_C_VERSION__ >= 200
+#define PIPE_RESERVE_ID_VALID_BIT (1U << 30)
+#define CLK_NULL_RESERVE_ID 
(__builtin_astype(((void*)(~PIPE_RESERVE_ID_VALID_BIT)), reserve_id_t))
+bool __attribute__((overloadable)) is_valid_reserve_id(reserve_id_t 
reserve_id);

pxli168 wrote:
> Is this macro needed in this header?
> And what happens to spir32 and spir64 difference?
The spec requires to define this macro.

I agree this definition seems arbitrary since the spec does not define 
PIPE_RESERVE_ID_VALID_BIT.

How about

  // Define an internally used macro for the maximum value of size_t.
  #if defined(__SPIR32__)
  #define _SIZET_MAX UINT_MAX
  #elif defined(__SPIR64__ )
  #define _SIZET_MAX ULONG_MAX
  #endif

and use it for defining CLK_NULL_RESERVE_ID.


Comment at: lib/Headers/opencl.h:15661
@@ +15660,3 @@
+#define CLK_NULL_QUEUE  0
+#define CLK_NULL_EVENT (__builtin_astype(((void*)(UINT32MAX)), clk_event_t))
+

pxli168 wrote:
> What is this UINT32MAX?
> And what about spir64?
How about replacing UINT32MAX with _SIZET_MAX defined above?



Comment at: lib/Headers/opencl.h:15675
@@ +15674,3 @@
+#define MAX_WORK_DIM3
+#if defined(__clang__) && (__clang_major__ < 3 || (__clang_major__ == 3 && 
__clang_minor__ < 9))
+typedef struct {

pxli168 wrote:
> Is this part necessary for up-streaming to the llvm3.9? It will never be hint.
I will remove it.


http://reviews.llvm.org/D18369



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


Re: [PATCH] D19117: [clang-tidy] Update RedundantVoidArgCheck to check for type aliases in addition to typedefs

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Commit in r266358


http://reviews.llvm.org/D19117



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


[clang-tools-extra] r266358 - Add support for type aliases to modernize-redundant-void-arg.cpp

2016-04-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Apr 14 14:28:13 2016
New Revision: 266358

URL: http://llvm.org/viewvc/llvm-project?rev=266358=rev
Log:
Add support for type aliases to modernize-redundant-void-arg.cpp

Patch by Clement Courbet.

Modified:
clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.h
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp

Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp?rev=266358=266357=266358=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.cpp Thu 
Apr 14 14:28:13 2016
@@ -50,7 +50,7 @@ void RedundantVoidArgCheck::registerMatc
   unless(isExternC()))
  .bind(FunctionId),
  this);
-  Finder->addMatcher(typedefDecl().bind(TypedefId), this);
+  Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
@@ -80,8 +80,9 @@ void RedundantVoidArgCheck::check(const
   const BoundNodes  = Result.Nodes;
   if (const auto *Function = Nodes.getNodeAs(FunctionId)) {
 processFunctionDecl(Result, Function);
-  } else if (const auto *Typedef = Nodes.getNodeAs(TypedefId)) {
-processTypedefDecl(Result, Typedef);
+  } else if (const auto *TypedefName =
+ Nodes.getNodeAs(TypedefId)) {
+processTypedefNameDecl(Result, TypedefName);
   } else if (const auto *Member = Nodes.getNodeAs(FieldId)) {
 processFieldDecl(Result, Member);
   } else if (const auto *Var = Nodes.getNodeAs(VarId)) {
@@ -105,8 +106,8 @@ void RedundantVoidArgCheck::processFunct
   if (Function->isThisDeclarationADefinition()) {
 const Stmt *Body = Function->getBody();
 SourceLocation Start = Function->getLocStart();
-SourceLocation End = Body ? Body->getLocStart().getLocWithOffset(-1) :
-Function->getLocEnd();
+SourceLocation End =
+Body ? Body->getLocStart().getLocWithOffset(-1) : 
Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");
   } else {
@@ -179,10 +180,13 @@ void RedundantVoidArgCheck::removeVoidTo
   diag(VoidLoc, Diagnostic) << FixItHint::CreateRemoval(VoidRange);
 }
 
-void RedundantVoidArgCheck::processTypedefDecl(
-const MatchFinder::MatchResult , const TypedefDecl *Typedef) {
-  if (protoTypeHasNoParms(Typedef->getUnderlyingType())) {
-removeVoidArgumentTokens(Result, Typedef->getSourceRange(), "typedef");
+void RedundantVoidArgCheck::processTypedefNameDecl(
+const MatchFinder::MatchResult ,
+const TypedefNameDecl *TypedefName) {
+  if (protoTypeHasNoParms(TypedefName->getUnderlyingType())) {
+removeVoidArgumentTokens(Result, TypedefName->getSourceRange(),
+ isa(TypedefName) ? "typedef"
+   : "type alias");
   }
 }
 

Modified: clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.h?rev=266358=266357=266358=diff
==
--- clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.h 
(original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/RedundantVoidArgCheck.h Thu 
Apr 14 14:28:13 2016
@@ -42,8 +42,9 @@ private:
   void processFunctionDecl(const ast_matchers::MatchFinder::MatchResult 
,
const FunctionDecl *Function);
 
-  void processTypedefDecl(const ast_matchers::MatchFinder::MatchResult ,
-  const TypedefDecl *Typedef);
+  void
+  processTypedefNameDecl(const ast_matchers::MatchFinder::MatchResult ,
+ const TypedefNameDecl *Typedef);
 
   void processFieldDecl(const ast_matchers::MatchFinder::MatchResult ,
 const FieldDecl *Member);

Modified: 
clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp?rev=266358=266357=266358=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-redundant-void-arg.cpp 
Thu Apr 14 14:28:13 2016
@@ -39,6 +39,12 @@ typedef int 

Re: [PATCH] D18698: [C11] PR24451: Allow restrict _Atomic pointers

2016-04-14 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla added a comment.

Richard, please let me know what in your opinion we should do with this 
revision.

Thank you,
Denis Zobnin


http://reviews.llvm.org/D18698



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


Re: r266254 - [modules] Remove CXX_CTOR_INITIALIZERS_OFFSETS table. Instead of storing an ID

2016-04-14 Thread Richard Smith via cfe-commits
On Thu, Apr 14, 2016 at 4:18 AM, Nico Weber  wrote:

> This broke building on
> http://lab.llvm.org:8011/builders/clang-x64-ninja-win7 . I tried fixing
> in r266290.
>

Oh, this is the hilarious MSVC do-while-inside-range-for bug again. Thanks
for the fix =)


> On Wed, Apr 13, 2016 at 5:57 PM, Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: rsmith
>> Date: Wed Apr 13 16:57:08 2016
>> New Revision: 266254
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=266254=rev
>> Log:
>> [modules] Remove CXX_CTOR_INITIALIZERS_OFFSETS table. Instead of storing
>> an ID
>> of a table entry in the corresponding decl, store an offset from the
>> current
>> record to the relevant CXX_CTOR_INITIALIZERS record. This results in fewer
>> indirections and a minor .pcm file size reduction.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/DeclCXX.h
>> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> cfe/trunk/include/clang/Serialization/ASTReader.h
>> cfe/trunk/include/clang/Serialization/ASTWriter.h
>> cfe/trunk/include/clang/Serialization/Module.h
>> cfe/trunk/lib/CodeGen/CGClass.cpp
>> cfe/trunk/lib/Serialization/ASTReader.cpp
>> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
>> cfe/trunk/lib/Serialization/Module.cpp
>>
>> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=266254=266253=266254=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
>> +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Apr 13 16:57:08 2016
>> @@ -2134,8 +2134,7 @@ public:
>>  assert(I < getNumArrayIndices() && "Out of bounds member array
>> index");
>>  getTrailingObjects()[I] = Index;
>>}
>> -  ArrayRef getArrayIndexes() {
>> -assert(getNumArrayIndices() != 0 && "Getting indexes for non-array
>> init");
>> +  ArrayRef getArrayIndices() {
>>  return llvm::makeArrayRef(getTrailingObjects(),
>>getNumArrayIndices());
>>}
>>
>> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=266254=266253=266254=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
>> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Apr 13 16:57:08
>> 2016
>> @@ -839,10 +839,10 @@ bool RecursiveASTVisitor::Trave
>>if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
>>  TRY_TO(TraverseStmt(Init->getInit()));
>>
>> -  if (Init->getNumArrayIndices() &&
>> getDerived().shouldVisitImplicitCode())
>> -for (VarDecl *VD : Init->getArrayIndexes()) {
>> +  if (getDerived().shouldVisitImplicitCode())
>> +for (VarDecl *VD : Init->getArrayIndices())
>>TRY_TO(TraverseDecl(VD));
>> -}
>> +
>>return true;
>>  }
>>
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=266254=266253=266254=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Apr 13
>> 16:57:08 2016
>> @@ -573,9 +573,7 @@ namespace clang {
>>/// \brief Record code for potentially unused local typedef names.
>>UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES = 52,
>>
>> -  /// \brief Record code for the table of offsets to
>> CXXCtorInitializers
>> -  /// lists.
>> -  CXX_CTOR_INITIALIZERS_OFFSETS = 53,
>> +  // ID 53 used to be a table of constructor initializer records.
>>
>>/// \brief Delete expressions that will be analyzed later.
>>DELETE_EXPRS_TO_ANALYZE = 54,
>>
>> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=266254=266253=266254=diff
>>
>> ==
>> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
>> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Apr 13 16:57:08
>> 2016
>> @@ -1971,11 +1971,6 @@ public:
>>ReadCXXCtorInitializers(ModuleFile , const RecordData ,
>>unsigned );
>>
>> -  /// \brief Read a CXXCtorInitializers ID from the given record and
>> -  /// return its global bit offset.
>> -  uint64_t ReadCXXCtorInitializersRef(ModuleFile , const RecordData
>> ,
>> -  unsigned );
>> -
>>

r266353 - Fix off-by-one error in worst-case number of offsets needed for an AST record.

2016-04-14 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Thu Apr 14 13:32:54 2016
New Revision: 266353

URL: http://llvm.org/viewvc/llvm-project?rev=266353=rev
Log:
Fix off-by-one error in worst-case number of offsets needed for an AST record.

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h
cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=266353=266352=266353=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Thu Apr 14 13:32:54 2016
@@ -704,7 +704,8 @@ class ASTRecordWriter {
   /// declaration or type.
   SmallVector StmtsToEmit;
 
-  static const int MaxOffsetIndices = 4;
+  /// Worst case: bases, vbases, visible and lexical contents, local redecls.
+  static const int MaxOffsetIndices = 5;
   /// \brief Indices of record elements that describe offsets within the
   /// bitcode. These will be converted to offsets relative to the current
   /// record when emitted.

Modified: cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h?rev=266353=266352=266353=diff
==
--- cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h (original)
+++ cfe/trunk/test/Modules/Inputs/cxx-decls-imported.h Thu Apr 14 13:32:54 2016
@@ -50,3 +50,8 @@ namespace Alias = Aliased;
 
 struct InhCtorA { InhCtorA(int); };
 struct InhCtorB : InhCtorA { using InhCtorA::InhCtorA; };
+
+struct ClassWithVBases : HasFriends, virtual HasNontrivialDefaultConstructor {
+  int n;
+};
+struct ClassWithVBases;


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


Re: r266160 - [modules] Refactor handling of cases where we write an offset to a prior record into the bitstream and simplify a little, in preparation for doing this in more cases.

2016-04-14 Thread Richard Smith via cfe-commits
r266353.

On Thu, Apr 14, 2016 at 11:09 AM, Richard Smith 
wrote:

> On Thu, Apr 14, 2016 at 9:00 AM, Nico Weber  wrote:
>
>> On Wed, Apr 13, 2016 at 10:24 PM, Nico Weber  wrote:
>>
>>> On Tue, Apr 12, 2016 at 10:12 PM, Richard Smith via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: rsmith
 Date: Tue Apr 12 21:12:03 2016
 New Revision: 266160

 URL: http://llvm.org/viewvc/llvm-project?rev=266160=rev
 Log:
 [modules] Refactor handling of cases where we write an offset to a
 prior record into the bitstream and simplify a little, in preparation for
 doing this in more cases.

 Modified:
 cfe/trunk/include/clang/Serialization/ASTWriter.h
 cfe/trunk/lib/Serialization/ASTWriter.cpp
 cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

 Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=266160=266159=266160=diff

 ==
 --- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
 +++ cfe/trunk/include/clang/Serialization/ASTWriter.h Tue Apr 12
 21:12:03 2016
 @@ -787,11 +787,29 @@ class ASTRecordWriter {
/// declaration or type.
SmallVector StmtsToEmit;

 +  static constexpr int MaxOffsetIndices = 4;
 +  /// \brief Indices of record elements that describe offsets within
 the
 +  /// bitcode. These will be converted to offsets relative to the
 current
 +  /// record when emitted.
 +  unsigned OffsetIndices[MaxOffsetIndices];
 +  unsigned NumOffsetIndices = 0;
 +
/// \brief Flush all of the statements and expressions that have
/// been added to the queue via AddStmt().
void FlushStmts();
void FlushSubStmts();

 +  void PrepareToEmit(uint64_t MyOffset) {
 +// Convert offsets into relative form.
 +for (unsigned I = 0; I != NumOffsetIndices; ++I) {
 +  auto  = (*Record)[OffsetIndices[I]];
 +  assert(StoredOffset < MyOffset && "invalid offset");
 +  if (StoredOffset)
 +StoredOffset = MyOffset - StoredOffset;
 +}
 +NumOffsetIndices = 0;
 +  }
 +
  public:
/// Construct a ASTRecordWriter that uses the default encoding
 scheme.
ASTRecordWriter(ASTWriter , ASTWriter::RecordDataImpl )
 @@ -802,6 +820,10 @@ public:
ASTRecordWriter(ASTRecordWriter , ASTWriter::RecordDataImpl
 )
: Writer(Parent.Writer), Record() {}

 +  /// Copying an ASTRecordWriter is almost certainly a bug.
 +  ASTRecordWriter(const ASTRecordWriter&) = delete;
 +  void operator=(const ASTRecordWriter&) = delete;
 +
/// \brief Extract the underlying record storage.
ASTWriter::RecordDataImpl () const { return *Record; }

 @@ -822,6 +844,7 @@ public:
// FIXME: Allow record producers to suggest Abbrevs.
uint64_t Emit(unsigned Code, unsigned Abbrev = 0) {
  uint64_t Offset = Writer->Stream.GetCurrentBitNo();
 +PrepareToEmit(Offset);
  Writer->Stream.EmitRecord(Code, *Record, Abbrev);
  FlushStmts();
  return Offset;
 @@ -830,10 +853,19 @@ public:
/// \brief Emit the record to the stream, preceded by its
 substatements.
uint64_t EmitStmt(unsigned Code, unsigned Abbrev = 0) {
  FlushSubStmts();
 +PrepareToEmit(Writer->Stream.GetCurrentBitNo());
  Writer->Stream.EmitRecord(Code, *Record, Abbrev);
  return Writer->Stream.GetCurrentBitNo();
}

 +  /// \brief Add a bit offset into the record. This will be converted
 into an
 +  /// offset relative to the current record when emitted.
 +  void AddOffset(uint64_t BitOffset) {
 +assert(NumOffsetIndices != MaxOffsetIndices && "too many offset
 indices");

>>>
>>> This assert is firing when building chrome with clang-cl on Windows:
>>> https://build.chromium.org/p/chromium.fyi/builders/ClangToTWin%28dbg%29/builds/5340/steps/compile/logs/stdio
>>>
>>
>> Repro: https://llvm.org/bugs/show_bug.cgi?id=27351
>>
>
> Thanks, investigating.
>
>
>> +OffsetIndices[NumOffsetIndices++] = Record->size();
 +Record->push_back(BitOffset);
 +  }
 +
/// \brief Add the given statement or expression to the queue of
/// statements to emit.
///

 Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
 URL:
 http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=266160=266159=266160=diff

 ==
 --- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
 +++ 

Re: [PATCH] D19117: [clang-tidy] Update RedundantVoidArgCheck to check for type aliases in addition to typedefs

2016-04-14 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks for the review !

> I can submit the patch on your behalf if you would like.


That'd be great, thank you.



Comment at: clang-tidy/modernize/RedundantVoidArgCheck.cpp:109-111
@@ -107,5 +108,5 @@
 SourceLocation Start = Function->getLocStart();
-SourceLocation End = Body ? Body->getLocStart().getLocWithOffset(-1) :
-Function->getLocEnd();
+SourceLocation End =
+Body ? Body->getLocStart().getLocWithOffset(-1) : 
Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");

aaron.ballman wrote:
> Generally, you run clang-format just over the patch so that you're only 
> formatting the code you've touched. However, if you ran clang-format over the 
> entire file and this is the only change it produced, I think it's fine as a 
> drive-by. If it produced more changes, then I would say submit all of the 
> formatting changes as a secondary patch.
Thanks, that's what I though. The test file had a ton of reformatting changes, 
so I left it out. 


http://reviews.llvm.org/D19117



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


Re: [PATCH] D19058: clang-format: Pointer `*` is seen as multiplication in C-style casts

2016-04-14 Thread Maxime Beaulieu via cfe-commits
mxbOctasic updated this revision to Diff 53755.
mxbOctasic added a comment.

Moved cast detection logic to `rParenEndsCast`.


http://reviews.llvm.org/D19058

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5882,6 +5882,24 @@
"operator()() && {}");
   verifyGoogleFormat("template \n"
  "auto x() & -> int {}");
+
+  // Some casts look like they might be multiplications, but they are 
definitely
+  // not!
+  // Here, foo could be a macro containing e.g. `const`
+  verifyFormat("(type *foo)bar");
+  verifyFormat("(type *const)bar");
+  verifyFormat("(type *restrict)bar");
+  verifyFormat("(type *foo)(bar)");
+  verifyFormat("(type *const)(bar)");
+  verifyFormat("(type *restrict)(bar)");
+  verifyFormat("type *x = (type *foo)bar");
+  verifyFormat("type *const x = (type *const)bar");
+  verifyFormat("type *x = (type *foo)(bar)");
+
+  FormatStyle LeftPointer = getLLVMStyle();
+  LeftPointer.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("int x = a[(sint16*)pIn - j]", LeftPointer);
+  verifyFormat("int x = a[(int*)pIn - j]", LeftPointer);
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -998,8 +998,14 @@
 Current.Type = TT_LineComment;
   }
 } else if (Current.is(tok::r_paren)) {
-  if (rParenEndsCast(Current))
+  if (rParenEndsCast(Current)) {
 Current.Type = TT_CastRParen;
+for (FormatToken *tok = Current.MatchingParen; tok && tok != 
+ tok = tok->Next)
+  // `*` in casts are never binary operators
+  if (tok->is(tok::star) && tok->is(TT_BinaryOperator))
+tok->Type = TT_PointerOrReference;
+  }
   if (Current.MatchingParen && Current.Next &&
   !Current.Next->isBinaryOperator() &&
   !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
@@ -1167,6 +1173,13 @@
 if (ParensAreType && !ParensCouldEndDecl)
   return true;
 
+// Some more obscure casts can leak through the above heuristic, like
+// (type* const)bar or (type* MACRO)(bar)
+if (Tok.Next->isOneOf(tok::identifier, tok::l_paren) && Tok.Previous &&
+Tok.Previous->isOneOf(tok::kw_const, tok::identifier) &&
+Tok.Previous->Previous && Tok.Previous->Previous->is(tok::star))
+  return true;
+
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there
 // are by the logic above, e.g. "(void)x;".


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5882,6 +5882,24 @@
"operator()() && {}");
   verifyGoogleFormat("template \n"
  "auto x() & -> int {}");
+
+  // Some casts look like they might be multiplications, but they are definitely
+  // not!
+  // Here, foo could be a macro containing e.g. `const`
+  verifyFormat("(type *foo)bar");
+  verifyFormat("(type *const)bar");
+  verifyFormat("(type *restrict)bar");
+  verifyFormat("(type *foo)(bar)");
+  verifyFormat("(type *const)(bar)");
+  verifyFormat("(type *restrict)(bar)");
+  verifyFormat("type *x = (type *foo)bar");
+  verifyFormat("type *const x = (type *const)bar");
+  verifyFormat("type *x = (type *foo)(bar)");
+
+  FormatStyle LeftPointer = getLLVMStyle();
+  LeftPointer.PointerAlignment = FormatStyle::PAS_Left;
+  verifyFormat("int x = a[(sint16*)pIn - j]", LeftPointer);
+  verifyFormat("int x = a[(int*)pIn - j]", LeftPointer);
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -998,8 +998,14 @@
 Current.Type = TT_LineComment;
   }
 } else if (Current.is(tok::r_paren)) {
-  if (rParenEndsCast(Current))
+  if (rParenEndsCast(Current)) {
 Current.Type = TT_CastRParen;
+for (FormatToken *tok = Current.MatchingParen; tok && tok != 
+ tok = tok->Next)
+  // `*` in casts are never binary operators
+  if (tok->is(tok::star) && tok->is(TT_BinaryOperator))
+tok->Type = TT_PointerOrReference;
+  }
   if (Current.MatchingParen && Current.Next &&
   !Current.Next->isBinaryOperator() &&
   !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
@@ -1167,6 +1173,13 @@
 if (ParensAreType && !ParensCouldEndDecl)
   return true;
 
+// Some more obscure casts can leak through the above 

[PATCH] D19123: In vector comparisons, handle scalar LHS just as we handle scalar RHS

2016-04-14 Thread Reid Kleckner via cfe-commits
rnk created this revision.
rnk added a reviewer: rsmith.
rnk added a subscriber: cfe-commits.

Fixes PR27258

http://reviews.llvm.org/D19123

Files:
  lib/Sema/SemaExpr.cpp
  test/CodeGen/vector.c

Index: test/CodeGen/vector.c
===
--- test/CodeGen/vector.c
+++ test/CodeGen/vector.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu pentium4 
-target-feature +sse4.1 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck 
%s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu core2 
-debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
 typedef short __v4hi __attribute__ ((__vector_size__ (8)));
 
 void test1() {
@@ -62,3 +62,23 @@
   extern __typeof(_mm_extract_epi16(_mm_setzero_si128(), 3)) check_result_int;
   extern __typeof(_mm_extract_epi32(_mm_setzero_si128(), 3)) check_result_int;
 }
+
+// Test some logic around our lax vector comparison rules with integers.
+
+typedef int vec_int1 __attribute__((vector_size(4)));
+vec_int1 lax_vector_compare1(int x, vec_int1 y) {
+  y = x == y;
+  return y;
+}
+
+// CHECK: define i32 @lax_vector_compare1(i32 {{.*}}, i32 {{.*}})
+// CHECK: icmp eq <1 x i32>
+
+typedef int vec_int2 __attribute__((vector_size(8)));
+vec_int2 lax_vector_compare2(long long x, vec_int2 y) {
+  y = x == y;
+  return y;
+}
+
+// CHECK: define void @lax_vector_compare2(<2 x i32>* {{.*sret.*}}, i64 
{{.*}}, i64 {{.*}})
+// CHECK: icmp eq <2 x i32>
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7932,11 +7932,12 @@
   // If we're allowing lax vector conversions, only the total (data) size
   // needs to be the same.
   // FIXME: Should we really be allowing this?
-  // FIXME: We really just pick the LHS type arbitrarily?
-  if (isLaxVectorConversion(RHSType, LHSType)) {
-QualType resultType = LHSType;
-RHS = ImpCastExprToType(RHS.get(), resultType, CK_BitCast);
-return resultType;
+  QualType VecType = LHSVecType ? LHSType : RHSType;
+  QualType ScalarType = LHSVecType ? RHSType : LHSType;
+  ExprResult *ScalarExpr = LHSVecType ?  : 
+  if (isLaxVectorConversion(ScalarType, VecType)) {
+*ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast);
+return VecType;
   }
 
   // Okay, the expression is invalid.


Index: test/CodeGen/vector.c
===
--- test/CodeGen/vector.c
+++ test/CodeGen/vector.c
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu pentium4 -target-feature +sse4.1 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple i386-apple-darwin9 -O1 -target-cpu core2 -debug-info-kind=limited -emit-llvm %s -o - | FileCheck %s
 typedef short __v4hi __attribute__ ((__vector_size__ (8)));
 
 void test1() {
@@ -62,3 +62,23 @@
   extern __typeof(_mm_extract_epi16(_mm_setzero_si128(), 3)) check_result_int;
   extern __typeof(_mm_extract_epi32(_mm_setzero_si128(), 3)) check_result_int;
 }
+
+// Test some logic around our lax vector comparison rules with integers.
+
+typedef int vec_int1 __attribute__((vector_size(4)));
+vec_int1 lax_vector_compare1(int x, vec_int1 y) {
+  y = x == y;
+  return y;
+}
+
+// CHECK: define i32 @lax_vector_compare1(i32 {{.*}}, i32 {{.*}})
+// CHECK: icmp eq <1 x i32>
+
+typedef int vec_int2 __attribute__((vector_size(8)));
+vec_int2 lax_vector_compare2(long long x, vec_int2 y) {
+  y = x == y;
+  return y;
+}
+
+// CHECK: define void @lax_vector_compare2(<2 x i32>* {{.*sret.*}}, i64 {{.*}}, i64 {{.*}})
+// CHECK: icmp eq <2 x i32>
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7932,11 +7932,12 @@
   // If we're allowing lax vector conversions, only the total (data) size
   // needs to be the same.
   // FIXME: Should we really be allowing this?
-  // FIXME: We really just pick the LHS type arbitrarily?
-  if (isLaxVectorConversion(RHSType, LHSType)) {
-QualType resultType = LHSType;
-RHS = ImpCastExprToType(RHS.get(), resultType, CK_BitCast);
-return resultType;
+  QualType VecType = LHSVecType ? LHSType : RHSType;
+  QualType ScalarType = LHSVecType ? RHSType : LHSType;
+  ExprResult *ScalarExpr = LHSVecType ?  : 
+  if (isLaxVectorConversion(ScalarType, VecType)) {
+*ScalarExpr = ImpCastExprToType(ScalarExpr->get(), VecType, CK_BitCast);
+return VecType;
   }
 
   // Okay, the expression is invalid.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18956: [Sema] Fix assertion failure at vector comparison

2016-04-14 Thread Reid Kleckner via cfe-commits
rnk added a subscriber: rnk.
rnk added a comment.

I think Sema::CheckVectorOperands isn't supposed to return a scalar type. 
Fixing that with http://reviews.llvm.org/D19123 also solves this problem. 
Richard, WDYT?


Repository:
  rL LLVM

http://reviews.llvm.org/D18956



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


Re: [PATCH] D18073: Add memory allocating functions

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D18073#399270, @ariccio wrote:

> In http://reviews.llvm.org/D18073#398882, @zaks.anna wrote:
>
> > "Since we are adding support for so many new APIs that are only available 
> > on Windows, could you please condition checking them only when we build for 
> > Windows. You probably can look and Language Options to figure that out."
> >
> > malloc-uses.c -> "alternative-malloc-api.c" ?
>
>
> Sorry for being so thickheaded about that the first go-around, I'm not 
> entirely sure what was up with me. I've changed the name of the file, but I 
> haven't yet figured out how to set up the Windows only tests to run on 
> Windows only. I'm assuming I can't simply:
>
>   #if defined(_WIN32)
>
>
> [...]
>
>   #endif
>
>
> ...because `lit` doesn't define `_WIN32` for me. Which Language Options 
> should I look in?


I believe that you can specify a triple using -triple i386-pc-win32 or 
something similar to force the compilation to be for a Windows target.


http://reviews.llvm.org/D18073



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


Re: [PATCH] D19118: [clang-tidy] Add checker for operations between integrals and pointers

2016-04-14 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Nice check!



Comment at: test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp:9
@@ +8,3 @@
+  pb = false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from bool 
to pointer
+  pc = '\0';

Specify the whole message including the check name once.


http://reviews.llvm.org/D19118



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


Re: [PATCH] D19062: Add functions in ctype.h to builtin function database (Fix)

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

This looks reasonable to me, but I am curious what @joerg thinks of this 
approach.


http://reviews.llvm.org/D19062



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


Re: [PATCH] D19121: [clang-tidy] Fix documentation generation.

2016-04-14 Thread Etienne Bergeron via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266333: [clang-tidy] Fix documentation generation. (authored 
by etienneb).

Changed prior to commit:
  http://reviews.llvm.org/D19121?vs=53741=53744#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19121

Files:
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst

Index: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
===
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
@@ -7,6 +7,7 @@
 not actually deleted by the compiler.
 
 .. code:: c++
+
   class Example {
   public:
 // This constructor is deleted because I is missing a default value.
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -286,6 +286,7 @@
   direct base class of this kind.
 
   The check has two complementary aspects:
+
   1. Ensure every constructor for a record type needing initialization
  value-initializes all members and direct bases via a combination of
  in-class initializers and the member initializer list.


Index: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
@@ -7,6 +7,7 @@
 not actually deleted by the compiler.
 
 .. code:: c++
+
   class Example {
   public:
 // This constructor is deleted because I is missing a default value.
Index: clang-tools-extra/trunk/docs/ReleaseNotes.rst
===
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst
@@ -286,6 +286,7 @@
   direct base class of this kind.
 
   The check has two complementary aspects:
+
   1. Ensure every constructor for a record type needing initialization
  value-initializes all members and direct bases via a combination of
  in-class initializers and the member initializer list.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19121: [clang-tidy] Fix documentation generation.

2016-04-14 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

LG. Thank you!


http://reviews.llvm.org/D19121



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


[clang-tools-extra] r266333 - [clang-tidy] Fix documentation generation.

2016-04-14 Thread Etienne Bergeron via cfe-commits
Author: etienneb
Date: Thu Apr 14 11:08:04 2016
New Revision: 266333

URL: http://llvm.org/viewvc/llvm-project?rev=266333=rev
Log:
[clang-tidy] Fix documentation generation.

Summary: The patch is fixing the generation of clang-tidy documentation.

Reviewers: alexfh

Subscribers: cfe-commits

Differential Revision: http://reviews.llvm.org/D19121

Modified:
clang-tools-extra/trunk/docs/ReleaseNotes.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst

Modified: clang-tools-extra/trunk/docs/ReleaseNotes.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/ReleaseNotes.rst?rev=266333=266332=266333=diff
==
--- clang-tools-extra/trunk/docs/ReleaseNotes.rst (original)
+++ clang-tools-extra/trunk/docs/ReleaseNotes.rst Thu Apr 14 11:08:04 2016
@@ -286,6 +286,7 @@ The 3.8 release didn't include release n
   direct base class of this kind.
 
   The check has two complementary aspects:
+
   1. Ensure every constructor for a record type needing initialization
  value-initializes all members and direct bases via a combination of
  in-class initializers and the member initializer list.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst?rev=266333=266332=266333=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst 
(original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst 
Thu Apr 14 11:08:04 2016
@@ -7,6 +7,7 @@ Checks that constructors and assignment
 not actually deleted by the compiler.
 
 .. code:: c++
+
   class Example {
   public:
 // This constructor is deleted because I is missing a default value.


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


Re: [PATCH] D19121: [clang-tidy] Fix documentation generation.

2016-04-14 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 53741.
etienneb added a comment.

right fix.


http://reviews.llvm.org/D19121

Files:
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-deleted-default.rst

Index: docs/clang-tidy/checks/readability-deleted-default.rst
===
--- docs/clang-tidy/checks/readability-deleted-default.rst
+++ docs/clang-tidy/checks/readability-deleted-default.rst
@@ -7,6 +7,7 @@
 not actually deleted by the compiler.
 
 .. code:: c++
+
   class Example {
   public:
 // This constructor is deleted because I is missing a default value.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -286,6 +286,7 @@
   direct base class of this kind.
 
   The check has two complementary aspects:
+
   1. Ensure every constructor for a record type needing initialization
  value-initializes all members and direct bases via a combination of
  in-class initializers and the member initializer list.


Index: docs/clang-tidy/checks/readability-deleted-default.rst
===
--- docs/clang-tidy/checks/readability-deleted-default.rst
+++ docs/clang-tidy/checks/readability-deleted-default.rst
@@ -7,6 +7,7 @@
 not actually deleted by the compiler.
 
 .. code:: c++
+
   class Example {
   public:
 // This constructor is deleted because I is missing a default value.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -286,6 +286,7 @@
   direct base class of this kind.
 
   The check has two complementary aspects:
+
   1. Ensure every constructor for a record type needing initialization
  value-initializes all members and direct bases via a combination of
  in-class initializers and the member initializer list.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266331 - Add typedefNameDecl() and typeAliasDecl() to the AST matchers; improves hasType() to match on TypedefNameDecl nodes.

2016-04-14 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Thu Apr 14 11:05:45 2016
New Revision: 266331

URL: http://llvm.org/viewvc/llvm-project?rev=266331=rev
Log:
Add typedefNameDecl() and typeAliasDecl() to the AST matchers; improves 
hasType() to match on TypedefNameDecl nodes.

Patch by Clement Courbet.

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
cfe/trunk/lib/ASTMatchers/Dynamic/Registry.cpp
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=266331=266330=266331=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Thu Apr 14 11:05:45 2016
@@ -405,13 +405,36 @@ decl(hasDeclContext(translationUnitDecl(
 
 
 
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypeAliasDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypeAliasDecl.html;>TypeAliasDecl...
+Matches type alias 
declarations.
+
+Given
+  typedef int X;
+   using Y = int;
+typeAliasDecl()
+  matches "using Y = int", but not "typedef int X"
+
+
+
 Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDecl...
 Matches typedef 
declarations.
 
 Given
   typedef int X;
+   using Y = int;
 typedefDecl()
-  matches "typedef int X"
+  matches "typedef int X", but not "using Y = int"
+
+
+
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1Decl.html;>DecltypedefNameDeclMatcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html;>TypedefNameDecl...
+Matches typedef 
name declarations.
+
+Given
+  typedef int X;
+   using Y = int;
+typedefNameDecl()
+  matches "typedef int X" and "using Y = int"
 
 
 
@@ -5083,7 +5106,7 @@ Usable as: Any Matcher
 
 
 
-Matcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefDecl.html;>TypedefDeclhasTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType
 InnerMatcher
+Matcherhttp://clang.llvm.org/doxygen/classclang_1_1TypedefNameDecl.html;>TypedefNameDeclhasTypeMatcherhttp://clang.llvm.org/doxygen/classclang_1_1QualType.html;>QualType
 InnerMatcher
 Matches if the expression's 
or declaration's type matches a type
 matcher.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=266331=266330=266331=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Thu Apr 14 11:05:45 2016
@@ -163,11 +163,35 @@ const internal::VariadicDynCastAllOfMatc
 /// Given
 /// \code
 ///   typedef int X;
+//using Y = int;
 /// \endcode
 /// typedefDecl()
-///   matches "typedef int X"
+///   matches "typedef int X", but not "using Y = int"
 const internal::VariadicDynCastAllOfMatcher typedefDecl;
 
+/// \brief Matches typedef name declarations.
+///
+/// Given
+/// \code
+///   typedef int X;
+//using Y = int;
+/// \endcode
+/// typedefNameDecl()
+///   matches "typedef int X" and "using Y = int"
+const internal::VariadicDynCastAllOfMatcher
+typedefNameDecl;
+
+/// \brief Matches type alias declarations.
+///
+/// Given
+/// \code
+///   typedef int X;
+//using Y = int;
+/// \endcode
+/// typeAliasDecl()
+///   matches "using Y = int", but not "typedef int X"
+const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
@@ -2451,9 +2475,9 @@ AST_MATCHER_P_OVERLOAD(CallExpr, callee,
 ///  typedef int U;
 /// \endcode
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, TypedefDecl, ValueDecl),
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, TypedefNameDecl, ValueDecl),
 internal::Matcher, InnerMatcher, 0) {
-  return InnerMatcher.matches(internal::getUnderlyingType(Node),
+  return InnerMatcher.matches(internal::getUnderlyingType(Node),
   Finder, Builder);
 }
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h?rev=266331=266330=266331=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchersInternal.h Thu Apr 14 
11:05:45 2016
@@ -96,12 +96,13 @@ private:
 
 /// \brief Unifies obtaining the underlying type of a regular node through
 

Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Committed in r266331


http://reviews.llvm.org/D19113



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


Re: [PATCH] D19117: [clang-tidy] Update RedundantVoidArgCheck to check for type aliases in addition to typedefs

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for working on this! I can submit the patch on your behalf if 
you would like.



Comment at: clang-tidy/modernize/RedundantVoidArgCheck.cpp:109-111
@@ -107,5 +108,5 @@
 SourceLocation Start = Function->getLocStart();
-SourceLocation End = Body ? Body->getLocStart().getLocWithOffset(-1) :
-Function->getLocEnd();
+SourceLocation End =
+Body ? Body->getLocStart().getLocWithOffset(-1) : 
Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");

Generally, you run clang-format just over the patch so that you're only 
formatting the code you've touched. However, if you ran clang-format over the 
entire file and this is the only change it produced, I think it's fine as a 
drive-by. If it produced more changes, then I would say submit all of the 
formatting changes as a secondary patch.


http://reviews.llvm.org/D19117



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


[PATCH] D19121: [clang-tidy] Fix documentation generation.

2016-04-14 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

The patch is fixing the generation of clang-tidy documentation.

http://reviews.llvm.org/D19121

Files:
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/readability-deleted-default.rst

Index: docs/clang-tidy/checks/readability-deleted-default.rst
===
--- docs/clang-tidy/checks/readability-deleted-default.rst
+++ docs/clang-tidy/checks/readability-deleted-default.rst
@@ -7,6 +7,7 @@
 not actually deleted by the compiler.
 
 .. code:: c++
+
   class Example {
   public:
 // This constructor is deleted because I is missing a default value.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -286,12 +286,8 @@
   direct base class of this kind.
 
   The check has two complementary aspects:
-  1. Ensure every constructor for a record type needing initialization
- value-initializes all members and direct bases via a combination of
- in-class initializers and the member initializer list.
-  2. Value-initialize every non-member instance of a record type needing
- initialization that lacks a user-provided default constructor, e.g.
- a POD.
+  1. Ensure every constructor for a record type needing initialization 
value-initializes all members and direct bases via a combination of in-class 
initializers and the member initializer list.
+  2. Value-initialize every non-member instance of a record type needing 
initialization that lacks a user-provided default constructor, e.g. a POD.
 
 Improvements to modularize
 --


Index: docs/clang-tidy/checks/readability-deleted-default.rst
===
--- docs/clang-tidy/checks/readability-deleted-default.rst
+++ docs/clang-tidy/checks/readability-deleted-default.rst
@@ -7,6 +7,7 @@
 not actually deleted by the compiler.
 
 .. code:: c++
+
   class Example {
   public:
 // This constructor is deleted because I is missing a default value.
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -286,12 +286,8 @@
   direct base class of this kind.
 
   The check has two complementary aspects:
-  1. Ensure every constructor for a record type needing initialization
- value-initializes all members and direct bases via a combination of
- in-class initializers and the member initializer list.
-  2. Value-initialize every non-member instance of a record type needing
- initialization that lacks a user-provided default constructor, e.g.
- a POD.
+  1. Ensure every constructor for a record type needing initialization value-initializes all members and direct bases via a combination of in-class initializers and the member initializer list.
+  2. Value-initialize every non-member instance of a record type needing initialization that lacks a user-provided default constructor, e.g. a POD.
 
 Improvements to modularize
 --
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-14 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: lib/Frontend/InitPreprocessor.cpp:421
@@ +420,3 @@
+switch (LangOpts.OpenCLVersion) {
+case 0:
+case 100:

pxli168 wrote:
> What is 0 stand for as OpenCLVersion, it seems the default OpenCLVersion if 
> we did not pass any -cl-std=CLXX is 100.
> So maybe we did not need this case 0:
There is a test test/Frontend/stdlang.c:

  // RUN: %clang_cc1 -x cl -std=c99 -DOPENCL %s

With this test, LangOpts.OpenCL is 1 but LangOpts.OpenCLVersion is 0.

If we all agree that this test is invalid and -x cl can only be compiled with 
OpenCL language standard and the default one is OpenCL 1.0, I can fix that test 
first and then remove case 0 in this switch.


Comment at: lib/Frontend/InitPreprocessor.cpp:439
@@ +438,3 @@
+if (LangOpts.OpenCLVersion >= 110)
+  Builder.defineMacro("CL_VERSION_1_1", "110");
+if (LangOpts.OpenCLVersion >= 120)

pxli168 wrote:
> These macros maybe need for all cl version, and in the header we should 
> compare  __OPENCL_C_VERSION__ with CL_VERSION_2_0 instead of the integer 200 
> in the header of  http://reviews.llvm.org/D18369? 
Each OpenCL version only defines some of these macros by spec.

In the header file `__OPENCL_C_VERSION__` can compare with 200 since the spec 
defines the integer value for `__OPENCL_C_VERSION__`. Comparing with 
CL_VERSION_2_0 requires checking CL_VERSION_2_0 is available first. I think 
probably I can define a macro 

  #define _OPENCL20_AND_ABOVE defined(__OPENCL_C_VERSION__) and 
defined(CL_VERSION_2_0) and __OPENCL_C_VERSION__ >= 200

and then use this macro for conditioning 2.0 specific functions.


http://reviews.llvm.org/D19071



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


Re: [PATCH] D19117: [clang-tidy] Update RedundantVoidArgCheck to check for type aliases in addition to typedefs

2016-04-14 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 53735.
courbet added a comment.

Fix error message in case of type alias declaration.


http://reviews.llvm.org/D19117

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tidy/modernize/RedundantVoidArgCheck.h
  test/clang-tidy/modernize-redundant-void-arg.cpp

Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -39,6 +39,12 @@
 // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: {{.*}} in typedef
 // CHECK-FIXES: {{^}}typedef int (*returns_fn_void_int_t())();{{$}}
 
+// Should work for type aliases as well as typedef.
+using returns_fn_void_int_t2 = int (*(void))(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: {{.*}} in type alias
+// CHECK-MESSAGES: :[[@LINE-2]]:46: warning: {{.*}} in type alias
+// CHECK-FIXES: {{^}}using returns_fn_void_int_t2 = int (*())();{{$}}
+
 int (*returns_fn_void_int(void))(void) {
 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function definition
 // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function definition
Index: clang-tidy/modernize/RedundantVoidArgCheck.h
===
--- clang-tidy/modernize/RedundantVoidArgCheck.h
+++ clang-tidy/modernize/RedundantVoidArgCheck.h
@@ -42,8 +42,9 @@
   void processFunctionDecl(const ast_matchers::MatchFinder::MatchResult 
,
const FunctionDecl *Function);
 
-  void processTypedefDecl(const ast_matchers::MatchFinder::MatchResult ,
-  const TypedefDecl *Typedef);
+  void
+  processTypedefNameDecl(const ast_matchers::MatchFinder::MatchResult ,
+ const TypedefNameDecl *Typedef);
 
   void processFieldDecl(const ast_matchers::MatchFinder::MatchResult ,
 const FieldDecl *Member);
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -50,7 +50,7 @@
   unless(isExternC()))
  .bind(FunctionId),
  this);
-  Finder->addMatcher(typedefDecl().bind(TypedefId), this);
+  Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
@@ -80,8 +80,9 @@
   const BoundNodes  = Result.Nodes;
   if (const auto *Function = Nodes.getNodeAs(FunctionId)) {
 processFunctionDecl(Result, Function);
-  } else if (const auto *Typedef = Nodes.getNodeAs(TypedefId)) {
-processTypedefDecl(Result, Typedef);
+  } else if (const auto *TypedefName =
+ Nodes.getNodeAs(TypedefId)) {
+processTypedefNameDecl(Result, TypedefName);
   } else if (const auto *Member = Nodes.getNodeAs(FieldId)) {
 processFieldDecl(Result, Member);
   } else if (const auto *Var = Nodes.getNodeAs(VarId)) {
@@ -105,8 +106,8 @@
   if (Function->isThisDeclarationADefinition()) {
 const Stmt *Body = Function->getBody();
 SourceLocation Start = Function->getLocStart();
-SourceLocation End = Body ? Body->getLocStart().getLocWithOffset(-1) :
-Function->getLocEnd();
+SourceLocation End =
+Body ? Body->getLocStart().getLocWithOffset(-1) : 
Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");
   } else {
@@ -179,10 +180,13 @@
   diag(VoidLoc, Diagnostic) << FixItHint::CreateRemoval(VoidRange);
 }
 
-void RedundantVoidArgCheck::processTypedefDecl(
-const MatchFinder::MatchResult , const TypedefDecl *Typedef) {
-  if (protoTypeHasNoParms(Typedef->getUnderlyingType())) {
-removeVoidArgumentTokens(Result, Typedef->getSourceRange(), "typedef");
+void RedundantVoidArgCheck::processTypedefNameDecl(
+const MatchFinder::MatchResult ,
+const TypedefNameDecl *TypedefName) {
+  if (protoTypeHasNoParms(TypedefName->getUnderlyingType())) {
+removeVoidArgumentTokens(Result, TypedefName->getSourceRange(),
+ isa(TypedefName) ? "typedef"
+   : "type alias");
   }
 }
 


Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -39,6 +39,12 @@
 // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: {{.*}} in typedef
 // CHECK-FIXES: {{^}}typedef int (*returns_fn_void_int_t())();{{$}}
 
+// Should work for type aliases as well as typedef.
+using returns_fn_void_int_t2 = int (*(void))(void);
+// 

Re: [PATCH] D19117: [clang-tidy] Update RedundantVoidArgCheck to check for type aliases in addition to typedefs

2016-04-14 Thread Clement Courbet via cfe-commits
courbet marked an inline comment as done.


Comment at: clang-tidy/modernize/RedundantVoidArgCheck.cpp:109-110
@@ -107,4 +108,4 @@
 SourceLocation Start = Function->getLocStart();
-SourceLocation End = Body ? Body->getLocStart().getLocWithOffset(-1) :
-Function->getLocEnd();
+SourceLocation End =
+Body ? Body->getLocStart().getLocWithOffset(-1) : 
Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),

aaron.ballman wrote:
> Is this a drive-by formatting fix from clang-format?
Yes. What's the policy here (I'm a new contributor) ? Should I not touch it ?


http://reviews.llvm.org/D19117



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


Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Clement Courbet via cfe-commits
courbet added a comment.

Thanks for the review ! I don't have write access, could you please submit this 
for me ?


http://reviews.llvm.org/D19113



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


Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for working on this!


http://reviews.llvm.org/D19113



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


Re: r266108 - clang-cl: Remove -isystem, add -imsvc.

2016-04-14 Thread Ismail Donmez via cfe-commits
On Thu, Apr 14, 2016 at 5:52 PM, Nico Weber  wrote:
> On Thu, Apr 14, 2016 at 10:32 AM, Ismail Donmez  wrote:
>>
>> On Thu, Apr 14, 2016 at 2:09 PM, Nico Weber  wrote:
>> > It's supposed to match the
>> >
>> > "-internal-isystem"
>> >
>> > "/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0/include"
>> > "-internal-isystem" "myincludedir"
>> >
>> > bit in your output. Looks like it's "lib64" instead of "lib" on your
>> > system.
>> > Does changing
>> >
>> > // SLASH_imsvc: "-internal-isystem"
>> > "{{[^"]*}}lib{{/|}}clang{{[^"]*}}include"
>> >
>> > to
>> >
>> > // SLASH_imsvc: "-internal-isystem"
>> > "{{[^"]*}}lib{{(64)?/|}}clang{{[^"]*}}include"
>> >
>> > help?
>>
>> Yes it does, thanks.
>
>
> Want to land that change? :-)

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


Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 53732.
courbet marked 2 inline comments as done.
courbet added a comment.

Regenerate doc, cosmetics.


http://reviews.llvm.org/D19113

Files:
  docs/LibASTMatchersReference.html
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1101,6 +1101,16 @@
   typedefDecl(hasType(asString("foo")), hasName("bar";
 }
 
+TEST(HasType, MatchesTypedefNameDecl) {
+  EXPECT_TRUE(matches("using X = int;", typedefNameDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("using T = const int;",
+  typedefNameDecl(hasType(asString("const int");
+  EXPECT_TRUE(notMatches("using T = const int;",
+ typedefNameDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("using foo = int; using bar = foo;",
+  typedefNameDecl(hasType(asString("foo")), hasName("bar";
+}
+
 TEST(HasTypeLoc, MatchesDeclaratorDecls) {
   EXPECT_TRUE(matches("int x;",
   varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
@@ -5404,9 +5414,25 @@
   .bind("data")));
 }
 
-TEST(TypeDefDeclMatcher, Match) {
+TEST(TypedefDeclMatcher, Match) {
   EXPECT_TRUE(matches("typedef int typedefDeclTest;",
   typedefDecl(hasName("typedefDeclTest";
+  EXPECT_TRUE(notMatches("using typedefDeclTest2 = int;",
+ typedefDecl(hasName("typedefDeclTest2";
+}
+
+TEST(TypeAliasDeclMatcher, Match) {
+  EXPECT_TRUE(matches("using typeAliasTest2 = int;",
+  typeAliasDecl(hasName("typeAliasTest2";
+  EXPECT_TRUE(notMatches("typedef int typeAliasTest;",
+ typeAliasDecl(hasName("typeAliasTest";
+}
+
+TEST(TypedefNameDeclMatcher, Match) {
+  EXPECT_TRUE(matches("typedef int typedefNameDeclTest1;",
+  typedefNameDecl(hasName("typedefNameDeclTest1";
+  EXPECT_TRUE(matches("using typedefNameDeclTest2 = int;",
+  typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
 TEST(IsInlineMatcher, IsInline) {
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -388,7 +388,9 @@
   REGISTER_MATCHER(translationUnitDecl);
   REGISTER_MATCHER(type);
   REGISTER_MATCHER(typedefDecl);
+  REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
+  REGISTER_MATCHER(typeAliasDecl);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
   REGISTER_MATCHER(unaryOperator);
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -96,12 +96,13 @@
 
 /// \brief Unifies obtaining the underlying type of a regular node through
 /// `getType` and a TypedefNameDecl node through `getUnderlyingType`.
-template 
-inline QualType getUnderlyingType(const NodeType ) {
+inline QualType getUnderlyingType(const Expr ) { return Node.getType(); }
+
+inline QualType getUnderlyingType(const ValueDecl ) {
   return Node.getType();
 }
 
-template <> inline QualType getUnderlyingType(const TypedefDecl ) {
+inline QualType getUnderlyingType(const TypedefNameDecl ) {
   return Node.getUnderlyingType();
 }
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -163,11 +163,35 @@
 /// Given
 /// \code
 ///   typedef int X;
+//using Y = int;
 /// \endcode
 /// typedefDecl()
-///   matches "typedef int X"
+///   matches "typedef int X", but not "using Y = int"
 const internal::VariadicDynCastAllOfMatcher typedefDecl;
 
+/// \brief Matches typedef name declarations.
+///
+/// Given
+/// \code
+///   typedef int X;
+//using Y = int;
+/// \endcode
+/// typedefNameDecl()
+///   matches "typedef int X" and "using Y = int"
+const internal::VariadicDynCastAllOfMatcher
+typedefNameDecl;
+
+/// \brief Matches type alias declarations.
+///
+/// Given
+/// \code
+///   typedef int X;
+//using Y = int;
+/// \endcode
+/// typeAliasDecl()
+///   matches "using Y = int", but not "typedef int X"
+const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
@@ -2451,9 +2475,9 @@
 ///  typedef int U;
 /// \endcode
 

r266324 - Fix testcase for the LLVM_LIBDIR_SUFFIX=64 case. Fallout from r266108.

2016-04-14 Thread Ismail Donmez via cfe-commits
Author: ismail
Date: Thu Apr 14 10:32:24 2016
New Revision: 266324

URL: http://llvm.org/viewvc/llvm-project?rev=266324=rev
Log:
Fix testcase for the LLVM_LIBDIR_SUFFIX=64 case. Fallout from r266108.


Modified:
cfe/trunk/test/Driver/cl-options.c

Modified: cfe/trunk/test/Driver/cl-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cl-options.c?rev=266324=266323=266324=diff
==
--- cfe/trunk/test/Driver/cl-options.c (original)
+++ cfe/trunk/test/Driver/cl-options.c Thu Apr 14 10:32:24 2016
@@ -85,7 +85,7 @@
 // RUN: %clang_cl /imsvcmyincludedir -### -- %s 2>&1 | FileCheck 
-check-prefix=SLASH_imsvc %s
 // RUN: %clang_cl /imsvc myincludedir -### -- %s 2>&1 | FileCheck 
-check-prefix=SLASH_imsvc %s
 // Clang's resource header directory should be first:
-// SLASH_imsvc: "-internal-isystem" 
"{{[^"]*}}lib{{/|}}clang{{[^"]*}}include"
+// SLASH_imsvc: "-internal-isystem" 
"{{[^"]*}}lib{{(64)?/|}}clang{{[^"]*}}include"
 // SLASH_imsvc: "-internal-isystem" "myincludedir"
 
 // RUN: %clang_cl /J -### -- %s 2>&1 | FileCheck -check-prefix=J %s


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


Re: [PATCH] D19118: [clang-tidy] Add checker for operations between integrals and pointers

2016-04-14 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 53730.
etienneb added a comment.

nits


http://reviews.llvm.org/D19118

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/PointerAndIntegralOperationCheck.cpp
  clang-tidy/misc/PointerAndIntegralOperationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst
  test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp
  test/clang-tidy/misc-pointer-and-integral-operation.cpp

Index: test/clang-tidy/misc-pointer-and-integral-operation.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-pointer-and-integral-operation.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s misc-pointer-and-integral-operation %t
+
+bool* pb;
+char* pc;
+int* pi;
+
+int Test() {
+  if (pi < 0) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with zero
+  if (pi <= 0) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with zero
+
+  if (nullptr <= pb) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: suspicious comparison of pointer with null
+  if (pc < nullptr) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with null
+  if (pi > nullptr) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with null
+
+  return 1;
+}
+
+int Valid() {
+  *pb = false;
+  *pc = '\0';
+
+  pi += (pi != nullptr);
+  pi -= (pi == nullptr);
+  pc += (pb != nullptr);
+}
Index: test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp
@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s misc-pointer-and-integral-operation %t -- -- -std=c++98
+
+bool* pb;
+char* pc;
+int* pi;
+
+int Test() {
+  pb = false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from bool to pointer
+  pc = '\0';
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from char to pointer
+
+  pb = (false?false:false);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from bool to pointer
+  pb = (4 != 5?false:false);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from bool to pointer
+
+  if (pb < false) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and bool literal
+  if (pb != false) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and bool literal
+  if (pc < '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+  if (pc != '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+  if (pi < '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+  if (pi != '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+
+  return 1;
+}
+
+int Valid() {
+  *pb = false;
+  *pc = '\0';
+
+  pb += 0;
+  pc += 0;
+  pi += 0;
+
+  pb += (pb != 0);
+  pc += (pc != 0);
+  pi += (pi != 0);
+}
Index: docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst
@@ -0,0 +1,25 @@
+.. title:: clang-tidy - misc-pointer-and-integral-operation
+
+misc-pointer-and-integral-operation
+===
+
+Looks for operation involving pointers and integral types. A common mistake is
+to forget to dereference a pointer. These errors may be detected when a pointer
+object is compare to an object with integral type.
+
+
+Examples:
+
+.. code:: c++
+
+  char* ptr;
+  if ((ptr = malloc(...)) < nullptr)   // Pointer comparison with operator '<'
+...// Should probably be '!='
+
+  if (ptr == '\0')   // Should probably be *ptr
+... 
+
+  void Prcess(std::string path, bool* error) {
+[...]
+if (error != false)  // Should probably be *error
+  ...
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -64,6 +64,7 @@
misc-new-delete-overloads
misc-noexcept-move-constructor
misc-non-copyable-objects
+   misc-pointer-and-integral-operation
misc-sizeof-container
misc-static-assert
misc-string-integer-assignment
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -103,6 +103,11 @@
   Warns 

[PATCH] D19118: [clang-tidy] Add checker for operations between integrals and pointers

2016-04-14 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added a reviewer: alexfh.
etienneb added a subscriber: cfe-commits.

This check is finding suspicious operations involving pointers and integral 
types; which are most likely bugs.

Examples:
subversion/v1_6/subversion/libsvn_subr/utf.c
```
static const char *
fuzzy_escape(const char *src, apr_size_t len, apr_pool_t *pool)
{
  [...]
   while (src_orig < src_end)
{
  if (! svn_ctype_isascii(*src_orig) || src_orig == '\0')   // Should be 
*src_orig
{
```

apache2/v2_2_23/modules/metadata/mod_headers.c
```
static char *parse_format_tag(apr_pool_t *p, format_tag *tag, const char **sa)
{
  [...]
tag->arg = '\0';   // ERROR: tag->arg has type char*

/* grab the argument if there is one */
if (*s == '{') {
++s;
tag->arg = ap_getword(p,,'}');
}
```

http://reviews.llvm.org/D19118

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/PointerAndIntegralOperationCheck.cpp
  clang-tidy/misc/PointerAndIntegralOperationCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst
  test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp
  test/clang-tidy/misc-pointer-and-integral-operation.cpp

Index: test/clang-tidy/misc-pointer-and-integral-operation.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-pointer-and-integral-operation.cpp
@@ -0,0 +1,30 @@
+// RUN: %check_clang_tidy %s misc-pointer-and-integral-operation %t
+
+bool* pb;
+char* pc;
+int* pi;
+
+int Test() {
+  if (pi < 0) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with zero
+  if (pi <= 0) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with zero
+
+  if (nullptr <= pb) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: suspicious comparison of pointer with null
+  if (pc < nullptr) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with null
+  if (pi > nullptr) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious comparison of pointer with null
+
+  return 1;
+}
+
+int Valid() {
+  *pb = false;
+  *pc = '\0';
+
+  pi += (pi != nullptr);
+  pi -= (pi == nullptr);
+  pc += (pb != nullptr);
+}
Index: test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-pointer-and-integral-operation-cxx98.cpp
@@ -0,0 +1,45 @@
+// RUN: %check_clang_tidy %s misc-pointer-and-integral-operation %t -- -- -std=c++98
+
+bool* pb;
+char* pc;
+int* pi;
+
+int Test() {
+  pb = false;
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from bool to pointer
+  pc = '\0';
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from char to pointer
+
+  pb = (false?false:false);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from bool to pointer
+  pb = (4 != 5?false:false);
+  // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: suspicious assignment from bool to pointer
+
+  if (pb < false) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and bool literal
+  if (pb != false) return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and bool literal
+  if (pc < '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+  if (pc != '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+  if (pi < '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+  if (pi != '\0') return 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious operation between pointer and character literal
+
+  return 1;
+}
+
+int Valid() {
+  *pb = false;
+  *pc = '\0';
+
+  pb += 0;
+  pc += 0;
+  pi += 0;
+
+  pb += (pb != 0);
+  pc += (pc != 0);
+  pi += (pi != 0);
+}
Index: docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/misc-pointer-and-integral-operation.rst
@@ -0,0 +1,25 @@
+.. title:: clang-tidy - misc-pointer-and-integral-operation
+
+misc-pointer-and-integral-operation
+===
+
+Looks for operation involving pointers and integral types. A common mistake is
+to forget to dereference a pointer. These errors may be detected when a pointer
+object is compare to an object with integral type.
+
+
+Examples:
+
+.. code:: c++
+
+  char* ptr;
+  if ((ptr = malloc(...)) < nullptr)   // Pointer comparison with operator '<'
+...// Should probably be '!='
+
+  if (ptr == '\0')   

Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

A few minor nits remain.

Please run clang\docs\tools\dump_ast_matchers.py to regenerate the AST matcher 
documentation with your changes.



Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:5420
@@ -5409,1 +5419,3 @@
   typedefDecl(hasName("typedefDeclTest";
+  EXPECT_FALSE(matches("using typedefDeclTest2 = int;",
+   typedefDecl(hasName("typedefDeclTest2";

Should be EXPECT_TRUE with notMatches().


Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:5427
@@ +5426,3 @@
+  typeAliasDecl(hasName("typeAliasTest2";
+  EXPECT_FALSE(matches("typedef int typeAliasTest;",
+   typeAliasDecl(hasName("typeAliasTest";

Should be EXPECT_TRUE with notMatches


http://reviews.llvm.org/D19113



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


Re: [PATCH] D19028: clang-format: Implemented tab usage for continuation and indentation

2016-04-14 Thread Marianne Mailhot-Sarrasin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266320: clang-format: Implemented tab usage for continuation 
and indentation (authored by mamai).

Changed prior to commit:
  http://reviews.llvm.org/D19028?vs=53444=53721#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19028

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

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -603,6 +603,8 @@
 UT_Never,
 /// Use tabs only for indentation.
 UT_ForIndentation,
+/// Use tabs only for line continuation and indentation.
+UT_ForContinuationAndIndentation,
 /// Use tabs whenever we need to fill whitespace that spans at least from
 /// one tab stop to the next one.
 UT_Always
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -69,6 +69,8 @@
 IO.enumCase(Value, "Always", FormatStyle::UT_Always);
 IO.enumCase(Value, "true", FormatStyle::UT_Always);
 IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation);
+IO.enumCase(Value, "ForContinuationAndIndentation",
+FormatStyle::UT_ForContinuationAndIndentation);
   }
 };
 
Index: cfe/trunk/lib/Format/WhitespaceManager.cpp
===
--- cfe/trunk/lib/Format/WhitespaceManager.cpp
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp
@@ -558,6 +558,14 @@
 }
 Text.append(Spaces, ' ');
 break;
+  case FormatStyle::UT_ForContinuationAndIndentation:
+if (WhitespaceStartColumn == 0) {
+  unsigned Tabs = Spaces / Style.TabWidth;
+  Text.append(Tabs, '\t');
+  Spaces -= Tabs * Style.TabWidth;
+}
+Text.append(Spaces, ' ');
+break;
   }
 }
 
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -8572,6 +8572,230 @@
"\t */\n"
"\t int i;\n"
"}"));
+
+  Tab.UseTab = FormatStyle::UT_ForContinuationAndIndentation;
+  Tab.TabWidth = 8;
+  Tab.IndentWidth = 8;
+  EXPECT_EQ("if ( && // q\n"
+"bb) // w\n"
+"\t;",
+format("if ( &&// q\n"
+   "bb)// w\n"
+   ";",
+   Tab));
+  EXPECT_EQ("if (aaa && bbb) // w\n"
+"\t;",
+format("if(aaa&)// w\n"
+   ";",
+   Tab));
+  verifyFormat("class X {\n"
+   "\tvoid f() {\n"
+   "\t\tsomeFunction(parameter1,\n"
+   "\t\t\t parameter2);\n"
+   "\t}\n"
+   "};",
+   Tab);
+  verifyFormat("#define A\\\n"
+   "\tvoid f() {   \\\n"
+   "\t\tsomeFunction(\\\n"
+   "\t\tparameter1,  \\\n"
+   "\t\tparameter2); \\\n"
+   "\t}",
+   Tab);
+  Tab.TabWidth = 4;
+  Tab.IndentWidth = 8;
+  verifyFormat("class TabWidth4Indent8 {\n"
+   "\t\tvoid f() {\n"
+   "\t\t\t\tsomeFunction(parameter1,\n"
+   "\t\t\t\t\t\t\t parameter2);\n"
+   "\t\t}\n"
+   "};",
+   Tab);
+  Tab.TabWidth = 4;
+  Tab.IndentWidth = 4;
+  verifyFormat("class TabWidth4Indent4 {\n"
+   "\tvoid f() {\n"
+   "\t\tsomeFunction(parameter1,\n"
+   "\t\t\t\t\t parameter2);\n"
+   "\t}\n"
+   "};",
+   Tab);
+  Tab.TabWidth = 8;
+  Tab.IndentWidth = 4;
+  verifyFormat("class TabWidth8Indent4 {\n"
+   "void f() {\n"
+   "\tsomeFunction(parameter1,\n"
+   "\t\t parameter2);\n"
+   "}\n"
+   "};",
+   Tab);
+  Tab.TabWidth = 8;
+  Tab.IndentWidth = 8;
+  EXPECT_EQ("/*\n"
+"\t  a\t\tcomment\n"
+"\t  in multiple lines\n"
+"   */",
+format("   /*\t \t \n"
+   " \t \t a\t\tcomment\t \t\n"
+   " \t \t in multiple lines\t\n"
+   " \t  */",
+   Tab));
+  verifyFormat("{\n"
+   "\t();\n"
+   "\t();\n"
+   "\t();\n"
+   "\t();\n"
+   "\t();\n"
+   

r266321 - clang-format: Last line in incomplete block is indented incorrectly

2016-04-14 Thread Marianne Mailhot-Sarrasin via cfe-commits
Author: mamai
Date: Thu Apr 14 09:56:49 2016
New Revision: 266321

URL: http://llvm.org/viewvc/llvm-project?rev=266321=rev
Log:
clang-format: Last line in incomplete block is indented incorrectly

Indentation of the last line was reset to the initial indentation of the block 
when reaching EOF.

Patch by Maxime Beaulieu

Differential Revision: http://reviews.llvm.org/D19065

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

Modified: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/UnwrappedLineParser.cpp?rev=266321=266320=266321=diff
==
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp (original)
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp Thu Apr 14 09:56:49 2016
@@ -430,6 +430,9 @@ void UnwrappedLineParser::parseBlock(boo
 ++Line->Level;
   parseLevel(/*HasOpeningBrace=*/true);
 
+  if (eof())
+return;
+
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=266321=266320=266321=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Apr 14 09:56:49 2016
@@ -7110,10 +7110,9 @@ TEST_F(FormatTest, BlockCommentsAtEndOfL
 }
 
 TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
-  // FIXME: This is not what we want...
   verifyFormat("{\n"
-   "// a"
-   "// b");
+   "  // a\n"
+   "  // b");
 }
 
 TEST_F(FormatTest, FormatStarDependingOnContext) {


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


Re: [PATCH] D19065: clang-format: Last line in incomplete block is indented incorrectly

2016-04-14 Thread Marianne Mailhot-Sarrasin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266321: clang-format: Last line in incomplete block is 
indented incorrectly (authored by mamai).

Changed prior to commit:
  http://reviews.llvm.org/D19065?vs=53582=53723#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19065

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

Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -430,6 +430,9 @@
 ++Line->Level;
   parseLevel(/*HasOpeningBrace=*/true);
 
+  if (eof())
+return;
+
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -7110,10 +7110,9 @@
 }
 
 TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
-  // FIXME: This is not what we want...
   verifyFormat("{\n"
-   "// a"
-   "// b");
+   "  // a\n"
+   "  // b");
 }
 
 TEST_F(FormatTest, FormatStarDependingOnContext) {


Index: cfe/trunk/lib/Format/UnwrappedLineParser.cpp
===
--- cfe/trunk/lib/Format/UnwrappedLineParser.cpp
+++ cfe/trunk/lib/Format/UnwrappedLineParser.cpp
@@ -430,6 +430,9 @@
 ++Line->Level;
   parseLevel(/*HasOpeningBrace=*/true);
 
+  if (eof())
+return;
+
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;
Index: cfe/trunk/unittests/Format/FormatTest.cpp
===
--- cfe/trunk/unittests/Format/FormatTest.cpp
+++ cfe/trunk/unittests/Format/FormatTest.cpp
@@ -7110,10 +7110,9 @@
 }
 
 TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
-  // FIXME: This is not what we want...
   verifyFormat("{\n"
-   "// a"
-   "// b");
+   "  // a\n"
+   "  // b");
 }
 
 TEST_F(FormatTest, FormatStarDependingOnContext) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266319 - clang-format: Allow include of clangFormat.h in managed context

2016-04-14 Thread Marianne Mailhot-Sarrasin via cfe-commits
Author: mamai
Date: Thu Apr 14 09:47:37 2016
New Revision: 266319

URL: http://llvm.org/viewvc/llvm-project?rev=266319=rev
Log:
clang-format: Allow include of clangFormat.h in managed context

Including VirtualFileSystem.h in the clangFormat.h indirectly includes .
This header is blocked when compiling with /clr.

Patch by Maxime Beaulieu

Differential Revision: http://reviews.llvm.org/D19064

Modified:
cfe/trunk/include/clang/Format/Format.h
cfe/trunk/lib/Format/Format.cpp

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=266319=266318=266319=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Apr 14 09:47:37 2016
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -27,6 +26,10 @@ class Lexer;
 class SourceManager;
 class DiagnosticConsumer;
 
+namespace vfs {
+class FileSystem;
+}
+
 namespace format {
 
 enum class ParseError { Success = 0, Error, Unsuitable };

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=266319=266318=266319=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Apr 14 09:47:37 2016
@@ -22,6 +22,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"


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


Re: [PATCH] D19064: clang-format: Allow include of clangFormat.h in managed context

2016-04-14 Thread Marianne Mailhot-Sarrasin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266319: clang-format: Allow include of clangFormat.h in 
managed context (authored by mamai).

Changed prior to commit:
  http://reviews.llvm.org/D19064?vs=53608=53717#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19064

Files:
  cfe/trunk/include/clang/Format/Format.h
  cfe/trunk/lib/Format/Format.cpp

Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -27,6 +26,10 @@
 class SourceManager;
 class DiagnosticConsumer;
 
+namespace vfs {
+class FileSystem;
+}
+
 namespace format {
 
 enum class ParseError { Success = 0, Error, Unsuitable };
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"


Index: cfe/trunk/include/clang/Format/Format.h
===
--- cfe/trunk/include/clang/Format/Format.h
+++ cfe/trunk/include/clang/Format/Format.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -27,6 +26,10 @@
 class SourceManager;
 class DiagnosticConsumer;
 
+namespace vfs {
+class FileSystem;
+}
+
 namespace format {
 
 enum class ParseError { Success = 0, Error, Unsuitable };
Index: cfe/trunk/lib/Format/Format.cpp
===
--- cfe/trunk/lib/Format/Format.cpp
+++ cfe/trunk/lib/Format/Format.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266320 - clang-format: Implemented tab usage for continuation and indentation

2016-04-14 Thread Marianne Mailhot-Sarrasin via cfe-commits
Author: mamai
Date: Thu Apr 14 09:52:26 2016
New Revision: 266320

URL: http://llvm.org/viewvc/llvm-project?rev=266320=rev
Log:
clang-format: Implemented tab usage for continuation and indentation

Use tabs to fill whitespace at the start of a line.

Patch by Maxime Beaulieu

Differential Revision: http://reviews.llvm.org/D19028

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

Modified: cfe/trunk/include/clang/Format/Format.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Format/Format.h?rev=266320=266319=266320=diff
==
--- cfe/trunk/include/clang/Format/Format.h (original)
+++ cfe/trunk/include/clang/Format/Format.h Thu Apr 14 09:52:26 2016
@@ -603,6 +603,8 @@ struct FormatStyle {
 UT_Never,
 /// Use tabs only for indentation.
 UT_ForIndentation,
+/// Use tabs only for line continuation and indentation.
+UT_ForContinuationAndIndentation,
 /// Use tabs whenever we need to fill whitespace that spans at least from
 /// one tab stop to the next one.
 UT_Always

Modified: cfe/trunk/lib/Format/Format.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/Format.cpp?rev=266320=266319=266320=diff
==
--- cfe/trunk/lib/Format/Format.cpp (original)
+++ cfe/trunk/lib/Format/Format.cpp Thu Apr 14 09:52:26 2016
@@ -69,6 +69,8 @@ template <> struct ScalarEnumerationTrai
 IO.enumCase(Value, "Always", FormatStyle::UT_Always);
 IO.enumCase(Value, "true", FormatStyle::UT_Always);
 IO.enumCase(Value, "ForIndentation", FormatStyle::UT_ForIndentation);
+IO.enumCase(Value, "ForContinuationAndIndentation",
+FormatStyle::UT_ForContinuationAndIndentation);
   }
 };
 

Modified: cfe/trunk/lib/Format/WhitespaceManager.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/WhitespaceManager.cpp?rev=266320=266319=266320=diff
==
--- cfe/trunk/lib/Format/WhitespaceManager.cpp (original)
+++ cfe/trunk/lib/Format/WhitespaceManager.cpp Thu Apr 14 09:52:26 2016
@@ -558,6 +558,14 @@ void WhitespaceManager::appendIndentText
 }
 Text.append(Spaces, ' ');
 break;
+  case FormatStyle::UT_ForContinuationAndIndentation:
+if (WhitespaceStartColumn == 0) {
+  unsigned Tabs = Spaces / Style.TabWidth;
+  Text.append(Tabs, '\t');
+  Spaces -= Tabs * Style.TabWidth;
+}
+Text.append(Spaces, ' ');
+break;
   }
 }
 

Modified: cfe/trunk/unittests/Format/FormatTest.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTest.cpp?rev=266320=266319=266320=diff
==
--- cfe/trunk/unittests/Format/FormatTest.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTest.cpp Thu Apr 14 09:52:26 2016
@@ -8572,6 +8572,230 @@ TEST_F(FormatTest, ConfigurableUseOfTab)
"\t */\n"
"\t int i;\n"
"}"));
+
+  Tab.UseTab = FormatStyle::UT_ForContinuationAndIndentation;
+  Tab.TabWidth = 8;
+  Tab.IndentWidth = 8;
+  EXPECT_EQ("if ( && // q\n"
+"bb) // w\n"
+"\t;",
+format("if ( &&// q\n"
+   "bb)// w\n"
+   ";",
+   Tab));
+  EXPECT_EQ("if (aaa && bbb) // w\n"
+"\t;",
+format("if(aaa&)// w\n"
+   ";",
+   Tab));
+  verifyFormat("class X {\n"
+   "\tvoid f() {\n"
+   "\t\tsomeFunction(parameter1,\n"
+   "\t\t\t parameter2);\n"
+   "\t}\n"
+   "};",
+   Tab);
+  verifyFormat("#define A\\\n"
+   "\tvoid f() {   \\\n"
+   "\t\tsomeFunction(\\\n"
+   "\t\tparameter1,  \\\n"
+   "\t\tparameter2); \\\n"
+   "\t}",
+   Tab);
+  Tab.TabWidth = 4;
+  Tab.IndentWidth = 8;
+  verifyFormat("class TabWidth4Indent8 {\n"
+   "\t\tvoid f() {\n"
+   "\t\t\t\tsomeFunction(parameter1,\n"
+   "\t\t\t\t\t\t\t parameter2);\n"
+   "\t\t}\n"
+   "};",
+   Tab);
+  Tab.TabWidth = 4;
+  Tab.IndentWidth = 4;
+  verifyFormat("class TabWidth4Indent4 {\n"
+   "\tvoid f() {\n"
+   "\t\tsomeFunction(parameter1,\n"
+   "\t\t\t\t\t parameter2);\n"
+   "\t}\n"
+   "};",
+   Tab);
+  Tab.TabWidth = 8;
+  Tab.IndentWidth = 4;
+  verifyFormat("class TabWidth8Indent4 {\n"
+   "void f() {\n"
+   "\tsomeFunction(parameter1,\n"
+

Re: [PATCH] D12761: MPI-Checker patch for Clang Static Analyzer

2016-04-14 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

Hi Anna,

> I am fine with committing it and iterating with smaller updates in tree if it 
> is more convenient for you.


This sounds good! The last thing I'll change before are the improvements you 
pointed out.

> One task that I would like to very strongly encourage is running this on a 
> lot of code.


Good idea. I'll do that.

Thanks a lot for all the time and effort you invested into the review!



Comment at: lib/StaticAnalyzer/Checkers/MPI-Checker/MPIChecker.cpp:87
@@ +86,3 @@
+  }
+  // A wait has no matching nonblocking call.
+  BReporter->reportUnmatchedWait(PreCallEvent, ReqRegion, ErrorNode);

zaks.anna wrote:
> This is done, right?
Yep.


Comment at: test/Analysis/MPIChecker.cpp:99
@@ +98,3 @@
+  MPI_Wait(, MPI_STATUS_IGNORE);
+}
+

zaks.anna wrote:
> This are explaining the path on which the problem occurs; the users will see 
> them as well. There should not be a lot of those, you do not have a lot of 
> conditions. Would it be reasonable to change the tests to incorporate those. 
> Other alternative is to have another tests file that tests the notes in that 
> mode.
> 
> What do you think?
I'm fine with adding the notes to this test file.


Comment at: test/Analysis/MPIChecker.cpp:114
@@ +113,3 @@
+
+void doubleNonblocking4() {
+  int rank = 0;

zaks.anna wrote:
> > I would then simply create a new pair of .cpp and .h files in the test 
> > folder 
> > where I define those functions so that the MPI-Checker tests can use them.
> 
> You do not have to do that. You could just declare the functions and not 
> define them. It will be equivalent to having the definitions in the other TUs.
> 
> 
Like you suggested, I'll simply declare the functions without definition.


http://reviews.llvm.org/D12761



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


Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Clement Courbet via cfe-commits
courbet added a comment.

Example of where this is useful as a drop-in replacement for typedefDecl():

http://reviews.llvm.org/D19117


http://reviews.llvm.org/D19113



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


[PATCH] D19117: [clang-tidy] Update RedundantVoidArgCheck to check for type aliases in addition to typedefs

2016-04-14 Thread Clement Courbet via cfe-commits
courbet created this revision.
courbet added a subscriber: cfe-commits.

RedundantVoidArgCheck will now warn on:
  using f_t = int (*(void))(void);
too.

(Depends on http://reviews.llvm.org/D19113)

http://reviews.llvm.org/D19117

Files:
  clang-tidy/modernize/RedundantVoidArgCheck.cpp
  clang-tidy/modernize/RedundantVoidArgCheck.h
  test/clang-tidy/modernize-redundant-void-arg.cpp

Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -39,6 +39,12 @@
 // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: {{.*}} in typedef
 // CHECK-FIXES: {{^}}typedef int (*returns_fn_void_int_t())();{{$}}
 
+// Should work for type aliases as well as typedef.
+using returns_fn_void_int_t2 = int (*(void))(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: {{.*}} in typedef
+// CHECK-MESSAGES: :[[@LINE-2]]:46: warning: {{.*}} in typedef
+// CHECK-FIXES: {{^}}using returns_fn_void_int_t2 = int (*())();{{$}}
+
 int (*returns_fn_void_int(void))(void) {
 // CHECK-MESSAGES: :[[@LINE-1]]:27: warning: {{.*}} in function definition
 // CHECK-MESSAGES: :[[@LINE-2]]:34: warning: {{.*}} in function definition
Index: clang-tidy/modernize/RedundantVoidArgCheck.h
===
--- clang-tidy/modernize/RedundantVoidArgCheck.h
+++ clang-tidy/modernize/RedundantVoidArgCheck.h
@@ -42,8 +42,9 @@
   void processFunctionDecl(const ast_matchers::MatchFinder::MatchResult 
,
const FunctionDecl *Function);
 
-  void processTypedefDecl(const ast_matchers::MatchFinder::MatchResult ,
-  const TypedefDecl *Typedef);
+  void
+  processTypedefNameDecl(const ast_matchers::MatchFinder::MatchResult ,
+ const TypedefNameDecl *Typedef);
 
   void processFieldDecl(const ast_matchers::MatchFinder::MatchResult ,
 const FieldDecl *Member);
Index: clang-tidy/modernize/RedundantVoidArgCheck.cpp
===
--- clang-tidy/modernize/RedundantVoidArgCheck.cpp
+++ clang-tidy/modernize/RedundantVoidArgCheck.cpp
@@ -50,7 +50,7 @@
   unless(isExternC()))
  .bind(FunctionId),
  this);
-  Finder->addMatcher(typedefDecl().bind(TypedefId), this);
+  Finder->addMatcher(typedefNameDecl().bind(TypedefId), this);
   auto ParenFunctionType = parenType(innerType(functionType()));
   auto PointerToFunctionType = pointee(ParenFunctionType);
   auto FunctionOrMemberPointer =
@@ -80,8 +80,9 @@
   const BoundNodes  = Result.Nodes;
   if (const auto *Function = Nodes.getNodeAs(FunctionId)) {
 processFunctionDecl(Result, Function);
-  } else if (const auto *Typedef = Nodes.getNodeAs(TypedefId)) {
-processTypedefDecl(Result, Typedef);
+  } else if (const auto *TypedefName =
+ Nodes.getNodeAs(TypedefId)) {
+processTypedefNameDecl(Result, TypedefName);
   } else if (const auto *Member = Nodes.getNodeAs(FieldId)) {
 processFieldDecl(Result, Member);
   } else if (const auto *Var = Nodes.getNodeAs(VarId)) {
@@ -105,8 +106,8 @@
   if (Function->isThisDeclarationADefinition()) {
 const Stmt *Body = Function->getBody();
 SourceLocation Start = Function->getLocStart();
-SourceLocation End = Body ? Body->getLocStart().getLocWithOffset(-1) :
-Function->getLocEnd();
+SourceLocation End =
+Body ? Body->getLocStart().getLocWithOffset(-1) : 
Function->getLocEnd();
 removeVoidArgumentTokens(Result, SourceRange(Start, End),
  "function definition");
   } else {
@@ -179,10 +180,11 @@
   diag(VoidLoc, Diagnostic) << FixItHint::CreateRemoval(VoidRange);
 }
 
-void RedundantVoidArgCheck::processTypedefDecl(
-const MatchFinder::MatchResult , const TypedefDecl *Typedef) {
-  if (protoTypeHasNoParms(Typedef->getUnderlyingType())) {
-removeVoidArgumentTokens(Result, Typedef->getSourceRange(), "typedef");
+void RedundantVoidArgCheck::processTypedefNameDecl(
+const MatchFinder::MatchResult ,
+const TypedefNameDecl *TypedefName) {
+  if (protoTypeHasNoParms(TypedefName->getUnderlyingType())) {
+removeVoidArgumentTokens(Result, TypedefName->getSourceRange(), "typedef");
   }
 }
 


Index: test/clang-tidy/modernize-redundant-void-arg.cpp
===
--- test/clang-tidy/modernize-redundant-void-arg.cpp
+++ test/clang-tidy/modernize-redundant-void-arg.cpp
@@ -39,6 +39,12 @@
 // CHECK-MESSAGES: :[[@LINE-2]]:44: warning: {{.*}} in typedef
 // CHECK-FIXES: {{^}}typedef int (*returns_fn_void_int_t())();{{$}}
 
+// Should work for type aliases as well as typedef.
+using returns_fn_void_int_t2 = int (*(void))(void);
+// CHECK-MESSAGES: :[[@LINE-1]]:39: warning: {{.*}} in typedef
+// 

Re: r266276 - Do not use llvm:getGlobalContext() in unittests

2016-04-14 Thread Mehdi Amini via cfe-commits

> On Apr 14, 2016, at 4:38 AM, Rafael Espíndola  
> wrote:
> 
> On 14 April 2016 at 01:34, Mehdi Amini via cfe-commits
>  wrote:
>> Author: mehdi_amini
>> Date: Thu Apr 14 00:34:32 2016
>> New Revision: 266276
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=266276=rev
>> Log:
>> Do not use llvm:getGlobalContext() in unittests
>> 
>> Currently trying to nuke this API from LLVM.
> 
> Thanks!

That is http://reviews.llvm.org/D19094 if you're interested :)

-- 
Mehdi

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


Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Clement Courbet via cfe-commits
courbet added a comment.

In http://reviews.llvm.org/D19113#401095, @aaron.ballman wrote:

> If we're going to add this (which I think is a good idea), perhaps we should 
> also add `typeAliasDecl()` at the same time?


Makes sense, done.


http://reviews.llvm.org/D19113



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


Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Clement Courbet via cfe-commits
courbet updated the summary for this revision.
courbet updated this revision to Diff 53724.
courbet marked an inline comment as done.
courbet added a comment.

Added typeAliasDecl. More tests.


http://reviews.llvm.org/D19113

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1101,6 +1101,16 @@
   typedefDecl(hasType(asString("foo")), hasName("bar";
 }
 
+TEST(HasType, MatchesTypedefNameDecl) {
+  EXPECT_TRUE(matches("using X = int;", typedefNameDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("using T = const int;",
+  typedefNameDecl(hasType(asString("const int");
+  EXPECT_TRUE(notMatches("using T = const int;",
+ typedefNameDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("using foo = int; using bar = foo;",
+  typedefNameDecl(hasType(asString("foo")), hasName("bar";
+}
+
 TEST(HasTypeLoc, MatchesDeclaratorDecls) {
   EXPECT_TRUE(matches("int x;",
   varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
@@ -5404,9 +5414,25 @@
   .bind("data")));
 }
 
-TEST(TypeDefDeclMatcher, Match) {
+TEST(TypedefDeclMatcher, Match) {
   EXPECT_TRUE(matches("typedef int typedefDeclTest;",
   typedefDecl(hasName("typedefDeclTest";
+  EXPECT_FALSE(matches("using typedefDeclTest2 = int;",
+   typedefDecl(hasName("typedefDeclTest2";
+}
+
+TEST(TypeAliasDeclMatcher, Match) {
+  EXPECT_TRUE(matches("using typeAliasTest2 = int;",
+  typeAliasDecl(hasName("typeAliasTest2";
+  EXPECT_FALSE(matches("typedef int typeAliasTest;",
+   typeAliasDecl(hasName("typeAliasTest";
+}
+
+TEST(TypedefNameDeclMatcher, Match) {
+  EXPECT_TRUE(matches("typedef int typedefNameDeclTest1;",
+  typedefNameDecl(hasName("typedefNameDeclTest1";
+  EXPECT_TRUE(matches("using typedefNameDeclTest2 = int;",
+  typedefNameDecl(hasName("typedefNameDeclTest2";
 }
 
 TEST(IsInlineMatcher, IsInline) {
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -388,7 +388,9 @@
   REGISTER_MATCHER(translationUnitDecl);
   REGISTER_MATCHER(type);
   REGISTER_MATCHER(typedefDecl);
+  REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
+  REGISTER_MATCHER(typeAliasDecl);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
   REGISTER_MATCHER(unaryOperator);
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -96,12 +96,13 @@
 
 /// \brief Unifies obtaining the underlying type of a regular node through
 /// `getType` and a TypedefNameDecl node through `getUnderlyingType`.
-template 
-inline QualType getUnderlyingType(const NodeType ) {
+inline QualType getUnderlyingType(const Expr ) { return Node.getType(); }
+
+inline QualType getUnderlyingType(const ValueDecl ) {
   return Node.getType();
 }
 
-template <> inline QualType getUnderlyingType(const TypedefDecl ) {
+inline QualType getUnderlyingType(const TypedefNameDecl ) {
   return Node.getUnderlyingType();
 }
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -163,11 +163,35 @@
 /// Given
 /// \code
 ///   typedef int X;
+//using Y = int;
 /// \endcode
 /// typedefDecl()
-///   matches "typedef int X"
+///   matches "typedef int X", but not "using Y = int"
 const internal::VariadicDynCastAllOfMatcher typedefDecl;
 
+/// \brief Matches typedef name declarations.
+///
+/// Given
+/// \code
+///   typedef int X;
+//using Y = int;
+/// \endcode
+/// typedefNameDecl()
+///   matches "typedef int X" and "using Y = int"
+const internal::VariadicDynCastAllOfMatcher
+typedefNameDecl;
+
+/// \brief Matches type alias declarations.
+///
+/// Given
+/// \code
+///   typedef int X;
+//using Y = int;
+/// \endcode
+/// typeAliasDecl()
+///   matches "using Y = int", but not "typedef int X"
+const internal::VariadicDynCastAllOfMatcher typeAliasDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
@@ -2451,9 +2475,9 @@
 ///  typedef int U;
 /// \endcode
 

Re: [PATCH] D18998: [CodeGen] Explicitly widen non-power-of-2 vector HFA base types.

2016-04-14 Thread Ulrich Weigand via cfe-commits
uweigand added a comment.

Makes sense to me.


http://reviews.llvm.org/D18998



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


Re: [PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-14 Thread Taewook Oh via cfe-commits
Joerg, 

Thank you for your comments. I submitted a new patch
(http://reviews.llvm.org/D19062) with a new test that checks attributes
but not types. I think this should cover both cases. What do you think?

Thanks,
Taewook

On 4/14/16, 2:46 AM, "Joerg Sonnenberger"  wrote:

>On Wed, Apr 13, 2016 at 03:02:09PM +, Taewook Oh wrote:
>> Sure, I'll take a look.
>> Thanks!
>
>Please provide two versions of the test, one hard-coded for an
>architecture with signed char, one hard-coded for an architecture with
>unsigned char. That should cover the difference.
>
>Joerg

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


Re: r266108 - clang-cl: Remove -isystem, add -imsvc.

2016-04-14 Thread Nico Weber via cfe-commits
On Thu, Apr 14, 2016 at 10:32 AM, Ismail Donmez  wrote:

> On Thu, Apr 14, 2016 at 2:09 PM, Nico Weber  wrote:
> > It's supposed to match the
> >
> > "-internal-isystem"
> >
> "/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0/include"
> > "-internal-isystem" "myincludedir"
> >
> > bit in your output. Looks like it's "lib64" instead of "lib" on your
> system.
> > Does changing
> >
> > // SLASH_imsvc: "-internal-isystem"
> > "{{[^"]*}}lib{{/|}}clang{{[^"]*}}include"
> >
> > to
> >
> > // SLASH_imsvc: "-internal-isystem"
> > "{{[^"]*}}lib{{(64)?/|}}clang{{[^"]*}}include"
> >
> > help?
>
> Yes it does, thanks.
>

Want to land that change? :-)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19069: clang-format: Fixed various brace wrapping and block merging bugs

2016-04-14 Thread Maxime Beaulieu via cfe-commits
mxbOctasic added inline comments.


Comment at: lib/Format/UnwrappedLineParser.cpp:789-790
@@ -773,4 +788,4 @@
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterObjCDeclaration)
-  addUnwrappedLine();
+CompoundStatementIndenter Indenter(
+this, Style, Line->Level, 
Style.BraceWrapping.AfterObjCDeclaration);
 parseBlock(/*MustBeDeclaration=*/false);

mxbOctasic wrote:
> We may not want this.
Type is set to TT_CompoundStatementLBrace by the CompoundStatementIndenter.

Should it be TT_ObjCBlockLBrace instead?

Should the braces be affected by BraceWrapping.IndentBraces?


Comment at: lib/Format/UnwrappedLineParser.cpp:1388-1390
@@ -1372,3 +1387,5 @@
 parseBlock(/*MustBeDeclaration=*/false);
-if (Style.BraceWrapping.BeforeElse)
+if (Style.BraceWrapping.BeforeElse ||
+Style.BraceWrapping.AfterControlStatement &&
+Style.BraceWrapping.IndentBraces)
   addUnwrappedLine();

djasper wrote:
> mxbOctasic wrote:
> > IndentBraces can only work properly when both AfterControlStatement and 
> > BeforeElse are active.
> > The opening brace can only be indented when it is wrapped on its own line, 
> > and the else keyword has to be on another line too.
> > We have to decide which option has precedence over the others.
> > Right now I'm overriding BeforeElse when the opening brace is wrapped.
> Maybe we should put logic like this into expandPresets (possibly renaming it)?
Something like "applyBraceWrappingFlags"?
The preset styles do not set incompatible flags (yet?).
Do we want to perform fix-ups like this only on custom styles?

I will update the \brief in Format.h to mention that some flags can be 
overridden in certain edge cases.


Comment at: unittests/Format/FormatTest.cpp:474
@@ +473,3 @@
+  EXPECT_EQ("if (true) { f(); }\nelse { f(); }",
+format("if (true)\n"
+   "{\n"

djasper wrote:
> I'd remove all the line breaks and "\n"s here.
Should we consider the BeforeElse flag when merging this statement?




http://reviews.llvm.org/D19069



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


Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-04-14 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

I will look into it tomorrow.


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-04-14 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

Might the problem be in the va_list checker?
Obviously the va_list variable is identified as an ElementRegion what seems not 
to be correct. 
Only if the passed region is an ElementRegion indices get appended.


http://reviews.llvm.org/D16044



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


Re: r266108 - clang-cl: Remove -isystem, add -imsvc.

2016-04-14 Thread Ismail Donmez via cfe-commits
On Thu, Apr 14, 2016 at 2:09 PM, Nico Weber  wrote:
> It's supposed to match the
>
> "-internal-isystem"
> "/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0/include"
> "-internal-isystem" "myincludedir"
>
> bit in your output. Looks like it's "lib64" instead of "lib" on your system.
> Does changing
>
> // SLASH_imsvc: "-internal-isystem"
> "{{[^"]*}}lib{{/|}}clang{{[^"]*}}include"
>
> to
>
> // SLASH_imsvc: "-internal-isystem"
> "{{[^"]*}}lib{{(64)?/|}}clang{{[^"]*}}include"
>
> help?

Yes it does, thanks.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-04-14 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

> Looking at the code it seems that this data structure:

> typedef SmallVector RegionVector;

> tricks the function into rating the MemRegion as an ElementRegion.


That's not the problem. I'm using the same data structure in the MPI-Checker 
patch.


http://reviews.llvm.org/D16044



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


Re: [PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.

If we're going to add this (which I think is a good idea), perhaps we should 
also add `typeAliasDecl()` at the same time?



Comment at: unittests/ASTMatchers/ASTMatchersTest.cpp:5417
@@ -5406,3 +5416,3 @@
 
-TEST(TypeDefDeclMatcher, Match) {
+TEST(TypedefDeclMatcher, Match) {
   EXPECT_TRUE(matches("typedef int typedefDeclTest;",

Can you add a test that ensures the typedef decl matcher does not match a type 
alias (and vice versa)?


http://reviews.llvm.org/D19113



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


Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-04-14 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

Looking at the code it seems that this data structure:
`typedef SmallVector RegionVector;`
tricks the function into rating the MemRegion as an ElementRegion.


http://reviews.llvm.org/D16044



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


[PATCH] D19113: [ASTMatchers] Upgrading typedef matching to c++11

2016-04-14 Thread Clement Courbet via cfe-commits
courbet created this revision.
courbet added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

- hasType() should be able to match the types of TypedefAliasDecl in addition 
to TypedefDecl, so made it work on TypedefNameDecl.
- new typedefNameDecl() matcher, which should be mostly used in place of 
typedefDecl (most people will want to match any typedef names, and not just 
those introduces through pre-c++11 typedefs).

http://reviews.llvm.org/D19113

Files:
  include/clang/ASTMatchers/ASTMatchers.h
  include/clang/ASTMatchers/ASTMatchersInternal.h
  lib/ASTMatchers/Dynamic/Registry.cpp
  unittests/ASTMatchers/ASTMatchersTest.cpp

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -1101,6 +1101,16 @@
   typedefDecl(hasType(asString("foo")), hasName("bar";
 }
 
+TEST(HasType, MatchesTypedefNameDecl) {
+  EXPECT_TRUE(matches("using X = int;", typedefNameDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("using T = const int;",
+  typedefNameDecl(hasType(asString("const int");
+  EXPECT_TRUE(notMatches("using T = const int;",
+ typedefNameDecl(hasType(asString("int");
+  EXPECT_TRUE(matches("using foo = int; using bar = foo;",
+  typedefNameDecl(hasType(asString("foo")), hasName("bar";
+}
+
 TEST(HasTypeLoc, MatchesDeclaratorDecls) {
   EXPECT_TRUE(matches("int x;",
   varDecl(hasName("x"), hasTypeLoc(loc(asString("int"));
@@ -5404,11 +5414,18 @@
   .bind("data")));
 }
 
-TEST(TypeDefDeclMatcher, Match) {
+TEST(TypedefDeclMatcher, Match) {
   EXPECT_TRUE(matches("typedef int typedefDeclTest;",
   typedefDecl(hasName("typedefDeclTest";
 }
 
+TEST(TypedefNameDeclMatcher, Match) {
+  EXPECT_TRUE(matches("typedef int typedefNameDeclTest1;",
+  typedefNameDecl(hasName("typedefNameDeclTest1";
+  EXPECT_TRUE(matches("using typedefNameDeclTest2 = int;",
+  typedefNameDecl(hasName("typedefNameDeclTest2";
+}
+
 TEST(IsInlineMatcher, IsInline) {
   EXPECT_TRUE(matches("void g(); inline void f();",
   functionDecl(isInline(), hasName("f";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -388,6 +388,7 @@
   REGISTER_MATCHER(translationUnitDecl);
   REGISTER_MATCHER(type);
   REGISTER_MATCHER(typedefDecl);
+  REGISTER_MATCHER(typedefNameDecl);
   REGISTER_MATCHER(typedefType);
   REGISTER_MATCHER(typeLoc);
   REGISTER_MATCHER(unaryExprOrTypeTraitExpr);
Index: include/clang/ASTMatchers/ASTMatchersInternal.h
===
--- include/clang/ASTMatchers/ASTMatchersInternal.h
+++ include/clang/ASTMatchers/ASTMatchersInternal.h
@@ -96,12 +96,15 @@
 
 /// \brief Unifies obtaining the underlying type of a regular node through
 /// `getType` and a TypedefNameDecl node through `getUnderlyingType`.
-template 
-inline QualType getUnderlyingType(const NodeType ) {
+inline QualType getUnderlyingType(const Expr ) {
   return Node.getType();
 }
 
-template <> inline QualType getUnderlyingType(const TypedefDecl ) {
+inline QualType getUnderlyingType(const ValueDecl ) {
+  return Node.getType();
+}
+
+inline QualType getUnderlyingType(const TypedefNameDecl ) {
   return Node.getUnderlyingType();
 }
 
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -163,11 +163,23 @@
 /// Given
 /// \code
 ///   typedef int X;
+//using Y = int;
 /// \endcode
 /// typedefDecl()
-///   matches "typedef int X"
+///   matches "typedef int X", but not "using Y = int"
 const internal::VariadicDynCastAllOfMatcher typedefDecl;
 
+/// \brief Matches typedef name declarations.
+///
+/// Given
+/// \code
+///   typedef int X;
+//using Y = int;
+/// \endcode
+/// typedefNameDecl()
+///   matches "typedef int X" and "using Y = int"
+const internal::VariadicDynCastAllOfMatcher typedefNameDecl;
+
 /// \brief Matches AST nodes that were expanded within the main-file.
 ///
 /// Example matches X but not Y
@@ -2451,9 +2463,9 @@
 ///  typedef int U;
 /// \endcode
 AST_POLYMORPHIC_MATCHER_P_OVERLOAD(
-hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, TypedefDecl, ValueDecl),
+hasType, AST_POLYMORPHIC_SUPPORTED_TYPES(Expr, TypedefNameDecl, ValueDecl),
 internal::Matcher, InnerMatcher, 0) {
-  return InnerMatcher.matches(internal::getUnderlyingType(Node),
+  return InnerMatcher.matches(internal::getUnderlyingType(Node),
   Finder, Builder);

Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-04-14 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

Sure, the test case of http://reviews.llvm.org/D15227 is faiing because of this.

In test/Analysis/valist-unterminated.c, line 10
Initialized va_list 'va[0]' is leaked
is emitted instead of
Initialized va_list 'va' is leaked


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-04-14 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

> I tested this patch using http://reviews.llvm.org/D15227

> Unfortunately for non-array variables the getDescriptiveName returned 
> var_name[0]. Note the spurious [0] part.

> Could you look into that?


Could you provide a code example where this effect turns up?


http://reviews.llvm.org/D16044



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


Re: [PATCH] D16044: getDescriptiveName() for MemRegion

2016-04-14 Thread Gábor Horváth via cfe-commits
xazax.hun added a comment.

I tested this patch using http://reviews.llvm.org/D15227

Unfortunately for non-array variables the getDescriptiveName returned 
var_name[0]. Note the spurious [0] part.

Could you look into that?


http://reviews.llvm.org/D16044



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


Re: [PATCH] D18821: Add modernize-bool-to-integer-conversion

2016-04-14 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

http://reviews.llvm.org/D19105
Here is a diff containing fixes for clang. What I see is that it would be nice 
to detect bitfields of 1 bit and treet it as bool, so it won't warn it such 
cases.


http://reviews.llvm.org/D18821



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


[PATCH] D19108: [Sema] Fixed assert failure in template code analyzer

2016-04-14 Thread Eugene via cfe-commits
kevgs created this revision.
kevgs added reviewers: rsmith, dblaikie.
kevgs added a subscriber: cfe-commits.

Fix for this bug https://llvm.org/bugs/show_bug.cgi?id=27312

http://reviews.llvm.org/D19108

Files:
  lib/Sema/SemaAccess.cpp
  test/SemaTemplate/crash-bug-27258.cpp

Index: test/SemaTemplate/crash-bug-27258.cpp
===
--- /dev/null
+++ test/SemaTemplate/crash-bug-27258.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+template 
+struct AA {
+  template 
+  struct B {};
+};
+
+class C {
+  int i; // expected-note{{implicitly declared private here}}
+  template 
+  template 
+  friend struct AA::B;
+};
+
+struct A {
+  template 
+  struct B {
+void f() {
+  C c;
+  c.i; // expected-error{{'i' is a private member of 'C'}} 
expected-warning{{expression result unused}}
+}
+  };
+};
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -475,8 +475,8 @@
 
 // If the class's context can't instantiate to the friend's
 // context, it can't be a dependent match.
-if (!MightInstantiateTo(S, CTD->getDeclContext(),
-Friend->getDeclContext()))
+if (Friend->getDeclContext()->isDependentContext() ||
+!MightInstantiateTo(S, CTD->getDeclContext(), 
Friend->getDeclContext()))
   continue;
 
 // Otherwise, it's a dependent match.


Index: test/SemaTemplate/crash-bug-27258.cpp
===
--- /dev/null
+++ test/SemaTemplate/crash-bug-27258.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -fsyntax-only %s -verify
+template 
+struct AA {
+  template 
+  struct B {};
+};
+
+class C {
+  int i; // expected-note{{implicitly declared private here}}
+  template 
+  template 
+  friend struct AA::B;
+};
+
+struct A {
+  template 
+  struct B {
+void f() {
+  C c;
+  c.i; // expected-error{{'i' is a private member of 'C'}} expected-warning{{expression result unused}}
+}
+  };
+};
Index: lib/Sema/SemaAccess.cpp
===
--- lib/Sema/SemaAccess.cpp
+++ lib/Sema/SemaAccess.cpp
@@ -475,8 +475,8 @@
 
 // If the class's context can't instantiate to the friend's
 // context, it can't be a dependent match.
-if (!MightInstantiateTo(S, CTD->getDeclContext(),
-Friend->getDeclContext()))
+if (Friend->getDeclContext()->isDependentContext() ||
+!MightInstantiateTo(S, CTD->getDeclContext(), Friend->getDeclContext()))
   continue;
 
 // Otherwise, it's a dependent match.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-14 Thread Vladimir Yakovlev via cfe-commits
vbyakovl updated this revision to Diff 53658.
vbyakovl added a comment.

Sema/SemaType.cpp: Deleted POD type and default constructor  checkings.
test/SemaCXX/c99-variable-length-array-cxx11.cpp: Edited dianocnics.


http://reviews.llvm.org/D18823

Files:
  llvm/tools/clang/lib/CodeGen/CGClass.cpp
  llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
  llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
  llvm/tools/clang/lib/Sema/SemaType.cpp
  llvm/tools/clang/test/CodeGenCXX/vla-consruct.cpp
  llvm/tools/clang/test/SemaCXX/c99-variable-length-array-cxx11.cpp
  llvm/tools/clang/test/SemaCXX/c99-variable-length-array.cpp
  llvm/tools/clang/test/SemaCXX/vla-consruct.cpp

Index: llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
===
--- llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
+++ llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
@@ -472,8 +472,8 @@
 }
   }
   
-  if (const ConstantArrayType *arrayType 
-= getContext().getAsConstantArrayType(E->getType())) {
+  if (const ArrayType *arrayType
+= getContext().getAsArrayType(E->getType())) {
 EmitCXXAggrConstructorCall(CD, arrayType, Dest.getAddress(), E);
   } else {
 CXXCtorType Type = Ctor_Complete;
Index: llvm/tools/clang/lib/CodeGen/CGClass.cpp
===
--- llvm/tools/clang/lib/CodeGen/CGClass.cpp
+++ llvm/tools/clang/lib/CodeGen/CGClass.cpp
@@ -1915,7 +1915,7 @@
 /// \param zeroInitialize true if each element should be
 ///   zero-initialized before it is constructed
 void CodeGenFunction::EmitCXXAggrConstructorCall(
-const CXXConstructorDecl *ctor, const ConstantArrayType *arrayType,
+const CXXConstructorDecl *ctor, const ArrayType *arrayType,
 Address arrayBegin, const CXXConstructExpr *E, bool zeroInitialize) {
   QualType elementType;
   llvm::Value *numElements =
Index: llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
===
--- llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
+++ llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
@@ -1872,7 +1872,7 @@
   const CXXConstructExpr *E);
 
   void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
-  const ConstantArrayType *ArrayTy,
+  const ArrayType *ArrayTy,
   Address ArrayPtr,
   const CXXConstructExpr *E,
   bool ZeroInitialization = false);
Index: llvm/tools/clang/lib/Sema/SemaType.cpp
===
--- llvm/tools/clang/lib/Sema/SemaType.cpp
+++ llvm/tools/clang/lib/Sema/SemaType.cpp
@@ -2156,15 +2156,8 @@
   // If this is not C99, extwarn about VLA's and C99 array size modifiers.
   if (!getLangOpts().C99) {
 if (T->isVariableArrayType()) {
-  // Prohibit the use of non-POD types in VLAs.
-  QualType BaseT = Context.getBaseElementType(T);
-  if (!T->isDependentType() && isCompleteType(Loc, BaseT) &&
-  !BaseT.isPODType(Context) && !BaseT->isObjCLifetimeType()) {
-Diag(Loc, diag::err_vla_non_pod) << BaseT;
-return QualType();
-  }
   // Prohibit the use of VLAs during template argument deduction.
-  else if (isSFINAEContext()) {
+  if (isSFINAEContext()) {
 Diag(Loc, diag::err_vla_in_sfinae);
 return QualType();
   }
Index: llvm/tools/clang/test/SemaCXX/vla-consruct.cpp
===
--- llvm/tools/clang/test/SemaCXX/vla-consruct.cpp
+++ llvm/tools/clang/test/SemaCXX/vla-consruct.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -O0 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -pedantic-errors -DPE -O0 -verify %s
+
+# ifndef PE
+// expected-no-diagnostics
+# endif
+
+extern "C" int printf(const char*, ...);
+
+static int N;
+struct S {
+  S() __attribute__ ((nothrow))  { printf("%d: S()\n", ++N); }
+  ~S()  __attribute__ ((nothrow))  { printf("%d: ~S()\n", N--); }
+  int n[17];
+};
+
+void print(int n, int a, int b, int c, int d) {
+  printf("n=%d\n,sizeof(S)=%d\nsizeof(array_t[0][0])=%d\nsizeof(array_t[0])=%d\nsizeof(array_t)=%d\n",
+ n, a, b, c, d);
+  if (n == 2) throw(n);
+}
+
+void test(int n) {
+  S array_t[n][n+1];
+# ifdef PE
+   // expected-error@-2 {{variable length arrays are a C99 feature}}
+   // expected-error@-3 {{variable length arrays are a C99 feature}}
+# endif
+  int sizeof_S = sizeof(S);
+  int sizeof_array_t_0_0 = sizeof(array_t[0][0]);
+  int sizeof_array_t_0 = sizeof(array_t[0]);
+  int sizeof_array_t = sizeof(array_t);
+  print(n, sizeof_S, sizeof_array_t_0_0, sizeof_array_t_0, sizeof_array_t);
+}
+
+int main()
+{
+  try {
+test(2);
+  } catch(int e) {
+printf("expeption %d\n", e);
+  }
+  

r266292 - [ASTImporter] Implement some expression-related AST node import.

2016-04-14 Thread Artem Dergachev via cfe-commits
Author: dergachev
Date: Thu Apr 14 06:51:27 2016
New Revision: 266292

URL: http://llvm.org/viewvc/llvm-project?rev=266292=rev
Log:
[ASTImporter] Implement some expression-related AST node import.

Introduce ASTImporter unit test framework.

Fix a memory leak introduced in cf8ccff5: an array is allocated
in ImportArray and never freed.

Support new node kinds:

- GCCAsmStmt

- AddrLabelExpr
- AtomicExpr
- CompoundLiteralExpr
- CXXBoolLiteralExpr
- CXXNullPtrLiteralExpr
- CXXThisExpr
- DesignatedInitExpr
- GNUNullExpr
- ImplicitValueInitExpr
- InitListExpr
- OpaqueValueExpr
- PredefinedExpr
- ParenListExpr
- StmtExpr
- VAArgExpr

- BinaryConditionalOperator
- ConditionalOperator

- FloatingLiteral
- StringLiteral

- InjectedClassNameType
- TemplateTypeParmType

- LabelDecl

Patch by Aleksei Sidorin!

Differential Revision: http://reviews.llvm.org/D14286

Added:
cfe/trunk/unittests/AST/ASTImporterTest.cpp
Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/unittests/AST/CMakeLists.txt

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=266292=266291=266292=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Thu Apr 14 06:51:27 2016
@@ -4278,6 +4278,8 @@ class InjectedClassNameType : public Typ
   friend class ASTReader; // FIXME: ASTContext::getInjectedClassNameType is not
   // currently suitable for AST reading, too much
   // interdependencies.
+  friend class ASTNodeImporter;
+
   InjectedClassNameType(CXXRecordDecl *D, QualType TST)
 : Type(InjectedClassName, QualType(), /*Dependent=*/true,
/*InstantiationDependent=*/true,

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=266292=266291=266292=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Thu Apr 14 06:51:27 2016
@@ -29,7 +29,7 @@ namespace clang {
   public DeclVisitor,
   public StmtVisitor {
 ASTImporter 
-
+
   public:
 explicit ASTNodeImporter(ASTImporter ) : Importer(Importer) { }
 
@@ -64,11 +64,12 @@ namespace clang {
 QualType VisitDecltypeType(const DecltypeType *T);
 QualType VisitUnaryTransformType(const UnaryTransformType *T);
 QualType VisitAutoType(const AutoType *T);
+QualType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentDecltypeType
 QualType VisitRecordType(const RecordType *T);
 QualType VisitEnumType(const EnumType *T);
 QualType VisitAttributedType(const AttributedType *T);
-// FIXME: TemplateTypeParmType
+QualType VisitTemplateTypeParmType(const TemplateTypeParmType *T);
 // FIXME: SubstTemplateTypeParmType
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType 
*T);
 QualType VisitElaboratedType(const ElaboratedType *T);
@@ -86,6 +87,10 @@ namespace clang {
 void ImportDeclarationNameLoc(const DeclarationNameInfo ,
   DeclarationNameInfo& To);
 void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
+
+typedef DesignatedInitExpr::Designator Designator;
+Designator ImportDesignator(const Designator );
+
 
 /// \brief What we should import from the definition.
 enum ImportDefinitionKind { 
@@ -136,6 +141,7 @@ namespace clang {
 Decl *VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
 Decl *VisitTypedefDecl(TypedefDecl *D);
 Decl *VisitTypeAliasDecl(TypeAliasDecl *D);
+Decl *VisitLabelDecl(LabelDecl *D);
 Decl *VisitEnumDecl(EnumDecl *D);
 Decl *VisitRecordDecl(RecordDecl *D);
 Decl *VisitEnumConstantDecl(EnumConstantDecl *D);
@@ -175,6 +181,7 @@ namespace clang {
 DeclGroupRef ImportDeclGroup(DeclGroupRef DG);
 
 Stmt *VisitStmt(Stmt *S);
+Stmt *VisitGCCAsmStmt(GCCAsmStmt *S);
 Stmt *VisitDeclStmt(DeclStmt *S);
 Stmt *VisitNullStmt(NullStmt *S);
 Stmt *VisitCompoundStmt(CompoundStmt *S);
@@ -192,7 +199,6 @@ namespace clang {
 Stmt *VisitContinueStmt(ContinueStmt *S);
 Stmt *VisitBreakStmt(BreakStmt *S);
 Stmt *VisitReturnStmt(ReturnStmt *S);
-// FIXME: GCCAsmStmt
 // FIXME: MSAsmStmt
 // FIXME: SEHExceptStmt
 // FIXME: SEHFinallyStmt
@@ -213,13 +219,29 @@ namespace clang {
 
 // Importing expressions
 Expr *VisitExpr(Expr *E);
+Expr *VisitVAArgExpr(VAArgExpr *E);
+Expr *VisitGNUNullExpr(GNUNullExpr *E);
+Expr *VisitPredefinedExpr(PredefinedExpr *E);
 Expr *VisitDeclRefExpr(DeclRefExpr *E);
+Expr 

r266293 - [analyzer] Make it possible to query the function name from a CallDescription.

2016-04-14 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Thu Apr 14 06:56:28 2016
New Revision: 266293

URL: http://llvm.org/viewvc/llvm-project?rev=266293=rev
Log:
[analyzer] Make it possible to query the function name from a CallDescription.

Modified:
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h?rev=266293=266292=266293=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h Thu 
Apr 14 06:56:28 2016
@@ -68,6 +68,9 @@ public:
   /// name regardless the number of arguments.
   CallDescription(StringRef FuncName, unsigned RequiredArgs = NoArgRequirement)
   : II(nullptr), FuncName(FuncName), RequiredArgs(RequiredArgs) {}
+
+  /// \brief Get the name of the function that this object matches.
+  StringRef getFunctionName() const { return FuncName; }
 };
 
 template


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


Re: [PATCH] D14286: ASTImporter: expressions, pt.1

2016-04-14 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266292: [ASTImporter] Implement some expression-related AST 
node import. (authored by dergachev).

Changed prior to commit:
  http://reviews.llvm.org/D14286?vs=53389=53692#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D14286

Files:
  cfe/trunk/include/clang/AST/Type.h
  cfe/trunk/lib/AST/ASTImporter.cpp
  cfe/trunk/unittests/AST/ASTImporterTest.cpp
  cfe/trunk/unittests/AST/CMakeLists.txt

Index: cfe/trunk/include/clang/AST/Type.h
===
--- cfe/trunk/include/clang/AST/Type.h
+++ cfe/trunk/include/clang/AST/Type.h
@@ -4278,6 +4278,8 @@
   friend class ASTReader; // FIXME: ASTContext::getInjectedClassNameType is not
   // currently suitable for AST reading, too much
   // interdependencies.
+  friend class ASTNodeImporter;
+
   InjectedClassNameType(CXXRecordDecl *D, QualType TST)
 : Type(InjectedClassName, QualType(), /*Dependent=*/true,
/*InstantiationDependent=*/true,
Index: cfe/trunk/lib/AST/ASTImporter.cpp
===
--- cfe/trunk/lib/AST/ASTImporter.cpp
+++ cfe/trunk/lib/AST/ASTImporter.cpp
@@ -29,7 +29,7 @@
   public DeclVisitor,
   public StmtVisitor {
 ASTImporter 
-
+
   public:
 explicit ASTNodeImporter(ASTImporter ) : Importer(Importer) { }
 
@@ -64,11 +64,12 @@
 QualType VisitDecltypeType(const DecltypeType *T);
 QualType VisitUnaryTransformType(const UnaryTransformType *T);
 QualType VisitAutoType(const AutoType *T);
+QualType VisitInjectedClassNameType(const InjectedClassNameType *T);
 // FIXME: DependentDecltypeType
 QualType VisitRecordType(const RecordType *T);
 QualType VisitEnumType(const EnumType *T);
 QualType VisitAttributedType(const AttributedType *T);
-// FIXME: TemplateTypeParmType
+QualType VisitTemplateTypeParmType(const TemplateTypeParmType *T);
 // FIXME: SubstTemplateTypeParmType
 QualType VisitTemplateSpecializationType(const TemplateSpecializationType *T);
 QualType VisitElaboratedType(const ElaboratedType *T);
@@ -86,6 +87,10 @@
 void ImportDeclarationNameLoc(const DeclarationNameInfo ,
   DeclarationNameInfo& To);
 void ImportDeclContext(DeclContext *FromDC, bool ForceImport = false);
+
+typedef DesignatedInitExpr::Designator Designator;
+Designator ImportDesignator(const Designator );
+
 
 /// \brief What we should import from the definition.
 enum ImportDefinitionKind { 
@@ -136,6 +141,7 @@
 Decl *VisitTypedefNameDecl(TypedefNameDecl *D, bool IsAlias);
 Decl *VisitTypedefDecl(TypedefDecl *D);
 Decl *VisitTypeAliasDecl(TypeAliasDecl *D);
+Decl *VisitLabelDecl(LabelDecl *D);
 Decl *VisitEnumDecl(EnumDecl *D);
 Decl *VisitRecordDecl(RecordDecl *D);
 Decl *VisitEnumConstantDecl(EnumConstantDecl *D);
@@ -175,6 +181,7 @@
 DeclGroupRef ImportDeclGroup(DeclGroupRef DG);
 
 Stmt *VisitStmt(Stmt *S);
+Stmt *VisitGCCAsmStmt(GCCAsmStmt *S);
 Stmt *VisitDeclStmt(DeclStmt *S);
 Stmt *VisitNullStmt(NullStmt *S);
 Stmt *VisitCompoundStmt(CompoundStmt *S);
@@ -192,7 +199,6 @@
 Stmt *VisitContinueStmt(ContinueStmt *S);
 Stmt *VisitBreakStmt(BreakStmt *S);
 Stmt *VisitReturnStmt(ReturnStmt *S);
-// FIXME: GCCAsmStmt
 // FIXME: MSAsmStmt
 // FIXME: SEHExceptStmt
 // FIXME: SEHFinallyStmt
@@ -213,13 +219,29 @@
 
 // Importing expressions
 Expr *VisitExpr(Expr *E);
+Expr *VisitVAArgExpr(VAArgExpr *E);
+Expr *VisitGNUNullExpr(GNUNullExpr *E);
+Expr *VisitPredefinedExpr(PredefinedExpr *E);
 Expr *VisitDeclRefExpr(DeclRefExpr *E);
+Expr *VisitImplicitValueInitExpr(ImplicitValueInitExpr *ILE);
+Expr *VisitDesignatedInitExpr(DesignatedInitExpr *E);
+Expr *VisitCXXNullPtrLiteralExpr(CXXNullPtrLiteralExpr *E);
 Expr *VisitIntegerLiteral(IntegerLiteral *E);
+Expr *VisitFloatingLiteral(FloatingLiteral *E);
 Expr *VisitCharacterLiteral(CharacterLiteral *E);
+Expr *VisitStringLiteral(StringLiteral *E);
+Expr *VisitCompoundLiteralExpr(CompoundLiteralExpr *E);
+Expr *VisitAtomicExpr(AtomicExpr *E);
+Expr *VisitAddrLabelExpr(AddrLabelExpr *E);
 Expr *VisitParenExpr(ParenExpr *E);
+Expr *VisitParenListExpr(ParenListExpr *E);
+Expr *VisitStmtExpr(StmtExpr *E);
 Expr *VisitUnaryOperator(UnaryOperator *E);
 Expr *VisitUnaryExprOrTypeTraitExpr(UnaryExprOrTypeTraitExpr *E);
 Expr *VisitBinaryOperator(BinaryOperator *E);
+Expr *VisitConditionalOperator(ConditionalOperator *E);
+Expr *VisitBinaryConditionalOperator(BinaryConditionalOperator *E);
+Expr *VisitOpaqueValueExpr(OpaqueValueExpr *E);
 Expr 

Re: [PATCH] D19106: Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-14 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 53691.
ioeric added a comment.

- Addressed reviewer comment.


http://reviews.llvm.org/D19106

Files:
  lib/Format/TokenAnnotator.h

Index: lib/Format/TokenAnnotator.h
===
--- lib/Format/TokenAnnotator.h
+++ lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outter `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return Tok && startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 


Index: lib/Format/TokenAnnotator.h
===
--- lib/Format/TokenAnnotator.h
+++ lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outter `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return Tok && startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r266276 - Do not use llvm:getGlobalContext() in unittests

2016-04-14 Thread Rafael Espíndola via cfe-commits
On 14 April 2016 at 01:34, Mehdi Amini via cfe-commits
 wrote:
> Author: mehdi_amini
> Date: Thu Apr 14 00:34:32 2016
> New Revision: 266276
>
> URL: http://llvm.org/viewvc/llvm-project?rev=266276=rev
> Log:
> Do not use llvm:getGlobalContext() in unittests
>
> Currently trying to nuke this API from LLVM.

Thanks!

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


Re: [PATCH] D11781: Refactored pthread usage in libcxx

2016-04-14 Thread Asiri Rathnayake via cfe-commits
rmaprath added a subscriber: rmaprath.
rmaprath added a comment.

Hi, could I know the status of this? I'd like to push this forward.

@espositofulvio: Are you working on this? (just checking since this has gone 
stale for a while). @EricWF: I can create a separate diff for further review if 
this one is too cluttered.

Cheers,

/ Asiri


Repository:
  rL LLVM

http://reviews.llvm.org/D11781



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


Re: [PATCH] D19105: Changes in clang after running http://reviews.llvm.org/D18821

2016-04-14 Thread Nico Weber via cfe-commits
thakis added a subscriber: thakis.
thakis added a comment.

> I want to replace all unsigned that are 1 bits with bool.


MSVC only packs bitfields of the same type together, so doing that change would 
make clang use much more memory on Windows.


http://reviews.llvm.org/D19105



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


Re: [PATCH] D19106: Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-14 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Can you add a test?



Comment at: lib/Format/TokenAnnotator.h:143
@@ +142,3 @@
+  Tok = Tok->Next;
+return startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);

It's a bit subtle that this works even if Tok is nullptr at this point. Maybe 
change to

  return Tok && startsWithInternal( ...

to make this more clear.


http://reviews.llvm.org/D19106



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


[PATCH] D19106: Fixed a bug in AnnotatedLine::startsWith when there are comments in the line.

2016-04-14 Thread Eric Liu via cfe-commits
ioeric created this revision.
ioeric added reviewers: djasper, mprobst.
ioeric added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

When there are comments in the line, one token may be checked multiple times.

http://reviews.llvm.org/D19106

Files:
  lib/Format/TokenAnnotator.h

Index: lib/Format/TokenAnnotator.h
===
--- lib/Format/TokenAnnotator.h
+++ lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outter `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 


Index: lib/Format/TokenAnnotator.h
===
--- lib/Format/TokenAnnotator.h
+++ lib/Format/TokenAnnotator.h
@@ -83,7 +83,7 @@
   /// \c true if this line starts with the given tokens in order, ignoring
   /// comments.
   template  bool startsWith(Ts... Tokens) const {
-return startsWith(First, Tokens...);
+return startsWithInternal(First, Tokens...);
   }
 
   /// \c true if this line looks like a function definition instead of a
@@ -124,15 +124,24 @@
   void operator=(const AnnotatedLine &) = delete;
 
   template 
-  bool startsWith(FormatToken *Tok, A K1) const {
+  bool startsWithInternal(const FormatToken *Tok, A K1) const {
+// Even though we skip comments in the outter `startWithInternal` function,
+// this loop is still necessary if it is invoked by the public interface
+// `startsWith`.
 while (Tok && Tok->is(tok::comment))
   Tok = Tok->Next;
 return Tok && Tok->is(K1);
   }
 
   template 
-  bool startsWith(FormatToken *Tok, A K1, Ts... Tokens) const {
-return startsWith(Tok, K1) && startsWith(Tok->Next, Tokens...);
+  bool startsWithInternal(const FormatToken *Tok, A K1, Ts... Tokens) const {
+// Skip comments before calling `startsWithInternal(Tok, K1)` so that  the
+// second call to `startsWithInternal` takes the correct `Tok->Next`, which
+// should be the next token of the token checked in the first call.
+while (Tok && Tok->is(tok::comment))
+  Tok = Tok->Next;
+return startsWithInternal(Tok, K1) &&
+   startsWithInternal(Tok->Next, Tokens...);
   }
 };
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266290 - Reapply r258505 after r266254, this time with a comment to make it more sticky.

2016-04-14 Thread Nico Weber via cfe-commits
Author: nico
Date: Thu Apr 14 06:12:32 2016
New Revision: 266290

URL: http://llvm.org/viewvc/llvm-project?rev=266290=rev
Log:
Reapply r258505 after r266254, this time with a comment to make it more sticky.

Modified:
cfe/trunk/include/clang/AST/RecursiveASTVisitor.h

Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=266290=266289=266290=diff
==
--- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
+++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Thu Apr 14 06:12:32 2016
@@ -840,8 +840,14 @@ bool RecursiveASTVisitor::Trave
 TRY_TO(TraverseStmt(Init->getInit()));
 
   if (getDerived().shouldVisitImplicitCode())
-for (VarDecl *VD : Init->getArrayIndices())
+// The braces for this one-line loop are required for MSVC2013.  It
+// refuses to compile
+// for (int i : int_vec)
+//   do {} while(false);
+// without braces on the for loop.
+for (VarDecl *VD : Init->getArrayIndices()) {
   TRY_TO(TraverseDecl(VD));
+}
 
   return true;
 }


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


Re: r266254 - [modules] Remove CXX_CTOR_INITIALIZERS_OFFSETS table. Instead of storing an ID

2016-04-14 Thread Nico Weber via cfe-commits
This broke building on
http://lab.llvm.org:8011/builders/clang-x64-ninja-win7 . I tried fixing in
r266290.

On Wed, Apr 13, 2016 at 5:57 PM, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Wed Apr 13 16:57:08 2016
> New Revision: 266254
>
> URL: http://llvm.org/viewvc/llvm-project?rev=266254=rev
> Log:
> [modules] Remove CXX_CTOR_INITIALIZERS_OFFSETS table. Instead of storing
> an ID
> of a table entry in the corresponding decl, store an offset from the
> current
> record to the relevant CXX_CTOR_INITIALIZERS record. This results in fewer
> indirections and a minor .pcm file size reduction.
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/include/clang/Serialization/ASTWriter.h
> cfe/trunk/include/clang/Serialization/Module.h
> cfe/trunk/lib/CodeGen/CGClass.cpp
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
> cfe/trunk/lib/Serialization/Module.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclCXX.h?rev=266254=266253=266254=diff
>
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Wed Apr 13 16:57:08 2016
> @@ -2134,8 +2134,7 @@ public:
>  assert(I < getNumArrayIndices() && "Out of bounds member array
> index");
>  getTrailingObjects()[I] = Index;
>}
> -  ArrayRef getArrayIndexes() {
> -assert(getNumArrayIndices() != 0 && "Getting indexes for non-array
> init");
> +  ArrayRef getArrayIndices() {
>  return llvm::makeArrayRef(getTrailingObjects(),
>getNumArrayIndices());
>}
>
> Modified: cfe/trunk/include/clang/AST/RecursiveASTVisitor.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/RecursiveASTVisitor.h?rev=266254=266253=266254=diff
>
> ==
> --- cfe/trunk/include/clang/AST/RecursiveASTVisitor.h (original)
> +++ cfe/trunk/include/clang/AST/RecursiveASTVisitor.h Wed Apr 13 16:57:08
> 2016
> @@ -839,10 +839,10 @@ bool RecursiveASTVisitor::Trave
>if (Init->isWritten() || getDerived().shouldVisitImplicitCode())
>  TRY_TO(TraverseStmt(Init->getInit()));
>
> -  if (Init->getNumArrayIndices() &&
> getDerived().shouldVisitImplicitCode())
> -for (VarDecl *VD : Init->getArrayIndexes()) {
> +  if (getDerived().shouldVisitImplicitCode())
> +for (VarDecl *VD : Init->getArrayIndices())
>TRY_TO(TraverseDecl(VD));
> -}
> +
>return true;
>  }
>
>
> Modified: cfe/trunk/include/clang/Serialization/ASTBitCodes.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTBitCodes.h?rev=266254=266253=266254=diff
>
> ==
> --- cfe/trunk/include/clang/Serialization/ASTBitCodes.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTBitCodes.h Wed Apr 13
> 16:57:08 2016
> @@ -573,9 +573,7 @@ namespace clang {
>/// \brief Record code for potentially unused local typedef names.
>UNUSED_LOCAL_TYPEDEF_NAME_CANDIDATES = 52,
>
> -  /// \brief Record code for the table of offsets to
> CXXCtorInitializers
> -  /// lists.
> -  CXX_CTOR_INITIALIZERS_OFFSETS = 53,
> +  // ID 53 used to be a table of constructor initializer records.
>
>/// \brief Delete expressions that will be analyzed later.
>DELETE_EXPRS_TO_ANALYZE = 54,
>
> Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=266254=266253=266254=diff
>
> ==
> --- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
> +++ cfe/trunk/include/clang/Serialization/ASTReader.h Wed Apr 13 16:57:08
> 2016
> @@ -1971,11 +1971,6 @@ public:
>ReadCXXCtorInitializers(ModuleFile , const RecordData ,
>unsigned );
>
> -  /// \brief Read a CXXCtorInitializers ID from the given record and
> -  /// return its global bit offset.
> -  uint64_t ReadCXXCtorInitializersRef(ModuleFile , const RecordData
> ,
> -  unsigned );
> -
>/// \brief Read the contents of a CXXCtorInitializer array.
>CXXCtorInitializer **GetExternalCXXCtorInitializers(uint64_t Offset)
> override;
>
>
> Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
> URL:
> 

Re: r266108 - clang-cl: Remove -isystem, add -imsvc.

2016-04-14 Thread Nico Weber via cfe-commits
On Thu, Apr 14, 2016 at 4:09 AM, Ismail Donmez via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi,
>
> On Tue, Apr 12, 2016 at 10:04 PM, Nico Weber via cfe-commits
>  wrote:
> > Author: nico
> > Date: Tue Apr 12 14:04:37 2016
> > New Revision: 266108
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=266108=rev
> > Log:
> > clang-cl: Remove -isystem, add -imsvc.
> >
> > r260990 exposed -isystem in clang-cl. -isystem adds a directory to the
> front of
> > the system include search path. The idea was to use this to point to a
> hermetic
> > msvc install, but as it turns out this doesn't work: -isystem then adds
> the
> > hermetic headers in front of clang's builtin headers, and clang's
> headers that
> > are supposed to wrap msvc headers (say, stdarg.h) aren't picked up at all
> > anymore.
> >
> > So revert that, and instead expose -imsvc which works as if the passed
> > directory was part of %INCLUDE%: The header is treated as a system
> header, but
> > it is searched after clang's lib/Header headers.
> >
> > Fixes half of PRPR26751.
>
> This fails the test for me on Linux x86-64:
>
>  /home/abuild/rpmbuild/BUILD/llvm/stage2/./bin/clang --driver-mode=cl
>  --driver-mode=cl  -fcolor-diagnostics
> -fno-color-diagnostics  -fdiagnostics-color
> -fno-diagnostics-color  -fdiagnostics-parseable-fixits
> -ferror-limit=10  -fmsc-version=1800  -fno-strict-aliasing
>  -fstrict-aliasing  -fsyntax-only  -fms-compatibility
> -fno-ms-compatibility  -fms-extensions  -fno-ms-extensions
>  -mllvm -disable-llvm-optzns  -Wunused-variable
> -fmacro-backtrace-limit=0  -Werror /Zs --
> /home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/cl-options.c
> 2>&1
>  --
>  Exit Code: 1
>
>  Command Output (stderr):
>  --
>
>  /home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/cl-options.c:88:17:
> error: expected string not found in input
>  // SLASH_imsvc: "-internal-isystem"
> "{{[^"]*}}lib{{/|}}clang{{[^"]*}}include"
>  ^
>  :1:1: note: scanning from here
>  openSUSE Linux clang version 3.9.0 (trunk 266277) (based on LLVM 3.9.0svn)
>  ^
>  :5:709: note: possible intended match here
>   "/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/clang-3.9" "-cc1"
> "-triple" "x86_64-pc-windows-msvc18.0.0" "-emit-obj" "-mrelax-all"
> "-mincremental-linker-compatible" "-disable-free"
> "-disable-llvm-verifier" "-discard-value-names" "-main-file-name"
> "cl-options.c" "-mrelocation-model" "pic" "-pic-level" "2"
> "-mthread-model" "posix" "-relaxed-aliasing" "-fmath-errno"
> "-masm-verbose" "-mconstructor-aliases" "-munwind-tables"
> "-target-cpu" "x86-64" "-D_MT" "--dependent-lib=libcmt"
> "--dependent-lib=oldnames" "-fms-volatile" "-fdiagnostics-format"
> "msvc" "-momit-leaf-frame-pointer" "-dwarf-column-info"
> "-debugger-tuning=gdb" "-resource-dir"
> "/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0"
> "-internal-isystem"
> "/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0/include"
> "-internal-isystem" "myincludedir" "-internal-isystem" "C:/Program
> Files/Microsoft Visual Studio 10.0/VC/include" "-internal-isystem"
> "C:/Program Files/Microsoft Visual Studio 9.0/VC/include"
> "-internal-isystem" "C:/Program Files/Microsoft Visual Studio
> 9.0/VC/PlatformSDK/Include" "-internal-isystem" "C:/Program
> Files/Microsoft Visual Studio 8/VC/include" "-internal-isystem"
> "C:/Program Files/Microsoft Visual Studio 8/VC/PlatformSDK/Include"
> "-fdebug-compilation-dir"
> "/home/abuild/rpmbuild/BUILD/llvm/stage2/tools/clang/test/Driver"
> "-ferror-limit" "19" "-fmessage-length" "0" "-fms-extensions"
> "-fms-compatibility" "-fms-compatibility-version=18"
> "-fno-threadsafe-statics" "-fdelayed-template-parsing"
> "-fobjc-runtime=gcc" "-fdiagnostics-show-option" "-o"
> "/tmp/cl-options-ca1c04.obj" "-x" "c"
> "/home/abuild/rpmbuild/BUILD/llvm/tools/clang/test/Driver/cl-options.c"
>

It's supposed to match the

"-internal-isystem"
"/home/abuild/rpmbuild/BUILD/llvm/stage2/bin/../lib64/clang/3.9.0/include"
"-internal-isystem" "myincludedir"

bit in your output. Looks like it's "lib64" instead of "lib" on your
system. Does changing

// SLASH_imsvc: "-internal-isystem"
"{{[^"]*}}lib{{/|}}clang{{[^"]*}}include"

to

// SLASH_imsvc: "-internal-isystem"
"{{[^"]*}}lib{{(64)?/|}}clang{{[^"]*}}include"

help?


>
> Any ideas?
> ___
> 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


Re: [PATCH] D19056: [MSVC] Fix check for wchar_t type in case of -fno-wchar

2016-04-14 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin marked an inline comment as done.
DmitryPolukhin added a comment.

I added few more negative tests. Thank you for the review!


Repository:
  rL LLVM

http://reviews.llvm.org/D19056



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


  1   2   >