Re: [PATCH] D21343: Implement `lcm` and `gcd` from library fundamentals V2

2016-07-25 Thread Eric Fiselier via cfe-commits
EricWF accepted this revision.
EricWF added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D21343



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


Re: [PATCH] D22785: [OpenMP] diagnose orphaned teams construct

2016-07-25 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276726: [OpenMP] diagnose orphaned teams construct (authored 
by kli).

Changed prior to commit:
  https://reviews.llvm.org/D22785?vs=65430=65472#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22785

Files:
  cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
  cfe/trunk/lib/Sema/SemaOpenMP.cpp
  cfe/trunk/test/OpenMP/nesting_of_regions.cpp

Index: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
===
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp
@@ -3693,6 +3693,8 @@
   }
 
 // TEAMS DIRECTIVE
+#pragma omp teams // expected-error {{orphaned 'omp teams' directives are 
prohibited; perhaps you forget to enclose the directive into a target region?}}
+  bar();
 #pragma omp target
 #pragma omp teams
 #pragma omp parallel
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -3172,6 +3172,7 @@
 auto OffendingRegion = ParentRegion;
 bool NestingProhibited = false;
 bool CloseNesting = true;
+bool OrphanSeen = false; 
 enum {
   NoRecommend,
   ShouldBeInParallelRegion,
@@ -3213,9 +3214,10 @@
   }
   return false;
 }
-// Allow some constructs to be orphaned (they could be used in functions,
-// called from OpenMP regions with the required preconditions).
-if (ParentRegion == OMPD_unknown)
+// Allow some constructs (except teams) to be orphaned (they could be
+// used in functions, called from OpenMP regions with the required 
+// preconditions).
+if (ParentRegion == OMPD_unknown && !isOpenMPTeamsDirective(CurrentRegion))
   return false;
 if (CurrentRegion == OMPD_cancellation_point ||
 CurrentRegion == OMPD_cancel) {
@@ -3315,6 +3317,7 @@
   // If specified, a teams construct must be contained within a target
   // construct.
   NestingProhibited = ParentRegion != OMPD_target;
+  OrphanSeen = ParentRegion == OMPD_unknown;
   Recommend = ShouldBeInTargetRegion;
   Stack->setParentTeamsRegionLoc(Stack->getConstructLoc());
 }
@@ -3354,9 +3357,14 @@
   CloseNesting = false;
 }
 if (NestingProhibited) {
-  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
-  << CloseNesting << getOpenMPDirectiveName(OffendingRegion)
-  << Recommend << getOpenMPDirectiveName(CurrentRegion);
+  if (OrphanSeen) {
+SemaRef.Diag(StartLoc, diag::err_omp_orphaned_device_directive)
+<< getOpenMPDirectiveName(CurrentRegion) << Recommend;
+  } else {
+SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
+<< CloseNesting << getOpenMPDirectiveName(OffendingRegion)
+<< Recommend << getOpenMPDirectiveName(CurrentRegion);
+  }
   return true;
 }
   }
Index: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
===
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
@@ -8389,6 +8389,9 @@
 def warn_omp_nesting_simd : Warning<
   "OpenMP only allows an ordered construct with the simd clause nested in a 
simd construct">,
   InGroup;
+def err_omp_orphaned_device_directive : Error<
+  "orphaned 'omp %0' directives are prohibited"
+  "; perhaps you forget to enclose the directive into a %select{|||target 
|teams }1region?">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {


Index: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
===
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp
@@ -3693,6 +3693,8 @@
   }
 
 // TEAMS DIRECTIVE
+#pragma omp teams // expected-error {{orphaned 'omp teams' directives are prohibited; perhaps you forget to enclose the directive into a target region?}}
+  bar();
 #pragma omp target
 #pragma omp teams
 #pragma omp parallel
Index: cfe/trunk/lib/Sema/SemaOpenMP.cpp
===
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp
@@ -3172,6 +3172,7 @@
 auto OffendingRegion = ParentRegion;
 bool NestingProhibited = false;
 bool CloseNesting = true;
+bool OrphanSeen = false; 
 enum {
   NoRecommend,
   ShouldBeInParallelRegion,
@@ -3213,9 +3214,10 @@
   }
   return false;
 }
-// Allow some constructs to be orphaned (they could be used in functions,
-// called from OpenMP regions with the required preconditions).
-if (ParentRegion == OMPD_unknown)
+// Allow some constructs (except teams) to be orphaned (they could be
+// used in functions, called from OpenMP 

r276726 - [OpenMP] diagnose orphaned teams construct

2016-07-25 Thread Kelvin Li via cfe-commits
Author: kli
Date: Mon Jul 25 23:32:50 2016
New Revision: 276726

URL: http://llvm.org/viewvc/llvm-project?rev=276726=rev
Log:
[OpenMP] diagnose orphaned teams construct

The OpenMP spec mandates that 'a teams construct must be contained within a 
target construct'. Currently, this scenario is not diagnosed. This patch is 
to add check for orphaned teams construct and issue an error message.

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

Modified:
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/nesting_of_regions.cpp

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=276726=276725=276726=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Jul 25 23:32:50 
2016
@@ -8389,6 +8389,9 @@ def err_omp_argument_type_isdeviceptr :
 def warn_omp_nesting_simd : Warning<
   "OpenMP only allows an ordered construct with the simd clause nested in a 
simd construct">,
   InGroup;
+def err_omp_orphaned_device_directive : Error<
+  "orphaned 'omp %0' directives are prohibited"
+  "; perhaps you forget to enclose the directive into a %select{|||target 
|teams }1region?">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=276726=276725=276726=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Mon Jul 25 23:32:50 2016
@@ -3172,6 +3172,7 @@ static bool CheckNestingOfRegions(Sema &
 auto OffendingRegion = ParentRegion;
 bool NestingProhibited = false;
 bool CloseNesting = true;
+bool OrphanSeen = false; 
 enum {
   NoRecommend,
   ShouldBeInParallelRegion,
@@ -3213,9 +3214,10 @@ static bool CheckNestingOfRegions(Sema &
   }
   return false;
 }
-// Allow some constructs to be orphaned (they could be used in functions,
-// called from OpenMP regions with the required preconditions).
-if (ParentRegion == OMPD_unknown)
+// Allow some constructs (except teams) to be orphaned (they could be
+// used in functions, called from OpenMP regions with the required 
+// preconditions).
+if (ParentRegion == OMPD_unknown && !isOpenMPTeamsDirective(CurrentRegion))
   return false;
 if (CurrentRegion == OMPD_cancellation_point ||
 CurrentRegion == OMPD_cancel) {
@@ -3315,6 +3317,7 @@ static bool CheckNestingOfRegions(Sema &
   // If specified, a teams construct must be contained within a target
   // construct.
   NestingProhibited = ParentRegion != OMPD_target;
+  OrphanSeen = ParentRegion == OMPD_unknown;
   Recommend = ShouldBeInTargetRegion;
   Stack->setParentTeamsRegionLoc(Stack->getConstructLoc());
 }
@@ -3354,9 +3357,14 @@ static bool CheckNestingOfRegions(Sema &
   CloseNesting = false;
 }
 if (NestingProhibited) {
-  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
-  << CloseNesting << getOpenMPDirectiveName(OffendingRegion)
-  << Recommend << getOpenMPDirectiveName(CurrentRegion);
+  if (OrphanSeen) {
+SemaRef.Diag(StartLoc, diag::err_omp_orphaned_device_directive)
+<< getOpenMPDirectiveName(CurrentRegion) << Recommend;
+  } else {
+SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
+<< CloseNesting << getOpenMPDirectiveName(OffendingRegion)
+<< Recommend << getOpenMPDirectiveName(CurrentRegion);
+  }
   return true;
 }
   }

Modified: cfe/trunk/test/OpenMP/nesting_of_regions.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/nesting_of_regions.cpp?rev=276726=276725=276726=diff
==
--- cfe/trunk/test/OpenMP/nesting_of_regions.cpp (original)
+++ cfe/trunk/test/OpenMP/nesting_of_regions.cpp Mon Jul 25 23:32:50 2016
@@ -3693,6 +3693,8 @@ void foo() {
   }
 
 // TEAMS DIRECTIVE
+#pragma omp teams // expected-error {{orphaned 'omp teams' directives are 
prohibited; perhaps you forget to enclose the directive into a target region?}}
+  bar();
 #pragma omp target
 #pragma omp teams
 #pragma omp parallel


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


Re: [PATCH] D22785: [OpenMP] diagnose orphaned teams construct

2016-07-25 Thread Kelvin Li via cfe-commits
kkwli0 added a comment.

Will add the braces.  Thanks.


https://reviews.llvm.org/D22785



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


Re: [PATCH] D22663: Support setting default value for -rtlib at build time

2016-07-25 Thread Lei Zhang via cfe-commits
zlei added a comment.

In https://reviews.llvm.org/D22663#494460, @Hahnfeld wrote:

> With the changes applied and configured with 
> `CLANG_DEFAULT_RTLIB=compiler-rt` some tests fail so you may have to adapt 
> the idea of `-rtlib=platform` for the tests.


Got it. And I also need to fix those failing tests by adding `-rtlib=platform` 
to them, right?



Comment at: CMakeLists.txt:210
@@ +209,3 @@
+  message(WARNING "Resetting default rtlib to use platform default")
+  set(CLANG_DEFAULT_RTLIB "")
+endif()

beanz wrote:
> You'll want this to be:
> 
> 
> ```
> set(CLANG_DEFAULT_RTLIB "" CACHE STRING "Default runtime library to use 
> (libgcc or compiler-rt)" FORCE)
> ```
> 
> Cached variables can only be overwritten by a `FORCE`.
Sorry, I'm not very familiar with cmake. But why isn't 
`CLANG_DEFAULT_CXX_STDLIB` declared with `FORCE`? Should I fix it as well?


Comment at: lib/Driver/ToolChain.cpp:530
@@ -538,1 +529,3 @@
+  const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
+  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
 

Hahnfeld wrote:
> What I dislike here is that it falls back to the platform default if the 
> specified argument value is invalid regardless of what was configured. This 
> may be surprising for the user as he gets a different behaviour when 
> specifiying `-rtlib=bla` than completely omitting.
> 
> I just added a comment explaining how this works in `GetCXXStdlibType`. Maybe 
> you can adapt its idea?
If you give an invalid value to `-rtlib`, clang should just abort and give you 
an error message, instead of falling back to the platform default. I see that's 
also how `-stdlib` behaves.

Or maybe I misunderstood your point?


https://reviews.llvm.org/D22663



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


Re: [PATCH] D22788: [OpenMP] Code generation for the is_device_ptr clause

2016-07-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with some nits



Comment at: include/clang/AST/OpenMPClause.h:4419
@@ -4405,1 +4418,3 @@
+  }
+  /// \brief Build clause with number of variables \a NumVars.
   ///

No \brief


Comment at: include/clang/AST/OpenMPClause.h:4439
@@ -4415,3 +4438,3 @@
 
-  /// Build an empty clause.
+  /// \brief Build an empty clause.
   ///

No \brief


Comment at: include/clang/AST/OpenMPClause.h:4457
@@ -4425,3 +4456,3 @@
 public:
-  /// Creates clause with a list of variables \a VL.
+  /// \brief Creates clause with a list of variables \a Vars.
   ///

No \brief


Comment at: include/clang/AST/OpenMPClause.h:4472
@@ -4438,1 +4471,3 @@
+
+  /// \brief Creates an empty clause with the place for \a NumVars variables.
   ///

No \brief


Comment at: lib/CodeGen/CGOpenMPRuntime.cpp:5025
@@ -5024,1 +5024,3 @@
 
+  /// \brief Map between device pointer declarations and their expression
+  /// components. The key value for declarations in 'this' is null.

No \brief


https://reviews.llvm.org/D22788



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


Re: [PATCH] D22787: [OpenMP] Add support to map member expressions with references to pointers.

2016-07-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D22787



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


Re: [PATCH] D22785: [OpenMP] diagnose orphaned teams construct

2016-07-25 Thread Alexey Bataev via cfe-commits
ABataev accepted this revision.
ABataev added a comment.
This revision is now accepted and ready to land.

LG with a nit



Comment at: lib/Sema/SemaOpenMP.cpp:3360-3366
@@ -3356,5 +3359,9 @@
 if (NestingProhibited) {
-  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
-  << CloseNesting << getOpenMPDirectiveName(OffendingRegion)
-  << Recommend << getOpenMPDirectiveName(CurrentRegion);
+  if (OrphanSeen)
+SemaRef.Diag(StartLoc, diag::err_omp_orphaned_device_directive)
+<< getOpenMPDirectiveName(CurrentRegion) << Recommend;
+  else
+SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
+<< CloseNesting << getOpenMPDirectiveName(OffendingRegion)
+<< Recommend << getOpenMPDirectiveName(CurrentRegion);
   return true;

Please, enclose multiline sub-statements of 'if' statement into braces.


https://reviews.llvm.org/D22785



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


Re: [PATCH] D21343: Implement `lcm` and `gcd` from library fundamentals V2

2016-07-25 Thread Marshall Clow via cfe-commits
mclow.lists updated this revision to Diff 65463.
mclow.lists added a comment.

Updated with Eric's constexpr tests.
Once this is approved, it will be applied twice - once in 
``, and once in ``


https://reviews.llvm.org/D21343

Files:
  include/experimental/numeric
  test/std/experimental/numeric/numeric.ops.overview/nothing_to_do.pass.cpp
  test/std/experimental/numeric/numeric.ops/nothing_to_do.pass.cpp
  
test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.not_integral1.fail.cpp
  
test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.not_integral2.fail.cpp
  test/std/experimental/numeric/numeric.ops/numeric.ops.gcd/gcd.pass.cpp
  
test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.not_integral1.fail.cpp
  
test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.not_integral2.fail.cpp
  test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp

Index: test/std/experimental/numeric/numeric.ops.overview/nothing_to_do.pass.cpp
===
--- test/std/experimental/numeric/numeric.ops.overview/nothing_to_do.pass.cpp
+++ test/std/experimental/numeric/numeric.ops.overview/nothing_to_do.pass.cpp
@@ -0,0 +1,15 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// UNSUPPORTED: c++98, c++03, c++11
+// 
+
+#include 
+
+int main () {}
Index: test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
===
--- test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
+++ test/std/experimental/numeric/numeric.ops/numeric.ops.lcm/lcm.pass.cpp
@@ -0,0 +1,131 @@
+//===--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===--===//
+// 
+// UNSUPPORTED: c++98, c++03, c++11
+// 
+
+// template
+// constexpr common_type_t<_M,_N> gcd(_M __m, _N __n)
+
+#include 
+#include 
+#include 
+#include 
+
+constexpr struct {
+  int x;
+  int y;
+  int expect;
+} Cases[] = {
+{0, 0, 0},
+{1, 0, 0},
+{0, 1, 0},
+{1, 1, 1},
+{2, 3, 6},
+{2, 4, 4},
+{3, 17, 51},
+{36, 18, 36}
+};
+
+template 
+constexpr bool test0(Input1 in1, Input2 in2, Output out)
+{
+static_assert((std::is_same::value), "" );
+static_assert((std::is_same::value), "" );
+return out == std::experimental::lcm(in1, in2) ? true : (std::abort(), false);
+}
+
+
+template 
+constexpr bool do_test(int dummy = 0)
+{
+using S1 = typename std::make_signed::type;
+using S2 = typename std::make_signed::type;
+using U1 = typename std::make_unsigned::type;
+using U2 = typename std::make_unsigned::type;
+bool accumulate = true;
+for (auto TC : Cases) {
+{ // Test with two signed types
+using Output = std::common_type_t;
+accumulate &= test0(TC.x, TC.y, TC.expect);
+accumulate &= test0(-TC.x, TC.y, TC.expect);
+accumulate &= test0(TC.x, -TC.y, TC.expect);
+accumulate &= test0(-TC.x, -TC.y, TC.expect);
+accumulate &= test0(TC.x, TC.y, TC.expect);
+accumulate &= test0(-TC.x, TC.y, TC.expect);
+accumulate &= test0(TC.x, -TC.y, TC.expect);
+accumulate &= test0(-TC.x, -TC.y, TC.expect);
+}
+{ // test with two unsigned types
+using Output = std::common_type_t;
+accumulate &= test0(TC.x, TC.y, TC.expect);
+accumulate &= test0(TC.x, TC.y, TC.expect);
+}
+{ // Test with mixed signs
+using Output = std::common_type_t;
+accumulate &= test0(TC.x, TC.y, TC.expect);
+accumulate &= test0(TC.x, TC.y, TC.expect);
+accumulate &= test0(-TC.x, TC.y, TC.expect);
+accumulate &= test0(TC.x, -TC.y, TC.expect);
+}
+{ // Test with mixed signs
+using Output = std::common_type_t;
+accumulate &= test0(TC.x, TC.y, TC.expect);
+accumulate &= test0(TC.x, 

[PATCH] D22794: [Sema] Propagate nullability when deducing type of auto

2016-07-25 Thread Akira Hatanaka via cfe-commits
ahatanak created this revision.
ahatanak added a reviewer: doug.gregor.
ahatanak added a subscriber: cfe-commits.

This patch fixes Sema to propagate the nullability of the initializer 
expression of a variable declared with auto or __auto_type to the deduced type. 
The patch consists of two parts:

- Define function QualType::setNullability, which is used to return a QualType 
with the specified nullability, and use it in computeConditionalNullability.
- Propagate nullability when type of auto is being deduced.

rdar://problem/27062504

https://reviews.llvm.org/D22794

Files:
  include/clang/AST/Type.h
  lib/AST/Type.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/nullability.c
  test/SemaCXX/nullability.cpp

Index: test/SemaCXX/nullability.cpp
===
--- test/SemaCXX/nullability.cpp
+++ test/SemaCXX/nullability.cpp
@@ -98,6 +98,11 @@
   TakeNonnull(ReturnNullable()); //expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull}}
 }
 
+void * _Nonnull DeduceAuto() {
+  auto *p = ReturnNullable();
+  return p; // expected-warning{{implicit conversion from nullable pointer 'void * _Nullable' to non-nullable pointer type 'void * _Nonnull'}}
+}
+
 void ConditionalExpr(bool c) {
   struct Base {};
   struct Derived : Base {};
Index: test/Sema/nullability.c
===
--- test/Sema/nullability.c
+++ test/Sema/nullability.c
@@ -129,6 +129,13 @@
   accepts_nonnull_1(ptr); // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
 }
 
+int * _Nullable return_nullable();
+
+int * _Nonnull deduce_auto() {
+  __auto_type *p = return_nullable();
+  return p; // expected-warning{{implicit conversion from nullable pointer 'int * _Nullable' to non-nullable pointer type 'int * _Nonnull'}}
+}
+
 // Check nullability of conditional expressions.
 void conditional_expr(int c) {
   int * _Nonnull p;
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -7052,13 +7052,8 @@
   if (GetNullability(ResTy) == MergedKind)
 return ResTy;
 
-  // Strip all nullability from ResTy.
-  while (ResTy->getNullability(Ctx))
-ResTy = ResTy.getSingleStepDesugaredType(Ctx);
-
-  // Create a new AttributedType with the new nullability kind.
-  auto NewAttr = AttributedType::getNullabilityAttrKind(MergedKind);
-  return Ctx.getAttributedType(NewAttr, ResTy, ResTy);
+  // Create a new type with the merged nullability kind.
+  return ResTy.setNullability(MergedKind, Ctx);
 }
 
 /// ActOnConditionalOp - Parse a ?: operation.  Note that 'LHS' may be null
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -9733,6 +9733,11 @@
   return;
 }
 
+// Propagate init expression's nullability to the deduced type.
+if (!Init->getType().isNull() && DeducedType->isAnyPointerType())
+  DeducedType = DeducedType.setNullability(
+  Init->getType()->getNullability(Context), Context);
+
 VDecl->setType(DeducedType);
 assert(VDecl->isLinkageValid());
 
Index: lib/AST/Type.cpp
===
--- lib/AST/Type.cpp
+++ lib/AST/Type.cpp
@@ -1279,6 +1279,23 @@
   return getUnqualifiedType();
 }
 
+QualType QualType::setNullability(Optional Kind,
+  ASTContext ) const {
+  assert(getTypePtr()->isAnyPointerType() && "type has to be a pointer type");
+  QualType ResTy = *this;
+
+  // Strip all nullability specifiers.
+  while (ResTy->getNullability(Ctx))
+ResTy = ResTy.getSingleStepDesugaredType(Ctx);
+
+  if (!Kind)
+return ResTy;
+
+  // Create a new AttributedType with the new nullability kind.
+  auto NewAttr = AttributedType::getNullabilityAttrKind(*Kind);
+  return Ctx.getAttributedType(NewAttr, ResTy, ResTy);
+}
+
 Optional Type::getObjCSubstitutions(
const DeclContext *dc) const {
   // Look through method scopes.
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1093,6 +1093,10 @@
   /// Remove all qualifiers including _Atomic.
   QualType getAtomicUnqualifiedType() const;
 
+  /// Create a type having the specified nullability.
+  QualType setNullability(Optional Kind,
+  ASTContext ) const;
+
 private:
   // These methods are implemented in a separate translation unit;
   // "static"-ize them to avoid creating temporary QualTypes in the
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r276716 - [Coverage] Do not write out coverage mappings with zero entries

2016-07-25 Thread Vedant Kumar via cfe-commits
Author: vedantk
Date: Mon Jul 25 19:24:59 2016
New Revision: 276716

URL: http://llvm.org/viewvc/llvm-project?rev=276716=rev
Log:
[Coverage] Do not write out coverage mappings with zero entries

After r275121, we stopped mapping regions from system headers. Lambdas
declared in regions belonging to system headers started producing empty
coverage mappings, since the files corresponding to their spelling locs
were being ignored.

The coverage reader doesn't know what to do with these empty mappings.
This commit makes sure that we don't produce them and adds a test. I'll
make the reader stricter in a follow-up commit.

Added:
cfe/trunk/test/CoverageMapping/system_macro.cpp
  - copied, changed from r276711, 
cfe/trunk/test/CoverageMapping/system_macro.c
Removed:
cfe/trunk/test/CoverageMapping/system_macro.c
Modified:
cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp

Modified: cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp?rev=276716=276715=276716=diff
==
--- cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp (original)
+++ cfe/trunk/lib/CodeGen/CoverageMappingGen.cpp Mon Jul 25 19:24:59 2016
@@ -352,6 +352,9 @@ struct EmptyCoverageMappingBuilder : pub
 gatherFileIDs(FileIDMapping);
 emitSourceRegions();
 
+if (MappingRegions.empty())
+  return;
+
 CoverageMappingWriter Writer(FileIDMapping, None, MappingRegions);
 Writer.write(OS);
   }
@@ -605,6 +608,9 @@ struct CounterCoverageMappingBuilder
 emitExpansionRegions();
 gatherSkippedRegions();
 
+if (MappingRegions.empty())
+  return;
+
 CoverageMappingWriter Writer(VirtualFileMapping, Builder.getExpressions(),
  MappingRegions);
 Writer.write(OS);
@@ -621,6 +627,11 @@ struct CounterCoverageMappingBuilder
 
   void VisitDecl(const Decl *D) {
 Stmt *Body = D->getBody();
+
+// Do not propagate region counts into system headers.
+if (Body && SM.isInSystemHeader(SM.getSpellingLoc(getStart(Body
+  return;
+
 propagateCounts(getRegionCounter(Body), Body);
   }
 

Removed: cfe/trunk/test/CoverageMapping/system_macro.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/system_macro.c?rev=276715=auto
==
--- cfe/trunk/test/CoverageMapping/system_macro.c (original)
+++ cfe/trunk/test/CoverageMapping/system_macro.c (removed)
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name system_macro.c -o - %s | 
FileCheck %s
-
-#ifdef IS_SYSHEADER
-
-#pragma clang system_header
-#define Func(x) if (x) {}
-#define SomeType int
-
-#else
-
-#define IS_SYSHEADER
-#include __FILE__
-
-// CHECK-LABEL: doSomething:
-void doSomething(int x) { // CHECK: File 0, [[@LINE]]:25 -> {{[0-9:]+}} = #0
-  Func(x);
-  return;
-  SomeType *f; // CHECK: File 0, [[@LINE]]:11 -> {{[0-9:]+}} = 0
-}
-
-int main() {}
-
-#endif

Copied: cfe/trunk/test/CoverageMapping/system_macro.cpp (from r276711, 
cfe/trunk/test/CoverageMapping/system_macro.c)
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CoverageMapping/system_macro.cpp?p2=cfe/trunk/test/CoverageMapping/system_macro.cpp=cfe/trunk/test/CoverageMapping/system_macro.c=276711=276716=276716=diff
==
--- cfe/trunk/test/CoverageMapping/system_macro.c (original)
+++ cfe/trunk/test/CoverageMapping/system_macro.cpp Mon Jul 25 19:24:59 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name system_macro.c -o - %s | 
FileCheck %s
+// RUN: %clang_cc1 -std=c++11 -fprofile-instrument=clang -fcoverage-mapping 
-dump-coverage-mapping -emit-llvm-only -main-file-name system_macro.cpp -o - %s 
| FileCheck %s
 
 #ifdef IS_SYSHEADER
 
@@ -11,13 +11,16 @@
 #define IS_SYSHEADER
 #include __FILE__
 
-// CHECK-LABEL: doSomething:
+// CHECK-LABEL: doSomething
 void doSomething(int x) { // CHECK: File 0, [[@LINE]]:25 -> {{[0-9:]+}} = #0
   Func(x);
   return;
   SomeType *f; // CHECK: File 0, [[@LINE]]:11 -> {{[0-9:]+}} = 0
 }
 
-int main() {}
+// CHECK-LABEL: main
+int main() { // CHECK: File 0, [[@LINE]]:12 -> [[@LINE+2]]:2 = #0
+  Func([] { return true; }());
+}
 
 #endif


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


Re: [PATCH] D22391: [Sema] Add warning for implicitly casting a null constant to a non null pointer type

2016-07-25 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 65446.
ahatanak added a comment.

Addressed review comment and made a couple of other changes.

- Move Sema::diagnoseNullPtrToNonnullCast to SemaChecking.cpp.
- In diagnoseNullPtrToNonnullCast, call "Type::isAnyPointerType" instead of 
"Type::isPointerType" so that the function can diagnose objective-c pointers in 
addition to c/c++ pointers.
- Instead of adding the new warning to the existing 
"NullableToNonNullConversion" group, which would cause clang to warn about nil 
returns from objective-c methods (which is undesirable according to r240153's 
commit log), create a new diagnostic group for "-Wnull-const_to-nonnull".


https://reviews.llvm.org/D22391

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/Sema/Sema.cpp
  lib/Sema/SemaChecking.cpp
  lib/Sema/SemaExpr.cpp
  test/Sema/null_const_to_nonnull.c
  test/SemaObjC/null_const_to_nonnull.m

Index: test/SemaObjC/null_const_to_nonnull.m
===
--- /dev/null
+++ test/SemaObjC/null_const_to_nonnull.m
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnull-const-to-nonnull %s -verify
+
+void null_const_to_nonnull(int c) {
+  id _Nonnull p0 = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'id _Nonnull'}}
+  id _Nonnull p1;
+  id _Nonnull p2 = c ? p1 : 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'id _Nonnull'}}
+}
Index: test/Sema/null_const_to_nonnull.c
===
--- /dev/null
+++ test/Sema/null_const_to_nonnull.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -fsyntax-only -Wnull-const-to-nonnull %s -verify
+
+void null_const_to_nonnull(int c) {
+  int * _Nonnull p0 = 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+  int * _Nonnull p1;
+  int * _Nonnull p2 = c ? p1 : 0; // expected-warning{{implicitly casting a null constant to non-nullable pointer type 'int * _Nonnull'}}
+}
Index: lib/Sema/SemaExpr.cpp
===
--- lib/Sema/SemaExpr.cpp
+++ lib/Sema/SemaExpr.cpp
@@ -714,6 +714,7 @@
   E->getType().getObjCLifetime() == Qualifiers::OCL_Weak)
 Cleanup.setExprNeedsCleanups(true);
 
+  diagnoseNullPtrToNonnullCast(T, E, E->getExprLoc());
   ExprResult Res = ImplicitCastExpr::Create(Context, T, CK_LValueToRValue, E,
 nullptr, VK_RValue);
 
Index: lib/Sema/SemaChecking.cpp
===
--- lib/Sema/SemaChecking.cpp
+++ lib/Sema/SemaChecking.cpp
@@ -8685,6 +8685,17 @@
   return false;
 }
 
