Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap marked 4 inline comments as done.
alexshap added a comment.

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap removed rL LLVM as the repository for this revision.
alexshap updated this revision to Diff 68955.
alexshap added a comment.

Get rid of sed in tests


https://reviews.llvm.org/D23279

Files:
  CMakeLists.txt
  clang-reorder-fields/CMakeLists.txt
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-reorder-fields/ReorderFieldsAction.h
  clang-reorder-fields/tool/CMakeLists.txt
  clang-reorder-fields/tool/ClangReorderFields.cpp
  test/CMakeLists.txt
  test/clang-reorder-fields/CStructAmbiguousName.cpp
  test/clang-reorder-fields/CStructFieldsOrder.cpp
  test/clang-reorder-fields/ClassMixedInitialization.cpp
  test/clang-reorder-fields/ClassSimpleCtor.cpp

Index: test/clang-reorder-fields/ClassSimpleCtor.cpp
===
--- test/clang-reorder-fields/ClassSimpleCtor.cpp
+++ test/clang-reorder-fields/ClassSimpleCtor.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-reorder-fields -record-name Foo -fields-order s1,x,z,s2 %s -- | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK:  {{^  const char \*s1;}}
+  const char *s1; // CHECK-NEXT: {{^  int x;}}
+  const char *s2; // CHECK-NEXT: {{^  double z;}}
+  double z;   // CHECK-NEXT: {{^  const char \*s2;}}
+};
+
+Foo::Foo():
+  x(12),  // CHECK:  {{^  s1\("abc"\),}}
+  s1("abc"),  // CHECK-NEXT: {{^  x\(12\),}}
+  s2("def"),  // CHECK-NEXT: {{^  z\(3.14\),}}
+  z(3.14) // CHECK-NEXT: {{^  s2\("def"\)}}
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/ClassMixedInitialization.cpp
===
--- test/clang-reorder-fields/ClassMixedInitialization.cpp
+++ test/clang-reorder-fields/ClassMixedInitialization.cpp
@@ -0,0 +1,24 @@
+// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,s2,s1 %s -- -std=c++11 | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK:  {{^  double e = 2.71;}}
+  const char *s1; // CHECK-NEXT: {{^  int x;}}
+  const char *s2; // CHECK-NEXT: {{^  double pi = 3.14;}}
+  double pi = 3.14;   // CHECK-NEXT: {{^  const char \*s2;}}
+  double e = 2.71;// CHECK-NEXT: {{^  const char \*s1;}}
+};
+
+Foo::Foo():
+  x(12),  // CHECK:  {{^  x\(12\)}},
+  s1("abc"),  // CHECK-NEXT: {{^  s2\("def"\)}},
+  s2("def")   // CHECK-NEXT: {{^  s1\("abc"\)}}
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldsOrder.cpp
===
--- test/clang-reorder-fields/CStructFieldsOrder.cpp
+++ test/clang-reorder-fields/CStructFieldsOrder.cpp
@@ -0,0 +1,16 @@
+// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %s -- | FileCheck %s
+
+namespace bar {
+struct Foo {
+  const int* x; // CHECK:  {{^  double z;}}
+  int y;// CHECK-NEXT: {{^  int w;}}
+  double z; // CHECK-NEXT: {{^  int y;}}
+  int w;// CHECK-NEXT: {{^  const int\* x}}
+};
+} // end namespace bar
+
+int main() {
+  const int x = 13;
+  bar::Foo foo = { , 0, 1.29, 17 }; // CHECK: {{^  bar::Foo foo = { 1.29, 17, 0,  };}} 
+  return 0;
+}
Index: test/clang-reorder-fields/CStructAmbiguousName.cpp
===
--- test/clang-reorder-fields/CStructAmbiguousName.cpp
+++ test/clang-reorder-fields/CStructAmbiguousName.cpp
@@ -0,0 +1,18 @@
+// RUN: clang-reorder-fields -record-name ::Foo -fields-order y,x %s -- | FileCheck %s
+
+struct Foo {
+  int x;// CHECK:  {{^  double y;}}
+  double y; // CHECK-NEXT: {{^  int x;}}
+};
+
+namespace bar {
+struct Foo {
+  int x;// CHECK:  {{^  int x;}}
+  double y; // CHECK-NEXT: {{^  double y;}}
+};
+} // end namespace bar
+
+int main() {
+  bar::Foo foo = { 1, 1.7 }; // CHECK: {{^  bar::Foo foo = { 1, 1.7 };}}
+  return 0;
+}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -45,6 +45,7 @@
   clang-include-fixer
   clang-query
   clang-rename
+  clang-reorder-fields
   clang-tidy
   find-all-symbols
   modularize
Index: clang-reorder-fields/tool/ClangReorderFields.cpp
===
--- clang-reorder-fields/tool/ClangReorderFields.cpp
+++ clang-reorder-fields/tool/ClangReorderFields.cpp
@@ -0,0 +1,104 @@
+//===-- tools/extra/clang-reorder-fields/tool/ClangReorderFields.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the implementation of clang-reorder-fields tool
+///
+//===--===//
+
+#include 

Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

> but by this moment i have not figured out yet how to make it happen.


oh, i see, let me check - i will update this diff


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

@aaron.ballman
thanks, yeah, i understand ur concerns that now we have zero tests that can run 
on windows.
To be honest i would prefer not to depend on sed, cat etc at all and have most 
of the tests (i would prefer all of them) running on windows - but by this 
moment i have not figured out yet how to make it happen.

P.S. (yeah, just fun fact, nothing else, as i said above - we do need normal 
tests which can run on windows - i agree with you)

> Correct, but those tools have other tests that ensure they work on Windows 
> (though those features are unfortunately >untested)


alexshap-mbp:clang-rename alexshap$ ls -a | grep cpp | while read F; do echo 
"$F `grep 'sed ' $F | grep RUN | wc -l`"; done
ClassAsTemplateArgument.cpp 2
ClassFindByName.cpp 1
ClassReplacements.cpp 1
ClassSimpleRenaming.cpp 2
ClassTestMulti.cpp 1
ClassTestMultiByName.cpp 1
ClassTestMultiByNameYAML.cpp 2
ComplexFunctionOverride.cpp 5
ComplicatedClassType.cpp 7
Ctor.cpp 2
CtorInitializer.cpp 2
DeclRefExpr.cpp 3
Field.cpp 2
FunctionMacro.cpp 1
FunctionOverride.cpp 3
FunctionWithClassFindByName.cpp 1
InvalidNewName.cpp 0
MemberExprMacro.cpp 2
Namespace.cpp 1
NoNewName.cpp 0
TemplateClassInstantiation.cpp 3
TemplateTypename.cpp 3
UserDefinedConversion.cpp 2
Variable.cpp 4
VariableMacro.cpp 3
alexshap-mbp:clang-rename alexshap$ pwd
/Users/alexshap/LLVM/llvm/tools/clang/tools/extra/test/clang-rename


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D22666: Frontend: Fix mcount inlining bug

2016-08-22 Thread Honggyu Kim via cfe-commits
honggyu.kim added a reviewer: compnerd.
honggyu.kim removed a subscriber: compnerd.
honggyu.kim updated this revision to Diff 68954.
honggyu.kim added a comment.

I have fixed SOH character problem by https://reviews.llvm.org/D23792.  I've 
verified that mcount.c and gnu-mcount.c tests are passed now.

  $ llvm-lit tools/clang/test/CodeGen/mcount.c
  -- Testing: 1 tests, 1 threads --
  PASS: Clang :: CodeGen/mcount.c (1 of 1)
  Testing Time: 0.81s
Expected Passes: 1
  
  $ llvm-lit tools/clang/test/Frontend/gnu-mcount.c
  -- Testing: 1 tests, 1 threads --
  PASS: Clang :: Frontend/gnu-mcount.c (1 of 1)
  Testing Time: 10.36s
Expected Passes: 1

I think it's almost ready to be commited now.  So please have a look at it with 
https://reviews.llvm.org/D23792.


https://reviews.llvm.org/D22666

Files:
  lib/CodeGen/CodeGenFunction.cpp
  test/CodeGen/mcount.c
  test/Frontend/gnu-mcount.c

Index: test/Frontend/gnu-mcount.c
===
--- test/Frontend/gnu-mcount.c
+++ test/Frontend/gnu-mcount.c
@@ -44,35 +44,35 @@
 }
 
 // CHECK-LABEL: f
-// CHECK-ARM-IOS-NOT: call void @_mcount()
-// CHECK-ARM-IOS-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI: call void @"\01mcount"()
-// CHECK-ARM-EABI-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM64-EABI: call void @mcount()
-// CHECK-ARM64-EABI-MEABI-GNU: call void @"\01_mcount"()
-// CHECK-ARM64-EABI-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI-FREEBSD: call void @__mcount()
-// CHECK-ARM-EABI-FREEBSD-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM64-EABI-FREEBSD: call void @.mcount()
-// CHECK-ARM64-EABI-FREEBSD-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI-NETBSD: call void @_mcount()
-// CHECK-ARM-EABI-NETBSD-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI-OPENBSD: call void @__mcount()
-// CHECK-ARM-EABI-OPENBSD-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM64-EABI-OPENBSD: call void @mcount()
-// CHECK-ARM64-EABI-OPENBSD-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI-MEABI-GNU-NOT: call void @mcount()
-// CHECK-ARM-EABI-MEABI-GNU: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI-BITRIG: call void @__mcount()
-// CHECK-ARM-EABI-BITRIG-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM54-EABI-BITRIG: call void @mcount()
-// CHECK-ARM54-EABI-BITRIG-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI-RTEMS: call void @mcount()
-// CHECK-ARM-EABI-RTEMS-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM64-EABI-RTEMS: call void @mcount()
-// CHECK-ARM64-EABI-RTEMS-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM-EABI-CLOUDABI: call void @mcount()
-// CHECK-ARM-EABI-CLOUDABI-NOT: call void @"\01__gnu_mcount_nc"()
-// CHECK-ARM64-EABI-CLOUDABI: call void @mcount()
-// CHECK-ARM64-EABI-CLOUDABI-NOT: call void @"\01__gnu_mcount_nc"()
+// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="_mcount"{{.*}} }
+// CHECK-ARM-IOS-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01mcount"{{.*}} }
+// CHECK-ARM-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM64-EABI: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
+// CHECK-ARM64-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01_mcount"{{.*}} }
+// CHECK-ARM64-EABI-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-EABI-FREEBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
+// CHECK-ARM-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM64-EABI-FREEBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"=".mcount"{{.*}} }
+// CHECK-ARM64-EABI-FREEBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-EABI-NETBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="_mcount"{{.*}} }
+// CHECK-ARM-EABI-NETBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
+// CHECK-ARM-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM64-EABI-OPENBSD: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
+// CHECK-ARM64-EABI-OPENBSD-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-EABI-MEABI-GNU-NOT: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="mcount"{{.*}} }
+// CHECK-ARM-EABI-MEABI-GNU: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="\01__gnu_mcount_nc"{{.*}} }
+// CHECK-ARM-EABI-BITRIG: attributes #{{[0-9]+}} = { {{.*}}"counting-function"="__mcount"{{.*}} }
+// CHECK-ARM-EABI-BITRIG-NOT: 

Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap updated this revision to Diff 68953.
alexshap added a comment.

Drop support of -field-pos for now


Repository:
  rL LLVM

https://reviews.llvm.org/D23279

Files:
  CMakeLists.txt
  clang-reorder-fields/CMakeLists.txt
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-reorder-fields/ReorderFieldsAction.h
  clang-reorder-fields/tool/CMakeLists.txt
  clang-reorder-fields/tool/ClangReorderFields.cpp
  test/CMakeLists.txt
  test/clang-reorder-fields/CStructAmbiguousName.cpp
  test/clang-reorder-fields/CStructFieldsOrder.cpp
  test/clang-reorder-fields/ClassMixedInitialization.cpp
  test/clang-reorder-fields/ClassSimpleCtor.cpp

Index: test/clang-reorder-fields/ClassSimpleCtor.cpp
===
--- test/clang-reorder-fields/ClassSimpleCtor.cpp
+++ test/clang-reorder-fields/ClassSimpleCtor.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order s1,x,z,s2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK: const char *s1;
+  const char *s1; // CHECK: int x;
+  const char *s2; // CHECK: double z;
+  double z;   // CHECK: const char *s2;
+};
+
+Foo::Foo():
+  x(12),  // CHECK: s1("abc"),
+  s1("abc"),  // CHECK: x(12),
+  s2("def"),  // CHECK: z(3.14),
+  z(3.14) // CHECK: s2("def")
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/ClassMixedInitialization.cpp
===
--- test/clang-reorder-fields/ClassMixedInitialization.cpp
+++ test/clang-reorder-fields/ClassMixedInitialization.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,s2,s1 %t.cpp -i -- -std=c++11
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK: double e = 2.71;
+  const char *s1; // CHECK: int x;
+  const char *s2; // CHECK: double pi = 3.14;
+  double pi = 3.14;   // CHECK: const char *s2;
+  double e = 2.71;// CHECK: const char *s1;
+};
+
+Foo::Foo():
+  x(12),  // CHECK: x(12),
+  s1("abc"),  // CHECK: s2("def"),
+  s2("def")   // CHECK: s1("abc")
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldsOrder.cpp
===
--- test/clang-reorder-fields/CStructFieldsOrder.cpp
+++ test/clang-reorder-fields/CStructFieldsOrder.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace bar {
+struct Foo {
+  const int* x; // CHECK: double z;
+  int y;// CHECK: int w;
+  double z; // CHECK: int y;
+  int w;// CHECK: const int* x;
+};
+} // end namespace bar
+
+int main() {
+  const int x = 13;
+  bar::Foo foo = { , 17, 1.29, 0 }; // CHECK: bar::Foo foo = { 1.29, 0, 17,  };
+  return 0;
+}
Index: test/clang-reorder-fields/CStructAmbiguousName.cpp
===
--- test/clang-reorder-fields/CStructAmbiguousName.cpp
+++ test/clang-reorder-fields/CStructAmbiguousName.cpp
@@ -0,0 +1,20 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+
+namespace bar {
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+} // end namespace bar
+
+int main() {
+  Foo foo = { 1, 1.7 }; // CHECK: Foo foo = { 1, 1.7 };
+  return 0;
+}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -45,6 +45,7 @@
   clang-include-fixer
   clang-query
   clang-rename
+  clang-reorder-fields
   clang-tidy
   find-all-symbols
   modularize
Index: clang-reorder-fields/tool/ClangReorderFields.cpp
===
--- clang-reorder-fields/tool/ClangReorderFields.cpp
+++ clang-reorder-fields/tool/ClangReorderFields.cpp
@@ -0,0 +1,104 @@
+//===-- tools/extra/clang-reorder-fields/tool/ClangReorderFields.cpp -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+///
+/// \file
+/// This file contains the implementation of clang-reorder-fields tool
+///
+//===--===//
+
+#include "../ReorderFieldsAction.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
+#include 

Re: [PATCH] D23791: [libc++] Perform configuration checks with -nodefaultlibs

2016-08-22 Thread Eric Fiselier via cfe-commits
What platforms was this tested on?

On Aug 22, 2016 9:20 PM, "Shoaib Meenai"  wrote:

> smeenai created this revision.
> smeenai added reviewers: beanz, compnerd, EricWF, mclow.lists, rsmith.
> smeenai added a subscriber: cfe-commits.
>
> We're compiling libc++ with -nodefaultlibs, so we should also pass this
> option during the configuration checks to ensure those checks are
> consistent with the actual build.
>
> The primary motivation here is to ease cross-compilation against a
> non-standard set of C++ libraries. Previously, the configuration checks
> would attempt to link against the standard C++ libraries, which would
> cause link failures when cross-compiling, even though the actual library
> link would go through correctly (because of the use of -nodefaultlibs
> and explicitly specifying any needed libraries). This is more correct
> even ignoring the motivation, however.
>
> https://reviews.llvm.org/D23791
>
> Files:
>   cmake/config-ix.cmake
>
> Index: cmake/config-ix.cmake
> ===
> --- cmake/config-ix.cmake
> +++ cmake/config-ix.cmake
> @@ -1,5 +1,26 @@
>  include(CheckLibraryExists)
>  include(CheckCXXCompilerFlag)
> +
> +check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
> +check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
> +
> +# libc++ is built with -nodefaultlibs, so we want all our checks to also
> +# use this option, otherwise we may end up with an inconsistency between
> +# the flags we think we require during configuration (if the checks are
> +# performed without -nodefaultlibs) and the flags that are actually
> +# required during compilation (which has the -nodefaultlibs). libc is
> +# required for the link to go through.
> +check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_
> FLAG)
> +if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
> +  list(APPEND CMAKE_REQUIRED_LIBRARIES -nodefaultlibs)
> +  if (LIBCXX_HAS_C_LIB)
> +list(APPEND CMAKE_REQUIRED_LIBRARIES c)
> +  endif ()
> +  if (LIBCXX_HAS_GCC_S_LIB)
> +list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
> +  endif ()
> +endif ()
> +
>  include(CheckLibcxxAtomic)
>
>  # Check compiler flags
> @@ -14,7 +35,5 @@
>
>  # Check libraries
>  check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
> -check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
>  check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
>  check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
> -check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D23791: [libc++] Perform configuration checks with -nodefaultlibs

2016-08-22 Thread Shoaib Meenai via cfe-commits
smeenai created this revision.
smeenai added reviewers: beanz, compnerd, EricWF, mclow.lists, rsmith.
smeenai added a subscriber: cfe-commits.

We're compiling libc++ with -nodefaultlibs, so we should also pass this
option during the configuration checks to ensure those checks are
consistent with the actual build.

The primary motivation here is to ease cross-compilation against a
non-standard set of C++ libraries. Previously, the configuration checks
would attempt to link against the standard C++ libraries, which would
cause link failures when cross-compiling, even though the actual library
link would go through correctly (because of the use of -nodefaultlibs
and explicitly specifying any needed libraries). This is more correct
even ignoring the motivation, however.

https://reviews.llvm.org/D23791

Files:
  cmake/config-ix.cmake

Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -1,5 +1,26 @@
 include(CheckLibraryExists)
 include(CheckCXXCompilerFlag)
+
+check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
+
+# libc++ is built with -nodefaultlibs, so we want all our checks to also
+# use this option, otherwise we may end up with an inconsistency between
+# the flags we think we require during configuration (if the checks are
+# performed without -nodefaultlibs) and the flags that are actually
+# required during compilation (which has the -nodefaultlibs). libc is
+# required for the link to go through.
+check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES -nodefaultlibs)
+  if (LIBCXX_HAS_C_LIB)
+list(APPEND CMAKE_REQUIRED_LIBRARIES c)
+  endif ()
+  if (LIBCXX_HAS_GCC_S_LIB)
+list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+  endif ()
+endif ()
+
 include(CheckLibcxxAtomic)
 
 # Check compiler flags
@@ -14,7 +35,5 @@
 
 # Check libraries
 check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
-check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
 check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
 check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
-check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)


Index: cmake/config-ix.cmake
===
--- cmake/config-ix.cmake
+++ cmake/config-ix.cmake
@@ -1,5 +1,26 @@
 include(CheckLibraryExists)
 include(CheckCXXCompilerFlag)
+
+check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
+check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
+
+# libc++ is built with -nodefaultlibs, so we want all our checks to also
+# use this option, otherwise we may end up with an inconsistency between
+# the flags we think we require during configuration (if the checks are
+# performed without -nodefaultlibs) and the flags that are actually
+# required during compilation (which has the -nodefaultlibs). libc is
+# required for the link to go through.
+check_cxx_compiler_flag(-nodefaultlibs LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
+if (LIBCXX_SUPPORTS_NODEFAULTLIBS_FLAG)
+  list(APPEND CMAKE_REQUIRED_LIBRARIES -nodefaultlibs)
+  if (LIBCXX_HAS_C_LIB)
+list(APPEND CMAKE_REQUIRED_LIBRARIES c)
+  endif ()
+  if (LIBCXX_HAS_GCC_S_LIB)
+list(APPEND CMAKE_REQUIRED_LIBRARIES gcc_s)
+  endif ()
+endif ()
+
 include(CheckLibcxxAtomic)
 
 # Check compiler flags
@@ -14,7 +35,5 @@
 
 # Check libraries
 check_library_exists(pthread pthread_create "" LIBCXX_HAS_PTHREAD_LIB)
-check_library_exists(c fopen "" LIBCXX_HAS_C_LIB)
 check_library_exists(m ccos "" LIBCXX_HAS_M_LIB)
 check_library_exists(rt clock_gettime "" LIBCXX_HAS_RT_LIB)
-check_library_exists(gcc_s __gcc_personality_v0 "" LIBCXX_HAS_GCC_S_LIB)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r279486 - Fix regression introduced by r279164: only pass definitions as the PatternDef

2016-08-22 Thread Chandler Carruth via cfe-commits
Reverted this per Richard's request in r279500.

On Mon, Aug 22, 2016 at 3:33 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Mon Aug 22 17:25:03 2016
> New Revision: 279486
>
> URL: http://llvm.org/viewvc/llvm-project?rev=279486=rev
> Log:
> Fix regression introduced by r279164: only pass definitions as the
> PatternDef
> to DiagnoseUninstantiableTemplate, teach hasVisibleDefinition to correctly
> determine whether a function definition is visible, and mark both the
> function
> and the template as visible when merging function template definitions to
> provide hasVisibleDefinition with the relevant information.
>
> The change to always pass the right declaration as the PatternDef to
> DiagnoseUninstantiableTemplate also caused those checks to happen before
> other
> diagnostics in InstantiateFunctionDefinition, giving worse diagnostics for
> the
> same situations, so I sunk the relevant diagnostics into
> DiagnoseUninstantiableTemplate. Those parts of this patch are based on
> changes
> in reviews.llvm.org/D23492 by Vassil Vassilev.
>
> Modified:
> cfe/trunk/lib/Sema/SemaDecl.cpp
> cfe/trunk/lib/Sema/SemaTemplate.cpp
> cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
> cfe/trunk/lib/Sema/SemaType.cpp
> cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h
> cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h
> cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=279486=279485=279486=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Aug 22 17:25:03 2016
> @@ -11274,9 +11274,8 @@ Sema::CheckForFunctionRedefinition(Funct
>  SkipBody->ShouldSkip = true;
>  if (auto *TD = Definition->getDescribedFunctionTemplate())
>makeMergedDefinitionVisible(TD, FD->getLocation());
> -else
> -  makeMergedDefinitionVisible(const_cast(Definition),
> -  FD->getLocation());
> +makeMergedDefinitionVisible(const_cast(Definition),
> +FD->getLocation());
>  return;
>}
>
>
> Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=279486=279485=279486=diff
>
> ==
> --- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Aug 22 17:25:03 2016
> @@ -487,8 +487,6 @@ bool Sema::DiagnoseUninstantiableTemplat
>QualType InstantiationTy;
>if (TagDecl *TD = dyn_cast(Instantiation))
>  InstantiationTy = Context.getTypeDeclType(TD);
> -  else
> -InstantiationTy = cast(Instantiation)->getType();
>if (!Complain || (PatternDef && PatternDef->isInvalidDecl())) {
>  // Say nothing
>} else if (PatternDef) {
> @@ -500,15 +498,30 @@ bool Sema::DiagnoseUninstantiableTemplat
>  // we're lexically inside it.
>  Instantiation->setInvalidDecl();
>} else if (InstantiatedFromMember) {
> -Diag(PointOfInstantiation,
> - diag::err_implicit_instantiate_member_undefined)
> -  << InstantiationTy;
> -Diag(Pattern->getLocation(), diag::note_member_declared_at);
> +if (isa(Instantiation)) {
> +  Diag(PointOfInstantiation,
> +   diag::err_explicit_instantiation_undefined_member)
> +<< 1 << Instantiation->getDeclName() <<
> Instantiation->getDeclContext();
> +} else {
> +  Diag(PointOfInstantiation,
> +   diag::err_implicit_instantiate_member_undefined)
> +<< InstantiationTy;
> +}
> +Diag(Pattern->getLocation(), isa(Instantiation)
> + ?
> diag::note_explicit_instantiation_here
> + : diag::note_member_declared_at);
>} else {
> -Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
> -  << (TSK != TSK_ImplicitInstantiation)
> -  << InstantiationTy;
> -Diag(Pattern->getLocation(), diag::note_template_decl_here);
> +if (isa(Instantiation))
> +  Diag(PointOfInstantiation,
> +   diag::err_explicit_instantiation_undefined_func_template)
> +<< Pattern;
> +else
> +  Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
> +<< (TSK != TSK_ImplicitInstantiation)
> +<< InstantiationTy;
> +Diag(Pattern->getLocation(), isa(Instantiation)
> + ?
> diag::note_explicit_instantiation_here
> + : diag::note_template_decl_here);
>}
>
>// In general, Instantiation isn't marked invalid to get more than one
>
> Modified: 

r279500 - Revert r279486 "Fix regression introduced by r279164"

2016-08-22 Thread Chandler Carruth via cfe-commits
Author: chandlerc
Date: Mon Aug 22 21:00:51 2016
New Revision: 279500

URL: http://llvm.org/viewvc/llvm-project?rev=279500=rev
Log:
Revert r279486 "Fix regression introduced by r279164"

Build bots seem unhappy and as Richard was leaving he asked me to revert
this for him. Doing so.

Modified:
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/a.h
cfe/trunk/test/Modules/Inputs/merge-template-pattern-visibility/b.h
cfe/trunk/test/Modules/merge-template-pattern-visibility.cpp

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=279500=279499=279500=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Mon Aug 22 21:00:51 2016
@@ -11274,8 +11274,9 @@ Sema::CheckForFunctionRedefinition(Funct
 SkipBody->ShouldSkip = true;
 if (auto *TD = Definition->getDescribedFunctionTemplate())
   makeMergedDefinitionVisible(TD, FD->getLocation());
-makeMergedDefinitionVisible(const_cast(Definition),
-FD->getLocation());
+else
+  makeMergedDefinitionVisible(const_cast(Definition),
+  FD->getLocation());
 return;
   }
 

Modified: cfe/trunk/lib/Sema/SemaTemplate.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplate.cpp?rev=279500=279499=279500=diff
==
--- cfe/trunk/lib/Sema/SemaTemplate.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplate.cpp Mon Aug 22 21:00:51 2016
@@ -487,6 +487,8 @@ bool Sema::DiagnoseUninstantiableTemplat
   QualType InstantiationTy;
   if (TagDecl *TD = dyn_cast(Instantiation))
 InstantiationTy = Context.getTypeDeclType(TD);
+  else
+InstantiationTy = cast(Instantiation)->getType();
   if (!Complain || (PatternDef && PatternDef->isInvalidDecl())) {
 // Say nothing
   } else if (PatternDef) {
@@ -498,30 +500,15 @@ bool Sema::DiagnoseUninstantiableTemplat
 // we're lexically inside it.
 Instantiation->setInvalidDecl();
   } else if (InstantiatedFromMember) {
-if (isa(Instantiation)) {
-  Diag(PointOfInstantiation,
-   diag::err_explicit_instantiation_undefined_member)
-<< 1 << Instantiation->getDeclName() << 
Instantiation->getDeclContext();
-} else {
-  Diag(PointOfInstantiation,
-   diag::err_implicit_instantiate_member_undefined)
-<< InstantiationTy;
-}
-Diag(Pattern->getLocation(), isa(Instantiation)
- ? diag::note_explicit_instantiation_here
- : diag::note_member_declared_at);
+Diag(PointOfInstantiation,
+ diag::err_implicit_instantiate_member_undefined)
+  << InstantiationTy;
+Diag(Pattern->getLocation(), diag::note_member_declared_at);
   } else {
-if (isa(Instantiation))
-  Diag(PointOfInstantiation,
-   diag::err_explicit_instantiation_undefined_func_template)
-<< Pattern;
-else
-  Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
-<< (TSK != TSK_ImplicitInstantiation)
-<< InstantiationTy;
-Diag(Pattern->getLocation(), isa(Instantiation)
- ? diag::note_explicit_instantiation_here
- : diag::note_template_decl_here);
+Diag(PointOfInstantiation, diag::err_template_instantiate_undefined)
+  << (TSK != TSK_ImplicitInstantiation)
+  << InstantiationTy;
+Diag(Pattern->getLocation(), diag::note_template_decl_here);
   }
 
   // In general, Instantiation isn't marked invalid to get more than one

Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=279500=279499=279500=diff
==
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Mon Aug 22 21:00:51 2016
@@ -3554,38 +3554,23 @@ void Sema::InstantiateFunctionDefinition
   const FunctionDecl *PatternDecl = 
Function->getTemplateInstantiationPattern();
   assert(PatternDecl && "instantiating a non-template");
 
-  const FunctionDecl *PatternDef = PatternDecl->getDefinition();
-  Stmt *Pattern = PatternDef->getBody(PatternDef);
-  if (PatternDef)
-PatternDecl = PatternDef;
+  Stmt *Pattern = PatternDecl->getBody(PatternDecl);
+  assert(PatternDecl && "template definition is not a template");
+  if (!Pattern) {
+// Try to find a defaulted definition
+PatternDecl->isDefined(PatternDecl);
+  }
+  

Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I think quite a bit of the complexity in this patch stems from the two 
different ways to format the input (defining the field order or alternatively 
defining the new index of specific fields). Do we really need both? If not, I'd 
remove one of them for now (likely the index-based one). If we do need both, 
I'd still remove the index-based version from ReorderFieldsAction and instead 
provide a helper that converts from one to the other. Or maybe we should even 
go one step further and move the entire name-to-index-mapping into helper 
functions and only hand an index-to-index mapping into ReorderFieldsAction. 
That way, it doesn't need a lot of its error handing. (All of these thoughts 
are based on the single responsibility principle).


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In https://reviews.llvm.org/D23279#522779, @alexshap wrote:

