r268366 - [libclang] Expose the ElaboratedType

2016-05-03 Thread Sergey Kalinichev via cfe-commits
Author: skalinichev
Date: Tue May  3 01:58:29 2016
New Revision: 268366

URL: http://llvm.org/viewvc/llvm-project?rev=268366&view=rev
Log:
[libclang] Expose the ElaboratedType

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

Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/test/Index/print-type.c
cfe/trunk/test/Index/print-type.cpp
cfe/trunk/tools/libclang/CXType.cpp
cfe/trunk/tools/libclang/libclang.exports

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=268366&r1=268365&r2=268366&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Tue May  3 01:58:29 2016
@@ -1750,6 +1750,7 @@ TypeKind.VARIABLEARRAY = TypeKind(115)
 TypeKind.DEPENDENTSIZEDARRAY = TypeKind(116)
 TypeKind.MEMBERPOINTER = TypeKind(117)
 TypeKind.AUTO = TypeKind(118)
+TypeKind.ELABORATED = TypeKind(119)
 
 class RefQualifierKind(BaseEnumeration):
 """Describes a specific ref-qualifier of a type."""
@@ -1948,6 +1949,12 @@ class Type(Structure):
 """
 return conf.lib.clang_Type_getClassType(self)
 
+def get_named_type(self):
+"""
+Retrieve the type named by the qualified-id.
+"""
+return conf.lib.clang_Type_getNamedType(self)
+
 def get_align(self):
 """
 Retrieve the alignment of the record.
@@ -3565,6 +3572,11 @@ functionList = [
[Type],
c_uint),
 
+  ("clang_Type_getNamedType",
+   [Type],
+   Type,
+   Type.from_result),
+
   ("clang_Type_visitFields",
[Type, callbacks['fields_visit'], py_object],
c_uint),

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=268366&r1=268365&r2=268366&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Tue May  3 01:58:29 2016
@@ -2950,7 +2950,14 @@ enum CXTypeKind {
   CXType_VariableArray = 115,
   CXType_DependentSizedArray = 116,
   CXType_MemberPointer = 117,
-  CXType_Auto = 118
+  CXType_Auto = 118,
+
+  /**
+   * \brief Represents a type that was referred to using an elaborated type 
keyword.
+   *
+   * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
+   */
+  CXType_Elaborated = 119
 };
 
 /**
@@ -3340,6 +3347,13 @@ CINDEX_LINKAGE CXType clang_getArrayElem
 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
 
 /**
+ * \brief Retrieve the type named by the qualified-id.
+ *
+ * If a non-elaborated type is passed in, an invalid type is returned.
+ */
+CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
+
+/**
  * \brief List the possible error codes for \c clang_Type_getSizeOf,
  *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
  *   \c clang_Cursor_getOffsetOf.

Modified: cfe/trunk/test/Index/print-type.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/print-type.c?rev=268366&r1=268365&r2=268366&view=diff
==
--- cfe/trunk/test/Index/print-type.c (original)
+++ cfe/trunk/test/Index/print-type.c Tue May  3 01:58:29 2016
@@ -12,6 +12,9 @@ typedef int __attribute__((vector_size(1
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, 
int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, 
char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] 
[resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] 
[Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] 
[Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] 
[isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -45,3 +48,8 @@ int f2(int incompletearray[]);
 // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * 
sizeof(int int] [typekind=Vector] [isPOD=1]
 // CHECK: TypedefDecl=int4_t:11:46 (Definition) [type=int4_t] 
[typekind=Typedef] [canonicaltype=__attribute__((__vector_size__(4 * 
sizeof(int int] [canonicaltypekind=Vector] [isPOD=1]
 // CHECK: ParmDecl=incompletearray:13:12 (Definition) [type=int []] 
[typekind=IncompleteArray] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedEnumType:15:25 [type=enum Enum ()] 
[typekind=FunctionNoProto] [canonicaltype=enum Enum ()] 
[canonicaltypekind=FunctionNoProto] [resulttype=enum Enum] 
[resulttypekind=Elaborated] [isPOD=0]
+// CHECK: TypeRef=enum Enum:15:6 [type=enum Enum] [typekind=Enum] [isPOD=1]
+// CHECK: StructDecl=Struct:16:8 (Definition) [typ

Re: [PATCH] D11797: [LIbClang] Report the named type for ElaboratedType

2016-05-03 Thread Sergey Kalinichev via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268366: [libclang] Expose the ElaboratedType (authored by 
skalinichev).

Changed prior to commit:
  http://reviews.llvm.org/D11797?vs=51109&id=55953#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11797

Files:
  cfe/trunk/bindings/python/clang/cindex.py
  cfe/trunk/include/clang-c/Index.h
  cfe/trunk/test/Index/print-type.c
  cfe/trunk/test/Index/print-type.cpp
  cfe/trunk/tools/libclang/CXType.cpp
  cfe/trunk/tools/libclang/libclang.exports

Index: cfe/trunk/include/clang-c/Index.h
===
--- cfe/trunk/include/clang-c/Index.h
+++ cfe/trunk/include/clang-c/Index.h
@@ -2950,7 +2950,14 @@
   CXType_VariableArray = 115,
   CXType_DependentSizedArray = 116,
   CXType_MemberPointer = 117,
-  CXType_Auto = 118
+  CXType_Auto = 118,
+
+  /**
+   * \brief Represents a type that was referred to using an elaborated type keyword.
+   *
+   * E.g., struct S, or via a qualified name, e.g., N::M::type, or both.
+   */
+  CXType_Elaborated = 119
 };
 
 /**
@@ -3340,6 +3347,13 @@
 CINDEX_LINKAGE long long clang_getArraySize(CXType T);
 
 /**
+ * \brief Retrieve the type named by the qualified-id.
+ *
+ * If a non-elaborated type is passed in, an invalid type is returned.
+ */
+CINDEX_LINKAGE CXType clang_Type_getNamedType(CXType T);
+
+/**
  * \brief List the possible error codes for \c clang_Type_getSizeOf,
  *   \c clang_Type_getAlignOf, \c clang_Type_getOffsetOf and
  *   \c clang_Cursor_getOffsetOf.
Index: cfe/trunk/test/Index/print-type.c
===
--- cfe/trunk/test/Index/print-type.c
+++ cfe/trunk/test/Index/print-type.c
@@ -12,6 +12,9 @@
 
 int f2(int incompletearray[]);
 
+enum Enum{i}; enum Enum elaboratedEnumType();
+struct Struct{}; struct Struct elaboratedStructType();
+
 // RUN: c-index-test -test-print-type %s | FileCheck %s
 // CHECK: FunctionDecl=f:3:6 (Definition) [type=int *(int *, char *, FooType, int *, void (*)(int))] [typekind=FunctionProto] [canonicaltype=int *(int *, char *, int, int *, void (*)(int))] [canonicaltypekind=FunctionProto] [resulttype=int *] [resulttypekind=Pointer] [args= [int *] [Pointer] [char *] [Pointer] [FooType] [Typedef] [int [5]] [ConstantArray] [void (*)(int)] [Pointer]] [isPOD=0]
 // CHECK: ParmDecl=p:3:13 (Definition) [type=int *] [typekind=Pointer] [isPOD=1] [pointeetype=int] [pointeekind=Int]
@@ -45,3 +48,8 @@
 // CHECK: VarDecl=x:10:38 [type=__attribute__((__vector_size__(4 * sizeof(int int] [typekind=Vector] [isPOD=1]
 // CHECK: TypedefDecl=int4_t:11:46 (Definition) [type=int4_t] [typekind=Typedef] [canonicaltype=__attribute__((__vector_size__(4 * sizeof(int int] [canonicaltypekind=Vector] [isPOD=1]
 // CHECK: ParmDecl=incompletearray:13:12 (Definition) [type=int []] [typekind=IncompleteArray] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedEnumType:15:25 [type=enum Enum ()] [typekind=FunctionNoProto] [canonicaltype=enum Enum ()] [canonicaltypekind=FunctionNoProto] [resulttype=enum Enum] [resulttypekind=Elaborated] [isPOD=0]
+// CHECK: TypeRef=enum Enum:15:6 [type=enum Enum] [typekind=Enum] [isPOD=1]
+// CHECK: StructDecl=Struct:16:8 (Definition) [type=struct Struct] [typekind=Record] [isPOD=1]
+// CHECK: FunctionDecl=elaboratedStructType:16:32 [type=struct Struct ()] [typekind=FunctionNoProto] [canonicaltype=struct Struct ()] [canonicaltypekind=FunctionNoProto] [resulttype=struct Struct] [resulttypekind=Elaborated] [isPOD=0]
+// CHECK: TypeRef=struct Struct:16:8 [type=struct Struct] [typekind=Record] [isPOD=1]
Index: cfe/trunk/test/Index/print-type.cpp
===
--- cfe/trunk/test/Index/print-type.cpp
+++ cfe/trunk/test/Index/print-type.cpp
@@ -48,7 +48,7 @@
 };
 int Blob::*member_pointer;
 
-
+namespace NS { struct Type{}; } NS::Type elaboratedNamespaceType(const NS::Type t);
 
 auto autoI = 0;
 auto autoTbar = tbar(0);
@@ -69,7 +69,7 @@
 // CHECK: Namespace=inner:14:11 (Definition) [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: StructDecl=Bar:16:8 (Definition) [type=outer::inner::Bar] [typekind=Record] [isPOD=0] [nbFields=3]
 // CHECK: CXXConstructor=Bar:17:3 (Definition) (converting constructor) [type=void (outer::Foo *){{.*}}] [typekind=FunctionProto] [canonicaltype=void (outer::Foo *){{.*}}] [canonicaltypekind=FunctionProto] [resulttype=void] [resulttypekind=Void] [args= [outer::Foo *] [Pointer]] [isPOD=0]
-// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Unexposed]
+// CHECK: ParmDecl=foo:17:25 (Definition) [type=outer::Foo *] [typekind=Pointer] [canonicaltype=outer::Foo *] [canonicaltypekind=Pointer] [isPOD=1] [pointeetype=outer::Foo] [pointeekind=Elaborated]
 // CHECK: NamespaceRef=outer:1:11 [type=] [typekind=Invalid] [isPOD=0]
 // CHECK: TemplateR

Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-03 Thread Haojian Wu via cfe-commits
hokein accepted this revision.
hokein added a comment.

LGTM with some nits.



Comment at: clang-tidy/modernize/UseUsingCheck.cpp:22
@@ +21,3 @@
+void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

Should be CplusPlus11 here.


Comment at: test/clang-tidy/modernize-use-using.cpp:28
@@ +27,3 @@
+class Class {
+typedef long long Type;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use using instead of typedef

code indentation.


Comment at: test/clang-tidy/modernize-use-using.cpp:29
@@ +28,3 @@
+typedef long long Type;
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use using instead of typedef
+   // CHECK-FIXES: using Type = long long;

The same.


Comment at: test/clang-tidy/modernize-use-using.cpp:44
@@ +43,3 @@
+class Test {
+typedef typename T::iterator Iter;
+   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: use using instead of typedef

The same.


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D19841: [clang-tidy] Lift common matchers to utils namespace

2016-05-03 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19841#419488, @etienneb wrote:

> Who is the owner of ASTMatcher?
>
> If he is willing to receive these matchers in ASTMatcher, I'll lift them.
>  Otherwise, we should at least lift them within clang-tidy.


Send a patch to sbenza or klimek. I think, these matchers are generic enough to 
be useful in the core matchers library.


http://reviews.llvm.org/D19841



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


[clang-tools-extra] r268369 - Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base

2016-05-03 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue May  3 03:11:47 2016
New Revision: 268369

URL: http://llvm.org/viewvc/llvm-project?rev=268369&view=rev
Log:
Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class 
that initializes itself as a base

Summary: Fix a crash when a record type initializes itself in its own base 
class initializer list.

Patch by Michael Miller!

Reviewers: alexfh, aaron.ballman, hokein

Subscribers: cfe-commits

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

Modified:

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

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp?rev=268369&r1=268368&r2=268369&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Tue May  3 03:11:47 2016
@@ -181,7 +181,7 @@ computeInsertions(const CXXConstructorDe
   const auto *InitDecl =
   Init->isMemberInitializer()
   ? static_cast(Init->getMember())
-  : Init->getBaseClass()->getAs()->getDecl();
+  : Init->getBaseClass()->getAsCXXRecordDecl();
 
   // Add all fields between current field up until the next intializer.
   for (; Decl != std::end(OrderedDecls) && *Decl != InitDecl; ++Decl) {
@@ -401,7 +401,7 @@ void ProTypeMemberInitCheck::checkMissin
   // Remove any bases that were explicitly written in the initializer list.
   for (const CXXCtorInitializer *Init : Ctor->inits()) {
 if (Init->isBaseInitializer() && Init->isWritten())
-  BasesToInit.erase(Init->getBaseClass()->getAs()->getDecl());
+  BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
   }
 
   if (BasesToInit.empty())

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=268369&r1=268368&r2=268369&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Tue May  3 03:11:47 2016
@@ -346,3 +346,14 @@ struct NegativeDeletedConstructor : Nega
 
   Template F;
 };
+
+// This pathological template fails to compile if actually instantiated. It
+// results in the check seeing a null RecordDecl when examining the base class
+// initializer list.
+template 
+class PositiveSelfInitialization : NegativeAggregateType
+{
+  PositiveSelfInitialization() : PositiveSelfInitialization() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these bases: NegativeAggregateType
+  // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), 
PositiveSelfInitialization() {}
+};


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


Re: [PATCH] D19802: Fix a crash in cppcoreguidelines-pro-type-member-init when checking a class that initializes itself as a base

2016-05-03 Thread Haojian Wu via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268369: Fix a crash in 
cppcoreguidelines-pro-type-member-init when checking a class… (authored by 
hokein).

Changed prior to commit:
  http://reviews.llvm.org/D19802?vs=55904&id=55956#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19802

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -181,7 +181,7 @@
   const auto *InitDecl =
   Init->isMemberInitializer()
   ? static_cast(Init->getMember())
-  : Init->getBaseClass()->getAs()->getDecl();
+  : Init->getBaseClass()->getAsCXXRecordDecl();
 
   // Add all fields between current field up until the next intializer.
   for (; Decl != std::end(OrderedDecls) && *Decl != InitDecl; ++Decl) {
@@ -401,7 +401,7 @@
   // Remove any bases that were explicitly written in the initializer list.
   for (const CXXCtorInitializer *Init : Ctor->inits()) {
 if (Init->isBaseInitializer() && Init->isWritten())
-  BasesToInit.erase(Init->getBaseClass()->getAs()->getDecl());
+  BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
   }
 
   if (BasesToInit.empty())
Index: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -346,3 +346,14 @@
 
   Template F;
 };
+
+// This pathological template fails to compile if actually instantiated. It
+// results in the check seeing a null RecordDecl when examining the base class
+// initializer list.
+template 
+class PositiveSelfInitialization : NegativeAggregateType
+{
+  PositiveSelfInitialization() : PositiveSelfInitialization() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize 
these bases: NegativeAggregateType
+  // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), 
PositiveSelfInitialization() {}
+};


Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
@@ -181,7 +181,7 @@
   const auto *InitDecl =
   Init->isMemberInitializer()
   ? static_cast(Init->getMember())
-  : Init->getBaseClass()->getAs()->getDecl();
+  : Init->getBaseClass()->getAsCXXRecordDecl();
 
   // Add all fields between current field up until the next intializer.
   for (; Decl != std::end(OrderedDecls) && *Decl != InitDecl; ++Decl) {
@@ -401,7 +401,7 @@
   // Remove any bases that were explicitly written in the initializer list.
   for (const CXXCtorInitializer *Init : Ctor->inits()) {
 if (Init->isBaseInitializer() && Init->isWritten())
-  BasesToInit.erase(Init->getBaseClass()->getAs()->getDecl());
+  BasesToInit.erase(Init->getBaseClass()->getAsCXXRecordDecl());
   }
 
   if (BasesToInit.empty())
Index: clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
===
--- clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
+++ clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
@@ -346,3 +346,14 @@
 
   Template F;
 };
+
+// This pathological template fails to compile if actually instantiated. It
+// results in the check seeing a null RecordDecl when examining the base class
+// initializer list.
+template 
+class PositiveSelfInitialization : NegativeAggregateType
+{
+  PositiveSelfInitialization() : PositiveSelfInitialization() {}
+  // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: constructor does not initialize these bases: NegativeAggregateType
+  // CHECK-FIXES: PositiveSelfInitialization() : NegativeAggregateType(), PositiveSelfInitialization() {}
+};
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-03 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/UseUsingCheck.cpp:22
@@ +21,3 @@
+void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

hokein wrote:
> Should be CplusPlus11 here.
BTW is there any policy about that? I see that some checks from modernize 
require C++11 (e.g. modernize-make-unique which is in C++14) and other require 
just C++ (modernize-loop-convert), and it even has a comment

// Only register the matchers for C++. Because this checker is used for
  // modernization, it is reasonable to run it on any C++ standard with the
  // assumption the user is trying to modernize their codebase.
  if (!getLangOpts().CPlusPlus)
return;


I have 2 thoughts for this:
1. there should be note in documentation about it, so the user won't spend time 
debuging why the check doesn't do anything. e.g. "This check requires to 
compile code with C++11 or higher"
2. I would suggest modernize checks to require standard version the same or 
higher for C++ standars that doesn't break backwards compatibility:
e.g. loop-convert should require C++11, make-shared C++14, this check also 
C++11,
but for modernize-increment-bool, that is deprecated in C++17, it should 
require just C++ (because if someone need it, the he wont be able to compile 
his code with C++17).


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


[clang-tools-extra] r268371 - [include-fixer] Abstract includeFixerMain function.

2016-05-03 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue May  3 03:38:35 2016
New Revision: 268371

URL: http://llvm.org/viewvc/llvm-project?rev=268371&view=rev
Log:
[include-fixer] Abstract includeFixerMain function.

Modified:
clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp

Modified: clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp?rev=268371&r1=268370&r2=268371&view=diff
==
--- clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp (original)
+++ clang-tools-extra/trunk/include-fixer/tool/ClangIncludeFixer.cpp Tue May  3 
03:38:35 2016
@@ -42,9 +42,8 @@ cl::opt
 MinimizeIncludePaths("minimize-paths",
  cl::desc("Whether to minimize added include paths"),
  cl::init(true), cl::cat(IncludeFixerCategory));
-} // namespace
 
-int main(int argc, const char **argv) {
+int includeFixerMain(int argc, const char **argv) {
   tooling::CommonOptionsParser options(argc, argv, IncludeFixerCategory);
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
@@ -97,3 +96,9 @@ int main(int argc, const char **argv) {
   tooling::applyAllReplacements(Replacements, Rewrites);
   return Rewrites.overwriteChangedFiles();
 }
+
+} // namespace
+
+int main(int argc, const char **argv) {
+  return includeFixerMain(argc, argv);
+}


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


Re: [PATCH] D19846: [clang-tidy] Lift parsing of sequence of names functions to utils.

2016-05-03 Thread Alexander Kornienko via cfe-commits
alexfh requested changes to this revision.
This revision now requires changes to proceed.


Comment at: clang-tidy/misc/SuspiciousStringCompareCheck.cpp:94
@@ +93,3 @@
+  std::vector FunctionNames = utils::option::parseNames(
+  (llvm::Twine(KnownStringCompareFunctions) + StringCompareLikeFunctions)
+  .str());

Please add a comment that the `KnownStringCompareFunctions` string should end 
with a semicolon.


Comment at: clang-tidy/utils/OptionUtils.h:18
@@ +17,3 @@
+namespace utils {
+namespace option {
+

"options" would convey the idea slightly better, imo.


Comment at: clang-tidy/utils/OptionUtils.h:21
@@ +20,3 @@
+/// \brief Parse a list of names separated by ";" character.
+std::vector parseNames(StringRef Option);
+

I don't think this code is specific to "names". Maybe `parseStrings`, 
`parseList` or `parseSemicolonSeparatedList`?


Comment at: clang-tidy/utils/OptionUtils.h:23
@@ +22,3 @@
+
+/// \brief Serialize a sequence of names that can be parse by parseNames.
+std::string serializeNames(const std::vector &Names);

1. s/parse/parsed/
2. Please enclose parseName in backquotes.
3. It's more common to use `ArrayRef` from llvm/ADT/ArrayRef.h to pass a 
reference to a number of sequential elements.


http://reviews.llvm.org/D19846



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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-03 Thread Haojian Wu via cfe-commits
hokein added inline comments.


Comment at: clang-tidy/modernize/UseUsingCheck.cpp:22
@@ +21,3 @@
+void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

Prazek wrote:
> hokein wrote:
> > Should be CplusPlus11 here.
> BTW is there any policy about that? I see that some checks from modernize 
> require C++11 (e.g. modernize-make-unique which is in C++14) and other 
> require just C++ (modernize-loop-convert), and it even has a comment
> 
> // Only register the matchers for C++. Because this checker is used for
>   // modernization, it is reasonable to run it on any C++ standard with the
>   // assumption the user is trying to modernize their codebase.
>   if (!getLangOpts().CPlusPlus)
> return;
> 
> 
> I have 2 thoughts for this:
> 1. there should be note in documentation about it, so the user won't spend 
> time debuging why the check doesn't do anything. e.g. "This check requires to 
> compile code with C++11 or higher"
> 2. I would suggest modernize checks to require standard version the same or 
> higher for C++ standars that doesn't break backwards compatibility:
> e.g. loop-convert should require C++11, make-shared C++14, this check also 
> C++11,
> but for modernize-increment-bool, that is deprecated in C++17, it should 
> require just C++ (because if someone need it, the he wont be able to compile 
> his code with C++17).
This is a good point. 

As far as I know, we don't have detailed policy about the modernized checks. It 
depends on the check author. Basically the modern words means "C++11" feature.

I'm +1 on adding a note in each modernized check's document. 


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-03 Thread Piotr Padlewski via cfe-commits
Prazek added inline comments.


Comment at: clang-tidy/modernize/UseUsingCheck.cpp:22
@@ +21,3 @@
+void UseUsingCheck::registerMatchers(MatchFinder *Finder) {
+  if (!getLangOpts().CPlusPlus)
+return;

hokein wrote:
> Prazek wrote:
> > hokein wrote:
> > > Should be CplusPlus11 here.
> > BTW is there any policy about that? I see that some checks from modernize 
> > require C++11 (e.g. modernize-make-unique which is in C++14) and other 
> > require just C++ (modernize-loop-convert), and it even has a comment
> > 
> > // Only register the matchers for C++. Because this checker is used for
> >   // modernization, it is reasonable to run it on any C++ standard with the
> >   // assumption the user is trying to modernize their codebase.
> >   if (!getLangOpts().CPlusPlus)
> > return;
> > 
> > 
> > I have 2 thoughts for this:
> > 1. there should be note in documentation about it, so the user won't spend 
> > time debuging why the check doesn't do anything. e.g. "This check requires 
> > to compile code with C++11 or higher"
> > 2. I would suggest modernize checks to require standard version the same or 
> > higher for C++ standars that doesn't break backwards compatibility:
> > e.g. loop-convert should require C++11, make-shared C++14, this check also 
> > C++11,
> > but for modernize-increment-bool, that is deprecated in C++17, it should 
> > require just C++ (because if someone need it, the he wont be able to 
> > compile his code with C++17).
> This is a good point. 
> 
> As far as I know, we don't have detailed policy about the modernized checks. 
> It depends on the check author. Basically the modern words means "C++11" 
> feature.
> 
> I'm +1 on adding a note in each modernized check's document. 
Cool. I sent email to mailing list to ask other devs for opinion.

Krystyna, please add note at the end of documentation

"This check requires using C++11 or higher to run."


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-05-03 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55961.
rmaprath added a comment.

As agreed, reverted back to using the native mutex / condition_variable types 
within library sources.

@EricWF: Good to go now?

Thanks.

/ Asiri


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,7 +46,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __libcpp_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +62,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -23,89 +23,67 @@
 
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__libcpp_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __libcpp_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
+int ec = __libcpp_recursive_mutex_init(&__m_);
 if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __libcpp_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __libcpp_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +143,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__libcpp_thread_id_equal(id, __id_))
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +161,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_equal(id, __id_)))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +195,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static __libcpp_mutex_t mut;
+static __libcpp_condvar_t cv;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +225,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock(&mut);
+__libcpp_mutex_lock(&mut);
 while (flag == 1)
-pthread_cond_wait(&cv, &mut);
+__libcpp_condvar_wait(&cv, &mut);
 if (flag == 0)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 __libcpp_relaxed_store(&flag, 1ul);
-pthread_mutex_unlock(&mut);
+__libcpp_mutex_unlock(&mut);

r268372 - [Clang][AVX512][BUILTIN] Adding intrinsics for compressstore{df|di|sf|si} instruction set.

2016-05-03 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue May  3 05:42:46 2016
New Revision: 268372

URL: http://llvm.org/viewvc/llvm-project?rev=268372&view=rev
Log:
[Clang][AVX512][BUILTIN] Adding intrinsics for compressstore{df|di|sf|si} 
instruction set.

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268372&r1=268371&r2=268372&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue May  3 05:42:46 2016
@@ -2248,6 +2248,10 @@ TARGET_BUILTIN(__builtin_ia32_movapd128_
 TARGET_BUILTIN(__builtin_ia32_movapd256_mask, "V4dV4dV4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movaps128_mask, "V4fV4fV4fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_movaps256_mask, "V8fV8fV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_compressstoredf512_mask, 
"vV8d*V8dUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, 
"vV8LLi*V8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_compressstoresf512_mask, 
"vV16f*V16fUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_compressstoresi512_mask, 
"vV16i*V16iUs","","avx512f")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268372&r1=268371&r2=268372&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue May  3 05:42:46 2016
@@ -7965,6 +7965,33 @@ _mm512_maskz_mov_ps (__mmask16 __U, __m5
  (__mmask16) __U);
 }
 
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm512_mask_compressstoreu_pd (void *__P, __mmask8 __U, __m512d __A)
+{
+  __builtin_ia32_compressstoredf512_mask ((__v8df *) __P, (__v8df) __A,
+(__mmask8) __U);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm512_mask_compressstoreu_epi64 (void *__P, __mmask8 __U, __m512i __A)
+{
+  __builtin_ia32_compressstoredi512_mask ((__v8di *) __P, (__v8di) __A,
+(__mmask8) __U);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm512_mask_compressstoreu_ps (void *__P, __mmask16 __U, __m512 __A)
+{
+  __builtin_ia32_compressstoresf512_mask ((__v16sf *) __P, (__v16sf) __A,
+(__mmask16) __U);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm512_mask_compressstoreu_epi32 (void *__P, __mmask16 __U, __m512i __A)
+{
+  __builtin_ia32_compressstoresi512_mask ((__v16si *) __P, (__v16si) __A,
+(__mmask16) __U);
+}
 
 #undef __DEFAULT_FN_ATTRS
 

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=268372&r1=268371&r2=268372&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue May  3 05:42:46 2016
@@ -5528,3 +5528,27 @@ __m512 test_mm512_maskz_mov_ps(__mmask16
   // CHECK: @llvm.x86.avx512.mask.mova.ps.512
   return _mm512_maskz_mov_ps(__U, __A); 
 }
+
+void test_mm512_mask_compressstoreu_pd(void *__P, __mmask8 __U, __m512d __A) {
+  // CHECK-LABEL: @test_mm512_mask_compressstoreu_pd
+  // CHECK: @llvm.x86.avx512.mask.compress.store.pd.512
+  return _mm512_mask_compressstoreu_pd(__P, __U, __A); 
+}
+
+void test_mm512_mask_compressstoreu_epi64(void *__P, __mmask8 __U, __m512i 
__A) {
+  // CHECK-LABEL: @test_mm512_mask_compressstoreu_epi64
+  // CHECK: @llvm.x86.avx512.mask.compress.store.q.512
+  return _mm512_mask_compressstoreu_epi64(__P, __U, __A); 
+}
+
+void test_mm512_mask_compressstoreu_ps(void *__P, __mmask16 __U, __m512 __A) {
+  // CHECK-LABEL: @test_mm512_mask_compressstoreu_ps
+  // CHECK: @llvm.x86.avx512.mask.compress.store.ps.512
+  return _mm512_mask_compressstoreu_ps(__P, __U, __A); 
+}
+
+void test_mm512_mask_compressstoreu_epi32(void *__P, __mmask16 __U, __m512i 
__A) {
+  // CHECK-LABEL: @test_mm512_mask_compressstoreu_epi32
+  // CHECK: @llvm.x86.avx512.mask.compress.store.d.512
+  return _mm512_mask_compressstoreu_epi32(__P, __U, __A); 
+}


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


Re: [PATCH] D19412: [libcxx] Refactor pthread usage - II

2016-05-03 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55965.
rmaprath added a comment.

Added missing initializer (typo).


http://reviews.llvm.org/D19412

Files:
  include/__config
  include/__mutex_base
  include/__threading_support
  include/mutex
  include/thread
  src/algorithm.cpp
  src/condition_variable.cpp
  src/memory.cpp
  src/mutex.cpp
  src/thread.cpp

Index: src/thread.cpp
===
--- src/thread.cpp
+++ src/thread.cpp
@@ -46,7 +46,7 @@
 void
 thread::join()
 {
-int ec = pthread_join(__t_, 0);
+int ec = __libcpp_thread_join(&__t_);
 #ifndef _LIBCPP_NO_EXCEPTIONS
 if (ec)
 throw system_error(error_code(ec, system_category()), "thread::join failed");
@@ -62,7 +62,7 @@
 int ec = EINVAL;
 if (__t_ != 0)
 {
-ec = pthread_detach(__t_);
+ec = __libcpp_thread_detach(&__t_);
 if (ec == 0)
 __t_ = 0;
 }
Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -23,89 +23,67 @@
 
 mutex::~mutex()
 {
-pthread_mutex_destroy(&__m_);
+__libcpp_mutex_destroy(&__m_);
 }
 
 void
 mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "mutex lock failed");
 }
 
 bool
 mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 void
 mutex::unlock() _NOEXCEPT
 {
-int ec = pthread_mutex_unlock(&__m_);
+int ec = __libcpp_mutex_unlock(&__m_);
 (void)ec;
 assert(ec == 0);
 }
 
 // recursive_mutex
 
 recursive_mutex::recursive_mutex()
 {
-pthread_mutexattr_t attr;
-int ec = pthread_mutexattr_init(&attr);
+int ec = __libcpp_recursive_mutex_init(&__m_);
 if (ec)
-goto fail;
-ec = pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutex_init(&__m_, &attr);
-if (ec)
-{
-pthread_mutexattr_destroy(&attr);
-goto fail;
-}
-ec = pthread_mutexattr_destroy(&attr);
-if (ec)
-{
-pthread_mutex_destroy(&__m_);
-goto fail;
-}
-return;
-fail:
-__throw_system_error(ec, "recursive_mutex constructor failed");
+__throw_system_error(ec, "recursive_mutex constructor failed");
 }
 
 recursive_mutex::~recursive_mutex()
 {
-int e = pthread_mutex_destroy(&__m_);
+int e = __libcpp_mutex_destroy(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 void
 recursive_mutex::lock()
 {
-int ec = pthread_mutex_lock(&__m_);
+int ec = __libcpp_mutex_lock(&__m_);
 if (ec)
 __throw_system_error(ec, "recursive_mutex lock failed");
 }
 
 void
 recursive_mutex::unlock() _NOEXCEPT
 {
-int e = pthread_mutex_unlock(&__m_);
+int e = __libcpp_mutex_unlock(&__m_);
 (void)e;
 assert(e == 0);
 }
 
 bool
 recursive_mutex::try_lock() _NOEXCEPT
 {
-return pthread_mutex_trylock(&__m_) == 0;
+return __libcpp_mutex_trylock(&__m_) == 0;
 }
 
 // timed_mutex
@@ -165,9 +143,9 @@
 void
 recursive_timed_mutex::lock()
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_);
-if (pthread_equal(id, __id_))
+if (__libcpp_thread_id_equal(id, __id_))
 {
 if (__count_ == numeric_limits::max())
 __throw_system_error(EAGAIN, "recursive_timed_mutex lock limit reached");
@@ -183,9 +161,9 @@
 bool
 recursive_timed_mutex::try_lock() _NOEXCEPT
 {
-pthread_t id = pthread_self();
+__libcpp_thread_id id = __libcpp_thread_get_current_id();
 unique_lock lk(__m_, try_to_lock);
-if (lk.owns_lock() && (__count_ == 0 || pthread_equal(id, __id_)))
+if (lk.owns_lock() && (__count_ == 0 || __libcpp_thread_id_equal(id, __id_)))
 {
 if (__count_ == numeric_limits::max())
 return false;
@@ -217,8 +195,8 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
-static pthread_mutex_t mut = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t  cv  = PTHREAD_COND_INITIALIZER;
+static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
+static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -247,36 +225,36 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-pthread_mutex_lock(&mut);
+__libcpp_mutex_lock(&mut);
 while (flag == 1)
-pthread_cond_wait(&cv, &mut);
+__libcpp_condvar_wait(&cv, &mut);
 if (flag == 0)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 __libcpp_relaxed_store(&flag, 1ul);
-pthread_mutex_unlock(&mut);
+__libcpp_mutex_unlock(&mut);
 func(arg);
-pthread_mutex_lock(&mu

Re: [PATCH] D19415: [libcxx][rfc] Externalized threading support

2016-05-03 Thread Asiri Rathnayake via cfe-commits
rmaprath updated this revision to Diff 55967.
rmaprath added a comment.

Re-spun on top of http://reviews.llvm.org/D19412.


http://reviews.llvm.org/D19415

Files:
  include/__threading_support
  src/algorithm.cpp
  src/memory.cpp
  src/mutex.cpp

Index: src/mutex.cpp
===
--- src/mutex.cpp
+++ src/mutex.cpp
@@ -195,8 +195,23 @@
 // keep in sync with:  7741191.
 
 #ifndef _LIBCPP_HAS_NO_THREADS
+# if defined(_LIBCPP_THREAD_API_EXTERNAL)
+static mutex mut;
+static condition_variable cv;
+#  define __LOCK_INIT() unique_lock lk(mut);
+#  define __LOCK_LOCK() lk.lock();
+#  define __LOCK_UNLOCK() lk.unlock();
+#  define __CV_WAIT_LOCK() cv.wait(lk);
+#  define __CV_NOTIFY_ALL() cv.notify_all();
+# else
 static __libcpp_mutex_t mut = _LIBCPP_MUTEX_INITIALIZER;
 static __libcpp_condvar_t cv = _LIBCPP_CONDVAR_INITIALIZER;
+#  define __LOCK_INIT() __libcpp_mutex_lock(&mut);
+#  define __LOCK_LOCK() __libcpp_mutex_lock(&mut);
+#  define __LOCK_UNLOCK() __libcpp_mutex_unlock(&mut);
+#  define __CV_WAIT_LOCK() __libcpp_condvar_wait(&cv, &mut);
+#  define __CV_NOTIFY_ALL() __libcpp_condvar_broadcast(&cv);
+# endif
 #endif
 
 /// NOTE: Changes to flag are done via relaxed atomic stores
@@ -225,38 +240,46 @@
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 #else // !_LIBCPP_HAS_NO_THREADS
-__libcpp_mutex_lock(&mut);
+__LOCK_INIT()
 while (flag == 1)
-__libcpp_condvar_wait(&cv, &mut);
+__CV_WAIT_LOCK()
 if (flag == 0)
 {
 #ifndef _LIBCPP_NO_EXCEPTIONS
 try
 {
 #endif  // _LIBCPP_NO_EXCEPTIONS
 __libcpp_relaxed_store(&flag, 1ul);
-__libcpp_mutex_unlock(&mut);
+__LOCK_UNLOCK()
 func(arg);
-__libcpp_mutex_lock(&mut);
+__LOCK_LOCK()
 __libcpp_relaxed_store(&flag, ~0ul);
-__libcpp_mutex_unlock(&mut);
-__libcpp_condvar_broadcast(&cv);
+__LOCK_UNLOCK()
+__CV_NOTIFY_ALL()
 #ifndef _LIBCPP_NO_EXCEPTIONS
 }
 catch (...)
 {
-__libcpp_mutex_lock(&mut);
+__LOCK_LOCK()
 __libcpp_relaxed_store(&flag, 0ul);
-__libcpp_mutex_unlock(&mut);
-__libcpp_condvar_broadcast(&cv);
+__LOCK_UNLOCK()
+__CV_NOTIFY_ALL()
 throw;
 }
 #endif  // _LIBCPP_NO_EXCEPTIONS
 }
 else
-__libcpp_mutex_unlock(&mut);
+__LOCK_UNLOCK()
 #endif // !_LIBCPP_HAS_NO_THREADS
 
 }
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+# undef __LOCK_INIT
+# undef __LOCK_LOCK
+# undef __LOCK_UNLOCK
+# undef __CV_WAIT_LOCK
+# undef __CV_NOTIFY_ALL
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
Index: src/memory.cpp
===
--- src/memory.cpp
+++ src/memory.cpp
@@ -127,13 +127,17 @@
 #if defined(_LIBCPP_HAS_C_ATOMIC_IMP) && !defined(_LIBCPP_HAS_NO_THREADS)
 
 static const std::size_t __sp_mut_count = 16;
+#if defined(_LIBCPP_THREAD_API_EXTERNAL)
+static mutex mut_back_imp[__sp_mut_count];
+#else
 static __libcpp_mutex_t mut_back_imp[__sp_mut_count] =
 {
 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER,
 _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER, _LIBCPP_MUTEX_INITIALIZER
 };
+#endif
 
 static mutex* mut_back = reinterpret_cast(mut_back_imp);
 
Index: src/algorithm.cpp
===
--- src/algorithm.cpp
+++ src/algorithm.cpp
@@ -48,14 +48,22 @@
 template unsigned __sort5<__less&, long double*>(long double*, long double*, long double*, long double*, long double*, __less&);
 
 #ifndef _LIBCPP_HAS_NO_THREADS
+# if defined(_LIBCPP_THREAD_API_EXTERNAL)
+static mutex __rs_mut;
+#  define __LOCK_LOCK() __rs_mut.lock();
+#  define __LOCK_UNLOCK() __rs_mut.unlock();
+# else
 static __libcpp_mutex_t __rs_mut = _LIBCPP_MUTEX_INITIALIZER;
+#  define __LOCK_LOCK() __libcpp_mutex_lock(&__rs_mut);
+#  define __LOCK_UNLOCK() __libcpp_mutex_unlock(&__rs_mut);
+# endif
 #endif
 unsigned __rs_default::__c_ = 0;
 
 __rs_default::__rs_default()
 {
 #ifndef _LIBCPP_HAS_NO_THREADS
-__libcpp_mutex_lock(&__rs_mut);
+__LOCK_LOCK()
 #endif
 __c_ = 1;
 }
@@ -69,7 +77,7 @@
 {
 #ifndef _LIBCPP_HAS_NO_THREADS
 if (--__c_ == 0)
-   __libcpp_mutex_unlock(&__rs_mut);
+   __LOCK_UNLOCK()
 #else
 --__c_;
 #endif
@@ -88,4 +96,9 @@
 return __rs_default();
 }
 
+#ifndef _LIBCPP_HAS_NO_THREADS
+# undef __LOCK_LOCK
+# undef __LOCK_UNLOCK
+#endif
+
 _LIBCPP_END_NAMESPACE_STD
Index: include/__threading_support
===
--- include/__threa

r268373 - [Clang][AVX512][Builtin] Adding intrinsics for vcvttpd2udq instruction set

2016-05-03 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue May  3 06:05:24 2016
New Revision: 268373

URL: http://llvm.org/viewvc/llvm-project?rev=268373&view=rev
Log:
[Clang][AVX512][Builtin] Adding intrinsics for vcvttpd2udq instruction set

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

Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268373&r1=268372&r2=268373&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue May  3 06:05:24 2016
@@ -5229,6 +5229,54 @@ _mm512_mask_testn_epi64_mask (__mmask8 _
 (__v8di) __B, __U);
 }
 
+#define _mm512_cvtt_roundpd_epu32( __A, __R) __extension__ ({ \
+__builtin_ia32_cvttpd2udq512_mask ((__v8df)( __A),\
+  (__v8si)\
+  _mm256_undefined_si256 (),\
+  (__mmask8) -1,( __R));\
+})
+
+#define _mm512_mask_cvtt_roundpd_epu32( __W, __U, __A, __R) __extension__ ({ \
+__builtin_ia32_cvttpd2udq512_mask ((__v8df)( __A),\
+  (__v8si)( __W),\
+  (__mmask8)( __U),( __R));\
+})
+
+#define _mm512_maskz_cvtt_roundpd_epu32( __U, __A, __R) __extension__ ({ \
+__builtin_ia32_cvttpd2udq512_mask ((__v8df)( __A),\
+  (__v8si)\
+  _mm256_setzero_si256 (),\
+  (__mmask8)( __U),( __R));\
+})
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm512_cvttpd_epu32 (__m512d __A)
+{
+  return (__m256i) __builtin_ia32_cvttpd2udq512_mask ((__v8df) __A,
+  (__v8si)
+  _mm256_undefined_si256 (),
+  (__mmask8) -1,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm512_mask_cvttpd_epu32 (__m256i __W, __mmask8 __U, __m512d __A)
+{
+  return (__m256i) __builtin_ia32_cvttpd2udq512_mask ((__v8df) __A,
+  (__v8si) __W,
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
+
+static __inline__ __m256i __DEFAULT_FN_ATTRS
+_mm512_maskz_cvttpd_epu32 (__mmask8 __U, __m512d __A)
+{
+  return (__m256i) __builtin_ia32_cvttpd2udq512_mask ((__v8df) __A,
+  (__v8si)
+  _mm256_setzero_si256 (),
+  (__mmask8) __U,
+  _MM_FROUND_CUR_DIRECTION);
+}
 
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_mask_unpackhi_epi32 (__m512i __W, __mmask16 __U, __m512i __A,

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=268373&r1=268372&r2=268373&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue May  3 06:05:24 2016
@@ -5552,3 +5552,39 @@ void test_mm512_mask_compressstoreu_epi3
   // CHECK: @llvm.x86.avx512.mask.compress.store.d.512
   return _mm512_mask_compressstoreu_epi32(__P, __U, __A); 
 }
+
+__m256i test_mm512_cvtt_roundpd_epu32(__m512d __A) {
+  // CHECK-LABEL: @test_mm512_cvtt_roundpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2udq.512
+  return _mm512_cvtt_roundpd_epu32(__A, _MM_FROUND_CUR_DIRECTION); 
+}
+
+__m256i test_mm512_mask_cvtt_roundpd_epu32(__m256i __W, __mmask8 __U, __m512d 
__A) {
+  // CHECK-LABEL: @test_mm512_mask_cvtt_roundpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2udq.512
+  return _mm512_mask_cvtt_roundpd_epu32(__W, __U, __A, 
_MM_FROUND_CUR_DIRECTION); 
+}
+
+__m256i test_mm512_maskz_cvtt_roundpd_epu32(__mmask8 __U, __m512d __A) {
+  // CHECK-LABEL: @test_mm512_maskz_cvtt_roundpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2udq.512
+  return _mm512_maskz_cvtt_roundpd_epu32(__U, __A, _MM_FROUND_CUR_DIRECTION); 
+}
+
+__m256i test_mm512_cvttpd_epu32(__m512d __A) {
+  // CHECK-LABEL: @test_mm512_cvttpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2udq.512
+  return _mm512_cvttpd_epu32(__A); 
+}
+
+__m256i test_mm512_mask_cvttpd_epu32(__m256i __W, __mmask8 __U, __m512d __A) {
+  // CHECK-LABEL: @test_mm512_mask_cvttpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2udq.512
+  return _mm512_mask_cvttpd_epu32(__W, __U, __A); 
+}
+
+__m256i test_mm512_maskz_cvttpd_epu32(__mmask8 __U, __m512d __A) {
+  // CHECK-LABEL: @test_mm512_maskz_cvttpd_epu32
+  // CHECK: @llvm.x86.avx512.mask.cvttpd2udq.512
+  return _mm512_maskz_cvttpd_epu32(__U, __A); 
+}


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


[clang-tools-extra] r268374 - Fix cppcoreguidelines-pro-type-member-init failure test on Windows.

2016-05-03 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue May  3 06:19:46 2016
New Revision: 268374

URL: http://llvm.org/viewvc/llvm-project?rev=268374&view=rev
Log:
Fix cppcoreguidelines-pro-type-member-init failure test on Windows.

Modified:

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Modified: 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp?rev=268374&r1=268373&r2=268374&view=diff
==
--- 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 (original)
+++ 
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp
 Tue May  3 06:19:46 2016
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t
+// RUN: %check_clang_tidy %s cppcoreguidelines-pro-type-member-init %t -- -- 
-std=c++11 -fno-delayed-template-parsing
 
 struct PositiveFieldBeforeConstructor {
   int F;


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


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-03 Thread Jonathan B Coe via cfe-commits
jbcoe added inline comments.


Comment at: clang-tidy/readability/ReadabilityTidyModule.cpp:37
@@ -35,1 +36,3 @@
+CheckFactories.registerCheck(
+"readability-avoid-std-bind");
 CheckFactories.registerCheck(

aaron.ballman wrote:
> I kind of wonder if this should be in modernize instead of readability? Tough 
> call, and I'm fine with either place, just wanted to pose the question.
Given that lambdas and `std::bind` both arrived in C++11, `modernize` seems a 
misnomer.
I think `readability` is better fit.


http://reviews.llvm.org/D16962



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


Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-03 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 55970.
jbcoe marked 16 inline comments as done.
jbcoe added a comment.

Minor fixes from review.


http://reviews.llvm.org/D16962

Files:
  clang-tidy/readability/AvoidStdBindCheck.cpp
  clang-tidy/readability/AvoidStdBindCheck.h
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-avoid-std-bind.rst
  test/clang-tidy/readability-avoid-std-bind.cpp

Index: test/clang-tidy/readability-avoid-std-bind.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-avoid-std-bind.cpp
@@ -0,0 +1,70 @@
+// RUN: %check_clang_tidy %s readability-avoid-std-bind %t -- -- -std=c++14
+
+namespace std {
+inline namespace impl {
+template 
+class bind_rt {};
+
+template 
+bind_rt bind(Fp &&, Arguments &&...);
+}
+}
+
+int add(int x, int y) { return x + y; }
+
+void f() {
+  auto clj = std::bind(add, 2, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto clj = [] { return add(2, 2); };
+}
+
+void g() {
+  int x = 2;
+  int y = 2;
+  auto clj = std::bind(add, x, y);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto clj = [=] { return add(x, y); };
+}
+
+struct placeholder {};
+placeholder _1;
+placeholder _2;
+
+void h() {
+  int x = 2;
+  auto clj = std::bind(add, x, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto clj = [=](auto && arg1) { return add(x, arg1); };
+}
+
+struct A;
+struct B;
+bool ABTest(const A &, const B &);
+
+void i() {
+  auto BATest = std::bind(ABTest, _2, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto BATest = [](auto && arg1, auto && arg2) { return ABTest(arg2, arg1); };
+}
+
+void j() {
+  auto clj = std::bind(add, 2, 2, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // No fix is applied for argument mismatches.
+  // CHECK-FIXES: auto clj = std::bind(add, 2, 2, 2);
+}
+
+void k() {
+  auto clj = std::bind(add, _1, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // No fix is applied for reused placeholders.
+  // CHECK-FIXES: auto clj = std::bind(add, _1, _1);
+}
+
+void m() {
+  auto clj = std::bind(add, 1, add(2, 5));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // No fix is applied for nested calls.
+  // CHECK-FIXES: auto clj = std::bind(add, 1, add(2, 5));
+}
+
Index: docs/clang-tidy/checks/readability-avoid-std-bind.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-avoid-std-bind.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - readability-avoid-std-bind
+
+readability-avoid-std-bind
+==
+
+The check finds uses of ``std::bind`` and replaces simple uses with lambdas.
+Lambdas will use value-capture where required.
+
+Right now it only handles free functions, not member functions.
+
+Given:
+
+.. code:: C++
+  int add(int x, int y) { return x + y; }
+
+Then:
+
+.. code:: C++
+  void f() {
+int x = 2;
+auto clj = std::bind(add, x, _1);
+  }
+
+is replaced by:
+  
+.. code:: C++
+  void f() {
+int x = 2;
+auto clj = [=](auto && arg1) { return add(x, arg1); };
+  }
+
+We created this check because ``std::bind`` can be hard to read and can result
+in larger object files and binaries due to type information that will not be
+produced by equivalent lambdas.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -105,6 +105,7 @@
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
readability-avoid-const-params-in-decls
+   readability-avoid-std-bind
readability-braces-around-statements
readability-container-size-empty
readability-deleted-default
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "AvoidConstParamsInDecls.h"
+#include "AvoidStdBindCheck.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
 #include "DeletedDefaultCheck.h"
@@ -37,6 +38,8 @@
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "readability-avo

Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-03 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 55974.
jbcoe added a comment.

Remove unused function `isStdBind`.


http://reviews.llvm.org/D16962

Files:
  clang-tidy/readability/AvoidStdBindCheck.cpp
  clang-tidy/readability/AvoidStdBindCheck.h
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-avoid-std-bind.rst
  test/clang-tidy/readability-avoid-std-bind.cpp

Index: test/clang-tidy/readability-avoid-std-bind.cpp
===
--- /dev/null
+++ test/clang-tidy/readability-avoid-std-bind.cpp
@@ -0,0 +1,70 @@
+// RUN: %check_clang_tidy %s readability-avoid-std-bind %t -- -- -std=c++14
+
+namespace std {
+inline namespace impl {
+template 
+class bind_rt {};
+
+template 
+bind_rt bind(Fp &&, Arguments &&...);
+}
+}
+
+int add(int x, int y) { return x + y; }
+
+void f() {
+  auto clj = std::bind(add, 2, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto clj = [] { return add(2, 2); };
+}
+
+void g() {
+  int x = 2;
+  int y = 2;
+  auto clj = std::bind(add, x, y);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto clj = [=] { return add(x, y); };
+}
+
+struct placeholder {};
+placeholder _1;
+placeholder _2;
+
+void h() {
+  int x = 2;
+  auto clj = std::bind(add, x, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto clj = [=](auto && arg1) { return add(x, arg1); };
+}
+
+struct A;
+struct B;
+bool ABTest(const A &, const B &);
+
+void i() {
+  auto BATest = std::bind(ABTest, _2, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:17: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // CHECK-FIXES: auto BATest = [](auto && arg1, auto && arg2) { return ABTest(arg2, arg1); };
+}
+
+void j() {
+  auto clj = std::bind(add, 2, 2, 2);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // No fix is applied for argument mismatches.
+  // CHECK-FIXES: auto clj = std::bind(add, 2, 2, 2);
+}
+
+void k() {
+  auto clj = std::bind(add, _1, _1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // No fix is applied for reused placeholders.
+  // CHECK-FIXES: auto clj = std::bind(add, _1, _1);
+}
+
+void m() {
+  auto clj = std::bind(add, 1, add(2, 5));
+  // CHECK-MESSAGES: :[[@LINE-1]]:14: warning: prefer a lambda to std::bind [readability-avoid-std-bind]
+  // No fix is applied for nested calls.
+  // CHECK-FIXES: auto clj = std::bind(add, 1, add(2, 5));
+}
+
Index: docs/clang-tidy/checks/readability-avoid-std-bind.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/readability-avoid-std-bind.rst
@@ -0,0 +1,35 @@
+.. title:: clang-tidy - readability-avoid-std-bind
+
+readability-avoid-std-bind
+==
+
+The check finds uses of ``std::bind`` and replaces simple uses with lambdas.
+Lambdas will use value-capture where required.
+
+Right now it only handles free functions, not member functions.
+
+Given:
+
+.. code:: C++
+  int add(int x, int y) { return x + y; }
+
+Then:
+
+.. code:: C++
+  void f() {
+int x = 2;
+auto clj = std::bind(add, x, _1);
+  }
+
+is replaced by:
+  
+.. code:: C++
+  void f() {
+int x = 2;
+auto clj = [=](auto && arg1) { return add(x, arg1); };
+  }
+
+We created this check because ``std::bind`` can be hard to read and can result
+in larger object files and binaries due to type information that will not be
+produced by equivalent lambdas.
+
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -105,6 +105,7 @@
performance-unnecessary-copy-initialization
performance-unnecessary-value-param
readability-avoid-const-params-in-decls
+   readability-avoid-std-bind
readability-braces-around-statements
readability-container-size-empty
readability-deleted-default
Index: clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -11,6 +11,7 @@
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
 #include "AvoidConstParamsInDecls.h"
+#include "AvoidStdBindCheck.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
 #include "DeletedDefaultCheck.h"
@@ -37,6 +38,8 @@
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
 CheckFactories.registerCheck(
 "readability-avoid-const-params-in-decls");
+ 

Re: [PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-03 Thread Felix Berger via cfe-commits
flx removed rL LLVM as the repository for this revision.
flx updated this revision to Diff 55975.

http://reviews.llvm.org/D19849

Files:
  clang-tidy/misc/MoveConstructorInitCheck.cpp
  test/clang-tidy/misc-move-constructor-init.cpp

Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -96,7 +96,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument can be moved to 
avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved 
to avoid copy [misc-move-constructor-init]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
Index: clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -109,8 +109,9 @@
   if (parmVarDeclRefExprOccurences(*MovableParam, *ConstructorDecl,
*Result.Context) > 1)
 return;
-  auto DiagOut =
-  diag(InitArg->getLocStart(), "value argument can be moved to avoid 
copy");
+  auto DiagOut = diag(InitArg->getLocStart(),
+  "value argument %0 can be moved to avoid copy")
+ << MovableParam;
   DiagOut << FixItHint::CreateReplacement(
   InitArg->getSourceRange(),
   (Twine("std::move(") + MovableParam->getName() + ")").str());


Index: test/clang-tidy/misc-move-constructor-init.cpp
===
--- test/clang-tidy/misc-move-constructor-init.cpp
+++ test/clang-tidy/misc-move-constructor-init.cpp
@@ -96,7 +96,7 @@
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument can be moved to avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved to avoid copy [misc-move-constructor-init]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };
Index: clang-tidy/misc/MoveConstructorInitCheck.cpp
===
--- clang-tidy/misc/MoveConstructorInitCheck.cpp
+++ clang-tidy/misc/MoveConstructorInitCheck.cpp
@@ -109,8 +109,9 @@
   if (parmVarDeclRefExprOccurences(*MovableParam, *ConstructorDecl,
*Result.Context) > 1)
 return;
-  auto DiagOut =
-  diag(InitArg->getLocStart(), "value argument can be moved to avoid copy");
+  auto DiagOut = diag(InitArg->getLocStart(),
+  "value argument %0 can be moved to avoid copy")
+ << MovableParam;
   DiagOut << FixItHint::CreateReplacement(
   InitArg->getSourceRange(),
   (Twine("std::move(") + MovableParam->getName() + ")").str());
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-03 Thread Felix Berger via cfe-commits
flx marked an inline comment as done.
flx added a comment.

Done.


http://reviews.llvm.org/D19849



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


Re: [PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman added a comment.

I'm not opposed to showing the name, but I'm not certain I understand under 
what circumstances the name would be useful. Since this is triggering on move 
constructors, and move constructors can only have one parameter, the name seems 
wholly redundant, isn't it?


http://reviews.llvm.org/D19849



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


Re: [PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-03 Thread Felix Berger via cfe-commits
flx added a comment.

In http://reviews.llvm.org/D19849#419751, @aaron.ballman wrote:

> I'm not opposed to showing the name, but I'm not certain I understand under 
> what circumstances the name would be useful. Since this is triggering on move 
> constructors, and move constructors can only have one parameter, the name 
> seems wholly redundant, isn't it?


The case this is covering is when a value parameter can be moved, of which 
there can be many.


http://reviews.llvm.org/D19849



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


Re: [PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D19849#419752, @flx wrote:

> In http://reviews.llvm.org/D19849#419751, @aaron.ballman wrote:
>
> > I'm not opposed to showing the name, but I'm not certain I understand under 
> > what circumstances the name would be useful. Since this is triggering on 
> > move constructors, and move constructors can only have one parameter, the 
> > name seems wholly redundant, isn't it?
>
>
> The case this is covering is when a value parameter can be moved, of which 
> there can be many.


Ah, I think I was thrown by the fact that the only instance of the diagnostic 
was with a move constructor in a check called misc-move-constructor-init. :-P


http://reviews.llvm.org/D19849



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


Re: [PATCH] D19851: Warn on binding reference to null in copy initialization

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.


Comment at: lib/Sema/SemaInit.cpp:3513
@@ -3512,1 +3512,3 @@
 
+static void CheckForNullPointerDereference(Sema &S, Expr *E) {
+  // Check to see if we are dereferencing a null pointer.  If so,

Can this take a `const Expr *` instead?


Comment at: lib/Sema/SemaInit.cpp:3649
@@ -3631,1 +3648,3 @@
 
+  for (Expr *Arg : Args) {
+CheckForNullPointerDereference(S, Arg);

`const Expr *` (or `const auto *`) instead?


Comment at: test/CXX/expr/expr.prim/expr.prim.lambda/p5.cpp:39
@@ -38,3 +38,3 @@
 
-  bogus_override_if_virtual bogus;
+  bogus_override_if_virtual bogus; // expected-note{{in 
instantiation of member function 'bogus_override_if_virtual<(lambda}}
 }

Missing `>` in the diagnostic text (I know it's not required, but it looks a 
bit strange if that's the only part missing from the diagnostic text).


http://reviews.llvm.org/D19851



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


r268376 - [Clang][AVX512][Builtin] Adding intrinsics for vcvt{ph|ps}2{ps|ph} instruction set

2016-05-03 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue May  3 07:45:04 2016
New Revision: 268376

URL: http://llvm.org/viewvc/llvm-project?rev=268376&view=rev
Log:
[Clang][AVX512][Builtin] Adding intrinsics for vcvt{ph|ps}2{ps|ph} instruction 
set

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512vl-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268376&r1=268375&r2=268376&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue May  3 07:45:04 2016
@@ -2252,6 +2252,10 @@ TARGET_BUILTIN(__builtin_ia32_compressst
 TARGET_BUILTIN(__builtin_ia32_compressstoredi512_mask, 
"vV8LLi*V8LLiUc","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoresf512_mask, 
"vV16f*V16fUs","","avx512f")
 TARGET_BUILTIN(__builtin_ia32_compressstoresi512_mask, 
"vV16i*V16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_vcvtph2ps_mask, "V4fV8sV4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vcvtph2ps256_mask, "V8fV8sV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vcvtps2ph_mask, "V8sV4fIiV8sUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_vcvtps2ph256_mask, "V8sV8fIiV8sUc","","avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512vlintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlintrin.h?rev=268376&r1=268375&r2=268376&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlintrin.h Tue May  3 07:45:04 2016
@@ -9453,6 +9453,65 @@ _mm256_maskz_mov_ps (__mmask8 __U, __m25
  (__mmask8) __U);
 }
 
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_mask_cvtph_ps (__m128 __W, __mmask8 __U, __m128i __A)
+{
+  return (__m128) __builtin_ia32_vcvtph2ps_mask ((__v8hi) __A,
+ (__v4sf) __W,
+ (__mmask8) __U);
+}
+
+static __inline__ __m128 __DEFAULT_FN_ATTRS
+_mm_maskz_cvtph_ps (__mmask8 __U, __m128i __A)
+{
+  return (__m128) __builtin_ia32_vcvtph2ps_mask ((__v8hi) __A,
+ (__v4sf)
+ _mm_setzero_ps (),
+ (__mmask8) __U);
+}
+
+static __inline__ __m256 __DEFAULT_FN_ATTRS
+_mm256_mask_cvtph_ps (__m256 __W, __mmask8 __U, __m128i __A)
+{
+  return (__m256) __builtin_ia32_vcvtph2ps256_mask ((__v8hi) __A,
+(__v8sf) __W,
+(__mmask8) __U);
+}
+
+static __inline__ __m256 __DEFAULT_FN_ATTRS
+_mm256_maskz_cvtph_ps (__mmask8 __U, __m128i __A)
+{
+  return (__m256) __builtin_ia32_vcvtph2ps256_mask ((__v8hi) __A,
+(__v8sf)
+_mm256_setzero_ps (),
+(__mmask8) __U);
+}
+
+#define _mm_mask_cvtps_ph( __W, __U, __A, __I) __extension__ ({ \
+__builtin_ia32_vcvtps2ph_mask ((__v4sf)( __A),( __I),\
+  (__v8hi)( __W),\
+  (__mmask8)( __U));\
+})
+
+#define _mm_maskz_cvtps_ph( __U, __A, __I) __extension__ ({ \
+__builtin_ia32_vcvtps2ph_mask ((__v4sf)( __A),( __I),\
+  (__v8hi)\
+  _mm_setzero_si128 (),\
+  (__mmask8)( __U));\
+})
+
+#define _mm256_mask_cvtps_ph( __W, __U, __A, __I) __extension__ ({ \
+__builtin_ia32_vcvtps2ph256_mask ((__v8sf)( __A),( __I),\
+ (__v8hi)( __W),\
+ (__mmask8)( __U));\
+})
+
+#define _mm256_maskz_cvtps_ph( __U, __A, __I) __extension__ ({ \
+__builtin_ia32_vcvtps2ph256_mask ((__v8sf)( __A),( __I),\
+ (__v8hi)\
+ _mm_setzero_si128 (),\
+ (__mmask8)( __U));\
+})
 
 #undef __DEFAULT_FN_ATTRS
 #undef __DEFAULT_FN_ATTRS_BOTH

Modified: cfe/trunk/test/CodeGen/avx512vl-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vl-builtins.c?rev=268376&r1=268375&r2=268376&view=diff
==
--- cfe/trunk/test/CodeGen/avx512vl-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512vl-builtins.c Tue May  3 07:45:04 2016
@@ -6654,3 +6654,51 @@ __m256 test_mm256_maskz_mov_ps(__mmask8
   return _mm256_maskz_mov_ps(__U, __A); 
 }
 
+__m128 test_mm_mask_cvtph_ps(__m128 __W, __mmask8 __U, __m128i __A) {
+  // CHECK-LABEL: @test_mm_mask_cvtph_ps
+  // CHECK: @llvm.x86.avx512.mask.vcvtph2ps.128
+  return _mm_mask_cvtph_ps(__W, __U, __A); 
+}
+
+__m128 test_mm_maskz_cvtph_ps(__mmask8 __U, __m128i __A) {
+  // CHECK-LABEL: @test_mm_maskz_cvtph_ps
+  // CHECK: @llvm.x86.avx512.mask.vcvtph2ps.128
+  return _mm_maskz_cvtph_ps(__U, __A); 
+}
+
+__m256 test_mm256_mask_cvtph_ps(__m256 __W, __mmask8 __U, __m128i __A) {
+  // CHECK-LABEL: @test_mm256_mask_cvtph_ps
+  // CHECK: @llvm.x86.avx512.mask.vcvtph2ps.256
+  return _mm2

[PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.

2016-05-03 Thread Felix Berger via cfe-commits
flx created this revision.
flx added a reviewer: alexfh.
flx added a subscriber: cfe-commits.
flx set the repository for this revision to rL LLVM.

This fixes bug: https://llvm.org/bugs/show_bug.cgi?id=27325

Repository:
  rL LLVM

http://reviews.llvm.org/D19865

Files:
  clang-tidy/performance/UnnecessaryCopyInitialization.cpp
  test/clang-tidy/performance-unnecessary-copy-initialization.cpp

Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -338,3 +338,8 @@
   WeirdCopyCtorType neg_weird_1(orig, false);
   WeirdCopyCtorType neg_weird_2(orig, true);
 }
+
+void NegativeMultiDeclStmt() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy = orig, copy2;
+}
Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -56,16 +56,15 @@
 
   auto localVarCopiedFrom = [](const internal::Matcher &CopyCtorArg) {
 return compoundStmt(
-   forEachDescendant(
+   forEachDescendant(declStmt(hasSingleDecl(
varDecl(hasLocalStorage(),
hasType(matchers::isExpensiveToCopy()),
hasInitializer(cxxConstructExpr(
   
hasDeclaration(cxxConstructorDecl(
   isCopyConstructor())),
   hasArgument(0, CopyCtorArg))
   .bind("ctorCall")))
-   .bind("newVarDecl")))
-.bind("blockStmt");
+   .bind("newVarDecl").bind("blockStmt");
   };
 
   Finder->addMatcher(


Index: test/clang-tidy/performance-unnecessary-copy-initialization.cpp
===
--- test/clang-tidy/performance-unnecessary-copy-initialization.cpp
+++ test/clang-tidy/performance-unnecessary-copy-initialization.cpp
@@ -338,3 +338,8 @@
   WeirdCopyCtorType neg_weird_1(orig, false);
   WeirdCopyCtorType neg_weird_2(orig, true);
 }
+
+void NegativeMultiDeclStmt() {
+  ExpensiveToCopyType orig;
+  ExpensiveToCopyType copy = orig, copy2;
+}
Index: clang-tidy/performance/UnnecessaryCopyInitialization.cpp
===
--- clang-tidy/performance/UnnecessaryCopyInitialization.cpp
+++ clang-tidy/performance/UnnecessaryCopyInitialization.cpp
@@ -56,16 +56,15 @@
 
   auto localVarCopiedFrom = [](const internal::Matcher &CopyCtorArg) {
 return compoundStmt(
-   forEachDescendant(
+   forEachDescendant(declStmt(hasSingleDecl(
varDecl(hasLocalStorage(),
hasType(matchers::isExpensiveToCopy()),
hasInitializer(cxxConstructExpr(
   hasDeclaration(cxxConstructorDecl(
   isCopyConstructor())),
   hasArgument(0, CopyCtorArg))
   .bind("ctorCall")))
-   .bind("newVarDecl")))
-.bind("blockStmt");
+   .bind("newVarDecl").bind("blockStmt");
   };
 
   Finder->addMatcher(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19856: Create new library 'libc++experimental.a' for packaging TS symbols.

2016-05-03 Thread Ben Craig via cfe-commits
bcraig added a comment.

LGTM


http://reviews.llvm.org/D19856



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


Re: [PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.

2016-05-03 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Is it a workaround to avoid breaking the code by incorrect fixes?


Repository:
  rL LLVM

http://reviews.llvm.org/D19865



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


Re: [PATCH] D19849: [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

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

LG. Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D19849



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


[PATCH] D19866: [Analyzer] Correct stack address escape diagnostic

2016-05-03 Thread Phil Camp via cfe-commits
FlameTop created this revision.
FlameTop added reviewers: zaks.anna, dcoughlin.
FlameTop added a subscriber: cfe-commits.

Leaking a stack address via a static variable refers to it in the diagnostic as 
a 'global'. This patch corrects the diagnostic for static variables. 

Patch by Phil Camp, SN Systems

http://reviews.llvm.org/D19866

Files:
  llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
  llvm/tools/clang/test/Analysis/stackaddrleak.c

Index: llvm/tools/clang/test/Analysis/stackaddrleak.c
===
--- llvm/tools/clang/test/Analysis/stackaddrleak.c
+++ llvm/tools/clang/test/Analysis/stackaddrleak.c
@@ -19,7 +19,7 @@
   p = (const char *) __builtin_alloca(12);
 } // expected-warning{{Address of stack memory allocated by call to alloca() 
on line 19 is still referred to by the global variable 'p' upon returning to 
the caller.  This will be a dangling reference}}
 
-// PR 7383 - previosly the stack address checker would crash on this example
+// PR 7383 - previously the stack address checker would crash on this example
 //  because it would attempt to do a direct load from 'pr7383_list'. 
 static int pr7383(__const char *__)
 {
@@ -33,7 +33,7 @@
   int x;
   a = &x;
   b = &x;
-} // expected-warning{{Address of stack memory associated with local variable 
'x' is still referred to by the global variable 'a' upon returning}} 
expected-warning{{Address of stack memory associated with local variable 'x' is 
still referred to by the global variable 'b' upon returning}}
+} // expected-warning{{Address of stack memory associated with local variable 
'x' is still referred to by the static variable 'a' upon returning}} 
expected-warning{{Address of stack memory associated with local variable 'x' is 
still referred to by the static variable 'b' upon returning}}
 
 intptr_t returnAsNonLoc() {
   int x;
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
+++ llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
@@ -226,17 +226,22 @@
 
   if (!BT_stackleak)
 BT_stackleak.reset(
-new BuiltinBug(this, "Stack address stored into global variable",
-   "Stack address was saved into a global variable. "
+new BuiltinBug(this, "Stack address stored into global/static 
variable",
+   "Stack address was saved into a global/static variable. 
"
"This is dangerous because the address will become "
"invalid after returning from the function"));
 
   for (unsigned i = 0, e = cb.V.size(); i != e; ++i) {
 // Generate a report for this bug.
 SmallString<512> buf;
 llvm::raw_svector_ostream os(buf);
 SourceRange range = genName(os, cb.V[i].second, Ctx.getASTContext());
-os << " is still referred to by the global variable '";
+os << " is still referred to by the ";
+if (isa(cb.V[i].first->getMemorySpace()))
+  os << "static";
+else
+  os << "global";
+os << " variable '";
 const VarRegion *VR = cast(cb.V[i].first->getBaseRegion());
 os << *VR->getDecl()
<< "' upon returning to the caller.  This will be a dangling reference";


Index: llvm/tools/clang/test/Analysis/stackaddrleak.c
===
--- llvm/tools/clang/test/Analysis/stackaddrleak.c
+++ llvm/tools/clang/test/Analysis/stackaddrleak.c
@@ -19,7 +19,7 @@
   p = (const char *) __builtin_alloca(12);
 } // expected-warning{{Address of stack memory allocated by call to alloca() on line 19 is still referred to by the global variable 'p' upon returning to the caller.  This will be a dangling reference}}
 
-// PR 7383 - previosly the stack address checker would crash on this example
+// PR 7383 - previously the stack address checker would crash on this example
 //  because it would attempt to do a direct load from 'pr7383_list'. 
 static int pr7383(__const char *__)
 {
@@ -33,7 +33,7 @@
   int x;
   a = &x;
   b = &x;
-} // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'a' upon returning}} expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the global variable 'b' upon returning}}
+} // expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'a' upon returning}} expected-warning{{Address of stack memory associated with local variable 'x' is still referred to by the static variable 'b' upon returning}}
 
 intptr_t returnAsNonLoc() {
   int x;
Index: llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp
===
--- llvm/tools/clang/lib/Stati

Re: [PATCH] D16962: clang-tidy: avoid std::bind

2016-05-03 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Please regenerate the patch with the full context (see 
http://llvm.org/docs/Phabricator.html).



Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:77
@@ +76,3 @@
+  for (size_t I = 1; I <= PlaceholderCount; ++I) {
+Stream << Delimiter << "auto &&"
+   << " arg" << I;

clang-format, please.


Comment at: clang-tidy/readability/AvoidStdBindCheck.cpp:116
@@ +115,3 @@
+void AvoidStdBindCheck::check(const MatchFinder::MatchResult &Result) {
+  if (!getLangOpts().CPlusPlus14) // Need C++14 for generic lambdas.
+return;

This should be done in `registerMatchers` instead.


Comment at: docs/clang-tidy/checks/readability-avoid-std-bind.rst:13
@@ +12,3 @@
+
+.. code:: C++
+  int add(int x, int y) { return x + y; }

`.. code::` should be followed by an empty line.

Please also verify the documentation can be built without errors. On Ubuntu 
this boils down to:

1. Install sphinx:

$ sudo apt-get install sphinx-common

2. Enable `LLVM_BUILD_DOCS` and maybe some other options in cmake.

3. `ninja docs-clang-tools-html` (or something similar, if you use make).


http://reviews.llvm.org/D16962



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


Re: [PATCH] D19165: [clang-tidy] Add modernize-increment-bool check.

2016-05-03 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

ping @Alexfh have you check it?


http://reviews.llvm.org/D19165



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


Re: [PATCH] D19827: Do not disable completely loop unroll according to optimization level.

2016-05-03 Thread Marianne Mailhot-Sarrasin via cfe-commits
mamai added a subscriber: tyler.nowicki.
mamai added a comment.

I think the blog comment is right. The pragma should make the loop unroll even 
in /Os. I think it is essential to allow the user to optimize some specific 
loops even if he generally wants to optimize for size the rest of the code. I 
will add tests that show the behavior of the loop unroll pass when optnone or 
optsize are specified.


Repository:
  rL LLVM

http://reviews.llvm.org/D19827



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


r268385 - [Clang][avx512][Builtin] Adding intrinsics for cvtw2mask{128|256|512} instruction set

2016-05-03 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue May  3 09:12:23 2016
New Revision: 268385

URL: http://llvm.org/viewvc/llvm-project?rev=268385&view=rev
Log:
[Clang][avx512][Builtin] Adding intrinsics for cvtw2mask{128|256|512} 
instruction set

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

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268385&r1=268384&r2=268385&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue May  3 09:12:23 2016
@@ -2256,6 +2256,9 @@ TARGET_BUILTIN(__builtin_ia32_vcvtph2ps_
 TARGET_BUILTIN(__builtin_ia32_vcvtph2ps256_mask, "V8fV8sV8fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vcvtps2ph_mask, "V8sV4fIiV8sUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_vcvtps2ph256_mask, "V8sV8fIiV8sUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtw2mask512, "UiV32s","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_cvtw2mask128, "UcV8s","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtw2mask256, "UsV16s","","avx512bw,avx512vl")
 
 #undef BUILTIN
 #undef TARGET_BUILTIN

Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=268385&r1=268384&r2=268385&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Tue May  3 09:12:23 2016
@@ -2063,6 +2063,12 @@ _mm512_movepi8_mask (__m512i __A)
   return (__mmask64) __builtin_ia32_cvtb2mask512 ((__v64qi) __A);
 }
 
+static __inline__ __mmask32 __DEFAULT_FN_ATTRS
+_mm512_movepi16_mask (__m512i __A)
+{
+  return (__mmask32) __builtin_ia32_cvtw2mask512 ((__v32hi) __A);
+}
+
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_movm_epi8 (__mmask64 __A)
 {

Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=268385&r1=268384&r2=268385&view=diff
==
--- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Tue May  3 09:12:23 2016
@@ -3181,6 +3181,18 @@ _mm256_movepi8_mask (__m256i __A)
   return (__mmask32) __builtin_ia32_cvtb2mask256 ((__v32qi) __A);
 }
 
+static __inline__ __mmask8 __DEFAULT_FN_ATTRS
+_mm_movepi16_mask (__m128i __A)
+{
+  return (__mmask8) __builtin_ia32_cvtw2mask128 ((__v8hi) __A);
+}
+
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm256_movepi16_mask (__m256i __A)
+{
+  return (__mmask16) __builtin_ia32_cvtw2mask256 ((__v16hi) __A);
+}
+
 static __inline__ __m128i __DEFAULT_FN_ATTRS
 _mm_movm_epi8 (__mmask16 __A)
 {

Modified: cfe/trunk/test/CodeGen/avx512bw-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512bw-builtins.c?rev=268385&r1=268384&r2=268385&view=diff
==
--- cfe/trunk/test/CodeGen/avx512bw-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512bw-builtins.c Tue May  3 09:12:23 2016
@@ -1530,3 +1530,10 @@ __m512i test_mm512_sad_epu8(__m512i __A,
   // CHECK: @llvm.x86.avx512.psad.bw.512
   return _mm512_sad_epu8(__A, __B); 
 }
+
+__mmask32 test_mm512_movepi16_mask(__m512i __A) {
+  // CHECK-LABEL: @test_mm512_movepi16_mask
+  // CHECK: @llvm.x86.avx512.cvtw2mask.512
+  return _mm512_movepi16_mask(__A); 
+}
+

Modified: cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vlbw-builtins.c?rev=268385&r1=268384&r2=268385&view=diff
==
--- cfe/trunk/test/CodeGen/avx512vlbw-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512vlbw-builtins.c Tue May  3 09:12:23 2016
@@ -2375,3 +2375,15 @@ __m256i test_mm256_maskz_dbsad_epu8(__mm
   // CHECK: @llvm.x86.avx512.mask.dbpsadbw.256
   return _mm256_maskz_dbsad_epu8(__U, __A, __B, 170); 
 }
+__mmask8 test_mm_movepi16_mask(__m128i __A) {
+  // CHECK-LABEL: @test_mm_movepi16_mask
+  // CHECK: @llvm.x86.avx512.cvtw2mask.128
+  return _mm_movepi16_mask(__A); 
+}
+
+__mmask16 test_mm256_movepi16_mask(__m256i __A) {
+  // CHECK-LABEL: @test_mm256_movepi16_mask
+  // CHECK: @llvm.x86.avx512.cvtw2mask.256
+  return _mm256_movepi16_mask(__A); 
+}
+


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


Re: [PATCH] D19484: [OpenCL] Add supported OpenCL extensions to target info.

2016-05-03 Thread Yaxun Liu via cfe-commits
yaxunl added a comment.

Hi Alexey,

Any comments on this patch?

Thanks.


http://reviews.llvm.org/D19484



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


r268387 - [clang][AVX512][BuiltIn] Adding intrinsics for cast{pd|ps|si}128_{pd|ps|si}512 and castsi256_si512 instruction set

2016-05-03 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Tue May  3 09:26:52 2016
New Revision: 268387

URL: http://llvm.org/viewvc/llvm-project?rev=268387&view=rev
Log:
[clang][AVX512][BuiltIn] Adding intrinsics for cast{pd|ps|si}128_{pd|ps|si}512 
and castsi256_si512 instruction set

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


Modified:
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/lib/Headers/avx512fintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512fintrin.h?rev=268387&r1=268386&r2=268387&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Tue May  3 09:26:52 2016
@@ -343,6 +343,31 @@ _mm512_castps512_ps128(__m512 __a)
   return __builtin_shufflevector(__a, __a, 0, 1, 2, 3);
 }
 
+
+static __inline__ __m512d __DEFAULT_FN_ATTRS
+_mm512_castpd128_pd512 (__m128d __A)
+{
+  return __builtin_shufflevector( __A, __A, 0, 1, -1, -1, -1, -1, -1, -1);
+}
+
+static __inline__ __m512 __DEFAULT_FN_ATTRS
+_mm512_castps128_ps512 (__m128 __A)
+{
+return  __builtin_shufflevector( __A, __A, 0, 1, 2, 3, -1, -1, -1, -1, -1, 
-1, -1, -1, -1, -1, -1, -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_castsi128_si512 (__m128i __A)
+{
+   return  __builtin_shufflevector( __A, __A, 0, 1, -1, -1, -1, -1, -1, -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_castsi256_si512 (__m256i __A)
+{
+   return  __builtin_shufflevector( __A, __A, 0, 1, 2, 3, -1, -1, -1, -1);
+}
+
 /* Bitwise operators */
 static __inline__ __m512i __DEFAULT_FN_ATTRS
 _mm512_and_epi32(__m512i __a, __m512i __b)

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=268387&r1=268386&r2=268387&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue May  3 09:26:52 2016
@@ -5588,3 +5588,28 @@ __m256i test_mm512_maskz_cvttpd_epu32(__
   // CHECK: @llvm.x86.avx512.mask.cvttpd2udq.512
   return _mm512_maskz_cvttpd_epu32(__U, __A); 
 }
+
+__m512d test_mm512_castpd128_pd512(__m128d __A) {
+  // CHECK-LABEL: @test_mm512_castpd128_pd512
+  // CHECK: shufflevector <2 x double> %1, <2 x double> %2, <8 x i32> 
+  return _mm512_castpd128_pd512(__A); 
+}
+
+__m512 test_mm512_castps128_ps512(__m128 __A) {
+  // CHECK-LABEL: @test_mm512_castps128_ps512
+  // CHECK: shufflevector <4 x float> %1, <4 x float> %2, <16 x i32> 
+  return _mm512_castps128_ps512(__A); 
+}
+
+__m512i test_mm512_castsi128_si512(__m128i __A) {
+  // CHECK-LABEL: @test_mm512_castsi128_si512
+  // CHECK: shufflevector <2 x i64> %1, <2 x i64> %2, <8 x i32> 
+  return _mm512_castsi128_si512(__A); 
+}
+
+__m512i test_mm512_castsi256_si512(__m256i __A) {
+  // CHECK-LABEL: @test_mm512_castsi256_si512
+  // CHECK: shufflevector <4 x i64> %1, <4 x i64> %2, <8 x i32> 
+  return _mm512_castsi256_si512(__A); 
+}
+


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


Re: [PATCH] D18919: [Clang-tidy] Add check "modernize use using"

2016-05-03 Thread Marek Kurdej via cfe-commits
curdeius added a subscriber: curdeius.
curdeius added a comment.

I'm really interested in the manner this check works when a typedef has 
multiple declarations in it (same example as in the comment):

  typedef int m_int, *m_int_p, &m_int_r, m_int_arr[10], (&m_int_fun)(int, int);

I tried to implement such a check once, but this was the hard part. FYI, that's 
my stub: 
https://github.com/llvm-mirror/clang-tools-extra/compare/master...mkurdej:feature/use-using.



Comment at: docs/clang-tidy/checks/modernize-use-using.rst:21
@@ +20,3 @@
+
+  using varible = int;
+

Typo: varible -> variable.


Comment at: test/clang-tidy/modernize-use-using.cpp:1
@@ +1,2 @@
+// RUN: %check_clang_tidy %s modernize-use-using %t
+

Could you add tests for the case where there are multiple type declarations in 
one statement? E.g.:

```
typedef int m_int, *m_int_p, &m_int_r, m_int_arr[10], (&m_int_fun)(int, int);
```

Would it be transformed to multiple using statements or only a warning will be 
emitted?


Repository:
  rL LLVM

http://reviews.llvm.org/D18919



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


Re: [PATCH] D19865: [clang-tidy] - PerformanceUnnecesaryCopyInitialization - only trigger for decl stmts with single VarDecl.

2016-05-03 Thread Felix Berger via cfe-commits
flx added a comment.

In http://reviews.llvm.org/D19865#419830, @alexfh wrote:

> Is it a workaround to avoid breaking the code by incorrect fixes?


Yes. We can't simply change the type of DeclStmt when we only look one of the 
VarDecls and how it is initialized.


Repository:
  rL LLVM

http://reviews.llvm.org/D19865



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


Re: [PATCH] D19827: Do not disable completely loop unroll according to optimization level.

2016-05-03 Thread Chad Rosier via cfe-commits
mcrosier added a comment.

In http://reviews.llvm.org/D19827#419870, @mamai wrote:

> I think the blog comment is right. The pragma should make the loop unroll 
> even in /Os. I think it is essential to allow the user to optimize some 
> specific loops even if he generally wants to optimize for size the rest of 
> the code. I will add tests that show the behavior of the loop unroll pass 
> when optnone or optsize are specified.


You're correct.  No more reviewing patches after my bedtime. :)


Repository:
  rL LLVM

http://reviews.llvm.org/D19827



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


[PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: alexfh, sbenza, klimek.
etienneb added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This AST matcher will match a given CastExpr kind.
It's an narrowing matcher on CastExpr.

http://reviews.llvm.org/D19871

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -75,6 +75,7 @@
   // TODO: Here is the list of the missing matchers, grouped by reason.
   //
   // Need Variant/Parser fixes:
+  // hasCastKind
   // ofKind
   //
   // Polymorphic + argument overload:
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3548,6 +3548,17 @@
   InnerMatcher.matches(*SubExpression, Finder, Builder));
 }
 
+/// \brief Matches casts that has a given cast kind.
+///
+/// Example: matches the implicit cast around \c 0
+/// (matcher = castExpr(hasCastKind(CK_NullToPointer)))
+/// \code
+///   int *p = 0;
+/// \endcode
+AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
+  return Node.getCastKind() == Kind;
+}
+
 /// \brief Matches casts whose destination type matches a given matcher.
 ///
 /// (Note: Clang's AST refers to other conversions as "casts" too, and calls


Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -75,6 +75,7 @@
   // TODO: Here is the list of the missing matchers, grouped by reason.
   //
   // Need Variant/Parser fixes:
+  // hasCastKind
   // ofKind
   //
   // Polymorphic + argument overload:
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -3548,6 +3548,17 @@
   InnerMatcher.matches(*SubExpression, Finder, Builder));
 }
 
+/// \brief Matches casts that has a given cast kind.
+///
+/// Example: matches the implicit cast around \c 0
+/// (matcher = castExpr(hasCastKind(CK_NullToPointer)))
+/// \code
+///   int *p = 0;
+/// \endcode
+AST_MATCHER_P(CastExpr, hasCastKind, CastKind, Kind) {
+  return Node.getCastKind() == Kind;
+}
+
 /// \brief Matches casts whose destination type matches a given matcher.
 ///
 /// (Note: Clang's AST refers to other conversions as "casts" too, and calls
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19534: [clang-tidy] new google-default-arguments check

2016-05-03 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 56000.
courbet marked 4 inline comments as done.
courbet added a comment.

Cosmetics + change error message.


http://reviews.llvm.org/D19534

Files:
  clang-tidy/google/CMakeLists.txt
  clang-tidy/google/DefaultArgumentsCheck.cpp
  clang-tidy/google/DefaultArgumentsCheck.h
  clang-tidy/google/GoogleTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/google-default-arguments.rst
  docs/clang-tidy/checks/list.rst
  test/clang-tidy/google-default-arguments.cpp

Index: test/clang-tidy/google-default-arguments.cpp
===
--- /dev/null
+++ test/clang-tidy/google-default-arguments.cpp
@@ -0,0 +1,29 @@
+// RUN: %check_clang_tidy %s google-default-arguments %t
+
+struct A {
+  virtual void f(int I, int J = 3);
+  // CHECK-MESSAGES: :[[@LINE-1]]:16: warning: default arguments on virtual or override methods are prohibited [google-default-arguments]
+};
+
+struct B : public A {
+  void f(int I, int J = 5);
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: default arguments on virtual or override methods are prohibited [google-default-arguments]
+};
+
+struct C : public B {
+  void f(int I, int J = 5) override;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: default arguments on virtual or override methods are prohibited [google-default-arguments]
+};
+
+// Negatives.
+struct D : public B {
+  void f(int I, int J) override;
+};
+
+struct X {
+  void f(int I, int J = 3);
+};
+
+struct Y : public X {
+  void f(int I, int J = 5);
+};
Index: docs/clang-tidy/checks/list.rst
===
--- docs/clang-tidy/checks/list.rst
+++ docs/clang-tidy/checks/list.rst
@@ -33,6 +33,7 @@
google-build-explicit-make-pair
google-build-namespaces
google-build-using-namespace
+   google-default-arguments
google-explicit-constructor
google-global-names-in-headers
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
Index: docs/clang-tidy/checks/google-default-arguments.rst
===
--- /dev/null
+++ docs/clang-tidy/checks/google-default-arguments.rst
@@ -0,0 +1,8 @@
+.. title:: clang-tidy - google-default-arguments
+
+google-default-arguments
+
+
+Checks that default arguments are not given for virtual methods.
+
+See https://google.github.io/styleguide/cppguide.html#Default_Arguments
Index: docs/ReleaseNotes.rst
===
--- docs/ReleaseNotes.rst
+++ docs/ReleaseNotes.rst
@@ -100,6 +100,11 @@
   Flags user-defined constructor definitions that do not initialize all builtin
   and pointer fields which leaves their memory in an undefined state.
 
+- New `google-default-arguments
+  `_ check
+
+  Flags default arguments in virtual methods.
+
 - New `misc-dangling-handle
   `_ check
 
Index: clang-tidy/google/GoogleTidyModule.cpp
===
--- clang-tidy/google/GoogleTidyModule.cpp
+++ clang-tidy/google/GoogleTidyModule.cpp
@@ -15,6 +15,7 @@
 #include "../readability/NamespaceCommentCheck.h"
 #include "../readability/RedundantSmartptrGetCheck.h"
 #include "AvoidCStyleCastsCheck.h"
+#include "DefaultArgumentsCheck.h"
 #include "ExplicitConstructorCheck.h"
 #include "ExplicitMakePairCheck.h"
 #include "GlobalNamesInHeadersCheck.h"
@@ -42,6 +43,8 @@
 "google-build-namespaces");
 CheckFactories.registerCheck(
 "google-build-using-namespace");
+CheckFactories.registerCheck(
+"google-default-arguments");
 CheckFactories.registerCheck(
 "google-explicit-constructor");
 CheckFactories.registerCheck(
Index: clang-tidy/google/DefaultArgumentsCheck.h
===
--- /dev/null
+++ clang-tidy/google/DefaultArgumentsCheck.h
@@ -0,0 +1,34 @@
+//===--- DefaultArgumentsCheck.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_GOOGLE_DEFAULT_ARGUMENTS_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GOOGLE_DEFAULT_ARGUMENTS_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace google {
+
+/// Checks that default parameters are not given for virtual methods.
+///
+/// See https://google.github.io/styleguide/cppguide.html#Default_Arguments
+class DefaultArgumentsCheck : public ClangTidyCheck {
+public:
+  DefaultArgumentsCheck(StringRef Name, ClangTidyContext *Context

Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

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

Is this required for some purpose?

I'm not keen on adding new AST matchers that we cannot expose via the dynamic 
API, so I would prefer to solve that problem if we want to add this matcher.

Also, be sure to regenerate the documentation from dump_ast_matchers.py


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

In http://reviews.llvm.org/D19871#419947, @aaron.ballman wrote:

> Is this required for some purpose?


It's used in clang-tidy checkers.

  see http://reviews.llvm.org/D19841
   

> I'm not keen on adding new AST matchers that we cannot expose via the dynamic 
> API, so I would prefer to solve that problem if we want to add this matcher.

> 

> Also, be sure to regenerate the documentation from dump_ast_matchers.py


Ah, this is the way to generate the doc. Thanks :)


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19534: [clang-tidy] new google-default-arguments check

2016-05-03 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: clang-tidy/google/GoogleTidyModule.cpp:40
@@ -38,1 +39,3 @@
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck(
+"google-default-arguments");

hokein wrote:
> Please keep the alphabetical order.
I think the script auto-generated that, but done.


Comment at: docs/clang-tidy/checks/google-default-arguments.rst:6
@@ +5,3 @@
+
+Checks that default parameters are not given for virtual methods.
+

hokein wrote:
> I'm a little confused about the words here. Indeed, the 
> `google-default-arguments` checks the default parameter given for virtual 
> methods.
> 
Right, I got mixed up in the terminology: the default argument is given as an 
initializer for the parameter declaration.


http://reviews.llvm.org/D19534



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-03 Thread Clement Courbet via cfe-commits
courbet updated this revision to Diff 56006.
courbet marked an inline comment as done.
courbet added a comment.

implement overridden_methods_begin()/end() in terms of overridden_methods().


http://reviews.llvm.org/D19324

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2085,6 +2085,50 @@
   notMatches("class X { virtual void f(); };", cxxMethodDecl(isFinal(;
 }
 
+TEST(Matcher, ForEachOverriden) {
+  const auto ForEachOverriddenInClass = [](const char *ClassName) {
+return cxxMethodDecl(ofClass(hasName(ClassName)), isVirtual(),
+ forEachOverridden(cxxMethodDecl().bind("overridden")))
+.bind("override");
+  };
+  constexpr const char Code1[] = "class A { virtual void f(); };"
+ "class B : public A { void f(); };"
+ "class C : public B { void f(); };";
+  // C::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("C"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // B::f overrides A::f.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 1)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code1, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  1)));
+  // A::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code1, ForEachOverriddenInClass("A")));
+
+  constexpr const char Code2[] =
+  "class A1 { virtual void f(); };"
+  "class A2 { virtual void f(); };"
+  "class B : public A1, public A2 { void f(); };";
+  // B::f overrides A1::f and A2::f. This produces two matches.
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("override", "f", 2)));
+  EXPECT_TRUE(matchAndVerifyResultTrue(
+  Code2, ForEachOverriddenInClass("B"),
+  llvm::make_unique>("overridden", "f",
+  2)));
+  // A1::f overrides nothing.
+  EXPECT_TRUE(notMatches(Code2, ForEachOverriddenInClass("A1")));
+}
+
 TEST(Matcher, MatchesVirtualMethod) {
   EXPECT_TRUE(matches("class X { virtual int f(); };",
   cxxMethodDecl(isVirtual(), hasName("::X::f";
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -182,6 +182,7 @@
   REGISTER_MATCHER(forEachArgumentWithParam);
   REGISTER_MATCHER(forEachConstructorInitializer);
   REGISTER_MATCHER(forEachDescendant);
+  REGISTER_MATCHER(forEachOverridden);
   REGISTER_MATCHER(forEachSwitchCase);
   REGISTER_MATCHER(forField);
   REGISTER_MATCHER(forStmt);
Index: lib/AST/DeclCXX.cpp
===
--- lib/AST/DeclCXX.cpp
+++ lib/AST/DeclCXX.cpp
@@ -1622,6 +1622,12 @@
   return getASTContext().overridden_methods_size(this);
 }
 
+const ArrayRef
+CXXMethodDecl::overridden_methods() const {
+  if (isa(this)) return nullptr;
+  return getASTContext().overridden_methods(this);
+}
+
 QualType CXXMethodDecl::getThisType(ASTContext &C) const {
   // C++ 9.3.2p1: The type of this in a member function of a class X is X*.
   // If the member function is declared const, the type of this is const X*,
Index: lib/AST/ASTContext.cpp
===
--- lib/AST/ASTContext.cpp
+++ lib/AST/ASTContext.cpp
@@ -1259,32 +1259,26 @@
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_begin(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-
-  return Pos->second.begin();
+  return overridden_methods(Method).begin();
 }
 
 ASTContext::overridden_cxx_method_iterator
 ASTContext::overridden_methods_end(const CXXMethodDecl *Method) const {
-  llvm::DenseMap::const_iterator Pos
-= OverriddenMethods.find(Method->getCanonicalDecl());
-  if (Pos == OverriddenMethods.end())
-return nullptr;
-
-  return Pos->second.end();
+  return overridden_methods(Method).end();
 }
 
 unsigned
 ASTContext::overridden_methods_size(cons

Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D19871#419954, @etienneb wrote:

> In http://reviews.llvm.org/D19871#419947, @aaron.ballman wrote:
>
> > Is this required for some purpose?
>
>
> It's used in clang-tidy checkers.
>
>   see http://reviews.llvm.org/D19841


It's good to have that context in a review for functionality that isn't part of 
the proposed patch. :-) Looking at the other patch, I would prefer to keep this 
matcher narrowed to just clang-tidy unless you can also solve how to expose it 
via the dynamic registry so that it can be used by tools like clang-query.

> > I'm not keen on adding new AST matchers that we cannot expose via the 
> > dynamic API, so I would prefer to solve that problem if we want to add this 
> > matcher.

> 

> > 

> 

> > Also, be sure to regenerate the documentation from dump_ast_matchers.py

> 

> 

> Ah, this is the way to generate the doc. Thanks :)


You're welcome!


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-03 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/InMemoryXrefsDB.cpp:18
@@ +17,3 @@
+InMemoryXrefsDB::InMemoryXrefsDB(
+std::map> LookupTable) {
+  for (const auto &Entry : LookupTable) {

I'd make that a const ref.


Comment at: include-fixer/InMemoryXrefsDB.cpp:24-26
@@ +23,5 @@
+for (const auto &Header : Entry.second) {
+  SymbolInfo Info;
+  Info.Name = Names.back();
+  Info.FilePath = Header;
+  for (auto IdentiferContext = Names.rbegin() + 1;

I assume it's intentional that SymbolInfo doesn't have a constructor; what's 
the reasoning behind that?


Comment at: include-fixer/IncludeFixer.h:34
@@ -33,2 +33,3 @@
   IncludeFixerActionFactory(
-  XrefsDB &Xrefs, std::vector &Replacements,
+  XrefsDBManager &XrefsDBMgr,
+  std::vector &Replacements,

Why wouldn't we still use the interface here? (usually we want to take the 
least specific type we can deal with)


http://reviews.llvm.org/D19869



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/AST/ASTContext.h:824
@@ -823,1 +823,3 @@
   unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
+  const ArrayRef overridden_methods(
+  const CXXMethodDecl *Method) const;

This is too tight of a coupling to the underlying datatype. It should return 
`iterator_range`


Comment at: include/clang/AST/DeclCXX.h:1830
@@ -1829,2 +1829,3 @@
   unsigned size_overridden_methods() const;
+  const ArrayRef overridden_methods() const;
 

This should return `iterator_range`


http://reviews.llvm.org/D19324



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

In http://reviews.llvm.org/D19871#419985, @aaron.ballman wrote:

> In http://reviews.llvm.org/D19871#419954, @etienneb wrote:
>
> > In http://reviews.llvm.org/D19871#419947, @aaron.ballman wrote:
> >
> > > Is this required for some purpose?
> >
> >
> > It's used in clang-tidy checkers.
> >
> >   see http://reviews.llvm.org/D19841
>
>
> It's good to have that context in a review for functionality that isn't part 
> of the proposed patch. :-) Looking at the other patch, I would prefer to keep 
> this matcher narrowed to just clang-tidy unless you can also solve how to 
> expose it via the dynamic registry so that it can be used by tools like 
> clang-query.


What we have done in the past with enum-arg matchers is to use string->enum 
conversion in the dynamic bindings.
See the specialization `ArgTypeTraits` in `Marshallers.h`.
We could add one for `CastKind` too.


http://reviews.llvm.org/D19871



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


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

2016-05-03 Thread Taewook Oh via cfe-commits
twoh added a comment.

Ping. Can someone please commit this patch for me? Thanks!


http://reviews.llvm.org/D19062



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

> It's good to have that context in a review for functionality that isn't part 
> of the proposed patch. :-) Looking at the other patch, I would prefer to keep 
> this matcher narrowed to just clang-tidy unless you can also solve how to 
> expose it via the dynamic registry so that it can be used by tools like 
> clang-query.


That was my original idea.

In http://reviews.llvm.org/D19871#419998, @sbenza wrote:

> In http://reviews.llvm.org/D19871#419985, @aaron.ballman wrote:
>
> > In http://reviews.llvm.org/D19871#419954, @etienneb wrote:
> >
> > > In http://reviews.llvm.org/D19871#419947, @aaron.ballman wrote:
> > >
> > > > Is this required for some purpose?
> > >
> > >
> > > It's used in clang-tidy checkers.
> > >
> > >   see http://reviews.llvm.org/D19841
> >
> >
> > It's good to have that context in a review for functionality that isn't 
> > part of the proposed patch. :-) Looking at the other patch, I would prefer 
> > to keep this matcher narrowed to just clang-tidy unless you can also solve 
> > how to expose it via the dynamic registry so that it can be used by tools 
> > like clang-query.
>
>
> What we have done in the past with enum-arg matchers is to use string->enum 
> conversion in the dynamic bindings.
>  See the specialization `ArgTypeTraits` in `Marshallers.h`.
>  We could add one for `CastKind` too.


I think I got the idea, I'll give a try to see the results. Thanks Samuel.


http://reviews.llvm.org/D19871



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


Re: [PATCH] D18035: [GCC] PR23529 Mangler part of attrbute abi_tag support

2016-05-03 Thread Reid Kleckner via cfe-commits
rnk added a comment.

I think Richard has a counterexample that shows that the "NullOut" approach to 
computing abi_tag sets isn't the right way to go. I wasn't able to craft it 
myself, but I figured I should send along the feedback that maybe a separate, 
up-front pass over the return type with a custom TypeVisitor might be a better 
way to do this.


http://reviews.llvm.org/D18035



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

In http://reviews.llvm.org/D19871#419947, @aaron.ballman wrote:

> Is this required for some purpose?
>
> I'm not keen on adding new AST matchers that we cannot expose via the dynamic 
> API, so I would prefer to solve that problem if we want to add this matcher.


I agree that when possible, matchers should be available via the dynamic 
matchers API. It doesn't seem overly complicated to add this support here. As 
far as I understand, we just need to register the matcher in 
lib/ASTMatchers/Dynamic/Registry.cpp and add support for `CastKind` argument 
type (by adding a corresponding `ArgTypeTraits` instantiation). Etienne, can 
you try this?


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-03 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: include/clang/AST/ASTContext.h:824
@@ -823,1 +823,3 @@
   unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
+  const ArrayRef overridden_methods(
+  const CXXMethodDecl *Method) const;

aaron.ballman wrote:
> This is too tight of a coupling to the underlying datatype. It should return 
> `iterator_range`
This is the exact opposite of the change that Samuel just requested 
(implementing the iterators in term of the ArrayRef getter). I don't have a 
strong opinion on this, but could you two agree on the desired API ?


http://reviews.llvm.org/D19324



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/AST/ASTContext.h:824
@@ -823,1 +823,3 @@
   unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
+  const ArrayRef overridden_methods(
+  const CXXMethodDecl *Method) const;

courbet wrote:
> aaron.ballman wrote:
> > This is too tight of a coupling to the underlying datatype. It should 
> > return `iterator_range`
> This is the exact opposite of the change that Samuel just requested 
> (implementing the iterators in term of the ArrayRef getter). I don't have a 
> strong opinion on this, but could you two agree on the desired API ?
I hadn't noticed that we disagreed, sorry for the conflicting advice. However, 
I strongly think that we should use an abstraction, and that ArrayRef is too 
concrete. FWIW, we use iterator_range in almost every other case in the code 
base when we refactored to rangify code.


http://reviews.llvm.org/D19324



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


Re: [PATCH] D19866: [Analyzer] Correct stack address escape diagnostic

2016-05-03 Thread Anna Zaks via cfe-commits
zaks.anna added a comment.

Thanks for fixing!

Devin, what do you think about the BugType wording?



Comment at: 
llvm/tools/clang/lib/StaticAnalyzer/Checkers/StackAddrEscapeChecker.cpp:229
@@ -228,3 +228,3 @@
 BT_stackleak.reset(
-new BuiltinBug(this, "Stack address stored into global variable",
-   "Stack address was saved into a global variable. "
+new BuiltinBug(this, "Stack address stored into global/static 
variable",
+   "Stack address was saved into a global/static variable. 
"

I don't like the '/' here. The only idea I have is to replace it with "into a 
variable with static allocation", which is also not ideal because it uses 
jargon.


http://reviews.llvm.org/D19866



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


Re: [PATCH] D19324: [ASTMatchers] new forEachOverriden matcher

2016-05-03 Thread Clement Courbet via cfe-commits
courbet added inline comments.


Comment at: include/clang/AST/ASTContext.h:824
@@ -823,1 +823,3 @@
   unsigned overridden_methods_size(const CXXMethodDecl *Method) const;
+  const ArrayRef overridden_methods(
+  const CXXMethodDecl *Method) const;

aaron.ballman wrote:
> courbet wrote:
> > aaron.ballman wrote:
> > > This is too tight of a coupling to the underlying datatype. It should 
> > > return `iterator_range`
> > This is the exact opposite of the change that Samuel just requested 
> > (implementing the iterators in term of the ArrayRef getter). I don't have a 
> > strong opinion on this, but could you two agree on the desired API ?
> I hadn't noticed that we disagreed, sorry for the conflicting advice. 
> However, I strongly think that we should use an abstraction, and that 
> ArrayRef is too concrete. FWIW, we use iterator_range in almost every other 
> case in the code base when we refactored to rangify code.
Samuel, are you OK with this (reverting the last change and using 
iterator_range instead of ArrayRef) ?


http://reviews.llvm.org/D19324



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


[Clang] Convergent Attribute

2016-05-03 Thread Ettore Speziale via cfe-commits
Hello,

the attached patch introduces the `convergent` attribute.

It is meant to be lowered into the LLVM `convergent` attribute, to restrict 
optimizations of attributed functions — e.g. you can attach convergent to 
OpenCL’s barrier, and thus prevent a call site being moved to another position 
which is not control equivalent. 

Bye,
Ettore Speziale



convergent.diff
Description: Binary data


--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--___
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-05-03 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 56015.
sepavloff added a comment.

Updated patch.


http://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 must 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,17 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+struct A;
+typedef int A::* P;
+
+inline P g();  // expected-warning{{inline function 'g' is not defined}}
+
+template
+struct R {
+  friend P g() {
+return M;
+  }
+};
+
+void m() {
+  g();  // expected-note{{used here}}
+}
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -8500,6 +8500,29 @@
   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
+///  belongs to.
+///
+bool Sema::shouldLinkDepend

Re: [PATCH] D19816: [find-all-symbols] Add IWYU private pragma support.

2016-05-03 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/find-all-symbols/FindAllSymbols.cpp:173-182
@@ -165,1 +172,12 @@
 
+void FindAllSymbols::addPragmaHeader(FileID ID, llvm::StringRef FilePath) {
+  PragmaHeaderMap[ID] = FilePath;
+}
+
+llvm::Optional FindAllSymbols::getPragmaHeader(FileID ID) const {
+  auto It = PragmaHeaderMap.find(ID);
+  if (It == PragmaHeaderMap.end())
+return llvm::None;
+  return It->second;
+}
+

It seems weird to add this and just forward the interface.


Comment at: include-fixer/find-all-symbols/FindAllSymbols.h:49
@@ -45,1 +48,3 @@
 
+  void addPragmaHeader(FileID ID, llvm::StringRef FilePath);
+

I think the fact that those are generated via IWYU comments are an 
implementation detail, and this code doesn't care. Perhaps call it 
HeaderMapping or HeaderRemapping. Also, it's unclear what the semantics are, so 
I think this needs a comment.


Comment at: include-fixer/find-all-symbols/PragmaCommentHandler.h:23
@@ +22,3 @@
+public:
+  PragmaCommentHandler(FindAllSymbols *Matcher) : Matcher(Matcher) {}
+

I'd pull out an interface like HeaderMapCollector or ForwardingHeaderCollector, 
or even just pass in a std::function that collects the header. Or, just make 
this PragmaCommentHandler have a method to return a list of forwarding headers?
Generally, I think this couples the two classes much more than necessary.


Repository:
  rL LLVM

http://reviews.llvm.org/D19816



___
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-05-03 Thread Serge Pavlov via cfe-commits
2016-04-26 0:55 GMT+06:00 Richard Smith :

> rsmith added inline comments.
>
> 
> Comment at: lib/Sema/SemaDecl.cpp:8611-8612
> @@ -8609,3 +8610,4 @@
>  } else {
> -  // This needs to happen first so that 'inline' propagates.
> -  NewFD->setPreviousDeclaration(cast(OldDecl));
> +  if (NewFD->isOutOfLine() &&
> +  NewFD->getLexicalDeclContext()->isDependentContext() &&
> +  IsDefinition)
> 
> Please factor this check out into a suitably-named function,
> `shouldLinkDependentDeclWithPrevious` or similar, and pass in `OldDecl` as
> well. I imagine we'll want to call this from multiple places (for instance,
> when handling `VarDecl`s), and I can see a few ways of making it return
> `true` in more cases, which would allow us to provide more precise
> diagnostics in a few more cases.
>
> (For instance, if the old and new declarations are in the same lexical
> context, we can mark them as redeclarations, and more generally I think we
> can do so if the new declaration has no more template parameters in scope
> than the old one did and the old declaration is declared within the current
> instantiation of the new declaration).
>
>
Done. The content of `shouldLinkDependentDeclWithPrevious` now supports
only the case of friend functions, more elaborated implementation will be
made latter in separate changes.


> 
> Comment at: lib/Sema/SemaDecl.cpp:8613
> @@ +8612,3 @@
> +  NewFD->getLexicalDeclContext()->isDependentContext() &&
> +  IsDefinition)
> +// Do not put friend function definitions found in template
> classes to
> 
> I don't think it makes sense to check whether the template declaration is
> a definition. It should not be added to the redeclaration chain regardless
> of whether it's a definition.
>

Indeed, without tracking of whether the declaration is a definition, the
implementation becomes simpler.


> 
> Comment at: lib/Sema/SemaDecl.cpp:10951-10956
> @@ -10941,1 +10950,8 @@
> SkipBodyInfo *SkipBody) {
> +  // Don't complain if the given declaration corresponds to the friend
> function
> +  // declared in a template class. Such declaration defines the function
> only if
> +  // the template is instantiated, in the latter case the definition must
> be
> +  // found in corresponding class instantiation.
> +  if (FD->isOutOfLine() &&
> FD->getLexicalDeclContext()->isDependentContext())
> +return;
> +
> 
> Is this change necessary? If we're not putting dependent templates into
> redeclaration chains any more, we shouldn't find an existing definition ...
>

Removed.


>
> 
> Comment at: lib/Sema/SemaDecl.cpp:10962
> @@ -10945,3 +10961,3 @@
>if (!Definition)
>  if (!FD->isDefined(Definition))
>return;
> 
> ... down here.
>
> 
> Comment at: lib/Sema/SemaDeclCXX.cpp:12663-12673
> @@ -12662,1 +12662,13 @@
>
> +  // If a friend non-dependent function is declared in a dependent
> context, do
> +  // not put it into redeclaration chain of corresponding file level
> +  // declarations. Such function will be available when the template will
> be
> +  // instantiated.
> +  } else if (CurContext->isDependentContext() &&
> + (D.getName().getKind() != UnqualifiedId::IK_TemplateId) &&
> + (SS.isInvalid() || !SS.isSet())) {
> +DC = CurContext;
> +while (!DC->isFileContext())
> +  DC = DC->getParent();
> +LookupName(Previous, S);
> +
> 
> What do these changes have to do with avoiding putting the declaration
> into the redeclaration chain? This looks equivalent to what the following
> `if` block will do, except that (a) it uses `LookupName` instead of
> `LookupQualifiedName` (which might be a bug fix but doesn't seem related to
> whether the context was dependent), and (b) it forgets to set `DCScope`
> (which looks like a bug).
>
>
Removed. All job now is done by `shouldLinkDependentDeclWithPrevious`.

http://reviews.llvm.org/D16989

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


[libcxx] r268401 - [CMake] Fix a copy-paste error

2016-05-03 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Tue May  3 11:54:20 2016
New Revision: 268401

URL: http://llvm.org/viewvc/llvm-project?rev=268401&view=rev
Log:
[CMake] Fix a copy-paste error

Based on post commit feedback from Eric Fiselier.

Modified:
libcxx/trunk/include/CMakeLists.txt

Modified: libcxx/trunk/include/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/CMakeLists.txt?rev=268401&r1=268400&r2=268401&view=diff
==
--- libcxx/trunk/include/CMakeLists.txt (original)
+++ libcxx/trunk/include/CMakeLists.txt Tue May  3 11:54:20 2016
@@ -53,7 +53,7 @@ if (LIBCXX_INSTALL_HEADERS)
 # this target is just needed as a placeholder for the distribution target
 add_custom_target(libcxx-headers)
 add_custom_target(install-libcxx-headers
-  DEPENDS ${name} libcxx-headers
+  DEPENDS libcxx-headers
   COMMAND "${CMAKE_COMMAND}"
   -DCMAKE_INSTALL_COMPONENT=libcxx-headers
   -P "${CMAKE_BINARY_DIR}/cmake_install.cmake")


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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.



> I agree that when possible, matchers should be available via the dynamic 
> matchers API. It doesn't seem overly complicated to add this support here. As 
> far as I understand, we just need to register the matcher in 
> lib/ASTMatchers/Dynamic/Registry.cpp and add support for `CastKind` argument 
> type (by adding a corresponding `ArgTypeTraits` instantiation). Etienne, can 
> you try this?




1. The parameter is passed as a string (which is not the case for the 
hasCastKind matcher): hasAttr("attr::CUDADevice").

2. There is no easy way to list every cast kind. Which means we need to 
hardcode them (or iterate over the domain) [both solution sounds terrible to 
me].

  static clang::CastKind getCastKind(llvm::StringRef AttrKind) {
return llvm::StringSwitch(AttrKind)
  .Case("CK_Dependent", CK_Dependent)
 [...]<<-- list every cast kind here.
  .Default(clang::CastKind(-1));
  }

So even if the above solution is working, we still need to call it that way (as 
a string):
clang-query> match castExpr(hasCastKind("CK_Dependent"))


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

In http://reviews.llvm.org/D19871#420095, @etienneb wrote:

> > I agree that when possible, matchers should be available via the dynamic 
> > matchers API. It doesn't seem overly complicated to add this support here. 
> > As far as I understand, we just need to register the matcher in 
> > lib/ASTMatchers/Dynamic/Registry.cpp and add support for `CastKind` 
> > argument type (by adding a corresponding `ArgTypeTraits` instantiation). 
> > Etienne, can you try this?
>
>
>
>
> 1. The parameter is passed as a string (which is not the case for the 
> hasCastKind matcher): hasAttr("attr::CUDADevice").


Correct. The dynamic registry has no support for enumerations of values, and so 
it uses strings instead. I think that's fine here as well.

> 2. There is no easy way to list every cast kind. Which means we need to 
> hardcode them (or iterate over the domain) [both solution sounds terrible to 
> me]. ``` static clang::CastKind getCastKind(llvm::StringRef AttrKind) { 
> return llvm::StringSwitch(AttrKind) .Case("CK_Dependent", 
> CK_Dependent) [...]<<-- list every cast kind here. 
> .Default(clang::CastKind(-1)); } ```


This is unfortunate, but is likely the way we would move forward.

> So even if the above solution is working, we still need to call it that way 
> (as a string):

>  clang-query> match castExpr(hasCastKind("CK_Dependent"))


Correct, that's expected behavior for clang-query (though I would love if 
someday we could expose actual enumerations somehow instead of string literals).


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb added a comment.

> though I would love if someday we could expose actual enumerations somehow 
> instead of string literals


I would like too. Ditto for "equals" which is missing :)


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 56022.
etienneb added a comment.

add dynamic parsing


http://reviews.llvm.org/D19871

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -209,6 +209,7 @@
   REGISTER_MATCHER(hasBody);
   REGISTER_MATCHER(hasCanonicalType);
   REGISTER_MATCHER(hasCaseConstant);
+  REGISTER_MATCHER(hasCastKind);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
   REGISTER_MATCHER(hasDecayedType);
Index: lib/ASTMatchers/Dynamic/Marshallers.h
===
--- lib/ASTMatchers/Dynamic/Marshallers.h
+++ lib/ASTMatchers/Dynamic/Marshallers.h
@@ -95,6 +95,85 @@
 return ArgKind(ArgKind::AK_String);
   }
 };
+///
+template <> struct ArgTypeTraits {
+private:
+  static clang::CastKind getCastKind(llvm::StringRef AttrKind) {
+return llvm::StringSwitch(AttrKind)
+  .Case("CK_Dependent", CK_Dependent)
+  .Case("CK_BitCast", CK_BitCast)
+  .Case("CK_LValueBitCast", CK_LValueBitCast)
+  .Case("CK_LValueToRValue", CK_LValueToRValue)
+  .Case("CK_NoOp", CK_NoOp)
+  .Case("CK_BaseToDerived", CK_BaseToDerived)
+  .Case("CK_DerivedToBase", CK_DerivedToBase)
+  .Case("CK_UncheckedDerivedToBase", CK_UncheckedDerivedToBase)
+  .Case("CK_Dynamic", CK_Dynamic)
+  .Case("CK_ToUnion", CK_ToUnion)
+  .Case("CK_ArrayToPointerDecay", CK_ArrayToPointerDecay)
+  .Case("CK_FunctionToPointerDecay", CK_FunctionToPointerDecay)
+  .Case("CK_NullToMemberPointer", CK_NullToMemberPointer)
+  .Case("CK_NullToPointer", CK_NullToPointer)
+  .Case("CK_BaseToDerivedMemberPointer", CK_BaseToDerivedMemberPointer)
+  .Case("CK_DerivedToBaseMemberPointer", CK_DerivedToBaseMemberPointer)
+  .Case("CK_ReinterpretMemberPointer", CK_ReinterpretMemberPointer)
+  .Case("CK_UserDefinedConversion", CK_UserDefinedConversion)
+  .Case("CK_ConstructorConversion", CK_ConstructorConversion)
+  .Case("CK_IntegralToPointer", CK_IntegralToPointer)
+  .Case("CK_PointerToIntegral", CK_PointerToIntegral)
+  .Case("CK_PointerToBoolean", CK_PointerToBoolean)
+  .Case("CK_ToVoid", CK_ToVoid)
+  .Case("CK_VectorSplat", CK_VectorSplat)
+  .Case("CK_IntegralCast", CK_IntegralCast)
+  .Case("CK_BooleanToSignedIntegral", CK_BooleanToSignedIntegral)
+  .Case("CK_IntegralToBoolean", CK_IntegralToBoolean)
+  .Case("CK_IntegralToFloating", CK_IntegralToFloating)
+  .Case("CK_FloatingToIntegral", CK_FloatingToIntegral)
+  .Case("CK_FloatingCast", CK_FloatingCast)
+  .Case("CK_FloatingToBoolean", CK_FloatingToBoolean)
+  .Case("CK_MemberPointerToBoolean", CK_MemberPointerToBoolean)
+  .Case("CK_CPointerToObjCPointerCast", CK_CPointerToObjCPointerCast)
+  .Case("CK_BlockPointerToObjCPointerCast",
+ CK_BlockPointerToObjCPointerCast)
+  .Case("CK_AnyPointerToBlockPointerCast", CK_AnyPointerToBlockPointerCast)
+  .Case("CK_ObjCObjectLValueCast", CK_ObjCObjectLValueCast)
+  .Case("CK_FloatingRealToComplex", CK_FloatingRealToComplex)
+  .Case("CK_FloatingComplexToReal", CK_FloatingComplexToReal)
+  .Case("CK_FloatingComplexToBoolean", CK_FloatingComplexToBoolean)
+  .Case("CK_FloatingComplexCast", CK_FloatingComplexCast)
+  .Case("CK_FloatingComplexToIntegralComplex",
+ CK_FloatingComplexToIntegralComplex)
+  .Case("CK_IntegralRealToComplex", CK_IntegralRealToComplex)
+  .Case("CK_IntegralComplexToReal", CK_IntegralComplexToReal)
+  .Case("CK_IntegralComplexToBoolean", CK_IntegralComplexToBoolean)
+  .Case("CK_IntegralComplexCast", CK_IntegralComplexCast)
+  .Case("CK_IntegralComplexToFloatingComplex",
+CK_IntegralComplexToFloatingComplex)
+  .Case("CK_ARCConsumeObject", CK_ARCConsumeObject)
+  .Case("CK_ARCProduceObject", CK_ARCProduceObject)
+  .Case("CK_ARCReclaimReturnedObjec

Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 56023.
etienneb added a comment.

nit


http://reviews.llvm.org/D19871

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -3475,6 +3475,13 @@
   EXPECT_TRUE(notMatches("int i = 0;", castExpr()));
 }
 
+TEST(CastExpression, HasCastKind) {
+  EXPECT_TRUE(matches("char *p = 0;",
+  castExpr(hasCastKind(CK_NullToPointer;
+  EXPECT_TRUE(notMatches("char *p = 0;",
+  castExpr(hasCastKind(CK_DerivedToBase;
+}
+
 TEST(ReinterpretCast, MatchesSimpleCase) {
   EXPECT_TRUE(matches("char* p = reinterpret_cast(&p);",
   cxxReinterpretCastExpr()));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -209,6 +209,7 @@
   REGISTER_MATCHER(hasBody);
   REGISTER_MATCHER(hasCanonicalType);
   REGISTER_MATCHER(hasCaseConstant);
+  REGISTER_MATCHER(hasCastKind);
   REGISTER_MATCHER(hasCondition);
   REGISTER_MATCHER(hasConditionVariableStatement);
   REGISTER_MATCHER(hasDecayedType);
Index: lib/ASTMatchers/Dynamic/Marshallers.h
===
--- lib/ASTMatchers/Dynamic/Marshallers.h
+++ lib/ASTMatchers/Dynamic/Marshallers.h
@@ -96,6 +96,85 @@
   }
 };
 
+template <> struct ArgTypeTraits {
+private:
+  static clang::CastKind getCastKind(llvm::StringRef AttrKind) {
+return llvm::StringSwitch(AttrKind)
+  .Case("CK_Dependent", CK_Dependent)
+  .Case("CK_BitCast", CK_BitCast)
+  .Case("CK_LValueBitCast", CK_LValueBitCast)
+  .Case("CK_LValueToRValue", CK_LValueToRValue)
+  .Case("CK_NoOp", CK_NoOp)
+  .Case("CK_BaseToDerived", CK_BaseToDerived)
+  .Case("CK_DerivedToBase", CK_DerivedToBase)
+  .Case("CK_UncheckedDerivedToBase", CK_UncheckedDerivedToBase)
+  .Case("CK_Dynamic", CK_Dynamic)
+  .Case("CK_ToUnion", CK_ToUnion)
+  .Case("CK_ArrayToPointerDecay", CK_ArrayToPointerDecay)
+  .Case("CK_FunctionToPointerDecay", CK_FunctionToPointerDecay)
+  .Case("CK_NullToMemberPointer", CK_NullToMemberPointer)
+  .Case("CK_NullToPointer", CK_NullToPointer)
+  .Case("CK_BaseToDerivedMemberPointer", CK_BaseToDerivedMemberPointer)
+  .Case("CK_DerivedToBaseMemberPointer", CK_DerivedToBaseMemberPointer)
+  .Case("CK_ReinterpretMemberPointer", CK_ReinterpretMemberPointer)
+  .Case("CK_UserDefinedConversion", CK_UserDefinedConversion)
+  .Case("CK_ConstructorConversion", CK_ConstructorConversion)
+  .Case("CK_IntegralToPointer", CK_IntegralToPointer)
+  .Case("CK_PointerToIntegral", CK_PointerToIntegral)
+  .Case("CK_PointerToBoolean", CK_PointerToBoolean)
+  .Case("CK_ToVoid", CK_ToVoid)
+  .Case("CK_VectorSplat", CK_VectorSplat)
+  .Case("CK_IntegralCast", CK_IntegralCast)
+  .Case("CK_BooleanToSignedIntegral", CK_BooleanToSignedIntegral)
+  .Case("CK_IntegralToBoolean", CK_IntegralToBoolean)
+  .Case("CK_IntegralToFloating", CK_IntegralToFloating)
+  .Case("CK_FloatingToIntegral", CK_FloatingToIntegral)
+  .Case("CK_FloatingCast", CK_FloatingCast)
+  .Case("CK_FloatingToBoolean", CK_FloatingToBoolean)
+  .Case("CK_MemberPointerToBoolean", CK_MemberPointerToBoolean)
+  .Case("CK_CPointerToObjCPointerCast", CK_CPointerToObjCPointerCast)
+  .Case("CK_BlockPointerToObjCPointerCast",
+ CK_BlockPointerToObjCPointerCast)
+  .Case("CK_AnyPointerToBlockPointerCast", CK_AnyPointerToBlockPointerCast)
+  .Case("CK_ObjCObjectLValueCast", CK_ObjCObjectLValueCast)
+  .Case("CK_FloatingRealToComplex", CK_FloatingRealToComplex)
+  .Case("CK_FloatingComplexToReal", CK_FloatingComplexToReal)
+  .Case("CK_FloatingComplexToBoolean", CK_FloatingComplexToBoolean)
+  .Case("CK_FloatingComplexCast", CK_FloatingComplexCast)
+  .Case("CK_FloatingComplexToIntegralComplex",
+ CK_FloatingComplexToIntegralComplex)
+  .Case("CK_IntegralRealToComplex", CK_IntegralRealToComplex)
+  .Case("CK_IntegralComplexToReal", CK_IntegralComplexToReal)
+  .Case("CK_IntegralComplexToBoolean", CK_IntegralComplexToBoolean)
+  .Case("CK_IntegralComplexCast", CK_IntegralComplexCast)
+  .Case("CK_IntegralComplexToFloatingComplex",
+CK_IntegralComplexToFloatingComplex)
+  .Case("CK_ARCConsumeObject", CK_ARCConsumeObject)
+  .Case("CK_ARCProduceObject", CK_ARCProduceObject)
+  .Case("CK_ARCReclaimReturnedObject", CK_ARCReclaimReturnedObject)
+  .Case("CK_ARCExtendBlockObject", CK_ARCExtendBlockObject)
+  .Ca

Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-03 Thread David Blaikie via cfe-commits
Looks good to me - go ahead & commit whenever you're ready.

On Mon, May 2, 2016 at 11:40 PM, Apelete Seketeli via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> apelete updated this revision to Diff 55952.
> apelete added a comment.
>
> [scan-build] fix dead store warnings emitted on clang code base
>
> Changes since last revision:
>
> - remove dead store since the do {} while() loop overwrite it immediatly
> anyway.
>
>
> http://reviews.llvm.org/D19831
>
> Files:
>   tools/c-index-test/c-index-test.c
>
> Index: tools/c-index-test/c-index-test.c
> ===
> --- tools/c-index-test/c-index-test.c
> +++ tools/c-index-test/c-index-test.c
> @@ -1435,7 +1435,6 @@
>  CXCursor Parent, Record;
>  unsigned RecordIsAnonymous = 0;
>  if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
> -  Record = Parent = p;
>do {
>  Record = Parent;
>  Parent = clang_getCursorSemanticParent(Record);
>
>
>
> ___
> 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] D19684: Power9 - Support for -mcpu=pwr9 in the front end

2016-05-03 Thread Kit Barton via cfe-commits
kbarton accepted this revision.
kbarton added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D19684



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


[PATCH] D19876: Add an AST matcher for string-literal length

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb created this revision.
etienneb added reviewers: alexfh, sbenza, aaron.ballman, klimek.
etienneb added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

This patch is adding support for a matcher to check string literal length.

This matcher is used in clang-tidy checkers and is part of this refactoring:
  see: http://reviews.llvm.org/D19841

http://reviews.llvm.org/D19876

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2536,6 +2536,17 @@
   EXPECT_TRUE(notMatches("const char s[1] = {'a'};", Literal));
 }
 
+TEST(StringLiteral, LengthIs) {
+  StatementMatcher Literal = stringLiteral(lengthIs(4));
+  EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));
+  // wide string
+  EXPECT_TRUE(matches("const wchar_t *s = L\"abcd\";", Literal));
+  // with escaped characters
+  EXPECT_TRUE(matches("const char *s = \"\x05\x06\x07\x08\";", Literal));
+  // no matching, too small
+  EXPECT_TRUE(notMatches("const char *s = \"ab\";", Literal));
+}
+
 TEST(Matcher, CharacterLiterals) {
   StatementMatcher CharLiteral = characterLiteral();
   EXPECT_TRUE(matches("const char c = 'c';", CharLiteral));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -323,6 +323,7 @@
   REGISTER_MATCHER(labelDecl);
   REGISTER_MATCHER(labelStmt);
   REGISTER_MATCHER(lambdaExpr);
+  REGISTER_MATCHER(lengthIs);
   REGISTER_MATCHER(lValueReferenceType);
   REGISTER_MATCHER(matchesName);
   REGISTER_MATCHER(matchesSelector);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1560,12 +1560,23 @@
 ///
 /// Example matches "abcd", L"abcd"
 /// \code
-///   char *s = "abcd"; wchar_t *ws = L"abcd"
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
   StringLiteral> stringLiteral;
 
+/// \brief Matches string length for a given string literal node.
+///
+/// Example matches "abcd", L"abcd"
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;
+}
+
 /// \brief Matches character literals (also matches wchar_t).
 ///
 /// Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -410,7 +410,7 @@
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typeAliasDecl()
   matches "using Y = int", but not "typedef int X"
 
@@ -421,7 +421,7 @@
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typedefDecl()
   matches "typedef int X", but not "using Y = int"
 
@@ -432,7 +432,7 @@
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typedefNameDecl()
   matches "typedef int X" and "using Y = int"
 
@@ -1217,7 +1217,7 @@
 Matches string literals (also matches wide string literals).
 
 Example matches "abcd", L"abcd"
-  char *s = "abcd"; wchar_t *ws = L"abcd"
+  char *s = "abcd"; wchar_t *ws = L"abcd";
 
 
 
@@ -2941,6 +2941,15 @@
 
 
 
+MatcherStringLiteral>lengthIsunsigned N
+Matches string length for a given string literal node.
+
+Example matches "abcd", L"abcd"
+  char *s = "abcd"; wchar_t *ws = L"abcd";
+  char *t = "a";
+
+
+
 MatcherTagDecl>isDefinition
 Matches if a declaration has a body attached.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 56025.
etienneb added a comment.

fix doc


http://reviews.llvm.org/D19876

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

Index: unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- unittests/ASTMatchers/ASTMatchersTest.cpp
+++ unittests/ASTMatchers/ASTMatchersTest.cpp
@@ -2536,6 +2536,17 @@
   EXPECT_TRUE(notMatches("const char s[1] = {'a'};", Literal));
 }
 
+TEST(StringLiteral, LengthIs) {
+  StatementMatcher Literal = stringLiteral(lengthIs(4));
+  EXPECT_TRUE(matches("const char *s = \"abcd\";", Literal));
+  // wide string
+  EXPECT_TRUE(matches("const wchar_t *s = L\"abcd\";", Literal));
+  // with escaped characters
+  EXPECT_TRUE(matches("const char *s = \"\x05\x06\x07\x08\";", Literal));
+  // no matching, too small
+  EXPECT_TRUE(notMatches("const char *s = \"ab\";", Literal));
+}
+
 TEST(Matcher, CharacterLiterals) {
   StatementMatcher CharLiteral = characterLiteral();
   EXPECT_TRUE(matches("const char c = 'c';", CharLiteral));
Index: lib/ASTMatchers/Dynamic/Registry.cpp
===
--- lib/ASTMatchers/Dynamic/Registry.cpp
+++ lib/ASTMatchers/Dynamic/Registry.cpp
@@ -323,6 +323,7 @@
   REGISTER_MATCHER(labelDecl);
   REGISTER_MATCHER(labelStmt);
   REGISTER_MATCHER(lambdaExpr);
+  REGISTER_MATCHER(lengthIs);
   REGISTER_MATCHER(lValueReferenceType);
   REGISTER_MATCHER(matchesName);
   REGISTER_MATCHER(matchesSelector);
Index: include/clang/ASTMatchers/ASTMatchers.h
===
--- include/clang/ASTMatchers/ASTMatchers.h
+++ include/clang/ASTMatchers/ASTMatchers.h
@@ -1560,12 +1560,25 @@
 ///
 /// Example matches "abcd", L"abcd"
 /// \code
-///   char *s = "abcd"; wchar_t *ws = L"abcd"
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
 /// \endcode
 const internal::VariadicDynCastAllOfMatcher<
   Stmt,
   StringLiteral> stringLiteral;
 
+/// \brief Matches string length for a given string literal node.
+///
+/// Example:
+///   stringLiteral(lengthIs(4))
+/// matches "abcd", L"abcd"
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;
+}
+
 /// \brief Matches character literals (also matches wchar_t).
 ///
 /// Not matching Hex-encoded chars (e.g. 0x1234, which is a IntegerLiteral),
Index: docs/LibASTMatchersReference.html
===
--- docs/LibASTMatchersReference.html
+++ docs/LibASTMatchersReference.html
@@ -410,7 +410,7 @@
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typeAliasDecl()
   matches "using Y = int", but not "typedef int X"
 
@@ -421,7 +421,7 @@
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typedefDecl()
   matches "typedef int X", but not "using Y = int"
 
@@ -432,7 +432,7 @@
 
 Given
   typedef int X;
-   using Y = int;
+  using Y = int;
 typedefNameDecl()
   matches "typedef int X" and "using Y = int"
 
@@ -1217,7 +1217,7 @@
 Matches string literals (also matches wide string literals).
 
 Example matches "abcd", L"abcd"
-  char *s = "abcd"; wchar_t *ws = L"abcd"
+  char *s = "abcd"; wchar_t *ws = L"abcd";
 
 
 
@@ -2941,6 +2941,17 @@
 
 
 
+MatcherStringLiteral>lengthIsunsigned N
+Matches string length for a given string literal node.
+
+Example:
+  stringLiteral(lengthIs(4))
+matches "abcd", L"abcd"
+  char *s = "abcd"; wchar_t *ws = L"abcd";
+  char *t = "a";
+
+
+
 MatcherTagDecl>isDefinition
 Matches if a declaration has a body attached.
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-03 Thread Eric Liu via cfe-commits
ioeric updated this revision to Diff 56026.
ioeric marked an inline comment as done.
ioeric added a comment.

- Addressed reviewer comment.


http://reviews.llvm.org/D19869

Files:
  include-fixer/CMakeLists.txt
  include-fixer/InMemoryXrefsDB.cpp
  include-fixer/InMemoryXrefsDB.h
  include-fixer/IncludeFixer.cpp
  include-fixer/IncludeFixer.h
  include-fixer/XrefsDB.h
  include-fixer/XrefsDBManager.cpp
  include-fixer/XrefsDBManager.h
  include-fixer/YamlXrefsDB.cpp
  include-fixer/YamlXrefsDB.h
  include-fixer/tool/ClangIncludeFixer.cpp
  unittests/include-fixer/IncludeFixerTest.cpp

Index: unittests/include-fixer/IncludeFixerTest.cpp
===
--- unittests/include-fixer/IncludeFixerTest.cpp
+++ unittests/include-fixer/IncludeFixerTest.cpp
@@ -9,6 +9,7 @@
 
 #include "InMemoryXrefsDB.h"
 #include "IncludeFixer.h"
+#include "XrefsDBManager.h"
 #include "unittests/Tooling/RewriterTestContext.h"
 #include "clang/Tooling/Tooling.h"
 #include "gtest/gtest.h"
@@ -51,10 +52,12 @@
   {"std::string::size_type", {""}},
   {"a::b::foo", {"dir/otherdir/qux.h"}},
   };
-  auto XrefsDB =
-  llvm::make_unique(std::move(XrefsMap));
+  auto XrefsDBMgr = llvm::make_unique();
+  XrefsDBMgr->addXrefsDB(
+  llvm::make_unique(std::move(XrefsMap)));
+
   std::vector Replacements;
-  IncludeFixerActionFactory Factory(*XrefsDB, Replacements);
+  IncludeFixerActionFactory Factory(*XrefsDBMgr, Replacements);
   runOnCode(&Factory, Code, "input.cc", ExtraArgs);
   clang::RewriterTestContext Context;
   clang::FileID ID = Context.createInMemoryFile("input.cc", Code);
@@ -79,8 +82,10 @@
   "#include \n#include \"foo.h\"\nstd::string::size_type foo;\n",
   runIncludeFixer("#include \"foo.h\"\nstd::string::size_type foo;\n"));
 
-  // The fixed xrefs db doesn't know how to handle string without std::.
-  EXPECT_EQ("string foo;\n", runIncludeFixer("string foo;\n"));
+  // string without "std::" can also be fixed since fixed db results go through
+  // XrefsDBManager, and XrefsDBManager matches unqualified identifier too.
+  EXPECT_EQ("#include \nstring foo;\n",
+runIncludeFixer("string foo;\n"));
 }
 
 TEST(IncludeFixer, IncompleteType) {
Index: include-fixer/tool/ClangIncludeFixer.cpp
===
--- include-fixer/tool/ClangIncludeFixer.cpp
+++ include-fixer/tool/ClangIncludeFixer.cpp
@@ -9,6 +9,7 @@
 
 #include "InMemoryXrefsDB.h"
 #include "IncludeFixer.h"
+#include "XrefsDBManager.h"
 #include "YamlXrefsDB.h"
 #include "clang/Frontend/TextDiagnosticPrinter.h"
 #include "clang/Rewrite/Core/Rewriter.h"
@@ -48,8 +49,8 @@
   tooling::ClangTool tool(options.getCompilations(),
   options.getSourcePathList());
 
-  // Set up the data source.
-  std::unique_ptr XrefsDB;
+  // Set up data source.
+  auto XrefsDBMgr = llvm::make_unique();
   switch (DatabaseFormat) {
   case fixed: {
 // Parse input and fill the database with it.
@@ -67,19 +68,20 @@
 Headers.push_back(Header.trim());
   XrefsMap[Split.first.trim()] = std::move(Headers);
 }
-XrefsDB =
-llvm::make_unique(std::move(XrefsMap));
+XrefsDBMgr->addXrefsDB(
+llvm::make_unique(std::move(XrefsMap)));
 break;
   }
   case yaml: {
-XrefsDB = llvm::make_unique(Input);
+XrefsDBMgr->addXrefsDB(
+llvm::make_unique(Input));
 break;
   }
   }
 
   // Now run our tool.
   std::vector Replacements;
-  include_fixer::IncludeFixerActionFactory Factory(*XrefsDB, Replacements,
+  include_fixer::IncludeFixerActionFactory Factory(*XrefsDBMgr, Replacements,
MinimizeIncludePaths);
 
   tool.run(&Factory); // Always succeeds.
Index: include-fixer/YamlXrefsDB.h
===
--- include-fixer/YamlXrefsDB.h
+++ include-fixer/YamlXrefsDB.h
@@ -23,7 +23,8 @@
 public:
   YamlXrefsDB(llvm::StringRef FilePath);
 
-  std::vector search(llvm::StringRef Identifier) override;
+  std::vector
+  search(llvm::StringRef Identifier) override;
 
 private:
   std::vector Symbols;
Index: include-fixer/XrefsDBManager.h
===
--- include-fixer/XrefsDBManager.h
+++ include-fixer/XrefsDBManager.h
@@ -1,38 +1,43 @@
-//===-- XrefsDB.h - Interface for symbol-header matching *- C++ -*-===//
+//===-- XrefsDBManager.h - Managing multiple XrefsDBs ---*- 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_INCLUDE_FIXER_XREFSDB_H
-#define LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDB_H
+#ifndef LLVM_CLANG_TOOLS_EXTRA_INCLUDE_FIXER_XREFSDBMANAGER_H
+#define LLVM_

Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-03 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/InMemoryXrefsDB.cpp:24-26
@@ +23,5 @@
+for (const auto &Header : Entry.second) {
+  SymbolInfo Info;
+  Info.Name = Names.back();
+  Info.FilePath = Header;
+  for (auto IdentiferContext = Names.rbegin() + 1;

klimek wrote:
> I assume it's intentional that SymbolInfo doesn't have a constructor; what's 
> the reasoning behind that?
SymbolInfo can be of different kinds, e.g. Function, Class etc. and has 
optional fields. I think this was the reason we didn't have a constructor for 
it. @hokein, right?


Comment at: include-fixer/IncludeFixer.h:34
@@ -33,2 +33,3 @@
   IncludeFixerActionFactory(
-  XrefsDB &Xrefs, std::vector &Replacements,
+  XrefsDBManager &XrefsDBMgr,
+  std::vector &Replacements,

klimek wrote:
> Why wouldn't we still use the interface here? (usually we want to take the 
> least specific type we can deal with)
XrefsDBManager now provides a different interface. XrefsDB provides 
`std::vector search(...)`, while XrefsDBManager provides 
`std::vector search(...)`, which just returns the #include paths.


http://reviews.llvm.org/D19869



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


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.



> > So even if the above solution is working, we still need to call it that way 
> > (as a string):

> 

> >  clang-query> match castExpr(hasCastKind("CK_Dependent"))

> 

> 

> Correct, that's expected behavior for clang-query (though I would love if 
> someday we could expose actual enumerations somehow instead of string 
> literals).


It is not hard to do, but it would require changing the parser, the registry, 
the type-erased value wrapper, etc.
The late conversion from "string" to enum was the easiest solution at the time.


http://reviews.llvm.org/D19871



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


Re: [PATCH] D19877: [clang-tidy] Speedup misc-static-assert.

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added a subscriber: aaron.ballman.
aaron.ballman accepted this revision.
aaron.ballman added a reviewer: aaron.ballman.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM, thank you for noticing that!


http://reviews.llvm.org/D19877



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


[PATCH] D19877: [clang-tidy] Speedup misc-static-assert.

2016-05-03 Thread Samuel Benzaquen via cfe-commits
sbenza created this revision.
sbenza added a reviewer: alexfh.
sbenza added a subscriber: cfe-commits.

Speedup the misc-static-assert check by not use `stmt()` as the toplevel 
matcher.
The framework runs a filter on the matchers before trying them on each node and
uses the toplevel type for this.
Using `stmt()` as the toplevel causes the matcher to be run on every `Stmt` 
node,
even if the node doesn't match the desired types.

This change speeds up clang-tidy by ~5% in a benchmark.

http://reviews.llvm.org/D19877

Files:
  clang-tidy/misc/StaticAssertCheck.cpp

Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -62,11 +62,15 @@
 hasArgument(0, AssertCondition))),
 AssertCondition);
 
-  Finder->addMatcher(stmt(anyOf(conditionalOperator(hasCondition(Condition)),
-ifStmt(hasCondition(Condition))),
-  unless(isInTemplateInstantiation()))
+  Finder->addMatcher(conditionalOperator(hasCondition(Condition),
+ unless(isInTemplateInstantiation()))
  .bind("condStmt"),
  this);
+
+  Finder->addMatcher(
+  ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation()))
+  .bind("condStmt"),
+  this);
 }
 
 void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) {


Index: clang-tidy/misc/StaticAssertCheck.cpp
===
--- clang-tidy/misc/StaticAssertCheck.cpp
+++ clang-tidy/misc/StaticAssertCheck.cpp
@@ -62,11 +62,15 @@
 hasArgument(0, AssertCondition))),
 AssertCondition);
 
-  Finder->addMatcher(stmt(anyOf(conditionalOperator(hasCondition(Condition)),
-ifStmt(hasCondition(Condition))),
-  unless(isInTemplateInstantiation()))
+  Finder->addMatcher(conditionalOperator(hasCondition(Condition),
+ unless(isInTemplateInstantiation()))
  .bind("condStmt"),
  this);
+
+  Finder->addMatcher(
+  ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation()))
+  .bind("condStmt"),
+  this);
 }
 
 void StaticAssertCheck::check(const MatchFinder::MatchResult &Result) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19871: Add an AST matcher for CastExpr kind

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: lib/ASTMatchers/Dynamic/Marshallers.h:102
@@ +101,3 @@
+  static clang::CastKind getCastKind(llvm::StringRef AttrKind) {
+return llvm::StringSwitch(AttrKind)
+  .Case("CK_Dependent", CK_Dependent)

This might be an awful idea, but let's explore it.

What if we moved the CastKind enumerator names into a .def (or .inc) file and 
use macros to generate the enumeration as well as this monster switch 
statement? We do this in other places where it makes sense to do so, such as in 
Expr.h:
```
  enum AtomicOp {
#define BUILTIN(ID, TYPE, ATTRS)
#define ATOMIC_BUILTIN(ID, TYPE, ATTRS) AO ## ID,
#include "clang/Basic/Builtins.def"
// Avoid trailing comma
BI_First = 0
  };
```


http://reviews.llvm.org/D19871



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


[PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Hans Wennborg via cfe-commits
hans created this revision.
hans added reviewers: thakis, brad.king.
hans added a subscriber: cfe-commits.

MSVC prints a blank line there, and it turns out CMake (at least currently 
released versions) expects it to be there.

http://reviews.llvm.org/D19881

Files:
  lib/Frontend/HeaderIncludeGen.cpp
  test/Frontend/print-header-includes.c

Index: test/Frontend/print-header-includes.c
===
--- test/Frontend/print-header-includes.c
+++ test/Frontend/print-header-includes.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -I%S -include Inputs/test3.h -E --show-includes -o 
/dev/null %s | \
 // RUN: FileCheck --strict-whitespace --check-prefix=MS %s
 // MS-NOT: 
+// MS: {{^$}}
 // MS: Note: including file: {{[^ ]*test3.h}}
 // MS: Note: including file: {{[^ ]*test.h}}
 // MS: Note: including file:  {{[^ ]*test2.h}}
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -99,6 +99,13 @@
 }
   }
 
+  if (MSStyle) {
+// MSVC writes a blank line at the start of the output from /showIncludes,
+// and some tools, such as certain versions of CMake (see PR27226) expect
+// it to be there.
+*OutputFile << '\n';
+  }
+
   // Print header info for extra headers, pretending they were discovered by
   // the regular preprocessor. The primary use case is to support proper
   // generation of Make / Ninja file dependencies for implicit includes, such


Index: test/Frontend/print-header-includes.c
===
--- test/Frontend/print-header-includes.c
+++ test/Frontend/print-header-includes.c
@@ -8,6 +8,7 @@
 // RUN: %clang_cc1 -I%S -include Inputs/test3.h -E --show-includes -o /dev/null %s | \
 // RUN: FileCheck --strict-whitespace --check-prefix=MS %s
 // MS-NOT: 
+// MS: {{^$}}
 // MS: Note: including file: {{[^ ]*test3.h}}
 // MS: Note: including file: {{[^ ]*test.h}}
 // MS: Note: including file:  {{[^ ]*test2.h}}
Index: lib/Frontend/HeaderIncludeGen.cpp
===
--- lib/Frontend/HeaderIncludeGen.cpp
+++ lib/Frontend/HeaderIncludeGen.cpp
@@ -99,6 +99,13 @@
 }
   }
 
+  if (MSStyle) {
+// MSVC writes a blank line at the start of the output from /showIncludes,
+// and some tools, such as certain versions of CMake (see PR27226) expect
+// it to be there.
+*OutputFile << '\n';
+  }
+
   // Print header info for extra headers, pretending they were discovered by
   // the regular preprocessor. The primary use case is to support proper
   // generation of Make / Ninja file dependencies for implicit includes, such
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Nico Weber via cfe-commits
thakis added inline comments.


Comment at: lib/Frontend/HeaderIncludeGen.cpp:106
@@ +105,3 @@
+// it to be there.
+*OutputFile << '\n';
+  }

Doesn't do that for me:

C:\src\ninja>cl /c test.cc /nologo /showIncludes
test.cc
Note: including file: c:\src\ninja\test.h


http://reviews.llvm.org/D19881



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


Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Hans Wennborg via cfe-commits
hans added inline comments.


Comment at: lib/Frontend/HeaderIncludeGen.cpp:106
@@ +105,3 @@
+// it to be there.
+*OutputFile << '\n';
+  }

thakis wrote:
> Doesn't do that for me:
> 
> C:\src\ninja>cl /c test.cc /nologo /showIncludes
> test.cc
> Note: including file: c:\src\ninja\test.h
Ah, it's the newline after "test.cc" that CMake looks for. Hmm..


http://reviews.llvm.org/D19881



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


Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Brad King via cfe-commits
brad.king added a comment.

I do not think MSVC starts off with an empty line with -showIncludes 
specifically.  It is just that MSVC unconditionally prints the name of the 
source file first.  This means that any showIncludes output is naturally 
preceded by a newline because at least one other line was printed first.  If 
clang-cl is to have compatible output with MS cl then it should print the 
source file name first too.  However, that would be a broader decision that 
should stand on its own.

IMO the motivating use case is simply a bug in CMake and clang-cl should not 
have to adapt to it.  There is already a workaround available for existing 
clang-cl/CMake release combinations.  CMake nightly binaries will be available 
starting tonight with the fix, and the CMake 3.6 release will have the fix too.


http://reviews.llvm.org/D19881



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


r268416 - Change test to use regex instead of explicit value numbers. NFC.

2016-05-03 Thread Pete Cooper via cfe-commits
Author: pete
Date: Tue May  3 13:32:01 2016
New Revision: 268416

URL: http://llvm.org/viewvc/llvm-project?rev=268416&view=rev
Log:
Change test to use regex instead of explicit value numbers.  NFC.

We were seeing an internal failure when running this test.  I can't
see a good reason for the difference, but the simple fix is to use
%{{.*}} instead of %1.

Modified:
cfe/trunk/test/CodeGen/avx512f-builtins.c

Modified: cfe/trunk/test/CodeGen/avx512f-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512f-builtins.c?rev=268416&r1=268415&r2=268416&view=diff
==
--- cfe/trunk/test/CodeGen/avx512f-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx512f-builtins.c Tue May  3 13:32:01 2016
@@ -5591,25 +5591,25 @@ __m256i test_mm512_maskz_cvttpd_epu32(__
 
 __m512d test_mm512_castpd128_pd512(__m128d __A) {
   // CHECK-LABEL: @test_mm512_castpd128_pd512
-  // CHECK: shufflevector <2 x double> %1, <2 x double> %2, <8 x i32> 
+  // CHECK: shufflevector <2 x double> %{{.*}}, <2 x double> %{{.*}}, <8 x 
i32> 
   return _mm512_castpd128_pd512(__A); 
 }
 
 __m512 test_mm512_castps128_ps512(__m128 __A) {
   // CHECK-LABEL: @test_mm512_castps128_ps512
-  // CHECK: shufflevector <4 x float> %1, <4 x float> %2, <16 x i32> 
+  // CHECK: shufflevector <4 x float> %{{.*}}, <4 x float> %{{.*}}, <16 x i32> 

   return _mm512_castps128_ps512(__A); 
 }
 
 __m512i test_mm512_castsi128_si512(__m128i __A) {
   // CHECK-LABEL: @test_mm512_castsi128_si512
-  // CHECK: shufflevector <2 x i64> %1, <2 x i64> %2, <8 x i32> 
+  // CHECK: shufflevector <2 x i64> %{{.*}}, <2 x i64> %{{.*}}, <8 x i32> 
   return _mm512_castsi128_si512(__A); 
 }
 
 __m512i test_mm512_castsi256_si512(__m256i __A) {
   // CHECK-LABEL: @test_mm512_castsi256_si512
-  // CHECK: shufflevector <4 x i64> %1, <4 x i64> %2, <8 x i32> 
+  // CHECK: shufflevector <4 x i64> %{{.*}}, <4 x i64> %{{.*}}, <8 x i32> 
   return _mm512_castsi256_si512(__A); 
 }
 


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


Re: r268385 - [Clang][avx512][Builtin] Adding intrinsics for cvtw2mask{128|256|512} instruction set

2016-05-03 Thread Pete Cooper via cfe-commits
Hi Michael

I was seeing issues with the CHECK lines referencing explicit value numbers.  
i.e., %1, %2, etc.

In r268416 I changed these to use a regex.  I hope this was ok.  Please let me 
know if you have an alternative you would prefer.

Thanks,
Pete
> On May 3, 2016, at 7:12 AM, Michael Zuckerman via cfe-commits 
>  wrote:
> 
> Author: mzuckerm
> Date: Tue May  3 09:12:23 2016
> New Revision: 268385
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=268385&view=rev
> Log:
> [Clang][avx512][Builtin] Adding intrinsics for cvtw2mask{128|256|512} 
> instruction set
> 
> Differential Revision: http://reviews.llvm.org/D19766
> 
> Modified:
>cfe/trunk/include/clang/Basic/BuiltinsX86.def
>cfe/trunk/lib/Headers/avx512bwintrin.h
>cfe/trunk/lib/Headers/avx512vlbwintrin.h
>cfe/trunk/test/CodeGen/avx512bw-builtins.c
>cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
> 
> Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=268385&r1=268384&r2=268385&view=diff
> ==
> --- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
> +++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Tue May  3 09:12:23 2016
> @@ -2256,6 +2256,9 @@ TARGET_BUILTIN(__builtin_ia32_vcvtph2ps_
> TARGET_BUILTIN(__builtin_ia32_vcvtph2ps256_mask, "V8fV8sV8fUc","","avx512vl")
> TARGET_BUILTIN(__builtin_ia32_vcvtps2ph_mask, "V8sV4fIiV8sUc","","avx512vl")
> TARGET_BUILTIN(__builtin_ia32_vcvtps2ph256_mask, 
> "V8sV8fIiV8sUc","","avx512vl")
> +TARGET_BUILTIN(__builtin_ia32_cvtw2mask512, "UiV32s","","avx512bw")
> +TARGET_BUILTIN(__builtin_ia32_cvtw2mask128, "UcV8s","","avx512bw,avx512vl")
> +TARGET_BUILTIN(__builtin_ia32_cvtw2mask256, "UsV16s","","avx512bw,avx512vl")
> 
> #undef BUILTIN
> #undef TARGET_BUILTIN
> 
> Modified: cfe/trunk/lib/Headers/avx512bwintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512bwintrin.h?rev=268385&r1=268384&r2=268385&view=diff
> ==
> --- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512bwintrin.h Tue May  3 09:12:23 2016
> @@ -2063,6 +2063,12 @@ _mm512_movepi8_mask (__m512i __A)
>   return (__mmask64) __builtin_ia32_cvtb2mask512 ((__v64qi) __A);
> }
> 
> +static __inline__ __mmask32 __DEFAULT_FN_ATTRS
> +_mm512_movepi16_mask (__m512i __A)
> +{
> +  return (__mmask32) __builtin_ia32_cvtw2mask512 ((__v32hi) __A);
> +}
> +
> static __inline__ __m512i __DEFAULT_FN_ATTRS
> _mm512_movm_epi8 (__mmask64 __A)
> {
> 
> Modified: cfe/trunk/lib/Headers/avx512vlbwintrin.h
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512vlbwintrin.h?rev=268385&r1=268384&r2=268385&view=diff
> ==
> --- cfe/trunk/lib/Headers/avx512vlbwintrin.h (original)
> +++ cfe/trunk/lib/Headers/avx512vlbwintrin.h Tue May  3 09:12:23 2016
> @@ -3181,6 +3181,18 @@ _mm256_movepi8_mask (__m256i __A)
>   return (__mmask32) __builtin_ia32_cvtb2mask256 ((__v32qi) __A);
> }
> 
> +static __inline__ __mmask8 __DEFAULT_FN_ATTRS
> +_mm_movepi16_mask (__m128i __A)
> +{
> +  return (__mmask8) __builtin_ia32_cvtw2mask128 ((__v8hi) __A);
> +}
> +
> +static __inline__ __mmask16 __DEFAULT_FN_ATTRS
> +_mm256_movepi16_mask (__m256i __A)
> +{
> +  return (__mmask16) __builtin_ia32_cvtw2mask256 ((__v16hi) __A);
> +}
> +
> static __inline__ __m128i __DEFAULT_FN_ATTRS
> _mm_movm_epi8 (__mmask16 __A)
> {
> 
> Modified: cfe/trunk/test/CodeGen/avx512bw-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512bw-builtins.c?rev=268385&r1=268384&r2=268385&view=diff
> ==
> --- cfe/trunk/test/CodeGen/avx512bw-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/avx512bw-builtins.c Tue May  3 09:12:23 2016
> @@ -1530,3 +1530,10 @@ __m512i test_mm512_sad_epu8(__m512i __A,
>   // CHECK: @llvm.x86.avx512.psad.bw.512
>   return _mm512_sad_epu8(__A, __B); 
> }
> +
> +__mmask32 test_mm512_movepi16_mask(__m512i __A) {
> +  // CHECK-LABEL: @test_mm512_movepi16_mask
> +  // CHECK: @llvm.x86.avx512.cvtw2mask.512
> +  return _mm512_movepi16_mask(__A); 
> +}
> +
> 
> Modified: cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx512vlbw-builtins.c?rev=268385&r1=268384&r2=268385&view=diff
> ==
> --- cfe/trunk/test/CodeGen/avx512vlbw-builtins.c (original)
> +++ cfe/trunk/test/CodeGen/avx512vlbw-builtins.c Tue May  3 09:12:23 2016
> @@ -2375,3 +2375,15 @@ __m256i test_mm256_maskz_dbsad_epu8(__mm
>   // CHECK: @llvm.x86.avx512.mask.dbpsadbw.256
>   return _mm256_maskz_dbsad_epu8(__U, __A, __B, 170); 
> }
> +__mmask8 test_mm_movepi16_mask(__m128i __A) {

Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Nico Weber via cfe-commits
thakis added a comment.

I agree with Brad that it'd be nice if we didn't have to add this :-)

What's the workaround for current cmake releases?


http://reviews.llvm.org/D19881



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


Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Hans Wennborg via cfe-commits
hans added a comment.

In http://reviews.llvm.org/D19881#420244, @thakis wrote:

> I agree with Brad that it'd be nice if we didn't have to add this :-)
>
> What's the workaround for current cmake releases?


Passing -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " is the 
work-around I used.

I just figured that if this is easy to fix, it would be nice for clang-cl users 
who don't have a bleeding-edge CMake version.


http://reviews.llvm.org/D19881



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


r268418 - [MS] Pass CalleeDecl to adjustThisArgumentForVirtualFunctionCall

2016-05-03 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue May  3 13:44:29 2016
New Revision: 268418

URL: http://llvm.org/viewvc/llvm-project?rev=268418&view=rev
Log:
[MS] Pass CalleeDecl to adjustThisArgumentForVirtualFunctionCall

If we are devirtualizing, then we want to compute the 'this' adjustment
of the devirtualized target, not the adjustment of the base's method
definition, which is usually zero.

Fixes PR27621

Modified:
cfe/trunk/lib/CodeGen/CGExprCXX.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp

Modified: cfe/trunk/lib/CodeGen/CGExprCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGExprCXX.cpp?rev=268418&r1=268417&r2=268418&view=diff
==
--- cfe/trunk/lib/CodeGen/CGExprCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGExprCXX.cpp Tue May  3 13:44:29 2016
@@ -274,7 +274,7 @@ RValue CodeGenFunction::EmitCXXMemberOrO
 
   if (MD->isVirtual()) {
 This = CGM.getCXXABI().adjustThisArgumentForVirtualFunctionCall(
-*this, MD, This, UseVirtualCall);
+*this, CalleeDecl, This, UseVirtualCall);
   }
 
   return EmitCXXMemberOrOperatorCall(MD, Callee, ReturnValue, 
This.getPointer(),

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp?rev=268418&r1=268417&r2=268418&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp Tue May  3 
13:44:29 2016
@@ -481,3 +481,21 @@ C::C() : B() {}
 // CHECK:   %[[FIELD:.*]] = getelementptr inbounds i8, i8* %[[B_i8]], i32 4
 // CHECK:   call void @llvm.memset.p0i8.i32(i8* %[[FIELD]], i8 0, i32 4, i32 
4, i1 false)
 }
+
+namespace pr27621 {
+// Devirtualization through a static_cast used to make us compute the 'this'
+// adjustment for B::g instead of C::g. When we directly call C::g, 'this' is a
+// B*, and the prologue of C::g will adjust it to a C*.
+struct A { virtual void f(); };
+struct B { virtual void g(); };
+struct C final : A, B {
+  virtual void h();
+  void g() override;
+};
+void callit(C *p) {
+  static_cast(p)->g();
+}
+// CHECK-LABEL: define void 
@"\01?callit@pr27621@@YAXPAUC@1@@Z"(%"struct.pr27621::C"* %{{.*}})
+// CHECK: %[[B_i8:.*]] = getelementptr i8, i8* %1, i32 4
+// CHECK: call x86_thiscallcc void @"\01?g@C@pr27621@@UAEXXZ"(i8* %[[B_i8]])
+}


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


Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Nico Weber via cfe-commits
thakis added a comment.

(Also, this "only" affects .rc compilations, not regular source compilations -- 
those don't go through cmcldeps)


http://reviews.llvm.org/D19881



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


Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Nico Weber via cfe-commits
thakis added a comment.

In http://reviews.llvm.org/D19881#420245, @hans wrote:

> In http://reviews.llvm.org/D19881#420244, @thakis wrote:
>
> > I agree with Brad that it'd be nice if we didn't have to add this :-)
> >
> > What's the workaround for current cmake releases?
>
>
> Passing -DCMAKE_CL_SHOWINCLUDES_PREFIX="Note: including file: " is the 
> work-around I used.
>
> I just figured that if this is easy to fix, it would be nice for clang-cl 
> users who don't have a bleeding-edge CMake version.


So ninja knows how to filter out the source line that cl.exe prints 
unconditionally, without a way to disable that. If you add a bare newline, 
ninja won't filter that out and this will add an empty line to each compile 
step run under ninja. To work around that, you could print the source input 
file, but that seems very undesirable.

So I think doing nothing (and documenting the workaround somewhere) is probably 
the best path forward :-/


http://reviews.llvm.org/D19881



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


r268419 - Fix use of LLVM IR names in lit test

2016-05-03 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue May  3 13:48:50 2016
New Revision: 268419

URL: http://llvm.org/viewvc/llvm-project?rev=268419&view=rev
Log:
Fix use of LLVM IR names in lit test

Modified:
cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp?rev=268419&r1=268418&r2=268419&view=diff
==
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-virtual-inheritance.cpp Tue May  3 
13:48:50 2016
@@ -496,6 +496,6 @@ void callit(C *p) {
   static_cast(p)->g();
 }
 // CHECK-LABEL: define void 
@"\01?callit@pr27621@@YAXPAUC@1@@Z"(%"struct.pr27621::C"* %{{.*}})
-// CHECK: %[[B_i8:.*]] = getelementptr i8, i8* %1, i32 4
+// CHECK: %[[B_i8:.*]] = getelementptr i8, i8* %{{.*}}, i32 4
 // CHECK: call x86_thiscallcc void @"\01?g@C@pr27621@@UAEXXZ"(i8* %[[B_i8]])
 }


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


Re: [PATCH] D19881: clang-cl: Print a blank line at the start of /showIncludes (PR27226)

2016-05-03 Thread Hans Wennborg via cfe-commits
hans abandoned this revision.
hans added a comment.

In http://reviews.llvm.org/D19881#420250, @thakis wrote:

> So ninja knows how to filter out the source line that cl.exe prints 
> unconditionally, without a way to disable that. If you add a bare newline, 
> ninja won't filter that out and this will add an empty line to each compile 
> step run under ninja. To work around that, you could print the source input 
> file, but that seems very undesirable.


Printing the source input file would be fiddly, and since this doesn't seem to 
have bitten a lot of people yet, I suppose it's not worth pursuing further.


http://reviews.llvm.org/D19881



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


Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-03 Thread Apelete Seketeli via cfe-commits
apelete added inline comments.


Comment at: tools/c-index-test/c-index-test.c:1440
@@ -1440,3 +1439,3 @@
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);
 RecordIsAnonymous = clang_Cursor_isAnonymous(Record);

This line now causes a new "uninitialized argument value" warning because 
Parent variable isn't initialized anymore and Record variable is being passed 
here without being initialized either consequently.

Will fix in next revision.


http://reviews.llvm.org/D19831



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


Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-03 Thread Apelete Seketeli via cfe-commits
apelete updated this revision to Diff 56042.
apelete added a comment.

[scan-build] fix dead store warnings emitted on clang code base

Changes since last revision:

- Initialize 'CXCursor Parent' variable to avoid passing 'Record' variable as 
an un-initialized argument thereafter.


http://reviews.llvm.org/D19831

Files:
  tools/c-index-test/c-index-test.c

Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1432,10 +1432,10 @@
 CXString FieldSpelling = clang_getCursorSpelling(cursor);
 const char *FieldName = clang_getCString(FieldSpelling);
 /* recurse to get the first parent record that is not anonymous. */
-CXCursor Parent, Record;
+CXCursor Record;
+CXCursor Parent = p;
 unsigned RecordIsAnonymous = 0;
 if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
-  Record = Parent = p;
   do {
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);


Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -1432,10 +1432,10 @@
 CXString FieldSpelling = clang_getCursorSpelling(cursor);
 const char *FieldName = clang_getCString(FieldSpelling);
 /* recurse to get the first parent record that is not anonymous. */
-CXCursor Parent, Record;
+CXCursor Record;
+CXCursor Parent = p;
 unsigned RecordIsAnonymous = 0;
 if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
-  Record = Parent = p;
   do {
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19831: [scan-build] fix dead store warnings emitted on clang code base

2016-05-03 Thread Apelete Seketeli via cfe-commits
apelete added a comment.

In http://reviews.llvm.org/D19831#420115, @dblaikie wrote:

> Looks good to me - go ahead & commit whenever you're ready.


If this last revision is good for you, please go ahead and commit this for me 
(I don't have commit access).

Thanks.


http://reviews.llvm.org/D19831



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


Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-03 Thread Manuel Klimek via cfe-commits
klimek added inline comments.


Comment at: include-fixer/IncludeFixer.h:34-35
@@ -33,3 +33,4 @@
   IncludeFixerActionFactory(
-  XrefsDB &Xrefs, std::vector &Replacements,
+  XrefsDBManager &XrefsDBMgr,
+  std::vector &Replacements,
   bool MinimizeIncludePaths = true);

That seems unexpected. Why is the XrefsDBManager in the business of doing 
SymbolInfo -> include path mappings?


http://reviews.llvm.org/D19869



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


r268422 - AArch64: simplify illegal vector check. NFC.

2016-05-03 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue May  3 14:22:41 2016
New Revision: 268422

URL: http://llvm.org/viewvc/llvm-project?rev=268422&view=rev
Log:
AArch64: simplify illegal vector check. NFC.

Use a utility function to check whether the number of elements is a power of 2
and drop the redundant upper limit (a 128-bit vector with more than 16 elements
would have each element < 8 bits, not possible).

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=268422&r1=268421&r2=268422&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May  3 14:22:41 2016
@@ -4614,7 +4614,7 @@ bool AArch64ABIInfo::isIllegalVectorType
 unsigned NumElements = VT->getNumElements();
 uint64_t Size = getContext().getTypeSize(VT);
 // NumElements should be power of 2 between 1 and 16.
-if ((NumElements & (NumElements - 1)) != 0 || NumElements > 16)
+if (!llvm::isPowerOf2_32(NumElements))
   return true;
 return Size != 64 && (Size != 128 || NumElements == 1);
   }


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


Re: [PATCH] D19869: Added XrefsDBManager into include-fixer and made XrefsDB return SymbolInfo.

2016-05-03 Thread Eric Liu via cfe-commits
ioeric added inline comments.


Comment at: include-fixer/IncludeFixer.h:34-35
@@ -33,3 +33,4 @@
   IncludeFixerActionFactory(
-  XrefsDB &Xrefs, std::vector &Replacements,
+  XrefsDBManager &XrefsDBMgr,
+  std::vector &Replacements,
   bool MinimizeIncludePaths = true);

klimek wrote:
> That seems unexpected. Why is the XrefsDBManager in the business of doing 
> SymbolInfo -> include path mappings?
Since the mapping was done in XrefsDB before, I kept the way it was. Migrating 
SymbolInfo -> Include path mappings into IncludeFixer will be the next step, 
and I'll need to discuss with Ben about where exactly we want to place it.


http://reviews.llvm.org/D19869



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


r268423 - AArch64: fixup comment after change

2016-05-03 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Tue May  3 14:24:47 2016
New Revision: 268423

URL: http://llvm.org/viewvc/llvm-project?rev=268423&view=rev
Log:
AArch64: fixup comment after change

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

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=268423&r1=268422&r2=268423&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue May  3 14:24:47 2016
@@ -4613,7 +4613,7 @@ bool AArch64ABIInfo::isIllegalVectorType
 // Check whether VT is legal.
 unsigned NumElements = VT->getNumElements();
 uint64_t Size = getContext().getTypeSize(VT);
-// NumElements should be power of 2 between 1 and 16.
+// NumElements should be power of 2.
 if (!llvm::isPowerOf2_32(NumElements))
   return true;
 return Size != 64 && (Size != 128 || NumElements == 1);


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


Re: [PATCH] D19876: Add an AST matcher for string-literal length

2016-05-03 Thread Aaron Ballman via cfe-commits
aaron.ballman added inline comments.


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1575
@@ +1574,3 @@
+/// \code
+///   char *s = "abcd"; wchar_t *ws = L"abcd";
+///   char *t = "a";

Split these onto two lines?


Comment at: include/clang/ASTMatchers/ASTMatchers.h:1578
@@ +1577,3 @@
+/// \endcode
+AST_MATCHER_P(StringLiteral, lengthIs, unsigned, N) {
+  return Node.getLength() == N;

Perhaps we can adjust the `hasSize()` matcher instead? It currently works with 
ConstantArrayType, but it seems reasonable for it to also work with 
StringLiteral.


http://reviews.llvm.org/D19876



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


  1   2   >