+void Sema::diagnoseNullPtrToNonnullCast(QualType DstType, Expr *E,
+SourceLocation Loc) {
+  if (!DstType->isAnyPointerType() || CurContext->isDependentContext())
+return;
+
+  if (Optional Kind = DstType->getNullability(Context))
+if (*Kind == NullabilityKind::NonNull &&
+E->isNullPointerConstant(Context, Expr::NPC_ValueDependentIsNotNull))
+  Diag(Loc, diag::warn_null_const_to_nonnull) << DstType;
+}
+
 /// \brief Diagnose pointers that are always non-null.
 /// \param E the expression containing the pointer
 /// \param NullKind NPCK_NotNull if E is a cast to bool, otherwise, E is
Index: lib/Sema/Sema.cpp
===
--- lib/Sema/Sema.cpp
+++ lib/Sema/Sema.cpp
@@ -399,6 +399,7 @@
 }
   }
 
+  diagnoseNullPtrToNonnullCast(Ty, E, E->getExprLoc());
   return ImplicitCastExpr::Create(Context, Ty, Kind, E, BasePath, VK);
 }
 
Index: include/clang/Sema/Sema.h
===
--- include/clang/Sema/Sema.h
+++ include/clang/Sema/Sema.h
@@ -3614,6 +3614,11 @@
   void diagnoseNullableToNonnullConversion(QualType DstType, QualType SrcType,
SourceLocation Loc);
 
+  /// Warn if we're implicitly casting from a null pointer constant to a
+  /// _Nonnull pointer type.
+  void diagnoseNullPtrToNonnullCast(QualType DstType, Expr *E,
+SourceLocation Loc);
+
   ParsingDeclState PushParsingDeclaration(sema::DelayedDiagnosticPool ) {
 return DelayedDiagnostics.push(pool);
   }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8538,6 +8538,10 @@
   "type %1">,
   InGroup, DefaultIgnore;
 
+def warn_null_const_to_nonnull : Warning<
+  "implicitly casting a null constant to non-nullable pointer type %0">,
+  InGroup, DefaultIgnore;
+
 def err_nullability_cs_multilevel : Error<
   "nullability keyword %0 cannot be applied to multi-level pointer type %1">;
 

Re: [PATCH] D22782: Added 'inline' attribute to __init to inline the basic_string's constructor

2016-07-25 Thread Sebastian Pop via cfe-commits
sebpop added a comment.

In https://reviews.llvm.org/D22782#495436, @mclow.lists wrote:

> Do we have a test for the problem that this is solving?


I think we can write a testcase that shows that copy constructors are not 
optimized away unless the string constructor is inlined.

This patch fixes the performance of a proprietary benchmark when compiled with 
libc++, closing the performance gap with the same benchmark compiled with the 
gnu libstdc++. Overall with this patch we have half a billion fewer 
instructions out of about 10 billion.


https://reviews.llvm.org/D22782



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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren updated this revision to Diff 65449.
manmanren added a comment.

Addressing Ben's comments


https://reviews.llvm.org/D22773

Files:
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/Driver/modules.m
  test/Modules/Inputs/DiagOutOfDate.h
  test/Modules/Inputs/module.map
  test/Modules/Inputs/pch-import-module-out-of-date.pch
  test/Modules/diagnostic-options-out-of-date.m

Index: test/Modules/diagnostic-options-out-of-date.m
===
--- test/Modules/diagnostic-options-out-of-date.m
+++ test/Modules/diagnostic-options-out-of-date.m
@@ -0,0 +1,12 @@
+// RUN: rm -rf %t
+// Build A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
+// Build pch that imports A.pcm
+// RUN: %clang_cc1 -Werror -Wno-conversion -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-out-of-date.pch -fmodules-disable-diagnostic-validation
+// Make sure that we don't rebuild A.pcm and overwrite the original A.pcm that the pch imports
+// RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
+// Make sure we don't error out when using the pch
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify -fmodules-disable-diagnostic-validation
+// expected-no-diagnostics
+
+@import DiagOutOfDate;
Index: test/Modules/Inputs/pch-import-module-out-of-date.pch
===
--- test/Modules/Inputs/pch-import-module-out-of-date.pch
+++ test/Modules/Inputs/pch-import-module-out-of-date.pch
@@ -0,0 +1 @@
+@import DiagOutOfDate;
Index: test/Modules/Inputs/module.map
===
--- test/Modules/Inputs/module.map
+++ test/Modules/Inputs/module.map
@@ -418,3 +418,7 @@
 module MacroFabs1 {
   header "MacroFabs1.h"
 }
+
+module DiagOutOfDate {
+  header "DiagOutOfDate.h"
+}
Index: test/Modules/Inputs/DiagOutOfDate.h
===
--- test/Modules/Inputs/DiagOutOfDate.h
+++ test/Modules/Inputs/DiagOutOfDate.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -33,6 +33,12 @@
 // RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
+// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: -fmodules-disable-diagnostic-validation
+
+// RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2084,7 +2084,7 @@
 ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
 BitstreamCursor , unsigned ClientLoadCapabilities,
 bool AllowCompatibleConfigurationMismatch, ASTReaderListener ,
-std::string ) {
+std::string , bool ValidateDiagnosticOptions) {
   if (Stream.EnterSubBlock(OPTIONS_BLOCK_ID))
 return Failure;
 
@@ -2128,7 +2128,8 @@
 
 case DIAGNOSTIC_OPTIONS: {
   bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
-  if (!AllowCompatibleConfigurationMismatch &&
+  if (ValidateDiagnosticOptions &&
+  !AllowCompatibleConfigurationMismatch &&
   ParseDiagnosticOptions(Record, Complain, Listener))
 return OutOfDate;
   break;
@@ -2255,10 +2256,13 @@
   // FIXME: Allow this for files explicitly specified with -include-pch.
   bool AllowCompatibleConfigurationMismatch =
   F.Kind == MK_ExplicitModule;
+  const HeaderSearchOptions  =
+  PP.getHeaderSearchInfo().getHeaderSearchOpts();
 
   Result = ReadOptionsBlock(Stream, ClientLoadCapabilities,
 

Re: [PATCH] D22515: Added false-positive filter for unintended hash code collisions to the CloneDetector.

2016-07-25 Thread Raphael Isemann via cfe-commits
teemperor added a comment.

This patch is no longer needed because the CloneDetector from patch 
https://reviews.llvm.org/D20795 no longer uses custom hashing.


https://reviews.llvm.org/D22515



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-25 Thread Raphael Isemann via cfe-commits
teemperor marked 3 inline comments as done.
teemperor added a comment.

https://reviews.llvm.org/D20795



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-25 Thread Raphael Isemann via cfe-commits
teemperor added inline comments.


Comment at: lib/Analysis/CloneDetection.cpp:178
@@ +177,3 @@
+
+  bool VisitFunctionDecl(FunctionDecl *D) {
+// If we found a function, we start the clone search on its body statement.

NoQ wrote:
> You'd probably want to add `ObjCMethodDecl` and `BlockDecl`, because they 
> aren't sub-classes of `FunctionDecl` (and probably even tests for that).
> 
> Because this part of the code essentially re-implements `AnalysisConsumer`, 
> (a `RecursiveASTVisitor` that tells us what code bodies to analyze with the 
> static analyzer - i should've looked there earlier!!).
> 
> Alternatively, you can just rely on `AnalysisConsumer`, which would eliminate 
> the recursive visitor completely: {F2205103} This way you'd be analyzing 
> exactly the same code bodies that the analyzer itself would analyze; if you'd 
> want to extend to various declarations, you'd be able to do that by 
> subscribing on `check::ASTDecl`. But i dare not to predict what kind of 
> different flexibility you'd need next.
Thanks for the patch!


https://reviews.llvm.org/D20795



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-25 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65441.
teemperor added a comment.

- The CloneGroup values in StringMap no longer store a copy of their own key.


https://reviews.llvm.org/D20795

Files:
  include/clang/Analysis/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/Analysis/CMakeLists.txt
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/blocks.cpp
  test/Analysis/copypaste/false-positives.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/objc-methods.m
  test/Analysis/copypaste/sub-sequences.cpp

Index: test/Analysis/copypaste/sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/sub-sequences.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if sub-sequences can match with normal sequences.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) { // no-warning
+  return a + b;
+}
Index: test/Analysis/copypaste/objc-methods.m
===
--- /dev/null
+++ test/Analysis/copypaste/objc-methods.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -Wno-objc-root-class -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if we search for clones in Objective-C methods.
+
+@interface A
+- (int) setOk : (int) a : (int) b;
+@end
+
+@implementation A
+- (int) setOk : (int) a : (int) b {  // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+@end
+
+@interface B
+- (int) setOk : (int) a : (int) b;
+@end
+
+@implementation B
+- (int) setOk : (int) a : (int) b { // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+@end
Index: test/Analysis/copypaste/functions.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/functions.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if we search for clones in functions.
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int x, int y) { // expected-note{{Related code clone is here.}}
+  log();
+  if (x > y)
+return x;
+  return y;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) { // no-warning
+  return a + b;
+}
Index: test/Analysis/copypaste/false-positives.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/false-positives.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This test contains false-positive reports from the CloneChecker that need to
+// be fixed.
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
Index: test/Analysis/copypaste/blocks.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/blocks.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -analyze -fblocks -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if we search for clones in blocks.
+
+void log();
+
+auto BlockA = ^(int a, int b){ // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+};
+
+auto BlockB = ^(int a, int b){ // expected-note{{Related code clone is here.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+};
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ lib/StaticAnalyzer/Checkers/CloneChecker.cpp
@@ -0,0 +1,96 @@
+//===--- CloneChecker.cpp - Clone detection checker -*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//

r276711 - [CMake] Pass DYLD_LIBRARY_PATH as CMake variable instead of as envar

2016-07-25 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon Jul 25 18:48:14 2016
New Revision: 276711

URL: http://llvm.org/viewvc/llvm-project?rev=276711=rev
Log:
[CMake] Pass DYLD_LIBRARY_PATH as CMake variable instead of as envar

On OS X 10.11 System Integrity Protection prevents the DYLD environment 
variables from being set on system binaries. To work around this r276710 
accepts DYLD_LIBRARY_PATH as a CMake variable and sets it directly on the 
archiver commands.

To make this work with bootstrapping we need to set DYLD_LIBRARY_PATH to the 
current stage's library directory and pass that into the next stage's 
configuration.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=276711=276710=276711=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Jul 25 18:48:14 2016
@@ -494,7 +494,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
   
   set(STAMP_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-stamps/)
   set(BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/${NEXT_CLANG_STAGE}-bins/)
-  set(cmake_command ${CMAKE_COMMAND})
 
   # If the next stage is LTO we need to depend on LTO and possibly LLVMgold
   if(BOOTSTRAP_LLVM_ENABLE_LTO OR LLVM_ENABLE_LTO)
@@ -503,8 +502,13 @@ if (CLANG_ENABLE_BOOTSTRAP)
   # on Darwin we need to set DARWIN_LTO_LIBRARY so that -flto will work
   # using the just-built compiler, and we need to override 
DYLD_LIBRARY_PATH
   # so that the host object file tools will use the just-built libLTO.
-  set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib)
-  set(cmake_command ${CMAKE_COMMAND} -E env 
DYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR} ${CMAKE_COMMAND})
+  # However if System Integrity Protection is enabled the DYLD variables
+  # will be scrubbed from the environment of any base system commands. This
+  # includes /bin/sh, which ninja uses when executing build commands. To
+  # work around the envar being filtered away we pass it in as a CMake
+  # variable, and have LLVM's CMake append the envar to the archiver calls.
+  set(LTO_LIBRARY 
-DDARWIN_LTO_LIBRARY=${LLVM_SHLIB_OUTPUT_INTDIR}/libLTO.dylib
+-DDYLD_LIBRARY_PATH=${LLVM_LIBRARY_OUTPUT_INTDIR})
 elseif(NOT WIN32)
   list(APPEND LTO_DEP LLVMgold llvm-ar llvm-ranlib)
   set(LTO_AR -DCMAKE_AR=${LLVM_RUNTIME_OUTPUT_INTDIR}/llvm-ar)
@@ -604,7 +608,6 @@ if (CLANG_ENABLE_BOOTSTRAP)
  -DCLANG_STAGE=${NEXT_CLANG_STAGE}
 ${COMPILER_OPTIONS}
 ${LTO_LIBRARY} ${LTO_AR} ${LTO_RANLIB} ${verbose} ${PGO_OPT}
-CMAKE_COMMAND ${cmake_command}
 INSTALL_COMMAND ""
 STEP_TARGETS configure build
 USES_TERMINAL_CONFIGURE 1
@@ -615,7 +618,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
   # exclude really-install from main target
   set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES 
_EP_really-install_EXCLUDE_FROM_MAIN On)
   ExternalProject_Add_Step(${NEXT_CLANG_STAGE} really-install
-COMMAND ${cmake_command} --build  --target install
+COMMAND ${CMAKE_COMMAND} --build  --target install
 COMMENT "Performing install step for '${NEXT_CLANG_STAGE}'"
 DEPENDEES build
 USES_TERMINAL 1
@@ -631,7 +634,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
 set_target_properties(${NEXT_CLANG_STAGE} PROPERTIES 
_EP_${target}_EXCLUDE_FROM_MAIN On)
 
 ExternalProject_Add_Step(${NEXT_CLANG_STAGE} ${target}
-  COMMAND ${cmake_command} --build  --target ${target}
+  COMMAND ${CMAKE_COMMAND} --build  --target ${target}
   COMMENT "Performing ${target} for '${NEXT_CLANG_STAGE}'"
   DEPENDEES configure
   USES_TERMINAL 1


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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D22773#495524, @benlangmuir wrote:

> > the pcm could still be rewritten by a compilation that doesn't use a PCH, 
> > and then it would be out of date because of the timestamp instead of the 
> > diagnostic options
>
> > 
>
> > "a compilation that doesn't use a PCH", is that a different project? And we 
> > have two projects building in parallel? Just to make sure I understand.
>
>
> Two different projects (or targets, or whatever), but they don't even have to 
> build at the same time.  They just have to share a cache. Suppose you have a 
> project A with a PCH and -fmodules-disable-diagnostic-validation.  Suppose 
> you have another project B that does not use this flag, and does not have a 
> PCH.  With this patch, A and B can share a module cache.
>
> A builds a PCH that depends on some module X -- OK
>  B builds with -Werror.  Rebuilds X.pcm -- OK
>
> Now suppose we build A again because of some change:  it can't build because 
> X.pcm changed, but we haven't rebuilt the PCH.


Got it, I will update the patch!

Manman


https://reviews.llvm.org/D22773



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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Ben Langmuir via cfe-commits
benlangmuir added a comment.

> the pcm could still be rewritten by a compilation that doesn't use a PCH, and 
> then it would be out of date because of the timestamp instead of the 
> diagnostic options

> 

> "a compilation that doesn't use a PCH", is that a different project? And we 
> have two projects building in parallel? Just to make sure I understand.


Two different projects (or targets, or whatever), but they don't even have to 
build at the same time.  They just have to share a cache. Suppose you have a 
project A with a PCH and -fmodules-disable-diagnostic-validation.  Suppose you 
have another project B that does not use this flag, and does not have a PCH.  
With this patch, A and B can share a module cache.

A builds a PCH that depends on some module X -- OK
B builds with -Werror.  Rebuilds X.pcm -- OK

Now suppose we build A again because of some change:  it can't build because 
X.pcm changed, but we haven't rebuilt the PCH.


https://reviews.llvm.org/D22773



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


Re: [PATCH] D20795: Added basic capabilities to detect source code clones.

2016-07-25 Thread Raphael Isemann via cfe-commits
teemperor updated this revision to Diff 65439.
teemperor marked 7 inline comments as done.
teemperor added a comment.

- Fixed the minor problems as pointed out by Artem.
- Now using AnalysisConsumer instead of RecursiveASTVisitor.
- Function names are now confirming to LLVM code-style.
- Renamed DataCollectVisitor to CloneSignatureGenerator (as it's no longer 
following the Visitor pattern).
- Added tests for clone detection in ObjC-methods and blocks.
- Moved false-positive tests into own file.


https://reviews.llvm.org/D20795

Files:
  include/clang/Analysis/CloneDetection.h
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/Analysis/CMakeLists.txt
  lib/Analysis/CloneDetection.cpp
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/CloneChecker.cpp
  test/Analysis/copypaste/blocks.cpp
  test/Analysis/copypaste/false-positives.cpp
  test/Analysis/copypaste/functions.cpp
  test/Analysis/copypaste/objc-methods.m
  test/Analysis/copypaste/sub-sequences.cpp

Index: test/Analysis/copypaste/sub-sequences.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/sub-sequences.cpp
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if sub-sequences can match with normal sequences.
+
+void log2(int a);
+void log();
+
+int max(int a, int b) {
+  log2(a);
+  log(); // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int a, int b) {
+  log(); // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) { // no-warning
+  return a + b;
+}
Index: test/Analysis/copypaste/objc-methods.m
===
--- /dev/null
+++ test/Analysis/copypaste/objc-methods.m
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -analyze -Wno-objc-root-class -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if we search for clones in Objective-C methods.
+
+@interface A
+- (int) setOk : (int) a : (int) b;
+@end
+
+@implementation A
+- (int) setOk : (int) a : (int) b {  // expected-warning{{Detected code clone.}}
+  if (a > b)
+return a;
+  return b;
+}
+@end
+
+@interface B
+- (int) setOk : (int) a : (int) b;
+@end
+
+@implementation B
+- (int) setOk : (int) a : (int) b { // expected-note{{Related code clone is here.}}
+  if (a > b)
+return a;
+  return b;
+}
+@end
Index: test/Analysis/copypaste/functions.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/functions.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if we search for clones in functions.
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+int maxClone(int x, int y) { // expected-note{{Related code clone is here.}}
+  log();
+  if (x > y)
+return x;
+  return y;
+}
+
+// Functions below are not clones and should not be reported.
+
+int foo(int a, int b) { // no-warning
+  return a + b;
+}
Index: test/Analysis/copypaste/false-positives.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/false-positives.cpp
@@ -0,0 +1,29 @@
+// RUN: %clang_cc1 -analyze -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This test contains false-positive reports from the CloneChecker that need to
+// be fixed.
+
+void log();
+
+int max(int a, int b) { // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different binary operator kinds.
+int min1(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (a < b)
+return a;
+  return b;
+}
+
+// FIXME: Detect different variable patterns.
+int min2(int a, int b) { // expected-note{{Related code clone is here.}}
+  log();
+  if (b > a)
+return a;
+  return b;
+}
Index: test/Analysis/copypaste/blocks.cpp
===
--- /dev/null
+++ test/Analysis/copypaste/blocks.cpp
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -analyze -fblocks -std=c++11 -analyzer-checker=alpha.clone.CloneChecker -verify %s
+
+// This tests if we search for clones in blocks.
+
+void log();
+
+auto BlockA = ^(int a, int b){ // expected-warning{{Detected code clone.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+};
+
+auto BlockB = ^(int a, int b){ // expected-note{{Related code clone is here.}}
+  log();
+  if (a > b)
+return a;
+  return b;
+};
Index: lib/StaticAnalyzer/Checkers/CloneChecker.cpp
===
--- /dev/null
+++ 

[PATCH] D22788: [OpenMP] Code generation for the is_device_ptr clause

2016-07-25 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: cfe-commits, caomhin.

This patch adds support for the is_device_ptr clause. It expands SEMA to use 
the mappable expression logic that can only be tested with code generation in 
place and check conflicts with other data sharing related clauses using the 
mappable expressions infrastructure. 

https://reviews.llvm.org/D22788

Files:
  include/clang/AST/OpenMPClause.h
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/OpenMPClause.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/Sema/SemaOpenMP.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/OpenMP/target_is_device_ptr_codegen.cpp
  test/OpenMP/target_is_device_ptr_messages.cpp

Index: test/OpenMP/target_is_device_ptr_messages.cpp
===
--- test/OpenMP/target_is_device_ptr_messages.cpp
+++ test/OpenMP/target_is_device_ptr_messages.cpp
@@ -142,6 +142,7 @@
   T * = k;
   T aa[10];
   auto  = aa;
+  S6 *ps;
 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
   {}
 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
@@ -178,6 +179,22 @@
   {}
 #pragma omp target is_device_ptr(da) // OK
   {}
+#pragma omp target map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as firstprivate}}
+  {}
+#pragma omp target is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as private}}
+  {}
   return 0;
 }
 
@@ -194,6 +211,7 @@
   int * = k;
   int aa[10];
   auto  = aa;
+  S6 *ps;
 #pragma omp target is_device_ptr // expected-error {{expected '(' after 'is_device_ptr'}}
   {}
 #pragma omp target is_device_ptr( // expected-error {{expected ')'}} expected-note {{to match this '('}} expected-error {{expected expression}}
@@ -230,5 +248,21 @@
   {}
 #pragma omp target is_device_ptr(da) // OK
   {}
+#pragma omp target map(ps) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target map(ps->a) is_device_ptr(ps) // expected-error{{variable already marked as mapped in current construct}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) map(ps->a) // expected-error{{pointer cannot be mapped along with a section derived from itself}} expected-note{{used here}}
+  {}
+#pragma omp target is_device_ptr(ps) firstprivate(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target firstprivate(ps) is_device_ptr(ps) // expected-error{{firstprivate variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as firstprivate}}
+  {}
+#pragma omp target is_device_ptr(ps) private(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}}
+  {}
+#pragma omp target private(ps) is_device_ptr(ps) // expected-error{{private variable cannot be in a is_device_ptr clause in '#pragma omp target' directive}} expected-note{{defined as private}}
+  {}
   return tmain(argc); // expected-note {{in instantiation of function template specialization 'tmain' requested here}}
 }
Index: test/OpenMP/target_is_device_ptr_codegen.cpp
===
--- /dev/null
+++ test/OpenMP/target_is_device_ptr_codegen.cpp
@@ -0,0 +1,293 @@
+// expected-no-diagnostics
+#ifndef 

[PATCH] D22787: [OpenMP] Add support to map member expressions with references to pointers.

2016-07-25 Thread Samuel Antao via cfe-commits
sfantao created this revision.
sfantao added reviewers: ABataev, hfinkel, carlo.bertolli, arpith-jacob, kkwli0.
sfantao added subscribers: cfe-commits, caomhin.

This patch add support to map pointers through references in class members. 
Although a reference does not have storage that a user can access, it still has 
to be mapped in order to get the deep copy right and the dereferencing code 
work properly.

https://reviews.llvm.org/D22787

Files:
  lib/CodeGen/CGOpenMPRuntime.cpp
  test/OpenMP/target_map_codegen.cpp

Index: test/OpenMP/target_map_codegen.cpp
===
--- test/OpenMP/target_map_codegen.cpp
+++ test/OpenMP/target_map_codegen.cpp
@@ -4564,4 +4564,193 @@
   }
 }
 #endif
+///==///
+// RUN: %clang_cc1 -DCK29 -verify -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -emit-llvm %s -o - | FileCheck %s --check-prefix CK29 --check-prefix CK29-64
+// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -std=c++11 -triple powerpc64le-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=powerpc64le-ibm-linux-gnu -x c++ -triple powerpc64le-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK29 --check-prefix CK29-64
+// RUN: %clang_cc1 -DCK29 -verify -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -emit-llvm %s -o - | FileCheck %s  --check-prefix CK29 --check-prefix CK29-32
+// RUN: %clang_cc1 -DCK29 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -std=c++11 -triple i386-unknown-unknown -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -fopenmp-targets=i386-pc-linux-gnu -x c++ -triple i386-unknown-unknown -std=c++11 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s  --check-prefix CK29 --check-prefix CK29-32
+#ifdef CK29
+
+// CK29: [[SSA:%.+]] = type { double*, double** }
+// CK29: [[SSB:%.+]]  = type { [[SSA]]*, [[SSA]]** }
+
+// CK29: [[SIZE00:@.+]] = private {{.*}}constant [4 x i[[Z:64|32]]] [i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] {{8|4}}, i[[Z:64|32]] 80]
+// CK29: [[MTYPE00:@.+]] = private {{.*}}constant [4 x i32] [i32 35, i32 16, i32 19, i32 19]
+
+// CK29: [[SIZE01:@.+]] = private {{.*}}constant [4 x i[[Z]]] [i[[Z]] {{8|4}}, i[[Z]] {{8|4}}, i[[Z]] {{8|4}}, i[[Z]] 80]
+// CK29: [[MTYPE01:@.+]] = private {{.*}}constant [4 x i32] [i32 32, i32 19, i32 19, i32 19]
+
+// CK29: [[SIZE02:@.+]] = private {{.*}}constant [5 x i[[Z]]] [i[[Z]] {{8|4}}, i[[Z]] {{8|4}}, i[[Z]] {{8|4}}, i[[Z]] {{8|4}}, i[[Z]] 80]
+// CK29: [[MTYPE02:@.+]] = private {{.*}}constant [5 x i32] [i32 32, i32 19, i32 16, i32 19, i32 19]
+
+struct SSA{
+  double *p;
+  double *
+  SSA(double *) : pr(pr) {}
+};
+
+struct SSB{
+  SSA *p;
+  SSA *
+  SSB(SSA *) : pr(pr) {}
+
+  // CK29-LABEL: define {{.+}}foo
+  void foo() {
+
+// Region 00
+// CK29-DAG: call i32 @__tgt_target(i32 {{[^,]+}}, i8* {{[^,]+}}, i32 4, i8** [[GEPBP:%.+]], i8** [[GEPP:%.+]], {{.+}}getelementptr {{.+}}[4 x i{{.+}}]* [[SIZE00]], {{.+}}getelementptr {{.+}}[4 x i{{.+}}]* [[MTYPE00]]{{.+}})
+
+// CK29-DAG: [[GEPBP]] = getelementptr inbounds {{.+}}[[BP:%[^,]+]]
+// CK29-DAG: [[GEPP]] = getelementptr inbounds {{.+}}[[P:%[^,]+]]
+
+// CK29-DAG: [[BP0:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 0
+// CK29-DAG: [[P0:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 0
+// CK29-DAG: store i8* [[CBPVAL0:%[^,]+]], i8** [[BP0]]
+// CK29-DAG: store i8* [[CPVAL0:%[^,]+]], i8** [[P0]]
+// CK29-DAG: [[CBPVAL0]] = bitcast [[SSB]]* [[VAR0:%.+]] to i8*
+// CK29-DAG: [[CPVAL0]] = bitcast [[SSA]]** [[VAR00:%.+]] to i8*
+// CK29-DAG: [[VAR0]] = load [[SSB]]*, [[SSB]]** %
+// CK29-DAG: [[VAR00]] = getelementptr inbounds [[SSB]], [[SSB]]* [[VAR0]], i32 0, i32 0
+
+// CK29-DAG: [[BP1:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 1
+// CK29-DAG: [[P1:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 1
+// CK29-DAG: store i8* [[CBPVAL1:%[^,]+]], i8** [[BP1]]
+// CK29-DAG: store i8* [[CPVAL1:%[^,]+]], i8** [[P1]]
+// CK29-DAG: [[CBPVAL1]] = bitcast [[SSA]]** [[VAR00]] to i8*
+// CK29-DAG: [[CPVAL1]] = bitcast double*** [[VAR1:%.+]] to i8*
+// CK29-DAG: [[VAR1]] = getelementptr inbounds [[SSA]], [[SSA]]* %{{.+}}, i32 0, i32 1
+
+// CK29-DAG: [[BP2:%.+]] = getelementptr inbounds {{.+}}[[BP]], i{{.+}} 0, i{{.+}} 2
+// CK29-DAG: [[P2:%.+]] = getelementptr inbounds {{.+}}[[P]], i{{.+}} 0, i{{.+}} 2
+// CK29-DAG: store i8* [[CBPVAL2:%[^,]+]], i8** [[BP2]]
+// CK29-DAG: store i8* [[CPVAL2:%[^,]+]], i8** [[P2]]
+// CK29-DAG: [[CBPVAL2]] = bitcast double*** [[VAR1]] to i8*
+// CK29-DAG: [[CPVAL2]] = bitcast double** [[VAR2:%.+]] to i8*
+// CK29-DAG: [[VAR2]] = load double**, double*** 

[libclc] r276704 - Make min follow the OCL 1.0 specs

2016-07-25 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Mon Jul 25 17:36:22 2016
New Revision: 276704

URL: http://llvm.org/viewvc/llvm-project?rev=276704=rev
Log:
Make min follow the OCL 1.0 specs

OpenCL 1.0: "Returns y if y < x, otherwise it returns x. If x *and* y
are infinite or NaN, the return values are undefined."

OpenCL 1.1+: "Returns y if y < x, otherwise it returns x. If x *or* y
are infinite or NaN, the return values are undefined."

The 1.0 version is stricter so use that one.

Signed-off-by: Jan Vesely 

Modified:
libclc/trunk/generic/lib/shared/min.inc

Modified: libclc/trunk/generic/lib/shared/min.inc
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/lib/shared/min.inc?rev=276704=276703=276704=diff
==
--- libclc/trunk/generic/lib/shared/min.inc (original)
+++ libclc/trunk/generic/lib/shared/min.inc Mon Jul 25 17:36:22 2016
@@ -1,9 +1,9 @@
 _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a, __CLC_GENTYPE b) {
-  return (a < b ? a : b);
+  return (b < a ? b : a);
 }
 
 #ifndef __CLC_SCALAR
 _CLC_OVERLOAD _CLC_DEF __CLC_GENTYPE min(__CLC_GENTYPE a, __CLC_SCALAR_GENTYPE 
b) {
-  return (a < (__CLC_GENTYPE)b ? a : (__CLC_GENTYPE)b);
+  return (b < (__CLC_GENTYPE)a ? (__CLC_GENTYPE)b : a);
 }
 #endif


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


[PATCH] D22785: [OpenMP] diagnose orphaned teams construct

2016-07-25 Thread Kelvin Li via cfe-commits
kkwli0 created this revision.
kkwli0 added reviewers: ABataev, sfantao, carlo.bertolli, arpith-jacob, hfinkel.
kkwli0 added a subscriber: cfe-commits.

The spec mandates that 'a teams construct must be contained within a target 
construct'.  Currently, this scenario is not diagnosed.  This patch is to add 
check for orphaned teams construct and issue an error message.

https://reviews.llvm.org/D22785

Files:
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaOpenMP.cpp
  test/OpenMP/nesting_of_regions.cpp

Index: test/OpenMP/nesting_of_regions.cpp
===
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -3693,6 +3693,8 @@
   }
 
 // TEAMS DIRECTIVE
+#pragma omp teams // expected-error {{orphaned 'omp teams' directives are 
prohibited; perhaps you forget to enclose the directive into a target region?}}
+  bar();
 #pragma omp target
 #pragma omp teams
 #pragma omp parallel
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -3172,6 +3172,7 @@
 auto OffendingRegion = ParentRegion;
 bool NestingProhibited = false;
 bool CloseNesting = true;
+bool OrphanSeen = false; 
 enum {
   NoRecommend,
   ShouldBeInParallelRegion,
@@ -3213,9 +3214,10 @@
   }
   return false;
 }
-// Allow some constructs to be orphaned (they could be used in functions,
-// called from OpenMP regions with the required preconditions).
-if (ParentRegion == OMPD_unknown)
+// Allow some constructs (except teams) to be orphaned (they could be
+// used in functions, called from OpenMP regions with the required 
+// preconditions).
+if (ParentRegion == OMPD_unknown && !isOpenMPTeamsDirective(CurrentRegion))
   return false;
 if (CurrentRegion == OMPD_cancellation_point ||
 CurrentRegion == OMPD_cancel) {
@@ -3315,6 +3317,7 @@
   // If specified, a teams construct must be contained within a target
   // construct.
   NestingProhibited = ParentRegion != OMPD_target;
+  OrphanSeen = ParentRegion == OMPD_unknown;
   Recommend = ShouldBeInTargetRegion;
   Stack->setParentTeamsRegionLoc(Stack->getConstructLoc());
 }
@@ -3354,9 +3357,13 @@
   CloseNesting = false;
 }
 if (NestingProhibited) {
-  SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
-  << CloseNesting << getOpenMPDirectiveName(OffendingRegion)
-  << Recommend << getOpenMPDirectiveName(CurrentRegion);
+  if (OrphanSeen)
+SemaRef.Diag(StartLoc, diag::err_omp_orphaned_device_directive)
+<< getOpenMPDirectiveName(CurrentRegion) << Recommend;
+  else
+SemaRef.Diag(StartLoc, diag::err_omp_prohibited_region)
+<< CloseNesting << getOpenMPDirectiveName(OffendingRegion)
+<< Recommend << getOpenMPDirectiveName(CurrentRegion);
   return true;
 }
   }
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8389,6 +8389,9 @@
 def warn_omp_nesting_simd : Warning<
   "OpenMP only allows an ordered construct with the simd clause nested in a 
simd construct">,
   InGroup;
+def err_omp_orphaned_device_directive : Error<
+  "orphaned 'omp %0' directives are prohibited"
+  "; perhaps you forget to enclose the directive into a %select{|||target 
|teams }1region?">;
 } // end of OpenMP category
 
 let CategoryName = "Related Result Type Issue" in {


Index: test/OpenMP/nesting_of_regions.cpp
===
--- test/OpenMP/nesting_of_regions.cpp
+++ test/OpenMP/nesting_of_regions.cpp
@@ -3693,6 +3693,8 @@
   }
 
 // TEAMS DIRECTIVE
+#pragma omp teams // expected-error {{orphaned 'omp teams' directives are prohibited; perhaps you forget to enclose the directive into a target region?}}
+  bar();
 #pragma omp target
 #pragma omp teams
 #pragma omp parallel
Index: lib/Sema/SemaOpenMP.cpp
===
--- lib/Sema/SemaOpenMP.cpp
+++ lib/Sema/SemaOpenMP.cpp
@@ -3172,6 +3172,7 @@
 auto OffendingRegion = ParentRegion;
 bool NestingProhibited = false;
 bool CloseNesting = true;
+bool OrphanSeen = false; 
 enum {
   NoRecommend,
   ShouldBeInParallelRegion,
@@ -3213,9 +3214,10 @@
   }
   return false;
 }
-// Allow some constructs to be orphaned (they could be used in functions,
-// called from OpenMP regions with the required preconditions).
-if (ParentRegion == OMPD_unknown)
+// Allow some constructs (except teams) to be orphaned (they could be
+// used in functions, called from OpenMP regions with the required 
+// preconditions).
+if (ParentRegion == OMPD_unknown && 

Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-25 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In https://reviews.llvm.org/D22725#495329, @etienneb wrote:

> In https://reviews.llvm.org/D22725#494167, @Prazek wrote:
>
> > hmm It seems that I mislead you, I suck at C api - memmove source and 
> > destination can overlap, but std::move can't. So I guess you have to remove 
> > the memmove support. Sorry.
>
>
> On windows (MSVC CRT), both function are the same : memmove.


It is possible that the call to move with some trivialy copyable object would 
end up calling memmove, even if the call is wrong.

quote from http://en.cppreference.com/w/cpp/algorithm/move

> d_first   -   the beginning of the destination range. If d_first is 
> within [first, last), std::move_backward must be used instead of std::move.


But this is only the special ability of memmove, so we should not introduce 
stl-implementation dependent bugs


https://reviews.llvm.org/D22725



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


Re: [PATCH] D22782: Added 'inline' attribute to __init to inline the basic_string's constructor

2016-07-25 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Do we have a test for the problem that this is solving?


https://reviews.llvm.org/D22782



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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren added a comment.

In https://reviews.llvm.org/D22773#495403, @benlangmuir wrote:

> We need to add this option to the module hash (see getModuleHash - we already 
> add a bunch of other HSOpts there).  Otherwise the pcm could still be 
> rewritten by a compilation that doesn't use a PCH, and then it would be out 
> of date because of the timestamp instead of the diagnostic options.


I was thinking that for a project using PCH+Module, all clang invocations will 
be using -fmodules-disable-diagnostic-validation, so if only the diagnostic 
options change, they will hash to the same pcm file but the compiler will not 
regenerate and overwrite the existing pcm file. So when we load the pch, the 
time stamp etc will match and the compiler will not throw out-of-date error.

We can definitely hash the option HSOpts.ModulesValidateDiagnosticOptions in 
getModuleHash. But I don't quite get the reason you give here :)
the pcm could still be rewritten by a compilation that doesn't use a PCH, and 
then it would be out of date because of the timestamp instead of the diagnostic 
options

"a compilation that doesn't use a PCH", is that a different project? And we 
have two projects building in parallel? Just to make sure I understand.

Thanks!
Manman


https://reviews.llvm.org/D22773



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


r276696 - [Sema][ObjC] Compute the nullability of a conditional expression based

2016-07-25 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Jul 25 16:58:19 2016
New Revision: 276696

URL: http://llvm.org/viewvc/llvm-project?rev=276696=rev
Log:
[Sema][ObjC] Compute the nullability of a conditional expression based
on the nullabilities of its operands.

This commit is a follow-up to r276076 and enables
computeConditionalNullability to compute the merged nullability when
the operands are objective-c pointers.

rdar://problem/22074116

Modified:
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/SemaObjC/nullability.m

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=276696=276695=276696=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Mon Jul 25 16:58:19 2016
@@ -7016,7 +7016,7 @@ static void DiagnoseConditionalPrecedenc
 static QualType computeConditionalNullability(QualType ResTy, bool IsBin,
   QualType LHSTy, QualType RHSTy,
   ASTContext ) {
-  if (!ResTy->isPointerType())
+  if (!ResTy->isAnyPointerType())
 return ResTy;
 
   auto GetNullability = [](QualType Ty) {

Modified: cfe/trunk/test/SemaObjC/nullability.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaObjC/nullability.m?rev=276696=276695=276696=diff
==
--- cfe/trunk/test/SemaObjC/nullability.m (original)
+++ cfe/trunk/test/SemaObjC/nullability.m Mon Jul 25 16:58:19 2016
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -fsyntax-only -fblocks -Woverriding-method-mismatch 
-Wno-nullability-declspec %s -verify
+// RUN: %clang_cc1 -fsyntax-only -fblocks -Woverriding-method-mismatch 
-Wno-nullability-declspec -Wnullable-to-nonnull-conversion %s -verify
 
 __attribute__((objc_root_class))
 @interface NSFoo
@@ -230,3 +230,29 @@ void testBlockLiterals() {
 
   int *x = (^ _Nullable id(void) { return 0; })(); // 
expected-warning{{incompatible pointer types initializing 'int *' with an 
expression of type 'id _Nullable'}}
 }
+
+// Check nullability of conditional expressions.
+void conditional_expr(int c) {
+  NSFoo * _Nonnull p;
+  NSFoo * _Nonnull nonnullP;
+  NSFoo * _Nullable nullableP;
+  NSFoo * _Null_unspecified unspecifiedP;
+  NSFoo *noneP;
+
+  p = c ? nonnullP : nonnullP;
+  p = c ? nonnullP : nullableP; // expected-warning{{implicit conversion from 
nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * 
_Nonnull'}}
+  p = c ? nonnullP : unspecifiedP;
+  p = c ? nonnullP : noneP;
+  p = c ? nullableP : nonnullP; // expected-warning{{implicit conversion from 
nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * 
_Nonnull'}}
+  p = c ? nullableP : nullableP; // expected-warning{{implicit conversion from 
nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * 
_Nonnull'}}
+  p = c ? nullableP : unspecifiedP; // expected-warning{{implicit conversion 
from nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * 
_Nonnull'}}
+  p = c ? nullableP : noneP; // expected-warning{{implicit conversion from 
nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * 
_Nonnull'}}
+  p = c ? unspecifiedP : nonnullP;
+  p = c ? unspecifiedP : nullableP; // expected-warning{{implicit conversion 
from nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * 
_Nonnull'}}
+  p = c ? unspecifiedP : unspecifiedP;
+  p = c ? unspecifiedP : noneP;
+  p = c ? noneP : nonnullP;
+  p = c ? noneP : nullableP; // expected-warning{{implicit conversion from 
nullable pointer 'NSFoo * _Nullable' to non-nullable pointer type 'NSFoo * 
_Nonnull'}}
+  p = c ? noneP : unspecifiedP;
+  p = c ? noneP : noneP;
+}


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


Re: [PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Ben Langmuir via cfe-commits
benlangmuir added a comment.

We need to add this option to the module hash (see getModuleHash - we already 
add a bunch of other HSOpts there).  Otherwise the pcm could still be rewritten 
by a compilation that doesn't use a PCH, and then it would be out of date 
because of the timestamp instead of the diagnostic options.


https://reviews.llvm.org/D22773



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


Re: [PATCH] D22697: [ObjC Availability] Consider lexical context of use of declaration when emitting availability diagnostics

2016-07-25 Thread Manman Ren via cfe-commits
manmanren accepted this revision.
manmanren added a comment.
This revision is now accepted and ready to land.

LGTM except one nit.

Manman



Comment at: include/clang/Sema/Sema.h:9595
@@ -9594,1 +9594,3 @@
+
+  VersionTuple getCurContextVersion() const;
   

Can you add comments here?


https://reviews.llvm.org/D22697



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


Re: [PATCH] D22513: [clang-tidy] add check cppcoreguidelines-rule-of-five-and-zero

2016-07-25 Thread Jonathan B Coe via cfe-commits
jbcoe marked an inline comment as done.
jbcoe added a comment.

https://reviews.llvm.org/D22513



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


Re: [PATCH] D22513: [clang-tidy] add check cppcoreguidelines-rule-of-five-and-zero

2016-07-25 Thread Jonathan B Coe via cfe-commits
jbcoe removed rL LLVM as the repository for this revision.
jbcoe updated this revision to Diff 65423.
jbcoe added a comment.

Fix underline length in docs.


https://reviews.llvm.org/D22513

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
  test/clang-tidy/cppcoreguidelines-special-member-functions.cpp

Index: test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t
+
+class DefinesDestructor {
+  ~DefinesDestructor();
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyConstructor {
+  DefinesCopyConstructor(const DefinesCopyConstructor &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyConstructor' defines a copy constructor but does not define a destructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyAssignment {
+  DefinesCopyAssignment =(const DefinesCopyAssignment &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyAssignment' defines a copy assignment operator but does not define a destructor, a copy constructor, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesMoveConstructor {
+  DefinesMoveConstructor(DefinesMoveConstructor &&);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesMoveConstructor' defines a move constructor but does not define a destructor, a copy constructor, a copy assignment operator or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesMoveAssignment {
+  DefinesMoveAssignment =(DefinesMoveAssignment &&);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesMoveAssignment' defines a move assignment operator but does not define a destructor, a copy constructor, a copy assignment operator or a move constructor [cppcoreguidelines-special-member-functions]
+class DefinesNothing {
+};
+
+class DefinesEverything {
+  DefinesEverything(const DefinesEverything &);
+  DefinesEverything =(const DefinesEverything &);
+  DefinesEverything(DefinesEverything &&);
+  DefinesEverything =(DefinesEverything &&);
+  ~DefinesEverything();
+};
+
+class DeletesEverything {
+  DeletesEverything(const DeletesEverything &) = delete;
+  DeletesEverything =(const DeletesEverything &) = delete;
+  DeletesEverything(DeletesEverything &&) = delete;
+  DeletesEverything =(DeletesEverything &&) = delete;
+  ~DeletesEverything() = delete;
+};
+
+class DeletesCopyDefaultsMove {
+  DeletesCopyDefaultsMove(const DeletesCopyDefaultsMove &) = delete;
+  DeletesCopyDefaultsMove =(const DeletesCopyDefaultsMove &) = delete;
+  DeletesCopyDefaultsMove(DeletesCopyDefaultsMove &&) = default;
+  DeletesCopyDefaultsMove =(DeletesCopyDefaultsMove &&) = default;
+  ~DeletesCopyDefaultsMove() = default;
+};
Index: test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
@@ -0,0 +1,26 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t -- -- -std=c++03
+
+class DefinesDestructor {
+  ~DefinesDestructor();
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyConstructor {
+  DefinesCopyConstructor(const DefinesCopyConstructor &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyConstructor' defines a copy constructor but does not define a destructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyAssignment {
+  DefinesCopyAssignment =(const DefinesCopyAssignment &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyAssignment' defines a copy assignment operator but does not define a destructor or a copy constructor [cppcoreguidelines-special-member-functions]
+
+class DefinesNothing {
+};
+
+class DefinesEverything {
+  DefinesEverything(const DefinesEverything &);
+  

Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-25 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:73
@@ +72,3 @@
+  Finder->addMatcher(
+  callExpr(allOf(callee(functionDecl(matchesName("::memcpy"))),
+ argumentCountIs(3)))

It's more efficient to use  hasAnyName and merge the three following 
matcher.
That way, you won't need the function 'getCallExpr' to retrieve the CallExpr.


Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:80
@@ +79,3 @@
+  Finder->addMatcher(
+  callExpr(allOf(callee(functionDecl(matchesName("::memmove"))),
+ argumentCountIs(3)))

allOf is not needed.


Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:106
@@ +105,3 @@
+  const auto *MatchedExpr = getCallExpr(Result);
+  const auto MatchedName = MatchedExpr->getDirectCallee()->getNameAsString();
+  const auto ReplacedName = Replacements[MatchedName];

Instead of DirectCallee, you could add a "bind" to the Matcher : 
functionDecl(...).bind("callee")


Comment at: clang-tidy/modernize/UseAlgorithmCheck.cpp:107
@@ +106,3 @@
+  const auto MatchedName = MatchedExpr->getDirectCallee()->getNameAsString();
+  const auto ReplacedName = Replacements[MatchedName];
+

What is the name is not in the map?


https://reviews.llvm.org/D22725



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


Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-25 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:20
@@ +19,3 @@
+
+static void ReplaceMoveWithForward(const UnresolvedLookupExpr *Callee,
+   const TemplateTypeParmType *TypeParmType,

aaron.ballman wrote:
> Might as well pass `Context` by const reference rather than pointer.
Function names start in lower case.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:30
@@ +29,3 @@
+  Callee->getLocStart(),
+  Lexer::getLocForEndOfToken(Callee->getLocEnd(), 0, SM, LangOpts)),
+  SM, LangOpts);

Isn't this just 
`CharSourceRange::getTokenRange(Callee->getLocStart(),Callee->getLocEnd())` ?


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:83
@@ +82,3 @@
+  // same function...
+  references(templateTypeParmType(hasDeclaration(hasDeclContext(
+  functionDecl().bind("context"

Will this trigger on code like this:


```
template 
void F(T);

void G() { F(std::move(str)); }
```


https://reviews.llvm.org/D0



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


Re: [PATCH] D22725: [clang-tidy] Add check 'misc-replace-memcpy'

2016-07-25 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In https://reviews.llvm.org/D22725#494167, @Prazek wrote:

> hmm It seems that I mislead you, I suck at C api - memmove source and 
> destination can overlap, but std::move can't. So I guess you have to remove 
> the memmove support. Sorry.


On windows (MSVC CRT), both function are the same : memmove.


https://reviews.llvm.org/D22725



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


Re: r276473 - [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.

2016-07-25 Thread Vassil Vassilev via cfe-commits

It could, it fixes a set of issues wrt to modules.
On 25/07/16 22:39, Hans Wennborg wrote:

Should this be merged to 3.9?

On Fri, Jul 22, 2016 at 2:08 PM, Vassil Vassilev via cfe-commits
 wrote:

Author: vvassilev
Date: Fri Jul 22 16:08:24 2016
New Revision: 276473

URL: http://llvm.org/viewvc/llvm-project?rev=276473=rev
Log:
[modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.

Processing update records (and loading a module, in general) might trigger
unexpected calls to the ASTWriter (being a mutation listener). Now we have a
mechanism to suppress those calls to the ASTWriter but notify other possible
mutation listeners.

Fixes https://llvm.org/bugs/show_bug.cgi?id=28332

Patch by Cristina Cristescu and me.

Reviewed by Richard Smith (D21800).

Added:
 cfe/trunk/test/Modules/Inputs/PR28332/
 cfe/trunk/test/Modules/Inputs/PR28332/TextualInclude.h
 cfe/trunk/test/Modules/Inputs/PR28332/a.h
 cfe/trunk/test/Modules/Inputs/PR28332/b.h
 cfe/trunk/test/Modules/Inputs/PR28332/c.h
 cfe/trunk/test/Modules/Inputs/PR28332/module.modulemap
 cfe/trunk/test/Modules/pr28332.cpp
Modified:
 cfe/trunk/include/clang/Serialization/ASTReader.h
 cfe/trunk/lib/Serialization/ASTReader.cpp
 cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
 cfe/trunk/lib/Serialization/ASTWriter.cpp



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


Re: [PATCH] D22663: Support setting default value for -rtlib at build time

2016-07-25 Thread Chris Bieneman via cfe-commits
beanz added a subscriber: beanz.
beanz added a comment.

One small comment on the CMake code.



Comment at: CMakeLists.txt:210
@@ +209,3 @@
+  message(WARNING "Resetting default rtlib to use platform default")
+  set(CLANG_DEFAULT_RTLIB "")
+endif()

You'll want this to be:


```
set(CLANG_DEFAULT_RTLIB "" CACHE STRING "Default runtime library to use (libgcc 
or compiler-rt)" FORCE)
```

Cached variables can only be overwritten by a `FORCE`.


https://reviews.llvm.org/D22663



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


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-25 Thread Vlad Dovlekaev via cfe-commits
vladisld added a comment.

In https://reviews.llvm.org/D22463#495211, @vladisld wrote:

> + you get a good integration with Gerrit enabled services like Gerrithub 
> (http://gerrithub.io/) and other CI systems (like Jenkins for example)


BTW, Buildbot is also supporting git-repo: 
http://docs.buildbot.net/latest/manual/cfg-buildsteps.html#repo


https://reviews.llvm.org/D22463



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


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-25 Thread Vlad Dovlekaev via cfe-commits
vladisld added a comment.

In https://reviews.llvm.org/D22463#494828, @jlebar wrote:

> I think the general feeling is that most of us (myself included) would rather 
> not learn a new tool if there's a simpler >alternative, such as a vanilla git 
> workflow.


Generally you're right, however learning how to use git-repo is much simpler 
than managing the intricacies of git sub-modules (and Google's experience with 
Android is a clear example of it). This is IMHO of cause.

+ you get a good integration with Gerrit enabled services like Gerrithub 
(http://gerrithub.io/) and other CI systems (like Jenkins for example)

I'll try to bring this topic back in llvm-dev - thanks for suggestion.


https://reviews.llvm.org/D22463



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


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-25 Thread Justin Lebar via cfe-commits
jlebar added a comment.

In https://reviews.llvm.org/D22463#495211, @vladisld wrote:

> In https://reviews.llvm.org/D22463#494828, @jlebar wrote:
>
> > I think the general feeling is that most of us (myself included) would 
> > rather not learn a new tool if there's a simpler >alternative, such as a 
> > vanilla git workflow.
>
>
> Generally you're right, however learning how to use git-repo is much simpler 
> than managing the intricacies of git sub-modules (and Google's experience 
> with Android is a clear example of it). This is IMHO of cause.


Just to be clear, since it sounds like you haven't been following the llvm-dev 
discussion -- the alternative to git-repo is *not* submodules.  I agree that 
submodules are awful.  The alternative is a monolithic repository (monorepo) 
that contains, as a single git repository, the full history of all llvm 
subprojects.  Similar to https://github.com/llvm-project/llvm-project.


https://reviews.llvm.org/D22463



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-25 Thread Matt via cfe-commits
mmasten added a comment.

I was just recently given commit privileges, so I can do it. Thanks Hal.


https://reviews.llvm.org/D19544



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


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-25 Thread Miklos Vajna via cfe-commits
vmiklos added a comment.

Rebased on top of r276684 and resolved conflicts.


https://reviews.llvm.org/D21814



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


Re: [PATCH] D21814: clang-rename: split existing options into two new subcommands

2016-07-25 Thread Miklos Vajna via cfe-commits
vmiklos updated this revision to Diff 65417.

https://reviews.llvm.org/D21814

Files:
  clang-rename/RenamingAction.cpp
  clang-rename/RenamingAction.h
  clang-rename/tool/ClangRename.cpp
  clang-rename/tool/clang-rename.py
  docs/clang-rename.rst
  test/clang-rename/ClassFindByName.cpp
  test/clang-rename/ClassTestMulti.cpp
  test/clang-rename/ClassTestMultiByName.cpp
  test/clang-rename/NoNewName.cpp

Index: test/clang-rename/NoNewName.cpp
===
--- test/clang-rename/NoNewName.cpp
+++ test/clang-rename/NoNewName.cpp
@@ -1,4 +1,4 @@
 // Check for an error while -new-name argument has not been passed to
 // clang-rename.
 // RUN: not clang-rename -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: no new name provided.
+// CHECK: clang-rename: for the -new-name option: must be specified
Index: test/clang-rename/ClassTestMultiByName.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMultiByName.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -old-name=Cla1 -new-name=Kla1 -old-name=Cla2 -new-name=Kla2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassTestMulti.cpp
===
--- /dev/null
+++ test/clang-rename/ClassTestMulti.cpp
@@ -0,0 +1,8 @@
+// RUN: cat %s > %t.cpp
+// RUN: clang-rename rename-all -offset=174 -new-name=Kla1 -offset=212 -new-name=Kla2 %t.cpp -i --
+// RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
+class Cla1 { // CHECK: class Kla1
+};
+
+class Cla2 { // CHECK: class Kla2
+};
Index: test/clang-rename/ClassFindByName.cpp
===
--- test/clang-rename/ClassFindByName.cpp
+++ test/clang-rename/ClassFindByName.cpp
@@ -1,5 +1,5 @@
 // RUN: cat %s > %t.cpp
-// RUN: clang-rename -old-name=Foo -new-name=Bar %t.cpp -i --
+// RUN: clang-rename rename-all -old-name=Foo -new-name=Bar %t.cpp -i --
 // RUN: sed 's,//.*,,' %t.cpp | FileCheck %s
 
 class Foo { // CHECK: class Bar
Index: docs/clang-rename.rst
===
--- docs/clang-rename.rst
+++ docs/clang-rename.rst
@@ -32,7 +32,7 @@
 
 .. code-block:: console
 
-  $ clang-rename -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
+  $ clang-rename rename-at -offset=42 -new-name=foo test.cpp -- -Imy_project/include -DMY_DEFINES ...
 
 
 To get an offset of a symbol in a file run
@@ -42,6 +42,14 @@
   $ grep -FUbo 'foo' file.cpp
 
 
+You can also identify one or more symbols to be renamed by giving the fully qualified
+name:
+
+.. code-block:: console
+
+  $ clang-rename rename-all -old-name=foo -new-name=bar test.cpp
+
+
 The tool currently supports renaming actions inside a single Translation Unit
 only. It is planned to extend the tool's functionality to support multi-TU
 renaming actions in the future.
@@ -55,34 +63,73 @@
 .. code-block:: console
 
   $ clang-rename -help
+  Usage: clang-rename {rename-at|rename-all} [OPTION]...
+
+  A tool to rename symbols in C/C++ code.
+
+  Subcommands:
+rename-at:  Perform rename off of a location in a file.
+rename-all: Perform rename of all symbols matching one or more fully qualified names.
+
+
+.. code-block:: console
+
+  $ clang-rename rename-at -help
   OVERVIEW: A tool to rename symbols in C/C++ code.
   clang-rename renames every occurrence of a symbol found at  in
   . If -i is specified, the edited files are overwritten to disk.
   Otherwise, the results are written to stdout.
-
-  USAGE: clang-rename [subcommand] [options]  [... ]
-
+  
+  USAGE: clang-rename rename-at [subcommand] [options]  [... ]
+  
   OPTIONS:
+  
+  Generic Options:
+  
+-help  - Display available options (-help-hidden for more)
+-help-list - Display list of available options (-help-list-hidden for more)
+-version   - Display the version of this program
 
-  Clang-rename options:
+  clang-rename rename-at options:
 
 -export-fixes=   - YAML file to store suggested fixes in.
 -extra-arg=- Additional argument to append to the compiler command line
 -extra-arg-before= - Additional argument to prepend to the compiler command line
 -i - Overwrite edited s.
 -new-name= - The new name to change the symbol to.
 -offset= - Locates the symbol by offset as opposed to :.
--old-name= - The fully qualified name of the symbol, if -offset is not used.
 -p=- Build path
 -pl- Print the locations affected by renaming to stderr.
 -pn- Print the found symbol's name prior to renaming to stderr.
 
+
+.. code-block:: console
+
+  $ 

Re: [PATCH] D22513: [clang-tidy] add check cppcoreguidelines-rule-of-five-and-zero

2016-07-25 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko added inline comments.


Comment at: 
docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst:4
@@ +3,3 @@
+cppcoreguidelines-special-member-functions
+===
+

Size should be same as size of name above.


Repository:
  rL LLVM

https://reviews.llvm.org/D22513



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


Re: r276653 - Support '#pragma once' in headers when using PCH

2016-07-25 Thread Hans Wennborg via cfe-commits
Should me merge this to 3.9?

On Mon, Jul 25, 2016 at 10:17 AM, Sunil Srivastava via cfe-commits
 wrote:
> Author: ssrivastava
> Date: Mon Jul 25 12:17:06 2016
> New Revision: 276653
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276653=rev
> Log:
> Support '#pragma once' in headers when using PCH
>
> The '#pragma once' directive was erroneously ignored when encountered
> in the header-file specified in generate-PCH-mode. This resulted in
> compile-time errors in some cases with legal code, and also a misleading
> warning being produced.
>
> Patch by Warren Ristow!
>
> Differential Revision: http://reviews.llvm.org/D19815
>
> Added:
> cfe/trunk/test/PCH/Inputs/pragma-once.h
> cfe/trunk/test/PCH/pragma-once.c
> Modified:
> cfe/trunk/lib/Lex/Pragma.cpp
>
> Modified: cfe/trunk/lib/Lex/Pragma.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=276653=276652=276653=diff
> ==
> --- cfe/trunk/lib/Lex/Pragma.cpp (original)
> +++ cfe/trunk/lib/Lex/Pragma.cpp Mon Jul 25 12:17:06 2016
> @@ -352,7 +352,9 @@ void Preprocessor::HandleMicrosoft__prag
>  /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
>  ///
>  void Preprocessor::HandlePragmaOnce(Token ) {
> -  if (isInPrimaryFile()) {
> +  // Don't honor the 'once' when handling the primary source file, unless
> +  // this is a prefix to a TU, which indicates we're generating a PCH file.
> +  if (isInPrimaryFile() && TUKind != TU_Prefix) {
>  Diag(OnceTok, diag::pp_pragma_once_in_main_file);
>  return;
>}
>
> Added: cfe/trunk/test/PCH/Inputs/pragma-once.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pragma-once.h?rev=276653=auto
> ==
> --- cfe/trunk/test/PCH/Inputs/pragma-once.h (added)
> +++ cfe/trunk/test/PCH/Inputs/pragma-once.h Mon Jul 25 12:17:06 2016
> @@ -0,0 +1,5 @@
> +#pragma once
> +
> +/* For use with the pragma-once.c test */
> +
> +int x = 3;
>
> Added: cfe/trunk/test/PCH/pragma-once.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pragma-once.c?rev=276653=auto
> ==
> --- cfe/trunk/test/PCH/pragma-once.c (added)
> +++ cfe/trunk/test/PCH/pragma-once.c Mon Jul 25 12:17:06 2016
> @@ -0,0 +1,13 @@
> +// Test this without pch.
> +// RUN: %clang_cc1 -include %S/Inputs/pragma-once.h -fsyntax-only -verify %s
> +
> +// Test with pch.
> +// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/pragma-once.h
> +// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
> +
> +// expected-no-diagnostics
> +
> +// Including "pragma-once.h" twice, to verify the 'once' aspect is honored.
> +#include "Inputs/pragma-once.h"
> +#include "Inputs/pragma-once.h"
> +int foo(void) { return 0; }
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22513: [clang-tidy] add check cppcoreguidelines-rule-of-five-and-zero

2016-07-25 Thread Jonathan B Coe via cfe-commits
jbcoe set the repository for this revision to rL LLVM.
jbcoe updated this revision to Diff 65414.
jbcoe marked an inline comment as done.
jbcoe added a comment.

Rename to cppcoreguidelines-special-member-functions to avoid the duplication 
required with naming it rule-of-3 and rule-of-5.

Reduce code duplication by iterating over a list of matchers.

Use dense map. [FIXME: I can't get DenseMap to work with the DenseMapInfo 
defined in the header. IdentifierNamingCheck.cpp does this without any issues 
but I hit compiler errors around DenseMap and SourceLocation. Moving the 
specialisation from the header to the source of SpecialMemberFunctionsCheck 
suffices to repeat the problem. Any input here would be appreciated.]


Repository:
  rL LLVM

https://reviews.llvm.org/D22513

Files:
  clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
  clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
  test/clang-tidy/cppcoreguidelines-special-member-functions.cpp

Index: test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
@@ -0,0 +1,52 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t
+
+class DefinesDestructor {
+  ~DefinesDestructor();
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyConstructor {
+  DefinesCopyConstructor(const DefinesCopyConstructor &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyConstructor' defines a copy constructor but does not define a destructor, a copy assignment operator, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyAssignment {
+  DefinesCopyAssignment =(const DefinesCopyAssignment &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesCopyAssignment' defines a copy assignment operator but does not define a destructor, a copy constructor, a move constructor or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesMoveConstructor {
+  DefinesMoveConstructor(DefinesMoveConstructor &&);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesMoveConstructor' defines a move constructor but does not define a destructor, a copy constructor, a copy assignment operator or a move assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesMoveAssignment {
+  DefinesMoveAssignment =(DefinesMoveAssignment &&);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesMoveAssignment' defines a move assignment operator but does not define a destructor, a copy constructor, a copy assignment operator or a move constructor [cppcoreguidelines-special-member-functions]
+class DefinesNothing {
+};
+
+class DefinesEverything {
+  DefinesEverything(const DefinesEverything &);
+  DefinesEverything =(const DefinesEverything &);
+  DefinesEverything(DefinesEverything &&);
+  DefinesEverything =(DefinesEverything &&);
+  ~DefinesEverything();
+};
+
+class DeletesEverything {
+  DeletesEverything(const DeletesEverything &) = delete;
+  DeletesEverything =(const DeletesEverything &) = delete;
+  DeletesEverything(DeletesEverything &&) = delete;
+  DeletesEverything =(DeletesEverything &&) = delete;
+  ~DeletesEverything() = delete;
+};
+
+class DeletesCopyDefaultsMove {
+  DeletesCopyDefaultsMove(const DeletesCopyDefaultsMove &) = delete;
+  DeletesCopyDefaultsMove =(const DeletesCopyDefaultsMove &) = delete;
+  DeletesCopyDefaultsMove(DeletesCopyDefaultsMove &&) = default;
+  DeletesCopyDefaultsMove =(DeletesCopyDefaultsMove &&) = default;
+  ~DeletesCopyDefaultsMove() = default;
+};
Index: test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
===
--- /dev/null
+++ test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp
@@ -0,0 +1,26 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-special-member-functions %t -- -- -std=c++03
+
+class DefinesDestructor {
+  ~DefinesDestructor();
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: class 'DefinesDestructor' defines a destructor but does not define a copy constructor or a copy assignment operator [cppcoreguidelines-special-member-functions]
+
+class DefinesCopyConstructor {
+  DefinesCopyConstructor(const DefinesCopyConstructor &);
+};
+// CHECK-MESSAGES: [[@LINE-3]]:7: warning: 

Re: r276473 - [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.

2016-07-25 Thread Hans Wennborg via cfe-commits
Should this be merged to 3.9?

On Fri, Jul 22, 2016 at 2:08 PM, Vassil Vassilev via cfe-commits
 wrote:
> Author: vvassilev
> Date: Fri Jul 22 16:08:24 2016
> New Revision: 276473
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276473=rev
> Log:
> [modules] Teach the ASTWriter to ignore mutations coming from the ASTReader.
>
> Processing update records (and loading a module, in general) might trigger
> unexpected calls to the ASTWriter (being a mutation listener). Now we have a
> mechanism to suppress those calls to the ASTWriter but notify other possible
> mutation listeners.
>
> Fixes https://llvm.org/bugs/show_bug.cgi?id=28332
>
> Patch by Cristina Cristescu and me.
>
> Reviewed by Richard Smith (D21800).
>
> Added:
> cfe/trunk/test/Modules/Inputs/PR28332/
> cfe/trunk/test/Modules/Inputs/PR28332/TextualInclude.h
> cfe/trunk/test/Modules/Inputs/PR28332/a.h
> cfe/trunk/test/Modules/Inputs/PR28332/b.h
> cfe/trunk/test/Modules/Inputs/PR28332/c.h
> cfe/trunk/test/Modules/Inputs/PR28332/module.modulemap
> cfe/trunk/test/Modules/pr28332.cpp
> Modified:
> cfe/trunk/include/clang/Serialization/ASTReader.h
> cfe/trunk/lib/Serialization/ASTReader.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r276684 - [Clang-rename] Remove custom version, fix extra space in error message.

2016-07-25 Thread Eugene Zelenko via cfe-commits
Author: eugenezelenko
Date: Mon Jul 25 15:30:13 2016
New Revision: 276684

URL: http://llvm.org/viewvc/llvm-project?rev=276684=rev
Log:
[Clang-rename] Remove custom version, fix extra space in error message.

Also fixed some Include What You Use Warnings.

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

Modified:
clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp

Modified: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp?rev=276684=276683=276684=diff
==
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp (original)
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp Mon Jul 25 
15:30:13 2016
@@ -15,28 +15,27 @@
 
 #include "../USRFindingAction.h"
 #include "../RenamingAction.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Basic/TargetOptions.h"
-#include "clang/Frontend/CommandLineSourceLoc.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendAction.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Parse/ParseAST.h"
-#include "clang/Parse/Parser.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/Host.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/YAMLTraits.h"
+#include 
 #include 
+#include 
 
 using namespace llvm;
 
@@ -79,12 +78,6 @@ ExportFixes(
 cl::value_desc("filename"),
 cl::cat(ClangRenameCategory));
 
-#define CLANG_RENAME_VERSION "0.0.1"
-
-static void PrintVersion() {
-  outs() << "clang-rename version " << CLANG_RENAME_VERSION << '\n';
-}
-
 using namespace clang;
 
 const char RenameUsage[] = "A tool to rename symbols in C/C++ code.\n\
@@ -93,7 +86,6 @@ clang-rename renames every occurrence of
 Otherwise, the results are written to stdout.\n";
 
 int main(int argc, const char **argv) {
-  cl::SetVersionPrinter(PrintVersion);
   tooling::CommonOptionsParser OP(argc, argv, ClangRenameCategory, 
RenameUsage);
 
   // Check the arguments for correctness.
@@ -110,7 +102,7 @@ int main(int argc, const char **argv) {
   IdentifierTable Table(Options);
   auto NewNameTokKind = Table.get(NewName).getTokenID();
   if (!tok::isAnyIdentifier(NewNameTokKind)) {
-errs() << "ERROR: new name is not a valid identifier in  C++17.\n\n";
+errs() << "ERROR: new name is not a valid identifier in C++17.\n\n";
 exit(1);
   }
 

Modified: clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp?rev=276684=276683=276684=diff
==
--- clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp (original)
+++ clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp Mon Jul 25 
15:30:13 2016
@@ -1,2 +1,2 @@
 // RUN: not clang-rename -new-name=class -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: new name is not a valid identifier in  C++17.
+// CHECK: ERROR: new name is not a valid identifier in C++17.


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


Re: [PATCH] D22654: [Clang-rename] Remove custom version, fix extra space in error message

2016-07-25 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276684: [Clang-rename] Remove custom version, fix extra 
space in error message. (authored by eugenezelenko).

Changed prior to commit:
  https://reviews.llvm.org/D22654?vs=65379=65412#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22654

Files:
  clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
  clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp

Index: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
===
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
@@ -15,28 +15,27 @@
 
 #include "../USRFindingAction.h"
 #include "../RenamingAction.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Basic/TargetOptions.h"
-#include "clang/Frontend/CommandLineSourceLoc.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendAction.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Parse/ParseAST.h"
-#include "clang/Parse/Parser.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/Host.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/YAMLTraits.h"
+#include 
 #include 
+#include 
 
 using namespace llvm;
 
@@ -79,21 +78,14 @@
 cl::value_desc("filename"),
 cl::cat(ClangRenameCategory));
 
-#define CLANG_RENAME_VERSION "0.0.1"
-
-static void PrintVersion() {
-  outs() << "clang-rename version " << CLANG_RENAME_VERSION << '\n';
-}
-
 using namespace clang;
 
 const char RenameUsage[] = "A tool to rename symbols in C/C++ code.\n\
 clang-rename renames every occurrence of a symbol found at  in\n\
 . If -i is specified, the edited files are overwritten to disk.\n\
 Otherwise, the results are written to stdout.\n";
 
 int main(int argc, const char **argv) {
-  cl::SetVersionPrinter(PrintVersion);
   tooling::CommonOptionsParser OP(argc, argv, ClangRenameCategory, 
RenameUsage);
 
   // Check the arguments for correctness.
@@ -110,7 +102,7 @@
   IdentifierTable Table(Options);
   auto NewNameTokKind = Table.get(NewName).getTokenID();
   if (!tok::isAnyIdentifier(NewNameTokKind)) {
-errs() << "ERROR: new name is not a valid identifier in  C++17.\n\n";
+errs() << "ERROR: new name is not a valid identifier in C++17.\n\n";
 exit(1);
   }
 
Index: clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp
===
--- clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp
+++ clang-tools-extra/trunk/test/clang-rename/InvalidNewName.cpp
@@ -1,2 +1,2 @@
 // RUN: not clang-rename -new-name=class -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: new name is not a valid identifier in  C++17.
+// CHECK: ERROR: new name is not a valid identifier in C++17.


Index: clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
===
--- clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
+++ clang-tools-extra/trunk/clang-rename/tool/ClangRename.cpp
@@ -15,28 +15,27 @@
 
 #include "../USRFindingAction.h"
 #include "../RenamingAction.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Basic/TargetOptions.h"
-#include "clang/Frontend/CommandLineSourceLoc.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendAction.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Parse/ParseAST.h"
-#include "clang/Parse/Parser.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/Host.h"

[PATCH] D22774: [MSVC] Add ARM support to intrin.h for MSVC compatibility

2016-07-25 Thread Martin Storsjö via cfe-commits
mstorsjo created this revision.
mstorsjo added a subscriber: cfe-commits.
Herald added subscribers: samparker, rengolin, aemerson.

This fixes compiling with headers from the Windows SDK for ARM, where the 
YieldProcessor function (in winnt.h) refers to _ARM_BARRIER_ISHST.

The actual MSVC armintr.h contains a lot more definitions, but this is enough 
to build code that uses the Windows SDK but doesn't use  ARM intrinsics 
directly.

An alternative would to just keep the addition to intr.h (to include 
armintr.h), but not actually ship armintr.h, instead having clang's intrin.h 
include armintr.h from MSVC's include directory. (That one works fine with 
clang, at least for building code that uses the Windows SDK.)

https://reviews.llvm.org/D22774

Files:
  lib/Headers/CMakeLists.txt
  lib/Headers/armintr.h
  lib/Headers/intrin.h

Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -34,6 +34,10 @@
 #include 
 #endif
 
+#if defined(__arm__)
+#include 
+#endif
+
 /* For the definition of jmp_buf. */
 #if __STDC_HOSTED__
 #include 
Index: lib/Headers/armintr.h
===
--- /dev/null
+++ lib/Headers/armintr.h
@@ -0,0 +1,39 @@
+/*=== armintr.h - ARM intrinsics ---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to 
deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 
FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __ARMINTR_H
+#define __ARMINTR_H
+
+typedef enum
+{
+  _ARM_BARRIER_SY= 0xF,
+  _ARM_BARRIER_ST= 0xE,
+  _ARM_BARRIER_ISH   = 0xB,
+  _ARM_BARRIER_ISHST = 0xA,
+  _ARM_BARRIER_NSH   = 0x7,
+  _ARM_BARRIER_NSHST = 0x6,
+  _ARM_BARRIER_OSH   = 0x3,
+  _ARM_BARRIER_OSHST = 0x2
+} _ARMINTR_BARRIER_TYPE;
+
+#endif /* __ARMINTR_H */
Index: lib/Headers/CMakeLists.txt
===
--- lib/Headers/CMakeLists.txt
+++ lib/Headers/CMakeLists.txt
@@ -3,6 +3,7 @@
   altivec.h
   ammintrin.h
   arm_acle.h
+  armintr.h
   avx2intrin.h
   avx512bwintrin.h
   avx512cdintrin.h


Index: lib/Headers/intrin.h
===
--- lib/Headers/intrin.h
+++ lib/Headers/intrin.h
@@ -34,6 +34,10 @@
 #include 
 #endif
 
+#if defined(__arm__)
+#include 
+#endif
+
 /* For the definition of jmp_buf. */
 #if __STDC_HOSTED__
 #include 
Index: lib/Headers/armintr.h
===
--- /dev/null
+++ lib/Headers/armintr.h
@@ -0,0 +1,39 @@
+/*=== armintr.h - ARM intrinsics ---===
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ *
+ *===---===
+ */
+
+#ifndef __ARMINTR_H
+#define __ARMINTR_H
+
+typedef enum
+{
+  

RE: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for __final specifier

2016-07-25 Thread Keane, Erich via cfe-commits
Done!  Attached a new diff.

From: David Majnemer [mailto:david.majne...@gmail.com]
Sent: Monday, July 25, 2016 1:18 PM
To: Keane, Erich 
Cc: cfe-commits@lists.llvm.org
Subject: Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for 
__final specifier

You've added a comment describing the new enum value.  Please make sure the 
comment starts with a cap letter and ends with a period.

On Mon, Jul 25, 2016 at 4:09 PM, Keane, Erich 
> wrote:
Thanks for the quick review!  I’ve updated the patch with the name changes in 
the attached diff file.

From: David Majnemer 
[mailto:david.majne...@gmail.com]
Sent: Monday, July 25, 2016 12:40 PM
To: Keane, Erich >
Cc: cfe-commits@lists.llvm.org
Subject: Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for 
__final specifier

I'd rename VS_Alt_Final to VS_GNU_Final.

On Mon, Jul 25, 2016 at 2:24 PM, Keane, Erich via cfe-commits 
> wrote:
Hi all, my first potential-contribution, so I apologize if I’m submitting this 
improperly, I’m unfamiliar with the ‘type’ keys that you use in the topic, so 
hopefully I have this right.

As reported in bug 28473, GCC supports ‘final’ functionality in pre-C++11 code 
using the __final keyword.  Clang currently supports the ‘final’ keyword in 
accordance with the C++11 specification, however it ALSO supports it in 
pre-C++11 mode, with a warning.

This patch adds the ‘__final’ keyword for compatibility with GCC in GCC 
Keywords mode (so it is enabled with existing flags), and issues a warning on 
its usage (suggesting switching to the C++11 keyword).  This patch also adds a 
regression test for the functionality described.  I believe this patch has 
minimal impact, as it simply adds a new keyword for existing behavior.

This has been validated with check-clang to avoid regressions.  Patch is 
created in reference to revisions 276665

Thanks,
Erich

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




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


Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for __final specifier

2016-07-25 Thread David Majnemer via cfe-commits
You've added a comment describing the new enum value.  Please make sure the
comment starts with a cap letter and ends with a period.

On Mon, Jul 25, 2016 at 4:09 PM, Keane, Erich  wrote:

> Thanks for the quick review!  I’ve updated the patch with the name changes
> in the attached diff file.
>
>
>
> *From:* David Majnemer [mailto:david.majne...@gmail.com]
> *Sent:* Monday, July 25, 2016 12:40 PM
> *To:* Keane, Erich 
> *Cc:* cfe-commits@lists.llvm.org
> *Subject:* Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch:
> Support for __final specifier
>
>
>
> I'd rename VS_Alt_Final to VS_GNU_Final.
>
>
>
> On Mon, Jul 25, 2016 at 2:24 PM, Keane, Erich via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
> Hi all, my first potential-contribution, so I apologize if I’m submitting
> this improperly, I’m unfamiliar with the ‘type’ keys that you use in the
> topic, so hopefully I have this right.
>
>
>
> As reported in bug 28473, GCC supports ‘final’ functionality in pre-C++11
> code using the __final keyword.  Clang currently supports the ‘final’
> keyword in accordance with the C++11 specification, however it ALSO
> supports it in pre-C++11 mode, with a warning.
>
>
>
> This patch adds the ‘__final’ keyword for compatibility with GCC in GCC
> Keywords mode (so it is enabled with existing flags), and issues a warning
> on its usage (suggesting switching to the C++11 keyword).  This patch also
> adds a regression test for the functionality described.  I believe this
> patch has minimal impact, as it simply adds a new keyword for existing
> behavior.
>
>
>
> This has been validated with check-clang to avoid regressions.  Patch is
> created in reference to revisions 276665
>
>
>
> Thanks,
>
> Erich
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-25 Thread Daniel Berlin via cfe-commits
On Mon, Jul 25, 2016 at 1:03 PM, Vlad Dovlekaev via llvm-commits <
llvm-comm...@lists.llvm.org> wrote:

> vladisld added a comment.
>
> In https://reviews.llvm.org/D22463#494828, @jlebar wrote:
>
> > I think the general feeling is that most of us (myself included) would
> rather not learn a new tool if there's a simpler >alternative, such as a
> vanilla git workflow.
>
>
> Generally you're right, however learning how to use git-repo is much
> simpler than managing the intricacies of git sub-modules (and Google's
> experience with Android is a clear example of it).


Just to make some points, as a guy who watched repo being designed in the
office next to me:
Sub modules were completely and totally unusable for Google at that point,
and something was needed sooner.
There is no good reason for android to change now, so they don't.

Note that repo does not solve the issue of cross-repo atomic commits in any
way, shape, or form, and in fact, this is the biggest complaint ;)

In fact, the gerrit team (same people who produce repo) uses submodules for
pseudo-atomic cross-repo commits.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


RE: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for __final specifier

2016-07-25 Thread Keane, Erich via cfe-commits
Thanks for the quick review!  I’ve updated the patch with the name changes in 
the attached diff file.

From: David Majnemer [mailto:david.majne...@gmail.com]
Sent: Monday, July 25, 2016 12:40 PM
To: Keane, Erich 
Cc: cfe-commits@lists.llvm.org
Subject: Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for 
__final specifier

I'd rename VS_Alt_Final to VS_GNU_Final.

On Mon, Jul 25, 2016 at 2:24 PM, Keane, Erich via cfe-commits 
> wrote:
Hi all, my first potential-contribution, so I apologize if I’m submitting this 
improperly, I’m unfamiliar with the ‘type’ keys that you use in the topic, so 
hopefully I have this right.

As reported in bug 28473, GCC supports ‘final’ functionality in pre-C++11 code 
using the __final keyword.  Clang currently supports the ‘final’ keyword in 
accordance with the C++11 specification, however it ALSO supports it in 
pre-C++11 mode, with a warning.

This patch adds the ‘__final’ keyword for compatibility with GCC in GCC 
Keywords mode (so it is enabled with existing flags), and issues a warning on 
its usage (suggesting switching to the C++11 keyword).  This patch also adds a 
regression test for the functionality described.  I believe this patch has 
minimal impact, as it simply adds a new keyword for existing behavior.

This has been validated with check-clang to avoid regressions.  Patch is 
created in reference to revisions 276665

Thanks,
Erich

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



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


[PATCH] D22773: Modules: add command line option fmodules-disable-diagnostic-validation to disable validation of the diagnostic options when loading the module

2016-07-25 Thread Manman Ren via cfe-commits
manmanren created this revision.
manmanren added a reviewer: benlangmuir.
manmanren added a subscriber: cfe-commits.

With PCH+Module, sometimes compiler gives a hard error:
"Module file ‘.pcm' is out of date and needs to be rebuilt"

This happens when we have a PCH importing a module and the module gets 
overwritten by another compiler instance after we build the pch (one example is 
that both compiler instances hash to the same pcm file but use different 
diagnostic options). When we try to load the pch later on, the compiler notices 
that the imported module is out of date (modification date, size do not match)  
but it can't handle this out of date pcm (i.e it does not know how to rebuild 
the pch).

This patch introduces a new command line option so for PCH + module, we can 
turn on this option and if two compiler instances only differ in diagnostic 
options, the latter instance will not invalidate the original pcm.


https://reviews.llvm.org/D22773

Files:
  include/clang/Driver/Options.td
  include/clang/Lex/HeaderSearchOptions.h
  include/clang/Serialization/ASTReader.h
  lib/Frontend/CompilerInvocation.cpp
  lib/Frontend/FrontendActions.cpp
  lib/Serialization/ASTReader.cpp
  test/Driver/modules.m
  test/Modules/Inputs/DiagOutOfDate.h
  test/Modules/Inputs/module.map
  test/Modules/Inputs/pch-import-module-out-of-date.pch
  test/Modules/diagnostic-options-out-of-date.m

Index: test/Modules/diagnostic-options-out-of-date.m
===
--- test/Modules/diagnostic-options-out-of-date.m
+++ test/Modules/diagnostic-options-out-of-date.m
@@ -0,0 +1,8 @@
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s
+// RUN: %clang_cc1 -Werror -Wno-conversion -emit-pch -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -o %t.pch -I %S/Inputs -x objective-c-header %S/Inputs/pch-import-module-out-of-date.pch
+// RUN: %clang_cc1 -Werror -Wconversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -I %S/Inputs %s -fmodules-disable-diagnostic-validation
+// RUN: %clang_cc1 -Werror -Wno-conversion -fmodules-cache-path=%t -fmodules -fimplicit-module-maps -fsyntax-only -I %S/Inputs -include-pch %t.pch %s -verify -fmodules-disable-diagnostic-validation
+// expected-no-diagnostics
+
+@import DiagOutOfDate;
Index: test/Modules/Inputs/pch-import-module-out-of-date.pch
===
--- test/Modules/Inputs/pch-import-module-out-of-date.pch
+++ test/Modules/Inputs/pch-import-module-out-of-date.pch
@@ -0,0 +1 @@
+@import DiagOutOfDate;
Index: test/Modules/Inputs/module.map
===
--- test/Modules/Inputs/module.map
+++ test/Modules/Inputs/module.map
@@ -418,3 +418,7 @@
 module MacroFabs1 {
   header "MacroFabs1.h"
 }
+
+module DiagOutOfDate {
+  header "DiagOutOfDate.h"
+}
Index: test/Modules/Inputs/DiagOutOfDate.h
===
--- test/Modules/Inputs/DiagOutOfDate.h
+++ test/Modules/Inputs/DiagOutOfDate.h
@@ -0,0 +1 @@
+const int a = 1;
Index: test/Driver/modules.m
===
--- test/Driver/modules.m
+++ test/Driver/modules.m
@@ -33,6 +33,12 @@
 // RUN: %clang -fmodules-validate-system-headers -### %s 2>&1 | FileCheck -check-prefix=MODULES_VALIDATE_SYSTEM_HEADERS %s
 // MODULES_VALIDATE_SYSTEM_HEADERS: -fmodules-validate-system-headers
 
+// RUN: %clang -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION_DEFAULT-NOT: -fmodules-disable-diagnostic-validation
+
+// RUN: %clang -fmodules-disable-diagnostic-validation -### %s 2>&1 | FileCheck -check-prefix=MODULES_DISABLE_DIAGNOSTIC_VALIDATION %s
+// MODULES_DISABLE_DIAGNOSTIC_VALIDATION: -fmodules-disable-diagnostic-validation
+
 // RUN: %clang -fmodules -fmodule-map-file=foo.map -fmodule-map-file=bar.map -### %s 2>&1 | FileCheck -check-prefix=CHECK-MODULE-MAP-FILES %s
 // CHECK-MODULE-MAP-FILES: "-fmodules"
 // CHECK-MODULE-MAP-FILES: "-fmodule-map-file=foo.map"
Index: lib/Serialization/ASTReader.cpp
===
--- lib/Serialization/ASTReader.cpp
+++ lib/Serialization/ASTReader.cpp
@@ -2084,7 +2084,7 @@
 ASTReader::ASTReadResult ASTReader::ReadOptionsBlock(
 BitstreamCursor , unsigned ClientLoadCapabilities,
 bool AllowCompatibleConfigurationMismatch, ASTReaderListener ,
-std::string ) {
+std::string , bool ValidateDiagnosticOptions) {
   if (Stream.EnterSubBlock(OPTIONS_BLOCK_ID))
 return Failure;
 
@@ -2128,7 +2128,8 @@
 
 case DIAGNOSTIC_OPTIONS: {
   bool Complain = (ClientLoadCapabilities & ARR_OutOfDate) == 0;
-  if (!AllowCompatibleConfigurationMismatch &&
+  if (ValidateDiagnosticOptions &&
+  

Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-07-25 Thread Alexander Droste via cfe-commits
Alexander_Droste removed rL LLVM as the repository for this revision.
Alexander_Droste updated this revision to Diff 65404.
Alexander_Droste added a comment.

Hi, thanks for the notification! Obviously, on some systems `char` is unsigned 
by default 
which is why the check now tolerates distinct signedness for char pairs.
http://blog.cdleary.com/2012/11/arm-chars-are-unsigned-by-default/
In addition, I removed the trailing white space from the test file.


https://reviews.llvm.org/D21962

Files:
  clang-tidy/CMakeLists.txt
  clang-tidy/mpi/CMakeLists.txt
  clang-tidy/mpi/MPITidyModule.cpp
  clang-tidy/mpi/TypeMismatchCheck.cpp
  clang-tidy/mpi/TypeMismatchCheck.h
  clang-tidy/plugin/CMakeLists.txt
  clang-tidy/tool/CMakeLists.txt
  clang-tidy/tool/ClangTidyMain.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/mpi-type-mismatch.rst
  test/clang-tidy/Inputs/mpi-type-mismatch/mpimock.h
  test/clang-tidy/mpi-type-mismatch.cpp

Index: test/clang-tidy/mpi-type-mismatch.cpp
===
--- /dev/null
+++ test/clang-tidy/mpi-type-mismatch.cpp
@@ -0,0 +1,255 @@
+// RUN: %check_clang_tidy %s mpi-type-mismatch %t -- -- -I %S/Inputs/mpi-type-mismatch
+
+#include "mpimock.h"
+
+void charNegativeTest() {
+  int buf;
+  MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int' does not match the MPI datatype 'MPI_CHAR'
+
+  short buf2;
+  MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_CHAR'
+
+  long buf3;
+  MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' does not match the MPI datatype 'MPI_CHAR'
+
+  int8_t buf4;
+  MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not match the MPI datatype 'MPI_CHAR'
+
+  uint16_t buf5;
+  MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_CHAR'
+
+  long double _Complex buf6;
+  MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long double _Complex' does not match the MPI datatype 'MPI_CHAR'
+
+  std::complex buf7;
+  MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex' does not match the MPI datatype 'MPI_CHAR'
+}
+
+void intNegativeTest() {
+  unsigned char buf;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned char' does not match the MPI datatype 'MPI_INT'
+
+  unsigned buf2;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_INT'
+
+  short buf3;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not match the MPI datatype 'MPI_INT'
+
+  long buf4;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' does not match the MPI datatype 'MPI_INT'
+
+  int8_t buf5;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not match the MPI datatype 'MPI_INT'
+
+  uint16_t buf6;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint16_t' does not match the MPI datatype 'MPI_INT'
+
+  long double _Complex buf7;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long double _Complex' does not match the MPI datatype 'MPI_INT'
+
+  std::complex buf8;
+  MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'complex' does not match the MPI datatype 'MPI_INT'
+}
+
+void longNegativeTest() {
+  char buf;
+  MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'char' does not match the MPI datatype 'MPI_LONG'
+
+  unsigned buf2;
+  MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does not match the MPI datatype 'MPI_LONG'
+
+  unsigned short buf3;
+  MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned short' does not match the MPI datatype 'MPI_LONG'
+
+  unsigned long buf4;
+  MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned long' does not match the MPI datatype 'MPI_LONG'
+
+  int8_t buf5;
+  MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
+  // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not 

Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-25 Thread Bianca-Cristina Cristescu via cfe-commits
CrisCristescu updated this revision to Diff 65403.
CrisCristescu marked an inline comment as done.
CrisCristescu added a comment.

PP CodeCompletionII initialisation.


Repository:
  rL LLVM

https://reviews.llvm.org/D17820

Files:
  include/clang/Lex/Preprocessor.h
  include/clang/Sema/CodeCompleteConsumer.h
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  test/CodeCompletion/filter-function-name.cpp
  test/CodeCompletion/filter-member-access.cpp
  test/CodeCompletion/filter-namespace.cpp
  test/CodeCompletion/filter-ordinary-name.cpp
  test/CodeCompletion/objc-message.mm
  test/Index/complete-method-decls.m
  test/Index/complete-objc-message-id.m
  test/Index/complete-objc-message.m
  test/Index/complete-recovery.m
  test/Index/complete-super.m

Index: test/Index/complete-super.m
===
--- test/Index/complete-super.m
+++ test/Index/complete-super.m
@@ -60,16 +60,16 @@
 // RUN: c-index-test -code-completion-at=%s:20:16 %s | FileCheck -check-prefix=CHECK-ADD-TO %s
 // CHECK-ADD-TO: ObjCInstanceMethodDecl:{ResultType void}{Informative add:}{TypedText to:}{Placeholder b} (20)
 
-// RUN: c-index-test -code-completion-at=%s:24:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// RUN: c-index-test -code-completion-at=%s:24:29 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
 // CHECK-SELECTOR-FIRST: ObjCClassMethodDecl:{ResultType void}{Informative select:}{TypedText first:}{Placeholder a}{HorizontalSpace  }{Text second:}{Placeholder b} (20)
 
 // Check "super" completion at the third identifier
 // RUN: c-index-test -code-completion-at=%s:24:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
 // CHECK-SELECTOR-SECOND: ObjCClassMethodDecl:{ResultType void}{Informative select:}{Informative first:}{TypedText second:}{Placeholder b} (20)
 
 // Check "super" completion with missing '['.
 // RUN: c-index-test -code-completion-at=%s:25:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s
-// RUN: c-index-test -code-completion-at=%s:25:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// RUN: c-index-test -code-completion-at=%s:25:29 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
 // RUN: c-index-test -code-completion-at=%s:25:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
 
 // Check "super" completion for a method declared in a category.
Index: test/Index/complete-recovery.m
===
--- test/Index/complete-recovery.m
+++ test/Index/complete-recovery.m
@@ -26,7 +26,7 @@
 // Test case for fix committed in r145441.
 // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:20 %s -fms-compatibility | FileCheck -check-prefix=CHECK-CC1 %s
 
-// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:24 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:25 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
 // CHECK-CC2: NotImplemented:{TypedText _Bool}
 // CHECK-CC2: VarDecl:{ResultType A *}{TypedText a}
Index: test/Index/complete-objc-message.m
===
--- test/Index/complete-objc-message.m
+++ test/Index/complete-objc-message.m
@@ -218,13 +218,13 @@
 // CHECK-CC2-NEXT: Container Kind: ObjCInterfaceDecl
 // CHECK-CC2-NEXT: Container is complete
 // CHECK-CC2-NEXT: Container USR: c:objc(cs)Foo
-// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:61:17 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)}
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
-// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:65:17 %s | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace  }{TypedText second:}{Placeholder (id)}
 // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
-// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: c-index-test -code-completion-at=%s:74:10 %s | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace  }{TypedText second:}{Placeholder (id)}
 // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
 // RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
@@ -311,7 +311,7 @@
 // CHECK-CCI: 

Re: [ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for __final specifier

2016-07-25 Thread David Majnemer via cfe-commits
I'd rename VS_Alt_Final to VS_GNU_Final.

On Mon, Jul 25, 2016 at 2:24 PM, Keane, Erich via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Hi all, my first potential-contribution, so I apologize if I’m submitting
> this improperly, I’m unfamiliar with the ‘type’ keys that you use in the
> topic, so hopefully I have this right.
>
>
>
> As reported in bug 28473, GCC supports ‘final’ functionality in pre-C++11
> code using the __final keyword.  Clang currently supports the ‘final’
> keyword in accordance with the C++11 specification, however it ALSO
> supports it in pre-C++11 mode, with a warning.
>
>
>
> This patch adds the ‘__final’ keyword for compatibility with GCC in GCC
> Keywords mode (so it is enabled with existing flags), and issues a warning
> on its usage (suggesting switching to the C++11 keyword).  This patch also
> adds a regression test for the functionality described.  I believe this
> patch has minimal impact, as it simply adds a new keyword for existing
> behavior.
>
>
>
> This has been validated with check-clang to avoid regressions.  Patch is
> created in reference to revisions 276665
>
>
>
> Thanks,
>
> Erich
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D17820: Clang Code Completion Filtering

2016-07-25 Thread Bianca-Cristina Cristescu via cfe-commits
CrisCristescu updated this revision to Diff 65401.
CrisCristescu marked 3 inline comments as done.
CrisCristescu added a comment.

Addressing some sugesstions.


Repository:
  rL LLVM

https://reviews.llvm.org/D17820

Files:
  include/clang/Lex/Preprocessor.h
  include/clang/Sema/CodeCompleteConsumer.h
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  lib/Sema/CodeCompleteConsumer.cpp
  test/CodeCompletion/filter-function-name.cpp
  test/CodeCompletion/filter-member-access.cpp
  test/CodeCompletion/filter-namespace.cpp
  test/CodeCompletion/filter-ordinary-name.cpp
  test/CodeCompletion/objc-message.mm
  test/Index/complete-method-decls.m
  test/Index/complete-objc-message-id.m
  test/Index/complete-objc-message.m
  test/Index/complete-recovery.m
  test/Index/complete-super.m

Index: test/Index/complete-super.m
===
--- test/Index/complete-super.m
+++ test/Index/complete-super.m
@@ -60,16 +60,16 @@
 // RUN: c-index-test -code-completion-at=%s:20:16 %s | FileCheck -check-prefix=CHECK-ADD-TO %s
 // CHECK-ADD-TO: ObjCInstanceMethodDecl:{ResultType void}{Informative add:}{TypedText to:}{Placeholder b} (20)
 
-// RUN: c-index-test -code-completion-at=%s:24:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// RUN: c-index-test -code-completion-at=%s:24:29 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
 // CHECK-SELECTOR-FIRST: ObjCClassMethodDecl:{ResultType void}{Informative select:}{TypedText first:}{Placeholder a}{HorizontalSpace  }{Text second:}{Placeholder b} (20)
 
 // Check "super" completion at the third identifier
 // RUN: c-index-test -code-completion-at=%s:24:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
 // CHECK-SELECTOR-SECOND: ObjCClassMethodDecl:{ResultType void}{Informative select:}{Informative first:}{TypedText second:}{Placeholder b} (20)
 
 // Check "super" completion with missing '['.
 // RUN: c-index-test -code-completion-at=%s:25:10 %s | FileCheck -check-prefix=CHECK-SELECTOR-SELECTOR %s
-// RUN: c-index-test -code-completion-at=%s:25:28 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
+// RUN: c-index-test -code-completion-at=%s:25:29 %s | FileCheck -check-prefix=CHECK-SELECTOR-FIRST %s
 // RUN: c-index-test -code-completion-at=%s:25:37 %s | FileCheck -check-prefix=CHECK-SELECTOR-SECOND %s
 
 // Check "super" completion for a method declared in a category.
Index: test/Index/complete-recovery.m
===
--- test/Index/complete-recovery.m
+++ test/Index/complete-recovery.m
@@ -26,7 +26,7 @@
 // Test case for fix committed in r145441.
 // RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:9:20 %s -fms-compatibility | FileCheck -check-prefix=CHECK-CC1 %s
 
-// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:24 %s | FileCheck -check-prefix=CHECK-CC2 %s
+// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:25 %s | FileCheck -check-prefix=CHECK-CC2 %s
 // CHECK-CC2: NotImplemented:{ResultType char[]}{TypedText @encode}{LeftParen (}{Placeholder type-name}{RightParen )}
 // CHECK-CC2: NotImplemented:{TypedText _Bool}
 // CHECK-CC2: VarDecl:{ResultType A *}{TypedText a}
Index: test/Index/complete-objc-message.m
===
--- test/Index/complete-objc-message.m
+++ test/Index/complete-objc-message.m
@@ -218,13 +218,13 @@
 // CHECK-CC2-NEXT: Container Kind: ObjCInterfaceDecl
 // CHECK-CC2-NEXT: Container is complete
 // CHECK-CC2-NEXT: Container USR: c:objc(cs)Foo
-// RUN: c-index-test -code-completion-at=%s:61:16 %s | FileCheck -check-prefix=CHECK-CC3 %s
+// RUN: c-index-test -code-completion-at=%s:61:17 %s | FileCheck -check-prefix=CHECK-CC3 %s
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyClassMethod:}{Placeholder (id)}
 // CHECK-CC3: ObjCClassMethodDecl:{ResultType int}{TypedText MyPrivateMethod}
-// RUN: c-index-test -code-completion-at=%s:65:16 %s | FileCheck -check-prefix=CHECK-CC4 %s
+// RUN: c-index-test -code-completion-at=%s:65:17 %s | FileCheck -check-prefix=CHECK-CC4 %s
 // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace  }{TypedText second:}{Placeholder (id)}
 // CHECK-CC4: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyPrivateInstMethod}
-// RUN: c-index-test -code-completion-at=%s:74:9 %s | FileCheck -check-prefix=CHECK-CC5 %s
+// RUN: c-index-test -code-completion-at=%s:74:10 %s | FileCheck -check-prefix=CHECK-CC5 %s
 // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MyInstMethod:}{Placeholder (id)}{HorizontalSpace  }{TypedText second:}{Placeholder (id)}
 // CHECK-CC5: ObjCInstanceMethodDecl:{ResultType int}{TypedText MySubInstMethod}
 // RUN: c-index-test -code-completion-at=%s:82:8 %s | FileCheck -check-prefix=CHECK-CC6 %s
@@ -311,7 +311,7 @@
 // CHECK-CCI: 

Re: [PATCH] D22584: constexpr array support C++1z (P0031)

2016-07-25 Thread Jason Turner via cfe-commits
lefticus added a comment.

I believe all or most of the "untested" comments are correctly tested in the 
updated test files via static_asserts with contexpr. I've commented on just the 
first one to make sure I understand correctly.



Comment at: include/array:156
@@ -155,3 +155,3 @@
 _LIBCPP_INLINE_VISIBILITY
-iterator begin() _NOEXCEPT {return iterator(__elems_);}
+_LIBCPP_CONSTEXPR_AFTER_CXX14 iterator begin() _NOEXCEPT {return 
iterator(__elems_);}
 _LIBCPP_INLINE_VISIBILITY

This should be tested in begin.pass.cpp:28 correct?


https://reviews.llvm.org/D22584



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


Re: [PATCH] D22584: constexpr array support C++1z (P0031)

2016-07-25 Thread Jason Turner via cfe-commits
lefticus updated this revision to Diff 65398.
lefticus added a comment.

Correct context from last patch


https://reviews.llvm.org/D22584

Files:
  include/array
  include/iterator
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/sequences/array/begin.pass.cpp
  test/std/containers/sequences/array/front_back.pass.cpp
  test/std/containers/sequences/array/indexing.pass.cpp
  test/std/containers/sequences/array/iterators.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp

Index: test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
@@ -33,12 +33,21 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s));
-test(random_access_iterator(s+10), 10, random_access_iterator(s));
-test(s+10, 10, s);
-
-test(bidirectional_iterator(s+1), bidirectional_iterator(s));
-test(random_access_iterator(s+1), random_access_iterator(s));
-test(s+1, s);
+{
+const char* s = "1234567890";
+test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s));
+test(random_access_iterator(s+10), 10, random_access_iterator(s));
+test(s+10, 10, s);
+
+test(bidirectional_iterator(s+1), bidirectional_iterator(s));
+test(random_access_iterator(s+1), random_access_iterator(s));
+test(s+1, s);
+}
+
+{
+constexpr const char* s = "1234567890";
+static_assert(std::prev(s+10, 10) == s);
+static_assert(std::prev(s+1) == s);
+}
+
 }
Index: test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -35,16 +35,27 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(input_iterator(s), 10, input_iterator(s+10));
-test(forward_iterator(s), 10, forward_iterator(s+10));
-test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10));
-test(random_access_iterator(s), 10, random_access_iterator(s+10));
-test(s, 10, s+10);
-
-test(input_iterator(s), input_iterator(s+1));
-test(forward_iterator(s), forward_iterator(s+1));
-test(bidirectional_iterator(s), bidirectional_iterator(s+1));
-test(random_access_iterator(s), random_access_iterator(s+1));
-test(s, s+1);
+{
+const char* s = "1234567890";
+test(input_iterator(s), 10, input_iterator(s+10));
+test(forward_iterator(s), 10, forward_iterator(s+10));
+test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10));
+test(random_access_iterator(s), 10, random_access_iterator(s+10));
+test(s, 10, s+10);
+
+test(input_iterator(s), input_iterator(s+1));
+test(forward_iterator(s), forward_iterator(s+1));
+test(bidirectional_iterator(s), bidirectional_iterator(s+1));
+test(random_access_iterator(s), random_access_iterator(s+1));
+test(s, s+1);
+}
+
+#if TEST_STD_VER > 14
+{
+constexpr const char* s = "1234567890";
+static_assert(std::next(s, 10) == s+10);
+static_assert(std::next(s) == s+1);
+}
+#endif
+
 }
Index: test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
@@ -31,10 +31,21 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(input_iterator(s), input_iterator(s+10), 10);
-test(forward_iterator(s), forward_iterator(s+10), 10);
-test(bidirectional_iterator(s), bidirectional_iterator(s+10), 10);
-test(random_access_iterator(s), random_access_iterator(s+10), 10);
-test(s, s+10, 10);
+{
+const char* s = "1234567890";
+test(input_iterator(s), input_iterator(s+10), 10);
+test(forward_iterator(s), forward_iterator(s+10), 10);
+test(bidirectional_iterator(s), bidirectional_iterator(s+10), 10);
+test(random_access_iterator(s), random_access_iterator(s+10), 10);
+test(s, s+10, 10);
+}
+
+
+#if TEST_STD_VER > 14
+{
+constexpr const char* s = "1234567890";
+static_assert(std::distance(s, s+10) == 10);
+}
+#endif
+
 }
Index: 

r276674 - [CMake] Cleaning up some CMake warnings

2016-07-25 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Mon Jul 25 13:54:30 2016
New Revision: 276674

URL: http://llvm.org/viewvc/llvm-project?rev=276674=rev
Log:
[CMake] Cleaning up some CMake warnings

In Bootstrap builds Clang logs some warnings. These are caused because Clang 
passes CLANG_STAGE and BOOTSTRAP_DEFAULT_PASSTHROUGH into the next stage's 
configuration.

BOOTSTRAP_DEFAULT_PASSTHROUGH shouldn't be passed, so it is renamed to 
_BOOTSTRAP_DEFAULT_PASSTHROUGH, to prevent passthrough.

CLANG_STAGE should be passed, so I've changed the code to log it if it is set 
outside the if(CLANG_ENABLE_BOOTSTRAP) block. This makes the variable always 
used, so the warning goes away.

Modified:
cfe/trunk/CMakeLists.txt

Modified: cfe/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/CMakeLists.txt?rev=276674=276673=276674=diff
==
--- cfe/trunk/CMakeLists.txt (original)
+++ cfe/trunk/CMakeLists.txt Mon Jul 25 13:54:30 2016
@@ -463,12 +463,15 @@ endif()
 
 add_subdirectory(cmake/modules)
 
+if(CLANG_STAGE)
+  message(STATUS "Setting current clang stage to: ${CLANG_STAGE}")
+endif()
+
 if (CLANG_ENABLE_BOOTSTRAP)
   include(ExternalProject)
 
   if(NOT CLANG_STAGE)
 set(CLANG_STAGE stage1)
-message(STATUS "Setting current clang stage to: ${CLANG_STAGE}")
   endif()
 
   string(REGEX MATCH "stage([0-9]*)" MATCHED_STAGE "${CLANG_STAGE}")
@@ -526,7 +529,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
 set(verbose -DCMAKE_VERBOSE_MAKEFILE=On)
   endif()
 
-  set(BOOTSTRAP_DEFAULT_PASSTHROUGH
+  set(_BOOTSTRAP_DEFAULT_PASSTHROUGH
 PACKAGE_VERSION
 LLVM_VERSION_MAJOR
 LLVM_VERSION_MINOR
@@ -577,7 +580,7 @@ if (CLANG_ENABLE_BOOTSTRAP)
   endforeach()
 
   # Populate the passthrough variables
-  foreach(variableName ${CLANG_BOOTSTRAP_PASSTHROUGH} 
${BOOTSTRAP_DEFAULT_PASSTHROUGH})
+  foreach(variableName ${CLANG_BOOTSTRAP_PASSTHROUGH} 
${_BOOTSTRAP_DEFAULT_PASSTHROUGH})
 if(${variableName})
   string(REPLACE ";" "\;" value ${${variableName}})
   list(APPEND PASSTHROUGH_VARIABLES


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


Re: [PATCH] D22505: clang-format Access Modifier Use Normal Indent

2016-07-25 Thread Loki Astari via cfe-commits
LokiAstari added a comment.

Hope you don't mind me chiming in:

> Roughly go ahead with what you are suggesting, although the option should not 
> be called AccessModifierStandardIndent, as that carries no meaning and 
> actually is far from the "standard" way. Reasonable names that spring to mind 
> are:


Though I personally disagree on the more standard technique :-)  Since I am the 
newbie to this I am not going to fight on that point (though I suspect if we 
meet up for some beers we could have a spirited debate).

> AccessModifiersCauseAdditionalIndent or 
> (Additional)IndentAfterAccessModifiers.


How about "AccessModifiersUseNormaIndent" as we are indenting by a normal 
indent width. But I am not going to fight over the name when it comes down to 
it.

> Be even more "clever" with AccessModifierOffset (I can come up with various 
> ways from negative numbers to special numbers, none of them really good).


I don't think this is a good idea (but as the newbie no strong feelings). 
Unfortunately a lot of large projects have stated using this is a standard part 
of their formatting; got to this project too late to prevent that :-O

> Deprecate AccessModifierOffset and instead use an enum with a few dedicated 
> settings.


The issue with this is getting all projects to update their settings with the 
new version. Not sure this is a great user experience.


https://reviews.llvm.org/D22505



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


Re: [PATCH] D22584: constexpr array support C++1z (P0031)

2016-07-25 Thread Jason Turner via cfe-commits
lefticus added a comment.

I believe I messed up the context for the files, will attempt to resubmit the 
patch.


https://reviews.llvm.org/D22584



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


Re: [PATCH] D22584: constexpr array support C++1z (P0031)

2016-07-25 Thread Jason Turner via cfe-commits
lefticus marked 3 inline comments as done.
lefticus added a comment.

https://reviews.llvm.org/D22584



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


Re: [PATCH] D22654: [Clang-rename] Remove custom version, fix extra space in error message

2016-07-25 Thread Kirill Bobyrev via cfe-commits
omtcyfz added a comment.

lgtm


Repository:
  rL LLVM

https://reviews.llvm.org/D22654



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


Re: [PATCH] D19544: Pass for translating math intrinsics to math library calls.

2016-07-25 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In https://reviews.llvm.org/D19544#492258, @mmasten wrote:

> I think this is just saying that some of the weird types are not supported on 
> all targets. For now, is it ok to proceed with checking this code in?


Correct.

In https://reviews.llvm.org/D19544#493403, @mmasten wrote:

> Thanks Michael. The tests have been updated.
>
> Matt


Do you need someone to commit this for you?


https://reviews.llvm.org/D19544



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


Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-07-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

A couple of nits.



Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.cpp:51
@@ +50,3 @@
+  hasArgument(
+  0, declRefExpr(BasicStringType),
+  declRefExpr(hasDeclaration(decl().bind("lhsStrT"))).bind("lhsStr")),

As noted earlier, there's no need to repeat `declRefExpr`. This should be:

  declRefExpr(BasicStringType, hasDeclaration(decl().bind("lhsStrT")))


Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.h:25
@@ +24,3 @@
+class InefficientStringConcatenationCheck : public ClangTidyCheck {
+ public:
+  InefficientStringConcatenationCheck(StringRef Name, ClangTidyContext 
*Context);

Please format the file with `clang-format -style=llvm`.


https://reviews.llvm.org/D20196



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


Re: [PATCH] D22584: constexpr array support C++1z (P0031)

2016-07-25 Thread Jason Turner via cfe-commits
lefticus updated this revision to Diff 65390.
lefticus added a comment.

Fixed syntax errors in test files.


https://reviews.llvm.org/D22584

Files:
  include/array
  include/iterator
  test/std/containers/sequences/array/at.pass.cpp
  test/std/containers/sequences/array/begin.pass.cpp
  test/std/containers/sequences/array/front_back.pass.cpp
  test/std/containers/sequences/array/indexing.pass.cpp
  test/std/containers/sequences/array/iterators.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/advance.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
  test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp

Index: test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/prev.pass.cpp
@@ -33,12 +33,21 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s));
-test(random_access_iterator(s+10), 10, random_access_iterator(s));
-test(s+10, 10, s);
-
-test(bidirectional_iterator(s+1), bidirectional_iterator(s));
-test(random_access_iterator(s+1), random_access_iterator(s));
-test(s+1, s);
+{
+const char* s = "1234567890";
+test(bidirectional_iterator(s+10), 10, bidirectional_iterator(s));
+test(random_access_iterator(s+10), 10, random_access_iterator(s));
+test(s+10, 10, s);
+
+test(bidirectional_iterator(s+1), bidirectional_iterator(s));
+test(random_access_iterator(s+1), random_access_iterator(s));
+test(s+1, s);
+}
+
+{
+constexpr const char* s = "1234567890";
+static_assert(std::prev(s+10, 10) == s);
+static_assert(std::prev(s+1) == s);
+}
+
 }
Index: test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/next.pass.cpp
@@ -35,16 +35,27 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(input_iterator(s), 10, input_iterator(s+10));
-test(forward_iterator(s), 10, forward_iterator(s+10));
-test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10));
-test(random_access_iterator(s), 10, random_access_iterator(s+10));
-test(s, 10, s+10);
-
-test(input_iterator(s), input_iterator(s+1));
-test(forward_iterator(s), forward_iterator(s+1));
-test(bidirectional_iterator(s), bidirectional_iterator(s+1));
-test(random_access_iterator(s), random_access_iterator(s+1));
-test(s, s+1);
+{
+const char* s = "1234567890";
+test(input_iterator(s), 10, input_iterator(s+10));
+test(forward_iterator(s), 10, forward_iterator(s+10));
+test(bidirectional_iterator(s), 10, bidirectional_iterator(s+10));
+test(random_access_iterator(s), 10, random_access_iterator(s+10));
+test(s, 10, s+10);
+
+test(input_iterator(s), input_iterator(s+1));
+test(forward_iterator(s), forward_iterator(s+1));
+test(bidirectional_iterator(s), bidirectional_iterator(s+1));
+test(random_access_iterator(s), random_access_iterator(s+1));
+test(s, s+1);
+}
+
+#if TEST_STD_VER > 14
+{
+constexpr const char* s = "1234567890";
+static_assert(std::next(s, 10) == s+10);
+static_assert(std::next(s) == s+1);
+}
+#endif
+
 }
Index: test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
===
--- test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
+++ test/std/iterators/iterator.primitives/iterator.operations/distance.pass.cpp
@@ -31,10 +31,21 @@
 
 int main()
 {
-const char* s = "1234567890";
-test(input_iterator(s), input_iterator(s+10), 10);
-test(forward_iterator(s), forward_iterator(s+10), 10);
-test(bidirectional_iterator(s), bidirectional_iterator(s+10), 10);
-test(random_access_iterator(s), random_access_iterator(s+10), 10);
-test(s, s+10, 10);
+{
+const char* s = "1234567890";
+test(input_iterator(s), input_iterator(s+10), 10);
+test(forward_iterator(s), forward_iterator(s+10), 10);
+test(bidirectional_iterator(s), bidirectional_iterator(s+10), 10);
+test(random_access_iterator(s), random_access_iterator(s+10), 10);
+test(s, s+10, 10);
+}
+
+
+#if TEST_STD_VER > 14
+{
+constexpr const char* s = "1234567890";
+static_assert(std::distance(s, s+10) == 10);
+}
+#endif
+
 }
Index: 

[ReviewRequest] [Sema/Parser] GCC Compatibility Patch: Support for __final specifier

2016-07-25 Thread Keane, Erich via cfe-commits
Hi all, my first potential-contribution, so I apologize if I'm submitting this 
improperly, I'm unfamiliar with the 'type' keys that you use in the topic, so 
hopefully I have this right.

As reported in bug 28473, GCC supports 'final' functionality in pre-C++11 code 
using the __final keyword.  Clang currently supports the 'final' keyword in 
accordance with the C++11 specification, however it ALSO supports it in 
pre-C++11 mode, with a warning.

This patch adds the '__final' keyword for compatibility with GCC in GCC 
Keywords mode (so it is enabled with existing flags), and issues a warning on 
its usage (suggesting switching to the C++11 keyword).  This patch also adds a 
regression test for the functionality described.  I believe this patch has 
minimal impact, as it simply adds a new keyword for existing behavior.

This has been validated with check-clang to avoid regressions.  Patch is 
created in reference to revisions 276665

Thanks,
Erich


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


[PATCH] D22770: [Sema, NFC] Reset HasFallthroughStmt when clearing FunctionScopeInfo

2016-07-25 Thread Erik Pilkington via cfe-commits
erik.pilkington created this revision.
erik.pilkington added a reviewer: rsmith.
erik.pilkington added a subscriber: cfe-commits.

The FunctionScopeInfo stack in Sema uses an optimization where the memory for 
the top-level functions is reused. The function FunctionScopeInfo::Clear() is 
used to reset this memory to the original, marking all the flags as false. The 
flag HasFallthroughStmt was omitted from this, meaning that once it set, it 
remained so for the rest of the TU. This meant we ran 
DiagnoseSwitchLabelsFallthrough() for every top level function in a TU where 
one function used `[[fallthrough]]`.

Thanks!

https://reviews.llvm.org/D22770

Files:
  lib/Sema/ScopeInfo.cpp

Index: lib/Sema/ScopeInfo.cpp
===
--- lib/Sema/ScopeInfo.cpp
+++ lib/Sema/ScopeInfo.cpp
@@ -29,6 +29,7 @@
   HasIndirectGoto = false;
   HasDroppedStmt = false;
   HasOMPDeclareReductionCombiner = false;
+  HasFallthroughStmt = false;
   ObjCShouldCallSuper = false;
   ObjCIsDesignatedInit = false;
   ObjCWarnForNoDesignatedInitChain = false;


Index: lib/Sema/ScopeInfo.cpp
===
--- lib/Sema/ScopeInfo.cpp
+++ lib/Sema/ScopeInfo.cpp
@@ -29,6 +29,7 @@
   HasIndirectGoto = false;
   HasDroppedStmt = false;
   HasOMPDeclareReductionCombiner = false;
+  HasFallthroughStmt = false;
   ObjCShouldCallSuper = false;
   ObjCIsDesignatedInit = false;
   ObjCWarnForNoDesignatedInitChain = false;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-07-25 Thread Bittner Barni via cfe-commits
bittnerbarni added inline comments.


Comment at: clang-tidy/performance/InefficientStringConcatenationCheck.cpp:55
@@ +54,3 @@
+ hasDeclaration(decl(equalsBoundNode("lhsStrT"))),
+  hasDescendant(BasicStringPlusOperator));
+

Yes this is the result of clang-format. 


https://reviews.llvm.org/D20196



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


Re: [PATCH] D20196: [clang-tidy] Inefficient string operation

2016-07-25 Thread Bittner Barni via cfe-commits
bittnerbarni updated this revision to Diff 65384.
bittnerbarni marked an inline comment as done.

https://reviews.llvm.org/D20196

Files:
  clang-tidy/performance/CMakeLists.txt
  clang-tidy/performance/InefficientStringConcatenationCheck.cpp
  clang-tidy/performance/InefficientStringConcatenationCheck.h
  clang-tidy/performance/PerformanceTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst
  test/clang-tidy/performance-inefficient-string-concatenation.cpp

Index: test/clang-tidy/performance-inefficient-string-concatenation.cpp
===
--- /dev/null
+++ test/clang-tidy/performance-inefficient-string-concatenation.cpp
@@ -0,0 +1,44 @@
+// RUN: %check_clang_tidy %s performance-inefficient-string-concatenation %t
+
+namespace std {
+template 
+class basic_string {
+public:
+  basic_string() {}
+  ~basic_string() {}
+  basic_string *operator+=(const basic_string &) {}
+  friend basic_string operator+(const basic_string &, const basic_string &) {}
+};
+typedef basic_string string;
+typedef basic_string wstring;
+}
+
+void f(std::string) {}
+std::string g(std::string) {}
+
+int main() {
+  std::string mystr1, mystr2;
+  std::wstring mywstr1, mywstr2;
+
+  for (int i = 0; i < 10; ++i) {
+f(mystr1 + mystr2 + mystr1);
+// CHECK-MESSAGES: :[[@LINE-1]]:23: warning: string concatenation results in allocation of unnecessary temporary strings; consider using 'operator+=' or 'string::append()' instead
+mystr1 = mystr1 + mystr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
+mystr1 = mystr2 + mystr2 + mystr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:30: warning: string concatenation
+mystr1 = mystr2 + mystr1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
+mywstr1 = mywstr2 + mywstr1;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
+mywstr1 = mywstr2 + mywstr2 + mywstr2;
+// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: string concatenation
+
+mywstr1 = mywstr2 + mywstr2;
+mystr1 = mystr2 + mystr2;
+mystr1 += mystr2;
+f(mystr2 + mystr1);
+mystr1 = g(mystr1);
+  }
+  return 0;
+}
Index: docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/performance-inefficient-string-concatenation.rst
@@ -0,0 +1,49 @@
+.. title:: clang-tidy - performance-inefficient-string-concatenation
+
+performance-inefficient-string-concatenation
+
+
+This check warns about the performance overhead arising from concatenating strings using the ``operator+``, for instance:
+
+.. code:: c++
+
+std::string a("Foo"), b("Bar");
+a = a + b;
+
+Instead of this structure you should use ``operator+=`` or ``std::string``'s (``std::basic_string``) class member function ``append()``. For instance:
+   
+.. code:: c++
+
+   std::string a("Foo"), b("Baz");
+   for (int i = 0; i < 2; ++i) {
+   a = a + "Bar" + b;
+   }
+
+Could be rewritten in a greatly more efficient way like:
+
+.. code:: c++
+
+   std::string a("Foo"), b("Baz");
+   for (int i = 0; i < 2; ++i) {
+   a.append("Bar").append(b);
+   } 
+
+And this can be rewritten too:
+
+.. code:: c++
+
+   void f(const std::string&) {}
+   std::string a("Foo"), b("Baz");
+   void g() {
+   f(a + "Bar" + b);
+   }
+
+In a slightly more efficient way like:
+
+.. code:: c++
+
+   void f(const std::string&) {}
+   std::string a("Foo"), b("Baz");
+   void g() {
+   f(std::string(a).append("Bar").append(b));
+   }
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -102,6 +102,7 @@
performance-faster-string-find
performance-for-range-copy
performance-implicit-cast-in-loop
+   performance-inefficient-string-concatenation
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
readability-avoid-const-params-in-decls
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -184,6 +184,12 @@
   Warns about range-based loop with a loop variable of const ref type where the
   type of the variable does not match the one returned by the iterator.
 
+- New `performance-inefficient-string-concatenation
+  `_ check
+
+  This check is to warn about the performance overhead arising from concatenating 
+  strings, using the ``operator+``, instead of ``operator+=``.
+  
 - New `performance-unnecessary-value-param
   

Re: [PATCH] D22654: [Clang-rename] Remove custom version, fix extra space in error message

2016-07-25 Thread Eugene Zelenko via cfe-commits
Eugene.Zelenko updated this revision to Diff 65379.
Eugene.Zelenko added a comment.

Don't include DiagnosticIDs.h


Repository:
  rL LLVM

https://reviews.llvm.org/D22654

Files:
  clang-rename/tool/ClangRename.cpp
  test/clang-rename/InvalidNewName.cpp

Index: test/clang-rename/InvalidNewName.cpp
===
--- test/clang-rename/InvalidNewName.cpp
+++ test/clang-rename/InvalidNewName.cpp
@@ -1,2 +1,2 @@
 // RUN: not clang-rename -new-name=class -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: new name is not a valid identifier in  C++17.
+// CHECK: ERROR: new name is not a valid identifier in C++17.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -15,28 +15,27 @@
 
 #include "../USRFindingAction.h"
 #include "../RenamingAction.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Basic/TargetOptions.h"
-#include "clang/Frontend/CommandLineSourceLoc.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendAction.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Parse/ParseAST.h"
-#include "clang/Parse/Parser.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/Host.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Support/YAMLTraits.h"
+#include 
 #include 
+#include 
 
 using namespace llvm;
 
@@ -79,12 +78,6 @@
 cl::value_desc("filename"),
 cl::cat(ClangRenameCategory));
 
-#define CLANG_RENAME_VERSION "0.0.1"
-
-static void PrintVersion() {
-  outs() << "clang-rename version " << CLANG_RENAME_VERSION << '\n';
-}
-
 using namespace clang;
 
 const char RenameUsage[] = "A tool to rename symbols in C/C++ code.\n\
@@ -93,7 +86,6 @@
 Otherwise, the results are written to stdout.\n";
 
 int main(int argc, const char **argv) {
-  cl::SetVersionPrinter(PrintVersion);
   tooling::CommonOptionsParser OP(argc, argv, ClangRenameCategory, 
RenameUsage);
 
   // Check the arguments for correctness.
@@ -110,7 +102,7 @@
   IdentifierTable Table(Options);
   auto NewNameTokKind = Table.get(NewName).getTokenID();
   if (!tok::isAnyIdentifier(NewNameTokKind)) {
-errs() << "ERROR: new name is not a valid identifier in  C++17.\n\n";
+errs() << "ERROR: new name is not a valid identifier in C++17.\n\n";
 exit(1);
   }
 


Index: test/clang-rename/InvalidNewName.cpp
===
--- test/clang-rename/InvalidNewName.cpp
+++ test/clang-rename/InvalidNewName.cpp
@@ -1,2 +1,2 @@
 // RUN: not clang-rename -new-name=class -offset=133 %s 2>&1 | FileCheck %s
-// CHECK: ERROR: new name is not a valid identifier in  C++17.
+// CHECK: ERROR: new name is not a valid identifier in C++17.
Index: clang-rename/tool/ClangRename.cpp
===
--- clang-rename/tool/ClangRename.cpp
+++ clang-rename/tool/ClangRename.cpp
@@ -15,28 +15,27 @@
 
 #include "../USRFindingAction.h"
 #include "../RenamingAction.h"
-#include "clang/AST/ASTConsumer.h"
-#include "clang/AST/ASTContext.h"
+#include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/FileManager.h"
+#include "clang/Basic/IdentifierTable.h"
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/TargetInfo.h"
-#include "clang/Basic/TargetOptions.h"
-#include "clang/Frontend/CommandLineSourceLoc.h"
-#include "clang/Frontend/CompilerInstance.h"
-#include "clang/Frontend/FrontendAction.h"
+#include "clang/Basic/SourceManager.h"
+#include "clang/Basic/TokenKinds.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Lex/Preprocessor.h"
-#include "clang/Parse/ParseAST.h"
-#include "clang/Parse/Parser.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/CommonOptionsParser.h"
 #include "clang/Tooling/Refactoring.h"
 #include "clang/Tooling/ReplacementsYaml.h"
 #include "clang/Tooling/Tooling.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
-#include "llvm/Support/Host.h"
+#include "llvm/Support/CommandLine.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/raw_ostream.h"
+#include 

Re: [PATCH] D20811: [analyzer] Model some library functions

2016-07-25 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:192
@@ +191,3 @@
+  };
+
+  // The map of all functions supported by the checker. It is initialized

Even though there are some doxygen-style comments in the checkers, i’ve never 
seen doxygen actually generate any docs for checker classes. Are they useful 
for IDE quick-hints only?


https://reviews.llvm.org/D20811



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


Re: [libcxxabi] r276022 - Attempt to bring peace to -Werror buildbots.

2016-07-25 Thread David Blaikie via cfe-commits
+Richard Trieu  - worth fixing? If anyone does get
around to fixing this, would be good to remove the workaround committed
here in r276022.

On Mon, Jul 25, 2016 at 10:51 AM Richard Smith 
wrote:

> On 25 Jul 2016 6:29 p.m., "David Blaikie via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
> >
> > Should we fix the diagnostic? Or is the code triggering it just esoteric
> enough to not be a good justification for changing the warning?
>
> Hmm, maybe we should. The case is something like
>
> template void f(T t) {
>   if (t) ...
> }
>
> with T being nullptr_t. That probably doesn't justify a warning.
>
> > On Tue, Jul 19, 2016 at 1:42 PM Richard Smith via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
> >>
> >> Author: rsmith
> >> Date: Tue Jul 19 15:35:09 2016
> >> New Revision: 276022
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=276022=rev
> >> Log:
> >> Attempt to bring peace to -Werror buildbots.
> >>
> >> Modified:
> >> libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp
> >>
> >> Modified: libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp
> >> URL:
> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp?rev=276022=276021=276022=diff
> >>
> ==
> >> --- libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp (original)
> >> +++ libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp Tue Jul 19
> 15:35:09 2016
> >> @@ -12,6 +12,12 @@
> >>  #include 
> >>  #include 
> >>
> >> +// Clang emits a warning on converting an object of type nullptr_t to
> bool,
> >> +// even in generic code. Suppress it.
> >> +#if defined(__clang__)
> >> +#pragma clang diagnostic ignored "-Wnull-conversion"
> >> +#endif
> >> +
> >>  struct A {};
> >>
> >>  template
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D21962: MPITypeMismatchCheck for Clang-Tidy

2016-07-25 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Alexander, FYI, the patch has been reverted, since it breaks multiple 
buildbots, e.g.

- 
http://lab.llvm.org:8011/builders/clang-cmake-armv7-a15/builds/13909/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Tools%3A%3Ampi-type-mismatch.cpp
- 
http://lab.llvm.org:8011/builders/clang-cmake-thumbv7-a15/builds/14191/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Tools%3A%3Ampi-type-mismatch.cpp
- 
http://lab.llvm.org:8011/builders/clang-cmake-aarch64-quick/builds/8891/steps/ninja%20check%201/logs/FAIL%3A%20Clang%20Tools%3A%3Ampi-type-mismatch.cpp

(all failures seem to be on ARM and PPC buildbots).

Please take a look.


Repository:
  rL LLVM

https://reviews.llvm.org/D21962



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


Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-25 Thread Aaron En Ye Shi via cfe-commits
ashi1 added inline comments.


Comment at: test/Misc/amdgcn.languageOptsOpenCL.cl:188
@@ +187,3 @@
+#endif
+// expected-warning@+6{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#else

yaxunl wrote:
> Anastasia wrote:
> > Can you move this error message down instead of adding 6 lines offset.
> > Also the extension seems to be set by default although it's hard to see 
> > without the full diff. So why do you get this warning at all?
> This warning is only for opencl version < 200. The extension is supported by 
> OpenCL 2.0 and above only.
I've added this error message here because I am following the order inside 
include/clang/Basic/OpenCLExtensions.def. Seems it is alphabetical there and in 
same order here. What do you think?


Comment at: test/SemaOpenCL/extension-version.cl:228
@@ +227,3 @@
+#endif
+// expected-warning@+6{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#else

Anastasia wrote:
> Can you move this error message down instead of adding 6 lines offset.
I've added this error message here because I am following the order inside 
include/clang/Basic/OpenCLExtensions.def. Seems it is alphabetical there and in 
same order here. What do you think?


Repository:
  rL LLVM

https://reviews.llvm.org/D22637



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


Re: [PATCH] D16989: Change interpretation of function definition in friend declaration of template class.

2016-07-25 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 65376.
sepavloff added a comment.

Added one more case in shouldLinkDependentDeclWithPrevious


https://reviews.llvm.org/D16989

Files:
  include/clang/Sema/Sema.h
  lib/Sema/SemaDecl.cpp
  test/SemaCXX/PR25848.cpp
  test/SemaCXX/friend2.cpp

Index: test/SemaCXX/friend2.cpp
===
--- /dev/null
+++ test/SemaCXX/friend2.cpp
@@ -0,0 +1,145 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11
+
+// If a friend function is defined in several non-template classes,
+// it is an error.
+
+void func1(int);
+struct C1a {
+  friend void func1(int) {}  // expected-note{{previous definition is here}}
+};
+struct C1b {
+  friend void func1(int) {}  // expected-error{{redefinition of 'func1'}}
+};
+
+
+// If a friend function is defined in both non-template and template
+// classes it is an error only if the template is instantiated.
+
+void func2(int);
+struct C2a {
+  friend void func2(int) {}
+};
+template struct C2b {
+  friend void func2(int) {}
+};
+
+void func3(int);
+struct C3a {
+  friend void func3(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C3b {
+  friend void func3(int) {}  // expected-error{{redefinition of 'func3'}}
+};
+C3b c3;  // expected-note{{in instantiation of template class 'C3b' requested here}}
+
+
+// If a friend function is defined in several template classes it is an error
+// only if several templates are instantiated.
+
+void func4(int);
+template struct C4a {
+  friend void func4(int) {}
+};
+template struct C4b {
+  friend void func4(int) {}
+};
+
+
+void func5(int);
+template struct C5a {
+  friend void func5(int) {}
+};
+template struct C5b {
+  friend void func5(int) {}
+};
+C5a c5a;
+
+void func6(int);
+template struct C6a {
+  friend void func6(int) {}  // expected-note{{previous definition is here}}
+};
+template struct C6b {
+  friend void func6(int) {}  // expected-error{{redefinition of 'func6'}}
+};
+C6a c6a;
+C6b c6b;  // expected-note{{in instantiation of template class 'C6b' requested here}}
+
+void func7(int);
+template struct C7 {
+  friend void func7(int) {}  // expected-error{{redefinition of 'func7'}}
+ // expected-note@-1{{previous definition is here}}
+};
+C7 c7a;
+C7 c7b;  // expected-note{{in instantiation of template class 'C7' requested here}}
+
+
+// Even if clases are not instantiated and hence friend functions defined in them are not
+// available, their declarations can be checked.
+
+void func8(int);  // expected-note{{previous declaration is here}}
+template struct C8a {
+  friend long func8(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func9(int);  // expected-note{{previous declaration is here}}
+template struct C9a {
+  friend int func9(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+void func10(int);  // expected-note{{previous declaration is here}}
+template struct C10a {
+  friend int func10(int);  // expected-error{{functions that differ only in their return type cannot be overloaded}}
+};
+
+
+namespace pr22307 {
+
+struct t {
+  friend int leak(t);
+};
+
+template
+struct m {
+  friend int leak(t) { return sizeof(v); }  // expected-error{{redefinition of 'leak'}} expected-note{{previous definition is here}}
+};
+
+template struct m;
+template struct m;  // expected-note{{in instantiation of template class 'pr22307::m' requested here}}
+
+int main() {
+  leak(t());
+}
+
+}
+
+namespace pr17923 {
+
+void f(unsigned long long);
+
+template struct X {
+  friend void f(unsigned long long) {
+ T t;
+  }
+};
+
+int main() { f(1234); }
+
+}
+
+namespace pr17923a {
+
+int get();
+
+template< int value >
+class set {
+  friend int get()
+{ return value; } // return 0; is OK
+};
+
+template class set< 5 >;
+
+int main() {
+  get();
+}
+
+}
Index: test/SemaCXX/PR25848.cpp
===
--- /dev/null
+++ test/SemaCXX/PR25848.cpp
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A;
+
+inline int g();  // expected-warning{{inline function 'g' is not defined}}
+
+template
+struct R {
+  friend int g() {
+return M;
+  }
+};
+
+void m() {
+  g();  // expected-note{{used here}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8792,6 +8792,49 @@
   return NewFD;
 }
 
+/// \brief Checks if the new declaration declared in dependent context must be
+/// put in the same redeclaration chain as the specified declaration.
+///
+/// \param D Declaration that is checked.
+/// \param PrevDecl Previous declaration found with proper lookup method for the
+/// same declaration name.
+/// \returns True if D must be added to the redeclaration chain which PrevDecl
+///  

Re: [libcxxabi] r276022 - Attempt to bring peace to -Werror buildbots.

2016-07-25 Thread David Blaikie via cfe-commits
Should we fix the diagnostic? Or is the code triggering it just esoteric
enough to not be a good justification for changing the warning?

On Tue, Jul 19, 2016 at 1:42 PM Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Jul 19 15:35:09 2016
> New Revision: 276022
>
> URL: http://llvm.org/viewvc/llvm-project?rev=276022=rev
> Log:
> Attempt to bring peace to -Werror buildbots.
>
> Modified:
> libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp
>
> Modified: libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp?rev=276022=276021=276022=diff
>
> ==
> --- libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp (original)
> +++ libcxxabi/trunk/test/catch_reference_nullptr.pass.cpp Tue Jul 19
> 15:35:09 2016
> @@ -12,6 +12,12 @@
>  #include 
>  #include 
>
> +// Clang emits a warning on converting an object of type nullptr_t to
> bool,
> +// even in generic code. Suppress it.
> +#if defined(__clang__)
> +#pragma clang diagnostic ignored "-Wnull-conversion"
> +#endif
> +
>  struct A {};
>
>  template
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D22767: [OpenCL] Added CLK_ABGR definition for get_image_channel_order return value

2016-07-25 Thread Yaxun Liu via cfe-commits
yaxunl accepted this revision.
yaxunl added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks!


Repository:
  rL LLVM

https://reviews.llvm.org/D22767



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


Re: [PATCH] D22637: [OpenCL] Add extension cl_khr_mipmap_image to clang

2016-07-25 Thread Yaxun Liu via cfe-commits
yaxunl added inline comments.


Comment at: test/Misc/amdgcn.languageOptsOpenCL.cl:188
@@ +187,3 @@
+#endif
+// expected-warning@+6{{unsupported OpenCL extension 'cl_khr_mipmap_image' - 
ignoring}}
+#else

Anastasia wrote:
> Can you move this error message down instead of adding 6 lines offset.
> Also the extension seems to be set by default although it's hard to see 
> without the full diff. So why do you get this warning at all?
This warning is only for opencl version < 200. The extension is supported by 
OpenCL 2.0 and above only.


Repository:
  rL LLVM

https://reviews.llvm.org/D22637



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


Re: [PATCH] D22220: [clang-tidy] Add check 'misc-move-forwarding-reference'

2016-07-25 Thread Etienne Bergeron via cfe-commits
etienneb added a subscriber: etienneb.
etienneb added a comment.

thx for the check



Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:25
@@ +24,3 @@
+  const SourceManager  = Context->getSourceManager();
+  const LangOptions LangOpts = Context->getLangOpts();
+

nit: reference?


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:43-53
@@ +42,13 @@
+// another namespace).
+const StringRef OriginalText =
+Lexer::getSourceText(CallRange, SM, LangOpts);
+if (OriginalText == "::std::move") {
+  Diag << FixItHint::CreateReplacement(CallRange, "::std::" + ForwardName);
+  // If the original text was simply "move", we conservatively still put a
+  // "std::" in front of the "forward". Rationale: Even if the code
+  // apparently had a "using std::move;", that doesn't tell us whether it
+  // also had a "using std::forward;".
+} else if (OriginalText == "std::move" || OriginalText == "move") {
+  Diag << FixItHint::CreateReplacement(CallRange, "std::" + ForwardName);
+}
+  }

alexfh wrote:
> aaron.ballman wrote:
> > I'm not certain I understand the benefit to this. We know it's a call to 
> > std::move() from the standard namespace already, so why do we care about 
> > the original text? I think it's reasonable to replace any call to move() 
> > from the standard namespace with `::std::forward()`, so we should be able 
> > to remove the if statements and not have to go read the original source 
> > text from the source manager (which could involve, for instance, a query 
> > for that text over a slow network).
> I think, the value of this is to maintain consistency with the existing code 
> in terms of whether the `std` namespace should be globally qualified or not. 
> Changing `std::move` to `::std::forward` would sometimes be unwelcome, if the 
> code doesn't use `::std` otherwise.
I agree with alex, it's better to keep code consistency (programmer intend).
But, at the same time, the check should be bomb proof for ugly cases like:
```
  "std:: move"
   ":: std::move",
```

For the moment, the code seems to propose a fix only when it's a known case,
and a warning is emitted in every cases.


Comment at: clang-tidy/misc/MoveForwardingReferenceCheck.cpp:92
@@ +91,3 @@
+  Finder->addMatcher(
+  callExpr(callee(unresolvedLookupExpr().bind("lookup")),
+   argumentCountIs(1),

aaron.ballman wrote:
> It might be a bit more clear if you made `isStdMove()` into a local AST 
> matcher and called it from here.
+1 I agree with Aaron here.

The match will also be more precise.


https://reviews.llvm.org/D0



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


[PATCH] D22767: [OpenCL] Added CLK_ABGR definition for get_image_channel_order return value

2016-07-25 Thread Aaron En Ye Shi via cfe-commits
ashi1 created this revision.
ashi1 added reviewers: yaxunl, Anastasia.
ashi1 added a subscriber: cfe-commits.
ashi1 set the repository for this revision to rL LLVM.

Added CLK_ABGR definition for get_image_channel_order return value inside 
opencl-c.h file

Repository:
  rL LLVM

https://reviews.llvm.org/D22767

Files:
  lib/Headers/opencl-c.h

Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -16493,6 +16493,7 @@
 #define CLK_sRGBA 0x10C1
 #define CLK_sRGBx 0x10C0
 #define CLK_sBGRA 0x10C2
+#define CLK_ABGR  0x10C3
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 int __ovld __cnfn get_image_channel_order(read_only image1d_t image);


Index: lib/Headers/opencl-c.h
===
--- lib/Headers/opencl-c.h
+++ lib/Headers/opencl-c.h
@@ -16493,6 +16493,7 @@
 #define CLK_sRGBA 0x10C1
 #define CLK_sRGBx 0x10C0
 #define CLK_sBGRA 0x10C2
+#define CLK_ABGR  0x10C3
 #endif //__OPENCL_C_VERSION__ >= CL_VERSION_2_0
 
 int __ovld __cnfn get_image_channel_order(read_only image1d_t image);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: r276352 - [Sema] Handle errors during rewriteBuiltinFunctionDecl

2016-07-25 Thread Hans Wennborg via cfe-commits
Actually, I now see the PR doesn't reproduce on 3.9, so this must have
broke after the branch point.

On Fri, Jul 22, 2016 at 7:02 AM, Hans Wennborg  wrote:
> Richard: should we merge this to 3.9?
>
> On Thu, Jul 21, 2016 at 7:03 PM, David Majnemer via cfe-commits
>  wrote:
>> Author: majnemer
>> Date: Thu Jul 21 18:03:43 2016
>> New Revision: 276352
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=276352=rev
>> Log:
>> [Sema] Handle errors during rewriteBuiltinFunctionDecl
>>
>> rewriteBuiltinFunctionDecl can encounter errors when performing
>> DefaultFunctionArrayLvalueConversion.  These errors were not handled
>> which led to a null pointer dereference.
>>
>> This fixes PR28651.
>>
>> Modified:
>> cfe/trunk/lib/Sema/SemaExpr.cpp
>> cfe/trunk/test/Sema/builtins.cl
>>
>> Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=276352=276351=276352=diff
>> ==
>> --- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaExpr.cpp Thu Jul 21 18:03:43 2016
>> @@ -5051,7 +5051,11 @@ static FunctionDecl *rewriteBuiltinFunct
>>for (QualType ParamType : FT->param_types()) {
>>
>>  // Convert array arguments to pointer to simplify type lookup.
>> -Expr *Arg = 
>> Sema->DefaultFunctionArrayLvalueConversion(ArgExprs[i++]).get();
>> +ExprResult ArgRes =
>> +Sema->DefaultFunctionArrayLvalueConversion(ArgExprs[i++]);
>> +if (ArgRes.isInvalid())
>> +  return nullptr;
>> +Expr *Arg = ArgRes.get();
>>  QualType ArgType = Arg->getType();
>>  if (!ParamType->isPointerType() ||
>>  ParamType.getQualifiers().hasAddressSpace() ||
>>
>> Modified: cfe/trunk/test/Sema/builtins.cl
>> URL: 
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/builtins.cl?rev=276352=276351=276352=diff
>> ==
>> --- cfe/trunk/test/Sema/builtins.cl (original)
>> +++ cfe/trunk/test/Sema/builtins.cl Thu Jul 21 18:03:43 2016
>> @@ -1,8 +1,11 @@
>>  // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic
>> -// expected-no-diagnostics
>>
>>  kernel void test(global float *out, global float *in, global int* in2) {
>>out[0] = __builtin_nanf("");
>>__builtin_memcpy(out, in, 32);
>>out[0] = __builtin_frexpf(in[0], in2);
>>  }
>> +
>> +void pr28651() {
>> +  __builtin_alloca(value); // expected-error{{use of undeclared identifier}}
>> +}
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r276655 - [cc1as] Add MCTargetOptions argument to createAsmBackend

2016-07-25 Thread Joel Jones via cfe-commits
Author: joel_k_jones
Date: Mon Jul 25 12:18:44 2016
New Revision: 276655

URL: http://llvm.org/viewvc/llvm-project?rev=276655=rev
Log:
[cc1as] Add MCTargetOptions argument to createAsmBackend

Allow an assembler backend to get ABI options. This is to match the changes
to http://reviews.llvm.org/D16213.

Tested with "make check-clang"

Patch by: Joel Jones

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

Modified:
cfe/trunk/tools/driver/cc1as_main.cpp

Modified: cfe/trunk/tools/driver/cc1as_main.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/cc1as_main.cpp?rev=276655=276654=276655=diff
==
--- cfe/trunk/tools/driver/cc1as_main.cpp (original)
+++ cfe/trunk/tools/driver/cc1as_main.cpp Mon Jul 25 12:18:44 2016
@@ -379,7 +379,8 @@ static bool ExecuteAssembler(AssemblerIn
 MCAsmBackend *MAB = nullptr;
 if (Opts.ShowEncoding) {
   CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
-  MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU);
+  MCTargetOptions Options;
+  MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU, 
Options);
 }
 auto FOut = llvm::make_unique(*Out);
 Str.reset(TheTarget->createAsmStreamer(
@@ -396,8 +397,9 @@ static bool ExecuteAssembler(AssemblerIn
 }
 
 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
+MCTargetOptions Options;
 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
-  Opts.CPU);
+  Opts.CPU, Options);
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
 T, Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,


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


Re: r276361 - Reverting r275115 which caused PR28634.

2016-07-25 Thread Hans Wennborg via cfe-commits
Merged the revert to 3.9 in r276656.

Thanks,
Hans

On Mon, Jul 25, 2016 at 10:02 AM, Pieb, Wolfgang  wrote:
> Yes, it should. I'm just now realizing that the original change got into 3.9.
>
> Thanks,
> Wolfgang
>
>> -Original Message-
>> From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of
>> Hans Wennborg
>> Sent: Monday, July 25, 2016 9:56 AM
>> To: Pieb, Wolfgang
>> Cc: cfe-commits
>> Subject: Re: r276361 - Reverting r275115 which caused PR28634.
>>
>> Should this revert be merged to 3.9?
>>
>> Thanks,
>> Hans
>>
>> On Thu, Jul 21, 2016 at 4:28 PM, Wolfgang Pieb via cfe-commits > comm...@lists.llvm.org> wrote:
>> > Author: wolfgangp
>> > Date: Thu Jul 21 18:28:18 2016
>> > New Revision: 276361
>> >
>> > URL: http://llvm.org/viewvc/llvm-project?rev=276361=rev
>> > Log:
>> > Reverting r275115 which caused PR28634.
>> > When empty (forwarding) basic blocks that are referenced by user
>> > labels are removed, incorrect code may be generated.
>> >
>> >
>> > Removed:
>> > cfe/trunk/test/CodeGen/forwarding-blocks-if.c
>> > Modified:
>> > cfe/trunk/lib/CodeGen/CGStmt.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D16538: [cc1as] Add MCTargetOptions argument to createAsmBackend

2016-07-25 Thread Joel Jones via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276655: [cc1as] Add MCTargetOptions argument to 
createAsmBackend (authored by joel_k_jones).

Changed prior to commit:
  https://reviews.llvm.org/D16538?vs=62793=65374#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D16538

Files:
  cfe/trunk/tools/driver/cc1as_main.cpp

Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -379,7 +379,8 @@
 MCAsmBackend *MAB = nullptr;
 if (Opts.ShowEncoding) {
   CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
-  MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU);
+  MCTargetOptions Options;
+  MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU, 
Options);
 }
 auto FOut = llvm::make_unique(*Out);
 Str.reset(TheTarget->createAsmStreamer(
@@ -396,8 +397,9 @@
 }
 
 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
+MCTargetOptions Options;
 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
-  Opts.CPU);
+  Opts.CPU, Options);
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
 T, Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,


Index: cfe/trunk/tools/driver/cc1as_main.cpp
===
--- cfe/trunk/tools/driver/cc1as_main.cpp
+++ cfe/trunk/tools/driver/cc1as_main.cpp
@@ -379,7 +379,8 @@
 MCAsmBackend *MAB = nullptr;
 if (Opts.ShowEncoding) {
   CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
-  MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU);
+  MCTargetOptions Options;
+  MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple, Opts.CPU, Options);
 }
 auto FOut = llvm::make_unique(*Out);
 Str.reset(TheTarget->createAsmStreamer(
@@ -396,8 +397,9 @@
 }
 
 MCCodeEmitter *CE = TheTarget->createMCCodeEmitter(*MCII, *MRI, Ctx);
+MCTargetOptions Options;
 MCAsmBackend *MAB = TheTarget->createMCAsmBackend(*MRI, Opts.Triple,
-  Opts.CPU);
+  Opts.CPU, Options);
 Triple T(Opts.Triple);
 Str.reset(TheTarget->createMCObjectStreamer(
 T, Ctx, *MAB, *Out, CE, *STI, Opts.RelaxAll,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19815: Support '#pragma once' in headers when using PCH

2016-07-25 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL276653: Support '#pragma once' in headers when using PCH 
(authored by ssrivastava).

Changed prior to commit:
  https://reviews.llvm.org/D19815?vs=57320=65372#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D19815

Files:
  cfe/trunk/lib/Lex/Pragma.cpp
  cfe/trunk/test/PCH/Inputs/pragma-once.h
  cfe/trunk/test/PCH/pragma-once.c

Index: cfe/trunk/test/PCH/Inputs/pragma-once.h
===
--- cfe/trunk/test/PCH/Inputs/pragma-once.h
+++ cfe/trunk/test/PCH/Inputs/pragma-once.h
@@ -0,0 +1,5 @@
+#pragma once
+
+/* For use with the pragma-once.c test */
+
+int x = 3;
Index: cfe/trunk/test/PCH/pragma-once.c
===
--- cfe/trunk/test/PCH/pragma-once.c
+++ cfe/trunk/test/PCH/pragma-once.c
@@ -0,0 +1,13 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/pragma-once.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Including "pragma-once.h" twice, to verify the 'once' aspect is honored.
+#include "Inputs/pragma-once.h"
+#include "Inputs/pragma-once.h"
+int foo(void) { return 0; }
Index: cfe/trunk/lib/Lex/Pragma.cpp
===
--- cfe/trunk/lib/Lex/Pragma.cpp
+++ cfe/trunk/lib/Lex/Pragma.cpp
@@ -352,7 +352,9 @@
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
 ///
 void Preprocessor::HandlePragmaOnce(Token ) {
-  if (isInPrimaryFile()) {
+  // Don't honor the 'once' when handling the primary source file, unless
+  // this is a prefix to a TU, which indicates we're generating a PCH file.
+  if (isInPrimaryFile() && TUKind != TU_Prefix) {
 Diag(OnceTok, diag::pp_pragma_once_in_main_file);
 return;
   }


Index: cfe/trunk/test/PCH/Inputs/pragma-once.h
===
--- cfe/trunk/test/PCH/Inputs/pragma-once.h
+++ cfe/trunk/test/PCH/Inputs/pragma-once.h
@@ -0,0 +1,5 @@
+#pragma once
+
+/* For use with the pragma-once.c test */
+
+int x = 3;
Index: cfe/trunk/test/PCH/pragma-once.c
===
--- cfe/trunk/test/PCH/pragma-once.c
+++ cfe/trunk/test/PCH/pragma-once.c
@@ -0,0 +1,13 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/pragma-once.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Including "pragma-once.h" twice, to verify the 'once' aspect is honored.
+#include "Inputs/pragma-once.h"
+#include "Inputs/pragma-once.h"
+int foo(void) { return 0; }
Index: cfe/trunk/lib/Lex/Pragma.cpp
===
--- cfe/trunk/lib/Lex/Pragma.cpp
+++ cfe/trunk/lib/Lex/Pragma.cpp
@@ -352,7 +352,9 @@
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
 ///
 void Preprocessor::HandlePragmaOnce(Token ) {
-  if (isInPrimaryFile()) {
+  // Don't honor the 'once' when handling the primary source file, unless
+  // this is a prefix to a TU, which indicates we're generating a PCH file.
+  if (isInPrimaryFile() && TUKind != TU_Prefix) {
 Diag(OnceTok, diag::pp_pragma_once_in_main_file);
 return;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r276653 - Support '#pragma once' in headers when using PCH

2016-07-25 Thread Sunil Srivastava via cfe-commits
Author: ssrivastava
Date: Mon Jul 25 12:17:06 2016
New Revision: 276653

URL: http://llvm.org/viewvc/llvm-project?rev=276653=rev
Log:
Support '#pragma once' in headers when using PCH

The '#pragma once' directive was erroneously ignored when encountered
in the header-file specified in generate-PCH-mode. This resulted in
compile-time errors in some cases with legal code, and also a misleading
warning being produced.

Patch by Warren Ristow!

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

Added:
cfe/trunk/test/PCH/Inputs/pragma-once.h
cfe/trunk/test/PCH/pragma-once.c
Modified:
cfe/trunk/lib/Lex/Pragma.cpp

Modified: cfe/trunk/lib/Lex/Pragma.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Pragma.cpp?rev=276653=276652=276653=diff
==
--- cfe/trunk/lib/Lex/Pragma.cpp (original)
+++ cfe/trunk/lib/Lex/Pragma.cpp Mon Jul 25 12:17:06 2016
@@ -352,7 +352,9 @@ void Preprocessor::HandleMicrosoft__prag
 /// HandlePragmaOnce - Handle \#pragma once.  OnceTok is the 'once'.
 ///
 void Preprocessor::HandlePragmaOnce(Token ) {
-  if (isInPrimaryFile()) {
+  // Don't honor the 'once' when handling the primary source file, unless
+  // this is a prefix to a TU, which indicates we're generating a PCH file.
+  if (isInPrimaryFile() && TUKind != TU_Prefix) {
 Diag(OnceTok, diag::pp_pragma_once_in_main_file);
 return;
   }

Added: cfe/trunk/test/PCH/Inputs/pragma-once.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/Inputs/pragma-once.h?rev=276653=auto
==
--- cfe/trunk/test/PCH/Inputs/pragma-once.h (added)
+++ cfe/trunk/test/PCH/Inputs/pragma-once.h Mon Jul 25 12:17:06 2016
@@ -0,0 +1,5 @@
+#pragma once
+
+/* For use with the pragma-once.c test */
+
+int x = 3;

Added: cfe/trunk/test/PCH/pragma-once.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/PCH/pragma-once.c?rev=276653=auto
==
--- cfe/trunk/test/PCH/pragma-once.c (added)
+++ cfe/trunk/test/PCH/pragma-once.c Mon Jul 25 12:17:06 2016
@@ -0,0 +1,13 @@
+// Test this without pch.
+// RUN: %clang_cc1 -include %S/Inputs/pragma-once.h -fsyntax-only -verify %s
+
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -o %t %S/Inputs/pragma-once.h
+// RUN: %clang_cc1 -include-pch %t -fsyntax-only -verify %s
+
+// expected-no-diagnostics
+
+// Including "pragma-once.h" twice, to verify the 'once' aspect is honored.
+#include "Inputs/pragma-once.h"
+#include "Inputs/pragma-once.h"
+int foo(void) { return 0; }


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


Re: r275377 - Use hasFlag instead of hasArg

2016-07-25 Thread David Blaikie via cfe-commits
Ping?

On Mon, Jul 18, 2016 at 11:28 AM David Blaikie  wrote:

> What build problem did this cause? Did this just not compile (it looks as
> if ArgList has hasArg and hasFlag, so I'm not sure what the specific
> problem might've been)
>
> On Wed, Jul 13, 2016 at 11:45 PM Dean Michael Berris via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: dberris
>> Date: Thu Jul 14 01:37:46 2016
>> New Revision: 275377
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=275377=rev
>> Log:
>> Use hasFlag instead of hasArg
>>
>> Summary: Fix the build to use hasFlag instead of hasArg for checking some
>> flags.
>>
>> Reviewers: echristo
>>
>> Subscribers: mehdi_amini, cfe-commits
>>
>> Differential Revision: http://reviews.llvm.org/D22338
>>
>> Modified:
>> cfe/trunk/lib/Driver/Tools.cpp
>>
>> Modified: cfe/trunk/lib/Driver/Tools.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=275377=275376=275377=diff
>>
>> ==
>> --- cfe/trunk/lib/Driver/Tools.cpp (original)
>> +++ cfe/trunk/lib/Driver/Tools.cpp Thu Jul 14 01:37:46 2016
>> @@ -4609,8 +4609,8 @@ void Clang::ConstructJob(Compilation ,
>>
>>Args.AddAllArgs(CmdArgs, options::OPT_finstrument_functions);
>>
>> -  if (Args.hasArg(options::OPT_fxray_instrument,
>> -  options::OPT_fnoxray_instrument, false)) {
>> +  if (Args.hasFlag(options::OPT_fxray_instrument,
>> +   options::OPT_fnoxray_instrument, false)) {
>>  CmdArgs.push_back("-fxray-instrument");
>>  if (Arg *A =
>> Args.getLastArg(options::OPT_fxray_instruction_threshold_,
>>
>> options::OPT_fxray_instruction_threshold_EQ)) {
>>
>>
>> ___
>> cfe-commits mailing list
>> cfe-commits@lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r276650 - Revert "Remove trailing spaces."

2016-07-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Jul 25 12:08:10 2016
New Revision: 276650

URL: http://llvm.org/viewvc/llvm-project?rev=276650=rev
Log:
Revert "Remove trailing spaces."

This reverts commit r276641. Breaks multiple buildbots.

Modified:
clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp?rev=276650=276649=276650=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp Mon Jul 25 
12:08:10 2016
@@ -6,11 +6,11 @@ void charNegativeTest() {
   unsigned char buf;
   MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned char' 
does not match the MPI datatype 'MPI_CHAR' [mpi-type-mismatch]
-
+  
   int buf2;
   MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int' does not 
match the MPI datatype 'MPI_CHAR'
-
+  
   short buf3;
   MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not 
match the MPI datatype 'MPI_CHAR'
@@ -18,7 +18,7 @@ void charNegativeTest() {
   long buf4;
   MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' does not 
match the MPI datatype 'MPI_CHAR'
-
+  
   int8_t buf5;
   MPI_Send(, 1, MPI_CHAR, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not 
match the MPI datatype 'MPI_CHAR'
@@ -40,11 +40,11 @@ void intNegativeTest() {
   unsigned char buf;
   MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned char' 
does not match the MPI datatype 'MPI_INT'
-
+  
   unsigned buf2;
   MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does 
not match the MPI datatype 'MPI_INT'
-
+  
   short buf3;
   MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not 
match the MPI datatype 'MPI_INT'
@@ -52,7 +52,7 @@ void intNegativeTest() {
   long buf4;
   MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'long' does not 
match the MPI datatype 'MPI_INT'
-
+  
   int8_t buf5;
   MPI_Send(, 1, MPI_INT, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not 
match the MPI datatype 'MPI_INT'
@@ -74,11 +74,11 @@ void longNegativeTest() {
   char buf;
   MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'char' does not 
match the MPI datatype 'MPI_LONG'
-
+  
   unsigned buf2;
   MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does 
not match the MPI datatype 'MPI_LONG'
-
+  
   unsigned short buf3;
   MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned short' 
does not match the MPI datatype 'MPI_LONG'
@@ -86,7 +86,7 @@ void longNegativeTest() {
   unsigned long buf4;
   MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned long' 
does not match the MPI datatype 'MPI_LONG'
-
+  
   int8_t buf5;
   MPI_Send(, 1, MPI_LONG, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'int8_t' does not 
match the MPI datatype 'MPI_LONG'
@@ -108,11 +108,11 @@ void int8_tNegativeTest() {
   char buf;
   MPI_Send(, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'char' does not 
match the MPI datatype 'MPI_INT8_T'
-
+  
   unsigned buf2;
   MPI_Send(, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned int' does 
not match the MPI datatype 'MPI_INT8_T'
-
+  
   short buf3;
   MPI_Send(, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'short' does not 
match the MPI datatype 'MPI_INT8_T'
@@ -120,7 +120,7 @@ void int8_tNegativeTest() {
   unsigned long buf4;
   MPI_Send(, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'unsigned long' 
does not match the MPI datatype 'MPI_INT8_T'
-
+  
   uint8_t buf5;
   MPI_Send(, 1, MPI_INT8_T, 0, 0, MPI_COMM_WORLD);
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: buffer type 'uint8_t' does not 
match the MPI datatype 'MPI_INT8_T'
@@ -142,11 +142,11 @@ void complex_c_long_double_complexNegati
   char buf;
   MPI_Send(, 1, MPI_C_LONG_DOUBLE_COMPLEX, 0, 0, 

[clang-tools-extra] r276651 - Revert "MPITypeMismatchCheck for Clang-Tidy"

2016-07-25 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Mon Jul 25 12:08:18 2016
New Revision: 276651

URL: http://llvm.org/viewvc/llvm-project?rev=276651=rev
Log:
Revert "MPITypeMismatchCheck for Clang-Tidy"

This reverts commit r276640. Breaks multiple buildbots.

Removed:
clang-tools-extra/trunk/clang-tidy/mpi/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/mpi/MPITidyModule.cpp
clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp
clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.h
clang-tools-extra/trunk/docs/clang-tidy/checks/mpi-type-mismatch.rst
clang-tools-extra/trunk/test/clang-tidy/Inputs/mpi-type-mismatch/mpimock.h
clang-tools-extra/trunk/test/clang-tidy/mpi-type-mismatch.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/plugin/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/tool/ClangTidyMain.cpp
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/CMakeLists.txt?rev=276651=276650=276651=diff
==
--- clang-tools-extra/trunk/clang-tidy/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/CMakeLists.txt Mon Jul 25 12:08:18 2016
@@ -34,7 +34,6 @@ add_subdirectory(cppcoreguidelines)
 add_subdirectory(google)
 add_subdirectory(misc)
 add_subdirectory(modernize)
-add_subdirectory(mpi)
 add_subdirectory(performance)
 add_subdirectory(readability)
 add_subdirectory(utils)

Removed: clang-tools-extra/trunk/clang-tidy/mpi/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/mpi/CMakeLists.txt?rev=276650=auto
==
--- clang-tools-extra/trunk/clang-tidy/mpi/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/mpi/CMakeLists.txt (removed)
@@ -1,15 +0,0 @@
-set(LLVM_LINK_COMPONENTS support)
-
-add_clang_library(clangTidyMPIModule
-  MPITidyModule.cpp
-  TypeMismatchCheck.cpp
-
-  LINK_LIBS
-  clangAST
-  clangASTMatchers
-  clangBasic
-  clangLex
-  clangTidy
-  clangTidyUtils
-  clangTooling
-  )

Removed: clang-tools-extra/trunk/clang-tidy/mpi/MPITidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/mpi/MPITidyModule.cpp?rev=276650=auto
==
--- clang-tools-extra/trunk/clang-tidy/mpi/MPITidyModule.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/mpi/MPITidyModule.cpp (removed)
@@ -1,37 +0,0 @@
-//===--- MPITidyModule.cpp - clang-tidy 
---===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "../ClangTidy.h"
-#include "../ClangTidyModule.h"
-#include "../ClangTidyModuleRegistry.h"
-#include "TypeMismatchCheck.h"
-
-namespace clang {
-namespace tidy {
-namespace mpi {
-
-class MPIModule : public ClangTidyModule {
-public:
-  void addCheckFactories(ClangTidyCheckFactories ) override {
-CheckFactories.registerCheck("mpi-type-mismatch");
-  }
-};
-
-} // namespace mpi
-
-// Register the MPITidyModule using this statically initialized variable.
-static ClangTidyModuleRegistry::Add
-X("mpi-module", "Adds MPI clang-tidy checks.");
-
-// This anchor is used to force the linker to link in the generated object file
-// and thus register the MPIModule.
-volatile int MPIModuleAnchorSource = 0;
-
-} // namespace tidy
-} // namespace clang

Removed: clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp?rev=276650=auto
==
--- clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/mpi/TypeMismatchCheck.cpp (removed)
@@ -1,328 +0,0 @@
-//===--- TypeMismatchCheck.cpp - 
clang-tidy===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-
-#include "TypeMismatchCheck.h"
-#include "clang/StaticAnalyzer/Checkers/MPIFunctionClassifier.h"
-#include "clang/Lex/Lexer.h"
-#include "clang/Tooling/FixIt.h"
-#include 
-#include 
-
-using namespace clang::ast_matchers;
-
-namespace clang {
-namespace tidy {
-namespace mpi {
-
-/// Check if a BuiltinType::Kind matches the MPI datatype.
-///
-/// 

Re: [PATCH] D20811: [analyzer] Model some library functions

2016-07-25 Thread Artem Dergachev via cfe-commits
NoQ added inline comments.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:191
@@ +190,3 @@
+// impossible to verify this precisely, but at least
+// this check avoids potential crashes.
+bool matchesCall(const CallExpr *CE) const;

zaks.anna wrote:
> Do we need to talk about crashes when describing what this does?
> Also, please, use oxygen throughout.
Added more comments below.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:205
@@ +204,3 @@
+  }
+  static QualType getArgType(const CallEvent , ArgNoTy ArgNo) {
+return ArgNo == Ret ? Call.getResultType().getCanonicalType()

zaks.anna wrote:
> We could either provide these APIs in CallEvent or at least have variants 
> that return canonical types. Maybe we already do some of that?
Maybe a separate commit? There are quite a few checkers from which the 
`.getArgExpr(N)->getType()` pattern could be de-duplicated, but i don't think 
many of them are interested in canonical types.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:445
@@ +444,3 @@
+
+  const FunctionSpecTy  = FSMI->second;
+  if (!Spec.matchesCall(CE))

zaks.anna wrote:
> When can this go wrong? Are we checking if there is a mismatch between the 
> function declaration and the call expression? It is strange that 
> findFunctionSpec takes both of those. Couldn't you always get FunctionDecl 
> out of CallExpr?
Callee decl is path-sensitive information because functions can be passed 
around by pointers, as mentioned in the comment at the beginning of the 
function. Expanded the comment, added a test.


Comment at: lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp:508
@@ +507,3 @@
+  FunctionSpecMap = {
+// The isascii() family of functions.
+{ "isalnum",

zaks.anna wrote:
> you could also use /*NameOfTheField*/ convention to name the arguments if 
> that would make this map more readable.
I think compactness is worth it here, and specs are pretty easy to remember, 
imho. Added an example to the first spec to see how it looks and make it easier 
for the reader to adapt and remember, but i'm not quite convinced that 
verbosity is worth it here.


Comment at: test/Analysis/std-library-functions.c:3
@@ +2,3 @@
+
+void clang_analyzer_eval(int);
+int glob;

zaks.anna wrote:
> Why are you not testing all of the functions?
I was too bored to generate tests for all branches of all functions (and if i 
auto-generate such tests, it defeats the purpose), but i added some of the more 
creative tests and covered at least some branches of all functions with them.


https://reviews.llvm.org/D20811



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


Re: [PATCH] D20811: [analyzer] Model some library functions

2016-07-25 Thread Artem Dergachev via cfe-commits
NoQ updated this revision to Diff 65369.
NoQ marked 4 inline comments as done.

https://reviews.llvm.org/D20811

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/StdLibraryFunctionsChecker.cpp
  test/Analysis/std-library-functions.c
  test/Analysis/std-library-functions.cpp

Index: test/Analysis/std-library-functions.cpp
===
--- /dev/null
+++ test/Analysis/std-library-functions.cpp
@@ -0,0 +1,14 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.StdLibraryFunctions,debug.ExprInspection -verify %s
+
+// Test that we don't model functions with broken prototypes.
+// Because they probably work differently as well.
+//
+// This test lives in a separate file because we wanted to test all functions
+// in the .c file, however in C there are no overloads.
+
+void clang_analyzer_eval(bool);
+bool isalpha(char);
+
+void test() {
+  clang_analyzer_eval(isalpha('A')); // no-crash // expected-warning{{UNKNOWN}}
+}
Index: test/Analysis/std-library-functions.c
===
--- /dev/null
+++ test/Analysis/std-library-functions.c
@@ -0,0 +1,184 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=unix.StdLibraryFunctions,debug.ExprInspection -verify %s
+
+void clang_analyzer_eval(int);
+
+int glob;
+
+typedef struct FILE FILE;
+#define EOF -1
+
+int getc(FILE *);
+void test_getc(FILE *fp) {
+  int x;
+  while ((x = getc(fp)) != EOF) {
+clang_analyzer_eval(x > 255); // expected-warning{{FALSE}}
+clang_analyzer_eval(x >= 0); // expected-warning{{TRUE}}
+  }
+}
+
+int fgetc(FILE *);
+void test_fgets(FILE *fp) {
+  clang_analyzer_eval(fgetc(fp) < 256); // expected-warning{{TRUE}}
+  clang_analyzer_eval(fgetc(fp) >= 0); // expected-warning{{UNKNOWN}}
+}
+
+
+typedef unsigned long size_t;
+typedef signed long ssize_t;
+ssize_t read(int, void *, size_t);
+ssize_t write(int, const void *, size_t);
+void test_read_write(int fd, char *buf) {
+  glob = 1;
+  ssize_t x = write(fd, buf, 10);
+  clang_analyzer_eval(glob); // expected-warning{{UNKNOWN}}
+  if (x >= 0) {
+clang_analyzer_eval(x <= 10); // expected-warning{{TRUE}}
+ssize_t y = read(fd, , sizeof(glob));
+if (y >= 0) {
+  clang_analyzer_eval(y <= sizeof(glob)); // expected-warning{{TRUE}}
+} else {
+  // -1 overflows on promotion!
+  clang_analyzer_eval(y <= sizeof(glob)); // expected-warning{{FALSE}}
+}
+  } else {
+clang_analyzer_eval(x == -1); // expected-warning{{TRUE}}
+  }
+}
+
+size_t fread(void *, size_t, size_t, FILE *);
+size_t fwrite(const void *restrict, size_t, size_t, FILE *restrict);
+void test_fread_fwrite(FILE *fp, int *buf) {
+  size_t x = fwrite(buf, sizeof(int), 10, fp);
+  clang_analyzer_eval(x <= 10); // expected-warning{{TRUE}}
+  size_t y = fread(buf, sizeof(int), 10, fp);
+  clang_analyzer_eval(y <= 10); // expected-warning{{TRUE}}
+  size_t z = fwrite(buf, sizeof(int), y, fp);
+  // FIXME: should be TRUE once symbol-symbol constraint support is improved.
+  clang_analyzer_eval(z <= y); // expected-warning{{UNKNOWN}}
+}
+
+ssize_t getline(char **, size_t *, FILE *);
+void test_getline(FILE *fp) {
+  char *line = 0;
+  size_t n = 0;
+  ssize_t len;
+  while ((len = getline(, , fp)) != -1) {
+clang_analyzer_eval(len == 0); // expected-warning{{FALSE}}
+  }
+}
+
+int isascii(int);
+void test_isascii(int x) {
+  clang_analyzer_eval(isascii(123)); // expected-warning{{TRUE}}
+  clang_analyzer_eval(isascii(-1)); // expected-warning{{FALSE}}
+  if (isascii(x)) {
+clang_analyzer_eval(x < 128); // expected-warning{{TRUE}}
+clang_analyzer_eval(x >= 0); // expected-warning{{TRUE}}
+  } else {
+if (x > 42)
+  clang_analyzer_eval(x >= 128); // expected-warning{{TRUE}}
+else
+  clang_analyzer_eval(x < 0); // expected-warning{{TRUE}}
+  }
+  glob = 1;
+  isascii('a');
+  clang_analyzer_eval(glob); // expected-warning{{TRUE}}
+}
+
+int islower(int);
+void test_islower(int x) {
+  clang_analyzer_eval(islower('x')); // expected-warning{{TRUE}}
+  clang_analyzer_eval(islower('X')); // expected-warning{{FALSE}}
+  if (islower(x))
+clang_analyzer_eval(x < 'a'); // expected-warning{{FALSE}}
+}
+
+int getchar(void);
+void test_getchar() {
+  int x = getchar();
+  if (x == EOF)
+return;
+  clang_analyzer_eval(x < 0); // expected-warning{{FALSE}}
+  clang_analyzer_eval(x < 256); // expected-warning{{TRUE}}
+}
+
+int isalpha(int);
+void test_isalpha() {
+  clang_analyzer_eval(isalpha(']')); // expected-warning{{FALSE}}
+  clang_analyzer_eval(isalpha('Q')); // expected-warning{{TRUE}}
+  clang_analyzer_eval(isalpha(128)); // expected-warning{{UNKNOWN}}
+}
+
+int isalnum(int);
+void test_alnum() {
+  clang_analyzer_eval(isalnum('1')); // expected-warning{{TRUE}}
+  clang_analyzer_eval(isalnum(')')); // expected-warning{{FALSE}}
+}
+
+int isblank(int);
+void test_isblank() {
+  

Re: [PATCH] D22463: [RFC] Moving to GitHub Proposal: NOT DECISION!

2016-07-25 Thread Chris Bieneman via cfe-commits
beanz added a subscriber: beanz.
beanz added a comment.

@rengolin, thank you for putting this all together. It is very well thought 
out, and I really like the shape it took. I have a few minor nitpick comments 
inline.

Thanks,
-Chris



Comment at: docs/Proposals/GitHub.rst:58
@@ +57,3 @@
+
+Git is also the version control most LLVM developers use. Despite the sources
+being stored in an SVN server, most people develop using the Git-SVN 
integration,

Not to be pedantic here, but do we actually /know/ that most LLVM developers 
use Git? I suspect that most do, but I don't think we actually have any 
metrics, so we should avoid using declarative language here. Maybe change 
'most' to 'many' here and below.


Comment at: docs/Proposals/GitHub.rst:87
@@ +86,3 @@
+for example development meetings, sponsoring disadvantaged people to work on
+compilers and foster diversity and equality in our community.
+

In lists you should generally keep the same verb conjugations. Maybe repharse 
this list to something more like:


> ... hosting developer meetings, sponsoring disadvantaged people... and 
> fostering diversity and equality in our community.




https://reviews.llvm.org/D22463



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


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

2016-07-25 Thread Krzysztof Parzyszek via cfe-commits
kparzysz created this revision.
kparzysz added reviewers: t.p.northover, echristo.
kparzysz added a subscriber: cfe-commits.
kparzysz set the repository for this revision to rL LLVM.
Herald added subscribers: mehdi_amini, aemerson.

Make -mlong-calls a general (i.e. non ARM-specific) option.

Repository:
  rL LLVM

https://reviews.llvm.org/D22766

Files:
  include/clang/Driver/Options.td
  lib/Basic/Targets.cpp
  lib/Driver/Tools.cpp
  test/Driver/hexagon-long-calls.c

Index: test/Driver/hexagon-long-calls.c
===
--- /dev/null
+++ test/Driver/hexagon-long-calls.c
@@ -0,0 +1,15 @@
+// RUN: %clang -target hexagon -### %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-DEFAULT
+
+// RUN: %clang -target hexagon -### -mlong-calls %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-LONG-CALLS
+
+// RUN: %clang -target hexagon -### -mlong-calls -mno-long-calls %s 2>&1 \
+// RUN:| FileCheck %s -check-prefix CHECK-NO-LONG-CALLS
+
+// CHECK-DEFAULT-NOT: "-target-feature" "+long-calls"
+
+// CHECK-LONG-CALLS: "-target-feature" "+long-calls"
+
+// CHECK-NO-LONG-CALLS-NOT: "-target-feature" "+long-calls"
+
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -2536,28 +2536,17 @@
 
 static void getHexagonTargetFeatures(const ArgList ,
  std::vector ) {
-  bool HasHVX = false, HasHVXD = false;
-
-  // FIXME: This should be able to use handleTargetFeaturesGroup except it is
-  // doing dependent option handling here rather than in initFeatureMap or a
-  // similar handler.
-  for (auto  : Args) {
-auto  = A->getOption();
-if (Opt.matches(options::OPT_mhexagon_hvx))
-  HasHVX = true;
-else if (Opt.matches(options::OPT_mno_hexagon_hvx))
-  HasHVXD = HasHVX = false;
-else if (Opt.matches(options::OPT_mhexagon_hvx_double))
-  HasHVXD = HasHVX = true;
-else if (Opt.matches(options::OPT_mno_hexagon_hvx_double))
-  HasHVXD = false;
-else
-  continue;
-A->claim();
+  handleTargetFeaturesGroup(Args, Features,
+options::OPT_m_hexagon_Features_Group);
+
+  bool UseLongCalls = false;
+  if (Arg *A = Args.getLastArg(options::OPT_mlong_calls,
+   options::OPT_mno_long_calls)) {
+if (A->getOption().matches(options::OPT_mlong_calls))
+  UseLongCalls = true;
   }
 
-  Features.push_back(HasHVX  ? "+hvx" : "-hvx");
-  Features.push_back(HasHVXD ? "+hvx-double" : "-hvx-double");
+  Features.push_back(UseLongCalls ? "+long-calls" : "-long-calls");
 }
 
 static void getWebAssemblyTargetFeatures(const ArgList ,
Index: lib/Basic/Targets.cpp
===
--- lib/Basic/Targets.cpp
+++ lib/Basic/Targets.cpp
@@ -6079,6 +6079,7 @@
   static const TargetInfo::GCCRegAlias GCCRegAliases[];
   std::string CPU;
   bool HasHVX, HasHVXDouble;
+  bool UseLongCalls;
 
 public:
   HexagonTargetInfo(const llvm::Triple , const TargetOptions &)
@@ -6103,6 +6104,7 @@
 UseBitFieldTypeAlignment = true;
 ZeroLengthBitfieldBoundary = 32;
 HasHVX = HasHVXDouble = false;
+UseLongCalls = false;
   }
 
   ArrayRef getTargetBuiltins() const override {
@@ -6137,15 +6139,19 @@
   .Case("hexagon", true)
   .Case("hvx", HasHVX)
   .Case("hvx-double", HasHVXDouble)
+  .Case("long-calls", UseLongCalls)
   .Default(false);
   }
 
+  bool handleTargetFeatures(std::vector ,
+DiagnosticsEngine ) override;
+
   bool initFeatureMap(llvm::StringMap , DiagnosticsEngine ,
 StringRef CPU, const std::vector )
 const override;
 
-  bool handleTargetFeatures(std::vector ,
-DiagnosticsEngine ) override;
+  void setFeatureEnabled(llvm::StringMap , StringRef Name,
+ bool Enabled) const override;
 
   BuiltinVaListKind getBuiltinVaListKind() const override {
 return TargetInfo::CharPtrBuiltinVaList;
@@ -6226,6 +6232,11 @@
   HasHVX = HasHVXDouble = true;
 else if (F == "-hvx-double")
   HasHVXDouble = false;
+
+if (F == "+long-calls")
+  UseLongCalls = true;
+else if (F == "-long-calls")
+  UseLongCalls = false;
   }
   return true;
 }
@@ -6236,10 +6247,23 @@
   // Default for v60: -hvx, -hvx-double.
   Features["hvx"] = false;
   Features["hvx-double"] = false;
+  Features["long-calls"] = false;
 
   return TargetInfo::initFeatureMap(Features, Diags, CPU, FeaturesVec);
 }
 
+void HexagonTargetInfo::setFeatureEnabled(llvm::StringMap ,
+  StringRef Name, bool Enabled) const {
+  if (Enabled) {
+if (Name == "hvx-double")
+  Features["hvx"] = true;
+  } else {
+if (Name == "hvx")
+  Features["hvx-double"] = false;
+  }
+  Features[Name] = Enabled;
+}
+
 
 const char *const HexagonTargetInfo::GCCRegNames[] = {
   "r0", "r1", "r2", "r3", "r4", 

RE: r276361 - Reverting r275115 which caused PR28634.

2016-07-25 Thread Pieb, Wolfgang via cfe-commits
Yes, it should. I'm just now realizing that the original change got into 3.9.

Thanks,
Wolfgang

> -Original Message-
> From: hwennb...@google.com [mailto:hwennb...@google.com] On Behalf Of
> Hans Wennborg
> Sent: Monday, July 25, 2016 9:56 AM
> To: Pieb, Wolfgang
> Cc: cfe-commits
> Subject: Re: r276361 - Reverting r275115 which caused PR28634.
> 
> Should this revert be merged to 3.9?
> 
> Thanks,
> Hans
> 
> On Thu, Jul 21, 2016 at 4:28 PM, Wolfgang Pieb via cfe-commits  comm...@lists.llvm.org> wrote:
> > Author: wolfgangp
> > Date: Thu Jul 21 18:28:18 2016
> > New Revision: 276361
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=276361=rev
> > Log:
> > Reverting r275115 which caused PR28634.
> > When empty (forwarding) basic blocks that are referenced by user
> > labels are removed, incorrect code may be generated.
> >
> >
> > Removed:
> > cfe/trunk/test/CodeGen/forwarding-blocks-if.c
> > Modified:
> > cfe/trunk/lib/CodeGen/CGStmt.cpp
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


  1   2   >