> @aaron.ballman
>  Thanks, yeah, there is an issue. Also there are inline-comments by @bcraig 
> and @compnerd about the tests.
>  I used clang-rename, include-fixer, clang-tidy as examples.


Correct, but those tools have other tests that ensure they work on Windows 
(though those features are unfortunately untested), while this tool has *zero* 
tests that will run on Windows.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

@aaron.ballman
Thanks, yeah, there is an issue. Also there are inline-comments by @bcraig and 
@compnerd about the tests.
I used clang-rename, include-fixer, clang-tidy as examples.

alexshap-mbp:extra alexshap$ grep -r -n "sed -e " ./* | head -n 5

./test/clang-tidy/modernize-pass-by-value-multi-fixes.cpp:2:// RUN: sed -e 
's#//.*$##' %s > %t.cpp
./test/include-fixer/exit_on_fatal.cpp:1:// RUN: sed -e 's#//.*$##' %s > %t.cpp
./test/include-fixer/fixeddb.cpp:1:// RUN: sed -e 's#//.*$##' %s > %t.cpp
./test/include-fixer/multiple_fixes.cpp:2:// RUN: sed -e 's#//.*$##' %s > %t.cpp
./test/include-fixer/prefix_variable.cpp:1:// RUN: sed -e 's#//.*$##' %s > 
%t.cpp

alexshap-mbp:test alexshap$ grep -r -n "sed " ./*  | grep rename | head -n 5

./clang-rename/ClassAsTemplateArgument.cpp:16:// RUN: clang-rename -offset=7 
-new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
./clang-rename/ClassAsTemplateArgument.cpp:18:// RUN: clang-rename -offset=215 
-new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
./clang-rename/ClassFindByName.cpp:10:// RUN: clang-rename rename-all 
-old-name=Foo -new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s
./clang-rename/ClassReplacements.cpp:6:// RUN: sed 's,//.*,,' %t.cpp | 
FileCheck %s
./clang-rename/ClassSimpleRenaming.cpp:9:// RUN: clang-rename -offset=6 
-new-name=Bar %s -- | sed 's,//.*,,' | FileCheck %s


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

None of your tests will run on Windows, which makes me worried if that's 
intended to be a supported target.


https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap removed rL LLVM as the repository for this revision.
alexshap changed the visibility of this Differential Revision from "All Users" 
to "Public (No Login Required)".
alexshap updated this revision to Diff 68943.
alexshap added a comment.

Fix typo


https://reviews.llvm.org/D23279

Files:
  CMakeLists.txt
  clang-reorder-fields/CMakeLists.txt
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-reorder-fields/ReorderFieldsAction.h
  clang-reorder-fields/tool/CMakeLists.txt
  clang-reorder-fields/tool/ClangReorderFields.cpp
  test/CMakeLists.txt
  test/clang-reorder-fields/CStructAmbiguousName.cpp
  test/clang-reorder-fields/CStructFieldPos.cpp
  test/clang-reorder-fields/CStructFieldsOrder.cpp
  test/clang-reorder-fields/ClassMixedInitialization.cpp
  test/clang-reorder-fields/ClassSimpleCtor.cpp

Index: test/clang-reorder-fields/ClassSimpleCtor.cpp
===
--- test/clang-reorder-fields/ClassSimpleCtor.cpp
+++ test/clang-reorder-fields/ClassSimpleCtor.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order s1,x,z,s2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK: const char *s1;
+  const char *s1; // CHECK: int x;
+  const char *s2; // CHECK: double z;
+  double z;   // CHECK: const char *s2;
+};
+
+Foo::Foo():
+  x(12),  // CHECK: s1("abc"),
+  s1("abc"),  // CHECK: x(12),
+  s2("def"),  // CHECK: z(3.14),
+  z(3.14) // CHECK: s2("def")
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/ClassMixedInitialization.cpp
===
--- test/clang-reorder-fields/ClassMixedInitialization.cpp
+++ test/clang-reorder-fields/ClassMixedInitialization.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,s2,s1 %t.cpp -i -- -std=c++11
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK: double e = 2.71;
+  const char *s1; // CHECK: int x;
+  const char *s2; // CHECK: double pi = 3.14;
+  double pi = 3.14;   // CHECK: const char *s2;
+  double e = 2.71;// CHECK: const char *s1;
+};
+
+Foo::Foo():
+  x(12),  // CHECK: x(12),
+  s1("abc"),  // CHECK: s2("def"),
+  s2("def")   // CHECK: s1("abc")
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldsOrder.cpp
===
--- test/clang-reorder-fields/CStructFieldsOrder.cpp
+++ test/clang-reorder-fields/CStructFieldsOrder.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace bar {
+struct Foo {
+  const int* x; // CHECK: double z;
+  int y;// CHECK: int w;
+  double z; // CHECK: int y;
+  int w;// CHECK: const int* x;
+};
+} // end namespace bar
+
+int main() {
+  const int x = 13;
+  bar::Foo foo = { , 17, 1.29, 0 }; // CHECK: bar::Foo foo = { 1.29, 0, 17,  };
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldPos.cpp
===
--- test/clang-reorder-fields/CStructFieldPos.cpp
+++ test/clang-reorder-fields/CStructFieldPos.cpp
@@ -0,0 +1,16 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name ::Foo -field-pos z:0 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+struct Foo {
+  const int* x; // CHECK: double z;
+  int y;// CHECK: const int* x;
+  double z; // CHECK: int y;
+  int w;// CHECK: int w;
+};
+
+int main() {
+  const int x = 13;
+  Foo foo = { , 17, 1.29, 0 }; // CHECK: Foo foo = { 1.29, , 17, 0 };
+  return 0;
+}
Index: test/clang-reorder-fields/CStructAmbiguousName.cpp
===
--- test/clang-reorder-fields/CStructAmbiguousName.cpp
+++ test/clang-reorder-fields/CStructAmbiguousName.cpp
@@ -0,0 +1,20 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+
+namespace bar {
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+} // end namespace bar
+
+int main() {
+  Foo foo = { 1, 1.7 }; // CHECK: Foo foo = { 1, 1.7 };
+  return 0;
+}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -45,6 +45,7 @@
   clang-include-fixer
   clang-query
   clang-rename
+  clang-reorder-fields
   clang-tidy
   find-all-symbols
   modularize
Index: clang-reorder-fields/tool/ClangReorderFields.cpp

Re: [PATCH] D22766: Handle -mlong-calls on Hexagon

2016-08-22 Thread Saleem Abdulrasool via cfe-commits
compnerd added a subscriber: compnerd.


Comment at: include/clang/Driver/Options.td:1380
@@ +1379,3 @@
+def mlong_calls : Flag<["-"], "mlong-calls">, Group,
+  HelpText<"ARM: Generate an indirect jump to enable jumps further than 64M, 
Hexagon: Generate constant-extended branches.">;
+def mno_long_calls : Flag<["-"], "mno-long-calls">, Group,

It seems a bit weird to have target specific descriptions.  AFAIK, the behavior 
is the same on all the targets: it generates branches which have full 
addressability (ARC, ARM, BlackFin, Epiphany, MIPS, PPC all support this 
option, probably amongst other architectures).  This would easily grow 
unwieldily if we try to have target specific descriptions.  We support at least 
ARM, MIPS, PPC, and now Hexagon.  Why not make the description generic, 
something like:

Generate branches with extended addressability, usually via indirect jumps.


Repository:
  rL LLVM

https://reviews.llvm.org/D22766



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


Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279494: Fix style in some Clang-tidy checks documentation. 
(authored by eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D23728?vs=68933=68941#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23728

Files:
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst

Index: clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
@@ -3,15 +3,18 @@
 google-global-names-in-headers
 ==
 
-Flag global namespace pollution in header files.
-Right now it only triggers on ``using`` declarations and directives.
-
-The check supports these options:
-  - `HeaderFileExtensions`: a comma-separated list of filename extensions
-of header files (the filename extensions should not contain "." prefix).
-"h" by default.
-For extension-less header files, using an empty string or leaving an
-empty string between "," if there are other filename extensions.
+Flag global namespace pollution in header files. Right now it only triggers on
+``using`` declarations and directives.
 
 The relevant style guide section is
 https://google.github.io/styleguide/cppguide.html#Namespaces.
+
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A comma-separated list of filename extensions of header files (the filename
+   extensions should not contain "." prefix). "h" by default. For extension-less
+   header files, using an empty string or leaving an empty string between ","
+   if there are other filename extensions.
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
@@ -8,21 +8,25 @@
 is misplaced, and there can be loss of precision. Otherwise the cast is
 ineffective.
 
-Example code::
+Example code:
+
+.. code-block:: c++
 
 long f(int x) {
-return (long)(x*1000);
+return (long)(x * 1000);
 }
 
-The result x*1000 is first calculated using int precision. If the result
-exceeds int precision there is loss of precision. Then the result is casted to
-long.
+The result ``x * 1000`` is first calculated using ``int`` precision. If the
+result exceeds ``int`` precision there is loss of precision. Then the result is
+casted to ``long``.
 
 If there is no loss of precision then the cast can be removed or you can
-explicitly cast to int instead.
+explicitly cast to ``int`` instead.
 
 If you want to avoid loss of precision then put the cast in a proper location,
-for instance::
+for instance:
+
+.. code-block:: c++
 
 long f(int x) {
 return (long)x * 1000;
@@ -32,8 +36,10 @@
 --
 
 Forgetting to place the cast at all is at least as dangerous and at least as
-common as misplacing it. If option ``CheckImplicitCasts`` is enabled (default)
-the checker also detects these cases, for instance::
+common as misplacing it. If :option:`CheckImplicitCasts` is enabled the check
+also detects these cases, for instance:
+
+.. code-block:: c++
 
 long f(int x) {
 return x * 1000;
@@ -43,8 +49,17 @@
 --
 
 Currently warnings are only written for integer conversion. No warning is
-written for this code::
+written for this code:
+
+.. code-block:: c++
 
 double f(float x) {
 return (double)(x * 10.0f);
 }
+
+Options
+---
+
+.. option:: CheckImplicitCasts
+
+   If non-zero, enables detection of implicit casts. Default is non-zero.
Index: clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst
===
--- clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst
@@ -11,14 +11,14 @@
 
 Before:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition)
 statement;
 
 After:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition) {
 statement;

[clang-tools-extra] r279494 - Fix style in some Clang-tidy checks documentation.

2016-08-22 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Aug 22 19:19:43 2016
New Revision: 279494

URL: http://llvm.org/viewvc/llvm-project?rev=279494=rev
Log:
Fix style in some Clang-tidy checks documentation.

Differential revision: https://reviews.llvm.org/D23728

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-misplaced-widening-cast.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-auto.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-braces-around-statements.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst?rev=279494=279493=279494=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
 Mon Aug 22 19:19:43 2016
@@ -6,10 +6,15 @@ cppcoreguidelines-pro-bounds-constant-ar
 This check flags all array subscript expressions on static arrays and
 ``std::arrays`` that either do not have a constant integer expression index or
 are out of bounds (for ``std::array``). For out-of-bounds checking of static
-arrays, see the clang-diagnostic-array-bounds check.
-
-The check can generate fixes after the option `GslHeader` has been set
-to the name of the include file that contains ``gsl::at()``, e.g. 
`"gsl/gsl.h"`.
+arrays, see the `-Warray-bounds` Clang diagnostic.
 
 This rule is part of the "Bounds safety" profile of the C++ Core Guidelines, 
see
 
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-bounds-arrayindex.
+
+Options
+---
+
+.. option:: GslHeader
+
+   The check can generate fixes after this option has been set to the name of
+   the include file that contains ``gsl::at()``, e.g. `"gsl/gsl.h"`.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst?rev=279494=279493=279494=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/google-global-names-in-headers.rst
 Mon Aug 22 19:19:43 2016
@@ -3,15 +3,18 @@
 google-global-names-in-headers
 ==
 
-Flag global namespace pollution in header files.
-Right now it only triggers on ``using`` declarations and directives.
-
-The check supports these options:
-  - `HeaderFileExtensions`: a comma-separated list of filename extensions
-of header files (the filename extensions should not contain "." prefix).
-"h" by default.
-For extension-less header files, using an empty string or leaving an
-empty string between "," if there are other filename extensions.
+Flag global namespace pollution in header files. Right now it only triggers on
+``using`` declarations and directives.
 
 The relevant style guide section is
 https://google.github.io/styleguide/cppguide.html#Namespaces.
+
+Options
+---
+
+.. option:: HeaderFileExtensions
+
+   A comma-separated list of filename extensions of header files (the filename
+   extensions should not contain "." prefix). "h" by default. For 
extension-less
+   header files, using an empty string or leaving an empty string between ","
+   if there are other filename extensions.

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst?rev=279494=279493=279494=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/misc-argument-comment.rst 
Mon Aug 22 19:19:43 2016
@@ -3,22 +3,26 @@
 misc-argument-comment
 =
 
-
 Checks that argument comments match parameter names.
 
 The check understands argument comments in the form ``/*parameter_name=*/``
 that are placed right before the argument.
 
-.. code:: c++
+.. code-block:: c++
 
   void f(bool foo);
 
   ...
+
   f(/*bar=*/true);
   // warning: argument name 'bar' in comment does not match parameter name 
'foo'
 
 

Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In https://reviews.llvm.org/D23728#522710, @Eugene.Zelenko wrote:

> Address review comment.


Thanks! Still LG.


Repository:
  rL LLVM

https://reviews.llvm.org/D23728



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap updated this revision to Diff 68939.
alexshap added a comment.

1. Get rid of the visitor.
2. Get rid of the dependency on libc++ in tests (ran and checked the tests 
under the minimal checkout: llvm + clang + extra tools)


Repository:
  rL LLVM

https://reviews.llvm.org/D23279

Files:
  CMakeLists.txt
  clang-reorder-fields/CMakeLists.txt
  clang-reorder-fields/ReorderFieldsAction.cpp
  clang-reorder-fields/ReorderFieldsAction.h
  clang-reorder-fields/tool/CMakeLists.txt
  clang-reorder-fields/tool/ClangReorderFields.cpp
  test/CMakeLists.txt
  test/clang-reorder-fields/CStructAmbiguousName.cpp
  test/clang-reorder-fields/CStructFieldPos.cpp
  test/clang-reorder-fields/CStructFieldsOrder.cpp
  test/clang-reorder-fields/ClassMixedInitialization.cpp
  test/clang-reorder-fields/ClassSimpleCtor.cpp

Index: test/clang-reorder-fields/ClassSimpleCtor.cpp
===
--- test/clang-reorder-fields/ClassSimpleCtor.cpp
+++ test/clang-reorder-fields/ClassSimpleCtor.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order s1,x,z,s2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK: const char *s1;
+  const char *s1; // CHECK: int x;
+  const char *s2; // CHECK: double z;
+  double z;   // CHECK: const char *s2;
+};
+
+Foo::Foo():
+  x(12),  // CHECK: s1("abc"),
+  s1("abc"),  // CHECK: x(12),
+  s2("def"),  // CHECK: z(3.14),
+  z(3.14) // CHECK: s2("def")
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/ClassMixedInitialization.cpp
===
--- test/clang-reorder-fields/ClassMixedInitialization.cpp
+++ test/clang-reorder-fields/ClassMixedInitialization.cpp
@@ -0,0 +1,26 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,s2,s1 %t.cpp -i -- -std=c++11
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+class Foo {
+public:
+  Foo();
+
+private:
+  int x;  // CHECK: double e = 2.71;
+  const char *s1; // CHECK: int x;
+  const char *s2; // CHECK: double pi = 3.14;
+  double pi = 3.14;   // CHECK: const char *s2;
+  double e = 2.71;// CHECK: const char *s1;
+};
+
+Foo::Foo():
+  x(12),  // CHECK: x(12),
+  s1("abc"),  // CHECK: s2("def"),
+  s2("def")   // CHECK: s1("abc")
+{}
+
+int main() {
+  Foo foo;
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldsOrder.cpp
===
--- test/clang-reorder-fields/CStructFieldsOrder.cpp
+++ test/clang-reorder-fields/CStructFieldsOrder.cpp
@@ -0,0 +1,18 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name ::bar::Foo -fields-order z,w,y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+namespace bar {
+struct Foo {
+  const int* x; // CHECK: double z;
+  int y;// CHECK: int w;
+  double z; // CHECK: int y;
+  int w;// CHECK: const int* x;
+};
+} // end namespace bar
+
+int main() {
+  const int x = 13;
+  bar::Foo foo = { , 17, 1.29, 0 }; // CHECK: bar::Foo foo = { 1.29, 0, 17,  };
+  return 0;
+}
Index: test/clang-reorder-fields/CStructFieldPos.cpp
===
--- test/clang-reorder-fields/CStructFieldPos.cpp
+++ test/clang-reorder-fields/CStructFieldPos.cpp
@@ -0,0 +1,16 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name ::Foo -field-pos z:0 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+struct Foo {
+  const int* x; // CHECK: double z;
+  int y;// CHECK: const int* x;
+  double z; // CHECK: int y;
+  int w;// CHECK: int w;
+};
+
+int main() {
+  const int x = 13;
+  Foo foo = { , 17, 1.29, 0 }; // CHECK: Foo foo = { 1.29, , 17, 0 };
+  return 0;
+}
Index: test/clang-reorder-fields/CStructAmbiguousName.cpp
===
--- test/clang-reorder-fields/CStructAmbiguousName.cpp
+++ test/clang-reorder-fields/CStructAmbiguousName.cpp
@@ -0,0 +1,20 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order y,x %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+
+namespace bar {
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;
+};
+} // end namespace bar
+
+int main() {
+  Foo foo = { 1, 1.7 }; // CHECK: Foo foo = { 1, 1.7 };
+  return 0;
+}
Index: test/CMakeLists.txt
===
--- test/CMakeLists.txt
+++ test/CMakeLists.txt
@@ -45,6 +45,7 @@
   clang-include-fixer
   clang-query
   clang-rename
+  clang-reorder-fields
   clang-tidy
   find-all-symbols
   modularize
Index: clang-reorder-fields/tool/ClangReorderFields.cpp

Re: [PATCH] D23493: Fix PR28366: Teach the const-expression evaluator to be more fault tolerant with non-const enclosing local variables, or otherwise fold them if const.

2016-08-22 Thread Richard Smith via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

LGTM, thanks!



Comment at: test/SemaCXX/constant-expression-cxx11.cpp:2091
@@ +2090,3 @@
+  };
+  static_assert(X::f() == c + d,"");
+}

I would use `'c' + 'd'` here, just in case we get the same incorrect value 
evaluating one of these in both places. (That is, if `d` incorrectly evaluated 
to `0` both here and on line 2088, this assert would still pass.)


https://reviews.llvm.org/D23493



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


Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko updated this revision to Diff 68933.
Eugene.Zelenko added a comment.

Address review comment.


Repository:
  rL LLVM

https://reviews.llvm.org/D23728

Files:
  docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
  docs/clang-tidy/checks/google-global-names-in-headers.rst
  docs/clang-tidy/checks/misc-argument-comment.rst
  docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
  docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  docs/clang-tidy/checks/readability-braces-around-statements.rst

Index: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
===
--- docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
+++ docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
@@ -8,22 +8,26 @@
 is misplaced, and there can be loss of precision. Otherwise the cast is
 ineffective.
 
-Example code::
+Example code:
 
+.. code-block:: c++
+
 long f(int x) {
-return (long)(x*1000);
+return (long)(x * 1000);
 }
 
-The result x*1000 is first calculated using int precision. If the result
-exceeds int precision there is loss of precision. Then the result is casted to
-long.
+The result ``x * 1000`` is first calculated using ``int`` precision. If the
+result exceeds ``int`` precision there is loss of precision. Then the result is
+casted to ``long``.
 
 If there is no loss of precision then the cast can be removed or you can
-explicitly cast to int instead.
+explicitly cast to ``int`` instead.
 
 If you want to avoid loss of precision then put the cast in a proper location,
-for instance::
+for instance:
 
+.. code-block:: c++
+
 long f(int x) {
 return (long)x * 1000;
 }
@@ -32,9 +36,11 @@
 --
 
 Forgetting to place the cast at all is at least as dangerous and at least as
-common as misplacing it. If option ``CheckImplicitCasts`` is enabled (default)
-the checker also detects these cases, for instance::
+common as misplacing it. If :option:`CheckImplicitCasts` is enabled the check
+also detects these cases, for instance:
 
+.. code-block:: c++
+
 long f(int x) {
 return x * 1000;
 }
@@ -43,8 +49,17 @@
 --
 
 Currently warnings are only written for integer conversion. No warning is
-written for this code::
+written for this code:
 
+.. code-block:: c++
+
 double f(float x) {
 return (double)(x * 10.0f);
 }
+
+Options
+---
+
+.. option:: CheckImplicitCasts
+
+   If non-zero, enables detection of implicit casts. Default is non-zero.
Index: docs/clang-tidy/checks/readability-braces-around-statements.rst
===
--- docs/clang-tidy/checks/readability-braces-around-statements.rst
+++ docs/clang-tidy/checks/readability-braces-around-statements.rst
@@ -11,14 +11,14 @@
 
 Before:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition)
 statement;
 
 After:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition) {
 statement;
Index: docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
===
--- docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
+++ docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
@@ -9,16 +9,15 @@
 
 For instance, the following declarations are equivalent:
 
-.. code:: c++
+.. code-block:: c++
 
   const char* A[] = "This is a test";
   const char* B[] = "This" " is a ""test";
 
-
 A common mistake done by programmers is to forget a comma between two string
 literals in an array initializer list.
 
-.. code:: c++
+.. code-block:: c++
 
   const char* Test[] = {
 "line 1",
@@ -28,17 +27,15 @@
 "line 5"
   };
 
-
 The array contains the string "line 2line3" at offset 1 (i.e. Test[1]). Clang
 won't generate warnings at compile time.
 
-This checker may warn incorrectly on cases like:
+This check may warn incorrectly on cases like:
 
-.. code:: c++
+.. code-block:: c++
 
   const char* SupportedFormat[] = {
 "Error %s",
 "Code " PRIu64,   // May warn here.
 "Warning %s",
   };
-
Index: docs/clang-tidy/checks/google-global-names-in-headers.rst
===
--- docs/clang-tidy/checks/google-global-names-in-headers.rst
+++ docs/clang-tidy/checks/google-global-names-in-headers.rst
@@ -3,15 +3,18 @@
 google-global-names-in-headers
 ==
 
-Flag global namespace pollution in header files.
-Right now it only triggers on ``using`` declarations and directives.
+Flag global namespace pollution in header files. Right now it only triggers on
+``using`` declarations and directives.
 
-The check supports these options:
-  - `HeaderFileExtensions`: a comma-separated list of filename extensions
-of header files (the filename extensions should not contain "." prefix).
-"h" by default.
-For extension-less 

Re: [PATCH] D15643: [clang-format] Don't allow newline after uppercase Obj-C block return types

2016-08-22 Thread Kent Sutherland via cfe-commits
ksuther updated this revision to Diff 68930.
ksuther added a comment.

This was accepted a few months ago but it got buried and was never committed. 
The diff has been updated so that it can be committed cleanly.


https://reviews.llvm.org/D15643

Files:
  lib/Format/TokenAnnotator.cpp

Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1037,12 +1037,17 @@
   !Current.Next->isBinaryOperator() &&
   !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
  tok::period, tok::arrow, tok::coloncolon))
-if (FormatToken *BeforeParen = Current.MatchingParen->Previous)
-  if (BeforeParen->is(tok::identifier) &&
-  BeforeParen->TokenText == BeforeParen->TokenText.upper() &&
-  (!BeforeParen->Previous ||
-   BeforeParen->Previous->ClosesTemplateDeclaration))
-Current.Type = TT_FunctionAnnotationRParen;
+if (FormatToken *AfterParen = Current.MatchingParen->Next) {
+  // Make sure this isn't the return type of an Obj-C block declaration
+  if (AfterParen->Tok.isNot(tok::caret)) {
+if (FormatToken *BeforeParen = Current.MatchingParen->Previous)
+  if (BeforeParen->is(tok::identifier) &&
+  BeforeParen->TokenText == BeforeParen->TokenText.upper() &&
+  (!BeforeParen->Previous ||
+   BeforeParen->Previous->ClosesTemplateDeclaration))
+Current.Type = TT_FunctionAnnotationRParen;
+  }
+   }
 } else if (Current.is(tok::at) && Current.Next) {
   if (Current.Next->isStringLiteral()) {
 Current.Type = TT_ObjCStringLiteral;


Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1037,12 +1037,17 @@
   !Current.Next->isBinaryOperator() &&
   !Current.Next->isOneOf(tok::semi, tok::colon, tok::l_brace,
  tok::period, tok::arrow, tok::coloncolon))
-if (FormatToken *BeforeParen = Current.MatchingParen->Previous)
-  if (BeforeParen->is(tok::identifier) &&
-  BeforeParen->TokenText == BeforeParen->TokenText.upper() &&
-  (!BeforeParen->Previous ||
-   BeforeParen->Previous->ClosesTemplateDeclaration))
-Current.Type = TT_FunctionAnnotationRParen;
+if (FormatToken *AfterParen = Current.MatchingParen->Next) {
+  // Make sure this isn't the return type of an Obj-C block declaration
+  if (AfterParen->Tok.isNot(tok::caret)) {
+if (FormatToken *BeforeParen = Current.MatchingParen->Previous)
+  if (BeforeParen->is(tok::identifier) &&
+  BeforeParen->TokenText == BeforeParen->TokenText.upper() &&
+  (!BeforeParen->Previous ||
+   BeforeParen->Previous->ClosesTemplateDeclaration))
+Current.Type = TT_FunctionAnnotationRParen;
+  }
+		}
 } else if (Current.is(tok::at) && Current.Next) {
   if (Current.Next->isStringLiteral()) {
 Current.Type = TT_ObjCStringLiteral;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Alexander Kornienko via cfe-commits
alexfh added inline comments.


Comment at: 
docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst:9
@@ -8,3 +8,3 @@
 are out of bounds (for ``std::array``). For out-of-bounds checking of static
-arrays, see the clang-diagnostic-array-bounds check.
+arrays, see the `clang-diagnostic-array-bounds` check.
 

Eugene.Zelenko wrote:
> Unfortunately not. Historically Clang warnings options documentation is very 
> poor in comparison with GCC's.
> 
> Probably some descriptions could be extracted from release notes, but I'm not 
> sure that clang-diagnostic-array-bounds is described there.
Ah, I completely missed the fact it's a clang diagnostic. The wording is off 
here. Should be "see the -Warray-bounds clang diagnostic" instead. The fact 
that clang diagnostics map to `clang-diagnostic-...` is described in the main 
doc (http://clang.llvm.org/extra/clang-tidy/).


Repository:
  rL LLVM

https://reviews.llvm.org/D23728



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


r279490 - Add comments. NFC

2016-08-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Aug 22 17:38:16 2016
New Revision: 279490

URL: http://llvm.org/viewvc/llvm-project?rev=279490=rev
Log:
Add comments. NFC

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

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=279490=279489=279490=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Aug 22 17:38:16 2016
@@ -1650,8 +1650,10 @@ static bool hasExplicitMemberDefinition(
 
 /// Does a type definition exist in an imported clang module?
 static bool isDefinedInClangModule(const RecordDecl *RD) {
+  // Only definitions that where imported from an AST file come from a module.
   if (!RD || !RD->isFromASTFile())
 return false;
+  // Anonymous entities cannot be addressed. Treat them as not from module.
   if (!RD->isExternallyVisible() && RD->getName().empty())
 return false;
   if (auto *CXXDecl = dyn_cast(RD)) {


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


r279491 - Typo.

2016-08-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Aug 22 17:38:18 2016
New Revision: 279491

URL: http://llvm.org/viewvc/llvm-project?rev=279491=rev
Log:
Typo.

Modified:
cfe/trunk/test/Modules/ExtDebugInfo.cpp

Modified: cfe/trunk/test/Modules/ExtDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ExtDebugInfo.cpp?rev=279491=279490=279491=diff
==
--- cfe/trunk/test/Modules/ExtDebugInfo.cpp (original)
+++ cfe/trunk/test/Modules/ExtDebugInfo.cpp Mon Aug 22 17:38:18 2016
@@ -1,5 +1,5 @@
 // RUN: rm -rf %t
-// Test that only forward declarations are emitted for types dfined in modules.
+// Test that only forward declarations are emitted for types defined in 
modules.
 
 // Modules:
 // RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \


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


r279489 - Add the second half of the testcase I should have added in 279485.

2016-08-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Aug 22 17:30:34 2016
New Revision: 279489

URL: http://llvm.org/viewvc/llvm-project?rev=279489=rev
Log:
Add the second half of the testcase I should have added in 279485.

Added:
cfe/trunk/test/Modules/ModuleModuleDebugInfo.cpp

Added: cfe/trunk/test/Modules/ModuleModuleDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/ModuleModuleDebugInfo.cpp?rev=279489=auto
==
--- cfe/trunk/test/Modules/ModuleModuleDebugInfo.cpp (added)
+++ cfe/trunk/test/Modules/ModuleModuleDebugInfo.cpp Mon Aug 22 17:30:34 2016
@@ -0,0 +1,18 @@
+// RUN: rm -rf %t
+
+// RUN: %clang_cc1 -x objective-c++ -std=c++11 -debug-info-kind=standalone \
+// RUN: -dwarf-ext-refs -fmodules   \
+// RUN: -fmodule-format=obj -fimplicit-module-maps -DMODULES \
+// RUN: -triple %itanium_abi_triple \
+// RUN: -fmodules-cache-path=%t %s -I %S/Inputs -I %t -emit-llvm -o - \
+// RUN:   | FileCheck %s
+
+#include "DebugNestedB.h"
+AF af; // This type is not anchored in the module.
+
+// CHECK: !DIDerivedType(tag: DW_TAG_typedef, name: "AF",
+// CHECK-SAME:   baseType: ![[AF:.*]])
+
+// CHECK: ![[AF]] = {{.*}}!DICompositeType(tag: DW_TAG_structure_type, name: 
"A",
+// CHECK-SAME: elements:
+


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


Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: 
docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst:9
@@ -8,3 +8,3 @@
 are out of bounds (for ``std::array``). For out-of-bounds checking of static
-arrays, see the clang-diagnostic-array-bounds check.
+arrays, see the `clang-diagnostic-array-bounds` check.
 

Unfortunately not. Historically Clang warnings options documentation is very 
poor in comparison with GCC's.

Probably some descriptions could be extracted from release notes, but I'm not 
sure that clang-diagnostic-array-bounds is described there.


Repository:
  rL LLVM

https://reviews.llvm.org/D23728



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


Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko updated this revision to Diff 68921.
Eugene.Zelenko added a comment.

Address review comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D23728

Files:
  docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
  docs/clang-tidy/checks/google-global-names-in-headers.rst
  docs/clang-tidy/checks/misc-argument-comment.rst
  docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
  docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  docs/clang-tidy/checks/readability-braces-around-statements.rst

Index: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
===
--- docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
+++ docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
@@ -8,22 +8,26 @@
 is misplaced, and there can be loss of precision. Otherwise the cast is
 ineffective.
 
-Example code::
+Example code:
 
+.. code-block:: c++
+
 long f(int x) {
-return (long)(x*1000);
+return (long)(x * 1000);
 }
 
-The result x*1000 is first calculated using int precision. If the result
-exceeds int precision there is loss of precision. Then the result is casted to
-long.
+The result ``x * 1000`` is first calculated using ``int`` precision. If the
+result exceeds ``int`` precision there is loss of precision. Then the result is
+casted to ``long``.
 
 If there is no loss of precision then the cast can be removed or you can
-explicitly cast to int instead.
+explicitly cast to ``int`` instead.
 
 If you want to avoid loss of precision then put the cast in a proper location,
-for instance::
+for instance:
 
+.. code-block:: c++
+
 long f(int x) {
 return (long)x * 1000;
 }
@@ -32,9 +36,11 @@
 --
 
 Forgetting to place the cast at all is at least as dangerous and at least as
-common as misplacing it. If option ``CheckImplicitCasts`` is enabled (default)
-the checker also detects these cases, for instance::
+common as misplacing it. If :option:`CheckImplicitCasts` is enabled the check
+also detects these cases, for instance:
 
+.. code-block:: c++
+
 long f(int x) {
 return x * 1000;
 }
@@ -43,8 +49,17 @@
 --
 
 Currently warnings are only written for integer conversion. No warning is
-written for this code::
+written for this code:
 
+.. code-block:: c++
+
 double f(float x) {
 return (double)(x * 10.0f);
 }
+
+Options
+---
+
+.. option:: CheckImplicitCasts
+
+   If non-zero, enables detection of implicit casts. Default is non-zero.
Index: docs/clang-tidy/checks/readability-braces-around-statements.rst
===
--- docs/clang-tidy/checks/readability-braces-around-statements.rst
+++ docs/clang-tidy/checks/readability-braces-around-statements.rst
@@ -11,14 +11,14 @@
 
 Before:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition)
 statement;
 
 After:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition) {
 statement;
Index: docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
===
--- docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
+++ docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
@@ -9,16 +9,15 @@
 
 For instance, the following declarations are equivalent:
 
-.. code:: c++
+.. code-block:: c++
 
   const char* A[] = "This is a test";
   const char* B[] = "This" " is a ""test";
 
-
 A common mistake done by programmers is to forget a comma between two string
 literals in an array initializer list.
 
-.. code:: c++
+.. code-block:: c++
 
   const char* Test[] = {
 "line 1",
@@ -28,17 +27,15 @@
 "line 5"
   };
 
-
 The array contains the string "line 2line3" at offset 1 (i.e. Test[1]). Clang
 won't generate warnings at compile time.
 
-This checker may warn incorrectly on cases like:
+This check may warn incorrectly on cases like:
 
-.. code:: c++
+.. code-block:: c++
 
   const char* SupportedFormat[] = {
 "Error %s",
 "Code " PRIu64,   // May warn here.
 "Warning %s",
   };
-
Index: docs/clang-tidy/checks/google-global-names-in-headers.rst
===
--- docs/clang-tidy/checks/google-global-names-in-headers.rst
+++ docs/clang-tidy/checks/google-global-names-in-headers.rst
@@ -3,15 +3,18 @@
 google-global-names-in-headers
 ==
 
-Flag global namespace pollution in header files.
-Right now it only triggers on ``using`` declarations and directives.
+Flag global namespace pollution in header files. Right now it only triggers on
+``using`` declarations and directives.
 
-The check supports these options:
-  - `HeaderFileExtensions`: a comma-separated list of filename extensions
-of header files (the filename extensions should not contain "." prefix).
-"h" by default.
-For extension-less 

Re: r267464 - Module Debugging: Fix the condition for determining whether a template

2016-08-22 Thread Adrian Prantl via cfe-commits

> On Apr 26, 2016, at 4:11 PM, Richard Smith  wrote:
> 
> On Tue, Apr 26, 2016 at 3:10 PM, Adrian Prantl via cfe-commits 
> > wrote:
> 
>> On Apr 25, 2016, at 5:34 PM, Richard Smith > > wrote:
>> 
>> On Mon, Apr 25, 2016 at 1:52 PM, Adrian Prantl via cfe-commits 
>> > wrote:
>> Author: adrian
>> Date: Mon Apr 25 15:52:40 2016
>> New Revision: 267464
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=267464=rev 
>> 
>> Log:
>> Module Debugging: Fix the condition for determining whether a template
>> instantiation is in a module.
>> 
>> This patch fixes the condition for determining whether the debug info for a
>> template instantiation will exist in an imported clang module by:
>> 
>> - checking whether the ClassTemplateSpecializationDecl is complete and
>> - checking that the instantiation was in a module by looking at the first 
>> field.
>> 
>> I also added a negative check to make sure that a typedef to a 
>> forward-declared
>> template (with the definition outside of the module) is handled correctly.
>> 
>> http://reviews.llvm.org/D19443 
>> rdar://problem/25553724 <>
>> 
>> Modified:
>> cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> cfe/trunk/test/Modules/ExtDebugInfo.cpp
>> cfe/trunk/test/Modules/Inputs/DebugCXX.h
>> cfe/trunk/test/Modules/ModuleDebugInfo.cpp
>> 
>> Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=267464=267463=267464=diff
>>  
>> 
>> ==
>> --- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
>> +++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Apr 25 15:52:40 2016
>> @@ -1514,12 +1514,28 @@ static bool hasExplicitMemberDefinition(
>>return false;
>>  }
>> 
>> +/// Does a type definition exist in an imported clang module?
>> +static bool isDefinedInClangModule(const RecordDecl *RD) {
>> +  if (!RD->isFromASTFile())
>> +return false;
>> +  if (!RD->getDefinition())
>> +return false;
>> +  if (!RD->isExternallyVisible() && RD->getName().empty())
>> +return false;
>> +  if (auto *CTSD = dyn_cast(RD)) {
>> 
>> The same issue also affects member classes of class template specializations 
>> (you can detect them with RD->getInstantiatedFromMemberClass(), or detect 
>> all the relevant cases at once with RD->getTemplateSpecializationKind()).
> 
> I added a testcase for this r267612, but I couldn’t reproduce the situation 
> that you were describing here. Do you have an example of what you had in mind?
> 
> Something just like your testcase for class template specializations should 
> work:
> 
> // DebugCXX.h
> template  class FwdDeclTemplateMember { class Member; };
> typedef FwdDeclTemplateMember::Member TypedefFwdDeclTemplateMember;
> 
> // ExtDebugInfo.cpp
> template  class FwdDeclTemplateMember::Member { T t; };
> TypedefFwdDeclTemplateMember tdfdtm;
>> +if (!CTSD->isCompleteDefinition())
>> +  return false;
>> 
>> You already checked this a few lines above. Actually, the two checks do 
>> different things depending on whether RD or some other declaration is the 
>> definition; did you really mean to treat a (non-template) class that's 
>> defined locally but forward-declared within a module as being defined in 
>> that module? (It might make more sense to map to the definition upfront and 
>> do all your queries on that if that's what you intend to check.)
> 
> Thanks! I changed this in r267611 to always pass RD->getDefinition() into 
> isDefinedInClangModule. Does this make the check for isCompleteDefinition() 
> redundant?
> 
> Yes. The only other possibility here is that the class is currently being 
> defined (we're between the open and close braces), but as far as I know you 
> shouldn't ever see such a class from here, and you should certainly never see 
> one where the partial definition is imported from an AST file. You could 
> assert isCompleteDefinition() if you're worried that we might give you a bad 
> AST.

FYI: The -gmodules bot on green dragon recently found a situation where this 
assertion fired. You might be interested in the testcase I added in r279485.

-- adrian

> 
> -- adrian
> 
>>  
>> +// Make sure the instantiation is actually in a module.
>> +if (CTSD->field_begin() != CTSD->field_end())
>> +  return CTSD->field_begin()->isFromASTFile();
>> +  }
>> +  return true;
>> +}
>> +
>>  static bool shouldOmitDefinition(codegenoptions::DebugInfoKind DebugKind,
>>   bool DebugTypeExtRefs, const RecordDecl 
>> *RD,
>> 

r279485 - Module debug info: Don't assert when encountering an incomplete definition

2016-08-22 Thread Adrian Prantl via cfe-commits
Author: adrian
Date: Mon Aug 22 17:23:58 2016
New Revision: 279485

URL: http://llvm.org/viewvc/llvm-project?rev=279485=rev
Log:
Module debug info: Don't assert when encountering an incomplete definition
in isDefinedInClangModule() and assume that the incomplete definition
is not defined in the module.

This broke the -gmodules self host recently.
rdar://problem/27894367

Added:
cfe/trunk/test/Modules/Inputs/DebugNestedA.h
cfe/trunk/test/Modules/Inputs/DebugNestedB.h
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=279485=279484=279485=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Aug 22 17:23:58 2016
@@ -1655,7 +1655,8 @@ static bool isDefinedInClangModule(const
   if (!RD->isExternallyVisible() && RD->getName().empty())
 return false;
   if (auto *CXXDecl = dyn_cast(RD)) {
-assert(CXXDecl->isCompleteDefinition() && "incomplete record definition");
+if (!CXXDecl->isCompleteDefinition())
+  return false;
 auto TemplateKind = CXXDecl->getTemplateSpecializationKind();
 if (TemplateKind != TSK_Undeclared) {
   // This is a template, check the origin of the first member.

Added: cfe/trunk/test/Modules/Inputs/DebugNestedA.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugNestedA.h?rev=279485=auto
==
--- cfe/trunk/test/Modules/Inputs/DebugNestedA.h (added)
+++ cfe/trunk/test/Modules/Inputs/DebugNestedA.h Mon Aug 22 17:23:58 2016
@@ -0,0 +1,8 @@
+/* -*- C++ -*- */
+template  class Base {};
+template  struct A : public Base {
+  void f();
+};
+
+class F {};
+typedef A AF;

Added: cfe/trunk/test/Modules/Inputs/DebugNestedB.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/DebugNestedB.h?rev=279485=auto
==
--- cfe/trunk/test/Modules/Inputs/DebugNestedB.h (added)
+++ cfe/trunk/test/Modules/Inputs/DebugNestedB.h Mon Aug 22 17:23:58 2016
@@ -0,0 +1,7 @@
+/* -*- C++ -*- */
+#include "DebugNestedA.h"
+class C {
+  void run(AF ) {
+af.f();
+  }
+};

Modified: cfe/trunk/test/Modules/Inputs/module.map
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/Inputs/module.map?rev=279485=279484=279485=diff
==
--- cfe/trunk/test/Modules/Inputs/module.map (original)
+++ cfe/trunk/test/Modules/Inputs/module.map Mon Aug 22 17:23:58 2016
@@ -422,3 +422,13 @@ module MacroFabs1 {
 module DiagOutOfDate {
   header "DiagOutOfDate.h"
 }
+
+module DebugNestedA {
+  header "DebugNestedA.h"
+  export *
+}
+
+module DebugNestedB {
+  header "DebugNestedB.h"
+  export *
+}


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


Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

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

LG with a few nits.



Comment at: 
docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst:9
@@ -8,3 +8,3 @@
 are out of bounds (for ``std::array``). For out-of-bounds checking of static
-arrays, see the clang-diagnostic-array-bounds check.
+arrays, see the `clang-diagnostic-array-bounds` check.
 

Can we make this a link?


Comment at: 
docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst:19
@@ +18,3 @@
+
+   The check can generate fixes after the this option has been set to the name
+   of the include file that contains ``gsl::at()``, e.g. `"gsl/gsl.h"`.

nit: "the this" - one of these should go


Comment at: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst:19
@@ -16,4 +18,3 @@
 
-The result x*1000 is first calculated using int precision. If the result
-exceeds int precision there is loss of precision. Then the result is casted to
-long.
+The result `x * 1000` is first calculated using ``int`` precision. If the 
result
+exceeds ``int`` precision there is loss of precision. Then the result is casted

`x * 1000` should also be enclosed in double quotes, imo.


Comment at: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst:65
@@ +64,2 @@
+
+   Enable (default) or disable detection of implicit casts.

I'd say "If non-zero, enables detection of implicit casts. Default is non-zero."


Repository:
  rL LLVM

https://reviews.llvm.org/D23728



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

@djasper - regarding the visitor - thank you, i understand ur concerns - i will 
add a version which uses a matcher (will update this diff).


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


r279481 - [SemaObjC] Do not RebuildObjCMessageExpr without valid method decl

2016-08-22 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Aug 22 16:50:22 2016
New Revision: 279481

URL: http://llvm.org/viewvc/llvm-project?rev=279481=rev
Log:
[SemaObjC] Do not RebuildObjCMessageExpr without valid method decl

Fix crash-on-invalid in ObjC Sema by avoiding to rebuild a message
expression to a 'super' class in case the method to call does not exist
(i.e. comes from another missing identifier).

In this case, the typo transform is invoked upon the message expression
in an attempt to solve a typo in a 'super' call parameters, but it
crashes since it assumes the method to call has a valid declaration.

rdar://problem/27305403

Modified:
cfe/trunk/lib/Sema/TreeTransform.h
cfe/trunk/test/SemaObjC/call-super-2.m

Modified: cfe/trunk/lib/Sema/TreeTransform.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/TreeTransform.h?rev=279481=279480=279481=diff
==
--- cfe/trunk/lib/Sema/TreeTransform.h (original)
+++ cfe/trunk/lib/Sema/TreeTransform.h Mon Aug 22 16:50:22 2016
@@ -11174,6 +11174,9 @@ TreeTransform::TransformObjCMes
   }
   else if (E->getReceiverKind() == ObjCMessageExpr::SuperClass ||
E->getReceiverKind() == ObjCMessageExpr::SuperInstance) {
+if (!E->getMethodDecl())
+  return ExprError();
+
 // Build a new class message send to 'super'.
 SmallVector SelLocs;
 E->getSelectorLocs(SelLocs);

Modified: cfe/trunk/test/SemaObjC/call-super-2.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/call-super-2.m?rev=279481=279480=279481=diff
==
--- cfe/trunk/test/SemaObjC/call-super-2.m (original)
+++ cfe/trunk/test/SemaObjC/call-super-2.m Mon Aug 22 16:50:22 2016
@@ -106,3 +106,18 @@ id objc_getClass(const char *s);
 }
 @end
 
+@class C;
+@interface A // expected-note {{receiver is instance of class declared here}}
+- (instancetype)initWithCoder:(A *)coder;
+@end
+
+@interface B : A
+@end
+
+@implementation B
+- (instancetype)initWithCoder:(C *)coder {
+  if (0 != (self = [super initWithCode:code])) // expected-error {{use of 
undeclared identifier 'code'}} expected-warning {{instance method 
'-initWithCode:' not found}}
+return (void *)0;
+  return (void *)0;
+}
+@end


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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap added inline comments.


Comment at: test/clang-reorder-fields/CStructAmbiguousName.cpp:6
@@ +5,3 @@
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;

djasper wrote:
> Have you thought about how to handle comments that surround these?
yup, take a look at one of my comments above.
Basically my plan was to leverage the approach/api described here
http://llvm.org/devmtg/2012-11/Gribenko_CommentParsing.pdf
It's doable, not very complicated, but requires some work - i need time to 
think more about it and prepare a diff - it's still in the oven and not ready 
yet. 


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


r279479 - [AST] Remove unused function, to silence a GCC7 warning.

2016-08-22 Thread Davide Italiano via cfe-commits
Author: davide
Date: Mon Aug 22 16:33:12 2016
New Revision: 279479

URL: http://llvm.org/viewvc/llvm-project?rev=279479=rev
Log:
[AST] Remove unused function, to silence a GCC7 warning.

Modified:
cfe/trunk/lib/AST/StmtProfile.cpp

Modified: cfe/trunk/lib/AST/StmtProfile.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/StmtProfile.cpp?rev=279479=279478=279479=diff
==
--- cfe/trunk/lib/AST/StmtProfile.cpp (original)
+++ cfe/trunk/lib/AST/StmtProfile.cpp Mon Aug 22 16:33:12 2016
@@ -93,10 +93,6 @@ void StmtProfiler::VisitCompoundStmt(con
   VisitStmt(S);
 }
 
-void StmtProfiler::VisitSwitchCase(const SwitchCase *S) {
-  VisitStmt(S);
-}
-
 void StmtProfiler::VisitCaseStmt(const CaseStmt *S) {
   VisitStmt(S);
 }


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


[PATCH] D23784: Remove trailing WS [NFC]

2016-08-22 Thread Aditya Kumar via cfe-commits
hiraditya created this revision.
hiraditya added reviewers: mclow.lists, EricWF.
hiraditya added a subscriber: cfe-commits.

https://reviews.llvm.org/D23784

Files:
  libcxx/include/algorithm

Index: libcxx/include/algorithm
===
--- libcxx/include/algorithm
+++ libcxx/include/algorithm
@@ -89,7 +89,7 @@
 
 template 
 pair
-mismatch(InputIterator1 first1, InputIterator1 last1, 
+mismatch(InputIterator1 first1, InputIterator1 last1,
  InputIterator2 first2, InputIterator2 last2); // **C++14**
 
 template 
@@ -109,7 +109,7 @@
 
 template 
 bool
-equal(InputIterator1 first1, InputIterator1 last1, 
+equal(InputIterator1 first1, InputIterator1 last1,
   InputIterator2 first2, InputIterator2 last2); // **C++14**
 
 template 
@@ -688,7 +688,7 @@
 template 
 struct __less
 {
-_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 
+_LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
 bool operator()(const _T1& __x, const _T1& __y) const {return __x < __y;}
 
 _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
@@ -1229,7 +1229,7 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__equal(_InputIterator1 __first1, _InputIterator1 __last1, 
+__equal(_InputIterator1 __first1, _InputIterator1 __last1,
 _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred,
 input_iterator_tag, input_iterator_tag )
 {
@@ -1242,8 +1242,8 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1, 
-_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred, 
+__equal(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
+_RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
   random_access_iterator_tag, random_access_iterator_tag )
 {
 if ( _VSTD::distance(__first1, __last1) != _VSTD::distance(__first2, __last2))
@@ -1256,19 +1256,19 @@
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-equal(_InputIterator1 __first1, _InputIterator1 __last1, 
+equal(_InputIterator1 __first1, _InputIterator1 __last1,
   _InputIterator2 __first2, _InputIterator2 __last2, _BinaryPredicate __pred )
 {
 return _VSTD::__equal::type>
-   (__first1, __last1, __first2, __last2, __pred, 
+   (__first1, __last1, __first2, __last2, __pred,
 typename iterator_traits<_InputIterator1>::iterator_category(),
 typename iterator_traits<_InputIterator2>::iterator_category());
 }
 
 template 
 inline _LIBCPP_INLINE_VISIBILITY
 bool
-equal(_InputIterator1 __first1, _InputIterator1 __last1, 
+equal(_InputIterator1 __first1, _InputIterator1 __last1,
   _InputIterator2 __first2, _InputIterator2 __last2)
 {
 typedef typename iterator_traits<_InputIterator1>::value_type __v1;
@@ -1342,7 +1342,7 @@
 template
 bool
 __is_permutation(_ForwardIterator1 __first1, _ForwardIterator1 __last1,
- _ForwardIterator2 __first2, _ForwardIterator2 __last2, 
+ _ForwardIterator2 __first2, _ForwardIterator2 __last2,
  _BinaryPredicate __pred,
  forward_iterator_tag, forward_iterator_tag )
 {
@@ -1393,7 +1393,7 @@
 template
 bool
 __is_permutation(_RandomAccessIterator1 __first1, _RandomAccessIterator2 __last1,
-   _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2, 
+   _RandomAccessIterator1 __first2, _RandomAccessIterator2 __last2,
_BinaryPredicate __pred,
random_access_iterator_tag, random_access_iterator_tag )
 {
@@ -1472,7 +1472,7 @@
 }
 
 template 
-_LIBCPP_CONSTEXPR_AFTER_CXX11 
+_LIBCPP_CONSTEXPR_AFTER_CXX11
 pair<_RandomAccessIterator1, _RandomAccessIterator1>
 __search(_RandomAccessIterator1 __first1, _RandomAccessIterator1 __last1,
  _RandomAccessIterator2 __first2, _RandomAccessIterator2 __last2, _BinaryPredicate __pred,
@@ -2799,7 +2799,7 @@
 __result.second = *__first;
 ++__first;
 }
-
+
 while (__first != __last)
 {
 _Tp __prev = *__first++;
@@ -2811,7 +2811,7 @@
 if ( __comp(__prev, __result.first))__result.first  = __prev;
 if (!__comp(*__first, __result.second)) __result.second = *__first;
 }
-
+
 __first++;
 }
 return __result;
@@ -4437,7 +4437,7 @@
 ::new(__p) value_type(_VSTD::move(*__i));
 typedef reverse_iterator<_BidirectionalIterator> _RBi;
 typedef reverse_iterator _Rv;
-__half_inplace_merge(_Rv(__p), _Rv(__buff), 
+__half_inplace_merge(_Rv(__p), _Rv(__buff),
  _RBi(__middle), _RBi(__first),
  _RBi(__last), __negate<_Compare>(__comp));
 }
___
cfe-commits 

Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Ben: I am happy to have this as a separate tool until then. But if we go that 
route, let's add very explicit comments about this so that people don't start 
depending on it and we can actually remove it as easily as possible.

Alex: I don't think there will be a significant performance difference between 
implementing this as recursive AST visitor or implementing this with matchers. 
Even if you have multiple matchers, a single run over the AST would suffice. If 
there is a performance difference, that's probably something we should fix. 
It's hard to make an estimate on which version would be more concise without 
actually comparing both versions (I would bet on the AST matcher version to be 
more concise). However, an equally important point is that a single way to find 
something in the AST is easier to understand and maintain then having two ways 
to do it in the same tool.



Comment at: test/clang-reorder-fields/CStructAmbiguousName.cpp:6
@@ +5,3 @@
+struct Foo {
+  int x;// CHECK: int x;
+  double y; // CHECK: double y;

Have you thought about how to handle comments that surround these?


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279475: [GraphTraits] Replace all NodeType usage with 
NodeRef (authored by timshen).

Changed prior to commit:
  https://reviews.llvm.org/D23730?vs=68748=68912#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23730

Files:
  cfe/trunk/include/clang/AST/StmtGraphTraits.h
  cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
  cfe/trunk/include/clang/Analysis/CFG.h
  cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
  cfe/trunk/lib/Serialization/ModuleManager.cpp
  llvm/trunk/include/llvm/ADT/GraphTraits.h
  llvm/trunk/include/llvm/Analysis/CallGraph.h
  llvm/trunk/include/llvm/Analysis/Interval.h
  llvm/trunk/include/llvm/Analysis/LazyCallGraph.h
  llvm/trunk/include/llvm/Analysis/LoopInfo.h
  llvm/trunk/include/llvm/Analysis/PostDominators.h
  llvm/trunk/include/llvm/Analysis/RegionIterator.h
  llvm/trunk/include/llvm/CodeGen/MachineBasicBlock.h
  llvm/trunk/include/llvm/CodeGen/MachineDominators.h
  llvm/trunk/include/llvm/CodeGen/MachineFunction.h
  llvm/trunk/include/llvm/CodeGen/MachineLoopInfo.h
  llvm/trunk/include/llvm/CodeGen/MachineRegionInfo.h
  llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h
  llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h
  llvm/trunk/include/llvm/IR/CFG.h
  llvm/trunk/include/llvm/IR/Dominators.h
  llvm/trunk/include/llvm/IR/Type.h
  llvm/trunk/include/llvm/Transforms/Utils/MemorySSA.h
  llvm/trunk/lib/Analysis/BlockFrequencyInfo.cpp
  llvm/trunk/lib/Analysis/BlockFrequencyInfoImpl.cpp
  llvm/trunk/lib/CodeGen/MachineBlockFrequencyInfo.cpp
  llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
  llvm/trunk/unittests/ADT/SCCIteratorTest.cpp
  llvm/trunk/unittests/Analysis/CallGraphTest.cpp

Index: llvm/trunk/include/llvm/IR/Type.h
===
--- llvm/trunk/include/llvm/IR/Type.h
+++ llvm/trunk/include/llvm/IR/Type.h
@@ -429,29 +429,27 @@
 // graph of sub types.
 
 template <> struct GraphTraits {
-  typedef Type NodeType;
   typedef Type *NodeRef;
   typedef Type::subtype_iterator ChildIteratorType;
 
-  static inline NodeType *getEntryNode(Type *T) { return T; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline NodeRef getEntryNode(Type *T) { return T; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return N->subtype_begin();
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 return N->subtype_end();
   }
 };
 
 template <> struct GraphTraits {
-  typedef const Type NodeType;
   typedef const Type *NodeRef;
   typedef Type::subtype_iterator ChildIteratorType;
 
-  static inline NodeType *getEntryNode(NodeType *T) { return T; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline NodeRef getEntryNode(NodeRef T) { return T; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return N->subtype_begin();
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 return N->subtype_end();
   }
 };
Index: llvm/trunk/include/llvm/IR/CFG.h
===
--- llvm/trunk/include/llvm/IR/CFG.h
+++ llvm/trunk/include/llvm/IR/CFG.h
@@ -154,65 +154,51 @@
 // graph of basic blocks...
 
 template <> struct GraphTraits {
-  typedef BasicBlock NodeType;
   typedef BasicBlock *NodeRef;
   typedef succ_iterator ChildIteratorType;
 
-  static NodeType *getEntryNode(BasicBlock *BB) { return BB; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static NodeRef getEntryNode(BasicBlock *BB) { return BB; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return succ_begin(N);
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return succ_end(N);
-  }
+  static inline ChildIteratorType child_end(NodeRef N) { return succ_end(N); }
 };
 
 template <> struct GraphTraits {
-  typedef const BasicBlock NodeType;
   typedef const BasicBlock *NodeRef;
   typedef succ_const_iterator ChildIteratorType;
 
-  static NodeType *getEntryNode(const BasicBlock *BB) { return BB; }
+  static NodeRef getEntryNode(const BasicBlock *BB) { return BB; }
 
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return succ_begin(N);
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return succ_end(N);
-  }
+  static inline ChildIteratorType child_end(NodeRef N) { return succ_end(N); }
 };
 
 // Provide specializations of GraphTraits to be able to treat a function as a
 // graph of basic blocks... and to walk it in inverse order.  Inverse order for
 // a function is considered to be when traversing the predecessor edges of a BB
 // instead of the successor edges.
 //
 template <> struct 

r279475 - [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
Author: timshen
Date: Mon Aug 22 16:09:30 2016
New Revision: 279475

URL: http://llvm.org/viewvc/llvm-project?rev=279475=rev
Log:
[GraphTraits] Replace all NodeType usage with NodeRef

This should finish the GraphTraits migration.

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

Modified:
cfe/trunk/include/clang/AST/StmtGraphTraits.h
cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
cfe/trunk/include/clang/Analysis/CFG.h
cfe/trunk/include/clang/StaticAnalyzer/Core/PathSensitive/ExplodedGraph.h
cfe/trunk/lib/Serialization/ModuleManager.cpp

Modified: cfe/trunk/include/clang/AST/StmtGraphTraits.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/StmtGraphTraits.h?rev=279475=279474=279475=diff
==
--- cfe/trunk/include/clang/AST/StmtGraphTraits.h (original)
+++ cfe/trunk/include/clang/AST/StmtGraphTraits.h Mon Aug 22 16:09:30 2016
@@ -25,19 +25,18 @@ namespace llvm {
 
 
 template <> struct GraphTraits {
-  typedef clang::Stmt   NodeType;
   typedef clang::Stmt * NodeRef;
   typedef clang::Stmt::child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
-  static NodeType* getEntryNode(clang::Stmt* S) { return S; }
+  static NodeRef getEntryNode(clang::Stmt *S) { return S; }
 
-  static inline ChildIteratorType child_begin(NodeType* N) {
+  static inline ChildIteratorType child_begin(NodeRef N) {
 if (N) return N->child_begin();
 else return ChildIteratorType();
   }
 
-  static inline ChildIteratorType child_end(NodeType* N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 if (N) return N->child_end();
 else return ChildIteratorType();
   }
@@ -53,19 +52,18 @@ template <> struct GraphTraits struct GraphTraits {
-  typedef const clang::Stmt   NodeType;
   typedef const clang::Stmt * NodeRef;
   typedef clang::Stmt::const_child_iterator   ChildIteratorType;
   typedef llvm::df_iterator   nodes_iterator;
 
-  static NodeType* getEntryNode(const clang::Stmt* S) { return S; }
+  static NodeRef getEntryNode(const clang::Stmt *S) { return S; }
 
-  static inline ChildIteratorType child_begin(NodeType* N) {
+  static inline ChildIteratorType child_begin(NodeRef N) {
 if (N) return N->child_begin();
 else return ChildIteratorType();
   }
 
-  static inline ChildIteratorType child_end(NodeType* N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 if (N) return N->child_end();
 else return ChildIteratorType();
   }

Modified: cfe/trunk/include/clang/Analysis/Analyses/Dominators.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/Analyses/Dominators.h?rev=279475=279474=279475=diff
==
--- cfe/trunk/include/clang/Analysis/Analyses/Dominators.h (original)
+++ cfe/trunk/include/clang/Analysis/Analyses/Dominators.h Mon Aug 22 16:09:30 
2016
@@ -167,19 +167,12 @@ private:
 ///
 namespace llvm {
 template <> struct GraphTraits< ::clang::DomTreeNode* > {
-  typedef ::clang::DomTreeNode NodeType;
   typedef ::clang::DomTreeNode *NodeRef;
-  typedef NodeType::iterator  ChildIteratorType;
+  typedef ::clang::DomTreeNode::iterator ChildIteratorType;
 
-  static NodeType *getEntryNode(NodeType *N) {
-return N;
-  }
-  static inline ChildIteratorType child_begin(NodeType *N) {
-return N->begin();
-  }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return N->end();
-  }
+  static NodeRef getEntryNode(NodeRef N) { return N; }
+  static inline ChildIteratorType child_begin(NodeRef N) { return N->begin(); }
+  static inline ChildIteratorType child_end(NodeRef N) { return N->end(); }
 
   typedef llvm::pointer_iterator>
   nodes_iterator;
@@ -195,7 +188,7 @@ template <> struct GraphTraits< ::clang:
 
 template <> struct GraphTraits< ::clang::DominatorTree* >
   : public GraphTraits< ::clang::DomTreeNode* > {
-  static NodeType *getEntryNode(::clang::DominatorTree *DT) {
+  static NodeRef getEntryNode(::clang::DominatorTree *DT) {
 return DT->getRootNode();
   }
 

Modified: cfe/trunk/include/clang/Analysis/CFG.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Analysis/CFG.h?rev=279475=279474=279475=diff
==
--- cfe/trunk/include/clang/Analysis/CFG.h (original)
+++ cfe/trunk/include/clang/Analysis/CFG.h Mon Aug 22 16:09:30 2016
@@ -945,63 +945,59 @@ template <> struct simplify_type< ::clan
 // Traits for: CFGBlock
 
 template <> struct GraphTraits< ::clang::CFGBlock *> {
-  typedef ::clang::CFGBlock NodeType;
   typedef ::clang::CFGBlock *NodeRef;
   typedef ::clang::CFGBlock::succ_iterator ChildIteratorType;
 
-  static NodeType* getEntryNode(::clang::CFGBlock 

[PATCH] D23783: [Sema][Comments] Support @param with c++ 'using' keyword

2016-08-22 Thread Bruno Cardoso Lopes via cfe-commits
bruno created this revision.
bruno added a reviewer: rsmith.
bruno added a subscriber: cfe-commits.

Give appropriate warnings with -Wdocumentation for @param comments
that refer to function aliases defined with 'using'. Very similar
to typedef's behavior. Support for TypeAliasTemplateDecl comes next.

https://reviews.llvm.org/D23783

Files:
  lib/AST/Comment.cpp
  test/Sema/warn-documentation.cpp

Index: test/Sema/warn-documentation.cpp
===
--- test/Sema/warn-documentation.cpp
+++ test/Sema/warn-documentation.cpp
@@ -368,6 +368,69 @@
 /// \param aaa Meow.
 typedef foo::not_a_function_wrapper<1> test_not_function_like_typedef4;
 
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using1 = int (int aaa, int ccc);
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using2 = int (*)(int aaa, int ccc);
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using3 = int (* const)(int aaa, int ccc);
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using4 = int (C::*)(int aaa, int ccc);
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using5 = foo::function_wrapper;
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using6 = foo::function_wrapper *;
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using7 = foo::function_wrapper &;
+
+// expected-warning@+2 {{parameter 'bbb' not found in the function declaration}} expected-note@+2 {{did you mean 'ccc'?}}
+/// \param aaa Meow.
+/// \param bbb Bbb.
+/// \returns aaa.
+using test_function_like_using8 = foo::function_wrapper &&;
+
+using test_not_function_like_using1 = int (*)(int aaa);
+
+// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
+/// \param aaa Meow.
+using test_not_function_like_using2 = test_not_function_like_using1;
+
+// Check that the diagnostic uses the same command marker as the comment.
+// expected-warning@+1 {{'@param' command used in a comment that is not attached to a function declaration}}
+/// @param aaa Meow.
+using test_not_function_like_using3 = unsigned int;
+
+// expected-warning@+1 {{'\param' command used in a comment that is not attached to a function declaration}}
+/// \param aaa Meow.
+using test_not_function_like_using4 = foo::not_a_function_wrapper<1>;
+
 /// \param aaa Aaa
 /// \param ... Vararg
 int test_vararg_param1(int aaa, ...);
Index: lib/AST/Comment.cpp
===
--- lib/AST/Comment.cpp
+++ lib/AST/Comment.cpp
@@ -226,12 +226,15 @@
   case Decl::Namespace:
 Kind = NamespaceKind;
 break;
+  case Decl::TypeAlias:
   case Decl::Typedef: {
 Kind = TypedefKind;
-// If this is a typedef to something we consider a function, extract
+// If this is a typedef / using to something we consider a function, extract
 // arguments and return type.
-const TypedefDecl *TD = cast(CommentDecl);
-const TypeSourceInfo *TSI = TD->getTypeSourceInfo();
+const TypeSourceInfo *TSI =
+K == Decl::Typedef
+? cast(CommentDecl)->getTypeSourceInfo()
+: cast(CommentDecl)->getTypeSourceInfo();
 if (!TSI)
   break;
 TypeLoc TL = TSI->getTypeLoc().getUnqualifiedLoc();
@@ -302,9 +305,6 @@
 }
 break;
   }
-  case Decl::TypeAlias:
-Kind = TypedefKind;
-break;
   case Decl::TypeAliasTemplate: {
 const TypeAliasTemplateDecl *TAT = cast(CommentDecl);
 Kind = TypedefKind;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D23730#522537, @dblaikie wrote:

> I'd sort of be inclined to remove them, then - but I leave that up to you.


It looks like people create some class, and add GraphTraits specialization for 
it, in the hope that others can use it, but didn't write a test. The right 
thing is to add the test, but I'm not going to be the one. :)

So I'll keep them.


https://reviews.llvm.org/D23730



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


libclang: binary/unary operator spelling

2016-08-22 Thread Markus Lottmann via cfe-commits

Hello,

this is my first patch proposal so please for give me if i made some 
mistakes.


This patch changes the result of clang_getCursorSpelling in the way that 
it returns the operator for 
CXCursor_BinaryOperator/CXCursor_UnaryOperator instead of an empty string.

So e.g. for a + b it returns: +

I would like to know if such a change is welcome or if maybe the
current behavior is intended in a way i failed to perceive.

If yes i would provide a patch which also includes updated tests.

Best Regards,
Markus Lottmann
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index f220ea1..8ac5301 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -4240,6 +4240,18 @@ CXString clang_getCursorSpelling(CXCursor C) {
   return cxstring::createDup(Spell);
 }
 
+if (C.kind == CXCursor_BinaryOperator) {
+  const BinaryOperator *BinOp = cast(E);
+  return cxstring::createDup(
+  BinaryOperator::getOpcodeStr(BinOp->getOpcode()));
+}
+
+if (C.kind == CXCursor_UnaryOperator) {
+  const UnaryOperator *UnOp = cast(E);
+  return cxstring::createDup(
+  UnaryOperator::getOpcodeStr(UnOp->getOpcode()));
+}
+
 const Decl *D = getDeclFromExpr(getCursorExpr(C));
 if (D)
   return getDeclSpelling(D);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko updated this revision to Diff 68908.
Eugene.Zelenko added a comment.

Address review comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D23728

Files:
  docs/clang-tidy/checks/cppcoreguidelines-pro-bounds-constant-array-index.rst
  docs/clang-tidy/checks/google-global-names-in-headers.rst
  docs/clang-tidy/checks/misc-argument-comment.rst
  docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
  docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
  docs/clang-tidy/checks/modernize-use-auto.rst
  docs/clang-tidy/checks/readability-braces-around-statements.rst

Index: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
===
--- docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
+++ docs/clang-tidy/checks/misc-misplaced-widening-cast.rst
@@ -8,22 +8,26 @@
 is misplaced, and there can be loss of precision. Otherwise the cast is
 ineffective.
 
-Example code::
+Example code:
 
+.. code-block:: c++
+
 long f(int x) {
-return (long)(x*1000);
+return (long)(x * 1000);
 }
 
-The result x*1000 is first calculated using int precision. If the result
-exceeds int precision there is loss of precision. Then the result is casted to
-long.
+The result `x * 1000` is first calculated using ``int`` precision. If the result
+exceeds ``int`` precision there is loss of precision. Then the result is casted
+to ``long``.
 
 If there is no loss of precision then the cast can be removed or you can
-explicitly cast to int instead.
+explicitly cast to ``int`` instead.
 
 If you want to avoid loss of precision then put the cast in a proper location,
-for instance::
+for instance:
 
+.. code-block:: c++
+
 long f(int x) {
 return (long)x * 1000;
 }
@@ -32,9 +36,11 @@
 --
 
 Forgetting to place the cast at all is at least as dangerous and at least as
-common as misplacing it. If option ``CheckImplicitCasts`` is enabled (default)
-the checker also detects these cases, for instance::
+common as misplacing it. If :option:`CheckImplicitCasts` is enabled the check
+also detects these cases, for instance:
 
+.. code-block:: c++
+
 long f(int x) {
 return x * 1000;
 }
@@ -43,8 +49,17 @@
 --
 
 Currently warnings are only written for integer conversion. No warning is
-written for this code::
+written for this code:
 
+.. code-block:: c++
+
 double f(float x) {
 return (double)(x * 10.0f);
 }
+
+Options
+---
+
+.. option:: CheckImplicitCasts
+
+   Enable (default) or disable detection of implicit casts.
Index: docs/clang-tidy/checks/readability-braces-around-statements.rst
===
--- docs/clang-tidy/checks/readability-braces-around-statements.rst
+++ docs/clang-tidy/checks/readability-braces-around-statements.rst
@@ -11,14 +11,14 @@
 
 Before:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition)
 statement;
 
 After:
 
-.. code:: c++
+.. code-block:: c++
 
   if (condition) {
 statement;
Index: docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
===
--- docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
+++ docs/clang-tidy/checks/misc-suspicious-missing-comma.rst
@@ -9,16 +9,15 @@
 
 For instance, the following declarations are equivalent:
 
-.. code:: c++
+.. code-block:: c++
 
   const char* A[] = "This is a test";
   const char* B[] = "This" " is a ""test";
 
-
 A common mistake done by programmers is to forget a comma between two string
 literals in an array initializer list.
 
-.. code:: c++
+.. code-block:: c++
 
   const char* Test[] = {
 "line 1",
@@ -28,17 +27,15 @@
 "line 5"
   };
 
-
 The array contains the string "line 2line3" at offset 1 (i.e. Test[1]). Clang
 won't generate warnings at compile time.
 
-This checker may warn incorrectly on cases like:
+This check may warn incorrectly on cases like:
 
-.. code:: c++
+.. code-block:: c++
 
   const char* SupportedFormat[] = {
 "Error %s",
 "Code " PRIu64,   // May warn here.
 "Warning %s",
   };
-
Index: docs/clang-tidy/checks/google-global-names-in-headers.rst
===
--- docs/clang-tidy/checks/google-global-names-in-headers.rst
+++ docs/clang-tidy/checks/google-global-names-in-headers.rst
@@ -3,15 +3,18 @@
 google-global-names-in-headers
 ==
 
-Flag global namespace pollution in header files.
-Right now it only triggers on ``using`` declarations and directives.
+Flag global namespace pollution in header files. Right now it only triggers on
+``using`` declarations and directives.
 
-The check supports these options:
-  - `HeaderFileExtensions`: a comma-separated list of filename extensions
-of header files (the filename extensions should not contain "." prefix).
-"h" by default.
-For extension-less header files, 

Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread David Blaikie via cfe-commits
dblaikie accepted this revision.
dblaikie added a comment.
This revision is now accepted and ready to land.

Or it isn't approved (was mixing up reviews) - but now it is...


https://reviews.llvm.org/D23730



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


Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread David Blaikie via cfe-commits
dblaikie added a comment.

In https://reviews.llvm.org/D23730#522501, @timshen wrote:

> In https://reviews.llvm.org/D23730#522396, @dblaikie wrote:
>
> > Not all of these already had NodeRef implemented - that implies that some 
> > algorithms weren't using NodeRef before this change, or that these traits 
> > are unused? I thought the plan was to migrate each algorithm then just do a 
> > strict cleanup. Did that not pan out/some other aspects I'm forgetting?
>
>
> I think those traits are unused. Notice that by merely removing "NodeType *" 
> declarations, the build/tests doesn't break, so at least they are not covered 
> by the tests.


I'd sort of be inclined to remove them, then - but I leave that up to you.

Otherwise this review is already approved, so commit as you see fit.


https://reviews.llvm.org/D23730



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


Re: [PATCH] D22834: Added 'inline' attribute to basic_string's destructor

2016-08-22 Thread Aditya Kumar via cfe-commits
hiraditya added a comment.

In https://reviews.llvm.org/D22834#522499, @EricWF wrote:

> No benchmark needed but one would be appreciated if possible.


I guess @laxmansole sent you a synthetic benchmark because we were having 
trouble integrating it to the libcxx testsuite. I can send you that again which 
can be submitted as a separate patch if you want.


https://reviews.llvm.org/D22834



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Ben Craig via cfe-commits
bcraig added a comment.

In https://reviews.llvm.org/D23279#522504, @djasper wrote:

> In the meantime, I don't know whether we should check this in as a 
> standalone-tool and then merge into clang-refactor once ready. Ben, what do 
> you think?


Well, I don't know how much you should count my opinion, but my preference is 
to check it in as a standalone tool first, then merge it into clang-rector once 
it is available.  Maybe the build gets turned off by default if we aren't 
comfortable shipping an interim tool.  I'd rather this not linger as a very 
long-term review though.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Daniel Jasper via cfe-commits
djasper added a subscriber: djasper.
djasper added a comment.

Sorry for the long silence. Manuel is currently out on vacation. I am not 
entirely sure how we want to make progress at this point. There seems to be 
consensus that in the mid-term, this should go into the clang-refactor tool. 
However, it might take a bit for that to be there (we have to carefully design 
that, I think). In the meantime, I don't know whether we should check this in 
as a standalone-tool and then merge into clang-refactor once ready. Ben, what 
do you think? Also, I guess we could at the very least start with a proper 
review of the code. That seems to be useful irrespective of how where the code 
ends up in the end.

My only high-level comment so far (will try to review in more detail later) is: 
I find it strange to mix ASTMatchers and a RecursiveASTVisitor in the same 
tool. It seem that if you are using ASTMatchers internally for other things, 
you should also use ASTMatchers to find all the constructors etc. That should 
(I hope) make the code a bit simpler.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread Tim Shen via cfe-commits
timshen added a comment.

In https://reviews.llvm.org/D23730#522396, @dblaikie wrote:

> Not all of these already had NodeRef implemented - that implies that some 
> algorithms weren't using NodeRef before this change, or that these traits are 
> unused? I thought the plan was to migrate each algorithm then just do a 
> strict cleanup. Did that not pan out/some other aspects I'm forgetting?


I think those traits are unused. Notice that by merely removing "NodeType *" 
declarations, the build/tests doesn't break, so at least they are not covered 
by the tests.


https://reviews.llvm.org/D23730



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


Re: [PATCH] D22834: Added 'inline' attribute to basic_string's destructor

2016-08-22 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

No benchmark needed but one would be appreciated if possible.


https://reviews.llvm.org/D22834



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


Re: [PATCH] D20168: [CodeGen] Handle structs directly in AMDGPUABIInfo

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

r279463


https://reviews.llvm.org/D20168



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


r279463 - AMDGPU: Handle structs directly in AMDGPUABIInfo

2016-08-22 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Aug 22 14:25:59 2016
New Revision: 279463

URL: http://llvm.org/viewvc/llvm-project?rev=279463=rev
Log:
AMDGPU: Handle structs directly in AMDGPUABIInfo

Structs are currently handled as pointer + byval, which makes AMDGPU
LLVM backend generate incorrect code when structs are used. This patch
changes struct argument to be handled directly and without flattening,
which Clover (Mesa 3D Gallium OpenCL state tracker) will be able to
handle. Flattening would expand the struct to individual elements and
pass each as a separate argument, which Clover can not
handle. Furthermore, such expansion does not fit the OpenCL
programming model which requires to explicitely specify each argument
index, size and memory location.

Patch by Vedran Miletić

Added:
cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=279463=279462=279463=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Mon Aug 22 14:25:59 2016
@@ -6876,10 +6876,50 @@ public:
 
 namespace {
 
+class AMDGPUABIInfo final : public DefaultABIInfo {
+public:
+  explicit AMDGPUABIInfo(CodeGen::CodeGenTypes ) : DefaultABIInfo(CGT) {}
+
+private:
+  ABIArgInfo classifyArgumentType(QualType Ty) const;
+
+  void computeInfo(CGFunctionInfo ) const override;
+};
+
+void AMDGPUABIInfo::computeInfo(CGFunctionInfo ) const {
+  if (!getCXXABI().classifyReturnType(FI))
+FI.getReturnInfo() = classifyReturnType(FI.getReturnType());
+
+  unsigned CC = FI.getCallingConvention();
+  for (auto  : FI.arguments())
+if (CC == llvm::CallingConv::AMDGPU_KERNEL)
+  Arg.info = classifyArgumentType(Arg.type);
+else
+  Arg.info = DefaultABIInfo::classifyArgumentType(Arg.type);
+}
+
+/// \brief Classify argument of given type \p Ty.
+ABIArgInfo AMDGPUABIInfo::classifyArgumentType(QualType Ty) const {
+  llvm::StructType *StrTy = dyn_cast(CGT.ConvertType(Ty));
+  if (!StrTy) {
+return DefaultABIInfo::classifyArgumentType(Ty);
+  }
+
+  // Coerce single element structs to its element.
+  if (StrTy->getNumElements() == 1) {
+return ABIArgInfo::getDirect();
+  }
+
+  // If we set CanBeFlattened to true, CodeGen will expand the struct to its
+  // individual elements, which confuses the Clover OpenCL backend; therefore 
we
+  // have to set it to false here. Other args of getDirect() are just defaults.
+  return ABIArgInfo::getDirect(nullptr, 0, nullptr, false);
+}
+
 class AMDGPUTargetCodeGenInfo : public TargetCodeGenInfo {
 public:
   AMDGPUTargetCodeGenInfo(CodeGenTypes )
-: TargetCodeGenInfo(new DefaultABIInfo(CGT)) {}
+: TargetCodeGenInfo(new AMDGPUABIInfo(CGT)) {}
   void setTargetAttributes(const Decl *D, llvm::GlobalValue *GV,
CodeGen::CodeGenModule ) const override;
   unsigned getOpenCLKernelCallingConv() const override;

Added: cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl?rev=279463=auto
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl (added)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl Mon Aug 22 
14:25:59 2016
@@ -0,0 +1,66 @@
+// REQUIRES: amdgpu-registered-target
+// RUN: %clang_cc1 -triple amdgcn-unknown-unknown -S -emit-llvm -o - %s | 
FileCheck %s
+
+// CHECK-NOT: %struct.single_element_struct_arg = type { i32 }
+typedef struct single_element_struct_arg
+{
+int i;
+} single_element_struct_arg_t;
+
+// CHECK: %struct.struct_arg = type { i32, float, i32 }
+typedef struct struct_arg
+{
+int i1;
+float f;
+int i2;
+} struct_arg_t;
+
+// CHECK: %struct.struct_of_arrays_arg = type { [2 x i32], float, [4 x i32], 
[3 x float], i32 }
+typedef struct struct_of_arrays_arg
+{
+int i1[2];
+float f1;
+int i2[4];
+float f2[3];
+int i3;
+} struct_of_arrays_arg_t;
+
+// CHECK: %struct.struct_of_structs_arg = type { i32, float, 
%struct.struct_arg, i32 }
+typedef struct struct_of_structs_arg
+{
+int i1;
+float f1;
+struct_arg_t s1;
+int i2;
+} struct_of_structs_arg_t;
+
+// CHECK-LABEL: @test_single_element_struct_arg
+// CHECK: i32 %arg1.coerce
+__kernel void test_single_element_struct_arg(single_element_struct_arg_t arg1)
+{
+}
+
+// CHECK-LABEL: @test_struct_arg
+// CHECK: %struct.struct_arg %arg1.coerce
+__kernel void test_struct_arg(struct_arg_t arg1)
+{
+}
+
+// CHECK-LABEL: @test_struct_of_arrays_arg
+// CHECK: %struct.struct_of_arrays_arg %arg1.coerce
+__kernel void test_struct_of_arrays_arg(struct_of_arrays_arg_t arg1)
+{
+}
+
+// CHECK-LABEL: @test_struct_of_structs_arg
+// CHECK: %struct.struct_of_structs_arg %arg1.coerce

r279457 - ADT: Remove uses of ilist_*sentinel_traits, NFC

2016-08-22 Thread Duncan P. N. Exon Smith via cfe-commits
Author: dexonsmith
Date: Mon Aug 22 13:57:44 2016
New Revision: 279457

URL: http://llvm.org/viewvc/llvm-project?rev=279457=rev
Log:
ADT: Remove uses of ilist_*sentinel_traits, NFC

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

Modified: cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h?rev=279457=279456=279457=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h 
(original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h Mon 
Aug 22 13:57:44 2016
@@ -311,18 +311,6 @@ public:
   virtual void Profile(llvm::FoldingSetNodeID& hash) const;
 };
 
-} // end ento namespace
-} // end clang namespace
-
-namespace llvm {
-template <>
-struct ilist_sentinel_traits
-: public ilist_half_embedded_sentinel_traits {};
-}
-
-namespace clang {
-namespace ento {
-
 
//===--===//
 // BugTypes (collections of related reports).
 
//===--===//


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


Re: [PATCH] D22834: Added 'inline' attribute to basic_string's destructor

2016-08-22 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Eric - did you want to see a benchmark as part of this commit?


https://reviews.llvm.org/D22834



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


Re: [PATCH] D23526: [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-22 Thread Artem Belevich via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279455: [CUDA] Collapsed offload actions should not be 
top-level jobs. (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D23526?vs=68100=68896#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23526

Files:
  cfe/trunk/lib/Driver/Driver.cpp
  cfe/trunk/test/Driver/cuda-bindings.cu

Index: cfe/trunk/test/Driver/cuda-bindings.cu
===
--- cfe/trunk/test/Driver/cuda-bindings.cu
+++ cfe/trunk/test/Driver/cuda-bindings.cu
@@ -0,0 +1,137 @@
+// Tests the bindings generated for a CUDA offloading target for different
+// combinations of:
+// - Number of gpu architectures;
+// - Host/device-only compilation;
+// - User-requested final phase - binary or assembly.
+// It parallels cuda-phases.cu test, but verifies whether output file is temporary or not.
+
+// It's hard to check whether file name is temporary in a portable
+// way. Instead we check whether we've generated a permanent name on
+// device side, which appends '-device-cuda-' suffix.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Test single gpu architecture with complete compilation.
+// No intermediary device files should have "-device-cuda..." in the name.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN %s
+// BIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test single gpu architecture up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test two gpu architectures with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings --cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN2 %s
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test two gpu architectures up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM2 %s
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: "cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_35.s"
+// ASM2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: "cuda-bindings.s"
+
+//
+// Test one or more gpu architecture with complete compilation in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s --cuda-host-only 2>&1 \
+// RUN: | FileCheck -check-prefix=HBIN %s
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// HBIN-NOT: cuda-bindings-device-cuda-nvptx64
+// HBIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: "a.out"
+
+//
+// Test one or more gpu architecture up to the assemble phase in host-only
+// compilation mode.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 %s --cuda-host-only -S 2>&1 \
+// RUN: | 

r279455 - [CUDA] Collapsed offload actions should not be top-level jobs.

2016-08-22 Thread Artem Belevich via cfe-commits
Author: tra
Date: Mon Aug 22 13:50:34 2016
New Revision: 279455

URL: http://llvm.org/viewvc/llvm-project?rev=279455=rev
Log:
[CUDA] Collapsed offload actions should not be top-level jobs.

If they are, we end up with the last intermediary output preserved
in the current directory after compilation.

Added a test case to verify that we're using appropriate filenames
for outputs of different phases.

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

Added:
cfe/trunk/test/Driver/cuda-bindings.cu
Modified:
cfe/trunk/lib/Driver/Driver.cpp

Modified: cfe/trunk/lib/Driver/Driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Driver.cpp?rev=279455=279454=279455=diff
==
--- cfe/trunk/lib/Driver/Driver.cpp (original)
+++ cfe/trunk/lib/Driver/Driver.cpp Mon Aug 22 13:50:34 2016
@@ -2230,7 +2230,7 @@ InputInfo Driver::BuildJobsForActionNoCa
 /*IsHostDependence=*/BuildForOffloadDevice,
 [&](Action *DepA, const ToolChain *DepTC, const char *DepBoundArch) {
   OffloadDependencesInputInfo.push_back(BuildJobsForAction(
-  C, DepA, DepTC, DepBoundArch, AtTopLevel,
+  C, DepA, DepTC, DepBoundArch, /* AtTopLevel */ false,
   /*MultipleArchs=*/!!DepBoundArch, LinkingOutput, CachedResults,
   /*BuildForOffloadDevice=*/DepA->getOffloadingDeviceKind() !=
   Action::OFK_None));

Added: cfe/trunk/test/Driver/cuda-bindings.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/cuda-bindings.cu?rev=279455=auto
==
--- cfe/trunk/test/Driver/cuda-bindings.cu (added)
+++ cfe/trunk/test/Driver/cuda-bindings.cu Mon Aug 22 13:50:34 2016
@@ -0,0 +1,137 @@
+// Tests the bindings generated for a CUDA offloading target for different
+// combinations of:
+// - Number of gpu architectures;
+// - Host/device-only compilation;
+// - User-requested final phase - binary or assembly.
+// It parallels cuda-phases.cu test, but verifies whether output file is 
temporary or not.
+
+// It's hard to check whether file name is temporary in a portable
+// way. Instead we check whether we've generated a permanent name on
+// device side, which appends '-device-cuda-' suffix.
+
+// REQUIRES: clang-driver
+// REQUIRES: powerpc-registered-target
+// REQUIRES: nvptx-registered-target
+
+//
+// Test single gpu architecture with complete compilation.
+// No intermediary device files should have "-device-cuda..." in the name.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings 
--cuda-gpu-arch=sm_30 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN %s
+// BIN: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: 
"a.out"
+
+//
+// Test single gpu architecture up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings 
--cuda-gpu-arch=sm_30 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM %s
+// ASM: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output: 
"cuda-bindings-device-cuda-nvptx64-nvidia-cuda-sm_30.s"
+// ASM: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}} output: 
"cuda-bindings.s"
+
+//
+// Test two gpu architectures with complete compilation.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings 
--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s 2>&1 \
+// RUN: | FileCheck -check-prefix=BIN2 %s
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "clang",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Assembler",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "nvptx64-nvidia-cuda" - "NVPTX::Linker",{{.*}} output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "clang",{{.*}}  output:
+// BIN2-NOT: cuda-bindings-device-cuda-nvptx64
+// BIN2: # "powerpc64le-ibm-linux-gnu" - "GNU::Linker", inputs:{{.*}}, output: 
"a.out"
+
+//
+// Test two gpu architectures up to the assemble phase.
+//
+// RUN: %clang -target powerpc64le-ibm-linux-gnu -ccc-print-bindings \
+// RUN:--cuda-gpu-arch=sm_30 --cuda-gpu-arch=sm_35 %s -S 2>&1 \
+// RUN: | FileCheck -check-prefix=ASM2 %s
+// ASM2: # "nvptx64-nvidia-cuda" - 

Re: [PATCH] D23685: [libcxx] [test] Include the iterator header for back_inserter.

2016-08-22 Thread Marshall Clow via cfe-commits
mclow.lists accepted this revision.
mclow.lists added a comment.
This revision is now accepted and ready to land.

Committed as revision 279453


https://reviews.llvm.org/D23685



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


[libcxx] r279453 - Add missing include that caused a test failure on Windows. Thanks to STL for the patch. No functional change.

2016-08-22 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Mon Aug 22 13:45:31 2016
New Revision: 279453

URL: http://llvm.org/viewvc/llvm-project?rev=279453=rev
Log:
Add missing include that caused a test failure on Windows. Thanks to STL for 
the patch. No functional change.

Modified:

libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp

Modified: 
libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp?rev=279453=279452=279453=diff
==
--- 
libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp 
(original)
+++ 
libcxx/trunk/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp 
Mon Aug 22 13:45:31 2016
@@ -17,6 +17,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 


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


Re: [PATCH] D23730: [GraphTraits] Replace all NodeType usage with NodeRef

2016-08-22 Thread David Blaikie via cfe-commits
dblaikie added a comment.

Not all of these already had NodeRef implemented - that implies that some 
algorithms weren't using NodeRef before this change, or that these traits are 
unused? I thought the plan was to migrate each algorithm then just do a strict 
cleanup. Did that not pan out/some other aspects I'm forgetting?



Comment at: llvm/trunk/include/llvm/CodeGen/ScheduleDAG.h:684-688
@@ -684,7 +683,7 @@
 typedef SUnitIterator ChildIteratorType;
-static inline NodeType *getEntryNode(SUnit *N) { return N; }
-static inline ChildIteratorType child_begin(NodeType *N) {
+static inline NodeRef getEntryNode(SUnit *N) { return N; }
+static inline ChildIteratorType child_begin(NodeRef N) {
   return SUnitIterator::begin(N);
 }
-static inline ChildIteratorType child_end(NodeType *N) {
+static inline ChildIteratorType child_end(NodeRef N) {
   return SUnitIterator::end(N);

If you like you could probably (separate commit) drop the 'inline' from these 
functions, they're implicitly inline anyway


Comment at: llvm/trunk/include/llvm/CodeGen/SelectionDAGNodes.h:2060-2064
@@ -2060,7 +2059,7 @@
   typedef SDNodeIterator ChildIteratorType;
-  static inline NodeType *getEntryNode(SDNode *N) { return N; }
-  static inline ChildIteratorType child_begin(NodeType *N) {
+  static inline NodeRef getEntryNode(SDNode *N) { return N; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return SDNodeIterator::begin(N);
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
+  static inline ChildIteratorType child_end(NodeRef N) {
 return SDNodeIterator::end(N);

and here


Comment at: llvm/trunk/include/llvm/IR/CFG.h:161-164
@@ -163,6 +160,6 @@
+  static NodeRef getEntryNode(BasicBlock *BB) { return BB; }
+  static inline ChildIteratorType child_begin(NodeRef N) {
 return succ_begin(N);
   }
-  static inline ChildIteratorType child_end(NodeType *N) {
-return succ_end(N);
-  }
+  static inline ChildIteratorType child_end(NodeRef N) { return succ_end(N); }
 };

And here.. and so on.


https://reviews.llvm.org/D23730



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


Re: [PATCH] D22766: Handle -mlong-calls on Hexagon

2016-08-22 Thread Krzysztof Parzyszek via cfe-commits
kparzysz added a comment.

Ping.


Repository:
  rL LLVM

https://reviews.llvm.org/D22766



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


Re: [PATCH] D23719: [libc++] Use C11 for atomics check

2016-08-22 Thread Shoaib Meenai via cfe-commits
smeenai abandoned this revision.
smeenai added a comment.

Will create a different change with the other config change, since it's 
completely different conceptually.


https://reviews.llvm.org/D23719



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


[PATCH] D23780: [analyzer] Fixed crash in StmtDataCollector when analyzing methods of template classes.

2016-08-22 Thread Raphael Isemann via cfe-commits
teemperor created this revision.
teemperor added reviewers: v.g.vassilev, NoQ.
teemperor added a subscriber: cfe-commits.

The current check with `isTemplateInstantiation()` is also returning true when 
calling a member method of a template class. In this case 
getTemplateSpecializationArgs() returns a null pointer and we crash. It seems 
the intended way to check for template specialization args is to make a nullptr 
check on getTemplateSpecializationArgs() which we start doing with this patch. 
We don't need to add any code for the member methods of template classes as the 
qualified type of the calling object already contains the template arguments of 
the class.

https://reviews.llvm.org/D23780

Files:
  lib/Analysis/CloneDetection.cpp
  test/Analysis/copypaste/call.cpp

Index: test/Analysis/copypaste/call.cpp
===
--- test/Analysis/copypaste/call.cpp
+++ test/Analysis/copypaste/call.cpp
@@ -88,3 +88,15 @@
 return templatePaddingFunc();
   return true;
 }
+
+// Test that we don't crash on member functions of template instantiations.
+
+template
+struct A {
+  void foo(T t) {}
+};
+
+void fooTestInstantiation() {
+  A a;
+  a.foo(1);
+}
Index: lib/Analysis/CloneDetection.cpp
===
--- lib/Analysis/CloneDetection.cpp
+++ lib/Analysis/CloneDetection.cpp
@@ -185,10 +185,9 @@
   DEF_ADD_DATA(CallExpr, {
 // Function pointers don't have a callee and we just skip hashing it.
 if (const FunctionDecl *D = S->getDirectCallee()) {
-  // If the function is a template instantiation, we also need to handle
-  // the template arguments as they are no included in the qualified name.
-  if (D->isTemplateInstantiation()) {
-auto Args = D->getTemplateSpecializationArgs();
+  // If the function is a template specialization, we also need to handle
+  // the template arguments as they are not included in the qualified name.
+  if (auto Args = D->getTemplateSpecializationArgs()) {
 std::string ArgString;
 
 // Print all template arguments into ArgString


Index: test/Analysis/copypaste/call.cpp
===
--- test/Analysis/copypaste/call.cpp
+++ test/Analysis/copypaste/call.cpp
@@ -88,3 +88,15 @@
 return templatePaddingFunc();
   return true;
 }
+
+// Test that we don't crash on member functions of template instantiations.
+
+template
+struct A {
+  void foo(T t) {}
+};
+
+void fooTestInstantiation() {
+  A a;
+  a.foo(1);
+}
Index: lib/Analysis/CloneDetection.cpp
===
--- lib/Analysis/CloneDetection.cpp
+++ lib/Analysis/CloneDetection.cpp
@@ -185,10 +185,9 @@
   DEF_ADD_DATA(CallExpr, {
 // Function pointers don't have a callee and we just skip hashing it.
 if (const FunctionDecl *D = S->getDirectCallee()) {
-  // If the function is a template instantiation, we also need to handle
-  // the template arguments as they are no included in the qualified name.
-  if (D->isTemplateInstantiation()) {
-auto Args = D->getTemplateSpecializationArgs();
+  // If the function is a template specialization, we also need to handle
+  // the template arguments as they are not included in the qualified name.
+  if (auto Args = D->getTemplateSpecializationArgs()) {
 std::string ArgString;
 
 // Print all template arguments into ArgString
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r279445 - PR29086: DebugInfo: Improve support for fixed array dimensions in variable length arrays

2016-08-22 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Aug 22 12:49:56 2016
New Revision: 279445

URL: http://llvm.org/viewvc/llvm-project?rev=279445=rev
Log:
PR29086: DebugInfo: Improve support for fixed array dimensions in variable 
length arrays

Added:
cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=279445=279444=279445=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Mon Aug 22 12:49:56 2016
@@ -2122,6 +2122,11 @@ llvm::DIType *CGDebugInfo::CreateType(co
 int64_t Count = -1; // Count == -1 is an unbounded array.
 if (const auto *CAT = dyn_cast(Ty))
   Count = CAT->getSize().getZExtValue();
+else if (const auto *VAT = dyn_cast(Ty)) {
+  llvm::APSInt V;
+  if (VAT->getSizeExpr()->EvaluateAsInt(V, CGM.getContext()))
+Count = V.getExtValue();
+}
 
 // FIXME: Verify this is right for VLAs.
 Subscripts.push_back(DBuilder.getOrCreateSubrange(0, Count));

Added: cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp?rev=279445=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/debug-info-vla.cpp Mon Aug 22 12:49:56 2016
@@ -0,0 +1,14 @@
+// RUN: %clang -target x86_64-unknown-unknown -fverbose-asm -g -O0 -S 
-emit-llvm %s -o - | FileCheck %s
+
+
+void f(int m) {
+  int x[3][m];
+}
+
+// CHECK: !DICompositeType(tag: DW_TAG_array_type,
+// CHECK-NOT:   size:
+// CHECK-SAME:  align: 32
+// CHECK-SAME:  elements: [[ELEM_TYPE:![0-9]+]]
+// CHECK: [[ELEM_TYPE]] = !{[[SUB1:.*]], [[SUB2:.*]]}
+// CHECK: [[SUB1]] = !DISubrange(count: 3)
+// CHECK: [[SUB2]] = !DISubrange(count: -1)


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


r279444 - Remove redundant test

2016-08-22 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Mon Aug 22 12:49:50 2016
New Revision: 279444

URL: http://llvm.org/viewvc/llvm-project?rev=279444=rev
Log:
Remove redundant test

test/CodeGenCXX/debug-info-zero-length-arrays.cpp tests this
functionality more comprehensively

Removed:
cfe/trunk/test/CodeGenCXX/debug-info-flex-member.cpp

Removed: cfe/trunk/test/CodeGenCXX/debug-info-flex-member.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/debug-info-flex-member.cpp?rev=279443=auto
==
--- cfe/trunk/test/CodeGenCXX/debug-info-flex-member.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/debug-info-flex-member.cpp (removed)
@@ -1,9 +0,0 @@
-// RUN: %clang_cc1 -emit-llvm -debug-info-kind=limited -triple 
x86_64-apple-darwin %s -o - | FileCheck %s
-
-// CHECK: !DISubrange(count: -1)
-
-struct StructName {
-  int member[];
-};
-
-struct StructName SN;


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


Re: [PATCH] D23492: Make function local tags visible.

2016-08-22 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3617
@@ +3616,3 @@
+PatternDef = nullptr;
+  // FIXME: We need to track the instantiation stack in order to know which
+  // definitions should be visible within this instantiation.

akuegel wrote:
> v.g.vassilev wrote:
> > akuegel wrote:
> > > Line 3619 to 3623 breaks the compilation of some of our targets. I am not 
> > > sure if it is because of a mistake in our code or if there is something 
> > > bad in this patch.
> > > This comment seems to indicate that there is still something missing to 
> > > make the check here correct?
> > @akuegel, would you be able to reduce a standalone example?
> I tried to create a simple example, but those simple cases worked fine. So I 
> am not sure what is going on in the more complex cases. I have asked Richard 
> for help. Since Richard has access to that broken code, I hope he will figure 
> it out.
Thanks! Otherwise, maybe `creduce` could help.


https://reviews.llvm.org/D23492



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


Re: [PATCH] D23343: [clang-tidy] modernize-make-{smart_ptr} private ctor bugfix

2016-08-22 Thread Alexander Kornienko via cfe-commits
alexfh accepted this revision.
alexfh added a comment.

LG. Thank you!


https://reviews.llvm.org/D23343



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


[clang-tools-extra] r279442 - [clang-tidy docs] Further cleanup of options

2016-08-22 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Aug 22 12:19:23 2016
New Revision: 279442

URL: http://llvm.org/viewvc/llvm-project?rev=279442=rev
Log:
[clang-tidy docs] Further cleanup of options

Modified:

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/performance-faster-string-find.rst

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-simplify-boolean-expr.rst

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst?rev=279442=279441=279442=diff
==
--- 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
 (original)
+++ 
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
 Mon Aug 22 12:19:23 2016
@@ -24,13 +24,14 @@ types without a user-provided constructo
 fix is to zero initialize the variable via ``{}`` for C++11 and beyond or ``=
 {}`` for older language versions.
 
-IgnoreArrays option

+Options
+---
 
-For performance critical code, it may be important to not zero
-fixed-size array members. If on, IgnoreArrays will not warn about
-array members that are not zero-initialized during construction.
-IgnoreArrays is false by default.
+.. option:: IgnoreArrays
+
+   If set to non-zero, the check will not warn about array members that are not
+   zero-initialized during construction. For performance critical code, it may
+   be important to not initialize fixed-size array members.  Default is `0`.
 
 This rule is part of the "Type safety" profile of the C++ Core
 Guidelines, corresponding to rule Type.6. See

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst?rev=279442=279441=279442=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-emplace.rst 
Mon Aug 22 12:19:23 2016
@@ -22,9 +22,9 @@ Before:
 std::vector v;
 v.push_back(MyClass(21, 37));
 
-std::vector> w;
+std::vector> w;
 
-w.push_back(std::pair(21, 37));
+w.push_back(std::pair(21, 37));
 w.push_back(std::make_pair(21L, 37L));
 
 After:
@@ -34,7 +34,7 @@ After:
 std::vector v;
 v.emplace_back(21, 37);
 
-std::vector> w;
+std::vector> w;
 w.emplace_back(21, 37);
 // This will be fixed to w.push_back(21, 37); in next version
 w.emplace_back(std::make_pair(21L, 37L);
@@ -80,9 +80,11 @@ other classes use the :option:`SmartPoin
 
 
 Check also fires if any argument of constructor call would be:
-- bitfield (bitfields can't bind to rvalue/universal reference)
-- ``new`` expression (to avoid leak)
-or if the argument would be converted via derived-to-base cast.
+
+  - bitfield (bitfields can't bind to rvalue/universal reference)
+
+  - ``new`` expression (to avoid leak) or if the argument would be converted 
via
+derived-to-base cast.
 
 This check requires C++11 of higher to run.
 

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst?rev=279442=279441=279442=diff
==
--- clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst 
(original)
+++ clang-tools-extra/trunk/docs/clang-tidy/checks/modernize-use-nullptr.rst 
Mon Aug 22 12:19:23 2016
@@ -41,10 +41,9 @@ Options
 
 .. option:: UserNullMacros
 
-   By default this check will only replace the ``NULL`` macro and will skip any
-   user-defined macros that behaves like ``NULL``. The user can use the
-   :option:`UserNullMacros` option to specify a comma-separated list of macro
-   names that will be transformed along with ``NULL``.
+   Comma-separated list of macro names that will be transformed along with
+   ``NULL``. By default this check will only replace the ``NULL`` macro and 
will
+   skip any similar user-defined macros.
 
 Example
 ^^^

Modified: 
clang-tools-extra/trunk/docs/clang-tidy/checks/performance-faster-string-find.rst
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/docs/clang-tidy/checks/performance-faster-string-find.rst?rev=279442=279441=279442=diff

Re: [PATCH] D23728: [Clang-tidy] Fix style in some checks documentation

2016-08-22 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please rebase your patch, I've made some changes to some of these files.



Comment at: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst:39
@@ -34,3 +38,3 @@
 Forgetting to place the cast at all is at least as dangerous and at least as
-common as misplacing it. If option ``CheckImplicitCasts`` is enabled (default)
-the checker also detects these cases, for instance::
+common as misplacing it. If :option:`CheckImplicitCasts` is enabled (default)
+the check also detects these cases, for instance:

The `.. option:: CheckImplicitCasts` block should be added in this document to 
prevent Sphinx warnings. In order to verify this, you should install Sphinx 
1.4.5 (on linux this can be done using `pip install -u Sphinx`, not sure about 
Windows).


Comment at: docs/clang-tidy/checks/misc-misplaced-widening-cast.rst:57
@@ -48,3 +56,3 @@
 double f(float x) {
-return (double)(x * 10.0f);
+return (double) (x * 10.0f);
 }

No space after the closing parenthesis is needed. Same above.


Repository:
  rL LLVM

https://reviews.llvm.org/D23728



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


Re: [PATCH] D23492: Make function local tags visible.

2016-08-22 Thread Adrian Kuegel via cfe-commits
akuegel added inline comments.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3617
@@ +3616,3 @@
+PatternDef = nullptr;
+  // FIXME: We need to track the instantiation stack in order to know which
+  // definitions should be visible within this instantiation.

v.g.vassilev wrote:
> akuegel wrote:
> > Line 3619 to 3623 breaks the compilation of some of our targets. I am not 
> > sure if it is because of a mistake in our code or if there is something bad 
> > in this patch.
> > This comment seems to indicate that there is still something missing to 
> > make the check here correct?
> @akuegel, would you be able to reduce a standalone example?
I tried to create a simple example, but those simple cases worked fine. So I am 
not sure what is going on in the more complex cases. I have asked Richard for 
help. Since Richard has access to that broken code, I hope he will figure it 
out.


https://reviews.llvm.org/D23492



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-08-22 Thread Asiri Rathnayake via cfe-commits
rmaprath added a comment.

Comments from @mclow.lists on the latest revision (received offline):

- Need instructions on how to build and test the patch...
- Need to be able to build+test on Mac (looks like there is a small problem in 
the patch w.r.t pthreads that makes the build fail on Mac)
- Need to work on shared library builds as well

I will address these comments soon (as soon as I get familiar with how Macs 
work...)


https://reviews.llvm.org/D21968



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


Re: r278483 - This patch implements PR#22821.

2016-08-22 Thread Nico Weber via cfe-commits
I don't see any approval after Aaron's "Please wait until someone has had
the chance to review before committing" on https://reviews.llvm.org/D20561
-- was this reviewed on IRC?

On Fri, Aug 12, 2016 at 4:04 AM, Roger Ferrer Ibanez via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rogfer01
> Date: Fri Aug 12 03:04:13 2016
> New Revision: 278483
>
> URL: http://llvm.org/viewvc/llvm-project?rev=278483=rev
> Log:
> This patch implements PR#22821.
>
> Taking the address of a packed member is dangerous since the reduced
> alignment of the pointee is lost. This can lead to memory alignment
> faults in some architectures if the pointer value is dereferenced.
>
> This change adds a new warning to clang emitted when taking the address
> of a packed member. A packed member is either a field/data member
> declared as attribute((packed)) or belonging to a struct/class
> declared as such. The associated flag is -Waddress-of-packed-member.
> Conversions (either implicit or via a valid casting) to pointer types
> with lower or equal alignment requirements (e.g. void* or char*)
> will silence the warning.
>
> Differential Revision: https://reviews.llvm.org/D20561
>
>
>
> Modified:
> cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> cfe/trunk/include/clang/Sema/Sema.h
> cfe/trunk/lib/Sema/SemaCast.cpp
> cfe/trunk/lib/Sema/SemaChecking.cpp
> cfe/trunk/lib/Sema/SemaExpr.cpp
> cfe/trunk/lib/Sema/SemaInit.cpp
>
> Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/
> DiagnosticSemaKinds.td?rev=278483=278482=278483=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
> +++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Fri Aug 12
> 03:04:13 2016
> @@ -5489,6 +5489,9 @@ def warn_pointer_indirection_from_incomp
>"dereference of type %1 that was reinterpret_cast from type %0 has
> undefined "
>"behavior">,
>InGroup, DefaultIgnore;
> +def warn_taking_address_of_packed_member : Warning<
> +  "taking address of packed member %0 of class or structure %q1 may
> result in an unaligned pointer value">,
> +  InGroup>;
>
>  def err_objc_object_assignment : Error<
>"cannot assign to class object (%0 invalid)">;
>
> Modified: cfe/trunk/include/clang/Sema/Sema.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Sema/Sema.h?rev=278483=278482=278483=diff
> 
> ==
> --- cfe/trunk/include/clang/Sema/Sema.h (original)
> +++ cfe/trunk/include/clang/Sema/Sema.h Fri Aug 12 03:04:13 2016
> @@ -9570,6 +9570,10 @@ private:
>void CheckArgumentWithTypeTag(const ArgumentWithTypeTagAttr *Attr,
>  const Expr * const *ExprArgs);
>
> +  /// \brief Check if we are taking the address of a packed field
> +  /// as this may be a problem if the pointer value is dereferenced.
> +  void CheckAddressOfPackedMember(Expr *rhs);
> +
>/// \brief The parser's current scope.
>///
>/// The parser maintains this state here.
> @@ -9664,6 +9668,51 @@ public:
>// Emitting members of dllexported classes is delayed until the class
>// (including field initializers) is fully parsed.
>SmallVector DelayedDllExportClasses;
> +
> +private:
> +  /// \brief Helper class that collects misaligned member designations and
> +  /// their location info for delayed diagnostics.
> +  struct MisalignedMember {
> +Expr *E;
> +RecordDecl *RD;
> +ValueDecl *MD;
> +CharUnits Alignment;
> +
> +MisalignedMember() : E(), RD(), MD(), Alignment() {}
> +MisalignedMember(Expr *E, RecordDecl *RD, ValueDecl *MD,
> + CharUnits Alignment)
> +: E(E), RD(RD), MD(MD), Alignment(Alignment) {}
> +explicit MisalignedMember(Expr *E)
> +: MisalignedMember(E, nullptr, nullptr, CharUnits()) {}
> +
> +bool operator==(const MisalignedMember ) { return this->E == m.E; }
> +  };
> +  /// \brief Small set of gathered accesses to potentially misaligned
> members
> +  /// due to the packed attribute.
> +  SmallVector MisalignedMembers;
> +
> +  /// \brief Adds an expression to the set of gathered misaligned members.
> +  void AddPotentialMisalignedMembers(Expr *E, RecordDecl *RD, ValueDecl
> *MD,
> + CharUnits Alignment);
> +
> +public:
> +  /// \brief Diagnoses the current set of gathered accesses. This
> typically
> +  /// happens at full expression level. The set is cleared after emitting
> the
> +  /// diagnostics.
> +  void DiagnoseMisalignedMembers();
> +
> +  /// \brief This function checks if the expression is in the sef of
> potentially
> +  /// misaligned members and it is converted to some pointer type T with
> lower
> +  /// or equal 

Re: [PATCH] D23492: Make function local tags visible.

2016-08-22 Thread Vassil Vassilev via cfe-commits
v.g.vassilev added inline comments.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3617
@@ +3616,3 @@
+PatternDef = nullptr;
+  // FIXME: We need to track the instantiation stack in order to know which
+  // definitions should be visible within this instantiation.

akuegel wrote:
> Line 3619 to 3623 breaks the compilation of some of our targets. I am not 
> sure if it is because of a mistake in our code or if there is something bad 
> in this patch.
> This comment seems to indicate that there is still something missing to make 
> the check here correct?
@akuegel, would you be able to reduce a standalone example?


https://reviews.llvm.org/D23492



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Alexander Shaposhnikov via cfe-commits
alexshap added a comment.

Thanks for the comments. @bcraig, multi-TU support is in - in the sense that 
it's in at the same level, as it's in for clang-rename and the other tools 
(take a look my comments above, please). Also:
@omtcyf0:

> Well, multi-TU support is needed for many tools and it is far beyond one tool 
> implementation details if we want it to be >nice. I want to have multi-TU 
> support in the clang-refactor, but it is still in designing stage at the 
> moment. At first, one >translation unit might be okay, though.


Regarding the tests - yes, i used the other tools as an example.


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-08-22 Thread Asiri Rathnayake via cfe-commits
rmaprath added inline comments.


Comment at: include/__external_threading:26
@@ +25,3 @@
+
+#if !defined(_LIBCPP_MUTEX_T) || \
+!defined(_LIBCPP_MUTEX_INITIALIZER) || \

mclow.lists wrote:
> bcraig wrote:
> > So users of external pthreading (or their compiler driver) would need to 
> > provide a pile of -D options on the command line?  Or is it expected that 
> > users will have their own __external_threading header that comes earlier in 
> > the include path?  Please document your expectation.
> My expectation is that system vendors who have a different threading 
> implementation will ship a customized version of the libc++ headers and 
> dylib. 
> 
> The headers will include a replacement `include/__external_threading`, and a 
> modified `include/__config` that contains additional `#define`s
> 
> What this patch does is to provide a customization point to produce such 
> libraries.
> 
This is correct.

With the latest revision, I (following @bcraig's comments) have made this a bit 
more simpler; system vendors can simply drop in the header 
`include/__external_threading` to override the default threading 
implementation. When this header is provided (and 
`_LIBCPP_HAS_THREAD_API_EXTERNAL` is defined - which is automatically wired 
into  `__config` header through `__config_site.in` at build time), the built 
library will end up using the new threading implementation.


https://reviews.llvm.org/D21968



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


Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-08-22 Thread Daniel Jasper via cfe-commits
djasper added a comment.

I think the IndentLevel in WhitespaceManager (and the nested Change) is a 
horrible mess and should be cleaned up. It gets set either to 0 or to the 
"Level" of the AnnotatedLine. To me only the latter makes sense as the line 
defines the indent level. Everything else, including recomputing this and 
introducing a ScopeLevel makes the current situation worse. I can try to do 
this in advance of this patch, if you prefer.


https://reviews.llvm.org/D21279



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


Re: [PATCH] D23418: [analyzer] Added a reusable constraint system to the CloneDetector

2016-08-22 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: include/clang/Analysis/CloneDetection.h:243
@@ +242,3 @@
+/// clone groups from the given hash group.
+virtual bool acceptsHashGroup(const CloneGroup );
+

I might be wishing a lot, but i've a feeling this interface should be more 
obvious, i.e. understandable without reading the cpp code.

For example, what is the difference between `acceptsHashGroup` and 
`acceptsGroup`? I don't think the difference is about accepting different kinds 
of groups ("hash"-groups vs. "non-hash" groups). If two items X and Y are 
similar in some sense (and here we have methods with similar names and similar 
prototypes, and the reader would instantly notice that), it's a good trick to 
first confirm that these are similar, and then highlight the difference: 
"However, unlike X, the Y is...".

Another example - are these `accept...` functions supposed to be "pure" (just 
have a look at the sequence or a group and say if we accept it), or are they 
supposed to change state of the constraint object? I wish it was obvious from 
just looking at the interface.

If i wished for even more, i wish this interface could consist of only one 
method. It seems that this interface is complicated because of performance 
considerations. So i'd probably want to know more about these considerations, 
how exactly do all the methods fit together and what is the efficient way of 
using them.

In order to solve this problem, probably the comment before the class could be 
extended to explain the big picture. I'd also do my best to understand things 
better, and probably come up with a wording that would look better from a 
bystander point of view. Here are a few examples of what seems easier to 
understand:
- "/// First, CloneDetector filters out groups that are obviously out of 
place... Then, it takes one prototype from each group and repeatedly asks the 
Constraint object if other clones of the group are similar to the prototype..."
- "/// If it is obvious just by looking at this group that all sequences in it 
shouldn't ever be reported, override this callback to notify CloneDetector 
about that and save some performance..."
- "/// In this callback you may record the property of the prototype you're 
interested in, so that later you could quickly compare other sequences to it..."


https://reviews.llvm.org/D23418



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


Re: [PATCH] D21968: [libcxx] Externally threaded libc++ variant - Take 2

2016-08-22 Thread Marshall Clow via cfe-commits
mclow.lists added inline comments.


Comment at: include/__external_threading:26
@@ +25,3 @@
+
+#if !defined(_LIBCPP_MUTEX_T) || \
+!defined(_LIBCPP_MUTEX_INITIALIZER) || \

bcraig wrote:
> So users of external pthreading (or their compiler driver) would need to 
> provide a pile of -D options on the command line?  Or is it expected that 
> users will have their own __external_threading header that comes earlier in 
> the include path?  Please document your expectation.
My expectation is that system vendors who have a different threading 
implementation will ship a customized version of the libc++ headers and dylib. 

The headers will include a replacement `include/__external_threading`, and a 
modified `include/__config` that contains additional `#define`s

What this patch does is to provide a customization point to produce such 
libraries.



https://reviews.llvm.org/D21968



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Saleem Abdulrasool via cfe-commits
compnerd added inline comments.


Comment at: test/clang-reorder-fields/ClassMixedInitialization.cpp:1-3
@@ +1,4 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,v,s %t.cpp 
-i -- -std=c++11
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+

bcraig wrote:
> Nit:
> This general pattern seems suspicious to me.  It really seems like it should 
> be some variation of "clang-reorder-fields [...] | FileCheck %s", without the 
> cat and sed stuff.  Is there a clang-reorder-fields mode where changes are 
> output into a new file / stdout instead of modifying the file in place?
Yes, it seems suspicious to me as well.  However, I think that this is fine as 
is for @alexshap's patch as this is the model used throughout clang-rename and 
friends as well.  Its because the tools are missing exactly what you are 
suggesting (`-verify`).


Repository:
  rL LLVM

https://reviews.llvm.org/D23279



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


Re: [PATCH] D23279: clang-reorder-fields

2016-08-22 Thread Aaron Ballman via cfe-commits
On Mon, Aug 22, 2016 at 10:34 AM, Ben Craig  wrote:
> bcraig added a comment.
>
> I will note that I'm only really looking at the tests, mostly from the 
> perspective of a potential user.
>
> Thanks for getting C++ initializer lists in.
>
> The tests in general look fine.  The omission of cross visibility reordering 
> is fine as an initial step.
>
> Once multi-TU support is in, you'll definitely want a test for that.
>
>
> 
> Comment at: test/clang-reorder-fields/ClassMixedInitialization.cpp:1-3
> @@ +1,4 @@
> +// RUN: cat %s > %t.cpp
> +// RUN: clang-reorder-fields -record-name Foo -fields-order e,x,pi,v,s 
> %t.cpp -i -- -std=c++11
> +// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
> +
> 
> Nit:
> This general pattern seems suspicious to me.  It really seems like it should 
> be some variation of "clang-reorder-fields [...] | FileCheck %s", without the 
> cat and sed stuff.  Is there a clang-reorder-fields mode where changes are 
> output into a new file / stdout instead of modifying the file in place?

This pattern likely also means the tests will fail on Windows (every
instance of RUN: sed in the clang tests also has REQUIRES: shell,
which disables the tests on Windows). Removing a test reliance on sed
is pretty important, IMO.

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


Re: [PATCH] D23761: clang-format: [JS] supports casts to types starting with punctuation ("{[(").

2016-08-22 Thread Martin Probst via cfe-commits
This revision was automatically updated to reflect the committed changes.
mprobst marked an inline comment as done.
Closed by commit rL279436: clang-format: [JS] supports casts to types starting 
with punctuation ("{[("). (authored by mprobst).

Changed prior to commit:
  https://reviews.llvm.org/D23761?vs=68844=68858#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23761

Files:
  cfe/trunk/lib/Format/TokenAnnotator.cpp
  cfe/trunk/unittests/Format/FormatTestJS.cpp

Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2121,6 +2121,9 @@
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
+if (Left.is(Keywords.kw_as) &&
+Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
+  return true;
 if (Left.is(tok::kw_default) && Left.Previous &&
 Left.Previous->is(tok::kw_export))
   return true;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1219,6 +1219,9 @@
"  2\n"
"];");
   verifyFormat("var x = [{x: 1} as type];");
+  verifyFormat("x = x as [a, b];");
+  verifyFormat("x = x as {a: string};");
+  verifyFormat("x = x as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {


Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -2121,6 +2121,9 @@
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
+if (Left.is(Keywords.kw_as) &&
+Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
+  return true;
 if (Left.is(tok::kw_default) && Left.Previous &&
 Left.Previous->is(tok::kw_export))
   return true;
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -1219,6 +1219,9 @@
"  2\n"
"];");
   verifyFormat("var x = [{x: 1} as type];");
+  verifyFormat("x = x as [a, b];");
+  verifyFormat("x = x as {a: string};");
+  verifyFormat("x = x as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r279436 - clang-format: [JS] supports casts to types starting with punctuation ("{[(").

2016-08-22 Thread Martin Probst via cfe-commits
Author: mprobst
Date: Mon Aug 22 09:23:30 2016
New Revision: 279436

URL: http://llvm.org/viewvc/llvm-project?rev=279436=rev
Log:
clang-format: [JS] supports casts to types starting with punctuation ("{[(").

Before:

x as{x: number}

After:

x as {x: number}

Reviewers: djasper

Subscribers: klimek, cfe-commits

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

Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp

Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=279436=279435=279436=diff
==
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Mon Aug 22 09:23:30 2016
@@ -2121,6 +2121,9 @@ bool TokenAnnotator::spaceRequiredBefore
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
+if (Left.is(Keywords.kw_as) &&
+Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
+  return true;
 if (Left.is(tok::kw_default) && Left.Previous &&
 Left.Previous->is(tok::kw_export))
   return true;

Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=279436=279435=279436=diff
==
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Mon Aug 22 09:23:30 2016
@@ -1219,6 +1219,9 @@ TEST_F(FormatTestJS, CastSyntax) {
"  2\n"
"];");
   verifyFormat("var x = [{x: 1} as type];");
+  verifyFormat("x = x as [a, b];");
+  verifyFormat("x = x as {a: string};");
+  verifyFormat("x = x as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {


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


Re: [PATCH] D23761: clang-format: [JS] supports casts to types starting with punctuation ("{[(").

2016-08-22 Thread Daniel Jasper via cfe-commits
djasper accepted this revision.
djasper added a comment.
This revision is now accepted and ready to land.

Please add a "before" and "after" to the patch description before submitting. 
Otherwise looks good.


https://reviews.llvm.org/D23761



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


Re: [PATCH] D23492: Make function local tags visible.

2016-08-22 Thread Adrian Kuegel via cfe-commits
akuegel added a subscriber: akuegel.


Comment at: lib/Sema/SemaTemplateInstantiateDecl.cpp:3617
@@ +3616,3 @@
+PatternDef = nullptr;
+  // FIXME: We need to track the instantiation stack in order to know which
+  // definitions should be visible within this instantiation.

Line 3619 to 3623 breaks the compilation of some of our targets. I am not sure 
if it is because of a mistake in our code or if there is something bad in this 
patch.
This comment seems to indicate that there is still something missing to make 
the check here correct?


https://reviews.llvm.org/D23492



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-22 Thread Jonathan Roelofs via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D23420



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


[PATCH] D23767: DebugInfo: use llvm::di_flags_t for debug info flags

2016-08-22 Thread Victor via cfe-commits
vleschuk created this revision.
vleschuk added reviewers: echristo, aprantl.
vleschuk added subscribers: llvm-commits, cfe-commits.
Herald added a subscriber: mehdi_amini.

Use llvm::di_flags_t type for debug flags instead of unsigned int to avoid 
problems on platforms with sizeof(int) < 4: we already have flags with values > 
(1 << 16).

https://reviews.llvm.org/D23767

Files:
  include/llvm/IR/DIBuilder.h
  include/llvm/IR/DebugInfoMetadata.h
  lib/IR/DIBuilder.cpp
  lib/IR/DebugInfoMetadata.cpp

Index: lib/IR/DebugInfoMetadata.cpp
===
--- lib/IR/DebugInfoMetadata.cpp
+++ lib/IR/DebugInfoMetadata.cpp
@@ -65,14 +65,14 @@
Storage, Context.pImpl->DILocations);
 }
 
-unsigned DINode::getFlag(StringRef Flag) {
-  return StringSwitch(Flag)
+di_flags_t DINode::getFlag(StringRef Flag) {
+  return StringSwitch(Flag)
 #define HANDLE_DI_FLAG(ID, NAME) .Case("DIFlag" #NAME, Flag##NAME)
 #include "llvm/IR/DebugInfoFlags.def"
   .Default(0);
 }
 
-const char *DINode::getFlagString(unsigned Flag) {
+const char *DINode::getFlagString(di_flags_t Flag) {
   switch (Flag) {
   default:
 return "";
@@ -83,20 +83,20 @@
   }
 }
 
-unsigned DINode::splitFlags(unsigned Flags,
-SmallVectorImpl ) {
+di_flags_t DINode::splitFlags(di_flags_t Flags,
+SmallVectorImpl ) {
   // Accessibility and member pointer flags need to be specially handled, since
   // they're packed together.
-  if (unsigned A = Flags & FlagAccessibility) {
+  if (di_flags_t A = Flags & FlagAccessibility) {
 if (A == FlagPrivate)
   SplitFlags.push_back(FlagPrivate);
 else if (A == FlagProtected)
   SplitFlags.push_back(FlagProtected);
 else
   SplitFlags.push_back(FlagPublic);
 Flags &= ~A;
   }
-  if (unsigned R = Flags & FlagPtrToMemberRep) {
+  if (di_flags_t R = Flags & FlagPtrToMemberRep) {
 if (R == FlagSingleInheritance)
   SplitFlags.push_back(FlagSingleInheritance);
 else if (R == FlagMultipleInheritance)
@@ -107,7 +107,7 @@
   }
 
 #define HANDLE_DI_FLAG(ID, NAME)   \
-  if (unsigned Bit = Flags & ID) { \
+  if (di_flags_t Bit = Flags & ID) { \
 SplitFlags.push_back(Bit); \
 Flags &= ~Bit; \
   }
@@ -242,7 +242,7 @@
 DIDerivedType *DIDerivedType::getImpl(
 LLVMContext , unsigned Tag, MDString *Name, Metadata *File,
 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
-uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
+uint64_t AlignInBits, uint64_t OffsetInBits, di_flags_t Flags,
 Metadata *ExtraData, StorageType Storage, bool ShouldCreate) {
   assert(isCanonical(Name) && "Expected canonical MDString");
   DEFINE_GETIMPL_LOOKUP(DIDerivedType,
@@ -257,7 +257,7 @@
 DICompositeType *DICompositeType::getImpl(
 LLVMContext , unsigned Tag, MDString *Name, Metadata *File,
 unsigned Line, Metadata *Scope, Metadata *BaseType, uint64_t SizeInBits,
-uint64_t AlignInBits, uint64_t OffsetInBits, unsigned Flags,
+uint64_t AlignInBits, uint64_t OffsetInBits, di_flags_t Flags,
 Metadata *Elements, unsigned RuntimeLang, Metadata *VTableHolder,
 Metadata *TemplateParams, MDString *Identifier, StorageType Storage,
 bool ShouldCreate) {
@@ -279,7 +279,7 @@
 LLVMContext , MDString , unsigned Tag, MDString *Name,
 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
-unsigned Flags, Metadata *Elements, unsigned RuntimeLang,
+di_flags_t Flags, Metadata *Elements, unsigned RuntimeLang,
 Metadata *VTableHolder, Metadata *TemplateParams) {
   assert(!Identifier.getString().empty() && "Expected valid identifier");
   if (!Context.isODRUniquingDebugTypes())
@@ -313,7 +313,7 @@
 LLVMContext , MDString , unsigned Tag, MDString *Name,
 Metadata *File, unsigned Line, Metadata *Scope, Metadata *BaseType,
 uint64_t SizeInBits, uint64_t AlignInBits, uint64_t OffsetInBits,
-unsigned Flags, Metadata *Elements, unsigned RuntimeLang,
+di_flags_t Flags, Metadata *Elements, unsigned RuntimeLang,
 Metadata *VTableHolder, Metadata *TemplateParams) {
   assert(!Identifier.getString().empty() && "Expected valid identifier");
   if (!Context.isODRUniquingDebugTypes())
@@ -336,7 +336,7 @@
 }
 
 DISubroutineType *DISubroutineType::getImpl(LLVMContext ,
-unsigned Flags, uint8_t CC,
+di_flags_t Flags, uint8_t CC,
 Metadata *TypeArray,
 StorageType Storage,

Re: [PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-08-22 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 68853.
mprobst added a comment.

- Fix escaping issue.


https://reviews.llvm.org/D22431

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1122,7 +1122,7 @@
 TEST_F(FormatTestJS, TemplateStrings) {
   // Keeps any whitespace/indentation within the template string.
   verifyFormat("var x = `hello\n"
-" ${  name}\n"
+" ${name}\n"
 "  !`;",
 "var x=`hello\n"
" ${  name}\n"
@@ -1206,6 +1206,18 @@
"var y;",
"var x = ` \\` a`;\n"
"var y;");
+  // Escaped dollar.
+  verifyFormat("var x = ` \\${foo}`;\n");
+}
+
+TEST_F(FormatTestJS, NestedTemplateStrings) {
+  verifyFormat(
+  "var x = `${xs.map(x => `${x}`).join('\\n')}`;");
+  verifyFormat("var x = `he${({text: 'll'}.text)}o`;");
+}
+
+TEST_F(FormatTestJS, TaggedTemplateStrings) {
+  verifyFormat("var x = html``;");
 }
 
 TEST_F(FormatTestJS, CastSyntax) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -858,7 +858,7 @@
 if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_ForEachMacro,
TT_FunctionLBrace, TT_ImplicitStringLiteral,
TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
-   TT_RegexLiteral))
+   TT_RegexLiteral, TT_TemplateString))
   CurrentToken->Type = TT_Unknown;
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;
@@ -1816,6 +1816,9 @@
   return 100;
 if (Left.is(TT_JsTypeColon))
   return 35;
+if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
+(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
+  return 100;
   }
 
   if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next &&
@@ -2114,6 +2117,11 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
+(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
+  return false;
+if (Left.is(tok::identifier) && Right.is(TT_TemplateString))
+  return false;
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
   return false;
Index: lib/Format/FormatTokenLexer.h
===
--- lib/Format/FormatTokenLexer.h
+++ lib/Format/FormatTokenLexer.h
@@ -23,9 +23,17 @@
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
 
+#include 
+
 namespace clang {
 namespace format {
 
+enum LexerState {
+  NORMAL,
+  TEMPLATE_STRING,
+  TOKEN_STASHED,
+};
+
 class FormatTokenLexer {
 public:
   FormatTokenLexer(const SourceManager , FileID ID,
@@ -53,7 +61,16 @@
   // its text if successful.
   void tryParseJSRegexLiteral();
 
-  void tryParseTemplateString();
+  // Handles JavaScript template strings.
+  //
+  // JavaScript template strings use backticks ('`') as delimiters, and allow
+  // embedding expressions nested in ${expr-here}. Template strings can be
+  // nested recursively, i.e. expressions can contain template strings in turns.
+  //
+  // The code below parses starting from a backtick, up to a closing backtick or
+  // an opening ${. It also maintains a stack of lexing contexts to handle
+  // nested template parts by balancing curly braces.
+  void handleTemplateStrings();
 
   bool tryMerge_TMacro();
 
@@ -65,7 +82,7 @@
 
   FormatToken *FormatTok;
   bool IsFirstToken;
-  bool GreaterStashed, LessStashed;
+  std::stack StateStack;
   unsigned Column;
   unsigned TrailingWhitespace;
   std::unique_ptr Lex;
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -26,12 +26,11 @@
 FormatTokenLexer::FormatTokenLexer(const SourceManager , FileID ID,
const FormatStyle ,
encoding::Encoding Encoding)
-: FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
-  LessStashed(false), Column(0), TrailingWhitespace(0),
-  SourceMgr(SourceMgr), ID(ID), Style(Style),
-  IdentTable(getFormattingLangOpts(Style)), Keywords(IdentTable),
-  Encoding(Encoding), FirstInLineIndex(0), FormattingDisabled(false),
-  MacroBlockBeginRegex(Style.MacroBlockBegin),
+: FormatTok(nullptr), IsFirstToken(true), 

Re: [PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-08-22 Thread Martin Probst via cfe-commits
mprobst added inline comments.


Comment at: lib/Format/FormatTokenLexer.cpp:259
@@ -241,1 +258,3 @@
   ++Offset; // Skip the escaped character.
+if (Offset + 1 < Lex->getBuffer().end() && Offset[0] == '$' &&
+Offset[1] == '{') {

Question by @ygao in the other diff:

> What happens if the '${' is immediately after a backslash (the if statement 
> above), should the '${' get escaped?

A template like `foo\${bar}` is the literal string `'foo\${bar}'`, i.e. the `\` 
acts as an escape for the `'$'` sign. I've added a test to validate that.


https://reviews.llvm.org/D22431



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


Re: [PATCH] D22431: clang-format: [JS] nested and tagged template strings.

2016-08-22 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 68851.
mprobst added a comment.

- Test escaped dollar sign.


https://reviews.llvm.org/D22431

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1122,7 +1122,7 @@
 TEST_F(FormatTestJS, TemplateStrings) {
   // Keeps any whitespace/indentation within the template string.
   verifyFormat("var x = `hello\n"
-" ${  name}\n"
+" ${name}\n"
 "  !`;",
 "var x=`hello\n"
" ${  name}\n"
@@ -1206,6 +1206,18 @@
"var y;",
"var x = ` \\` a`;\n"
"var y;");
+  // Escaped dollar.
+  verifyFormat("var x = ` \\${foo}`;\n");
+}
+
+TEST_F(FormatTestJS, NestedTemplateStrings) {
+  verifyFormat(
+  "var x = `${xs.map(x => `${x}`).join('\\n')}`;");
+  verifyFormat("var x = `he${({text: 'll'}.text)}o`;");
+}
+
+TEST_F(FormatTestJS, TaggedTemplateStrings) {
+  verifyFormat("var x = html``;");
 }
 
 TEST_F(FormatTestJS, CastSyntax) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -858,7 +858,7 @@
 if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_ForEachMacro,
TT_FunctionLBrace, TT_ImplicitStringLiteral,
TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
-   TT_RegexLiteral))
+   TT_RegexLiteral, TT_TemplateString))
   CurrentToken->Type = TT_Unknown;
 CurrentToken->Role.reset();
 CurrentToken->MatchingParen = nullptr;
@@ -1816,6 +1816,9 @@
   return 100;
 if (Left.is(TT_JsTypeColon))
   return 35;
+if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
+(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
+  return 100;
   }
 
   if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next &&
@@ -2114,6 +2117,11 @@
   } else if (Style.Language == FormatStyle::LK_JavaScript) {
 if (Left.is(TT_JsFatArrow))
   return true;
+if ((Left.is(TT_TemplateString) && Left.TokenText.endswith("${")) ||
+(Right.is(TT_TemplateString) && Right.TokenText.startswith("}")))
+  return false;
+if (Left.is(tok::identifier) && Right.is(TT_TemplateString))
+  return false;
 if (Right.is(tok::star) &&
 Left.isOneOf(Keywords.kw_function, Keywords.kw_yield))
   return false;
Index: lib/Format/FormatTokenLexer.h
===
--- lib/Format/FormatTokenLexer.h
+++ lib/Format/FormatTokenLexer.h
@@ -23,9 +23,17 @@
 #include "clang/Format/Format.h"
 #include "llvm/Support/Regex.h"
 
+#include 
+
 namespace clang {
 namespace format {
 
+enum LexerState {
+  NORMAL,
+  TEMPLATE_STRING,
+  TOKEN_STASHED,
+};
+
 class FormatTokenLexer {
 public:
   FormatTokenLexer(const SourceManager , FileID ID,
@@ -53,7 +61,16 @@
   // its text if successful.
   void tryParseJSRegexLiteral();
 
-  void tryParseTemplateString();
+  // Handles JavaScript template strings.
+  //
+  // JavaScript template strings use backticks ('`') as delimiters, and allow
+  // embedding expressions nested in ${expr-here}. Template strings can be
+  // nested recursively, i.e. expressions can contain template strings in turns.
+  //
+  // The code below parses starting from a backtick, up to a closing backtick or
+  // an opening ${. It also maintains a stack of lexing contexts to handle
+  // nested template parts by balancing curly braces.
+  void handleTemplateStrings();
 
   bool tryMerge_TMacro();
 
@@ -65,7 +82,7 @@
 
   FormatToken *FormatTok;
   bool IsFirstToken;
-  bool GreaterStashed, LessStashed;
+  std::stack StateStack;
   unsigned Column;
   unsigned TrailingWhitespace;
   std::unique_ptr Lex;
Index: lib/Format/FormatTokenLexer.cpp
===
--- lib/Format/FormatTokenLexer.cpp
+++ lib/Format/FormatTokenLexer.cpp
@@ -26,12 +26,11 @@
 FormatTokenLexer::FormatTokenLexer(const SourceManager , FileID ID,
const FormatStyle ,
encoding::Encoding Encoding)
-: FormatTok(nullptr), IsFirstToken(true), GreaterStashed(false),
-  LessStashed(false), Column(0), TrailingWhitespace(0),
-  SourceMgr(SourceMgr), ID(ID), Style(Style),
-  IdentTable(getFormattingLangOpts(Style)), Keywords(IdentTable),
-  Encoding(Encoding), FirstInLineIndex(0), FormattingDisabled(false),
-  MacroBlockBeginRegex(Style.MacroBlockBegin),
+: FormatTok(nullptr), IsFirstToken(true), 

Re: [PATCH] D15227: [analyzer] Valist checkers.

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

In https://reviews.llvm.org/D15227#521781, @NoQ wrote:

> In https://reviews.llvm.org/D15227#519239, @xazax.hun wrote:
>
> > I suspect that slightly different AST is generated for those architectures 
> > that cause the different behavior. I will further investigate those 
> > problems.
>
>
> Seems so, because on my machine when i append `-triple hexagon-unknown-linux` 
> to the test run line, a bunch of things start failing. You may also consider 
> hardcoding the runline in the current test and commit (which is so often a 
> good idea), and fix other stuff in later commits. A proper investigation 
> would be great, of course :)


I committed with the hardcoded triple in the runline for now.

> P.S. Just curious - do you plan to eventually model `va_arg()`, as we 
> discussed with Michael Tandy in 
> http://lists.llvm.org/pipermail/cfe-dev/2016-August/050202.html ?


It is not on my TODO list at the moment, but I might look into it in the 
distant future.


Repository:
  rL LLVM

https://reviews.llvm.org/D15227



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


Re: [PATCH] D23420: libcxx: Fix libcxx test on aarch64 with libunwind

2016-08-22 Thread Adhemerval Zanella via cfe-commits
zatrazz added a comment.

Ping (x2).


https://reviews.llvm.org/D23420



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


Re: [PATCH] D21959: [X86] Add xgetbv xsetbv intrinsics

2016-08-22 Thread Guy Blank via cfe-commits
guyblank added a comment.

removing the MSC_VER check will not be enough, the feature guards from the 
intrinsic and the builtin need to be removed to make it work. not sure if this 
is the right way to go, any thoughts on this?


Repository:
  rL LLVM

https://reviews.llvm.org/D21959



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


Re: [PATCH] D15227: [analyzer] Valist checkers.

2016-08-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279427: Reapply "[analyzer] Added valist related checkers." 
(authored by xazax).

Repository:
  rL LLVM

https://reviews.llvm.org/D15227

Files:
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
  cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
  cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-valist.h
  cfe/trunk/test/Analysis/valist-uninitialized.c
  cfe/trunk/test/Analysis/valist-unterminated.c

Index: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
===
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
@@ -43,6 +43,9 @@
 def Cplusplus : Package<"cplusplus">;
 def CplusplusAlpha : Package<"cplusplus">, InPackage, Hidden;
 
+def Valist : Package<"valist">;
+def ValistAlpha : Package<"valist">, InPackage, Hidden;
+
 def DeadCode : Package<"deadcode">;
 def DeadCodeAlpha : Package<"deadcode">, InPackage, Hidden;
 
@@ -267,6 +270,27 @@
 
 } // end: "alpha.cplusplus"
 
+
+//===--===//
+// Valist checkers.
+//===--===//
+
+let ParentPackage = ValistAlpha in {
+
+def UninitializedChecker : Checker<"Uninitialized">,
+  HelpText<"Check for usages of uninitialized (or already released) va_lists.">,
+  DescFile<"ValistChecker.cpp">;
+
+def UnterminatedChecker : Checker<"Unterminated">,
+  HelpText<"Check for va_lists which are not released by a va_end call.">,
+  DescFile<"ValistChecker.cpp">;
+
+def CopyToSelfChecker : Checker<"CopyToSelf">,
+  HelpText<"Check for va_lists which are copied onto itself.">,
+  DescFile<"ValistChecker.cpp">;
+
+} // end : "alpha.valist"
+
 //===--===//
 // Deadcode checkers.
 //===--===//
Index: cfe/trunk/test/Analysis/valist-unterminated.c
===
--- cfe/trunk/test/Analysis/valist-unterminated.c
+++ cfe/trunk/test/Analysis/valist-unterminated.c
@@ -0,0 +1,133 @@
+// RUN: %clang_cc1 -triple x86_64-pc-linux-gnu -analyze -analyzer-checker=core,alpha.valist.Unterminated,alpha.valist.CopyToSelf -analyzer-output=text -analyzer-store=region -verify %s
+
+#include "Inputs/system-header-simulator-for-valist.h"
+
+void f1(int fst, ...) {
+  va_list va;
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+  return; // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}
+}
+
+void f2(int fst, ...) {
+  va_list va;
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+  va_end(va); // expected-note{{Ended va_list}}
+  va_start(va, fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}}
+
+void f3(int fst, ...) {
+  va_list va, va2;
+  va_start(va, fst);
+  va_copy(va2, va); // expected-note{{Initialized va_list}}
+  va_end(va); // expected-warning{{Initialized va_list 'va2' is leaked}} expected-note{{Initialized va_list 'va2' is leaked}}
+}
+
+void f4(va_list *fst, ...) {
+  va_start(*fst, fst); // expected-note{{Initialized va_list}}
+  return; // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}}
+}
+
+void f5(va_list fst, ...) {
+  va_start(fst, fst);
+  //FIXME: this should cause a warning
+} // no-warning
+
+void f6(va_list *fst, ...) {
+  va_start(*fst, fst); // expected-note{{Initialized va_list}}
+  (void)va_arg(*fst, int);
+  //FIXME: this should NOT cause a warning
+  va_end(*fst); // expected-warning{{Initialized va_list is leaked}} expected-note{{Initialized va_list is leaked}}
+}
+
+void f7(int *fst, ...) {
+  va_list x;
+  va_list *y = 
+  va_start(*y,fst); // expected-note{{Initialized va_list}}
+} // expected-warning{{Initialized va_list 'x' is leaked}} expected-note{{Initialized va_list 'x' is leaked}}
+
+void f8(int *fst, ...) {
+  va_list x;
+  va_list *y = 
+  va_start(*y,fst);
+  va_end(x);
+} // no-warning 
+
+void reinit(int *fst, ...) {
+  va_list va;
+  va_start(va, fst); // expected-note{{Initialized va_list}} expected-note{{Initialized va_list}}
+  va_start(va, fst); // expected-warning{{Initialized va_list 'va' is initialized again}} expected-note{{Initialized va_list 'va' is initialized again}}
+} // expected-warning{{Initialized va_list 'va' is leaked}} expected-note{{Initialized va_list 'va' is leaked}}
+
+void reinitOk(int *fst, ...) {
+  va_list va;
+  va_start(va, fst);
+  va_end(va);
+  va_start(va, fst);
+  va_end(va);
+} // no-warning
+
+void copyself(int fst, ...) {
+  va_list va;
+  

r279427 - Reapply "[analyzer] Added valist related checkers."

2016-08-22 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Aug 22 06:21:30 2016
New Revision: 279427

URL: http://llvm.org/viewvc/llvm-project?rev=279427=rev
Log:
Reapply "[analyzer] Added valist related checkers."

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

Added:
cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
cfe/trunk/test/Analysis/Inputs/system-header-simulator-for-valist.h
cfe/trunk/test/Analysis/valist-uninitialized.c
cfe/trunk/test/Analysis/valist-unterminated.c
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=279427=279426=279427=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Mon Aug 22 
06:21:30 2016
@@ -43,6 +43,9 @@ def Nullability : Package<"nullability">
 def Cplusplus : Package<"cplusplus">;
 def CplusplusAlpha : Package<"cplusplus">, InPackage, Hidden;
 
+def Valist : Package<"valist">;
+def ValistAlpha : Package<"valist">, InPackage, Hidden;
+
 def DeadCode : Package<"deadcode">;
 def DeadCodeAlpha : Package<"deadcode">, InPackage, Hidden;
 
@@ -267,6 +270,27 @@ def VirtualCallChecker : Checker<"Virtua
 
 } // end: "alpha.cplusplus"
 
+
+//===--===//
+// Valist checkers.
+//===--===//
+
+let ParentPackage = ValistAlpha in {
+
+def UninitializedChecker : Checker<"Uninitialized">,
+  HelpText<"Check for usages of uninitialized (or already released) 
va_lists.">,
+  DescFile<"ValistChecker.cpp">;
+
+def UnterminatedChecker : Checker<"Unterminated">,
+  HelpText<"Check for va_lists which are not released by a va_end call.">,
+  DescFile<"ValistChecker.cpp">;
+
+def CopyToSelfChecker : Checker<"CopyToSelf">,
+  HelpText<"Check for va_lists which are copied onto itself.">,
+  DescFile<"ValistChecker.cpp">;
+
+} // end : "alpha.valist"
+
 
//===--===//
 // Deadcode checkers.
 
//===--===//

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt?rev=279427=279426=279427=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CMakeLists.txt Mon Aug 22 06:21:30 
2016
@@ -81,6 +81,7 @@ add_clang_library(clangStaticAnalyzerChe
   UnreachableCodeChecker.cpp
   VforkChecker.cpp
   VLASizeChecker.cpp
+  ValistChecker.cpp
   VirtualCallChecker.cpp
 
   DEPENDS

Added: cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp?rev=279427=auto
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp (added)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ValistChecker.cpp Mon Aug 22 06:21:30 
2016
@@ -0,0 +1,373 @@
+//== ValistChecker.cpp - stdarg.h macro usage checker ---*- C++ 
-*--==//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This defines checkers which detect usage of uninitialized va_list values
+// and va_start calls with no matching va_end.
+//
+//===--===//
+
+#include "ClangSACheckers.h"
+#include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
+#include "clang/StaticAnalyzer/Core/Checker.h"
+#include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CallEvent.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
+
+using namespace clang;
+using namespace ento;
+
+REGISTER_SET_WITH_PROGRAMSTATE(InitializedVALists, const MemRegion *)
+
+namespace {
+typedef SmallVector RegionVector;
+
+class ValistChecker : public Checker {
+  mutable std::unique_ptr BT_leakedvalist, BT_uninitaccess;
+
+  struct VAListAccepter {
+CallDescription Func;
+int VAListPos;
+  };
+  static const SmallVector VAListAccepters;
+  static const CallDescription VaStart, VaEnd, VaCopy;
+
+public:
+  enum CheckKind {
+CK_Uninitialized,
+

Re: [PATCH] D23761: clang-format: [JS] supports casts to types starting with punctuation ("{[(").

2016-08-22 Thread Martin Probst via cfe-commits
mprobst updated this revision to Diff 68844.
mprobst added a comment.

- drop accidentally included template string patch from this diff.


https://reviews.llvm.org/D23761

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

Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1219,6 +1219,9 @@
"  2\n"
"];");
   verifyFormat("var x = [{x: 1} as type];");
+  verifyFormat("x = x as [a, b];");
+  verifyFormat("x = x as {a: string};");
+  verifyFormat("x = x as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2121,6 +2121,9 @@
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
+if (Left.is(Keywords.kw_as) &&
+Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
+  return true;
 if (Left.is(tok::kw_default) && Left.Previous &&
 Left.Previous->is(tok::kw_export))
   return true;


Index: unittests/Format/FormatTestJS.cpp
===
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1219,6 +1219,9 @@
"  2\n"
"];");
   verifyFormat("var x = [{x: 1} as type];");
+  verifyFormat("x = x as [a, b];");
+  verifyFormat("x = x as {a: string};");
+  verifyFormat("x = x as (string);");
 }
 
 TEST_F(FormatTestJS, TypeArguments) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2121,6 +2121,9 @@
  Keywords.kw_of, tok::kw_const) &&
 (!Left.Previous || !Left.Previous->is(tok::period)))
   return true;
+if (Left.is(Keywords.kw_as) &&
+Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
+  return true;
 if (Left.is(tok::kw_default) && Left.Previous &&
 Left.Previous->is(tok::kw_export))
   return true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D23112: [analyzer] Correctly add assumptions based on array bounds.

2016-08-22 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL279425: [analyzer] Correctly add assumptions based on array 
bounds. (authored by xazax).

Changed prior to commit:
  https://reviews.llvm.org/D23112?vs=68023=68840#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D23112

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
  cfe/trunk/test/Analysis/out-of-bounds.c

Index: cfe/trunk/test/Analysis/out-of-bounds.c
===
--- cfe/trunk/test/Analysis/out-of-bounds.c
+++ cfe/trunk/test/Analysis/out-of-bounds.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2 -verify %s
+// RUN: %clang_cc1 -Wno-array-bounds -analyze -analyzer-checker=core,alpha.security.ArrayBoundV2,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
 
 // Tests doing an out-of-bounds access after the end of an array using:
 // - constant integer index
@@ -128,22 +130,22 @@
   buf[0][0] = 1; // no-warning
 }
 
-// *** FIXME ***
-// We don't get a warning here yet because our symbolic constraint solving
-// doesn't handle:  (symbol * constant) < constant
 void test3(int x) {
   int buf[100];
   if (x < 0)
-buf[x] = 1;
+buf[x] = 1; // expected-warning{{Out of bound memory access}}
 }
 
-// *** FIXME ***
-// We don't get a warning here yet because our symbolic constraint solving
-// doesn't handle:  (symbol * constant) < constant
 void test4(int x) {
   int buf[100];
   if (x > 99)
-buf[x] = 1; 
+buf[x] = 1; // expected-warning{{Out of bound memory access}}
+}
+
+void test_assume_after_access(unsigned long x) {
+  int buf[100];
+  buf[x] = 1;
+  clang_analyzer_eval(x <= 99); // expected-warning{{TRUE}}
 }
 
 // Don't warn when indexing below the start of a symbolic region's whose
@@ -166,3 +168,9 @@
   p[1] = 42; // no-warning
 }
 
+void test_assume_after_access2(unsigned long x) {
+  char buf[100];
+  buf[x] = 1;
+  clang_analyzer_eval(x <= 99); // expected-warning{{TRUE}}
+}
+
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallString.h"
@@ -81,6 +82,42 @@
 }
 }
 
+// TODO: once the constraint manager is smart enough to handle non simplified
+// symbolic expressions remove this function. Note that this can not be used in
+// the constraint manager as is, since this does not handle overflows. It is
+// safe to assume, however, that memory offsets will not overflow.
+static std::pair
+getSimplifiedOffsets(NonLoc offset, nonloc::ConcreteInt extent,
+ SValBuilder ) {
+  Optional SymVal = offset.getAs();
+  if (SymVal && SymVal->isExpression()) {
+if (const SymIntExpr *SIE = dyn_cast(SymVal->getSymbol())) {
+  llvm::APSInt constant =
+  APSIntType(extent.getValue()).convert(SIE->getRHS());
+  switch (SIE->getOpcode()) {
+  case BO_Mul:
+// The constant should never be 0 here, since it the result of scaling
+// based on the size of a type which is never 0.
+if ((extent.getValue() % constant) != 0)
+  return std::pair(offset, extent);
+else
+  return getSimplifiedOffsets(
+  nonloc::SymbolVal(SIE->getLHS()),
+  svalBuilder.makeIntVal(extent.getValue() / constant),
+  svalBuilder);
+  case BO_Add:
+return getSimplifiedOffsets(
+nonloc::SymbolVal(SIE->getLHS()),
+svalBuilder.makeIntVal(extent.getValue() - constant), svalBuilder);
+  default:
+break;
+  }
+}
+  }
+
+  return std::pair(offset, extent);
+}
+
 void ArrayBoundCheckerV2::checkLocation(SVal location, bool isLoad,
 const Stmt* LoadS,
 CheckerContext ) const {
@@ -104,16 +141,26 @@
   if (!rawOffset.getRegion())
 return;
 
+  NonLoc rawOffsetVal = rawOffset.getByteOffset();
+
   // CHECK LOWER BOUND: Is byteOffset < extent begin?
   //  If so, we are doing a load/store
   //  before the first valid offset in the memory region.
 
   SVal extentBegin = computeExtentBegin(svalBuilder, rawOffset.getRegion());
 
   if (Optional NV = extentBegin.getAs()) {
-SVal lowerBound =
-svalBuilder.evalBinOpNN(state, BO_LT, 

r279425 - [analyzer] Correctly add assumptions based on array bounds.

2016-08-22 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Mon Aug 22 05:07:32 2016
New Revision: 279425

URL: http://llvm.org/viewvc/llvm-project?rev=279425=rev
Log:
[analyzer] Correctly add assumptions based on array bounds.

Also simplify the constraints generated by the checker. 

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
cfe/trunk/test/Analysis/out-of-bounds.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp?rev=279425=279424=279425=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/ArrayBoundCheckerV2.cpp Mon Aug 22 
05:07:32 2016
@@ -17,6 +17,7 @@
 #include "clang/StaticAnalyzer/Core/BugReporter/BugType.h"
 #include "clang/StaticAnalyzer/Core/Checker.h"
 #include "clang/StaticAnalyzer/Core/CheckerManager.h"
+#include "clang/StaticAnalyzer/Core/PathSensitive/APSIntType.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/CheckerContext.h"
 #include "clang/StaticAnalyzer/Core/PathSensitive/ExprEngine.h"
 #include "llvm/ADT/SmallString.h"
@@ -81,6 +82,42 @@ static SVal computeExtentBegin(SValBuild
 }
 }
 
+// TODO: once the constraint manager is smart enough to handle non simplified
+// symbolic expressions remove this function. Note that this can not be used in
+// the constraint manager as is, since this does not handle overflows. It is
+// safe to assume, however, that memory offsets will not overflow.
+static std::pair
+getSimplifiedOffsets(NonLoc offset, nonloc::ConcreteInt extent,
+ SValBuilder ) {
+  Optional SymVal = offset.getAs();
+  if (SymVal && SymVal->isExpression()) {
+if (const SymIntExpr *SIE = dyn_cast(SymVal->getSymbol())) {
+  llvm::APSInt constant =
+  APSIntType(extent.getValue()).convert(SIE->getRHS());
+  switch (SIE->getOpcode()) {
+  case BO_Mul:
+// The constant should never be 0 here, since it the result of scaling
+// based on the size of a type which is never 0.
+if ((extent.getValue() % constant) != 0)
+  return std::pair(offset, extent);
+else
+  return getSimplifiedOffsets(
+  nonloc::SymbolVal(SIE->getLHS()),
+  svalBuilder.makeIntVal(extent.getValue() / constant),
+  svalBuilder);
+  case BO_Add:
+return getSimplifiedOffsets(
+nonloc::SymbolVal(SIE->getLHS()),
+svalBuilder.makeIntVal(extent.getValue() - constant), svalBuilder);
+  default:
+break;
+  }
+}
+  }
+
+  return std::pair(offset, extent);
+}
+
 void ArrayBoundCheckerV2::checkLocation(SVal location, bool isLoad,
 const Stmt* LoadS,
 CheckerContext ) const {
@@ -104,6 +141,8 @@ void ArrayBoundCheckerV2::checkLocation(
   if (!rawOffset.getRegion())
 return;
 
+  NonLoc rawOffsetVal = rawOffset.getByteOffset();
+
   // CHECK LOWER BOUND: Is byteOffset < extent begin?
   //  If so, we are doing a load/store
   //  before the first valid offset in the memory region.
@@ -111,9 +150,17 @@ void ArrayBoundCheckerV2::checkLocation(
   SVal extentBegin = computeExtentBegin(svalBuilder, rawOffset.getRegion());
 
   if (Optional NV = extentBegin.getAs()) {
-SVal lowerBound =
-svalBuilder.evalBinOpNN(state, BO_LT, rawOffset.getByteOffset(), *NV,
-svalBuilder.getConditionType());
+if (NV->getAs()) {
+  std::pair simplifiedOffsets =
+  getSimplifiedOffsets(rawOffset.getByteOffset(),
+   NV->castAs(),
+   svalBuilder);
+  rawOffsetVal = simplifiedOffsets.first;
+  *NV = simplifiedOffsets.second;
+}
+
+SVal lowerBound = svalBuilder.evalBinOpNN(state, BO_LT, rawOffsetVal, *NV,
+  svalBuilder.getConditionType());
 
 Optional lowerBoundToCheck = lowerBound.getAs();
 if (!lowerBoundToCheck)
@@ -142,10 +189,18 @@ void ArrayBoundCheckerV2::checkLocation(
 if (!extentVal.getAs())
   break;
 
-SVal upperbound
-  = svalBuilder.evalBinOpNN(state, BO_GE, rawOffset.getByteOffset(),
-extentVal.castAs(),
-svalBuilder.getConditionType());
+if (extentVal.getAs()) {
+  std::pair simplifiedOffsets =
+  getSimplifiedOffsets(rawOffset.getByteOffset(),
+   extentVal.castAs(),
+   svalBuilder);
+  rawOffsetVal = simplifiedOffsets.first;
+  extentVal = 

Re: [PATCH] D21279: Fix some issues in clang-format's AlignConsecutive modes

2016-08-22 Thread Ben Harper via cfe-commits
bmharper added a comment.

The reason one has to precompute ScopeLevel is because IndentLevel is not 
actually meaningful on each token. It's only meaningful for the first token on 
the line (the remaining tokens on the line have IndentLevel = 0). So if you 
look at the implementation of calculateScopeLevel(), you'll see that the 
function "remembers" the most recent meaningful IndentLevel, and copies that 
into ScopeLevel for all subsequent tokens on the same line.
Now, one could argue that IndentLevel ought to be the same for all tokens on a 
line, but that seems to me like a much bigger change, that would propagate into 
many other parts of the code.


https://reviews.llvm.org/D21279



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


Re: [PATCH] D23400: Implement Use-Define Chain.

2016-08-22 Thread Vassil Vassilev via cfe-commits
v.g.vassilev updated this revision to Diff 68834.
v.g.vassilev added a comment.

Add the right diff.


https://reviews.llvm.org/D23400

Files:
  include/clang/Analysis/DefUse.h
  lib/Analysis/CMakeLists.txt
  lib/Analysis/DefUse.cpp

Index: lib/Analysis/DefUse.cpp
===
--- /dev/null
+++ lib/Analysis/DefUse.cpp
@@ -0,0 +1,920 @@
+//===-- clang/Analysis/DefUse.cpp - DefUse analysis ---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===-===//
+//
+// This file contains the implementation of DefUse analysis
+//
+//===-===//
+
+#include "clang/Analysis/DefUse.h"
+
+#include "clang/Basic/SourceManager.h"
+#include "clang/Analysis/CFG.h"
+#include 
+
+// todo: Use DenseMap and llvm sets
+#include 
+#include 
+
+using namespace clang;
+using namespace defuse;
+
+// utility functions
+static unsigned Line(SourceLocation const& l, clang::SourceManager const& sm) {
+  PresumedLoc pl = sm.getPresumedLoc(l);
+  return pl.getLine();
+}
+
+static unsigned Column(SourceLocation const& l, SourceManager const& sm) {
+  PresumedLoc pl = sm.getPresumedLoc(l);
+  return pl.getColumn();
+}
+
+static std::string PrintClangStmt(Stmt const* stmt, ASTContext const& ctx) {
+  std::string str;
+  llvm::raw_string_ostream pp(str);
+  stmt->printPretty(pp, 0, PrintingPolicy(ctx.getLangOpts()), 0);
+  return pp.str();
+}
+
+//===- DefUseNode -===//
+inline bool defuse::DefUseNode::operator==(DefUseNode const& n) const {
+  if (n.usage != usage || n.kind != kind) return false;
+  return kind == VarDecl ? var_decl == n.var_decl : var_ref == n.var_ref;
+}
+
+inline clang::VarDecl const* DefUseNode::getDecl() const {
+  return kind == VarRef ? dyn_cast (var_ref->getDecl()) :
+dyn_cast (var_decl);
+}
+
+typedef std::set VarRefsSet;
+typedef std::set VarDeclsSet;
+typedef std::map DefUseChain;
+
+//===- DefUseBlock -===//
+
+class defuse::DefUseBlock : public DefUseChain {
+public:
+  VarDeclsSet uses;
+  VarRefsVect defsout;
+  VarDeclsSet killed;
+  VarRefsVect reaches;
+
+  class not_killed_set_iterator : public std::iterator {
+DefUseBlock& block;
+VarRefsVect::const_iterator ptr_it;
+
+not_killed_set_iterator& inc(bool first) {
+  if (ptr_it != block.reaches.end() && !first)
+++ptr_it;
+  while (ptr_it != block.reaches.end() &&
+  (block.killed.find((*ptr_it)->getDecl()) != block.killed.end() &&
+  std::find(block.defsout.begin(), block.defsout.end(), *ptr_it)
+  == block.defsout.end()))
+++ptr_it;
+  return *this;
+}
+  public:
+not_killed_set_iterator(DefUseBlock& block_,
+VarRefsVect::const_iterator ptr_it_) :
+  block(block_), ptr_it(ptr_it_) { inc(true); }
+not_killed_set_iterator& operator++() { return inc(false); }
+bool operator!=(not_killed_set_iterator const& iter) const {
+  return !(() == &(block) && iter.ptr_it == ptr_it);
+}
+const DefUseNode* const & operator*() const { return *ptr_it; }
+  };
+
+  not_killed_set_iterator begin_not_killed_set() {
+return DefUseBlock::not_killed_set_iterator(*this, reaches.begin());
+  }
+  not_killed_set_iterator end_not_killed_set() {
+return DefUseBlock::not_killed_set_iterator(*this, reaches.end());
+  }
+};
+
+//===- VarDeclMap -===//
+
+class defuse::VarDeclMap : public StmtVisitor ,
+public llvm::DenseMap {
+public:
+  VarDeclMap(Stmt const* body) { VisitStmt(const_cast (body)); }
+
+  void VisitDeclStmt(DeclStmt *DS) {
+for (DeclStmt::decl_iterator I = DS->decl_begin(), E = DS->decl_end();
+I != E; ++I)
+{
+  if (VarDecl *VD = dyn_cast(*I))
+insert(std::make_pair(VD, DS));
+}
+  }
+  void VisitStmt(Stmt* S) {
+for (Stmt::child_iterator I = S->child_begin(), E = S->child_end();
+I != E; ++I)
+  if (*I) Visit(*I);
+  }
+};
+
+//===- DefUseHelper -===//
+struct defuse::DefUseHelper::DefUseHelperImpl {
+  DefUseData* data;
+  VarRefBlockMap* bm;
+  VarDeclMap* dm;
+  unsigned blockID;
+
+  DefUseHelperImpl() :
+data(NULL), bm(NULL), dm(NULL) { }
+};
+
+defuse::DefUseHelper::DefUseHelper() :
+  pimpl(new DefUseHelperImpl), current_use(DefUseNode::Use) { }
+
+defuse::DefUseHelper::~DefUseHelper() { delete pimpl; }
+
+void defuse::DefUseHelper::InitializeValues(DefUseData* data,
+VarRefBlockMap* bm, VarDeclMap* dm) {
+  pimpl->data = data;
+  pimpl->bm = bm;
+  pimpl->dm = dm;
+}
+
+void 

Re: [PATCH] D23400: Implement Use-Define Chain.

2016-08-22 Thread Vassil Vassilev via cfe-commits
v.g.vassilev removed rL LLVM as the repository for this revision.
v.g.vassilev updated this revision to Diff 68833.
v.g.vassilev added a comment.

Adapt to the new APIs. Now it builds.


https://reviews.llvm.org/D23400

Files:
  lib/Sema/SemaExceptionSpec.cpp
  test/Modules/Inputs/PR28423/Allocator.h
  test/Modules/Inputs/PR28423/Memory.h
  test/Modules/Inputs/PR28423/SmallVector.h
  test/Modules/Inputs/PR28423/StringMap.h
  test/Modules/Inputs/PR28423/StringRef.h
  test/Modules/Inputs/PR28423/iterator_range.h
  test/Modules/Inputs/PR28423/module.modulemap
  test/Modules/Inputs/PR28423/queue
  test/Modules/Inputs/PR28423/string
  test/Modules/pr28423.cpp

Index: test/Modules/pr28423.cpp
===
--- /dev/null
+++ test/Modules/pr28423.cpp
@@ -0,0 +1,11 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -std=c++11 -I%S/Inputs/PR28423 -verify %s
+// RUN: %clang_cc1 -std=c++11 -fmodules -fmodule-map-file=%S/Inputs/PR28423/module.modulemap -fmodules-cache-path=%t -I%S/Inputs/PR28423/ -verify %s
+
+#include "StringMap.h"
+#include 
+
+std::priority_queue a,b;
+void fn1() { a.swap(b); }
+
+// expected-no-diagnostics
\ No newline at end of file
Index: test/Modules/Inputs/PR28423/string
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/string
@@ -0,0 +1,9 @@
+#ifndef _GLIBCXX_STRING
+#define _GLIBCXX_STRING
+namespace std {
+template  void swap(_Tp, _Tp);
+template  class allocator;
+template  struct greater {};
+template  struct less;
+}
+#endif
Index: test/Modules/Inputs/PR28423/queue
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/queue
@@ -0,0 +1,11 @@
+#pragma GCC system_header
+namespace std {
+template 
+class priority_queue {
+  _Compare comp;
+
+public:
+  void swap(priority_queue __pq) noexcept(noexcept(swap(comp, comp)));
+};
+}
Index: test/Modules/Inputs/PR28423/module.modulemap
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/module.modulemap
@@ -0,0 +1,6 @@
+module "StringRef.h" {header "StringRef.h" export *}
+module "iterator_range.h" {header "iterator_range.h" export *}
+module "SmallVector.h" {header "SmallVector.h" export *}
+module "StringMap.h" {header "StringMap.h" export *}
+module "Memory.h" {header "Memory.h" export *}
+module "Allocator.h" {header "Allocator.h" export *}
Index: test/Modules/Inputs/PR28423/iterator_range.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/iterator_range.h
@@ -0,0 +1 @@
+namespace llvm {}
Index: test/Modules/Inputs/PR28423/StringRef.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/StringRef.h
@@ -0,0 +1 @@
+namespace llvm{}
Index: test/Modules/Inputs/PR28423/StringMap.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/StringMap.h
@@ -0,0 +1,4 @@
+#include "StringRef.h"
+#include "Allocator.h"
+#include "iterator_range.h"
+namespace std {}
Index: test/Modules/Inputs/PR28423/SmallVector.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/SmallVector.h
@@ -0,0 +1,7 @@
+
+#include "iterator_range.h"
+#include 
+namespace std {
+template > class vector;
+}
+
Index: test/Modules/Inputs/PR28423/Memory.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/Memory.h
@@ -0,0 +1 @@
+#include 
Index: test/Modules/Inputs/PR28423/Allocator.h
===
--- /dev/null
+++ test/Modules/Inputs/PR28423/Allocator.h
@@ -0,0 +1,3 @@
+
+#include "SmallVector.h"
+#include "Memory.h"
Index: lib/Sema/SemaExceptionSpec.cpp
===
--- lib/Sema/SemaExceptionSpec.cpp
+++ lib/Sema/SemaExceptionSpec.cpp
@@ -44,7 +44,8 @@
 
   // All the problem cases are member functions named "swap" within class
   // templates declared directly within namespace std.
-  if (!RD || RD->getEnclosingNamespaceContext() != getStdNamespace() ||
+  if (!RD || !getStdNamespace() ||
+  !RD->getEnclosingNamespaceContext()->Equals(getStdNamespace()) ||
   !RD->getIdentifier() || !RD->getDescribedClassTemplate() ||
   !D.getIdentifier() || !D.getIdentifier()->isStr("swap"))
 return false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >