[PATCH] D22997: [cxx1z-constexpr-lambda] Make conversion function constexpr, and teach the expression-evaluator to evaluate the static-invoker.

2016-07-30 Thread Faisal Vali via cfe-commits
faisalv created this revision.
faisalv added reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, 
erik.pilkington.
faisalv added a subscriber: cfe-commits.
faisalv set the repository for this revision to rL LLVM.
faisalv added a project: clang-c.


This patch enables the following code:

  auto L = [](int i) { return i; };
  constexpr int (*fpi)(int) = L;
  static_assert(fpi(3) == 3);


Repository:
  rL LLVM

https://reviews.llvm.org/D22997

Files:
  lib/AST/ExprConstant.cpp
  lib/Sema/SemaLambda.cpp
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Index: test/SemaCXX/cxx1z-constexpr-lambdas.cpp
===
--- test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -46,5 +46,31 @@
 
 } // end ns test_constexpr_call
 
+
+namespace test_conversion_function_for_non_capturing_lambdas {
+
+namespace ns1 {
+auto L = [](int i) { return i; };
+constexpr int (*fpi)(int) = L;
+static_assert(fpi(3) == 3);
+auto GL = [](auto a) { return a; };
+
+constexpr char (*fp2)(char) = GL;
+constexpr double (*fp3)(double) = GL;
+constexpr const char* (*fp4)(const char*) = GL;
+static_assert(fp2('3') == '3');
+static_assert(fp3(3.14) == 3.14);
+constexpr const char *Str = "abc";
+static_assert(fp4(Str) == Str);
+
+auto NCL = [](int i) { static int j; return j; }; //expected-note{{declared here}}
+constexpr int (*fp5)(int) = NCL;
+constexpr int I = //expected-error{{must be initialized by a constant expression}}
+  fp5(5); //expected-note{{non-constexpr function}}
+
+} // end ns1
+
+} // end ns test_conversion_function_for_non_capturing_lambdas
+
 #endif // ndef CPP14_AND_EARLIER
 
Index: lib/Sema/SemaLambda.cpp
===
--- lib/Sema/SemaLambda.cpp
+++ lib/Sema/SemaLambda.cpp
@@ -1263,7 +1263,7 @@
 ConvTy, 
 ConvTSI,
 /*isInline=*/true, /*isExplicit=*/false,
-/*isConstexpr=*/false, 
+/*isConstexpr=*/S.getLangOpts().CPlusPlus1z, 
 CallOperator->getBody()->getLocEnd());
   Conversion->setAccess(AS_public);
   Conversion->setImplicit(true);
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -4386,6 +4386,10 @@
  Call.getLValueBase().dyn_cast());
   if (!FD)
 return Error(Callee);
+  
+  // Don't call function pointers which have been cast to some other type.
+  if (!Info.Ctx.hasSameType(CalleeType->getPointeeType(), FD->getType()))
+return Error(E);
 
   // Overloaded operator calls to member functions are represented as normal
   // calls with '*this' as the first argument.
@@ -4401,11 +4405,36 @@
   return false;
 This = &ThisVal;
 Args = Args.slice(1);
+  } else if (MD && MD->isLambdaStaticInvoker()) {
+   
+// Map the static invoker for the lambda back to the call operator.
+// Conveniently, we don't have to slice out the 'this' argument (as is
+// being done for the non-static case), since a static member function
+// doesn't have an implicit argument passed in.
+const CXXRecordDecl *ClosureClass = MD->getParent();
+ // number of captures better be zero.
+assert(std::distance(ClosureClass->captures_begin(),
+ ClosureClass->captures_end()) == 0);
+const CXXMethodDecl *LambdaCallOp = ClosureClass->getLambdaCallOperator();
+
+// Set 'FD', the function that will be called below, to the call
+// operator.  If the closure object represents a generic lambda, find
+// the corresponding specialization of the call operator.
+
+if (ClosureClass->isGenericLambda()) {
+  assert(MD->isFunctionTemplateSpecialization());
+  const TemplateArgumentList *TAL = MD->getTemplateSpecializationArgs();
+  FunctionTemplateDecl *CallOpTemplate =
+  LambdaCallOp->getDescribedFunctionTemplate();
+  void *InsertPos = nullptr;
+  FunctionDecl *CorrespondingCallOpSpecialization =
+  CallOpTemplate->findSpecialization(TAL->asArray(), InsertPos);
+  assert(CorrespondingCallOpSpecialization);
+  FD = cast(CorrespondingCallOpSpecialization);
+} else
+  FD = LambdaCallOp;
   }
-
-  // Don't call function pointers which have been cast to some other type.
-  if (!Info.Ctx.hasSameType(CalleeType->getPointeeType(), FD->getType()))
-return Error(E);
+  
 } else
   return Error(E);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r277287 - [NFC] Rearrange an example-file so the c++14 specific example is on top.

2016-07-30 Thread Faisal Vali via cfe-commits
Author: faisalv
Date: Sat Jul 30 20:19:17 2016
New Revision: 277287

URL: http://llvm.org/viewvc/llvm-project?rev=277287&view=rev
Log:
[NFC] Rearrange an example-file so the c++14 specific example is on top.

This makes it easier to add C++1z examples to the bottom, just before the 
#endif.

Modified:
cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Modified: cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp?rev=277287&r1=277286&r2=277287&view=diff
==
--- cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp (original)
+++ cfe/trunk/test/SemaCXX/cxx1z-constexpr-lambdas.cpp Sat Jul 30 20:19:17 2016
@@ -2,6 +2,17 @@
 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks 
-fdelayed-template-parsing %s 
 // RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -fblocks %s 
-DCPP14_AND_EARLIER
 
+
+namespace test_lambda_is_literal {
+#ifdef CPP14_AND_EARLIER
+//expected-error@+4{{not a literal type}}
+//expected-note@+2{{not an aggregate and has no constexpr constructors}}
+#endif
+auto L = [] { };
+constexpr int foo(decltype(L) l) { return 0; }
+
+}
+
 #ifndef CPP14_AND_EARLIER
 namespace test_constexpr_checking {
 
@@ -35,14 +46,5 @@ namespace ns3 {
 
 } // end ns test_constexpr_call
 
-#endif
-
-namespace test_lambda_is_literal {
-#ifdef CPP14_AND_EARLIER
-//expected-error@+4{{not a literal type}}
-//expected-note@+2{{not an aggregate and has no constexpr constructors}}
-#endif
-auto L = [] { };
-constexpr int foo(decltype(L) l) { return 0; }
+#endif // ndef CPP14_AND_EARLIER
 
-}
\ No newline at end of file


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


[PATCH] D22996: [cxx1z-constexpr-lambda] Implement constant evaluation of non-capturing lambda expressions.

2016-07-30 Thread Faisal Vali via cfe-commits
faisalv created this revision.
faisalv added reviewers: rsmith, hubert.reinterpretcast, aaron.ballman, 
erik.pilkington.
faisalv added a subscriber: cfe-commits.
faisalv set the repository for this revision to rL LLVM.
faisalv added a project: clang-c.

Add a visitor for lambda expressions to RecordExprEvaluator in ExprConstant.cpp 
that creates an empty APValue Struct - thus supporting the following code:

constexpr auto ID = [] (auto a) { return a; };
static_assert(ID(3.14) == 3.14);




Repository:
  rL LLVM

https://reviews.llvm.org/D22996

Files:
  lib/AST/ExprConstant.cpp
  test/SemaCXX/cxx1z-constexpr-lambdas.cpp

Index: test/SemaCXX/cxx1z-constexpr-lambdas.cpp
===
--- test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -2,6 +2,16 @@
 // RUN: %clang_cc1 -std=c++1z -verify -fsyntax-only -fblocks -fdelayed-template-parsing %s 
 // RUN: %clang_cc1 -std=c++14 -verify -fsyntax-only -fblocks %s -DCPP14_AND_EARLIER
 
+namespace test_lambda_is_literal {
+#ifdef CPP14_AND_EARLIER
+//expected-error@+4{{not a literal type}}
+//expected-note@+2{{not an aggregate and has no constexpr constructors}}
+#endif
+auto L = [] { };
+constexpr int foo(decltype(L) l) { return 0; }
+}
+
+
 #ifndef CPP14_AND_EARLIER
 namespace test_constexpr_checking {
 
@@ -35,14 +45,73 @@
 
 } // end ns test_constexpr_call
 
-#endif
 
-namespace test_lambda_is_literal {
-#ifdef CPP14_AND_EARLIER
-//expected-error@+4{{not a literal type}}
-//expected-note@+2{{not an aggregate and has no constexpr constructors}}
-#endif
-auto L = [] { };
-constexpr int foo(decltype(L) l) { return 0; }
+namespace test_lambda_is_cce {
+namespace ns1_simple_lambda {
 
-}
\ No newline at end of file
+namespace ns1 {
+constexpr auto f(int i) {
+  double d = 3.14;
+  auto L = [=](auto a) { 
+int Isz = sizeof(i);
+return sizeof(i) + sizeof(a) + sizeof(d); 
+  };
+  int I = L("abc") + L(nullptr);
+  return L;
+}
+constexpr auto L = f(3);
+constexpr auto M =  L("abc") + L(nullptr);
+
+static_assert(M == sizeof(int) * 2 + sizeof(double) * 2 + sizeof(nullptr) + sizeof(const char*));
+
+} // end ns1
+
+namespace ns2 {
+constexpr auto f(int i) {
+  auto L = [](auto a) { return a + a; };
+  return L;
+}
+constexpr auto L = f(3);
+constexpr int I = L(6);
+static_assert(I == 12);
+} // end ns2
+
+namespace contained_lambdas_call_operator_is_not_constexpr {
+constexpr auto f(int i) {
+  double d = 3.14;
+  auto L = [=](auto a) { //expected-note{{declared here}}
+int Isz = sizeof(i);
+asm("hello");
+return sizeof(i) + sizeof(a) + sizeof(d); 
+  };
+  return L;
+}
+
+constexpr auto L = f(3);
+
+constexpr auto M =  // expected-error{{must be initialized by}} 
+L("abc"); //expected-note{{non-constexpr function}}
+
+} // end ns contained_lambdas_call_operator_is_not_constexpr
+
+
+
+} // end ns1_simple_lambda
+
+namespace ns1_unimplemented {
+namespace ns1_captures {
+constexpr auto f(int i) {
+  double d = 3.14;
+  auto L = [=](auto a) { //expected-note{{coming soon}}
+int Isz = i + d;
+return sizeof(i) + sizeof(a) + sizeof(d); 
+  };
+  return L;
+}
+constexpr auto M = f(3);  //expected-error{{constant expression}} expected-note{{in call to}}
+} // end ns1_captures
+} // end ns1_unimplemented 
+
+} // end ns test_lambda_is_cce
+
+#endif // ndef CPP14_AND_EARLIER
Index: lib/AST/ExprConstant.cpp
===
--- lib/AST/ExprConstant.cpp
+++ lib/AST/ExprConstant.cpp
@@ -5433,6 +5433,7 @@
 bool VisitCXXConstructExpr(const CXXConstructExpr *E) {
   return VisitCXXConstructExpr(E, E->getType());
 }
+bool VisitLambdaExpr(const LambdaExpr *E);
 bool VisitCXXInheritedCtorInitExpr(const CXXInheritedCtorInitExpr *E);
 bool VisitCXXConstructExpr(const CXXConstructExpr *E, QualType T);
 bool VisitCXXStdInitializerListExpr(const CXXStdInitializerListExpr *E);
@@ -5764,6 +5765,21 @@
   return true;
 }
 
+bool RecordExprEvaluator::VisitLambdaExpr(const LambdaExpr *E) {
+  const CXXRecordDecl *ClosureClass = E->getLambdaClass();
+  if (ClosureClass->isInvalidDecl()) return false;
+
+  if (Info.checkingPotentialConstantExpression()) return true;
+  if (E->capture_size()) {
+Info.FFDiag(E, diag::note_unimplemented_constexpr_lambda_feature_ast)
+<< "can not evaluate lambda expressions with captures";
+return false;
+  }
+  // FIXME: Implement captures.
+  Result = APValue(APValue::UninitStruct(), /*NumBases*/0, /*NumFields*/0);
+  return true;
+}
+
 static bool EvaluateRecord(const Expr *E, const LValue &This,
APValue &Result, EvalInfo &Info) {
   assert(E->isRValue() && E->getType()->isRecordType() &&
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r277286 - Reapply r276069 with workaround for MSVC 2013

2016-07-30 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Sat Jul 30 17:33:34 2016
New Revision: 277286

URL: http://llvm.org/viewvc/llvm-project?rev=277286&view=rev
Log:
Reapply r276069 with workaround for MSVC 2013

Modified:
cfe/trunk/include/clang/AST/DeclTemplate.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/DeclTemplate.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateDeduction.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/include/clang/AST/DeclTemplate.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclTemplate.h?rev=277286&r1=277285&r2=277286&view=diff
==
--- cfe/trunk/include/clang/AST/DeclTemplate.h (original)
+++ cfe/trunk/include/clang/AST/DeclTemplate.h Sat Jul 30 17:33:34 2016
@@ -46,7 +46,8 @@ typedef llvm::PointerUnion3 {
+: private llvm::TrailingObjects {
 
   /// The location of the 'template' keyword.
   SourceLocation TemplateLoc;
@@ -56,26 +57,36 @@ class TemplateParameterList final
 
   /// The number of template parameters in this template
   /// parameter list.
-  unsigned NumParams : 31;
+  unsigned NumParams : 30;
 
   /// Whether this template parameter list contains an unexpanded parameter
   /// pack.
   unsigned ContainsUnexpandedParameterPack : 1;
 
+  /// Whether this template parameter list has an associated requires-clause
+  unsigned HasRequiresClause : 1;
+
 protected:
   size_t numTrailingObjects(OverloadToken) const {
 return NumParams;
   }
 
+  size_t numTrailingObjects(OverloadToken) const {
+return HasRequiresClause;
+  }
+
   TemplateParameterList(SourceLocation TemplateLoc, SourceLocation LAngleLoc,
-ArrayRef Params, SourceLocation 
RAngleLoc);
+ArrayRef Params, SourceLocation RAngleLoc,
+Expr *RequiresClause);
 
 public:
+  // FIXME: remove default argument for RequiresClause
   static TemplateParameterList *Create(const ASTContext &C,
SourceLocation TemplateLoc,
SourceLocation LAngleLoc,
ArrayRef Params,
-   SourceLocation RAngleLoc);
+   SourceLocation RAngleLoc,
+   Expr *RequiresClause = nullptr);
 
   /// \brief Iterates through the template parameters in this list.
   typedef NamedDecl** iterator;
@@ -127,6 +138,16 @@ public:
 return ContainsUnexpandedParameterPack;
   }
 
+  /// \brief The constraint-expression of the associated requires-clause.
+  Expr *getRequiresClause() {
+return HasRequiresClause ? *getTrailingObjects() : nullptr;
+  }
+
+  /// \brief The constraint-expression of the associated requires-clause.
+  const Expr *getRequiresClause() const {
+return HasRequiresClause ? *getTrailingObjects() : nullptr;
+  }
+
   SourceLocation getTemplateLoc() const { return TemplateLoc; }
   SourceLocation getLAngleLoc() const { return LAngleLoc; }
   SourceLocation getRAngleLoc() const { return RAngleLoc; }
@@ -136,36 +157,37 @@ public:
   }
 
   friend TrailingObjects;
-  template  friend class FixedSizeTemplateParameterListStorage;
+
+  template 
+  friend class FixedSizeTemplateParameterListStorage;
+
+public:
+  // FIXME: workaround for MSVC 2013; remove when no longer needed
+  using FixedSizeStorageOwner = TrailingObjects::FixedSizeStorageOwner;
 };
 
-/// \brief Stores a list of template parameters for a TemplateDecl and its
-/// derived classes. Suitable for creating on the stack.
-template  class FixedSizeTemplateParameterListStorage {
-  // This is kinda ugly: TemplateParameterList usually gets allocated
-  // in a block of memory with NamedDecls appended to it. Here, to get
-  // it stack allocated, we include the params as a separate
-  // variable. After allocation, the TemplateParameterList object
-  // treats them as part of itself.
-  TemplateParameterList List;
-  NamedDecl *Params[N];
+/// \brief Stores a list of template parameters and the associated
+/// requires-clause (if any) for a TemplateDecl and its derived classes.
+/// Suitable for creating on the stack.
+template 
+class FixedSizeTemplateParameterListStorage
+: public TemplateParameterList::FixedSizeStorageOwner {
+  typename TemplateParameterList::FixedSizeStorage<
+  NamedDecl *, Expr *>::with_counts<
+  N, HasRequiresClause ? 1u : 0u
+  >::type storage;
 
 public:
   FixedSizeTemplateParameterListStorage(SourceLocation TemplateLoc,
 SourceLocation LAngleLoc,
 ArrayRef Params,
-SourceLocation RAngl

r277277 - Correcting some sphinx formatting issues so that the attribute documentation builds again.

2016-07-30 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Sat Jul 30 15:20:03 2016
New Revision: 277277

URL: http://llvm.org/viewvc/llvm-project?rev=277277&view=rev
Log:
Correcting some sphinx formatting issues so that the attribute documentation 
builds again.

Modified:
cfe/trunk/include/clang/Basic/AttrDocs.td

Modified: cfe/trunk/include/clang/Basic/AttrDocs.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/AttrDocs.td?rev=277277&r1=277276&r2=277277&view=diff
==
--- cfe/trunk/include/clang/Basic/AttrDocs.td (original)
+++ cfe/trunk/include/clang/Basic/AttrDocs.td Sat Jul 30 15:20:03 2016
@@ -1382,17 +1382,17 @@ This attribute is primarily useful for c
 (``pointer_with_type_tag`` can be used in most non-variadic cases).
 
 In the attribute prototype above:
-* ``arg_kind`` is an identifier that should be used when annotating all
-  applicable type tags.
-* ``arg_idx`` provides the position of a function argument. The expected type 
of
-  this function argument will be determined by the function argument specified
-  by ``type_tag_idx``. In the code example below, "3" means that the type of 
the
-  function's third argument will be determined by ``type_tag_idx``.
-* ``type_tag_idx`` provides the position of a function argument. This function
-  argument will be a type tag. The type tag will determine the expected type of
-  the argument specified by ``arg_idx``. In the code example below, "2" means
-  that the type tag associated with the function's second argument should agree
-  with the type of the argument specified by ``arg_idx``.
+  * ``arg_kind`` is an identifier that should be used when annotating all
+applicable type tags.
+  * ``arg_idx`` provides the position of a function argument. The expected 
type of
+this function argument will be determined by the function argument 
specified
+by ``type_tag_idx``. In the code example below, "3" means that the type of 
the
+function's third argument will be determined by ``type_tag_idx``.
+  * ``type_tag_idx`` provides the position of a function argument. This 
function
+argument will be a type tag. The type tag will determine the expected type 
of
+the argument specified by ``arg_idx``. In the code example below, "2" means
+that the type tag associated with the function's second argument should 
agree
+with the type of the argument specified by ``arg_idx``.
 
 For example:
 
@@ -1414,19 +1414,19 @@ on a function declaration to specify tha
 determines the pointee type of some other pointer argument.
 
 In the attribute prototype above:
-* ``ptr_kind`` is an identifier that should be used when annotating all
-  applicable type tags.
-* ``ptr_idx`` provides the position of a function argument; this function
-  argument will have a pointer type. The expected pointee type of this pointer
-  type will be determined by the function argument specified by
-  ``type_tag_idx``. In the code example below, "1" means that the pointee type
-  of the function's first argument will be determined by ``type_tag_idx``.
-* ``type_tag_idx`` provides the position of a function argument; this function
-  argument will be a type tag. The type tag will determine the expected pointee
-  type of the pointer argument specified by ``ptr_idx``. In the code example
-  below, "3" means that the type tag associated with the function's third
-  argument should agree with the pointee type of the pointer argument specified
-  by ``ptr_idx``.
+  * ``ptr_kind`` is an identifier that should be used when annotating all
+applicable type tags.
+  * ``ptr_idx`` provides the position of a function argument; this function
+argument will have a pointer type. The expected pointee type of this 
pointer
+type will be determined by the function argument specified by
+``type_tag_idx``. In the code example below, "1" means that the pointee 
type
+of the function's first argument will be determined by ``type_tag_idx``.
+  * ``type_tag_idx`` provides the position of a function argument; this 
function
+argument will be a type tag. The type tag will determine the expected 
pointee
+type of the pointer argument specified by ``ptr_idx``. In the code example
+below, "3" means that the type tag associated with the function's third
+argument should agree with the pointee type of the pointer argument 
specified
+by ``ptr_idx``.
 
 For example:
 
@@ -1448,35 +1448,35 @@ When declaring a variable, use
 is tied to the ``type`` argument given to the attribute.
 
 In the attribute prototype above:
-* ``kind`` is an identifier that should be used when annotating all applicable
-  type tags.
-* ``type`` indicates the name of the type.
+  * ``kind`` is an identifier that should be used when annotating all 
applicable
+type tags.
+  * ``type`` indicates the name of the type.
 
 Clang supports annotating type tags of two forms.
 
-* **Type tag that is a reference to a declared 

Re: [PATCH] D22943: [Driver] Add FIXME's where we can't use effective triples (NFC)

2016-07-30 Thread Joerg Sonnenberger via cfe-commits
On Thu, Jul 28, 2016 at 10:11:05PM +, Vedant Kumar wrote:
>   - test/Driver/netbsd.c
> 
> We see -mcpu=arm1022e instead of arm926ej-s in a single run.

Which one exactly? 

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


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

2016-07-30 Thread Joerg Sonnenberger via cfe-commits
On Tue, Jul 26, 2016 at 10:30:22PM +, Laxman Sole via cfe-commits wrote:
> Currently basic_string's destructor is not getting inlined. So adding 
> 'inline' attribute to ~basic_string().

Does this change the ABI?

Joerg
___
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-30 Thread Artem Dergachev via cfe-commits
NoQ added a comment.

> Is it really a problem if the checker comments are part of the Doxygen 
> documentation?


Of course not :) I've been mostly thinking about the benefits of the anonymous 
namespace itself (cleaner global scope, no name collisions, but even these 
benefits are extremely minor).


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-30 Thread Alexander Droste via cfe-commits
Alexander_Droste added a comment.

> It has been originally written as a large set of files. If you feel strongly 
> about it, we could merge it into a single file. That makes sense to me. 
> @Alexander_Droste, what do you think?


Hi, 
I would still strongly prefer to keep them in separate files if possible. One 
of the headers (`MPIFunctionClassifier.hpp`)
also got moved to `include/clang/StaticAnalyzer/Checkers`, as it is needed by 
some MPI clang-tidy checks. 
Is it really a problem if the checker comments are part of the Doxygen 
documentation? Further, I think that
the separation of concerns in form of distinct files might be valuable for 
people being new to the Clang Static Analyzer
framework, as the grouping of functionality is visible on a higher level of 
abstraction. Regardless, I would of course
accept if you prefer to merge the files into a single one, excluding the 
`MPIFunctionClassifier.hpp` header.


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] D22090: [analyzer] Add more FileIDs to PlistDiagnostic map

2016-07-30 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

https://reviews.llvm.org/D22090



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


Re: [PATCH] D22926: Static Analyzer - Localizability Checker: New Localizable APIs for macOS Sierra

2016-07-30 Thread Devin Coughlin via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277273: [analyzer] Update APIs taking user-facing strings. 
(authored by dcoughlin).

Changed prior to commit:
  https://reviews.llvm.org/D22926?vs=66006&id=66225#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22926

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -188,6 +188,22 @@
   NEW_RECEIVER(NSButton)
   ADD_UNARY_METHOD(NSButton, setTitle, 0)
   ADD_UNARY_METHOD(NSButton, setAlternateTitle, 0)
+  IdentifierInfo *radioButtonWithTitleNSButton[] = {
+  &Ctx.Idents.get("radioButtonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, radioButtonWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonImage[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("image"),
+  &Ctx.Idents.get("target"), &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonImage, 4, 0)
+  IdentifierInfo *checkboxWithTitleNSButton[] = {
+  &Ctx.Idents.get("checkboxWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, checkboxWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonTarget[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonTarget, 3, 0)
 
   NEW_RECEIVER(NSSavePanel)
   ADD_UNARY_METHOD(NSSavePanel, setPrompt, 0)
@@ -270,6 +286,9 @@
   ADD_UNARY_METHOD(NSButtonCell, setTitle, 0)
   ADD_UNARY_METHOD(NSButtonCell, setAlternateTitle, 0)
 
+  NEW_RECEIVER(NSDatePickerCell)
+  ADD_UNARY_METHOD(NSDatePickerCell, initTextCell, 0)
+
   NEW_RECEIVER(NSSliderCell)
   ADD_UNARY_METHOD(NSSliderCell, setTitle, 0)
 
@@ -335,9 +354,6 @@
   ADD_UNARY_METHOD(UIActionSheet, addButtonWithTitle, 0)
   ADD_UNARY_METHOD(UIActionSheet, setTitle, 0)
 
-  NEW_RECEIVER(NSURLSessionTask)
-  ADD_UNARY_METHOD(NSURLSessionTask, setTaskDescription, 0)
-
   NEW_RECEIVER(UIAccessibilityCustomAction)
   IdentifierInfo *initWithNameUIAccessibilityCustomAction[] = {
   &Ctx.Idents.get("initWithName"), &Ctx.Idents.get("target"),
@@ -362,6 +378,9 @@
 
   NEW_RECEIVER(NSTextField)
   ADD_UNARY_METHOD(NSTextField, setPlaceholderString, 0)
+  ADD_UNARY_METHOD(NSTextField, textFieldWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, wrappingLabelWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, labelWithString, 0)
 
   NEW_RECEIVER(NSAttributedString)
   ADD_UNARY_METHOD(NSAttributedString, initWithString, 0)
@@ -522,9 +541,6 @@
   ADD_METHOD(NSUserNotificationAction,
  actionWithIdentifierNSUserNotificationAction, 2, 1)
 
-  NEW_RECEIVER(NSURLSession)
-  ADD_UNARY_METHOD(NSURLSession, setSessionDescription, 0)
-
   NEW_RECEIVER(UITextField)
   ADD_UNARY_METHOD(UITextField, setText, 0)
   ADD_UNARY_METHOD(UITextField, setPlaceholder, 0)


Index: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
@@ -188,6 +188,22 @@
   NEW_RECEIVER(NSButton)
   ADD_UNARY_METHOD(NSButton, setTitle, 0)
   ADD_UNARY_METHOD(NSButton, setAlternateTitle, 0)
+  IdentifierInfo *radioButtonWithTitleNSButton[] = {
+  &Ctx.Idents.get("radioButtonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, radioButtonWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonImage[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("image"),
+  &Ctx.Idents.get("target"), &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonImage, 4, 0)
+  IdentifierInfo *checkboxWithTitleNSButton[] = {
+  &Ctx.Idents.get("checkboxWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, checkboxWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonTarget[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonTarget, 3, 0)
 
   NEW_RECEIVER(NSSavePanel)
   ADD_UNARY_METHOD(NSSavePanel, setPrompt, 0)
@@ -270,6 +286,9 @@
   ADD_UNARY_METHOD(NSButtonCell, setTitle, 0)
   ADD_UNARY_METHOD(NSButtonCell, setAlternateTitle, 0)
 
+  NEW_RECEIVER(NSDatePickerCell)
+  ADD_UNARY_METHOD(NSDatePickerCell, initTextCell, 0)
+
   NEW_RECEIVER(NSSliderCell)
   ADD_UNARY_METHOD(NSSliderCell, setTitle, 0)
 
@@ -335,9 +354,6 @@
   ADD_UNARY_METHOD(UIActionSheet, addButtonWithTitle, 0)
   ADD_UNARY_METHOD(UIActio

r277273 - [analyzer] Update APIs taking user-facing strings.

2016-07-30 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Sat Jul 30 11:16:51 2016
New Revision: 277273

URL: http://llvm.org/viewvc/llvm-project?rev=277273&view=rev
Log:
[analyzer] Update APIs taking user-facing strings.

Add new APIs that require localized strings and remove two APIs that were
incorrectly marked as requiring a user-facing string.

A patch by Kulpreet Chilana!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp?rev=277273&r1=277272&r2=277273&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/LocalizationChecker.cpp Sat Jul 30 
11:16:51 2016
@@ -188,6 +188,22 @@ void NonLocalizedStringChecker::initUIMe
   NEW_RECEIVER(NSButton)
   ADD_UNARY_METHOD(NSButton, setTitle, 0)
   ADD_UNARY_METHOD(NSButton, setAlternateTitle, 0)
+  IdentifierInfo *radioButtonWithTitleNSButton[] = {
+  &Ctx.Idents.get("radioButtonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, radioButtonWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonImage[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("image"),
+  &Ctx.Idents.get("target"), &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonImage, 4, 0)
+  IdentifierInfo *checkboxWithTitleNSButton[] = {
+  &Ctx.Idents.get("checkboxWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, checkboxWithTitleNSButton, 3, 0)
+  IdentifierInfo *buttonWithTitleNSButtonTarget[] = {
+  &Ctx.Idents.get("buttonWithTitle"), &Ctx.Idents.get("target"),
+  &Ctx.Idents.get("action")};
+  ADD_METHOD(NSButton, buttonWithTitleNSButtonTarget, 3, 0)
 
   NEW_RECEIVER(NSSavePanel)
   ADD_UNARY_METHOD(NSSavePanel, setPrompt, 0)
@@ -270,6 +286,9 @@ void NonLocalizedStringChecker::initUIMe
   ADD_UNARY_METHOD(NSButtonCell, setTitle, 0)
   ADD_UNARY_METHOD(NSButtonCell, setAlternateTitle, 0)
 
+  NEW_RECEIVER(NSDatePickerCell)
+  ADD_UNARY_METHOD(NSDatePickerCell, initTextCell, 0)
+
   NEW_RECEIVER(NSSliderCell)
   ADD_UNARY_METHOD(NSSliderCell, setTitle, 0)
 
@@ -335,9 +354,6 @@ void NonLocalizedStringChecker::initUIMe
   ADD_UNARY_METHOD(UIActionSheet, addButtonWithTitle, 0)
   ADD_UNARY_METHOD(UIActionSheet, setTitle, 0)
 
-  NEW_RECEIVER(NSURLSessionTask)
-  ADD_UNARY_METHOD(NSURLSessionTask, setTaskDescription, 0)
-
   NEW_RECEIVER(UIAccessibilityCustomAction)
   IdentifierInfo *initWithNameUIAccessibilityCustomAction[] = {
   &Ctx.Idents.get("initWithName"), &Ctx.Idents.get("target"),
@@ -362,6 +378,9 @@ void NonLocalizedStringChecker::initUIMe
 
   NEW_RECEIVER(NSTextField)
   ADD_UNARY_METHOD(NSTextField, setPlaceholderString, 0)
+  ADD_UNARY_METHOD(NSTextField, textFieldWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, wrappingLabelWithString, 0)
+  ADD_UNARY_METHOD(NSTextField, labelWithString, 0)
 
   NEW_RECEIVER(NSAttributedString)
   ADD_UNARY_METHOD(NSAttributedString, initWithString, 0)
@@ -522,9 +541,6 @@ void NonLocalizedStringChecker::initUIMe
   ADD_METHOD(NSUserNotificationAction,
  actionWithIdentifierNSUserNotificationAction, 2, 1)
 
-  NEW_RECEIVER(NSURLSession)
-  ADD_UNARY_METHOD(NSURLSession, setSessionDescription, 0)
-
   NEW_RECEIVER(UITextField)
   ADD_UNARY_METHOD(UITextField, setText, 0)
   ADD_UNARY_METHOD(UITextField, setPlaceholder, 0)


___
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-special-member-functions

2016-07-30 Thread Jonathan B Coe via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL277262: [clang-tidy] add check 
cppcoreguidelines-special-member-functions (authored by jbcoe).

Changed prior to commit:
  https://reviews.llvm.org/D22513?vs=66161&id=66219#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D22513

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

Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
@@ -22,6 +22,7 @@
 #include "ProTypeStaticCastDowncastCheck.h"
 #include "ProTypeUnionAccessCheck.h"
 #include "ProTypeVarargCheck.h"
+#include "SpecialMemberFunctionsCheck.h"
 #include "SlicingCheck.h"
 
 namespace clang {
@@ -54,6 +55,8 @@
 "cppcoreguidelines-pro-type-union-access");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-vararg");
+CheckFactories.registerCheck(
+"cppcoreguidelines-special-member-functions");
 CheckFactories.registerCheck(
 "cppcoreguidelines-slicing");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h
@@ -0,0 +1,101 @@
+//===--- SpecialMemberFunctionsCheck.h - clang-tidy---*- C++ -*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SPECIAL_MEMBER_FUNCTIONS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CPPCOREGUIDELINES_SPECIAL_MEMBER_FUNCTIONS_H
+
+#include "../ClangTidy.h"
+
+#include "llvm/ADT/DenseMapInfo.h"
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+/// Checks for classes where some, but not all, of the special member functions
+/// are defined.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-special-member-functions.html
+class SpecialMemberFunctionsCheck : public ClangTidyCheck {
+public:
+  SpecialMemberFunctionsCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void onEndOfTranslationUnit() override;
+  
+  enum class SpecialMemberFunctionKind {
+Destructor,
+CopyConstructor,
+CopyAssignment,
+MoveConstructor,
+MoveAssignment
+  };
+
+  using ClassDefId = std::pair;
+
+  using ClassDefiningSpecialMembersMap = llvm::DenseMap>;
+
+private:
+  
+  static llvm::StringRef toString(SpecialMemberFunctionKind K);
+
+  static std::string join(llvm::ArrayRef SMFS,
+  llvm::StringRef AndOr);
+  
+  ClassDefiningSpecialMembersMap ClassWithSpecialMembers;
+};
+
+} // namespace cppcoreguidelines
+} // namespace tidy
+} // namespace clang
+
+namespace llvm {
+/// Specialisation of DenseMapInfo to allow ClassDefId objects in DenseMaps
+/// FIXME: Move this to the corresponding cpp file as is done for
+/// clang-tidy/readability/IdentifierNamingCheck.cpp. 
+template <>
+struct DenseMapInfo<
+clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId> {
+  using ClassDefId =
+clang::tidy::cppcoreguidelines::SpecialMemberFunctionsCheck::ClassDefId;
+
+  static inline ClassDefId getEmptyKey() {
+return ClassDefId(
+clang::SourceLocation::getFromRawEncoding(static_cast(-1)),
+"EMPTY");
+  }
+
+  static inline ClassDefId getTombstoneKey() {
+return ClassDefId(
+clang::SourceLocation::getFromRawEncoding(static_cast(-2)),
+"TOMBSTONE");
+  }
+
+  static unsigned getHashValue(

[clang-tools-extra] r277262 - [clang-tidy] add check cppcoreguidelines-special-member-functions

2016-07-30 Thread Jonathan Coe via cfe-commits
Author: jbcoe
Date: Sat Jul 30 03:58:54 2016
New Revision: 277262

URL: http://llvm.org/viewvc/llvm-project?rev=277262&view=rev
Log:
[clang-tidy] add check cppcoreguidelines-special-member-functions

Summary:
Check for classes that violate the rule of five and zero as specified in 
CppCoreGuidelines:

"If a class defines or deletes a default operation then it should define or 
delete them all."

https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#c21-if-you-define-or-delete-any-default-operation-define-or-delete-them-all.

Reviewers: alexfh, sbenza, aaron.ballman

Subscribers: Prazek, Eugene.Zelenko, cfe-commits, ericLemanissier, nemanjai

Projects: #clang-tools-extra

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

Added:

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-special-member-functions.rst

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-special-member-functions-cxx-03.cpp

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-special-member-functions.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt?rev=277262&r1=277261&r2=277262&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt 
(original)
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CMakeLists.txt Sat Jul 
30 03:58:54 2016
@@ -13,6 +13,7 @@ add_clang_library(clangTidyCppCoreGuidel
   ProTypeStaticCastDowncastCheck.cpp
   ProTypeUnionAccessCheck.cpp
   ProTypeVarargCheck.cpp
+  SpecialMemberFunctionsCheck.cpp
   SlicingCheck.cpp
 
   LINK_LIBS

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp?rev=277262&r1=277261&r2=277262&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 (original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
 Sat Jul 30 03:58:54 2016
@@ -22,6 +22,7 @@
 #include "ProTypeStaticCastDowncastCheck.h"
 #include "ProTypeUnionAccessCheck.h"
 #include "ProTypeVarargCheck.h"
+#include "SpecialMemberFunctionsCheck.h"
 #include "SlicingCheck.h"
 
 namespace clang {
@@ -54,6 +55,8 @@ public:
 "cppcoreguidelines-pro-type-union-access");
 CheckFactories.registerCheck(
 "cppcoreguidelines-pro-type-vararg");
+CheckFactories.registerCheck(
+"cppcoreguidelines-special-member-functions");
 CheckFactories.registerCheck(
 "cppcoreguidelines-slicing");
 CheckFactories.registerCheck(

Added: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp?rev=277262&view=auto
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
 (added)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/SpecialMemberFunctionsCheck.cpp
 Sat Jul 30 03:58:54 2016
@@ -0,0 +1,133 @@
+//===--- SpecialMemberFunctionsCheck.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 "SpecialMemberFunctionsCheck.h"
+
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+#include "llvm/ADT/DenseMapInfo.h"
+#include "llvm/ADT/StringExtras.h"
+
+#define DEBUG_TYPE "clang-tidy"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace cppcoreguidelines {
+
+void SpecialMemberFunctionsCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;
+  Finder->addMatcher(
+  cxxRecordDecl(
+  eachOf(
+  has(cxxDestructorDecl(unless(isImplicit())).bind("dtor")),
+  has(cxxConstructorDecl(isCopyConstructor(), unless(isImplicit()))
+  .bind("