Re: [PATCH] D13128: Fix backend crash on multiple close of stdout.

2015-09-26 Thread Yaron Keren via cfe-commits
yaron.keren added a comment.

Hi Dan, it makes sense that output streams should not usually be mixed 
together, especially if one is binary as you write.
This may or may not be a problem depending on what the user really wants. He 
may want to mix the outputs for whatever purposes or it may usually be a user 
error. 
In any case, that's not how clang deal with usage or even internal unexpected 
errors. It asserts, print error messages but does not crash on purpose. Having 
clang crash here does not seem like a good solution and will result in this 
issue continue to surface again.


http://reviews.llvm.org/D13128



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


r248632 - Change arc-cxx11-init-list.mm to work with upcoming SCEV changes.

2015-09-26 Thread Sanjoy Das via cfe-commits
Author: sanjoy
Date: Fri Sep 25 18:07:11 2015
New Revision: 248632

URL: http://llvm.org/viewvc/llvm-project?rev=248632&view=rev
Log:
Change arc-cxx11-init-list.mm to work with upcoming SCEV changes.

Summary:
The store being checked for in arc-cxx11-init-list.mm is a store to an
unescaped alloca.  After an uncoming change to ScalarEvolution, LLVM is
able to elide the store, so adjust the test accordingly.

Reviewers: compnerd

Subscribers: cfe-commits

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

Modified:
cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm

Modified: cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm?rev=248632&r1=248631&r2=248632&view=diff
==
--- cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm (original)
+++ cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm Fri Sep 25 18:07:11 2015
@@ -41,8 +41,6 @@ extern "C" void extended() {
 }
 
 // CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* 
@objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
-// CHECK-NEXT: [[CAST:%.*]] = bitcast [1 x %0*]* %{{.*}} to i8**
-// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]],
 // CHECK: {{.*}} call void @_Z8externalv()
 // CHECK: {{.*}} call void @objc_release(i8* {{.*}})
 


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


[PATCH] D13183: Change arc-cxx11-init-list.mm to work with upcoming SCEV changes.

2015-09-26 Thread Sanjoy Das via cfe-commits
sanjoy created this revision.
sanjoy added a reviewer: compnerd.
sanjoy added a subscriber: cfe-commits.

The store being checked for in arc-cxx11-init-list.mm is a store to an
unescaped alloca.  After an uncoming change to ScalarEvolution, LLVM is
able to elide the store, so adjust the test accordingly.

http://reviews.llvm.org/D13183

Files:
  test/CodeGenObjCXX/arc-cxx11-init-list.mm

Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -41,8 +41,6 @@
 }
 
 // CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* 
@objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
-// CHECK-NEXT: [[CAST:%.*]] = bitcast [1 x %0*]* %{{.*}} to i8**
-// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]],
 // CHECK: {{.*}} call void @_Z8externalv()
 // CHECK: {{.*}} call void @objc_release(i8* {{.*}})
 


Index: test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -41,8 +41,6 @@
 }
 
 // CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
-// CHECK-NEXT: [[CAST:%.*]] = bitcast [1 x %0*]* %{{.*}} to i8**
-// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]],
 // CHECK: {{.*}} call void @_Z8externalv()
 // CHECK: {{.*}} call void @objc_release(i8* {{.*}})
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D13183: Change arc-cxx11-init-list.mm to work with upcoming SCEV changes.

2015-09-26 Thread Sanjoy Das via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL248632: Change arc-cxx11-init-list.mm to work with upcoming 
SCEV changes. (authored by sanjoy).

Changed prior to commit:
  http://reviews.llvm.org/D13183?vs=35777&id=35778#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D13183

Files:
  cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm

Index: cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -41,8 +41,6 @@
 }
 
 // CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* 
@objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
-// CHECK-NEXT: [[CAST:%.*]] = bitcast [1 x %0*]* %{{.*}} to i8**
-// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]],
 // CHECK: {{.*}} call void @_Z8externalv()
 // CHECK: {{.*}} call void @objc_release(i8* {{.*}})
 


Index: cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
===
--- cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
+++ cfe/trunk/test/CodeGenObjCXX/arc-cxx11-init-list.mm
@@ -41,8 +41,6 @@
 }
 
 // CHECK: [[INSTANCE:%.*]] = {{.*}} call i8* bitcast (i8* (i8*, i8*, ...)* @objc_msgSend to i8* (i8*, i8*)*)(i8* {{.*}}, i8* {{.*}})
-// CHECK-NEXT: [[CAST:%.*]] = bitcast [1 x %0*]* %{{.*}} to i8**
-// CHECK-NEXT: store i8* [[INSTANCE]], i8** [[CAST]],
 // CHECK: {{.*}} call void @_Z8externalv()
 // CHECK: {{.*}} call void @objc_release(i8* {{.*}})
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D13192: Fix incorrect parsing of arguments for nested functions

2015-09-26 Thread Arseny Kapoulkine via cfe-commits
arseny.kapoulkine created this revision.
arseny.kapoulkine added a subscriber: cfe-commits.

For nested functions, local-name can be followed by function arguments; in
some cases the first argument starts with a digit (if it's a named type).

For example, this code:

void test() { struct g { void foo(Point p); }; }

Generates this name for symbol foo:

_ZZ4testvEN1g3fooE5Point

When decomposed, this results in a local-name with entity name N1g3fooE
(aka g::foo). According to Itanium ABI, entity name can be followed by
a discriminator that has to start with _.

However, libcxxabi defines an extension that says that discriminator can start
with a digit. This makes the grammar ambiguous, and causes 5 to be skipped and
Point to be parsed as a series of types for function arguments.

Resolve ambiguity by requiring that a digit-only discriminator is the last
token in the input string.

http://reviews.llvm.org/D13192

Files:
  libcxxabi/trunk/src/cxa_demangle.cpp
  libcxxabi/trunk/test/test_demangle.pass.cpp

Index: libcxxabi/trunk/test/test_demangle.pass.cpp
===
--- libcxxabi/trunk/test/test_demangle.pass.cpp
+++ libcxxabi/trunk/test/test_demangle.pass.cpp
@@ -29593,6 +29593,7 @@
 
{"_ZNK3Ncr6Silver7Utility6detail12CallOnThreadIZ53-[DeploymentSetupController 
handleManualServerEntry:]E3$_5EclIJEEEDTclclL_ZNS2_4getTIS4_EERT_vEEspclsr3stdE7forwardIT_Efp_EEEDpOSA_",
 "decltype(-[DeploymentSetupController handleManualServerEntry:]::$_5& 
Ncr::Silver::Utility::detail::getT<-[DeploymentSetupController 
handleManualServerEntry:]::$_5>()()(std::forward<-[DeploymentSetupController 
handleManualServerEntry:]::$_5>(fp))) 
Ncr::Silver::Utility::detail::CallOnThread<-[DeploymentSetupController 
handleManualServerEntry:]::$_5>::operator()<>(-[DeploymentSetupController 
handleManualServerEntry:]::$_5&&) const"},
 {"_Zli2_xy", "operator\"\" _x(unsigned long long)"},
 {"_Z1fIiEDcT_", "decltype(auto) f(int)"},
+{"_ZZ4testvEN1g3fooE5Point", "test()::g::foo(Point)"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
Index: libcxxabi/trunk/src/cxa_demangle.cpp
===
--- libcxxabi/trunk/src/cxa_demangle.cpp
+++ libcxxabi/trunk/src/cxa_demangle.cpp
@@ -4054,7 +4054,7 @@
 
 //  := _   # when number < 10
 // := __  _   # when number >= 10
-//  extension  := decimal-digit+
+//  extension  := decimal-digit+   # at the end of string
 
 const char*
 parse_discriminator(const char* first, const char* last)
@@ -4083,7 +4083,8 @@
 const char* t1 = first+1;
 for (; t1 != last && std::isdigit(*t1); ++t1)
 ;
-first = t1;
+if (t1 == last)
+first = last;
 }
 }
 return first;


Index: libcxxabi/trunk/test/test_demangle.pass.cpp
===
--- libcxxabi/trunk/test/test_demangle.pass.cpp
+++ libcxxabi/trunk/test/test_demangle.pass.cpp
@@ -29593,6 +29593,7 @@
 {"_ZNK3Ncr6Silver7Utility6detail12CallOnThreadIZ53-[DeploymentSetupController handleManualServerEntry:]E3$_5EclIJEEEDTclclL_ZNS2_4getTIS4_EERT_vEEspclsr3stdE7forwardIT_Efp_EEEDpOSA_", "decltype(-[DeploymentSetupController handleManualServerEntry:]::$_5& Ncr::Silver::Utility::detail::getT<-[DeploymentSetupController handleManualServerEntry:]::$_5>()()(std::forward<-[DeploymentSetupController handleManualServerEntry:]::$_5>(fp))) Ncr::Silver::Utility::detail::CallOnThread<-[DeploymentSetupController handleManualServerEntry:]::$_5>::operator()<>(-[DeploymentSetupController handleManualServerEntry:]::$_5&&) const"},
 {"_Zli2_xy", "operator\"\" _x(unsigned long long)"},
 {"_Z1fIiEDcT_", "decltype(auto) f(int)"},
+{"_ZZ4testvEN1g3fooE5Point", "test()::g::foo(Point)"},
 };
 
 const unsigned N = sizeof(cases) / sizeof(cases[0]);
Index: libcxxabi/trunk/src/cxa_demangle.cpp
===
--- libcxxabi/trunk/src/cxa_demangle.cpp
+++ libcxxabi/trunk/src/cxa_demangle.cpp
@@ -4054,7 +4054,7 @@
 
 //  := _   # when number < 10
 // := __  _   # when number >= 10
-//  extension  := decimal-digit+
+//  extension  := decimal-digit+   # at the end of string
 
 const char*
 parse_discriminator(const char* first, const char* last)
@@ -4083,7 +4083,8 @@
 const char* t1 = first+1;
 for (; t1 != last && std::isdigit(*t1); ++t1)
 ;
-first = t1;
+if (t1 == last)
+first = last;
 }
 }
 return first;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r248666 - clang/test/Driver/arm-compiler-rt.c: Relax expressions for dos path.

2015-09-26 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Sat Sep 26 06:17:32 2015
New Revision: 248666

URL: http://llvm.org/viewvc/llvm-project?rev=248666&view=rev
Log:
clang/test/Driver/arm-compiler-rt.c: Relax expressions for dos path.

Modified:
cfe/trunk/test/Driver/arm-compiler-rt.c

Modified: cfe/trunk/test/Driver/arm-compiler-rt.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/arm-compiler-rt.c?rev=248666&r1=248665&r2=248666&view=diff
==
--- cfe/trunk/test/Driver/arm-compiler-rt.c (original)
+++ cfe/trunk/test/Driver/arm-compiler-rt.c Sat Sep 26 06:17:32 2015
@@ -1,21 +1,21 @@
 // RUN: %clang -target arm-linux-gnueabi -rtlib=compiler-rt -### %s 2>&1 | 
FileCheck %s -check-prefix ARM-GNUEABI
-// ARM-GNUEABI: "{{.*}}/libclang_rt.builtins-arm.a"
+// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
 
 // RUN: %clang -target arm-linux-gnueabi -rtlib=compiler-rt -mfloat-abi=hard 
-### %s 2>&1 | FileCheck %s -check-prefix ARM-GNUEABI-ABI
-// ARM-GNUEABI-ABI: "{{.*}}/libclang_rt.builtins-armhf.a"
+// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
 
 // RUN: %clang -target arm-linux-gnueabihf -rtlib=compiler-rt -### %s 2>&1 | 
FileCheck %s -check-prefix ARM-GNUEABIHF
-// ARM-GNUEABIHF: "{{.*}}/libclang_rt.builtins-armhf.a"
+// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
 
 // RUN: %clang -target arm-linux-gnueabihf -rtlib=compiler-rt -mfloat-abi=soft 
-### %s 2>&1 | FileCheck %s -check-prefix ARM-GNUEABIHF-ABI
-// ARM-GNUEABIHF-ABI: "{{.*}}/libclang_rt.builtins-arm.a"
+// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
 
 // RUN: %clang -target arm-windows-itanium -rtlib=compiler-rt -### %s 2>&1 | 
FileCheck %s -check-prefix ARM-WINDOWS
-// ARM-WINDOWS: "{{.*}}/clang_rt.builtins-arm.lib"
+// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins-arm.lib"
 
 // RUN: %clang -target arm-linux-androideabi -rtlib=compiler-rt -### %s 2>&1 | 
FileCheck %s -check-prefix ARM-ANDROID
-// ARM-ANDROID: "{{.*}}/libclang_rt.builtins-arm-android.a"
+// ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins-arm-android.a"
 
 // RUN: %clang -target arm-linux-androideabi -rtlib=compiler-rt 
-mfloat-abi=hard -### %s 2>&1 | FileCheck %s -check-prefix ARM-ANDROIDHF
-// ARM-ANDROIDHF: "{{.*}}/libclang_rt.builtins-armhf-android.a"
+// ARM-ANDROIDHF: "{{.*[/\\]}}libclang_rt.builtins-armhf-android.a"
 


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


Re: [PATCH] D12407: [clang-format-vs] Add an option to reformat source code when file is saved to disk

2015-09-26 Thread Paul Hoad via cfe-commits
MyDeveloperDay added a comment.

After a little digging, the problem is based on the fact that the extension 
doesn't load until we use it, so the nBeforeSave won't fire, so after doing 
Ctrl-R,Ctrl-F once it will work

This exact same problem is mentioned here

http://schmalls.com/2015/01/19/adventures-in-visual-studio-extension-development-part-2

Quote:

So, we implement all of the event functionality and try out the extension. 
**The first time we save a file, no arranging happens. If we run the arrange 
command from the menu item, it runs fine and then subsequent file saves also 
get arranged. **That seems weird. It turns out that Visual Studio only loads 
the extensions as needed. We have to add another one of our provide attributes, 
ProvideAutoLoadAttribute, to the VSPackage class to get the extension to load 
sooner.
[ProvideAutoLoad("ADFC4E64-0397-11D1-9F4E-00A0C911004F")]
I found the GUID to pass to this from a blog post I found to get the extension 
to load as soon as possible. After further research on MSDN, it turns out to be 
the same as the UIContextGuids80.NoSolution field. The remarks seem to indicate 
that it would only become active when a solution is closed or Visual Studio is 
started with the "Show Empty Environment" option set in startup; however, it 
looks like it happens when Visual Studio is started no matter the value of the 
startup setting. There are other useful contexts in the UIContextGuids80 Class. 
The attribute can be rewritten as shown.


http://reviews.llvm.org/D12407



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


[libunwind] r248673 - unwind: Allow the building of libunwind for MIPS.

2015-09-26 Thread Vasileios Kalintiris via cfe-commits
Author: vkalintiris
Date: Sat Sep 26 13:26:01 2015
New Revision: 248673

URL: http://llvm.org/viewvc/llvm-project?rev=248673&view=rev
Log:
unwind: Allow the building of libunwind for MIPS.

Summary:
Currently, libunwind doesn't support MIPS. However, with this patch
we do allow the library to build, and we warn the user about the lack of
support for MIPS. Also, the dummy unw_getcontext() implementation for MIPS just
traps on function entry in order to avoid any confusion with silent/weird
failures at runtime.

This allows us to test an LLVM-based toolchain without the dependency on a
GCC toolchain. Of course, C++ exception handling and other things that depend
on stack unwinding will not work until we add a proper implementation of the
stub functions.

Reviewers: compnerd, logan

Subscribers: dsanders, llvm-commits

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

Modified:
libunwind/trunk/src/UnwindRegistersSave.S
libunwind/trunk/src/config.h
libunwind/trunk/src/libunwind.cpp

Modified: libunwind/trunk/src/UnwindRegistersSave.S
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/UnwindRegistersSave.S?rev=248673&r1=248672&r2=248673&view=diff
==
--- libunwind/trunk/src/UnwindRegistersSave.S (original)
+++ libunwind/trunk/src/UnwindRegistersSave.S Sat Sep 26 13:26:01 2015
@@ -87,6 +87,15 @@ DEFINE_LIBUNWIND_FUNCTION(unw_getcontext
   xorl  %eax, %eax# return UNW_ESUCCESS
   ret
 
+# elif defined(__mips__)
+
+#
+# extern int unw_getcontext(unw_context_t* thread_state)
+#
+# Just trap for the time being.
+DEFINE_LIBUNWIND_FUNCTION(unw_getcontext)
+  teq $0, $0
+
 #elif defined(__ppc__)
 
 ;

Modified: libunwind/trunk/src/config.h
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/config.h?rev=248673&r1=248672&r2=248673&view=diff
==
--- libunwind/trunk/src/config.h (original)
+++ libunwind/trunk/src/config.h Sat Sep 26 13:26:01 2015
@@ -41,7 +41,8 @@
 
   #define _LIBUNWIND_BUILD_ZERO_COST_APIS (defined(__i386__) || \
defined(__x86_64__) || \
-   defined(__arm64__))
+   defined(__arm64__) || \
+   defined(__mips__))
   #define _LIBUNWIND_BUILD_SJLJ_APIS  defined(__arm__)
   #define _LIBUNWIND_SUPPORT_FRAME_APIS   (defined(__i386__) || \
defined(__x86_64__))

Modified: libunwind/trunk/src/libunwind.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libunwind/trunk/src/libunwind.cpp?rev=248673&r1=248672&r2=248673&view=diff
==
--- libunwind/trunk/src/libunwind.cpp (original)
+++ libunwind/trunk/src/libunwind.cpp Sat Sep 26 13:26:01 2015
@@ -64,6 +64,8 @@ _LIBUNWIND_EXPORT int unw_init_local(unw
 #elif defined(__or1k__)
   new ((void *)cursor) UnwindCursor(
  context, 
LocalAddressSpace::sThisAddressSpace);
+#elif defined(__mips__)
+#warning The MIPS architecture is not supported.
 #else
 #error Architecture not supported
 #endif


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


Re: [PATCH] D13171: [CUDA] Added a wrapper header for inclusion of stock CUDA headers.

2015-09-26 Thread Eric Christopher via cfe-commits
echristo added a comment.

Bikeshed: it's part of the clang headers, do we really need "clang" in the 
header name?

-eric


http://reviews.llvm.org/D13171



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


Re: [PATCH] D6920: [clang-format] Add SpaceBeforeBrackets

2015-09-26 Thread Matthäus G . Chajdas via cfe-commits
Anteru updated this revision to Diff 35810.
Anteru added a comment.

Here's an updated diff which should do the trick. If not, please tell me how to 
improve -- this is my first change to Clang.


http://reviews.llvm.org/D6920

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -8358,6 +8358,43 @@
   verifyFormat("X A::operator++ (T);", Space);
 }
 
+TEST_F(FormatTest, ConfigurableSpaceBeforeSquareBrackets) {
+  FormatStyle NoSpace = getLLVMStyle();
+  NoSpace.SpaceBeforeSquareBrackets = false;
+  
+  verifyFormat("int a[5];", NoSpace);
+  verifyFormat("a[3] += 42;", NoSpace);
+
+  verifyFormat("int a[1];", NoSpace);
+  verifyFormat("int 1 [a];", NoSpace);
+  verifyFormat("int a[1][2];", NoSpace);
+  verifyFormat("a[7] = 5;", NoSpace);
+  verifyFormat("int a = (f())[23];", NoSpace);
+  verifyFormat("f([] {})", NoSpace);
+
+  FormatStyle Space = getLLVMStyle();
+  Space.SpaceBeforeSquareBrackets = true;
+  verifyFormat("int c = []() -> int { return 2; }();\n", Space);
+  verifyFormat("return [i, args...] {};", Space);
+
+  verifyFormat("int a [5];", Space);
+  verifyFormat("a [3] += 42;", Space);
+  verifyFormat("constexpr char hello []{\"hello\"};", Space);
+  verifyFormat("double &operator[](int i) { return 0; }\n"
+"int i;",
+Space);
+  verifyFormat("std::unique_ptr foo() {}", Space);
+  verifyFormat("int i = a [a][a]->f();", Space);
+  verifyFormat("int i = (*b) [a]->f();", Space);
+
+  verifyFormat("int a [1];", Space);
+  verifyFormat("int 1 [a];", Space);
+  verifyFormat("int a [1][2];", Space);
+  verifyFormat("a [7] = 5;", Space);
+  verifyFormat("int a = (f()) [23];", Space);
+  verifyFormat("f([] {})", Space);
+}
+
 TEST_F(FormatTest, ConfigurableSpacesInParentheses) {
   FormatStyle Spaces = getLLVMStyle();
 
@@ -9303,6 +9340,7 @@
   CHECK_PARSE_BOOL(SpacesInCStyleCastParentheses);
   CHECK_PARSE_BOOL(SpaceAfterCStyleCast);
   CHECK_PARSE_BOOL(SpaceBeforeAssignmentOperators);
+  CHECK_PARSE_BOOL(SpaceBeforeSquareBrackets);
 }
 
 #undef CHECK_PARSE_BOOL
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1882,7 +1882,9 @@
  Right.MatchingParen->is(TT_ArraySubscriptLSquare)));
   if (Right.is(tok::l_square) &&
   !Right.isOneOf(TT_ObjCMethodExpr, TT_LambdaLSquare) &&
-  !Left.isOneOf(tok::numeric_constant, TT_DictLiteral))
+  !Left.isOneOf(tok::numeric_constant, TT_DictLiteral) &&
+  !(!Left.is(tok::r_square) && Style.SpaceBeforeSquareBrackets &&
+Right.is(TT_ArraySubscriptLSquare)))
 return false;
   if (Left.is(tok::colon))
 return !Left.is(TT_ObjCMethodExpr);
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -279,6 +279,7 @@
Style.SpacesInCStyleCastParentheses);
 IO.mapOptional("SpacesInParentheses", Style.SpacesInParentheses);
 IO.mapOptional("SpacesInSquareBrackets", Style.SpacesInSquareBrackets);
+IO.mapOptional("SpaceBeforeSquareBrackets", Style.SpaceBeforeSquareBrackets);
 IO.mapOptional("Standard", Style.Standard);
 IO.mapOptional("TabWidth", Style.TabWidth);
 IO.mapOptional("UseTab", Style.UseTab);
@@ -391,6 +392,7 @@
   LLVMStyle.UseTab = FormatStyle::UT_Never;
   LLVMStyle.SpacesInParentheses = false;
   LLVMStyle.SpacesInSquareBrackets = false;
+  LLVMStyle.SpaceBeforeSquareBrackets = false;
   LLVMStyle.SpaceInEmptyParentheses = false;
   LLVMStyle.SpacesInContainerLiterals = true;
   LLVMStyle.SpacesInCStyleCastParentheses = false;
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -410,6 +410,9 @@
   /// \brief If \c true, spaces will be inserted after '[' and before ']'.
   bool SpacesInSquareBrackets;
 
+  /// \brief If \c true, a space will be inserted before '[' in array subscripts.
+  bool SpaceBeforeSquareBrackets;
+
   /// \brief Supported language standards.
   enum LanguageStandard {
 /// Use C++03-compatible syntax.
@@ -515,6 +518,7 @@
SpacesInCStyleCastParentheses == R.SpacesInCStyleCastParentheses &&
SpacesInParentheses == R.SpacesInParentheses &&
SpacesInSquareBrackets == R.SpacesInSquareBrackets &&
+   SpaceBeforeSquareBrackets == R.SpaceBeforeSquareBrackets &&
Standard == R.Standard &&
TabWidth == R.TabWidth &&
UseTab == R.UseTab;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman

Re: [PATCH] D13090: [clang-tidy] IdentifierNamingCheck should only emit warnings when declaration or usage is outside of macros

2015-09-26 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.
This revision is now accepted and ready to land.

Looks good. Should I submit this?


http://reviews.llvm.org/D13090



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


Re: [PATCH] D13071: [PATCH] New checker for mismatched operator new/operator delete definitions

2015-09-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please add a documentation file.



Comment at: clang-tidy/misc/NewDeleteOverloadsCheck.cpp:42
@@ +41,3 @@
+return Node.getNumParams() > 1;
+  else if (Node.getNumParams() == 1)
+return false;

Please no `else` after `return`.


http://reviews.llvm.org/D13071



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


Re: [PATCH] D12945: [PATCH] Add checker for objects that should not be value types

2015-09-26 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please add a documentation file.



Comment at: clang-tidy/misc/NonCopyableObjects.cpp:21
@@ +20,3 @@
+  static const char *TypeNames[] = {
+"::pthread_cond_t",
+"::pthread_mutex_t",

How about making these lists configurable or adding a list for custom type 
names that should be checked in a similar way?


Comment at: clang-tidy/misc/NonCopyableObjects.cpp:81
@@ +80,3 @@
+  if (D && BD)
+diag(D->getLocation(), "'%0' declared as type '%1'; did you mean '%1 *'?")
+<< D->getName() << BD->getName();

I think, error messages should contain some explanation of why is this wrong. 
Not sure if this can be fit into a reasonable number of words, but we have to 
try.


http://reviews.llvm.org/D12945



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


r248678 - Use llvm::makeArrayRef. NFC.

2015-09-26 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Sat Sep 26 22:44:08 2015
New Revision: 248678

URL: http://llvm.org/viewvc/llvm-project?rev=248678&view=rev
Log:
Use llvm::makeArrayRef. NFC.

Modified:
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/include/clang/AST/Type.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=248678&r1=248677&r2=248678&view=diff
==
--- cfe/trunk/include/clang/AST/Type.h (original)
+++ cfe/trunk/include/clang/AST/Type.h Sat Sep 26 22:44:08 2015
@@ -4635,7 +4635,7 @@ public:
   /// Retrieve the type arguments of this object type as they were
   /// written.
   ArrayRef getTypeArgsAsWritten() const {
-return ArrayRef(getTypeArgStorage(),
+return llvm::makeArrayRef(getTypeArgStorage(),
   ObjCObjectTypeBits.NumTypeArgs);
   }
 

Modified: cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h?rev=248678&r1=248677&r2=248678&view=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/ThreadSafetyTIL.h Sat Sep 26 
22:44:08 2015
@@ -1395,7 +1395,7 @@ public:
 
   /// Return the list of basic blocks that this terminator can branch to.
   ArrayRef successors() {
-return ArrayRef(&TargetBlock, 1);
+return llvm::makeArrayRef(TargetBlock);
   }
 
   template 
@@ -1445,7 +1445,7 @@ public:
 
   /// Return the list of basic blocks that this terminator can branch to.
   ArrayRef successors() {
-return ArrayRef(Branches, 2);
+return llvm::makeArrayRef(Branches);
   }
 
   template 

Modified: cfe/trunk/lib/AST/ASTImporter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTImporter.cpp?rev=248678&r1=248677&r2=248678&view=diff
==
--- cfe/trunk/lib/AST/ASTImporter.cpp (original)
+++ cfe/trunk/lib/AST/ASTImporter.cpp Sat Sep 26 22:44:08 2015
@@ -5329,7 +5329,7 @@ Expr *ASTNodeImporter::VisitCallExpr(Cal
 
   return new (Importer.getToContext())
 CallExpr(Importer.getToContext(), ToCallee, 
- ArrayRef(ToArgs_Copied, NumArgs), T, E->getValueKind(),
+ llvm::makeArrayRef(ToArgs_Copied, NumArgs), T, E->getValueKind(),
  Importer.Import(E->getRParenLoc()));
 }
 

Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=248678&r1=248677&r2=248678&view=diff
==
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Sat Sep 26 22:44:08 2015
@@ -2825,7 +2825,7 @@ CodeGenModule::GetAddrOfConstantCFString
   // String pointer.
   llvm::Constant *C = nullptr;
   if (isUTF16) {
-ArrayRef Arr = llvm::makeArrayRef(
+auto Arr = llvm::makeArrayRef(
 reinterpret_cast(const_cast(Entry.first().data())),
 Entry.first().size() / 2);
 C = llvm::ConstantDataArray::get(VMContext, Arr);

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=248678&r1=248677&r2=248678&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Sat Sep 26 22:44:08 2015
@@ -208,7 +208,7 @@ namespace clang {
   auto &&PartialSpecializations = getPartialSpecializations(Common);
   ArrayRef LazySpecializations;
   if (auto *LS = Common->LazySpecializations)
-LazySpecializations = ArrayRef(LS + 1, LS + 1 + LS[0]);
+LazySpecializations = llvm::makeArrayRef(LS + 1, LS + 1 + LS[0]);
 
   // Add a slot to the record for the number of specializations.
   unsigned I = Record.size();


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


Re: [clang-tools-extra] r248438 - Fix loop-convert for trivially copyable types.

2015-09-26 Thread comex via cfe-commits
On Thu, Sep 24, 2015 at 7:28 AM, Manuel Klimek via cfe-commits
 wrote:
> Fix loop-convert for trivially copyable types.

If I'm not misunderstanding the patch, "trivially copyable" by itself
seems like a suboptimal test.  After all, "trivial" can still include
an expensive memcpy of a large struct.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D12686: Add support for GCC's '__auto_type' extension.

2015-09-26 Thread Nicholas Allegra via cfe-commits
comex added a comment.

Ping?


http://reviews.llvm.org/D12686



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


Re: [clang-tools-extra] r248438 - Fix loop-convert for trivially copyable types.

2015-09-26 Thread Manuel Klimek via cfe-commits
Yep. We'll make it better by limiting the size, but trivially copyable is
an improvement, as there are orders of magnitude more loops over small
copyable types than over large ones.

On Sat, Sep 26, 2015, 9:02 PM comex  wrote:

> On Thu, Sep 24, 2015 at 7:28 AM, Manuel Klimek via cfe-commits
>  wrote:
> > Fix loop-convert for trivially copyable types.
>
> If I'm not misunderstanding the patch, "trivially copyable" by itself
> seems like a suboptimal test.  After all, "trivial" can still include
> an expensive memcpy of a large struct.
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits