Re: [PATCH] D15469: Expose cxx constructor and method properties through libclang and python bindings.

2016-04-13 Thread Jonathan B Coe via cfe-commits
jbcoe updated this revision to Diff 53519.
jbcoe added a comment.

Remove python test for deleted method.

I missed this because the python tests are not run as part of check-clang - is 
this something I could submit a patch to change?


http://reviews.llvm.org/D15469

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_cursor.py
  include/clang-c/Index.h
  test/Index/availability.cpp
  test/Index/file-refs.cpp
  test/Index/get-cursor.cpp
  test/Index/index-file.cpp
  test/Index/load-classes.cpp
  test/Index/print-type.cpp
  test/Index/recursive-cxx-member-calls.cpp
  test/Parser/skip-function-bodies.mm
  tools/c-index-test/c-index-test.c
  tools/libclang/CIndex.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -2,7 +2,12 @@
 clang_CXCursorSet_insert
 clang_CXIndex_getGlobalOptions
 clang_CXIndex_setGlobalOptions
+clang_CXXConstructor_isConvertingConstructor
+clang_CXXConstructor_isCopyConstructor
+clang_CXXConstructor_isDefaultConstructor
+clang_CXXConstructor_isMoveConstructor
 clang_CXXField_isMutable
+clang_CXXMethod_isDefaulted
 clang_CXXMethod_isConst
 clang_CXXMethod_isPureVirtual
 clang_CXXMethod_isStatic
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -7379,6 +7379,48 @@
 //===--===//
 
 extern "C" {
+
+unsigned clang_CXXConstructor_isDefaultConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Constructor && Constructor->isDefaultConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isCopyConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Constructor && Constructor->isCopyConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isMoveConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Constructor && Constructor->isMoveConstructor()) ? 1 : 0;
+}
+
+unsigned clang_CXXConstructor_isConvertingConstructor(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXConstructorDecl *Constructor =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  // Passing 'false' excludes constructors marked 'explicit'.
+  return (Constructor && Constructor->isConvertingConstructor(false)) ? 1 : 0;
+}
+
 unsigned clang_CXXField_isMutable(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return 0;
@@ -7409,6 +7451,16 @@
   return (Method && (Method->getTypeQualifiers() & Qualifiers::Const)) ? 1 : 0;
 }
 
+unsigned clang_CXXMethod_isDefaulted(CXCursor C) {
+  if (!clang_isDeclaration(C.kind))
+return 0;
+
+  const Decl *D = cxcursor::getCursorDecl(C);
+  const CXXMethodDecl *Method =
+  D ? dyn_cast_or_null(D->getAsFunction()) : nullptr;
+  return (Method && Method->isDefaulted()) ? 1 : 0;
+}
+
 unsigned clang_CXXMethod_isStatic(CXCursor C) {
   if (!clang_isDeclaration(C.kind))
 return 0;
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
@@ -772,9 +772,20 @@
 
 clang_disposeString(DeprecatedMessage);
 clang_disposeString(UnavailableMessage);
-
+
+if (clang_CXXConstructor_isDefaultConstructor(Cursor))
+  printf(" (default constructor)");
+
+if (clang_CXXConstructor_isMoveConstructor(Cursor))
+  printf(" (move constructor)");
+if (clang_CXXConstructor_isCopyConstructor(Cursor))
+  printf(" (copy constructor)");
+if (clang_CXXConstructor_isConvertingConstructor(Cursor))
+  printf(" (converting constructor)");
 if (clang_CXXField_isMutable(Cursor))
   printf(" (mutable)");
+if (clang_CXXMethod_isDefaulted(Cursor))
+  printf(" (defaulted)");
 if (clang_CXXMethod_isStatic(Cursor))
   printf(" (static)");
 if (clang_CXXMethod_isVirtual(Cursor))
Index: test/Parser/skip-function-bodies.mm
===
--- test/Parser/skip-function-bodies.mm
+++ test/Parser/skip-function-bodies.mm
@@ -30,7 +30,7 @@
 // CHECK: skip-function-bodies.mm:3:7: ClassDecl=A:3:7 (Definition) Extent=[3:1 - 14:2]
 // CHECK: skip-function-bodies.mm:4:9: ClassDecl=B:4:9

Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

2016-04-13 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added inline comments.


Comment at: clang-tidy/misc/AssignOperatorCheck.cpp:63
@@ +62,3 @@
+
+  Finder->addMatcher(returnStmt(IsBadReturnStatement, 
hasAncestor(IsGoodAssign))
+ .bind("returnStmt"),

sbenza wrote:
> baloghadamsoftware wrote:
> > sbenza wrote:
> > > baloghadamsoftware wrote:
> > > > sbenza wrote:
> > > > > I dislike these uses of hasAnscestor. They are kind of slow.
> > > > > But more importantly, they break with nested functions/types.
> > > > > This particular example is not checking that the return statement is 
> > > > > from the assignment operator, only that it is within it. For example, 
> > > > > it would match a lambda.
> > > > > I think this would trip the check:
> > > > > 
> > > > > F& operator=(const F& o) {
> > > > >   std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v > 
> > > > > 0; });
> > > > >   return *this;
> > > > > }
> > > > I can change it to hasDescendant if it is faster, but it does not solve 
> > > > the lambda problem. No solution for that comes to my mind with the 
> > > > existing matchers. Maybe a new matcher hasDescendantStatement could 
> > > > help which only traverses statements down the AST. Is this the right 
> > > > way to go?
> > > hasDescendant has the same problem has hasAnscestor.
> > > I think the best is to write a matcher like:
> > > 
> > > AST_MATCHER_P(ReturnStmt, forFunction, 
> > > internal::Matcher, InnerMatcher) {
> > >   ...
> > > }
> > > 
> > > In there we can find the right FunctionDecl that encloses the return 
> > > statement and apply the matcher.
> > > This matcher seems like a good candidate to add to ASTMatchers.h
> > Maybe I am wrong, but your proposal also seems a bottom-up matcher which is 
> > slow. That is the reason I proposed a top-down matcher, e.g. 
> > hasDescendantStatement or something like this which is top-down and only 
> > traverses statements so it does not search in a lambda which is a 
> > declaration.
> hasAnscestor is slow because it is way too general. There are tons of virtual 
> function calls, cache lookups, memory allocations, etc. And the search will 
> not stop until it find a match or runs out of anscestors. This means it will 
> go all the way to the translationUnitDecl before it figures out that there 
> are no matches.
> Every parent will be run through the matcher.
> 
> What I propose is a simple matcher that:
>  1. Finds the enclosing FunctionDecl for a statement.
>  2. Runs the matcher on it, if there is an enclosing function.
> 
> (1) can be done without any virtual function call and with no/minimal memory 
> allocations.
> (2) will be done only once on the found node.
> 
I did something like your proposal and it is working, but before uploading a 
patch I have a question. There are some nodes, even statement having multiple 
parents, probably due to template instantiations. Is it enough if we chose the 
first parent here (thus going up only to the template itself) or should we do a 
depth-first (better to say height-search here, since we are not searching 
downwards in a tree but upwards in a DAG) search here and go up to every 
parent? hasAncestor uses breadth-first search which is out of the question here.


http://reviews.llvm.org/D18265



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


r266176 - [modules] Add some missing blockinfo records. No functionality change except to llvm-bcanalyzer output.

2016-04-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 13 02:41:35 2016
New Revision: 266176

URL: http://llvm.org/viewvc/llvm-project?rev=266176&view=rev
Log:
[modules] Add some missing blockinfo records. No functionality change except to 
llvm-bcanalyzer output.

Modified:
cfe/trunk/lib/Serialization/ASTWriter.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriter.cpp?rev=266176&r1=266175&r2=266176&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriter.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriter.cpp Wed Apr 13 02:41:35 2016
@@ -1121,10 +1121,22 @@ void ASTWriter::WriteBlockInfoBlock() {
   RECORD(DECL_TEMPLATE_TYPE_PARM);
   RECORD(DECL_NON_TYPE_TEMPLATE_PARM);
   RECORD(DECL_TEMPLATE_TEMPLATE_PARM);
+  RECORD(DECL_TYPE_ALIAS_TEMPLATE);
   RECORD(DECL_STATIC_ASSERT);
   RECORD(DECL_CXX_BASE_SPECIFIERS);
+  RECORD(DECL_CXX_CTOR_INITIALIZERS);
   RECORD(DECL_INDIRECTFIELD);
   RECORD(DECL_EXPANDED_NON_TYPE_TEMPLATE_PARM_PACK);
+  RECORD(DECL_EXPANDED_TEMPLATE_TEMPLATE_PARM_PACK);
+  RECORD(DECL_CLASS_SCOPE_FUNCTION_SPECIALIZATION);
+  RECORD(DECL_IMPORT);
+  RECORD(DECL_OMP_THREADPRIVATE);
+  RECORD(DECL_EMPTY);
+  RECORD(DECL_OBJC_TYPE_PARAM);
+  RECORD(DECL_OMP_CAPTUREDEXPR);
+  RECORD(DECL_PRAGMA_COMMENT);
+  RECORD(DECL_PRAGMA_DETECT_MISMATCH);
+  RECORD(DECL_OMP_DECLARE_REDUCTION);
   
   // Statements and Exprs can occur in the Decls and Types block.
   AddStmtsExprs(Stream, Record);


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


r266177 - ASTWriterDecl.cpp: Prune a couple of \param(s), corresponding to r266160. [-Wdocumentation]

2016-04-13 Thread NAKAMURA Takumi via cfe-commits
Author: chapuni
Date: Wed Apr 13 02:45:10 2016
New Revision: 266177

URL: http://llvm.org/viewvc/llvm-project?rev=266177&view=rev
Log:
ASTWriterDecl.cpp: Prune a couple of \param(s), corresponding to r266160. 
[-Wdocumentation]

Modified:
cfe/trunk/lib/Serialization/ASTWriterDecl.cpp

Modified: cfe/trunk/lib/Serialization/ASTWriterDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTWriterDecl.cpp?rev=266177&r1=266176&r2=266177&view=diff
==
--- cfe/trunk/lib/Serialization/ASTWriterDecl.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTWriterDecl.cpp Wed Apr 13 02:45:10 2016
@@ -1542,16 +1542,6 @@ void ASTDeclWriter::VisitStaticAssertDec
 }
 
 /// \brief Emit the DeclContext part of a declaration context decl.
-///
-/// \param LexicalOffset the offset at which the DECL_CONTEXT_LEXICAL
-/// block for this declaration context is stored. May be 0 to indicate
-/// that there are no declarations stored within this context.
-///
-/// \param VisibleOffset the offset at which the DECL_CONTEXT_VISIBLE
-/// block for this declaration context is stored. May be 0 to indicate
-/// that there are no declarations visible from this context. Note
-/// that this value will not be emitted for non-primary declaration
-/// contexts.
 void ASTDeclWriter::VisitDeclContext(DeclContext *DC) {
   Record.AddOffset(Writer.WriteDeclContextLexicalBlock(Context, DC));
   Record.AddOffset(Writer.WriteDeclContextVisibleBlock(Context, DC));


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


r266178 - constexpr -> const to appease MSVC bots.

2016-04-13 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Apr 13 02:47:38 2016
New Revision: 266178

URL: http://llvm.org/viewvc/llvm-project?rev=266178&view=rev
Log:
constexpr -> const to appease MSVC bots.

Modified:
cfe/trunk/include/clang/Serialization/ASTWriter.h

Modified: cfe/trunk/include/clang/Serialization/ASTWriter.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTWriter.h?rev=266178&r1=266177&r2=266178&view=diff
==
--- cfe/trunk/include/clang/Serialization/ASTWriter.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTWriter.h Wed Apr 13 02:47:38 2016
@@ -787,7 +787,7 @@ class ASTRecordWriter {
   /// declaration or type.
   SmallVector StmtsToEmit;
 
-  static constexpr int MaxOffsetIndices = 4;
+  static const int MaxOffsetIndices = 4;
   /// \brief Indices of record elements that describe offsets within the
   /// bitcode. These will be converted to offsets relative to the current
   /// record when emitted.


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


r266180 - [OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library.

2016-04-13 Thread Alexey Bader via cfe-commits
Author: bader
Date: Wed Apr 13 03:33:41 2016
New Revision: 266180

URL: http://llvm.org/viewvc/llvm-project?rev=266180&view=rev
Log:
[OpenCL] Move OpenCLImageTypes.def from clangAST to clangBasic library.

Putting OpenCLImageTypes.def to clangAST library violates layering requirement: 
"It's not OK for a Basic/ header to include an AST/ header".
This fixes the modules build.

Differential revision: http://reviews.llvm.org/D18954
Reviewers: Richard Smith, Vassil Vassilev.

Added:
cfe/trunk/include/clang/Basic/OpenCLImageTypes.def
Removed:
cfe/trunk/include/clang/AST/OpenCLImageTypes.def
Modified:
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ASTImporter.cpp
cfe/trunk/lib/AST/ExprConstant.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.h
cfe/trunk/lib/CodeGen/CGOpenCLRuntime.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=266180&r1=266179&r2=266180&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Apr 13 03:33:41 2016
@@ -904,7 +904,7 @@ public:
   CanQualType ObjCBuiltinBoolTy;
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   CanQualType SingletonId;
-#include "clang/AST/OpenCLImageTypes.def"
+#include "clang/Basic/OpenCLImageTypes.def"
   CanQualType OCLSamplerTy, OCLEventTy, OCLClkEventTy;
   CanQualType OCLQueueTy, OCLNDRangeTy, OCLReserveIDTy;
   CanQualType OMPArraySectionTy;

Removed: cfe/trunk/include/clang/AST/OpenCLImageTypes.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/OpenCLImageTypes.def?rev=266179&view=auto
==
--- cfe/trunk/include/clang/AST/OpenCLImageTypes.def (original)
+++ cfe/trunk/include/clang/AST/OpenCLImageTypes.def (removed)
@@ -1,82 +0,0 @@
-//===-- OpenCLImageTypes.def - Metadata about BuiltinTypes --*- C++ 
-*-===//
-//
-// The LLVM Compiler Infrastructure
-//
-// This file is distributed under the University of Illinois Open Source
-// License. See LICENSE.TXT for details.
-//
-//===--===//
-//  This file extends builtin types database with OpenCL image singleton types.
-//  Custom code should define one of those two macros:
-//GENERIC_IMAGE_TYPE(Type, Id) - a generic image with its Id without an 
-//  access type
-//IMAGE_TYPE(Type, Id, SingletonId, AccessType, CGSuffix) - an image type
-//  with given ID, singleton ID access type and a codegen suffix  
-
-#ifdef GENERIC_IMAGE_TYPE
-
-#define IMAGE_READ_TYPE(Type, Id) GENERIC_IMAGE_TYPE(Type, Id)
-#define IMAGE_WRITE_TYPE(Type, Id) 
-#define IMAGE_READ_WRITE_TYPE(Type, Id) 
-
-#else
-
-#ifndef IMAGE_READ_TYPE
-#define IMAGE_READ_TYPE(Type, Id) \
-  IMAGE_TYPE(Type, Id##RO, Id##ROTy,  read_only, ro)
-#endif
-#ifndef IMAGE_WRITE_TYPE
-#define IMAGE_WRITE_TYPE(Type, Id) \
-  IMAGE_TYPE(Type, Id##WO, Id##WOTy, write_only, wo)
-#endif
-#ifndef IMAGE_READ_WRITE_TYPE
-#define IMAGE_READ_WRITE_TYPE(Type, Id) \
-  IMAGE_TYPE(Type, Id##RW, Id##RWTy, read_write, rw)
-#endif
-
-#endif
-
-IMAGE_READ_TYPE(image1d, OCLImage1d)
-IMAGE_READ_TYPE(image1d_array, OCLImage1dArray)
-IMAGE_READ_TYPE(image1d_buffer, OCLImage1dBuffer)
-IMAGE_READ_TYPE(image2d, OCLImage2d)
-IMAGE_READ_TYPE(image2d_array, OCLImage2dArray)
-IMAGE_READ_TYPE(image2d_depth, OCLImage2dDepth)
-IMAGE_READ_TYPE(image2d_array_depth, OCLImage2dArrayDepth)
-IMAGE_READ_TYPE(image2d_msaa, OCLImage2dMSAA)
-IMAGE_READ_TYPE(image2d_array_msaa, OCLImage2dArrayMSAA)
-IMAGE_READ_TYPE(image2d_msaa_depth, OCLImage2dMSAADepth)
-IMAGE_READ_TYPE(image2d_array_msaa_depth, OCLImage2dArrayMSAADepth)
-IMAGE_READ_TYPE(image3d, O

Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

2016-04-13 Thread Balogh , Ádám via cfe-commits
baloghadamsoftware added a comment.

misc-unconventional-assign-operator, misc-assign-operator-conventions, 
misc-non-idiomatic-assign-operator or something else then?


http://reviews.llvm.org/D18265



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


[clang-tools-extra] r266181 - [clang-tidy] add_new_check.py should fail if check name starts with the module name

2016-04-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr 13 03:46:32 2016
New Revision: 266181

URL: http://llvm.org/viewvc/llvm-project?rev=266181&view=rev
Log:
[clang-tidy] add_new_check.py should fail if check name starts with the module 
name

+ updated formatting

Modified:
clang-tools-extra/trunk/clang-tidy/add_new_check.py

Modified: clang-tools-extra/trunk/clang-tidy/add_new_check.py
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/add_new_check.py?rev=266181&r1=266180&r2=266181&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/add_new_check.py (original)
+++ clang-tools-extra/trunk/clang-tidy/add_new_check.py Wed Apr 13 03:46:32 2016
@@ -50,8 +50,8 @@ def write_header(module_path, module, ch
   filename = os.path.join(module_path, check_name_camel) + '.h'
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
-header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() +
-'_' + check_name.upper().replace('-', '_') + '_H')
+header_guard = ('LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_' + module.upper() + '_'
++ check_name.upper().replace('-', '_') + '_H')
 f.write('//===--- ')
 f.write(os.path.basename(filename))
 f.write(' - clang-tidy')
@@ -151,7 +151,8 @@ void %(check_name)s::check(const MatchFi
 
 # Modifies the module to include the new check.
 def adapt_module(module_path, module, check_name, check_name_camel):
-  modulecpp = filter(lambda p: p.lower() == module.lower() + "tidymodule.cpp", 
os.listdir(module_path))[0]
+  modulecpp = filter(lambda p: p.lower() == module.lower() + 'tidymodule.cpp',
+ os.listdir(module_path))[0]
   filename = os.path.join(module_path, modulecpp)
   with open(filename, 'r') as f:
 lines = f.readlines()
@@ -191,13 +192,11 @@ def adapt_module(module_path, module, ch
 # Adds a test for the check.
 def write_test(module_path, module, check_name):
   check_name_dashes = module + '-' + check_name
-  filename = os.path.normpath(
-  os.path.join(module_path, '../../test/clang-tidy',
-   check_name_dashes + '.cpp'))
+  filename = os.path.normpath(os.path.join(module_path, 
'../../test/clang-tidy',
+   check_name_dashes + '.cpp'))
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
-f.write(
-"""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
+f.write("""// RUN: %%check_clang_tidy %%s %(check_name_dashes)s %%t
 
 // FIXME: Add something that triggers the check here.
 void f();
@@ -211,7 +210,8 @@ void f();
 
 // FIXME: Add something that doesn't trigger the check here.
 void awesome_f2();
-""" % {"check_name_dashes" : check_name_dashes})
+""" % {'check_name_dashes': check_name_dashes})
+
 
 # Recreates the list of checks in the docs/clang-tidy/checks directory.
 def update_checks_list(clang_tidy_path):
@@ -219,18 +219,20 @@ def update_checks_list(clang_tidy_path):
   filename = os.path.normpath(os.path.join(docs_dir, 'list.rst'))
   with open(filename, 'r') as f:
 lines = f.readlines()
-  doc_files = filter(
-  lambda s: s.endswith('.rst') and s != 'list.rst',
-  os.listdir(docs_dir))
+  doc_files = filter(lambda s: s.endswith('.rst') and s != 'list.rst',
+ os.listdir(docs_dir))
   doc_files.sort()
 
   def format_link(doc_file):
 check_name = doc_file.replace('.rst', '')
 with open(os.path.join(docs_dir, doc_file), 'r') as doc:
-  match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*', 
doc.read())
+  match = re.search('.*:http-equiv=refresh: \d+;URL=(.*).html.*',
+doc.read())
   if match:
 return '   %(check)s (redirects to %(target)s) <%(check)s>\n' % {
-'check' : check_name, 'target' : match.group(1) }
+'check': check_name,
+'target': match.group(1)
+}
   return '   %s\n' % check_name
 
   checks = map(format_link, doc_files)
@@ -243,23 +245,23 @@ def update_checks_list(clang_tidy_path):
 f.writelines(checks)
 break
 
+
 # Adds a documentation for the check.
 def write_docs(module_path, module, check_name):
   check_name_dashes = module + '-' + check_name
-  filename = os.path.normpath(
-  os.path.join(module_path, '../../docs/clang-tidy/checks/',
-   check_name_dashes + '.rst'))
+  filename = os.path.normpath(os.path.join(
+  module_path, '../../docs/clang-tidy/checks/', check_name_dashes + 
'.rst'))
   print('Creating %s...' % filename)
   with open(filename, 'wb') as f:
-f.write(
-""".. title:: clang-tidy - %(check_name_dashes)s
+f.write(""".. title:: clang-tidy - %(check_name_dashes)s
 
 %(check_name_dashes)s
 %(underline)s
 
 FIXME: Describe what patterns does the check detect and why. Give examples.
-""" % {"check_name_dashes" : check_name_dashes,
-   "underline" : "=" * len(check_name_dashes)})
+"

r266182 - [clang-tidy] Disable misc-unused-parameters for clang.

2016-04-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr 13 03:47:42 2016
New Revision: 266182

URL: http://llvm.org/viewvc/llvm-project?rev=266182&view=rev
Log:
[clang-tidy] Disable misc-unused-parameters for clang.

Modified:
cfe/trunk/.clang-tidy

Modified: cfe/trunk/.clang-tidy
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/.clang-tidy?rev=266182&r1=266181&r2=266182&view=diff
==
--- cfe/trunk/.clang-tidy (original)
+++ cfe/trunk/.clang-tidy Wed Apr 13 03:47:42 2016
@@ -1 +1 @@
-Checks: '-*,clang-diagnostic-*,llvm-*,misc-*'
+Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters'


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


r266184 - Try to use readability-identifier-naming check on Clang.

2016-04-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr 13 03:59:49 2016
New Revision: 266184

URL: http://llvm.org/viewvc/llvm-project?rev=266184&view=rev
Log:
Try to use readability-identifier-naming check on Clang.

Modified:
cfe/trunk/.clang-tidy

Modified: cfe/trunk/.clang-tidy
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/.clang-tidy?rev=266184&r1=266183&r2=266184&view=diff
==
--- cfe/trunk/.clang-tidy (original)
+++ cfe/trunk/.clang-tidy Wed Apr 13 03:59:49 2016
@@ -1 +1,12 @@
-Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters'
+Checks: 
'-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming'
+CheckOptions:
+  - key: readability-identifier-naming.ClassCase
+value:   CamelCase
+  - key: readability-identifier-naming.EnumCase
+value:   CamelCase
+  - key: readability-identifier-naming.FunctionCase
+value:   lowerCase
+  - key: readability-identifier-naming.UnionCase
+value:   CamelCase
+  - key: readability-identifier-naming.VariableCase
+value:   CamelCase


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


r266186 - Enable support for __float128 in Clang

2016-04-13 Thread Nemanja Ivanovic via cfe-commits
Author: nemanjai
Date: Wed Apr 13 04:49:45 2016
New Revision: 266186

URL: http://llvm.org/viewvc/llvm-project?rev=266186&view=rev
Log:
Enable support for __float128 in Clang

This patch corresponds to review:
http://reviews.llvm.org/D15120

It adds support for the __float128 keyword, literals and a target feature to
enable it. This support is disabled by default on all targets and any target
that has support for this type is free to add it.

Based on feedback that I've received from target maintainers, this appears to
be the right thing for most targets. I have not heard from the maintainers of
X86 which I believe supports this type. I will subsequently investigate the
impact of enabling this on X86.

Added:
cfe/trunk/test/CodeGenCXX/float128-declarations.cpp
cfe/trunk/test/Sema/float128-ld-incompatibility.cpp
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/include/clang/AST/ASTContext.h
cfe/trunk/include/clang/AST/BuiltinTypes.def
cfe/trunk/include/clang/AST/Type.h
cfe/trunk/include/clang/AST/TypeLoc.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Basic/Specifiers.h
cfe/trunk/include/clang/Basic/TargetInfo.h
cfe/trunk/include/clang/Basic/TokenKinds.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/include/clang/Lex/LiteralSupport.h
cfe/trunk/include/clang/Sema/DeclSpec.h
cfe/trunk/include/clang/Serialization/ASTBitCodes.h
cfe/trunk/lib/AST/ASTContext.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/MicrosoftMangle.cpp
cfe/trunk/lib/AST/NSAPI.cpp
cfe/trunk/lib/AST/StmtPrinter.cpp
cfe/trunk/lib/AST/Type.cpp
cfe/trunk/lib/AST/TypeLoc.cpp
cfe/trunk/lib/Analysis/PrintfFormatString.cpp
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Basic/Targets.cpp
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/CGExprScalar.cpp
cfe/trunk/lib/CodeGen/CodeGenTypes.cpp
cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
cfe/trunk/lib/Format/FormatToken.cpp
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/lib/Lex/LiteralSupport.cpp
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Parse/ParseExpr.cpp
cfe/trunk/lib/Parse/ParseExprCXX.cpp
cfe/trunk/lib/Parse/ParseTentative.cpp
cfe/trunk/lib/Sema/DeclSpec.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/lib/Sema/SemaExprCXX.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOverload.cpp
cfe/trunk/lib/Sema/SemaTemplateVariadic.cpp
cfe/trunk/lib/Sema/SemaType.cpp
cfe/trunk/lib/Serialization/ASTCommon.cpp
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Preprocessor/init.c
cfe/trunk/test/Sema/128bitfloat.cpp
cfe/trunk/test/SemaCXX/deleted-operator.cpp
cfe/trunk/test/SemaCXX/overloaded-builtin-operators.cpp
cfe/trunk/tools/libclang/CXType.cpp

Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=266186&r1=266185&r2=266186&view=diff
==
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Wed Apr 13 04:49:45 2016
@@ -1685,6 +1685,7 @@ TypeKind.DEPENDENT = TypeKind(26)
 TypeKind.OBJCID = TypeKind(27)
 TypeKind.OBJCCLASS = TypeKind(28)
 TypeKind.OBJCSEL = TypeKind(29)
+TypeKind.FLOAT128 = TypeKind(30)
 TypeKind.COMPLEX = TypeKind(100)
 TypeKind.POINTER = TypeKind(101)
 TypeKind.BLOCKPOINTER = TypeKind(102)

Modified: cfe/trunk/include/clang-c/Index.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=266186&r1=266185&r2=266186&view=diff
==
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Apr 13 04:49:45 2016
@@ -2929,6 +2929,7 @@ enum CXTypeKind {
   CXType_ObjCId = 27,
   CXType_ObjCClass = 28,
   CXType_ObjCSel = 29,
+  CXType_Float128 = 30,
   CXType_FirstBuiltin = CXType_Void,
   CXType_LastBuiltin  = CXType_ObjCSel,
 

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=266186&r1=266185&r2=266186&view=diff
==
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Wed Apr 13 04:49:45 2016
@@ -893,9 +893,10 @@ public:
   CanQualType SignedCharTy, ShortTy, IntTy, LongTy, LongLongTy, Int128Ty;
   CanQualType UnsignedCharTy, UnsignedShortTy, UnsignedIntTy, UnsignedLongTy;
   CanQualType UnsignedLongLongTy, UnsignedInt128Ty;
-  CanQualType FloatTy, DoubleTy, LongDoubleTy;
+  CanQualType FloatTy, DoubleTy, LongDoubleTy, Float128Ty;
   CanQualType HalfTy; // [OpenCL 6.1.1.1], ARM NEON
   CanQua

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alex Pilkiewicz via cfe-commits
pilki added inline comments.


Comment at:  clang-tidy/readability/DeletedDefaultCheck.cpp:37
@@ +36,3 @@
+
+void DeletedDefaultCheck::check(const MatchFinder::MatchResult &Result) {
+  const StringRef Message = "%0 is explicitly defaulted but implicitly "

alexfh wrote:
> Will it be less confusing to you, if you change "assignment" to something 
> more generic, e.g. "method" or "decl"?
> 
> Also, if you find it less readable that way, we can leave it as is for now.
I implemented the requested changes


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alex Pilkiewicz via cfe-commits
pilki updated this revision to Diff 53525.
pilki marked 2 inline comments as done.

http://reviews.llvm.org/D18961

Files:
   clang-tidy/readability/CMakeLists.txt
   clang-tidy/readability/DeletedDefaultCheck.cpp
   clang-tidy/readability/DeletedDefaultCheck.h
   clang-tidy/readability/ReadabilityTidyModule.cpp
   docs/ReleaseNotes.rst
   docs/clang-tidy/checks/list.rst
   docs/clang-tidy/checks/readability-deleted-default.rst
   test/clang-tidy/readability-deleted-default.cpp

Index:  test/clang-tidy/readability-deleted-default.cpp
===
---  test/clang-tidy/readability-deleted-default.cpp
+++  test/clang-tidy/readability-deleted-default.cpp
@@ -0,0 +1,127 @@
+// RUN: %check_clang_tidy %s readability-deleted-default %t
+
+class NoDefault {
+public:
+  NoDefault() = delete;
+  NoDefault(NoDefault &&Other) = delete;
+  NoDefault(const NoDefault &Other) = delete;
+};
+
+class MissingEverything {
+public:
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: default constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is lacking a default constructor; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is neither copyable nor movable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is not copyable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+
+private:
+  NoDefault ND;
+};
+
+class NotAssignable {
+public:
+  NotAssignable(NotAssignable &&Other) = default;
+  NotAssignable(const NotAssignable &Other) = default;
+  NotAssignable &operator=(NotAssignable &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted
+  NotAssignable &operator=(const NotAssignable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+
+private:
+  const int I = 0;
+};
+
+class Movable {
+public:
+  Movable() = default;
+  Movable(Movable &&Other) = default;
+  Movable(const Movable &Other) = delete;
+  Movable &operator=(Movable &&Other) = default;
+  Movable &operator=(const Movable &Other) = delete;
+};
+
+class NotCopyable {
+public:
+  NotCopyable(NotCopyable &&Other) = default;
+  NotCopyable(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted
+  NotCopyable &operator=(NotCopyable &&Other) = default;
+  NotCopyable &operator=(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+private:
+  Movable M;
+};
+
+template  class Templated {
+public:
+  // No warning here, it is a templated class.
+  Templated() = default;
+  Templated(Templated &&Other) = default;
+  Templated(const Templated &Other) = default;
+  Templated &operator=(Templated &&Other) = default;
+  Templated &operator=(const Templated &Other) = default;
+
+  class InnerTemplated {
+  public:
+// This class is not in itself templated, but we still don't have warning.
+InnerTemplated() = default;
+InnerTemplated(InnerTemplated &&Other) = default;
+InnerTemplated(const InnerTemplated &Other) = default;
+InnerTemplated &operator=(InnerTemplated &&Other) = default;
+InnerTemplated &operator=(const InnerTemplated &Other) = default;
+
+  private:
+T TVar;
+  };
+
+  class InnerNotTemplated {
+  public:
+// This one could technically have warnings, but currently doesn't.
+InnerNotTemplated() = default;
+InnerNotTemplated(InnerNotTemplated &&Other) = default;
+InnerNotTemplated(const InnerNotTemplated &Other) = default

r266187 - [modules] Add OpenCLImageTypes.def to module map to fix the modules build.

2016-04-13 Thread Alexey Bader via cfe-commits
Author: bader
Date: Wed Apr 13 04:54:47 2016
New Revision: 266187

URL: http://llvm.org/viewvc/llvm-project?rev=266187&view=rev
Log:
[modules] Add OpenCLImageTypes.def to module map to fix the modules build.

Modified:
cfe/trunk/include/clang/module.modulemap

Modified: cfe/trunk/include/clang/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/module.modulemap?rev=266187&r1=266186&r2=266187&view=diff
==
--- cfe/trunk/include/clang/module.modulemap (original)
+++ cfe/trunk/include/clang/module.modulemap Wed Apr 13 04:54:47 2016
@@ -41,6 +41,7 @@ module Clang_Basic {
   textual header "Basic/DiagnosticOptions.def"
   textual header "Basic/LangOptions.def"
   textual header "Basic/OpenCLExtensions.def"
+  textual header "Basic/OpenCLImageTypes.def"
   textual header "Basic/OpenMPKinds.def"
   textual header "Basic/OperatorKinds.def"
   textual header "Basic/Sanitizers.def"


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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Thank you for addressing the comments!

I'll commit the patch for you.


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

The patch doesn't apply cleanly. Please rebase it against current HEAD.


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alex Pilkiewicz via cfe-commits
pilki updated this revision to Diff 53529.

http://reviews.llvm.org/D18961

Files:
   clang-tidy/readability/CMakeLists.txt
   clang-tidy/readability/DeletedDefaultCheck.cpp
   clang-tidy/readability/DeletedDefaultCheck.h
   clang-tidy/readability/ReadabilityTidyModule.cpp
   docs/ReleaseNotes.rst
   docs/clang-tidy/checks/list.rst
   docs/clang-tidy/checks/readability-deleted-default.rst
   test/clang-tidy/readability-deleted-default.cpp

Index:  test/clang-tidy/readability-deleted-default.cpp
===
---  test/clang-tidy/readability-deleted-default.cpp
+++  test/clang-tidy/readability-deleted-default.cpp
@@ -0,0 +1,127 @@
+// RUN: %check_clang_tidy %s readability-deleted-default %t
+
+class NoDefault {
+public:
+  NoDefault() = delete;
+  NoDefault(NoDefault &&Other) = delete;
+  NoDefault(const NoDefault &Other) = delete;
+};
+
+class MissingEverything {
+public:
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: default constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is lacking a default constructor; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is neither copyable nor movable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is not copyable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+
+private:
+  NoDefault ND;
+};
+
+class NotAssignable {
+public:
+  NotAssignable(NotAssignable &&Other) = default;
+  NotAssignable(const NotAssignable &Other) = default;
+  NotAssignable &operator=(NotAssignable &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted
+  NotAssignable &operator=(const NotAssignable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+
+private:
+  const int I = 0;
+};
+
+class Movable {
+public:
+  Movable() = default;
+  Movable(Movable &&Other) = default;
+  Movable(const Movable &Other) = delete;
+  Movable &operator=(Movable &&Other) = default;
+  Movable &operator=(const Movable &Other) = delete;
+};
+
+class NotCopyable {
+public:
+  NotCopyable(NotCopyable &&Other) = default;
+  NotCopyable(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted
+  NotCopyable &operator=(NotCopyable &&Other) = default;
+  NotCopyable &operator=(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+private:
+  Movable M;
+};
+
+template  class Templated {
+public:
+  // No warning here, it is a templated class.
+  Templated() = default;
+  Templated(Templated &&Other) = default;
+  Templated(const Templated &Other) = default;
+  Templated &operator=(Templated &&Other) = default;
+  Templated &operator=(const Templated &Other) = default;
+
+  class InnerTemplated {
+  public:
+// This class is not in itself templated, but we still don't have warning.
+InnerTemplated() = default;
+InnerTemplated(InnerTemplated &&Other) = default;
+InnerTemplated(const InnerTemplated &Other) = default;
+InnerTemplated &operator=(InnerTemplated &&Other) = default;
+InnerTemplated &operator=(const InnerTemplated &Other) = default;
+
+  private:
+T TVar;
+  };
+
+  class InnerNotTemplated {
+  public:
+// This one could technically have warnings, but currently doesn't.
+InnerNotTemplated() = default;
+InnerNotTemplated(InnerNotTemplated &&Other) = default;
+InnerNotTemplated(const InnerNotTemplated &Other) = default;
+InnerNotTemplated &operator=(Inne

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alex Pilkiewicz via cfe-commits
pilki added a comment.

I did svn up and reuploaded the diff. I did not see any changes on files I 
touched, so I'm not sure it worked.


http://reviews.llvm.org/D18961



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


r266188 - [Clang][AVX512][Builtin] Adding supporting to intrinsics of cvt{b|d|q}2mask{128|256|512} and cvtmask2{b|d|q}{128|256|512} instruction set.

2016-04-13 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Apr 13 05:49:37 2016
New Revision: 266188

URL: http://llvm.org/viewvc/llvm-project?rev=266188&view=rev
Log:
[Clang][AVX512][Builtin] Adding supporting to intrinsics of 
cvt{b|d|q}2mask{128|256|512} and cvtmask2{b|d|q}{128|256|512} instruction set.

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-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=266188&r1=266187&r2=266188&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Apr 13 05:49:37 2016
@@ -1962,6 +1962,27 @@ TARGET_BUILTIN(__builtin_ia32_rsqrt14pd1
 TARGET_BUILTIN(__builtin_ia32_rsqrt14pd256_mask, "V4dV4dV4dUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_rsqrt14ps128_mask, "V4fV4fV4fUc","","avx512vl")
 TARGET_BUILTIN(__builtin_ia32_rsqrt14ps256_mask, "V8fV8fV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtb2mask512, "ULLiV64c","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2b512, "V64cULLi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2w512, "V32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_cvtd2mask512, "UsV16i","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2d512, "V16iUs","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2q512, "V8LLiUc","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_cvtq2mask512, "UcV8LLi","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_cvtb2mask128, "UsV16c","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtb2mask256, "UiV32c","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2b128, "V16cUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2b256, "V32cUi","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2w128, "V8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2w256, "V16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtd2mask128, "UcV4i","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtd2mask256, "UcV8i","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2d128, "V4iUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2d256, "V8iUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2q128, "V2LLiUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtmask2q256, "V4LLiUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtq2mask128, "UcV2LLi","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_cvtq2mask256, "UcV4LLi","","avx512dq,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=266188&r1=266187&r2=266188&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Wed Apr 13 05:49:37 2016
@@ -2057,6 +2057,24 @@ _mm512_mask_testn_epi16_mask (__mmask32
  (__v32hi) __B, __U);
 }
 
+static __inline__ __mmask64 __DEFAULT_FN_ATTRS
+_mm512_movepi8_mask (__m512i __A)
+{
+  return (__mmask64) __builtin_ia32_cvtb2mask512 ((__v64qi) __A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_movm_epi8 (__mmask64 __A)
+{
+  return (__m512i) __builtin_ia32_cvtmask2b512 (__A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_movm_epi16 (__mmask32 __A)
+{
+  return (__m512i) __builtin_ia32_cvtmask2w512 (__A);
+}
+
 
 #undef __DEFAULT_FN_ATTRS
 

Modified: cfe/trunk/lib/Headers/avx512dqintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/avx512dqintrin.h?rev=266188&r1=266187&r2=266188&view=diff
==
--- cfe/trunk/lib/Headers/avx512dqintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512dqintrin.h Wed Apr 13 05:49:37 2016
@@ -773,6 +773,31 @@ _mm512_maskz_cvtepu64_ps (__mmask8 __U,
   (__m512) __builtin_ia32_reduceps512_mask ((__v16sf) __A, __B,  \
(__v16sf) _mm512_setzero_ps(), (__mmask16) __U, __R);})
 
+static __inline__ __mmask16 __DEFAULT_FN_ATTRS
+_mm512_movepi32_mask (__m512i __A)
+{
+  return (__mmask16) __builtin_ia32_cvtd2mask512 ((__v16si) __A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_movm_epi32 (__mmask16 __A)
+{
+  return (__m512i) __builtin_ia32_cvtmask2d512 (__A);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_movm_epi64 (__mmask8 __A)

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

Something is weird with your patch: it has names starting with a space (note 
two spaces between "Index:" and "clang-tidy/..."):

  Index:  clang-tidy/readability/CMakeLists.txt
  ===
  ---  clang-tidy/readability/CMakeLists.txt
  +++  clang-tidy/readability/CMakeLists.txt
  @@ -4,6 +4,7 @@
 AvoidConstParamsInDecls.cpp
 BracesAroundStatementsCheck.cpp
 ContainerSizeEmptyCheck.cpp
  +  DeletedDefaultCheck.cpp
 ElseAfterReturnCheck.cpp
 FunctionSizeCheck.cpp
 IdentifierNamingCheck.cpp
  Index:  clang-tidy/readability/DeletedDefaultCheck.h
  ===

For comparison, a normal diff:
http://reviews.llvm.org/file/data/ldmp5jqxuvect5cwpyer/PHID-FILE-3rnivuajuco4mxhb6nzh/D18962.diff

  Index: llvm/trunk/lib/Target/SystemZ/README.txt
  ===
  --- llvm/trunk/lib/Target/SystemZ/README.txt
  +++ llvm/trunk/lib/Target/SystemZ/README.txt
  @@ -43,11 +43,6 @@
   


http://reviews.llvm.org/D18961



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alex Pilkiewicz via cfe-commits
pilki updated this revision to Diff 53532.

http://reviews.llvm.org/D18961

Files:
   clang-tidy/readability/CMakeLists.txt
   clang-tidy/readability/DeletedDefaultCheck.cpp
   clang-tidy/readability/DeletedDefaultCheck.h
   clang-tidy/readability/ReadabilityTidyModule.cpp
   docs/ReleaseNotes.rst
   docs/clang-tidy/checks/list.rst
   docs/clang-tidy/checks/readability-deleted-default.rst
   test/clang-tidy/readability-deleted-default.cpp

Index:  test/clang-tidy/readability-deleted-default.cpp
===
---  test/clang-tidy/readability-deleted-default.cpp
+++  test/clang-tidy/readability-deleted-default.cpp
@@ -0,0 +1,127 @@
+// RUN: %check_clang_tidy %s readability-deleted-default %t
+
+class NoDefault {
+public:
+  NoDefault() = delete;
+  NoDefault(NoDefault &&Other) = delete;
+  NoDefault(const NoDefault &Other) = delete;
+};
+
+class MissingEverything {
+public:
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: default constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is lacking a default constructor; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is neither copyable nor movable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is not copyable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+
+private:
+  NoDefault ND;
+};
+
+class NotAssignable {
+public:
+  NotAssignable(NotAssignable &&Other) = default;
+  NotAssignable(const NotAssignable &Other) = default;
+  NotAssignable &operator=(NotAssignable &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted
+  NotAssignable &operator=(const NotAssignable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+
+private:
+  const int I = 0;
+};
+
+class Movable {
+public:
+  Movable() = default;
+  Movable(Movable &&Other) = default;
+  Movable(const Movable &Other) = delete;
+  Movable &operator=(Movable &&Other) = default;
+  Movable &operator=(const Movable &Other) = delete;
+};
+
+class NotCopyable {
+public:
+  NotCopyable(NotCopyable &&Other) = default;
+  NotCopyable(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted
+  NotCopyable &operator=(NotCopyable &&Other) = default;
+  NotCopyable &operator=(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+private:
+  Movable M;
+};
+
+template  class Templated {
+public:
+  // No warning here, it is a templated class.
+  Templated() = default;
+  Templated(Templated &&Other) = default;
+  Templated(const Templated &Other) = default;
+  Templated &operator=(Templated &&Other) = default;
+  Templated &operator=(const Templated &Other) = default;
+
+  class InnerTemplated {
+  public:
+// This class is not in itself templated, but we still don't have warning.
+InnerTemplated() = default;
+InnerTemplated(InnerTemplated &&Other) = default;
+InnerTemplated(const InnerTemplated &Other) = default;
+InnerTemplated &operator=(InnerTemplated &&Other) = default;
+InnerTemplated &operator=(const InnerTemplated &Other) = default;
+
+  private:
+T TVar;
+  };
+
+  class InnerNotTemplated {
+  public:
+// This one could technically have warnings, but currently doesn't.
+InnerNotTemplated() = default;
+InnerNotTemplated(InnerNotTemplated &&Other) = default;
+InnerNotTemplated(const InnerNotTemplated &Other) = default;
+InnerNotTemplated &operator=(Inne

Re: [PATCH] D19038: Add AST Matchers for CXXConstructorDecl::isDelegatingConstructor and CXXMethodDecl::isUserProvided.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh added a comment.

LG.


http://reviews.llvm.org/D19038



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


Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alex Pilkiewicz via cfe-commits
pilki updated this revision to Diff 53533.

http://reviews.llvm.org/D18961

Files:
  clang-tidy/readability/CMakeLists.txt
  clang-tidy/readability/DeletedDefaultCheck.cpp
  clang-tidy/readability/DeletedDefaultCheck.h
  clang-tidy/readability/ReadabilityTidyModule.cpp
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/readability-deleted-default.rst
  test/clang-tidy/readability-deleted-default.cpp

Index: test/clang-tidy/readability-deleted-default.cpp
===
--- test/clang-tidy/readability-deleted-default.cpp
+++ test/clang-tidy/readability-deleted-default.cpp
@@ -0,0 +1,127 @@
+// RUN: %check_clang_tidy %s readability-deleted-default %t
+
+class NoDefault {
+public:
+  NoDefault() = delete;
+  NoDefault(NoDefault &&Other) = delete;
+  NoDefault(const NoDefault &Other) = delete;
+};
+
+class MissingEverything {
+public:
+  MissingEverything() = default;
+  // CHECK-MESSAGES: warning: default constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is lacking a default constructor; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is neither copyable nor movable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted, probably because a non-static data member or a base class is not copyable; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(MissingEverything &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+  MissingEverything &operator=(const MissingEverything &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted, probably because a base class or a non-static data member is not assignable, e.g. because the latter is marked 'const'; definition can either be removed or explicitly deleted [readability-deleted-default]
+
+private:
+  NoDefault ND;
+};
+
+class NotAssignable {
+public:
+  NotAssignable(NotAssignable &&Other) = default;
+  NotAssignable(const NotAssignable &Other) = default;
+  NotAssignable &operator=(NotAssignable &&Other) = default;
+  // CHECK-MESSAGES: warning: move assignment operator is explicitly defaulted but implicitly deleted
+  NotAssignable &operator=(const NotAssignable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+
+private:
+  const int I = 0;
+};
+
+class Movable {
+public:
+  Movable() = default;
+  Movable(Movable &&Other) = default;
+  Movable(const Movable &Other) = delete;
+  Movable &operator=(Movable &&Other) = default;
+  Movable &operator=(const Movable &Other) = delete;
+};
+
+class NotCopyable {
+public:
+  NotCopyable(NotCopyable &&Other) = default;
+  NotCopyable(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy constructor is explicitly defaulted but implicitly deleted
+  NotCopyable &operator=(NotCopyable &&Other) = default;
+  NotCopyable &operator=(const NotCopyable &Other) = default;
+  // CHECK-MESSAGES: warning: copy assignment operator is explicitly defaulted but implicitly deleted
+private:
+  Movable M;
+};
+
+template  class Templated {
+public:
+  // No warning here, it is a templated class.
+  Templated() = default;
+  Templated(Templated &&Other) = default;
+  Templated(const Templated &Other) = default;
+  Templated &operator=(Templated &&Other) = default;
+  Templated &operator=(const Templated &Other) = default;
+
+  class InnerTemplated {
+  public:
+// This class is not in itself templated, but we still don't have warning.
+InnerTemplated() = default;
+InnerTemplated(InnerTemplated &&Other) = default;
+InnerTemplated(const InnerTemplated &Other) = default;
+InnerTemplated &operator=(InnerTemplated &&Other) = default;
+InnerTemplated &operator=(const InnerTemplated &Other) = default;
+
+  private:
+T TVar;
+  };
+
+  class InnerNotTemplated {
+  public:
+// This one could technically have warnings, but currently doesn't.
+InnerNotTemplated() = default;
+InnerNotTemplated(InnerNotTemplated &&Other) = default;
+InnerNotTemplated(const InnerNotTemplated &Other) = default;
+InnerNotTemplated &operator=(InnerNotTemplat

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alex Pilkiewicz via cfe-commits
pilki added a comment.

Sorry, both my 'diff' and my 'svn' command added some magical coloring... It 
should be good now.


http://reviews.llvm.org/D18961



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


r266189 - Add AST Matchers for CXXConstructorDecl::isDelegatingConstructor and CXXMethodDecl::isUserProvided.

2016-04-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr 13 06:13:08 2016
New Revision: 266189

URL: http://llvm.org/viewvc/llvm-project?rev=266189&view=rev
Log:
Add AST Matchers for CXXConstructorDecl::isDelegatingConstructor and 
CXXMethodDecl::isUserProvided.

Summary: Added two AST matchers: isDelegatingConstructor for 
CXXConstructorDecl::IsDelegatingConstructor; and isUserProvided corresponding 
to CXXMethodDecl::isUserProvided.

Reviewers: aaron.ballman, alexfh

Subscribers: klimek, cfe-commits

Patch by Michael Miller!

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

Modified:
cfe/trunk/docs/LibASTMatchersReference.html
cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Modified: cfe/trunk/docs/LibASTMatchersReference.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LibASTMatchersReference.html?rev=266189&r1=266188&r2=266189&view=diff
==
--- cfe/trunk/docs/LibASTMatchersReference.html (original)
+++ cfe/trunk/docs/LibASTMatchersReference.html Wed Apr 13 06:13:08 2016
@@ -1799,6 +1799,21 @@ cxxConstructorDecl(isDefaultConstructor(
 
 
 
+MatcherCXXConstructorDecl>isDelegatingConstructor
+Matches 
constructors that delegate to another constructor.
+
+Given
+  struct S {
+S(); #1
+S(int) {} #2
+S(S &&) : S() {} #3
+  };
+  S::S() : S(0) {} #4
+cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
+#1 or #2.
+
+
+
 MatcherCXXConstructorDecl>isExplicit
 Matches constructor and 
conversion declarations that are marked with
 the explicit keyword.
@@ -1983,6 +1998,19 @@ Given
 
 
 
+MatcherCXXMethodDecl>isUserProvided
+Matches method 
declarations that are user-provided.
+
+Given
+  struct S {
+S(); #1
+S(const S &) = default; #2
+S(S &&) = delete; #3
+  };
+cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
+
+
+
 MatcherCXXMethodDecl>isVirtual
 Matches if the given 
method declaration is virtual.
 
@@ -2538,7 +2566,7 @@ memberExpr(isArrow())
 
 
 
-MatcherNamedDecl>hasNamestd::string Name
+MatcherNamedDecl>hasNamestd::string  Name
 Matches NamedDecl nodes 
that have the specified name.
 
 Supports specifying enclosing namespaces or classes by prefixing the name
@@ -2731,13 +2759,20 @@ matches "a(char)", "b(wchar_t)", but not
 
 
 MatcherQualType>isAnyPointer
-Matches QualType nodes 
that are of any pointer type.
+Matches QualType nodes 
that are of any pointer type; this includes
+the Objective-C object pointer type, which is different despite being
+syntactically similar.
 
 Given
   int *i = nullptr;
+
+  @interface Foo
+  @end
+  Foo *f;
+
   int j;
 varDecl(hasType(isAnyPointer()))
-  matches "int *i", but not "int j".
+  matches "int *i" and "Foo *f", but not "int j".
 
 
 
@@ -3228,16 +3263,6 @@ expr(nullPointerConstant())
 
 
 
-MatcherNamedDecl>>hasAnyNameStringRef, ..., 
StringRef
-Matches NamedDecl nodes 
that have any of the specified names.
-
-This matcher is only provided as a performance optimization of hasName.
-hasAnyName(a, b, c)
- is equivalent but faster than
-anyOf(hasName(a), hasName(b), hasName(c))
-
-
-
 MatcherStmt>>isInTemplateInstantiation
 Matches 
statements inside of a template instantiation.
 

Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h?rev=266189&r1=266188&r2=266189&view=diff
==
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h (original)
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h Wed Apr 13 06:13:08 2016
@@ -3803,6 +3803,21 @@ AST_MATCHER(CXXMethodDecl, isOverride) {
   return Node.size_overridden_methods() > 0 || Node.hasAttr();
 }
 
+/// \brief Matches method declarations that are user-provided.
+///
+/// Given
+/// \code
+///   struct S {
+/// S(); // #1
+/// S(const S &) = default; // #2
+/// S(S &&) = delete; // #3
+///   };
+/// \endcode
+/// cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
+AST_MATCHER(CXXMethodDecl, isUserProvided) {
+  return Node.isUserProvided();
+}
+
 /// \brief Matches member expressions that are called with '->' as opposed
 /// to '.'.
 ///
@@ -4911,6 +4926,23 @@ AST_MATCHER(CXXConstructorDecl, isDefaul
   retu

Re: [PATCH] D19038: Add AST Matchers for CXXConstructorDecl::isDelegatingConstructor and CXXMethodDecl::isUserProvided.

2016-04-13 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266189: Add AST Matchers for 
CXXConstructorDecl::isDelegatingConstructor and… (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D19038?vs=53479&id=53534#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19038

Files:
  cfe/trunk/docs/LibASTMatchersReference.html
  cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
  cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp

Index: cfe/trunk/docs/LibASTMatchersReference.html
===
--- cfe/trunk/docs/LibASTMatchersReference.html
+++ cfe/trunk/docs/LibASTMatchersReference.html
@@ -1799,6 +1799,21 @@
 
 
 
+MatcherCXXConstructorDecl>isDelegatingConstructor
+Matches constructors that delegate to another constructor.
+
+Given
+  struct S {
+S(); #1
+S(int) {} #2
+S(S &&) : S() {} #3
+  };
+  S::S() : S(0) {} #4
+cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
+#1 or #2.
+
+
+
 MatcherCXXConstructorDecl>isExplicit
 Matches constructor and conversion declarations that are marked with
 the explicit keyword.
@@ -1983,6 +1998,19 @@
 
 
 
+MatcherCXXMethodDecl>isUserProvided
+Matches method declarations that are user-provided.
+
+Given
+  struct S {
+S(); #1
+S(const S &) = default; #2
+S(S &&) = delete; #3
+  };
+cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
+
+
+
 MatcherCXXMethodDecl>isVirtual
 Matches if the given method declaration is virtual.
 
@@ -2538,7 +2566,7 @@
 
 
 
-MatcherNamedDecl>hasNamestd::string Name
+MatcherNamedDecl>hasNamestd::string  Name
 Matches NamedDecl nodes that have the specified name.
 
 Supports specifying enclosing namespaces or classes by prefixing the name
@@ -2731,13 +2759,20 @@
 
 
 MatcherQualType>isAnyPointer
-Matches QualType nodes that are of any pointer type.
+Matches QualType nodes that are of any pointer type; this includes
+the Objective-C object pointer type, which is different despite being
+syntactically similar.
 
 Given
   int *i = nullptr;
+
+  @interface Foo
+  @end
+  Foo *f;
+
   int j;
 varDecl(hasType(isAnyPointer()))
-  matches "int *i", but not "int j".
+  matches "int *i" and "Foo *f", but not "int j".
 
 
 
@@ -3228,16 +3263,6 @@
 
 
 
-MatcherNamedDecl>>hasAnyNameStringRef, ..., StringRef
-Matches NamedDecl nodes that have any of the specified names.
-
-This matcher is only provided as a performance optimization of hasName.
-hasAnyName(a, b, c)
- is equivalent but faster than
-anyOf(hasName(a), hasName(b), hasName(c))
-
-
-
 MatcherStmt>>isInTemplateInstantiation
 Matches statements inside of a template instantiation.
 
Index: cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
===
--- cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
+++ cfe/trunk/include/clang/ASTMatchers/ASTMatchers.h
@@ -3803,6 +3803,21 @@
   return Node.size_overridden_methods() > 0 || Node.hasAttr();
 }
 
+/// \brief Matches method declarations that are user-provided.
+///
+/// Given
+/// \code
+///   struct S {
+/// S(); // #1
+/// S(const S &) = default; // #2
+/// S(S &&) = delete; // #3
+///   };
+/// \endcode
+/// cxxConstructorDecl(isUserProvided()) will match #1, but not #2 or #3.
+AST_MATCHER(CXXMethodDecl, isUserProvided) {
+  return Node.isUserProvided();
+}
+
 /// \brief Matches member expressions that are called with '->' as opposed
 /// to '.'.
 ///
@@ -4911,6 +4926,23 @@
   return Node.isDefaultConstructor();
 }
 
+/// \brief Matches constructors that delegate to another constructor.
+///
+/// Given
+/// \code
+///   struct S {
+/// S(); // #1
+/// S(int) {} // #2
+/// S(S &&) : S() {} // #3
+///   };
+///   S::S() : S(0) {} // #4
+/// \endcode
+/// cxxConstructorDecl(isDelegatingConstructor()) will match #3 and #4, but not
+/// #1 or #2.
+AST_MATCHER(CXXConstructorDecl, isDelegatingConstructor) {
+  return Node.isDelegatingConstructor();
+}
+
 /// \brief Matches constructor and conversion declarations that are marked with
 /// the explicit keyword.
 ///
Index: cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
===
--- cfe/trunk/unittests/ASTMatchers/ASTMatchersTest.cpp
+++ cfe/trunk/unittests/ASTMatchers/ASTMatchers

Re: [PATCH] D17815: [libc++abi] Use fallback_malloc to allocate __cxa_eh_globals in case of dynamic memory exhaustion.

2016-04-13 Thread Igor Kudrin via cfe-commits
ikudrin added a comment.

Ping...


http://reviews.llvm.org/D17815



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


[clang-tools-extra] r266190 - [clang-tidy] Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr 13 06:33:40 2016
New Revision: 266190

URL: http://llvm.org/viewvc/llvm-project?rev=266190&view=rev
Log:
[clang-tidy] Add a readability-deleted-default clang-tidy check.

Checks if constructors and assignment operators that are marked '= default' are
actually deleted by the compiler.

Patch by Alex Pilkiewicz!

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

Added:
clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp
clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.h

clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
clang-tools-extra/trunk/test/clang-tidy/readability-deleted-default.cpp
Modified:
clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
clang-tools-extra/trunk/docs/ReleaseNotes.rst
clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst

Modified: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt?rev=266190&r1=266189&r2=266190&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt Wed Apr 13 
06:33:40 2016
@@ -4,6 +4,7 @@ add_clang_library(clangTidyReadabilityMo
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ContainerSizeEmptyCheck.cpp
+  DeletedDefaultCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionSizeCheck.cpp
   IdentifierNamingCheck.cpp

Added: clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp?rev=266190&view=auto
==
--- clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp 
(added)
+++ clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp Wed 
Apr 13 06:33:40 2016
@@ -0,0 +1,69 @@
+//===--- DeletedDefaultCheck.cpp - 
clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DeletedDefaultCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void DeletedDefaultCheck::registerMatchers(MatchFinder *Finder) {
+  // We match constructors/assignment operators that are:
+  //   - explicitly marked '= default'
+  //   - actually deleted
+  //   - not in template instantiation.
+  // We bind the declaration to "method-decl" and also to "constructor" when
+  // it is a constructor.
+
+  Finder->addMatcher(
+  cxxMethodDecl(anyOf(cxxConstructorDecl().bind("constructor"),
+  isCopyAssignmentOperator(),
+  isMoveAssignmentOperator()),
+isDefaulted(), unless(isImplicit()), isDeleted(),
+unless(isInstantiated()))
+  .bind("method-decl"),
+  this);
+}
+
+void DeletedDefaultCheck::check(const MatchFinder::MatchResult &Result) {
+  const StringRef Message = "%0 is explicitly defaulted but implicitly "
+"deleted, probably because %1; definition can "
+"either be removed or explicitly deleted";
+  if (const auto *Constructor =
+  Result.Nodes.getNodeAs("constructor")) {
+auto Diag = diag(Constructor->getLocStart(), Message);
+if (Constructor->isDefaultConstructor()) {
+  Diag << "default constructor"
+   << "a non-static data member or a base class is lacking a default "
+  "constructor";
+} else if (Constructor->isCopyConstructor()) {
+  Diag << "copy constructor"
+   << "a non-static data member or a base class is not copyable";
+} else if (Constructor->isMoveConstructor()) {
+  Diag << "move constructor"
+   << "a non-static data member or a base class is neither copyable "
+  "nor movable";
+}
+  } else if (const auto *Assignment =
+ Result.Nodes.getNodeAs("method-decl")) {
+diag(Assignment->getLocStart(), Message)
+<< (Assignment->isCopyAssignmentOperator() ? "copy assignment operator"
+   : "move assignment 
operator")
+<< "a base class or a non-static data member is not assignable, e.g. "
+   "because the latter is marked 'const'";
+  }
+}
+
+} // namespace readability
+} // namespace tidy
+} // namespa

Re: [PATCH] D18961: Add a readability-deleted-default clang-tidy check.

2016-04-13 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266190: [clang-tidy] Add a readability-deleted-default 
clang-tidy check. (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D18961?vs=53533&id=53536#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18961

Files:
  clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
  clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp
  clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.h
  clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/list.rst
  clang-tools-extra/trunk/docs/clang-tidy/checks/readability-deleted-default.rst
  clang-tools-extra/trunk/test/clang-tidy/readability-deleted-default.cpp

Index: clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/ReadabilityTidyModule.cpp
@@ -13,6 +13,7 @@
 #include "AvoidConstParamsInDecls.h"
 #include "BracesAroundStatementsCheck.h"
 #include "ContainerSizeEmptyCheck.h"
+#include "DeletedDefaultCheck.h"
 #include "ElseAfterReturnCheck.h"
 #include "FunctionSizeCheck.h"
 #include "IdentifierNamingCheck.h"
@@ -40,6 +41,8 @@
 "readability-braces-around-statements");
 CheckFactories.registerCheck(
 "readability-container-size-empty");
+CheckFactories.registerCheck(
+"readability-deleted-default");
 CheckFactories.registerCheck(
 "readability-else-after-return");
 CheckFactories.registerCheck(
Index: clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.h
+++ clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.h
@@ -0,0 +1,36 @@
+//===--- DeletedDefaultCheck.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_READABILITY_DELETED_DEFAULT_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETED_DEFAULT_H
+
+#include "../ClangTidy.h"
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+/// Checks when a constructor or an assignment operator is marked as '= default'
+/// but is actually deleted by the compiler.
+///
+/// For the user-facing documentation see:
+/// http://clang.llvm.org/extra/clang-tidy/checks/readability-deleted-default.html
+class DeletedDefaultCheck : public ClangTidyCheck {
+public:
+  DeletedDefaultCheck(StringRef Name, ClangTidyContext *Context)
+  : ClangTidyCheck(Name, Context) {}
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+};
+
+} // namespace readability
+} // namespace tidy
+} // namespace clang
+
+#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_READABILITY_DELETED_DEFAULT_H
Index: clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
===
--- clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
+++ clang-tools-extra/trunk/clang-tidy/readability/CMakeLists.txt
@@ -4,6 +4,7 @@
   AvoidConstParamsInDecls.cpp
   BracesAroundStatementsCheck.cpp
   ContainerSizeEmptyCheck.cpp
+  DeletedDefaultCheck.cpp
   ElseAfterReturnCheck.cpp
   FunctionSizeCheck.cpp
   IdentifierNamingCheck.cpp
Index: clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp
===
--- clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp
+++ clang-tools-extra/trunk/clang-tidy/readability/DeletedDefaultCheck.cpp
@@ -0,0 +1,69 @@
+//===--- DeletedDefaultCheck.cpp - clang-tidy--===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+
+#include "DeletedDefaultCheck.h"
+#include "clang/AST/ASTContext.h"
+#include "clang/ASTMatchers/ASTMatchFinder.h"
+
+using namespace clang::ast_matchers;
+
+namespace clang {
+namespace tidy {
+namespace readability {
+
+void DeletedDefaultCheck::registerMatchers(MatchFinder *Finder) {
+  // We match constructors/assignment operators that are:
+  //   - explicitly marked '= default'
+  //   - actually deleted
+  // 

Re: [PATCH] D18584: Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-13 Thread Alexander Kornienko via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266191: Complete support for C++ Core Guidelines Type.6: 
Always initialize a member… (authored by alexfh).

Changed prior to commit:
  http://reviews.llvm.org/D18584?vs=53480&id=53537#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D18584

Files:
  
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp
  clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
  clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
  clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp
  clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h
  clang-tools-extra/trunk/docs/ReleaseNotes.rst
  
clang-tools-extra/trunk/docs/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.rst
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-cxx98.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.cpp
  
clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init.cpp

Index: clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
===
--- clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
+++ clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
@@ -16,24 +16,53 @@
 namespace tidy {
 namespace cppcoreguidelines {
 
-/// \brief Checks that builtin or pointer fields are initialized by
-/// user-defined constructors.
+/// \brief Implements C++ Core Guidelines Type.6.
+///
+/// Checks that every user-provided constructor value-initializes all class
+/// members and base classes that would have undefined behavior otherwise. Also
+/// check that any record types without user-provided default constructors are
+/// value-initialized where used.
 ///
 /// Members initialized through function calls in the body of the constructor
 /// will result in false positives.
 ///
 /// For the user-facing documentation see:
 /// http://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-pro-type-member-init.html
 /// TODO: See if 'fixes' for false positives are optimized away by the compiler.
-/// TODO: "Issue a diagnostic when constructing an object of a trivially
-/// constructible type without () or {} to initialize its members. To fix: Add
-/// () or {}."
+/// TODO: For classes with multiple constructors, make sure that we don't offer
+/// multiple in-class initializer fixits for the same  member.
 class ProTypeMemberInitCheck : public ClangTidyCheck {
 public:
-  ProTypeMemberInitCheck(StringRef Name, ClangTidyContext *Context)
-  : ClangTidyCheck(Name, Context) {}
+  ProTypeMemberInitCheck(StringRef Name, ClangTidyContext *Context);
   void registerMatchers(ast_matchers::MatchFinder *Finder) override;
   void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  // Checks Type.6 part 1:
+  // Issue a diagnostic for any constructor of a non-trivially-constructible
+  // type that does not initialize all member variables.
+  //
+  // To fix: Write a data member initializer, or mention it in the member
+  // initializer list.
+  void checkMissingMemberInitializer(ASTContext &Context,
+ const CXXConstructorDecl *Ctor);
+
+  // A subtle side effect of Type.6 part 2:
+  // Make sure to initialize trivially constructible base classes.
+  void checkMissingBaseClassInitializer(const ASTContext &Context,
+const CXXConstructorDecl *Ctor);
+
+  // Checks Type.6 part 2:
+  // Issue a diagnostic when constructing an object of a trivially constructible
+  // type without () or {} to initialize its members.
+  //
+  // To fix: Add () or {}.
+  void checkUninitializedTrivialType(const ASTContext &Context,
+ const VarDecl *Var);
+
+  // Whether arrays need to be initialized or not. Default is false.
+  bool IgnoreArrays;
 };
 
 } // namespace cppcoreguidelines
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
@@ -9,12 +9,15 @@
 
 #include "ProTypeMemberInitCheck.h"
 #include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
+#include "../utils/TypeTraits.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallPtrSet.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 using llvm::SmallPtrSet;
 using llvm::SmallPtrSetImpl;
 
@@ -24,16 +27,13 @@
 
 namespace {
 
-AST_MATCHER(CXXConstructorDecl, isU

[clang-tools-extra] r266191 - Complete support for C++ Core Guidelines Type.6: Always initialize a member variable.

2016-04-13 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Apr 13 06:35:47 2016
New Revision: 266191

URL: http://llvm.org/viewvc/llvm-project?rev=266191&view=rev
Log:
Complete support for C++ Core Guidelines Type.6: Always initialize a member 
variable.

Summary: Added the remaining features needed to satisfy C++ Core Guideline 
Type.6: Always initialize a member variable to 
cppcoreguidelines-pro-type-member-init. The check now flags all 
default-constructed uses of record types without user-provided default 
constructors that would leave their memory in an undefined state. The check 
suggests value initializing them instead.

Reviewers: flx, alexfh, aaron.ballman

Subscribers: klimek, aaron.ballman, LegalizeAdulthood, cfe-commits

Patch by Michael Miller!

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

Modified:

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

clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.h
clang-tools-extra/trunk/clang-tidy/utils/Matchers.h
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.cpp
clang-tools-extra/trunk/clang-tidy/utils/TypeTraits.h
clang-tools-extra/trunk/docs/ReleaseNotes.rst

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

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

clang-tools-extra/trunk/test/clang-tidy/cppcoreguidelines-pro-type-member-init-delayed.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=266191&r1=266190&r2=266191&view=diff
==
--- 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
(original)
+++ 
clang-tools-extra/trunk/clang-tidy/cppcoreguidelines/ProTypeMemberInitCheck.cpp 
Wed Apr 13 06:35:47 2016
@@ -9,12 +9,15 @@
 
 #include "ProTypeMemberInitCheck.h"
 #include "../utils/LexerUtils.h"
+#include "../utils/Matchers.h"
+#include "../utils/TypeTraits.h"
 #include "clang/AST/ASTContext.h"
 #include "clang/ASTMatchers/ASTMatchFinder.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/SmallPtrSet.h"
 
 using namespace clang::ast_matchers;
+using namespace clang::tidy::matchers;
 using llvm::SmallPtrSet;
 using llvm::SmallPtrSetImpl;
 
@@ -24,16 +27,13 @@ namespace cppcoreguidelines {
 
 namespace {
 
-AST_MATCHER(CXXConstructorDecl, isUserProvided) {
-  return Node.isUserProvided();
-}
-
-static void
-fieldsRequiringInit(const RecordDecl::field_range &Fields,
-SmallPtrSetImpl &FieldsToInit) {
+void fieldsRequiringInit(const RecordDecl::field_range &Fields,
+ ASTContext &Context,
+ SmallPtrSetImpl &FieldsToInit) {
   for (const FieldDecl *F : Fields) {
 QualType Type = F->getType();
-if (Type->isPointerType() || Type->isBuiltinType())
+if (!F->hasInClassInitializer() &&
+type_traits::isTriviallyDefaultConstructible(Type, Context))
   FieldsToInit.insert(F);
   }
 }
@@ -50,134 +50,259 @@ void removeFieldsInitializedInBody(
 FieldDecls.erase(Match.getNodeAs("fieldDecl"));
 }
 
-// Creates comma separated list of fields requiring initialization in order of
+StringRef getName(const FieldDecl *Field) { return Field->getName(); }
+
+StringRef getName(const RecordDecl *Record) {
+  // Get the typedef name if this is a C-style anonymous struct and typedef.
+  if (const TypedefNameDecl *Typedef = Record->getTypedefNameForAnonDecl())
+return Typedef->getName();
+  return Record->getName();
+}
+
+// Creates comma separated list of decls requiring initialization in order of
 // declaration.
-std::string toCommaSeparatedString(
-const RecordDecl::field_range &FieldRange,
-const SmallPtrSetImpl &FieldsRequiringInit) {
-  std::string List;
-  llvm::raw_string_ostream Stream(List);
-  size_t AddedFields = 0;
-  for (const FieldDecl *Field : FieldRange) {
-if (FieldsRequiringInit.count(Field) > 0) {
-  Stream << Field->getName();
-  if (++AddedFields < FieldsRequiringInit.size())
-Stream << ", ";
-}
-  }
-  return Stream.str();
-}
-
-// Contains all fields in correct order that need to be inserted at the same
-// location for pre C++11.
-// There are 3 kinds of insertions:
-// 1. The fields are inserted after an existing CXXCtorInitializer stored in
-// InitializerBefore. This will be the case whenever there is a written
-// initializer before the fields available.
-// 2. The fields are inserted before the first existing initializer stored in
-// InitializerAfter.
-// 3. There are no written initializers and the fields will be inserted before
-// the constructor's body creating a new initializer list including the ':'.
-stru

[PATCH] D19056: [MSVC] Fix check for wchar_t type in case of -fno-wchar

2016-04-13 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin created this revision.
DmitryPolukhin added a reviewer: rnk.
DmitryPolukhin added a subscriber: cfe-commits.

The example below should work identically with and without compiler native 
wchar_t support.

void foo(wchar_t * t = L"");

http://reviews.llvm.org/D19056

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaCXX/no-wchar.cpp

Index: test/SemaCXX/no-wchar.cpp
===
--- test/SemaCXX/no-wchar.cpp
+++ test/SemaCXX/no-wchar.cpp
@@ -7,3 +7,6 @@
 void bar() {
   foo(L"wide string literal");
 }
+
+void foo1(wchar_t * t = L"");
+// expected-warning@-1 {{conversion from string literal to 'wchar_t *' (aka 
'unsigned short *') is deprecated}}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3040,7 +3040,8 @@
   return (ToPointeeType->getKind() == BuiltinType::Char_U ||
   ToPointeeType->getKind() == BuiltinType::Char_S);
 case StringLiteral::Wide:
-  return ToPointeeType->isWideCharType();
+  return Context.typesAreCompatible(Context.getWideCharType(),
+QualType(ToPointeeType, 0));
   }
 }
   }


Index: test/SemaCXX/no-wchar.cpp
===
--- test/SemaCXX/no-wchar.cpp
+++ test/SemaCXX/no-wchar.cpp
@@ -7,3 +7,6 @@
 void bar() {
   foo(L"wide string literal");
 }
+
+void foo1(wchar_t * t = L"");
+// expected-warning@-1 {{conversion from string literal to 'wchar_t *' (aka 'unsigned short *') is deprecated}}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -3040,7 +3040,8 @@
   return (ToPointeeType->getKind() == BuiltinType::Char_U ||
   ToPointeeType->getKind() == BuiltinType::Char_S);
 case StringLiteral::Wide:
-  return ToPointeeType->isWideCharType();
+  return Context.typesAreCompatible(Context.getWideCharType(),
+QualType(ToPointeeType, 0));
   }
 }
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266166 - [PPC64][VSX] Add a couple of new data types for vec_vsx_ld and vec_vsx_st intrinsics and fix incorrect testcases with minor refactoring

2016-04-13 Thread Chuang-Yu Cheng via cfe-commits
Author: cycheng
Date: Wed Apr 13 00:16:31 2016
New Revision: 266166

URL: http://llvm.org/viewvc/llvm-project?rev=266166&view=rev
Log:
[PPC64][VSX] Add a couple of new data types for vec_vsx_ld and vec_vsx_st 
intrinsics and fix incorrect testcases with minor refactoring

New added data types:
  vector double vec_vsx_ld (int, const double *);
  vector float vec_vsx_ld (int, const float *);
  vector bool short vec_vsx_ld (int, const vector bool short *);
  vector bool int vec_vsx_ld (int, const vector bool int *);
  vector signed int vec_vsx_ld (int, const signed int *);
  vector unsigned int vec_vsx_ld (int, const unsigned int *);

  void vec_vsx_st (vector double, int, double *);
  void vec_vsx_st (vector float, int, float *);
  void vec_vsx_st (vector bool short, int, vector bool short *);
  void vec_vsx_st (vector bool short, int, signed short *);
  void vec_vsx_st (vector bool short, int, unsigned short *);
  void vec_vsx_st (vector bool int, int, vector bool int *);
  void vec_vsx_st (vector bool int, int, signed int *);
  void vec_vsx_st (vector bool int, int, unsigned int *);

Also fix testcases which use non-vector argument version of vec_vsx_ld or
vec_vsx_st, but pass incorrect parameter.

Modified:
cfe/trunk/lib/Headers/altivec.h
cfe/trunk/test/CodeGen/builtins-ppc-vsx.c

Modified: cfe/trunk/lib/Headers/altivec.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/altivec.h?rev=266166&r1=266165&r2=266166&view=diff
==
--- cfe/trunk/lib/Headers/altivec.h (original)
+++ cfe/trunk/lib/Headers/altivec.h Wed Apr 13 00:16:31 2016
@@ -10268,16 +10268,31 @@ vec_vupklsw(vector bool int __a) {
 
 #ifdef __VSX__
 
+static __inline__ vector bool int __ATTRS_o_ai
+vec_vsx_ld(int __a, const vector bool int *__b) {
+  return (vector bool int)__builtin_vsx_lxvw4x(__a, __b);
+}
+
 static __inline__ vector signed int __ATTRS_o_ai
 vec_vsx_ld(int __a, const vector signed int *__b) {
   return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
 }
 
+static __inline__ vector signed int __ATTRS_o_ai
+vec_vsx_ld(int __a, const signed int *__b) {
+  return (vector signed int)__builtin_vsx_lxvw4x(__a, __b);
+}
+
 static __inline__ vector unsigned int __ATTRS_o_ai
 vec_vsx_ld(int __a, const vector unsigned int *__b) {
   return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
 }
 
+static __inline__ vector unsigned int __ATTRS_o_ai
+vec_vsx_ld(int __a, const unsigned int *__b) {
+  return (vector unsigned int)__builtin_vsx_lxvw4x(__a, __b);
+}
+
 static __inline__ vector float __ATTRS_o_ai
 vec_vsx_ld(int __a, const vector float *__b) {
   return (vector float)__builtin_vsx_lxvw4x(__a, __b);
@@ -10303,6 +10318,16 @@ vec_vsx_ld(int __a, const vector double
   return (vector double)__builtin_vsx_lxvd2x(__a, __b);
 }
 
+static __inline__ vector double __ATTRS_o_ai
+vec_vsx_ld(int __a, const double *__b) {
+  return (vector double)__builtin_vsx_lxvd2x(__a, __b);
+}
+
+static __inline__ vector bool short __ATTRS_o_ai
+vec_vsx_ld(int __a, const vector bool short *__b) {
+  return (vector bool short)__builtin_vsx_lxvw4x(__a, __b);
+}
+
 static __inline__ vector signed short __ATTRS_o_ai
 vec_vsx_ld(int __a, const vector signed short *__b) {
   return (vector signed short)__builtin_vsx_lxvw4x(__a, __b);
@@ -10354,6 +10379,21 @@ vec_vsx_ld(int __a, const unsigned char
 
 #ifdef __VSX__
 
+static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
+   vector bool int *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
+   signed int *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool int __a, int __b,
+   unsigned int *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
 static __inline__ void __ATTRS_o_ai vec_vsx_st(vector signed int __a, int __b,
vector signed int *__c) {
   __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
@@ -10401,6 +10441,25 @@ static __inline__ void __ATTRS_o_ai vec_
   __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
 }
 
+static __inline__ void __ATTRS_o_ai vec_vsx_st(vector double __a, int __b,
+   double *__c) {
+  __builtin_vsx_stxvd2x((vector double)__a, __b, __c);
+}
+
+static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
+   vector bool short *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static __inline__ void __ATTRS_o_ai vec_vsx_st(vector bool short __a, int __b,
+   signed short *__c) {
+  __builtin_vsx_stxvw4x((vector int)__a, __b, __c);
+}
+
+static

Re: [PATCH] D18652: [Inline asm] Correctly parse GCC-style asm line following MS-style asm line

2016-04-13 Thread Denis Zobnin via cfe-commits
d.zobnin.bugzilla added a reviewer: rsmith.
d.zobnin.bugzilla removed a subscriber: rsmith.
d.zobnin.bugzilla updated this revision to Diff 53543.
d.zobnin.bugzilla added a comment.

Richard, thank you for the review!

I've created a static function to check if this is a GCC asm statement as you 
recommended to do, and also made "isTypeQualifier" function static.
I've added a check for "goto" after "asm" to treat such statements as GCC-style 
assembly.
Also, do you think it will be better to diagnose unsupported "asm goto" 
statements rather than fall into parsing them and emit "expected identifier" 
error or something like that?

Thank you,
Denis Zobnin


http://reviews.llvm.org/D18652

Files:
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  lib/Parse/ParseDecl.cpp
  lib/Parse/ParseStmtAsm.cpp
  test/CodeGen/inline-asm-mixed-style.c

Index: lib/Parse/ParseStmtAsm.cpp
===
--- lib/Parse/ParseStmtAsm.cpp
+++ lib/Parse/ParseStmtAsm.cpp
@@ -335,6 +335,33 @@
   return false;
 }
 
+/// isTypeQualifier - Return true if the current token could be the
+/// start of a type-qualifier-list.
+static bool isTypeQualifier(const Token &Tok) {
+  switch (Tok.getKind()) {
+  default: return false;
+  // type-qualifier
+  case tok::kw_const:
+  case tok::kw_volatile:
+  case tok::kw_restrict:
+  case tok::kw___private:
+  case tok::kw___local:
+  case tok::kw___global:
+  case tok::kw___constant:
+  case tok::kw___generic:
+  case tok::kw___read_only:
+  case tok::kw___read_write:
+  case tok::kw___write_only:
+return true;
+  }
+}
+
+// Determine if this is a GCC-style asm statement.
+static bool isGCCAsmStatement(const Token &TokAfterAsm) {
+  return TokAfterAsm.is(tok::l_paren) || TokAfterAsm.is(tok::kw_goto) ||
+ isTypeQualifier(TokAfterAsm);
+}
+
 /// ParseMicrosoftAsmStatement. When -fms-extensions/-fasm-blocks is enabled,
 /// this routine is called to collect the tokens for an MS asm statement.
 ///
@@ -415,11 +442,11 @@
   if (ExpLoc.first != FID ||
   SrcMgr.getLineNumber(ExpLoc.first, ExpLoc.second) != LineNo) {
 // If this is a single-line __asm, we're done, except if the next
-// line begins with an __asm too, in which case we finish a comment
+// line is MS-style asm too, in which case we finish a comment
 // if needed and then keep processing the next line as a single
 // line __asm.
 bool isAsm = Tok.is(tok::kw_asm);
-if (SingleLineMode && !isAsm)
+if (SingleLineMode && (!isAsm || isGCCAsmStatement(NextToken(
   break;
 // We're no longer in a comment.
 InAsmComment = false;
@@ -643,8 +670,7 @@
   assert(Tok.is(tok::kw_asm) && "Not an asm stmt");
   SourceLocation AsmLoc = ConsumeToken();
 
-  if (getLangOpts().AsmBlocks && Tok.isNot(tok::l_paren) &&
-  !isTypeQualifier()) {
+  if (getLangOpts().AsmBlocks && !isGCCAsmStatement(Tok)) {
 msAsm = true;
 return ParseMicrosoftAsmStatement(AsmLoc);
   }
@@ -664,6 +690,14 @@
 
   // Remember if this was a volatile asm.
   bool isVolatile = DS.getTypeQualifiers() & DeclSpec::TQ_volatile;
+
+  // TODO: support "asm goto" constructs (PR#9295).
+  if (Tok.is(tok::kw_goto)) {
+Diag(Tok, diag::err_asm_goto_not_supported_yet);
+SkipUntil(tok::r_paren, StopAtSemi);
+return StmtError();
+  }
+
   if (Tok.isNot(tok::l_paren)) {
 Diag(Tok, diag::err_expected_lparen_after) << "asm";
 SkipUntil(tok::r_paren, StopAtSemi);
Index: lib/Parse/ParseDecl.cpp
===
--- lib/Parse/ParseDecl.cpp
+++ lib/Parse/ParseDecl.cpp
@@ -4259,27 +4259,6 @@
   }
 }
 
-/// isTypeSpecifierQualifier - Return true if the current token could be the
-/// start of a type-qualifier-list.
-bool Parser::isTypeQualifier() const {
-  switch (Tok.getKind()) {
-  default: return false;
-  // type-qualifier
-  case tok::kw_const:
-  case tok::kw_volatile:
-  case tok::kw_restrict:
-  case tok::kw___private:
-  case tok::kw___local:
-  case tok::kw___global:
-  case tok::kw___constant:
-  case tok::kw___generic:
-  case tok::kw___read_only:
-  case tok::kw___read_write:
-  case tok::kw___write_only:
-return true;
-  }
-}
-
 /// isKnownToBeTypeSpecifier - Return true if we know that the specified token
 /// is definitely a type-specifier.  Return false if it isn't part of a type
 /// specifier or if we're not sure.
Index: include/clang/Parse/Parser.h
===
--- include/clang/Parse/Parser.h
+++ include/clang/Parse/Parser.h
@@ -1873,7 +1873,6 @@
 
   bool isDeclarationSpecifier(bool DisambiguatingWithExpression = false);
   bool isTypeSpecifierQualifier();
-  bool isTypeQualifier() const;
 
   /// isKnownToBeTypeSpecifier - Return true if we know that the specified token
   /// is definitely a type-specifier.  Return false if it isn't part of a type
Index: i

Re: [PATCH] D18473: AMDGPU: Add test for generic builtin behavior

2016-04-13 Thread Tom Stellard via cfe-commits
tstellarAMD accepted this revision.
This revision is now accepted and ready to land.


Comment at: lib/Basic/Targets.cpp:1854-1857
@@ -1853,1 +1853,6 @@
 
+  bool isCLZForZeroUndef() const override {
+// It is -1 instead of expected for intrinsic.
+return true;
+  }
+

arsenm wrote:
> tstellarAMD wrote:
> > Why do we need to add this if it's the same as the default?
> Don't really, other than it adds a comment. I can keep just the test
Ok, sounds good. LGTM.


http://reviews.llvm.org/D18473



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


r266195 - [Clang][AVX512][Builtin] Adding support for VBROADCAST and VPBROADCASTB/W/D/Q instruction set

2016-04-13 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Apr 13 07:58:01 2016
New Revision: 266195

URL: http://llvm.org/viewvc/llvm-project?rev=266195&view=rev
Log:
[Clang][AVX512][Builtin] Adding support for VBROADCAST and VPBROADCASTB/W/D/Q 
instruction set
 
Differential Revision: http://reviews.llvm.org/D19012


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512bwintrin.h
cfe/trunk/lib/Headers/avx512dqintrin.h
cfe/trunk/lib/Headers/avx512vlbwintrin.h
cfe/trunk/lib/Headers/avx512vldqintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512bw-builtins.c
cfe/trunk/test/CodeGen/avx512dq-builtins.c
cfe/trunk/test/CodeGen/avx512vl-builtins.c
cfe/trunk/test/CodeGen/avx512vlbw-builtins.c
cfe/trunk/test/CodeGen/avx512vldq-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=266195&r1=266194&r2=266195&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Apr 13 07:58:01 2016
@@ -1983,6 +1983,35 @@ TARGET_BUILTIN(__builtin_ia32_cvtmask2q1
 TARGET_BUILTIN(__builtin_ia32_cvtmask2q256, "V4LLiUc","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtq2mask128, "UcV2LLi","","avx512dq,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_cvtq2mask256, "UcV4LLi","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcastf32x2_512_mask, 
"V16fV4fV16fUs","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_broadcastf32x8_512_mask, 
"V16fV8fV16fUs","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_broadcastf64x2_512_mask, 
"V8dV2dV8dUc","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_broadcasti32x2_512_mask, 
"V16iV4iV16iUs","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_broadcasti32x8_512_mask, 
"V16iV8iV16iUs","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_broadcasti64x2_512_mask, 
"V8LLiV2LLiV8LLiUc","","avx512dq")
+TARGET_BUILTIN(__builtin_ia32_broadcastf32x2_256_mask, 
"V8fV4fV8fUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcastf64x2_256_mask, 
"V4dV2dV4dUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcasti32x2_128_mask, 
"V4iV4iV4iUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcasti32x2_256_mask, 
"V8iV4iV8iUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcasti64x2_256_mask, 
"V4LLiV2LLiV4LLiUc","","avx512dq,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcastf32x4_256_mask, 
"V8fV4fV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcasti32x4_256_mask, 
"V8iV4iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcastsd256_mask, "V4dV2dV4dUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcastss128_mask, "V4fV4fV4fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_broadcastss256_mask, "V8fV4fV8fUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastw512_mask, 
"V32sV8sV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastb128_mask, 
"V16cV16cV16cUs","","avx512vl,avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastb256_mask, 
"V32cV16cV32cUi","","avx512vl,avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastw128_mask, 
"V8sV8sV8sUc","","avx512vl,avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastw256_mask, 
"V16sV8sV16sUs","","avx512vl,avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastd128_mask, "V4iV4iV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastd256_mask, "V8iV4iV8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastq128_mask, 
"V2LLiV2LLiV2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastq256_mask, 
"V4LLiV2LLiV4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastb512_mask, 
"V64cV16cV64cULLi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastw512_gpr_mask, 
"V32shV32sUi","","avx512bw")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastw256_gpr_mask, 
"V16shV16sUs","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pbroadcastw128_gpr_mask, 
"V8ssV8sUc","","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=266195&r1=266194&r2=266195&view=diff
==
--- cfe/trunk/lib/Headers/avx512bwintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512bwintrin.h Wed Apr 13 07:58:01 2016
@@ -2075,6 +2075,69 @@ _mm512_movm_epi16 (__mmask32 __A)
   return (__m512i) __builtin_ia32_cvtmask2w512 (__A);
 }
 
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_broadcastb_epi8 (__m128i __A)
+{
+  return (__m512i) __builtin_ia32_pbroadcastb512_mask ((__v16qi) __A,
+   (__v64qi) _mm512_setzero_si512(),
+   (__mmask64) -1);
+}
+
+static __inline__ __m512i __DEFAULT_FN_ATTRS
+_mm512_mask_broadcastb_epi8 (__m512i __O, __mmask64 __M, __m128i __A)
+{
+  r

Re: [PATCH] D16396: Warn if variable cannot be implicitly instantiated

2016-04-13 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 53547.
sepavloff added a comment.

Updated patch according to review notes.

The patch adds diagnostics for undefined function templates, in a similar way
as for template variables. These two warnings are classified into different 
groups.
Warnings on undefined variable templates are enabled by default. This is more
error-prone case, existence of PR24425 may be considered as an evidence. 
Warnings
on undefined function templates are off by default. If it is enabled,
about 80 tests require update.

References to template declarations can now be printed in two ways. The usual 
way
is to print only names, such as 'C1::C2', it is compact and convenient when the
reference occurs inside template definition. The patch adds new format, in which
template parameters are also printed, like 'C1::C2', it can be more
convenient if the template is referenced from outside.


http://reviews.llvm.org/D16396

Files:
  include/clang/AST/ASTContext.h
  include/clang/AST/PrettyPrinter.h
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Sema/Sema.h
  lib/AST/ASTDiagnostic.cpp
  lib/AST/Decl.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  test/CXX/temp/temp.decls/temp.mem/p1.cpp
  test/OpenMP/parallel_ast_print.cpp
  test/OpenMP/parallel_sections_ast_print.cpp
  test/OpenMP/target_parallel_ast_print.cpp
  test/OpenMP/task_ast_print.cpp
  test/OpenMP/teams_ast_print.cpp
  test/OpenMP/threadprivate_ast_print.cpp
  test/SemaCXX/PR10177.cpp
  test/SemaCXX/undefined-internal.cpp
  test/SemaTemplate/undefined-template.cpp

Index: test/SemaTemplate/undefined-template.cpp
===
--- /dev/null
+++ test/SemaTemplate/undefined-template.cpp
@@ -0,0 +1,139 @@
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++14 -Wundefined-func-template %s
+
+template  struct C1 {
+  static char s_var_1;
+  static char s_var_2;
+  static void s_func_1();
+  static void s_func_2();
+  void meth_1();
+  void meth_2();
+  template  static char s_tvar_2;
+  template  static void s_tfunc_2();
+  template struct C2 {
+static char s_var_2;
+static void s_func_2();
+void meth_2();
+template  static char s_tvar_2;
+template  void tmeth_2();
+  };
+};
+
+extern template char C1::s_var_2;
+extern template void C1::s_func_2();
+extern template void C1::meth_2();
+extern template char C1::s_tvar_2;
+extern template void C1::s_tfunc_2();
+extern template void C1::C2::s_var_2;
+extern template void C1::C2::s_func_2();
+extern template void C1::C2::meth_2();
+extern template char C1::C2::s_tvar_2;
+extern template void C1::C2::tmeth_2();
+
+char func_01() {
+  return C1::s_var_2;
+}
+
+char func_02() {
+  return C1::s_var_1; // expected-warning{{instantiation of variable 'C1::s_var_1' required here, but 'C1::s_var_1' is not defined}}
+   // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_var_1' is explicitly instantiated in another translation unit}}
+}
+
+char func_03() {
+  return C1::s_var_2; // expected-warning{{instantiation of variable 'C1::s_var_2' required here, but 'C1::s_var_2' is not defined}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_var_2' is explicitly instantiated in another translation unit}}
+}
+
+void func_04() {
+  C1::s_func_1(); // expected-warning{{instantiation of function 'C1::s_func_1' required here, but 'C1::s_func_1' is not defined}}
+   // expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_func_1' is explicitly instantiated in another translation unit}}
+}
+
+void func_05() {
+  C1::s_func_2();
+}
+
+void func_06() {
+  C1::s_func_2(); // expected-warning{{instantiation of function 'C1::s_func_2' required here, but 'C1::s_func_2' is not defined}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::s_func_2' is explicitly instantiated in another translation unit}}
+}
+
+void func_07(C1 *x) {
+  x->meth_1();  // expected-warning{{instantiation of function 'C1::meth_1' required here, but 'C1::meth_1' is not defined}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::meth_1' is explicitly instantiated in another translation unit}}
+}
+
+void func_08(C1 *x) {
+  x->meth_2();
+}
+
+void func_09(C1 *x) {
+  x->meth_1();  // expected-warning{{instantiation of function 'C1::meth_1' required here, but 'C1::meth_1' is not defined}}
+// expected-note@-1{{add an explicit instantiation declaration to suppress this warning if 'C1::meth_1' is explicitly instantiated in another translation unit}}
+}
+
+char func_10() {
+  return C1::s_tvar_2;
+}
+
+char func_11() {
+  return C1::s_tvar_2; // expected-warning{{instantiation of varia

r266198 - [OPENMP 4.0] Fixed DSA analysis for taskloop directives.

2016-04-13 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Apr 13 08:36:48 2016
New Revision: 266198

URL: http://llvm.org/viewvc/llvm-project?rev=266198&view=rev
Log:
[OPENMP 4.0] Fixed DSA analysis for taskloop directives.

Patch make clang to perform analysis for task-based directives also for
taskloop-based directives.

Modified:
cfe/trunk/include/clang/Basic/OpenMPKinds.h
cfe/trunk/lib/Basic/OpenMPKinds.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/test/OpenMP/taskloop_firstprivate_messages.cpp
cfe/trunk/test/OpenMP/taskloop_simd_firstprivate_messages.cpp

Modified: cfe/trunk/include/clang/Basic/OpenMPKinds.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/OpenMPKinds.h?rev=266198&r1=266197&r2=266198&view=diff
==
--- cfe/trunk/include/clang/Basic/OpenMPKinds.h (original)
+++ cfe/trunk/include/clang/Basic/OpenMPKinds.h Wed Apr 13 08:36:48 2016
@@ -203,6 +203,9 @@ bool isOpenMPPrivate(OpenMPClauseKind Ki
 /// \return true - the clause is a threadprivate clause, otherwise - false.
 bool isOpenMPThreadPrivate(OpenMPClauseKind Kind);
 
+/// Checks if the specified directive kind is one of tasking directives - task,
+/// taskloop or taksloop simd.
+bool isOpenMPTaskingDirective(OpenMPDirectiveKind Kind);
 }
 
 #endif

Modified: cfe/trunk/lib/Basic/OpenMPKinds.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/OpenMPKinds.cpp?rev=266198&r1=266197&r2=266198&view=diff
==
--- cfe/trunk/lib/Basic/OpenMPKinds.cpp (original)
+++ cfe/trunk/lib/Basic/OpenMPKinds.cpp Wed Apr 13 08:36:48 2016
@@ -632,3 +632,6 @@ bool clang::isOpenMPThreadPrivate(OpenMP
   return Kind == OMPC_threadprivate || Kind == OMPC_copyin;
 }
 
+bool clang::isOpenMPTaskingDirective(OpenMPDirectiveKind Kind) {
+  return Kind == OMPD_task || isOpenMPTaskLoopDirective(Kind);
+}

Modified: cfe/trunk/lib/Sema/SemaOpenMP.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaOpenMP.cpp?rev=266198&r1=266197&r2=266198&view=diff
==
--- cfe/trunk/lib/Sema/SemaOpenMP.cpp (original)
+++ cfe/trunk/lib/Sema/SemaOpenMP.cpp Wed Apr 13 08:36:48 2016
@@ -376,9 +376,8 @@ public:
   }
 };
 bool isParallelOrTaskRegion(OpenMPDirectiveKind DKind) {
-  return isOpenMPParallelDirective(DKind) || DKind == OMPD_task ||
- isOpenMPTeamsDirective(DKind) || DKind == OMPD_unknown ||
- isOpenMPTaskLoopDirective(DKind);
+  return isOpenMPParallelDirective(DKind) || isOpenMPTaskingDirective(DKind) ||
+ isOpenMPTeamsDirective(DKind) || DKind == OMPD_unknown;
 }
 } // namespace
 
@@ -474,27 +473,24 @@ DSAStackTy::DSAVarData DSAStackTy::getDS
 //  In a task construct, if no default clause is present, a variable that 
in
 //  the enclosing context is determined to be shared by all implicit tasks
 //  bound to the current team is shared.
-if (DVar.DKind == OMPD_task) {
+if (isOpenMPTaskingDirective(DVar.DKind)) {
   DSAVarData DVarTemp;
   for (StackTy::reverse_iterator I = std::next(Iter), EE = Stack.rend();
I != EE; ++I) {
 // OpenMP [2.9.1.1, Data-sharing Attribute Rules for Variables
-// Referenced
-// in a Construct, implicitly determined, p.6]
+// Referenced in a Construct, implicitly determined, p.6]
 //  In a task construct, if no default clause is present, a variable
 //  whose data-sharing attribute is not determined by the rules above 
is
 //  firstprivate.
 DVarTemp = getDSA(I, D);
 if (DVarTemp.CKind != OMPC_shared) {
   DVar.RefExpr = nullptr;
-  DVar.DKind = OMPD_task;
   DVar.CKind = OMPC_firstprivate;
   return DVar;
 }
 if (isParallelOrTaskRegion(I->Directive))
   break;
   }
-  DVar.DKind = OMPD_task;
   DVar.CKind =
   (DVarTemp.CKind == OMPC_unknown) ? OMPC_firstprivate : OMPC_shared;
   return DVar;
@@ -1337,7 +1333,8 @@ static void ReportOriginalDSA(Sema &Sema
   Reason = PDSA_LoopIterVarLastprivate;
 else
   Reason = PDSA_LoopIterVarLinear;
-  } else if (DVar.DKind == OMPD_task && DVar.CKind == OMPC_firstprivate) {
+  } else if (isOpenMPTaskingDirective(DVar.DKind) &&
+ DVar.CKind == OMPC_firstprivate) {
 Reason = PDSA_TaskVarFirstprivate;
 ReportLoc = DVar.ImplicitDSALoc;
   } else if (VD && VD->isStaticLocal())
@@ -1406,7 +1403,7 @@ public:
  isOpenMPTeamsDirective(K);
 },
 false);
-  if (DKind == OMPD_task && DVar.CKind == OMPC_reduction) {
+  if (isOpenMPTaskingDirective(DKind) && DVar.CKind == OMPC_reduction) {
 ErrorFound = true;
 SemaRef.Diag(ELoc, diag::err_omp_reduction_in_task);
 ReportOriginalDSA(

Re: [PATCH] D18823: Implementation of VlA of GNU C++ extension

2016-04-13 Thread Vladimir Yakovlev via cfe-commits
vbyakovl updated this revision to Diff 53548.
vbyakovl added a comment.

Sema/SemaType.cpp: Vla works in C++ by default. An error is printed if a class 
has not default constructor.
test/SemaCXX/c99-variable-length-array.cpp: Changes is removed
test/SemaCXX/vla.cpp: changes is removed.
test/CodeGenCXX/vla-consruct.cpp is added.


http://reviews.llvm.org/D18823

Files:
  llvm/tools/clang/lib/CodeGen/CGClass.cpp
  llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
  llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
  llvm/tools/clang/lib/Sema/SemaType.cpp
  llvm/tools/clang/test/CodeGenCXX/vla-consruct.cpp
  llvm/tools/clang/test/SemaCXX/c99-variable-length-array.cpp
  llvm/tools/clang/test/SemaCXX/vla-consruct.cpp

Index: llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
===
--- llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
+++ llvm/tools/clang/lib/CodeGen/CGExprCXX.cpp
@@ -472,8 +472,8 @@
 }
   }
   
-  if (const ConstantArrayType *arrayType 
-= getContext().getAsConstantArrayType(E->getType())) {
+  if (const ArrayType *arrayType
+= getContext().getAsArrayType(E->getType())) {
 EmitCXXAggrConstructorCall(CD, arrayType, Dest.getAddress(), E);
   } else {
 CXXCtorType Type = Ctor_Complete;
Index: llvm/tools/clang/lib/CodeGen/CGClass.cpp
===
--- llvm/tools/clang/lib/CodeGen/CGClass.cpp
+++ llvm/tools/clang/lib/CodeGen/CGClass.cpp
@@ -1915,7 +1915,7 @@
 /// \param zeroInitialize true if each element should be
 ///   zero-initialized before it is constructed
 void CodeGenFunction::EmitCXXAggrConstructorCall(
-const CXXConstructorDecl *ctor, const ConstantArrayType *arrayType,
+const CXXConstructorDecl *ctor, const ArrayType *arrayType,
 Address arrayBegin, const CXXConstructExpr *E, bool zeroInitialize) {
   QualType elementType;
   llvm::Value *numElements =
Index: llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
===
--- llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
+++ llvm/tools/clang/lib/CodeGen/CodeGenFunction.h
@@ -1872,7 +1872,7 @@
   const CXXConstructExpr *E);
 
   void EmitCXXAggrConstructorCall(const CXXConstructorDecl *D,
-  const ConstantArrayType *ArrayTy,
+  const ArrayType *ArrayTy,
   Address ArrayPtr,
   const CXXConstructExpr *E,
   bool ZeroInitialization = false);
Index: llvm/tools/clang/lib/Sema/SemaType.cpp
===
--- llvm/tools/clang/lib/Sema/SemaType.cpp
+++ llvm/tools/clang/lib/Sema/SemaType.cpp
@@ -2158,10 +2158,12 @@
 if (T->isVariableArrayType()) {
   // Prohibit the use of non-POD types in VLAs.
   QualType BaseT = Context.getBaseElementType(T);
+  const CXXRecordDecl *RD = BaseT->getAsCXXRecordDecl();
   if (!T->isDependentType() && isCompleteType(Loc, BaseT) &&
-  !BaseT.isPODType(Context) && !BaseT->isObjCLifetimeType()) {
+  RD && !RD->hasDefaultConstructor() &&
+  !BaseT->isObjCLifetimeType()) {
 Diag(Loc, diag::err_vla_non_pod) << BaseT;
-return QualType();
+  return QualType();
   }
   // Prohibit the use of VLAs during template argument deduction.
   else if (isSFINAEContext()) {
Index: llvm/tools/clang/test/SemaCXX/vla-consruct.cpp
===
--- llvm/tools/clang/test/SemaCXX/vla-consruct.cpp
+++ llvm/tools/clang/test/SemaCXX/vla-consruct.cpp
@@ -0,0 +1,48 @@
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -O0 -verify %s
+// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -fcxx-exceptions -fexceptions -pedantic-errors -DPE -O0 -verify %s
+
+# ifndef PE
+// expected-no-diagnostics
+# endif
+
+extern "C" int printf(const char*, ...);
+
+static int N;
+struct S {
+  S() __attribute__ ((nothrow))  { printf("%d: S()\n", ++N); }
+  ~S()  __attribute__ ((nothrow))  { printf("%d: ~S()\n", N--); }
+  int n[17];
+};
+
+void print(int n, int a, int b, int c, int d) {
+  printf("n=%d\n,sizeof(S)=%d\nsizeof(array_t[0][0])=%d\nsizeof(array_t[0])=%d\nsizeof(array_t)=%d\n",
+ n, a, b, c, d);
+  if (n == 2) throw(n);
+}
+
+void test(int n) {
+  S array_t[n][n+1];
+# ifdef PE
+   // expected-error@-2 {{variable length arrays are a C99 feature}}
+   // expected-error@-3 {{variable length arrays are a C99 feature}}
+# endif
+  int sizeof_S = sizeof(S);
+  int sizeof_array_t_0_0 = sizeof(array_t[0][0]);
+  int sizeof_array_t_0 = sizeof(array_t[0]);
+  int sizeof_array_t = sizeof(array_t);
+  print(n, sizeof_S, sizeof_array_t_0_0, sizeof_array_t_0, sizeof_array_t);
+}
+
+int main()
+{
+  try {
+test(2);
+  } catch(int e) {
+printf("expeption %d\n", e

Re: [PATCH] D19014: [clang-tidy] Add new checker for suspicious sizeof expressions

2016-04-13 Thread Malcolm Parsons via cfe-commits
malcolm.parsons added a subscriber: malcolm.parsons.


Comment at: docs/clang-tidy/checks/misc-sizeof-expression.rst:16
@@ +15,3 @@
+A common mistake is to query the ``sizeof`` of an integer literal. This is
+equivalent to query the size of it's type (probably ``int``). The intent of the
+programmer was probably to simply get the integer and not its size.

s/it's/its/


http://reviews.llvm.org/D19014



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


r266199 - Add functions declared in ctype.h to builtin function database. All functions are annotated with nothrow and pure attribute, which enables better optimization.

2016-04-13 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Apr 13 08:55:58 2016
New Revision: 266199

URL: http://llvm.org/viewvc/llvm-project?rev=266199&view=rev
Log:
Add functions declared in ctype.h to builtin function database. All functions 
are annotated with nothrow and pure attribute, which enables better 
optimization.

Patch by Taewook Oh.

Added:
cfe/trunk/test/Sema/libbuiltins-ctype.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/Builtins.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/FixIt/typo.m
cfe/trunk/test/Sema/enable_if.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=266199&r1=266198&r2=266199&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Apr 13 08:55:58 2016
@@ -67,6 +67,7 @@
 // Builtin::Context class.  Currently we have:
 //  n -> nothrow
 //  r -> noreturn
+//  U -> pure
 //  c -> const
 //  t -> signature is meaningless, use custom typechecking
 //  F -> this is a libc/libm function with a '__builtin_' prefix added.
@@ -773,6 +774,22 @@ LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:
 LIBBUILTIN(vscanf, "icC*Ra",  "fS:0:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
+// C99 ctype.h
+LIBBUILTIN(isalnum, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isalpha, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isblank, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(iscntrl, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isgraph, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(islower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isprint, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(ispunct, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isspace, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(isxdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
+
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=266199&r1=266198&r2=266199&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Wed Apr 13 08:55:58 2016
@@ -89,11 +89,16 @@ public:
 return getRecord(ID).Type;
   }
 
-  /// \brief Return true if this function is a target-specific builtin
+  /// \brief Return true if this function is a target-specific builtin.
   bool isTSBuiltin(unsigned ID) const {
 return ID >= Builtin::FirstTSBuiltin;
   }
 
+  /// \brief Return true if this function has no side effects.
+  bool isPure(unsigned ID) const {
+return strchr(getRecord(ID).Attributes, 'U') != nullptr;
+  }
+
   /// \brief Return true if this function has no side effects and doesn't
   /// read memory.
   bool isConst(unsigned ID) const {
@@ -155,7 +160,7 @@ public:
   /// \brief Completely forget that the given ID was ever considered a builtin,
   /// e.g., because the user provided a conflicting signature.
   void forgetBuiltin(unsigned ID, IdentifierTable &Table);
-  
+
   /// \brief If this is a library function that comes from a specific
   /// header, retrieve that header name.
   const char *getHeaderName(unsigned ID) const {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=266199&r1=266198&r2=266199&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 13 08:55:58 2016
@@ -274,7 +274,7 @@ ParsedType Sema::getTypeName(const Ident
 // so build a dependent node to describe the type.
 if (WantNontrivialTypeSourceInfo)
   return ActOnTypenameType(S, SourceLocation(), *SS, II, 
NameLoc).get();
-
+
 NestedNameSpecifierLoc QualifierLoc = SS->getWithLocInContext(Context);
 QualType T = CheckTypenameType(ETK_None, SourceLocation(), 
QualifierLoc,
II, NameLoc);
@@ -283,7 +283,7 @@ ParsedType Sema::getTypeName(const Ident
 
   return nullptr;
 }
-
+
 if (!LookupCtx->isDependentContext() &&
 RequireCompleteDeclContext(*SS, LookupCtx))
   return nullptr;
@@ -304,7 +304,7 @@ ParsedType Sema::getTypeName(const

Re: [PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-13 Thread Aaron Ballman via cfe-commits
aaron.ballman closed this revision.
aaron.ballman added a comment.

Commit in r266199, thank you!


http://reviews.llvm.org/D18970



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


[PATCH] D19057: [analyzer] Let TK_PreserveContents span across the whole base region.

2016-04-13 Thread Artem Dergachev via cfe-commits
NoQ created this revision.
NoQ added reviewers: zaks.anna, dcoughlin.
NoQ added a subscriber: cfe-commits.

Essentially, if `s` is a structure, and `foo(const void *)` is evaluated 
conservatively, then `foo(&s)` does not invalidate `s`, but `foo(&(s.x))` 
invalidates the whole `s`, because the store only looks at traits of base 
regions (inside binding keys), and `s.x` is a field region.

This patch represents the idea that only whole base regions should carry the 
`TK_PreserveContents` trait. This also makes a bit of sense, because no matter 
what pointer arithmetic we do with a const pointer, it's still a const pointer. 
There's an extra complication with mutable fields in C++ classes, which i 
neither added nor fixed here.

In `CallEvent.cpp` below the changed code there's a FIXME comment, but i'm not 
sure what it means; if anybody thinks it means exactly what this patch is 
about, then i'd have to update it :)

What i don't like about the approach this patch implements, is that it makes 
the core rely on an implementation detail of RegionStoreManager ("only base 
regions are relevant" is such implementation detail). Instead, i also tried to 
add a few extra virtual methods into the StoreManager to avoid this problem, 
but it made the patch much heavier. I can post that, unless anybody else thinks 
that it's a natural thing (rather than implementation detail) to propagate this 
trait to base regions.

Instead, it should be possible to auto-replace the region with a base region 
inside `setTrait()` and `hasTrait()` methods.

http://reviews.llvm.org/D19057

Files:
  lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  lib/StaticAnalyzer/Core/CallEvent.cpp
  test/Analysis/call-invalidation.cpp

Index: test/Analysis/call-invalidation.cpp
===
--- test/Analysis/call-invalidation.cpp
+++ test/Analysis/call-invalidation.cpp
@@ -118,3 +118,47 @@
 }
 
 
+struct PlainStruct {
+  int x, y;
+  mutable int z;
+};
+
+PlainStruct glob;
+
+void useAnything(void *);
+void useAnythingConst(const void *);
+
+void testInvalidationThroughBaseRegionPointer() {
+  PlainStruct s1;
+  s1.x = 1;
+  s1.z = 1;
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
+  clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
+  useAnythingConst(&(s1.y));
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{TRUE}}
+  // FIXME: Should say "UNKNOWN", because it is not uncommon to
+  // modify a mutable member variable through const pointer.
+  clang_analyzer_eval(s1.z == 1); // expected-warning{{TRUE}}
+  useAnything(&(s1.y));
+  clang_analyzer_eval(s1.x == 1); // expected-warning{{UNKNOWN}}
+}
+
+
+void useFirstConstSecondNonConst(const void *x, void *y);
+void useFirstNonConstSecondConst(void *x, const void *y);
+
+void testMixedConstNonConstCalls() {
+  PlainStruct s2;
+  s2.x = 1;
+  useFirstConstSecondNonConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.x == 1); // expected-warning{{UNKNOWN}}
+  s2.x = 1;
+  useFirstNonConstSecondConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.x == 1); // expected-warning{{UNKNOWN}}
+  s2.y = 1;
+  useFirstConstSecondNonConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.y == 1); // expected-warning{{UNKNOWN}}
+  s2.y = 1;
+  useFirstNonConstSecondConst(&(s2.x), &(s2.y));
+  clang_analyzer_eval(s2.y == 1); // expected-warning{{UNKNOWN}}
+}
Index: lib/StaticAnalyzer/Core/CallEvent.cpp
===
--- lib/StaticAnalyzer/Core/CallEvent.cpp
+++ lib/StaticAnalyzer/Core/CallEvent.cpp
@@ -177,7 +177,7 @@
 // below for efficiency.
 if (PreserveArgs.count(Idx))
   if (const MemRegion *MR = getArgSVal(Idx).getAsRegion())
-ETraits.setTrait(MR->StripCasts(),
+ETraits.setTrait(MR->getBaseRegion(),
 
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
 // TODO: Factor this out + handle the lower level const pointers.
 
Index: lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -920,7 +920,7 @@
 // Invalidate and escape only indirect regions accessible through the 
source
 // buffer.
 if (IsSourceBuffer) {
-  ITraits.setTrait(R,
+  ITraits.setTrait(R->getBaseRegion(),
RegionAndSymbolInvalidationTraits::TK_PreserveContents);
   ITraits.setTrait(R, 
RegionAndSymbolInvalidationTraits::TK_SuppressEscape);
   CausesPointerEscape = true;


Index: test/Analysis/call-invalidation.cpp
===
--- test/Analysis/call-invalidation.cpp
+++ test/Analysis/call-invalidation.cpp
@@ -118,3 +118,47 @@
 }
 
 
+struct PlainStruct {
+  int x, y;
+  mutable int z;
+};
+
+PlainStruct glob;
+
+void useAnything(void *);
+void useAnythingConst(const void *);
+
+void te

r266201 - Reverting r266199; it causes build bot failures.

2016-04-13 Thread Aaron Ballman via cfe-commits
Author: aaronballman
Date: Wed Apr 13 09:53:52 2016
New Revision: 266201

URL: http://llvm.org/viewvc/llvm-project?rev=266201&view=rev
Log:
Reverting r266199; it causes build bot failures.

http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/3255
http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3517  

Removed:
cfe/trunk/test/Sema/libbuiltins-ctype.c
Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/include/clang/Basic/Builtins.h
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/test/FixIt/typo.m
cfe/trunk/test/Sema/enable_if.c

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=266201&r1=266200&r2=266201&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Wed Apr 13 09:53:52 2016
@@ -67,7 +67,6 @@
 // Builtin::Context class.  Currently we have:
 //  n -> nothrow
 //  r -> noreturn
-//  U -> pure
 //  c -> const
 //  t -> signature is meaningless, use custom typechecking
 //  F -> this is a libc/libm function with a '__builtin_' prefix added.
@@ -774,22 +773,6 @@ LIBBUILTIN(sscanf, "icC*RcC*R.",  "fs:1:
 LIBBUILTIN(vscanf, "icC*Ra",  "fS:0:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vfscanf, "iP*RcC*Ra",  "fS:1:", "stdio.h", ALL_LANGUAGES)
 LIBBUILTIN(vsscanf, "icC*RcC*Ra", "fS:1:", "stdio.h", ALL_LANGUAGES)
-// C99 ctype.h
-LIBBUILTIN(isalnum, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isalpha, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isblank, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(iscntrl, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isgraph, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(islower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isprint, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(ispunct, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isspace, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(isxdigit, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(tolower, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-LIBBUILTIN(toupper, "ii", "fnU", "ctype.h", ALL_LANGUAGES)
-
 // C99
 // In some systems setjmp is a macro that expands to _setjmp. We undefine
 // it here to avoid having two identical LIBBUILTIN entries.

Modified: cfe/trunk/include/clang/Basic/Builtins.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.h?rev=266201&r1=266200&r2=266201&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.h (original)
+++ cfe/trunk/include/clang/Basic/Builtins.h Wed Apr 13 09:53:52 2016
@@ -89,16 +89,11 @@ public:
 return getRecord(ID).Type;
   }
 
-  /// \brief Return true if this function is a target-specific builtin.
+  /// \brief Return true if this function is a target-specific builtin
   bool isTSBuiltin(unsigned ID) const {
 return ID >= Builtin::FirstTSBuiltin;
   }
 
-  /// \brief Return true if this function has no side effects.
-  bool isPure(unsigned ID) const {
-return strchr(getRecord(ID).Attributes, 'U') != nullptr;
-  }
-
   /// \brief Return true if this function has no side effects and doesn't
   /// read memory.
   bool isConst(unsigned ID) const {
@@ -160,7 +155,7 @@ public:
   /// \brief Completely forget that the given ID was ever considered a builtin,
   /// e.g., because the user provided a conflicting signature.
   void forgetBuiltin(unsigned ID, IdentifierTable &Table);
-
+  
   /// \brief If this is a library function that comes from a specific
   /// header, retrieve that header name.
   const char *getHeaderName(unsigned ID) const {

Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=266201&r1=266200&r2=266201&view=diff
==
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Apr 13 09:53:52 2016
@@ -274,7 +274,7 @@ ParsedType Sema::getTypeName(const Ident
 // so build a dependent node to describe the type.
 if (WantNontrivialTypeSourceInfo)
   return ActOnTypenameType(S, SourceLocation(), *SS, II, 
NameLoc).get();
-
+
 NestedNameSpecifierLoc QualifierLoc = SS->getWithLocInContext(Context);
 QualType T = CheckTypenameType(ETK_None, SourceLocation(), 
QualifierLoc,
II, NameLoc);
@@ -283,7 +283,7 @@ ParsedType Sema::getTypeName(const Ident
 
   return nullptr;
 }
-
+
 if (!LookupCtx->isDependentContext() &&
 RequireCompleteDeclContext(*SS, LookupCtx))
   return nullptr;
@@ -304,7 +304,7 @@ ParsedType Sema::getTypeName(const

Re: [PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-13 Thread Aaron Ballman via cfe-commits
aaron.ballman added a comment.

I reverted this in r266201; it was causing build bot failures like:

http://lab.llvm.org:8011/builders/clang-ppc64be-linux/builds/3517

Can you please take a look?

Thanks!


http://reviews.llvm.org/D18970



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


Re: [PATCH] D18970: Add functions in ctype.h to builtin function database

2016-04-13 Thread Taewook Oh via cfe-commits
Sure, I'll take a look.
Thanks!

-- Taewook

On 4/13/16, 8:00 AM, "Aaron Ballman"  wrote:

>aaron.ballman added a comment.
>
>I reverted this in r266201; it was causing build bot failures like:
>
>https://urldefense.proofpoint.com/v2/url?u=http-3A__lab.llvm.org-3A8011_bu
>ilders_clang-2Dppc64be-2Dlinux_builds_3517&d=CwIFaQ&c=5VD0RTtNlTh3ycd41b3M
>Uw&r=kOsLCgQzH7N8ptZ7diJD9g&m=lY0h_n-Ss10lCixhInwZ0rdHJVh8NThGYMjXc95lcXI&
>s=jHcJfUPDOu_1aryqBoPpgyy4YSQAGSBc2Ay-uz13TFg&e=
>
>Can you please take a look?
>
>Thanks!
>
>
>https://urldefense.proofpoint.com/v2/url?u=http-3A__reviews.llvm.org_D1897
>0&d=CwIFaQ&c=5VD0RTtNlTh3ycd41b3MUw&r=kOsLCgQzH7N8ptZ7diJD9g&m=lY0h_n-Ss10
>lCixhInwZ0rdHJVh8NThGYMjXc95lcXI&s=kmrF5dkYE8pxLuu3VXReWZ6ogoJqmOHz1rTfU4L
>nQQ0&e= 
>
>
>

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


r266202 - [Clang][AVX512][Builtin] Adding support to intrinsics of pmovs{d|q}{b|w|d}{128|256|512} instruction set

2016-04-13 Thread Michael Zuckerman via cfe-commits
Author: mzuckerm
Date: Wed Apr 13 10:02:04 2016
New Revision: 266202

URL: http://llvm.org/viewvc/llvm-project?rev=266202&view=rev
Log:
[Clang][AVX512][Builtin] Adding support to intrinsics of 
pmovs{d|q}{b|w|d}{128|256|512} instruction set

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


Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/Headers/avx512fintrin.h
cfe/trunk/lib/Headers/avx512vlintrin.h
cfe/trunk/test/CodeGen/avx512f-builtins.c
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=266202&r1=266201&r2=266202&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Apr 13 10:02:04 2016
@@ -2012,6 +2012,36 @@ TARGET_BUILTIN(__builtin_ia32_pbroadcast
 TARGET_BUILTIN(__builtin_ia32_pbroadcastw512_gpr_mask, 
"V32shV32sUi","","avx512bw")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastw256_gpr_mask, 
"V16shV16sUs","","avx512bw,avx512vl")
 TARGET_BUILTIN(__builtin_ia32_pbroadcastw128_gpr_mask, 
"V8ssV8sUc","","avx512bw,avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdb512_mask, "V16cV16iV16cUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsdb512mem_mask, "vV16c*V16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsdw512_mask, "V16sV16iV16sUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsdw512mem_mask, "vV16s*V16iUs","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsqb512_mask, "V16cV8LLiV16cUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsqb512mem_mask, "vV16c*V8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsqd512_mask, "V8iV8LLiV8iUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsqd512mem_mask, "vV8i*V8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsqw512_mask, "V8sV8LLiV8sUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsqw512mem_mask, "vV8s*V8LLiUc","","avx512f")
+TARGET_BUILTIN(__builtin_ia32_pmovsdb128_mask, "V16cV4iV16cUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdb128mem_mask, "vV16c*V4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdb256_mask, "V16cV8iV16cUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdb256mem_mask, "vV16c*V8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdw128_mask, "V8sV4iV8sUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdw128mem_mask, "vV8s*V4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdw256_mask, "V8sV8iV8sUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsdw256mem_mask, "vV8s*V8iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqb128_mask, "V16cV2LLiV16cUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqb128mem_mask, 
"vV16c*V2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqb256_mask, "V16cV4LLiV16cUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqb256mem_mask, 
"vV16c*V4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqd128_mask, "V4iV2LLiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqd128mem_mask, "vV4i*V2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqd256_mask, "V4iV4LLiV4iUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqd256mem_mask, "vV4i*V4LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqw128_mask, "V8sV2LLiV8sUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqw128mem_mask, "vV8s*V2LLiUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqw256_mask, "V8sV4LLiV8sUc","","avx512vl")
+TARGET_BUILTIN(__builtin_ia32_pmovsqw256mem_mask, "vV8s*V4LLiUc","","avx512vl")
 
 #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=266202&r1=266201&r2=266202&view=diff
==
--- cfe/trunk/lib/Headers/avx512fintrin.h (original)
+++ cfe/trunk/lib/Headers/avx512fintrin.h Wed Apr 13 10:02:04 2016
@@ -5619,6 +5619,152 @@ __builtin_ia32_sqrtss_round_mask ((__v4s
  __R);\
 })
 
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm512_cvtsepi32_epi8 (__m512i __A)
+{
+  return (__m128i) __builtin_ia32_pmovsdb512_mask ((__v16si) __A,
+   (__v16qi) _mm_undefined_si128 (),
+   (__mmask16) -1);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm512_mask_cvtsepi32_epi8 (__m128i __O, __mmask16 __M, __m512i __A)
+{
+  return (__m128i) __builtin_ia32_pmovsdb512_mask ((__v16si) __A,
+   (__v16qi) __O, __M);
+}
+
+static __inline__ __m128i __DEFAULT_FN_ATTRS
+_mm512_maskz_cvtsepi32_epi8 (__mmask16 __M, __m512i __A)
+{
+  return (__m128i) __builtin_ia32_pmovsdb512_mask ((__v16si) __A,
+   (__v16qi) _mm_setzero_si128 (),
+   __M);
+}
+
+static __inline__ void __DEFAULT_FN_ATTRS
+_mm512_mask_cvtsepi32_storeu_epi8 (void * __P, __mmask16 __M, _

[PATCH] D19059: Reorder ASTNodeKind::AllKindInfo to match NodeKindId.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh created this revision.
alexfh added a reviewer: sbenza.
alexfh added a subscriber: cfe-commits.
Herald added a subscriber: klimek.

AllKindInfo is being indexed by NodeKindId, so the order must match.
I've updated the tests, though I'm not sure what exactly they verify and whether
the new state of the tests makes sense ;)

I can add dedicated tests for this change, if needed.

http://reviews.llvm.org/D19059

Files:
  lib/AST/ASTTypeTraits.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp
  unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -449,26 +449,25 @@
   // Overloaded
   EXPECT_TRUE(hasCompletion(
   Comps, "hasParent(",
-  "Matcher "
-  "hasParent(Matcher)"));
+  "Matcher "
+  "hasParent(Matcher)"));
   // Variadic.
   EXPECT_TRUE(hasCompletion(Comps, "whileStmt(",
 "Matcher whileStmt(Matcher...)"));
   // Polymorphic.
   EXPECT_TRUE(hasCompletion(
   Comps, "hasDescendant(",
-  
"Matcher"
-  " hasDescendant(Matcher)"));
+  "Matcher "
+  "hasDescendant(Matcher)"));
 
   CompVector WhileComps = getCompletions("whileStmt", 0);
 
   EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(",
 "Matcher hasBody(Matcher)"));
-  EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(",
-"Matcher "
-"hasParent(Matcher)"));
+  EXPECT_TRUE(hasCompletion(
+  WhileComps, "hasParent(",
+  "Matcher "
+  "hasParent(Matcher)"));
   EXPECT_TRUE(
   hasCompletion(WhileComps, "allOf(", "Matcher allOf(Matcher...)"));
 
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -320,7 +320,7 @@
   EXPECT_EQ("arent(", Comps[2].TypedText);
   EXPECT_EQ(
   "Matcher "
-  "hasParent(Matcher)",
+  "hasParent(Matcher)",
   Comps[2].MatcherDecl);
 }
 
Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -22,12 +22,12 @@
 
 const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
   { NKI_None, "" },
-  { NKI_None, "CXXCtorInitializer" },
   { NKI_None, "TemplateArgument" },
-  { NKI_None, "NestedNameSpecifier" },
   { NKI_None, "NestedNameSpecifierLoc" },
   { NKI_None, "QualType" },
   { NKI_None, "TypeLoc" },
+  { NKI_None, "CXXCtorInitializer" },
+  { NKI_None, "NestedNameSpecifier" },
   { NKI_None, "Decl" },
 #define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" },
 #include "clang/AST/DeclNodes.inc"


Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -449,26 +449,25 @@
   // Overloaded
   EXPECT_TRUE(hasCompletion(
   Comps, "hasParent(",
-  "Matcher "
-  "hasParent(Matcher)"));
+  "Matcher "
+  "hasParent(Matcher)"));
   // Variadic.
   EXPECT_TRUE(hasCompletion(Comps, "whileStmt(",
 "Matcher whileStmt(Matcher...)"));
   // Polymorphic.
   EXPECT_TRUE(hasCompletion(
   Comps, "hasDescendant(",
-  "Matcher"
-  " hasDescendant(Matcher)"));
+  "Matcher "
+  "hasDescendant(Matcher)"));
 
   CompVector WhileComps = getCompletions("whileStmt", 0);
 
   EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(",
 "Matcher hasBody(Matcher)"));
-  EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(",
-"Matcher "
-"hasParent(Matcher)"));
+  EXPECT_TRUE(hasCompletion(
+  WhileComps, "hasParent(",
+  "Matcher "
+  "hasParent(Matcher)"));
   EXPECT_TRUE(
   hasCompletion(WhileComps, "allOf(", "Matcher allOf(Matcher...)"));
 
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -320,7 +320,7 @@
   EXPECT_EQ("arent(", Comps[2].TypedText);
   EXPECT_EQ(
   "Matcher "
-  "hasParent(Matcher)",
+  "hasParent(Matcher)",
   Comps[2].MatcherDecl);
 }
 
Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -22,12 +22,12 @@
 
 const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
   { NKI_None, "" },
-  { NKI_None, "CXXCtorInitializer" },
   { NKI_None, "TemplateArgument" },
-  { NKI_None, "NestedNameSpecifier" },
   { NKI_None, "NestedNameSpecifierLoc" },

Re: [PATCH] D15120: Add support for __float128 type to be used by targets that support it

2016-04-13 Thread Nemanja Ivanovic via cfe-commits
nemanjai closed this revision.
nemanjai added a comment.

Committed revision 266186.


Repository:
  rL LLVM

http://reviews.llvm.org/D15120



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


[PATCH] D19058: clang-format: Pointer `*` is seen as multiplication in C-style casts

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic created this revision.
mxbOctasic added a reviewer: djasper.
mxbOctasic added subscribers: cameron314, cfe-commits.
Herald added a subscriber: klimek.

The `*` was treated as multiplication operator in complex pointer type casts.

e.g. 
(type *const)bar
(type *restrict)bar

Patch by cameron314

http://reviews.llvm.org/D19058

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5882,6 +5882,15 @@
"operator()() && {}");
   verifyGoogleFormat("template \n"
  "auto x() & -> int {}");
+
+  // Some casts look like they might be multiplications, but they are 
definitely
+  // not!
+  // Here, foo could be a macro containing e.g. `const`
+  verifyFormat("(type *foo)bar");
+  verifyFormat("(type *const)bar");
+  verifyFormat("type *x = (type *foo)bar");
+  verifyFormat("type *const x = (type *const)bar");
+  verifyFormat("type *x = (type *foo)(bar)");
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1167,6 +1167,14 @@
 if (ParensAreType && !ParensCouldEndDecl)
   return true;
 
+// Some more obscure casts can leak through the above heuristic, like
+// (type* const)bar or (type* MACRO)bar
+if (Tok.Next->is(tok::identifier) && Tok.Previous &&
+Tok.Previous->isOneOf(tok::kw_const, tok::identifier) &&
+Tok.Previous->Previous &&
+Tok.Previous->Previous->is(TT_PointerOrReference))
+  return true;
+
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there
 // are by the logic above, e.g. "(void)x;".
@@ -1260,6 +1268,17 @@
 if (NextNextToken && NextNextToken->is(tok::arrow))
   return TT_BinaryOperator;
 
+// Casts are never binary operators, regardless of IsExpression
+if (NextToken->isOneOf(tok::r_paren, tok::greater))
+  return TT_PointerOrReference;
+if (NextToken->isOneOf(tok::identifier, tok::kw_const) && NextNextToken &&
+NextNextToken->is(tok::r_paren) && NextNextToken->Next &&
+NextNextToken->Next->isOneOf(tok::identifier, tok::l_paren) &&
+(!PrevToken->Previous || !PrevToken->Previous->is(tok::l_paren) ||
+ !PrevToken->Previous->Previous ||
+ !PrevToken->Previous->Previous->is(tok::kw_decltype)))
+  return TT_PointerOrReference;
+
 // It is very unlikely that we are going to find a pointer or reference 
type
 // definition on the RHS of an assignment.
 if (IsExpression && !Contexts.back().CaretFound)


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -5882,6 +5882,15 @@
"operator()() && {}");
   verifyGoogleFormat("template \n"
  "auto x() & -> int {}");
+
+  // Some casts look like they might be multiplications, but they are definitely
+  // not!
+  // Here, foo could be a macro containing e.g. `const`
+  verifyFormat("(type *foo)bar");
+  verifyFormat("(type *const)bar");
+  verifyFormat("type *x = (type *foo)bar");
+  verifyFormat("type *const x = (type *const)bar");
+  verifyFormat("type *x = (type *foo)(bar)");
 }
 
 TEST_F(FormatTest, UnderstandsAttributes) {
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1167,6 +1167,14 @@
 if (ParensAreType && !ParensCouldEndDecl)
   return true;
 
+// Some more obscure casts can leak through the above heuristic, like
+// (type* const)bar or (type* MACRO)bar
+if (Tok.Next->is(tok::identifier) && Tok.Previous &&
+Tok.Previous->isOneOf(tok::kw_const, tok::identifier) &&
+Tok.Previous->Previous &&
+Tok.Previous->Previous->is(TT_PointerOrReference))
+  return true;
+
 // At this point, we heuristically assume that there are no casts at the
 // start of the line. We assume that we have found most cases where there
 // are by the logic above, e.g. "(void)x;".
@@ -1260,6 +1268,17 @@
 if (NextNextToken && NextNextToken->is(tok::arrow))
   return TT_BinaryOperator;
 
+// Casts are never binary operators, regardless of IsExpression
+if (NextToken->isOneOf(tok::r_paren, tok::greater))
+  return TT_PointerOrReference;
+if (NextToken->isOneOf(tok::identifier, tok::kw_const) && NextNextToken &&
+NextNextToken->is(tok::r_paren) && NextNextToken->Next &&
+NextNextToken->Next->isOneOf(tok::identifier, tok::l_paren) &&
+(!PrevToken->Previous

Re: [PATCH] D19059: Reorder ASTNodeKind::AllKindInfo to match NodeKindId.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 53566.
alexfh added a comment.

- Added a test


http://reviews.llvm.org/D19059

Files:
  lib/AST/ASTTypeTraits.cpp
  unittests/AST/ASTTypeTraitsTest.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp
  unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -449,26 +449,25 @@
   // Overloaded
   EXPECT_TRUE(hasCompletion(
   Comps, "hasParent(",
-  "Matcher "
-  "hasParent(Matcher)"));
+  "Matcher "
+  "hasParent(Matcher)"));
   // Variadic.
   EXPECT_TRUE(hasCompletion(Comps, "whileStmt(",
 "Matcher whileStmt(Matcher...)"));
   // Polymorphic.
   EXPECT_TRUE(hasCompletion(
   Comps, "hasDescendant(",
-  
"Matcher"
-  " hasDescendant(Matcher)"));
+  "Matcher "
+  "hasDescendant(Matcher)"));
 
   CompVector WhileComps = getCompletions("whileStmt", 0);
 
   EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(",
 "Matcher hasBody(Matcher)"));
-  EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(",
-"Matcher "
-"hasParent(Matcher)"));
+  EXPECT_TRUE(hasCompletion(
+  WhileComps, "hasParent(",
+  "Matcher "
+  "hasParent(Matcher)"));
   EXPECT_TRUE(
   hasCompletion(WhileComps, "allOf(", "Matcher allOf(Matcher...)"));
 
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -320,7 +320,7 @@
   EXPECT_EQ("arent(", Comps[2].TypedText);
   EXPECT_EQ(
   "Matcher "
-  "hasParent(Matcher)",
+  "hasParent(Matcher)",
   Comps[2].MatcherDecl);
 }
 
Index: unittests/AST/ASTTypeTraitsTest.cpp
===
--- unittests/AST/ASTTypeTraitsTest.cpp
+++ unittests/AST/ASTTypeTraitsTest.cpp
@@ -107,10 +107,20 @@
 }
 
 TEST(ASTNodeKind, Name) {
-  EXPECT_EQ("Decl", DNT().asStringRef());
-  EXPECT_EQ("CallExpr", DNT().asStringRef());
-  EXPECT_EQ("ConstantArrayType", DNT().asStringRef());
   EXPECT_EQ("", ASTNodeKind().asStringRef());
+#define VERIFY_NAME(Node) EXPECT_EQ(#Node, DNT().asStringRef());
+  VERIFY_NAME(TemplateArgument);
+  VERIFY_NAME(NestedNameSpecifierLoc);
+  VERIFY_NAME(QualType);
+  VERIFY_NAME(TypeLoc);
+  VERIFY_NAME(CXXCtorInitializer);
+  VERIFY_NAME(NestedNameSpecifier);
+  VERIFY_NAME(Decl);
+  VERIFY_NAME(Stmt);
+  VERIFY_NAME(Type);
+  VERIFY_NAME(CallExpr);
+  VERIFY_NAME(ConstantArrayType);
+#undef VERIFY_NAME
 }
 
 TEST(DynTypedNode, DeclSourceRange) {
Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -22,12 +22,12 @@
 
 const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
   { NKI_None, "" },
-  { NKI_None, "CXXCtorInitializer" },
   { NKI_None, "TemplateArgument" },
-  { NKI_None, "NestedNameSpecifier" },
   { NKI_None, "NestedNameSpecifierLoc" },
   { NKI_None, "QualType" },
   { NKI_None, "TypeLoc" },
+  { NKI_None, "CXXCtorInitializer" },
+  { NKI_None, "NestedNameSpecifier" },
   { NKI_None, "Decl" },
 #define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" },
 #include "clang/AST/DeclNodes.inc"


Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -449,26 +449,25 @@
   // Overloaded
   EXPECT_TRUE(hasCompletion(
   Comps, "hasParent(",
-  "Matcher "
-  "hasParent(Matcher)"));
+  "Matcher "
+  "hasParent(Matcher)"));
   // Variadic.
   EXPECT_TRUE(hasCompletion(Comps, "whileStmt(",
 "Matcher whileStmt(Matcher...)"));
   // Polymorphic.
   EXPECT_TRUE(hasCompletion(
   Comps, "hasDescendant(",
-  "Matcher"
-  " hasDescendant(Matcher)"));
+  "Matcher "
+  "hasDescendant(Matcher)"));
 
   CompVector WhileComps = getCompletions("whileStmt", 0);
 
   EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(",
 "Matcher hasBody(Matcher)"));
-  EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(",
-"Matcher "
-"hasParent(Matcher)"));
+  EXPECT_TRUE(hasCompletion(
+  WhileComps, "hasParent(",
+  "Matcher "
+  "hasParent(Matcher)"));
   EXPECT_TRUE(
   hasCompletion(WhileComps, "allOf(", "Matcher allOf(Matcher...)"));
 
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynam

Re: [PATCH] D19059: Reorder ASTNodeKind::AllKindInfo to match NodeKindId.

2016-04-13 Thread Samuel Benzaquen via cfe-commits
sbenza added a comment.

Those tests are testing the code completion you get in clang-query.
The type list must match what that matcher supports.

`hasParent` is declared as

  const internal::ArgumentAdaptingMatcherFunc<
  internal::HasParentMatcher,
  internal::TypeList,
  internal::TypeList>
  LLVM_ATTRIBUTE_UNUSED hasParent = {};

so the completion message is correct now.



Comment at: unittests/AST/ASTTypeTraitsTest.cpp:118
@@ +117,3 @@
+  VERIFY_NAME(NestedNameSpecifier);
+  VERIFY_NAME(Decl);
+  VERIFY_NAME(Stmt);

Add a derived Decl type too.
You added one for Stmt and Type, but not for Decl.


http://reviews.llvm.org/D19059



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


Re: [PATCH] D19059: Reorder ASTNodeKind::AllKindInfo to match NodeKindId.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh updated this revision to Diff 53569.
alexfh added a comment.

Added a Decl descendant for a test.


http://reviews.llvm.org/D19059

Files:
  lib/AST/ASTTypeTraits.cpp
  unittests/AST/ASTTypeTraitsTest.cpp
  unittests/ASTMatchers/Dynamic/ParserTest.cpp
  unittests/ASTMatchers/Dynamic/RegistryTest.cpp

Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -449,26 +449,25 @@
   // Overloaded
   EXPECT_TRUE(hasCompletion(
   Comps, "hasParent(",
-  "Matcher "
-  "hasParent(Matcher)"));
+  "Matcher "
+  "hasParent(Matcher)"));
   // Variadic.
   EXPECT_TRUE(hasCompletion(Comps, "whileStmt(",
 "Matcher whileStmt(Matcher...)"));
   // Polymorphic.
   EXPECT_TRUE(hasCompletion(
   Comps, "hasDescendant(",
-  
"Matcher"
-  " hasDescendant(Matcher)"));
+  "Matcher "
+  "hasDescendant(Matcher)"));
 
   CompVector WhileComps = getCompletions("whileStmt", 0);
 
   EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(",
 "Matcher hasBody(Matcher)"));
-  EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(",
-"Matcher "
-"hasParent(Matcher)"));
+  EXPECT_TRUE(hasCompletion(
+  WhileComps, "hasParent(",
+  "Matcher "
+  "hasParent(Matcher)"));
   EXPECT_TRUE(
   hasCompletion(WhileComps, "allOf(", "Matcher allOf(Matcher...)"));
 
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dynamic/ParserTest.cpp
+++ unittests/ASTMatchers/Dynamic/ParserTest.cpp
@@ -320,7 +320,7 @@
   EXPECT_EQ("arent(", Comps[2].TypedText);
   EXPECT_EQ(
   "Matcher "
-  "hasParent(Matcher)",
+  "hasParent(Matcher)",
   Comps[2].MatcherDecl);
 }
 
Index: unittests/AST/ASTTypeTraitsTest.cpp
===
--- unittests/AST/ASTTypeTraitsTest.cpp
+++ unittests/AST/ASTTypeTraitsTest.cpp
@@ -107,10 +107,21 @@
 }
 
 TEST(ASTNodeKind, Name) {
-  EXPECT_EQ("Decl", DNT().asStringRef());
-  EXPECT_EQ("CallExpr", DNT().asStringRef());
-  EXPECT_EQ("ConstantArrayType", DNT().asStringRef());
   EXPECT_EQ("", ASTNodeKind().asStringRef());
+#define VERIFY_NAME(Node) EXPECT_EQ(#Node, DNT().asStringRef());
+  VERIFY_NAME(TemplateArgument);
+  VERIFY_NAME(NestedNameSpecifierLoc);
+  VERIFY_NAME(QualType);
+  VERIFY_NAME(TypeLoc);
+  VERIFY_NAME(CXXCtorInitializer);
+  VERIFY_NAME(NestedNameSpecifier);
+  VERIFY_NAME(Decl);
+  VERIFY_NAME(CXXRecordDecl);
+  VERIFY_NAME(Stmt);
+  VERIFY_NAME(CallExpr);
+  VERIFY_NAME(Type);
+  VERIFY_NAME(ConstantArrayType);
+#undef VERIFY_NAME
 }
 
 TEST(DynTypedNode, DeclSourceRange) {
Index: lib/AST/ASTTypeTraits.cpp
===
--- lib/AST/ASTTypeTraits.cpp
+++ lib/AST/ASTTypeTraits.cpp
@@ -22,12 +22,12 @@
 
 const ASTNodeKind::KindInfo ASTNodeKind::AllKindInfo[] = {
   { NKI_None, "" },
-  { NKI_None, "CXXCtorInitializer" },
   { NKI_None, "TemplateArgument" },
-  { NKI_None, "NestedNameSpecifier" },
   { NKI_None, "NestedNameSpecifierLoc" },
   { NKI_None, "QualType" },
   { NKI_None, "TypeLoc" },
+  { NKI_None, "CXXCtorInitializer" },
+  { NKI_None, "NestedNameSpecifier" },
   { NKI_None, "Decl" },
 #define DECL(DERIVED, BASE) { NKI_##BASE, #DERIVED "Decl" },
 #include "clang/AST/DeclNodes.inc"


Index: unittests/ASTMatchers/Dynamic/RegistryTest.cpp
===
--- unittests/ASTMatchers/Dynamic/RegistryTest.cpp
+++ unittests/ASTMatchers/Dynamic/RegistryTest.cpp
@@ -449,26 +449,25 @@
   // Overloaded
   EXPECT_TRUE(hasCompletion(
   Comps, "hasParent(",
-  "Matcher "
-  "hasParent(Matcher)"));
+  "Matcher "
+  "hasParent(Matcher)"));
   // Variadic.
   EXPECT_TRUE(hasCompletion(Comps, "whileStmt(",
 "Matcher whileStmt(Matcher...)"));
   // Polymorphic.
   EXPECT_TRUE(hasCompletion(
   Comps, "hasDescendant(",
-  "Matcher"
-  " hasDescendant(Matcher)"));
+  "Matcher "
+  "hasDescendant(Matcher)"));
 
   CompVector WhileComps = getCompletions("whileStmt", 0);
 
   EXPECT_TRUE(hasCompletion(WhileComps, "hasBody(",
 "Matcher hasBody(Matcher)"));
-  EXPECT_TRUE(hasCompletion(WhileComps, "hasParent(",
-"Matcher "
-"hasParent(Matcher)"));
+  EXPECT_TRUE(hasCompletion(
+  WhileComps, "hasParent(",
+  "Matcher "
+  "hasParent(Matcher)"));
   EXPECT_TRUE(
   hasCompletion(WhileComps, "allOf(", "Matcher allOf(Matcher...)"));
 
Index: unittests/ASTMatchers/Dynamic/ParserTest.cpp
===
--- unittests/ASTMatchers/Dy

Re: [PATCH] D19059: Reorder ASTNodeKind::AllKindInfo to match NodeKindId.

2016-04-13 Thread Alexander Kornienko via cfe-commits
alexfh marked an inline comment as done.
alexfh added a comment.

http://reviews.llvm.org/D19059



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


Re: [PATCH] D18637: Extract key to avoid preemptive mallocs in insert/emplace in associative containers

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

This looks good to me, except for the noisy tests.



Comment at: 
test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp:29
@@ +28,3 @@
+template 
+void PrintInfo(int line, Arg&& arg)
+{

In general, we want tests to be silent on success.


http://reviews.llvm.org/D18637



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


Re: [PATCH] D18217: [libcxx] Fix -Wdeprecated warnings

2016-04-13 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Let's retire this patch, then.
I'll be watching for your replacement patches.


http://reviews.llvm.org/D18217



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


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

2016-04-13 Thread Taewook Oh via cfe-commits
twoh created this revision.
twoh added a reviewer: aaron.ballman.
twoh added subscribers: joerg, cfe-commits, rsmith.

Add functions declared in ctype.h to builtin function database. All functions 
are annotated with nothrow and const attribute, which enables better 
optimization. 

This patch has been accepted and committed in 
r266199(http://reviews.llvm.org/D18970, http://reviews.llvm.org/rL266199), but 
reverted because newly added test caused build bot 
failures(http://reviews.llvm.org/rL266201). I fixed the test and resubmit patch 
here. 

http://reviews.llvm.org/D19062

Files:
  include/clang/Basic/Builtins.def
  include/clang/Basic/Builtins.h
  lib/Sema/SemaDecl.cpp
  test/FixIt/typo.m
  test/Sema/enable_if.c
  test/Sema/libbuiltins-ctype.c

Index: test/Sema/libbuiltins-ctype.c
===
--- test/Sema/libbuiltins-ctype.c
+++ test/Sema/libbuiltins-ctype.c
@@ -0,0 +1,65 @@
+// RUN: %clang_cc1 -emit-llvm < %s | FileCheck %s
+
+int isalnum(int);
+int isalpha(int);
+int isblank(int);
+int iscntrl(int);
+int isdigit(int);
+int isgraph(int);
+int islower(int);
+int isprint(int);
+int ispunct(int);
+int isspace(int);
+int isupper(int);
+int isxdigit(int);
+int tolower(int);
+int toupper(int);
+
+void test(int x) {
+  // CHECK: call {{.*}}isalnum{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isalnum(x);
+  // CHECK: call {{.*}}isalpha{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isalpha(x);
+  // CHECK: call {{.*}}isblank{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isblank(x);
+  // CHECK: call {{.*}}iscntrl{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)iscntrl(x);
+  // CHECK: call {{.*}}isdigit{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isdigit(x);
+  // CHECK: call {{.*}}isgraph{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isgraph(x);
+  // CHECK: call {{.*}}islower{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)islower(x);
+  // CHECK: call {{.*}}isprint{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isprint(x);
+  // CHECK: call {{.*}}ispunct{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)ispunct(x);
+  // CHECK: call {{.*}}isspace{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isspace(x);
+  // CHECK: call {{.*}}isupper{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isupper(x);
+  // CHECK: call {{.*}}isxdigit{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)isxdigit(x);
+  // CHECK: call {{.*}}tolower{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)tolower(x);
+  // CHECK: call {{.*}}toupper{{.*}} [[NUW_RO_CALL:#[0-9]+]]
+  (void)toupper(x);
+}
+
+// CHECK: declare {{.*}}isalnum{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isalpha{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isblank{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}iscntrl{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isdigit{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isgraph{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}islower{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isprint{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}ispunct{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isspace{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isupper{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}isxdigit{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}tolower{{.*}} [[NUW_RO:#[0-9]+]]
+// CHECK: declare {{.*}}toupper{{.*}} [[NUW_RO:#[0-9]+]]
+
+// CHECK: attributes [[NUW_RO]] = { nounwind readonly{{.*}} }
+// CHECK: attributes [[NUW_RO_CALL]] = { nounwind readonly }
Index: test/Sema/enable_if.c
===
--- test/Sema/enable_if.c
+++ test/Sema/enable_if.c
@@ -72,8 +72,8 @@
   __attribute__((unavailable("'c' must have the value of an unsigned char or EOF")));
 
 void test3(int c) {
-  isdigit(c);
-  isdigit(10);
+  isdigit(c); // expected-warning{{ignoring return value of function declared with pure attribute}}
+  isdigit(10); // expected-warning{{ignoring return value of function declared with pure attribute}}
 #ifndef CODEGEN
   isdigit(-10);  // expected-error{{call to unavailable function 'isdigit': 'c' must have the value of an unsigned char or EOF}}
 #endif
Index: test/FixIt/typo.m
===
--- test/FixIt/typo.m
+++ test/FixIt/typo.m
@@ -113,8 +113,6 @@
   
 @end
 
-double *isupper(int);
-
 @interface Sub2 : Super
 - (int)method2;
 @end
Index: lib/Sema/SemaDecl.cpp
===
--- lib/Sema/SemaDecl.cpp
+++ lib/Sema/SemaDecl.cpp
@@ -274,16 +274,16 @@
 // so build a dependent node to describe the type.
 if (WantNontrivialTypeSourceInfo)
   return ActOnTypenameType(S, SourceLocation(), *SS, II, NameLoc).get();
-
+
 NestedNameSpecifierLoc QualifierLoc = SS->getWithLocInContext(Context);
 QualType T = CheckTypenameType(ETK_None, SourceLocation(), QualifierLoc,
II, NameLoc);
 return ParsedType::make(T);
   }
 
   return nullptr;
 }
-
+
 if (!LookupCtx

Re: [PATCH] D17469: [libcxx] Add deployment knobs to tests (for Apple platforms)

2016-04-13 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

This direction looks fine to me.  All the test changes look fine to me.


http://reviews.llvm.org/D17469



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


Re: [PATCH] D18876: NFC: unify clang / LLVM atomic ordering

2016-04-13 Thread James Y Knight via cfe-commits
jyknight added a comment.

The large amount of casting to/from integers for AtomicOrderingCABI makes me 
think that it probably ought not actually be converted to an enum class after 
all.


http://reviews.llvm.org/D18876



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


Re: [PATCH] D18217: [libcxx] Fix -Wdeprecated warnings

2016-04-13 Thread don hinton via cfe-commits
hintonda added a comment.

Will do -- moved and started new job, so got a bit behind.

Btw, I have a new checker that's under review that will take care of the 
noexcept for you.  And I think someone else has something that might take care 
of the implicit copy/assignment.

So this should be trivial very soon.


http://reviews.llvm.org/D18217



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


Re: [PATCH] D18637: Extract key to avoid preemptive mallocs in insert/emplace in associative containers

2016-04-13 Thread Eric Fiselier via cfe-commits
EricWF added inline comments.


Comment at: 
test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp:29
@@ +28,3 @@
+template 
+void PrintInfo(int line, Arg&& arg)
+{

mclow.lists wrote:
> In general, we want tests to be silent on success.
I'll see what I can do. The reason these tests are so noisy is because almost 
all of the assertions are in "container_test_types.h". Meaning that when the 
tests fail the diagnostic points into the header with no information about what 
code actually triggered the assertion.  Hence why these tests manually print 
what they are testing.

I'll try and come up with something better.


http://reviews.llvm.org/D18637



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


Re: [PATCH] D18637: Extract key to avoid preemptive mallocs in insert/emplace in associative containers

2016-04-13 Thread Duncan P. N. Exon Smith via cfe-commits

> On 2016-Apr-13, at 09:50, Eric Fiselier  wrote:
> 
> EricWF added inline comments.
> 
> 
> Comment at: 
> test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp:29
> @@ +28,3 @@
> +template 
> +void PrintInfo(int line, Arg&& arg)
> +{
> 
> mclow.lists wrote:
>> In general, we want tests to be silent on success.
> I'll see what I can do. The reason these tests are so noisy is because almost 
> all of the assertions are in "container_test_types.h". Meaning that when the 
> tests fail the diagnostic points into the header with no information about 
> what code actually triggered the assertion.  Hence why these tests manually 
> print what they are testing.
> 
> I'll try and come up with something better.

You might be able to change the API to use macros that pass in __FILE__
and __LINE__ as arguments.

> 
> 
> http://reviews.llvm.org/D18637
> 
> 
> 

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


[libcxx] r266209 - Qualify calls to addressof to avoid getting ADL. Fixes PR#27254.

2016-04-13 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Apr 13 12:02:23 2016
New Revision: 266209

URL: http://llvm.org/viewvc/llvm-project?rev=266209&view=rev
Log:
Qualify calls to addressof to avoid getting ADL. Fixes PR#27254.

Modified:
libcxx/trunk/include/__mutex_base
libcxx/trunk/include/shared_mutex

Modified: libcxx/trunk/include/__mutex_base
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__mutex_base?rev=266209&r1=266208&r2=266209&view=diff
==
--- libcxx/trunk/include/__mutex_base (original)
+++ libcxx/trunk/include/__mutex_base Wed Apr 13 12:02:23 2016
@@ -117,24 +117,24 @@ public:
 unique_lock() _NOEXCEPT : __m_(nullptr), __owns_(false) {}
 _LIBCPP_INLINE_VISIBILITY
 explicit unique_lock(mutex_type& __m)
-: __m_(addressof(__m)), __owns_(true) {__m_->lock();}
+: __m_(_VSTD::addressof(__m)), __owns_(true) {__m_->lock();}
 _LIBCPP_INLINE_VISIBILITY
 unique_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
-: __m_(addressof(__m)), __owns_(false) {}
+: __m_(_VSTD::addressof(__m)), __owns_(false) {}
 _LIBCPP_INLINE_VISIBILITY
 unique_lock(mutex_type& __m, try_to_lock_t)
-: __m_(addressof(__m)), __owns_(__m.try_lock()) {}
+: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock()) {}
 _LIBCPP_INLINE_VISIBILITY
 unique_lock(mutex_type& __m, adopt_lock_t)
-: __m_(addressof(__m)), __owns_(true) {}
+: __m_(_VSTD::addressof(__m)), __owns_(true) {}
 template 
 _LIBCPP_INLINE_VISIBILITY
 unique_lock(mutex_type& __m, const chrono::time_point<_Clock, 
_Duration>& __t)
-: __m_(addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
+: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_until(__t)) {}
 template 
 _LIBCPP_INLINE_VISIBILITY
 unique_lock(mutex_type& __m, const chrono::duration<_Rep, _Period>& 
__d)
-: __m_(addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
+: __m_(_VSTD::addressof(__m)), __owns_(__m.try_lock_for(__d)) {}
 _LIBCPP_INLINE_VISIBILITY
 ~unique_lock()
 {

Modified: libcxx/trunk/include/shared_mutex
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/shared_mutex?rev=266209&r1=266208&r2=266209&view=diff
==
--- libcxx/trunk/include/shared_mutex (original)
+++ libcxx/trunk/include/shared_mutex Wed Apr 13 12:02:23 2016
@@ -319,25 +319,25 @@ public:
 
 _LIBCPP_INLINE_VISIBILITY
 explicit shared_lock(mutex_type& __m)
-: __m_(addressof(__m)),
+: __m_(_VSTD::addressof(__m)),
   __owns_(true)
 {__m_->lock_shared();}
 
 _LIBCPP_INLINE_VISIBILITY
 shared_lock(mutex_type& __m, defer_lock_t) _NOEXCEPT
-: __m_(addressof(__m)),
+: __m_(_VSTD::addressof(__m)),
   __owns_(false)
 {}
 
 _LIBCPP_INLINE_VISIBILITY
 shared_lock(mutex_type& __m, try_to_lock_t)
-: __m_(addressof(__m)),
+: __m_(_VSTD::addressof(__m)),
   __owns_(__m.try_lock_shared())
 {}
 
 _LIBCPP_INLINE_VISIBILITY
 shared_lock(mutex_type& __m, adopt_lock_t)
-: __m_(addressof(__m)),
+: __m_(_VSTD::addressof(__m)),
   __owns_(true)
 {}
 
@@ -345,7 +345,7 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 shared_lock(mutex_type& __m,
 const chrono::time_point<_Clock, _Duration>& __abs_time)
-: __m_(addressof(__m)),
+: __m_(_VSTD::addressof(__m)),
   __owns_(__m.try_lock_shared_until(__abs_time))
 {}
 
@@ -353,7 +353,7 @@ public:
 _LIBCPP_INLINE_VISIBILITY
 shared_lock(mutex_type& __m,
 const chrono::duration<_Rep, _Period>& __rel_time)
-: __m_(addressof(__m)),
+: __m_(_VSTD::addressof(__m)),
   __owns_(__m.try_lock_shared_for(__rel_time))
 {}
 


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


r266211 - ARM: make Darwin's "-arch armv7em" default to hard-float.

2016-04-13 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Apr 13 12:08:51 2016
New Revision: 266211

URL: http://llvm.org/viewvc/llvm-project?rev=266211&view=rev
Log:
ARM: make Darwin's "-arch armv7em" default to hard-float.

We've already paid the price for separate "armv7m" and "armv7em" slices
(support in other tools), it's silly to make them identical other than the
default CPU.

rdar://23055688

Modified:
cfe/trunk/lib/Driver/Tools.cpp
cfe/trunk/test/Driver/darwin-embedded.c

Modified: cfe/trunk/lib/Driver/Tools.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Tools.cpp?rev=266211&r1=266210&r2=266211&view=diff
==
--- cfe/trunk/lib/Driver/Tools.cpp (original)
+++ cfe/trunk/lib/Driver/Tools.cpp Wed Apr 13 12:08:51 2016
@@ -803,7 +803,12 @@ arm::FloatABI arm::getARMFloatABI(const
 break;
   default:
 // Assume "soft", but warn the user we are guessing.
-ABI = FloatABI::Soft;
+if (Triple.isOSBinFormatMachO() &&
+Triple.getSubArch() == llvm::Triple::ARMSubArch_v7em)
+  ABI = FloatABI::Hard;
+else
+  ABI = FloatABI::Soft;
+
 if (Triple.getOS() != llvm::Triple::UnknownOS ||
 !Triple.isOSBinFormatMachO())
   D.Diag(diag::warn_drv_assuming_mfloat_abi_is) << "soft";

Modified: cfe/trunk/test/Driver/darwin-embedded.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-embedded.c?rev=266211&r1=266210&r2=266211&view=diff
==
--- cfe/trunk/test/Driver/darwin-embedded.c (original)
+++ cfe/trunk/test/Driver/darwin-embedded.c Wed Apr 13 12:08:51 2016
@@ -1,6 +1,6 @@
 // RUN: %clang -target x86_64-apple-darwin -arch armv6m 
-resource-dir=%S/Inputs/resource_dir %s -### 2> %t
 // RUN: %clang -target x86_64-apple-darwin -arch armv7em 
-resource-dir=%S/Inputs/resource_dir %s -### 2>> %t
-// RUN: %clang -target x86_64-apple-darwin -arch armv7em -mhard-float 
-resource-dir=%S/Inputs/resource_dir %s -### 2>> %t
+// RUN: %clang -target x86_64-apple-darwin -arch armv7em -mfloat-abi=soft 
-resource-dir=%S/Inputs/resource_dir %s -### 2>> %t
 
 // RUN: %clang -target x86_64-apple-darwin -arch armv7m -fPIC 
-resource-dir=%S/Inputs/resource_dir %s -### 2>> %t
 // RUN: %clang -target x86_64-apple-darwin -arch armv7em -fPIC 
-mfloat-abi=hard -resource-dir=%S/Inputs/resource_dir %s -### 2>> %t
@@ -17,17 +17,18 @@
 // CHECK: "-mfloat-abi" "soft"
 // CHECK: libclang_rt.soft_static.a
 
-// ARMv7em does, but defaults to soft
+// ARMv7em does
 // CHECK-LABEL: Target:
 // CHECK-NOT: warning: unknown platform
-// CHECK: "-mfloat-abi" "soft"
-// CHECK: libclang_rt.soft_static.a
+// CHECK: "-mfloat-abi" "hard"
+// CHECK: libclang_rt.hard_static.a
 
-// Which can be overridden
+// but the ABI can be overridden
 // CHECK-LABEL: Target:
 // CHECK-NOT: warning: unknown platform
-// CHECK: "-mfloat-abi" "hard"
-// CHECK: libclang_rt.hard_static.a
+// CHECK: "-target-feature" "+soft-float"
+// CHECK: "-mfloat-abi" "soft"
+// CHECK: libclang_rt.soft_static.a
 
 // ARMv7m has no float either
 // CHECK-LABEL: Target:


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


r266212 - AArch64: allow 64-bit access to sysregs.

2016-04-13 Thread Tim Northover via cfe-commits
Author: tnorthover
Date: Wed Apr 13 12:08:55 2016
New Revision: 266212

URL: http://llvm.org/viewvc/llvm-project?rev=266212&view=rev
Log:
AArch64: allow 64-bit access to sysregs.

Although all the registers are actually 32-bits, I think we have to assume the
high 32-bits could be RES0 (the ARM ARM is unclear). If so, reading as a 32-bit
register can require extra zero extension operations.

Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/aarch64-special-register.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=266212&r1=266211&r2=266212&view=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Apr 13 12:08:55 2016
@@ -1155,7 +1155,7 @@ bool Sema::CheckAArch64BuiltinFunctionCa
 
   if (BuiltinID == AArch64::BI__builtin_arm_rsr64 ||
   BuiltinID == AArch64::BI__builtin_arm_wsr64)
-return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5, false);
+return SemaBuiltinARMSpecialReg(BuiltinID, TheCall, 0, 5, true);
 
   if (BuiltinID == AArch64::BI__builtin_arm_rsr ||
   BuiltinID == AArch64::BI__builtin_arm_rsrp ||

Modified: cfe/trunk/test/Sema/aarch64-special-register.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/aarch64-special-register.c?rev=266212&r1=266211&r2=266212&view=diff
==
--- cfe/trunk/test/Sema/aarch64-special-register.c (original)
+++ cfe/trunk/test/Sema/aarch64-special-register.c Wed Apr 13 12:08:55 2016
@@ -13,7 +13,7 @@ void wsrp_1(void *v) {
 }
 
 void wsr64_1(unsigned long v) {
-  __builtin_arm_wsr64("sysreg", v); //expected-error {{invalid special 
register for builtin}}
+  __builtin_arm_wsr64("sysreg", v);
 }
 
 unsigned rsr_1() {
@@ -25,7 +25,7 @@ void *rsrp_1() {
 }
 
 unsigned long rsr64_1() {
-  return __builtin_arm_rsr64("sysreg"); //expected-error {{invalid special 
register for builtin}}
+  return __builtin_arm_rsr64("sysreg");
 }
 
 void wsr_2(unsigned v) {


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


r266213 - [OrderFiles] Don't allow lit to run dtrace multithreaded

2016-04-13 Thread Chris Bieneman via cfe-commits
Author: cbieneman
Date: Wed Apr 13 12:12:56 2016
New Revision: 266213

URL: http://llvm.org/viewvc/llvm-project?rev=266213&view=rev
Log:
[OrderFiles] Don't allow lit to run dtrace multithreaded

Dtrace is implemented to try and minimize performance impact on the process 
being traced. This results in dtrace dropping samples if it is taking too many 
CPU resources. Multi-threading dtrace increases the sample drop rate 
dramatically.

Modified:
cfe/trunk/utils/perf-training/CMakeLists.txt

Modified: cfe/trunk/utils/perf-training/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/perf-training/CMakeLists.txt?rev=266213&r1=266212&r2=266213&view=diff
==
--- cfe/trunk/utils/perf-training/CMakeLists.txt (original)
+++ cfe/trunk/utils/perf-training/CMakeLists.txt Wed Apr 13 12:12:56 2016
@@ -48,6 +48,7 @@ if(DTRACE)
 
   add_lit_testsuite(generate-dtrace-logs "Generating clang dtrace data"
 ${CMAKE_CURRENT_BINARY_DIR}/order-files/
+ARGS -j 1
 DEPENDS clang clear-dtrace-logs
 )
 


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


Re: [PATCH] D18821: Add modernize-bool-to-integer-conversion

2016-04-13 Thread Piotr Padlewski via cfe-commits
Prazek added a comment.

In http://reviews.llvm.org/D18821#399079, @alexfh wrote:

> In http://reviews.llvm.org/D18821#399064, @Prazek wrote:
>
> > In http://reviews.llvm.org/D18821#398843, @alexfh wrote:
> >
> > > BTW, why is the check in the 'modernize' module? It doesn't seem to make 
> > > anything more modern. I would guess, the pattern it detects is most 
> > > likely to result from a programming error. Also, the fix, though it 
> > > retains the behavior, has a high chance to be incorrect. Can you share 
> > > the results of running this check on LLVM? At least, how many problems it 
> > > found and how many times the suggested fix was correct.
> > >
> > > I'd suggest to move the check to `misc` or maybe it's time to create a 
> > > separate directory for checks targeting various bug-prone patterns.
> >
> >
> > There were many places.
>
>
> Would be nice, if you could tell the number and provide a list of locations. 
> Have any of these been fixed since then?


No, I didn't know that I can do that - I always heard that I can't format code 
that I didn't change, so I though the same thing is here. I will try do post 
review of changes in clang/llvm soon.


http://reviews.llvm.org/D18821



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


Re: [PATCH] D19056: [MSVC] Fix check for wchar_t type in case of -fno-wchar

2016-04-13 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm



Comment at: test/SemaCXX/no-wchar.cpp:12
@@ +11,2 @@
+void foo1(wchar_t * t = L"");
+// expected-warning@-1 {{conversion from string literal to 'wchar_t *' (aka 
'unsigned short *') is deprecated}}

Can you add some negative tests like these:
  short *p1 = L""; // error
  int *p2 = L""; // error
Even if they don't make it into IsStringLiteralToNonConstPointerConversion, 
it's nice to test around things a bit.


http://reviews.llvm.org/D19056



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


[PATCH] D19064: clang-format: Allow include of clangFormat.h in managed context

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic created this revision.
mxbOctasic added a reviewer: djasper.
mxbOctasic added subscribers: cameron314, cfe-commits.
Herald added a subscriber: klimek.

Including `VirtualFileSystem.h` in the clangFormat.h indirectly includes 
``.
This header is blocked when compiling with /clr.
I added a forward declaration of `vfs::FileSystem` in clangFormat.h and moved 
the include to clangFormat.cpp.


http://reviews.llvm.org/D19064

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -27,6 +26,11 @@
 class SourceManager;
 class DiagnosticConsumer;
 
+namespace vfs {
+
+class FileSystem;
+}
+
 namespace format {
 
 enum class ParseError { Success = 0, Error, Unsuitable };


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -27,6 +26,11 @@
 class SourceManager;
 class DiagnosticConsumer;
 
+namespace vfs {
+
+class FileSystem;
+}
+
 namespace format {
 
 enum class ParseError { Success = 0, Error, Unsuitable };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19065: clang-format: Last line in incomplete block is indented incorrectly

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic created this revision.
mxbOctasic added a reviewer: djasper.
mxbOctasic added subscribers: cameron314, cfe-commits.
Herald added a subscriber: klimek.

This bug occurred when the end of the file was reached while parsing a block.
The indentation of the last line was reset to the initial indentation of the 
block.

http://reviews.llvm.org/D19065

Files:
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7110,10 +7110,9 @@
 }
 
 TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
-  // FIXME: This is not what we want...
   verifyFormat("{\n"
-   "// a"
-   "// b");
+   "  // a\n"
+   "  // b");
 }
 
 TEST_F(FormatTest, FormatStarDependingOnContext) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -430,6 +430,9 @@
 ++Line->Level;
   parseLevel(/*HasOpeningBrace=*/true);
 
+  if (eof())
+return;
+
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -7110,10 +7110,9 @@
 }
 
 TEST_F(FormatTest, IndentLineCommentsInStartOfBlockAtEndOfFile) {
-  // FIXME: This is not what we want...
   verifyFormat("{\n"
-   "// a"
-   "// b");
+   "  // a\n"
+   "  // b");
 }
 
 TEST_F(FormatTest, FormatStarDependingOnContext) {
Index: lib/Format/UnwrappedLineParser.cpp
===
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -430,6 +430,9 @@
 ++Line->Level;
   parseLevel(/*HasOpeningBrace=*/true);
 
+  if (eof())
+return;
+
   if (MacroBlock ? !FormatTok->is(TT_MacroBlockEnd)
  : !FormatTok->is(tok::r_brace)) {
 Line->Level = InitialLevel;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D19063: clang-format: Fixed line merging of more than two lines

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic created this revision.
mxbOctasic added a reviewer: djasper.
mxbOctasic added subscribers: cameron314, cfe-commits.
Herald added a subscriber: klimek.

`getNextMergedLine` merged pairs of adjacent lines instead of merging them all 
with the first one.

Consider `AnnotatedLine` `A`, `B` and `C`.

The function merges `A` with `B` then `B` with `C` and returns a pointer to `A`.
`A.Last` is not updated when `B` and `C` are merged together. (`A.Last == 
B.Last`)

Subsequent lines need to be merged with the first.
By merging `A` with `B` then with `C`, `A.Last` points to the proper token. 
(`A.Last == C.Last`)



http://reviews.llvm.org/D19063

Files:
  lib/Format/UnwrappedLineFormatter.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -273,6 +273,30 @@
"int i;\n"
"\n"
"}  // namespace"));
+
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  Style.MaxEmptyLinesToKeep = 2;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterClass = true;
+  Style.BraceWrapping.AfterFunction = true;
+  Style.KeepEmptyLinesAtTheStartOfBlocks = false;
+
+  EXPECT_EQ("class Foo\n"
+"{\n"
+"  Foo() {}\n"
+"\n"
+"  void funk() {}\n"
+"};",
+format("class Foo\n"
+   "{\n"
+   "  Foo()\n"
+   "  {\n"
+   "  }\n"
+   "\n"
+   "  void funk() {}\n"
+   "};",
+   Style));
 }
 
 TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -150,7 +150,7 @@
   MergedLines = 0;
 if (!DryRun)
   for (unsigned i = 0; i < MergedLines; ++i)
-join(*Next[i], *Next[i + 1]);
+join(*Next[0], *Next[i + 1]);
 Next = Next + MergedLines + 1;
 return Current;
   }


Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -273,6 +273,30 @@
"int i;\n"
"\n"
"}  // namespace"));
+
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  Style.MaxEmptyLinesToKeep = 2;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.AfterClass = true;
+  Style.BraceWrapping.AfterFunction = true;
+  Style.KeepEmptyLinesAtTheStartOfBlocks = false;
+
+  EXPECT_EQ("class Foo\n"
+"{\n"
+"  Foo() {}\n"
+"\n"
+"  void funk() {}\n"
+"};",
+format("class Foo\n"
+   "{\n"
+   "  Foo()\n"
+   "  {\n"
+   "  }\n"
+   "\n"
+   "  void funk() {}\n"
+   "};",
+   Style));
 }
 
 TEST_F(FormatTest, RecognizesBinaryOperatorKeywords) {
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -150,7 +150,7 @@
   MergedLines = 0;
 if (!DryRun)
   for (unsigned i = 0; i < MergedLines; ++i)
-join(*Next[i], *Next[i + 1]);
+join(*Next[0], *Next[i + 1]);
 Next = Next + MergedLines + 1;
 return Current;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266219 - [analyzer] Nullability: Suppress diagnostic on bind with cast.

2016-04-13 Thread Devin Coughlin via cfe-commits
Author: dcoughlin
Date: Wed Apr 13 12:59:24 2016
New Revision: 266219

URL: http://llvm.org/viewvc/llvm-project?rev=266219&view=rev
Log:
[analyzer] Nullability: Suppress diagnostic on bind with cast.

Update the nullability checker to allow an explicit cast to nonnull to
suppress a warning on an assignment of nil to a nonnull:

id _Nonnull x = (id _Nonnull)nil; // no-warning

This suppression as already possible for diagnostics on returns and
function/method arguments.

rdar://problem/25381178

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
cfe/trunk/test/Analysis/nullability.mm

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp?rev=266219&r1=266218&r2=266219&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NullabilityChecker.cpp Wed Apr 13 
12:59:24 2016
@@ -1103,26 +1103,48 @@ void NullabilityChecker::checkBind(SVal
 ValNullability = getNullabilityAnnotation(Sym->getType());
 
   Nullability LocNullability = getNullabilityAnnotation(LocType);
+
+  // If the type of the RHS expression is nonnull, don't warn. This
+  // enables explicit suppression with a cast to nonnull.
+  Nullability ValueExprTypeLevelNullability = Nullability::Unspecified;
+  const Expr *ValueExpr = matchValueExprForBind(S);
+  if (ValueExpr) {
+ValueExprTypeLevelNullability =
+  getNullabilityAnnotation(lookThroughImplicitCasts(ValueExpr)->getType());
+  }
+
+  bool NullAssignedToNonNull = (LocNullability == Nullability::Nonnull &&
+RhsNullness == NullConstraint::IsNull);
   if (Filter.CheckNullPassedToNonnull &&
-  RhsNullness == NullConstraint::IsNull &&
+  NullAssignedToNonNull &&
   ValNullability != Nullability::Nonnull &&
-  LocNullability == Nullability::Nonnull &&
+  ValueExprTypeLevelNullability != Nullability::Nonnull &&
   !isARCNilInitializedLocal(C, S)) {
 static CheckerProgramPointTag Tag(this, "NullPassedToNonnull");
 ExplodedNode *N = C.generateErrorNode(State, &Tag);
 if (!N)
   return;
 
-const Stmt *ValueExpr = matchValueExprForBind(S);
-if (!ValueExpr)
-  ValueExpr = S;
+
+const Stmt *ValueStmt = S;
+if (ValueExpr)
+  ValueStmt = ValueExpr;
 
 reportBugIfInvariantHolds("Null is assigned to a pointer which is "
   "expected to have non-null value",
   ErrorKind::NilAssignedToNonnull, N, nullptr, C,
-  ValueExpr);
+  ValueStmt);
 return;
   }
+
+  // If null was returned from a non-null function, mark the nullability
+  // invariant as violated even if the diagnostic was suppressed.
+  if (NullAssignedToNonNull) {
+State = State->set(true);
+C.addTransition(State);
+return;
+  }
+
   // Intentionally missing case: '0' is bound to a reference. It is handled by
   // the DereferenceChecker.
 

Modified: cfe/trunk/test/Analysis/nullability.mm
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/nullability.mm?rev=266219&r1=266218&r2=266219&view=diff
==
--- cfe/trunk/test/Analysis/nullability.mm (original)
+++ cfe/trunk/test/Analysis/nullability.mm Wed Apr 13 12:59:24 2016
@@ -174,6 +174,47 @@ void testIndirectCastNilToNonnullAndPass
   takesNonnull(p);  // expected-warning {{Null passed to a callee that 
requires a non-null 1st parameter}}
 }
 
+void testDirectCastNilToNonnullAndAssignToLocalInInitializer() {
+  Dummy * _Nonnull nonnullLocalWithAssignmentInInitializer = (Dummy * 
_Nonnull)0; // no-warning
+  (void)nonnullLocalWithAssignmentInInitializer;
+
+  // Since we've already had an invariant violation along this path,
+  // we shouldn't warn here.
+  nonnullLocalWithAssignmentInInitializer = 0;
+  (void)nonnullLocalWithAssignmentInInitializer;
+
+}
+
+void testDirectCastNilToNonnullAndAssignToLocal(Dummy * _Nonnull p) {
+  Dummy * _Nonnull nonnullLocalWithAssignment = p;
+  nonnullLocalWithAssignment = (Dummy * _Nonnull)0; // no-warning
+  (void)nonnullLocalWithAssignment;
+
+  // Since we've already had an invariant violation along this path,
+  // we shouldn't warn here.
+  nonnullLocalWithAssignment = 0;
+  (void)nonnullLocalWithAssignment;
+}
+
+void testDirectCastNilToNonnullAndAssignToParam(Dummy * _Nonnull p) {
+  p = (Dummy * _Nonnull)0; // no-warning
+}
+
+@interface ClassWithNonnullIvar : NSObject {
+  Dummy *_nonnullIvar;
+}
+@end
+
+@implementation ClassWithNonnullIvar
+-(void)testDirectCastNilToNonnullAndAssignToIvar {
+  _nonnullIvar = (Dummy * _Nonnull)0; // no-warning;
+
+  // Since we've already had an invariant violation along this path,
+  // we shouldn't warn her

[PATCH] D19066: clang-format: `SpaceAfterTemplate` and `SpacesInBraces` options

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic created this revision.
mxbOctasic added a reviewer: djasper.
mxbOctasic added subscribers: cameron314, cfe-commits.
Herald added a subscriber: klimek.

This patch adds two new spacing options.

`SpaceAfterTemplate` inserts a space between the template keyword and the 
opening chevron.

`SpacesInBraces` inserts spaces in short and empty brace blocks.

Patch by cameron314.

http://reviews.llvm.org/D19066

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11058,6 +11058,24 @@
   verifyFormat("A>();", Spaces);
 }
 
+TEST_F(FormatTest, SpaceAfterTemplate) {
+  FormatStyle Style = getLLVMStyle();
+
+  verifyFormat("template  void foo();", Style);
+
+  Style.SpaceAfterTemplate = false;
+  verifyFormat("template void foo();", Style);
+}
+
+TEST_F(FormatTest, SpacesInBraces) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_All;
+  Style.SpacesInBraces = true;
+
+  verifyFormat("int x[] = { 1, 2, 3, 4 };", Style);
+  verifyFormat("void foo() { }", Style);
+}
+
 TEST_F(FormatTest, TripleAngleBrackets) {
   verifyFormat("f<<<1, 1>>>();");
   verifyFormat("f<<<1, 1, 1, s>>>();");
Index: lib/Format/UnwrappedLineFormatter.cpp
===
--- lib/Format/UnwrappedLineFormatter.cpp
+++ lib/Format/UnwrappedLineFormatter.cpp
@@ -358,7 +358,7 @@
 (Tok->getNextNonComment() == nullptr ||
  Tok->getNextNonComment()->is(tok::semi))) {
   // We merge empty blocks even if the line exceeds the column limit.
-  Tok->SpacesRequiredBefore = 0;
+  Tok->SpacesRequiredBefore = Style.SpacesInBraces ? 1 : 0;
   Tok->CanBreakBefore = true;
   return 1;
 } else if (Limit != 0 && !Line.startsWith(tok::kw_namespace) &&
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -1938,7 +1938,7 @@
   if (Right.isOneOf(tok::semi, tok::comma))
 return false;
   if (Right.is(tok::less) &&
-  (Left.is(tok::kw_template) ||
+  (Left.is(tok::kw_template) && Style.SpaceAfterTemplate ||
(Line.Type == LT_ObjCDecl && Style.ObjCSpaceBeforeProtocolList)))
 return true;
   if (Left.isOneOf(tok::exclaim, tok::tilde))
@@ -2001,11 +2001,12 @@
   !Left.isOneOf(tok::numeric_constant, TT_DictLiteral))
 return false;
   if (Left.is(tok::l_brace) && Right.is(tok::r_brace))
-return !Left.Children.empty(); // No spaces in "{}".
+return Style.SpacesInBraces ? true
+: !Left.Children.empty(); // No spaces in "{}".
   if ((Left.is(tok::l_brace) && Left.BlockKind != BK_Block) ||
   (Right.is(tok::r_brace) && Right.MatchingParen &&
Right.MatchingParen->BlockKind != BK_Block))
-return !Style.Cpp11BracedListStyle;
+return Style.SpacesInBraces || !Style.Cpp11BracedListStyle;
   if (Left.is(TT_BlockComment))
 return !Left.TokenText.endswith("=*/");
   if (Right.is(tok::l_paren)) {
Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -328,13 +328,15 @@
 IO.mapOptional("ReflowComments", Style.ReflowComments);
 IO.mapOptional("SortIncludes", Style.SortIncludes);
 IO.mapOptional("SpaceAfterCStyleCast", Style.SpaceAfterCStyleCast);
+IO.mapOptional("SpaceAfterTemplate", Style.SpaceAfterTemplate);
 IO.mapOptional("SpaceBeforeAssignmentOperators",
Style.SpaceBeforeAssignmentOperators);
 IO.mapOptional("SpaceBeforeParens", Style.SpaceBeforeParens);
 IO.mapOptional("SpaceInEmptyParentheses", Style.SpaceInEmptyParentheses);
 IO.mapOptional("SpacesBeforeTrailingComments",
Style.SpacesBeforeTrailingComments);
 IO.mapOptional("SpacesInAngles", Style.SpacesInAngles);
+IO.mapOptional("SpacesInBraces", Style.SpacesInBraces);
 IO.mapOptional("SpacesInContainerLiterals",
Style.SpacesInContainerLiterals);
 IO.mapOptional("SpacesInCStyleCastParentheses",
@@ -541,9 +543,11 @@
   LLVMStyle.SpacesInContainerLiterals = true;
   LLVMStyle.SpacesInCStyleCastParentheses = false;
   LLVMStyle.SpaceAfterCStyleCast = false;
+  LLVMStyle.SpaceAfterTemplate = true;
   LLVMStyle.SpaceBeforeParens = FormatStyle::SBPO_ControlStatements;
   LLVMStyle.SpaceBeforeAssignmentOperators = true;
   LLVMStyle.SpacesInAngles = false;
+  LLVMStyle.SpacesInBraces = false;
 
   LLVMStyle.PenaltyBreakComment = 300;
   LLVMStyle.PenaltyBreakFirstLessLess = 120;
Index: include/clang/Format/Format.h
===

r266222 - Simplify memory management of CXEvalResultKind/ExprEvalResult using unique_ptr and a dtor

2016-04-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Apr 13 13:23:33 2016
New Revision: 266222

URL: http://llvm.org/viewvc/llvm-project?rev=266222&view=rev
Log:
Simplify memory management of CXEvalResultKind/ExprEvalResult using unique_ptr 
and a dtor

This doesn't seem to need to be a C type, C only handles a void*, so use
new/delete as usual to simplify allocation and cleanup.

Follow-up to r265994

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=266222&r1=266221&r2=266222&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Apr 13 13:23:33 2016
@@ -3409,26 +3409,23 @@ static StringLiteral* getCFSTR_value(Cal
   return S;
 }
 
-typedef struct {
+struct ExprEvalResult {
   CXEvalResultKind EvalType;
   union {
 int intVal;
 double floatVal;
 char *stringVal;
   } EvalData;
-} ExprEvalResult;
-
-void clang_EvalResult_dispose(CXEvalResult E) {
-  ExprEvalResult *ER = (ExprEvalResult *)E;
-  if (ER) {
-CXEvalResultKind evalType = ER->EvalType;
-
-if (evalType != CXEval_UnExposed &&  evalType != CXEval_Float &&
-evalType != CXEval_Int && ER->EvalData.stringVal) {
-free((void *) ER->EvalData.stringVal);
+  ~ExprEvalResult() {
+if (EvalType != CXEval_UnExposed && EvalType != CXEval_Float &&
+EvalType != CXEval_Int) {
+  delete EvalData.stringVal;
 }
-free((void *)ER);
   }
+};
+
+void clang_EvalResult_dispose(CXEvalResult E) {
+  delete static_cast(E);
 }
 
 CXEvalResultKind clang_EvalResult_getKind(CXEvalResult E) {
@@ -3469,10 +3466,7 @@ static const ExprEvalResult* evaluateExp
   bool res = expr->EvaluateAsRValue(ER, ctx);
   QualType rettype;
   CallExpr *callExpr;
-  ExprEvalResult *result = (ExprEvalResult *) malloc(sizeof(ExprEvalResult));
-  if (!result) {
-return nullptr;
-  }
+  auto result = llvm::make_unique();
   result->EvalType = CXEval_UnExposed;
 
   if (res) {
@@ -3480,7 +3474,7 @@ static const ExprEvalResult* evaluateExp
 if (ER.Val.isInt()) {
   result->EvalType = CXEval_Int;
   result->EvalData.intVal = ER.Val.getInt().getExtValue();
-  return result;
+  return result.release();
 } else if (ER.Val.isFloat()) {
 
   llvm::SmallVector Buffer;
@@ -3492,7 +3486,7 @@ static const ExprEvalResult* evaluateExp
   apFloat.convert(llvm::APFloat::IEEEdouble,
   llvm::APFloat::rmNearestTiesToEven, &ignored);
   result->EvalData.floatVal = apFloat.convertToDouble();
-  return result;
+  return result.release();
 
 } else if (expr->getStmtClass() == Stmt::ImplicitCastExprClass) {
 
@@ -3514,11 +3508,11 @@ static const ExprEvalResult* evaluateExp
 }
 
 std::string strRef(StrE->getString().str());
-result->EvalData.stringVal = (char *)malloc(strRef.size()+1);
+result->EvalData.stringVal = new char[strRef.size() + 1];
 strncpy((char*)result->EvalData.stringVal, strRef.c_str(),
strRef.size());
 result->EvalData.stringVal[strRef.size()] = '\0';
-return result;
+return result.release();
   }
 
 } else if (expr->getStmtClass() == Stmt::ObjCStringLiteralClass ||
@@ -3537,11 +3531,11 @@ static const ExprEvalResult* evaluateExp
   }
 
   std::string strRef(StrE->getString().str());
-  result->EvalData.stringVal = (char *)malloc(strRef.size()+1);
+  result->EvalData.stringVal = new char[strRef.size() + 1];
   strncpy((char*)result->EvalData.stringVal, strRef.c_str(),
   strRef.size());
   result->EvalData.stringVal[strRef.size()] = '\0';
-  return result;
+  return result.release();
 
 } else if (expr->getStmtClass() == Stmt::CStyleCastExprClass) {
 
@@ -3557,11 +3551,11 @@ static const ExprEvalResult* evaluateExp
   std::string strLiteral(S->getString().str());
   result->EvalType = CXEval_CFStr;
 
-  result->EvalData.stringVal = (char *)malloc(strLiteral.size()+1);
+  result->EvalData.stringVal = new char[strLiteral.size() + 1];
   strncpy((char*)result->EvalData.stringVal, strLiteral.c_str(),
  strLiteral.size());
   result->EvalData.stringVal[strLiteral.size()] = '\0';
-  return result;
+  return result.release();
 }
   }
 
@@ -3570,27 +3564,24 @@ static const ExprEvalResult* evaluateExp
   callExpr = static_cast(expr);
   rettype = callExpr->getCallReturnType(ctx);
 
-  if (rettype->isVectorType() || callExpr->getNumArgs() > 1) {
-clang_EvalResult_dispose((CXEvalResult *)result);
+  if (rettype->isVectorType() || callExpr->getNumArgs() > 1)
 return nullptr;
-  }
+
   if (rettype->isIntegralType(ctx) || rettype->isRealFloatingType()) {
-if(callExpr->getNumArg

Re: r265994 - libclang: fix two memory leaks (PR26292)

2016-04-13 Thread David Blaikie via cfe-commits
Didn't seem to be too invasive - r266222.

On Tue, Apr 12, 2016 at 10:54 AM, Hans Wennborg  wrote:

> While useful, that would require a lot of restructuring, I think.
>
> This file seems to mostly be dealing with C-style objects;
> ExprEvalResult doesn't even have a C++ destructor. I'm not going to
> dig into that, I just wanted to address this bug that someone
> reported.
>
>  - Hans
>
>
> On Tue, Apr 12, 2016 at 9:51 AM, David Blaikie via cfe-commits
>  wrote:
> > Any chance of using unique_ptr, or at least a scoped cleanup device,
> here?
> >
> > On Mon, Apr 11, 2016 at 1:54 PM, Hans Wennborg via cfe-commits
> >  wrote:
> >>
> >> Author: hans
> >> Date: Mon Apr 11 15:53:59 2016
> >> New Revision: 265994
> >>
> >> URL: http://llvm.org/viewvc/llvm-project?rev=265994&view=rev
> >> Log:
> >> libclang: fix two memory leaks (PR26292)
> >>
> >> Modified:
> >> cfe/trunk/tools/libclang/CIndex.cpp
> >>
> >> Modified: cfe/trunk/tools/libclang/CIndex.cpp
> >> URL:
> >>
> http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=265994&r1=265993&r2=265994&view=diff
> >>
> >>
> ==
> >> --- cfe/trunk/tools/libclang/CIndex.cpp (original)
> >> +++ cfe/trunk/tools/libclang/CIndex.cpp Mon Apr 11 15:53:59 2016
> >> @@ -3571,12 +3571,13 @@ static const ExprEvalResult* evaluateExp
> >>rettype = callExpr->getCallReturnType(ctx);
> >>
> >>if (rettype->isVectorType() || callExpr->getNumArgs() > 1) {
> >> +clang_EvalResult_dispose((CXEvalResult *)result);
> >>  return nullptr;
> >>}
> >>if (rettype->isIntegralType(ctx) ||
> rettype->isRealFloatingType())
> >> {
> >>  if(callExpr->getNumArgs() == 1 &&
> >> -  !callExpr->getArg(0)->getType()->isIntegralType(ctx)){
> >> -
> >> +  !callExpr->getArg(0)->getType()->isIntegralType(ctx)) {
> >> +  clang_EvalResult_dispose((CXEvalResult *)result);
> >>return nullptr;
> >>  }
> >>} else if(rettype.getAsString() == "CFStringRef") {
> >>
> >>
> >> ___
> >> cfe-commits mailing list
> >> cfe-commits@lists.llvm.org
> >> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
> >
> >
> > ___
> > cfe-commits mailing list
> > cfe-commits@lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
> >
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r266224 - libclang: Use early-return to reduce indentation.

2016-04-13 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Wed Apr 13 13:36:19 2016
New Revision: 266224

URL: http://llvm.org/viewvc/llvm-project?rev=266224&view=rev
Log:
libclang: Use early-return to reduce indentation.

& since I'll get blamed for all the lines anyway, remove some
else-after-return and otherwise tidy things up.

Modified:
cfe/trunk/tools/libclang/CIndex.cpp

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=266224&r1=266223&r2=266224&view=diff
==
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Apr 13 13:36:19 2016
@@ -3459,146 +3459,138 @@ const char* clang_EvalResult_getAsStr(CX
 static const ExprEvalResult* evaluateExpr(Expr *expr, CXCursor C) {
   Expr::EvalResult ER;
   ASTContext &ctx = getCursorContext(C);
-  if (!expr) {
+  if (!expr)
 return nullptr;
-  }
+
   expr = expr->IgnoreParens();
-  bool res = expr->EvaluateAsRValue(ER, ctx);
+  if (!expr->EvaluateAsRValue(ER, ctx))
+return nullptr;
+
   QualType rettype;
   CallExpr *callExpr;
   auto result = llvm::make_unique();
   result->EvalType = CXEval_UnExposed;
 
-  if (res) {
-
-if (ER.Val.isInt()) {
-  result->EvalType = CXEval_Int;
-  result->EvalData.intVal = ER.Val.getInt().getExtValue();
-  return result.release();
-} else if (ER.Val.isFloat()) {
-
-  llvm::SmallVector Buffer;
-  ER.Val.getFloat().toString(Buffer);
-  std::string floatStr(Buffer.data(), Buffer.size());
-  result->EvalType = CXEval_Float;
-  bool ignored;
-  llvm::APFloat apFloat = ER.Val.getFloat();
-  apFloat.convert(llvm::APFloat::IEEEdouble,
-  llvm::APFloat::rmNearestTiesToEven, &ignored);
-  result->EvalData.floatVal = apFloat.convertToDouble();
-  return result.release();
-
-} else if (expr->getStmtClass() == Stmt::ImplicitCastExprClass) {
-
-  const ImplicitCastExpr *I = dyn_cast(expr);
-  auto *subExpr = I->getSubExprAsWritten();
-  if (subExpr->getStmtClass() == Stmt::StringLiteralClass ||
-  subExpr->getStmtClass() == Stmt::ObjCStringLiteralClass) {
-
-const StringLiteral *StrE = nullptr;
-const ObjCStringLiteral *ObjCExpr;
-ObjCExpr = dyn_cast(subExpr);
-
-if (ObjCExpr) {
-  StrE = ObjCExpr->getString();
-  result->EvalType = CXEval_ObjCStrLiteral;
-} else {
-  StrE = cast(I->getSubExprAsWritten());
-  result->EvalType = CXEval_StrLiteral;
-}
-
-std::string strRef(StrE->getString().str());
-result->EvalData.stringVal = new char[strRef.size() + 1];
-strncpy((char*)result->EvalData.stringVal, strRef.c_str(),
-   strRef.size());
-result->EvalData.stringVal[strRef.size()] = '\0';
-return result.release();
-  }
+  if (ER.Val.isInt()) {
+result->EvalType = CXEval_Int;
+result->EvalData.intVal = ER.Val.getInt().getExtValue();
+return result.release();
+  }
 
-} else if (expr->getStmtClass() == Stmt::ObjCStringLiteralClass ||
- expr->getStmtClass() == Stmt::StringLiteralClass) {
+  if (ER.Val.isFloat()) {
+llvm::SmallVector Buffer;
+ER.Val.getFloat().toString(Buffer);
+std::string floatStr(Buffer.data(), Buffer.size());
+result->EvalType = CXEval_Float;
+bool ignored;
+llvm::APFloat apFloat = ER.Val.getFloat();
+apFloat.convert(llvm::APFloat::IEEEdouble,
+llvm::APFloat::rmNearestTiesToEven, &ignored);
+result->EvalData.floatVal = apFloat.convertToDouble();
+return result.release();
+  }
 
+  if (expr->getStmtClass() == Stmt::ImplicitCastExprClass) {
+const ImplicitCastExpr *I = dyn_cast(expr);
+auto *subExpr = I->getSubExprAsWritten();
+if (subExpr->getStmtClass() == Stmt::StringLiteralClass ||
+subExpr->getStmtClass() == Stmt::ObjCStringLiteralClass) {
   const StringLiteral *StrE = nullptr;
   const ObjCStringLiteral *ObjCExpr;
-  ObjCExpr = dyn_cast(expr);
+  ObjCExpr = dyn_cast(subExpr);
 
   if (ObjCExpr) {
 StrE = ObjCExpr->getString();
 result->EvalType = CXEval_ObjCStrLiteral;
   } else {
-StrE = cast(expr);
+StrE = cast(I->getSubExprAsWritten());
 result->EvalType = CXEval_StrLiteral;
   }
 
   std::string strRef(StrE->getString().str());
   result->EvalData.stringVal = new char[strRef.size() + 1];
-  strncpy((char*)result->EvalData.stringVal, strRef.c_str(),
-  strRef.size());
+  strncpy((char *)result->EvalData.stringVal, strRef.c_str(),
+  strRef.size());
   result->EvalData.stringVal[strRef.size()] = '\0';
   return result.release();
+}
+  } else if (expr->getStmtClass() == Stmt::ObjCStringLiteralClass ||
+ expr->getStmtClass() == Stmt::StringLiteralClass) {
+const StringLiteral *StrE = nul

r266226 - Remove redundant null-check; NFC

2016-04-13 Thread Hubert Tong via cfe-commits
Author: hubert.reinterpretcast
Date: Wed Apr 13 13:41:03 2016
New Revision: 266226

URL: http://llvm.org/viewvc/llvm-project?rev=266226&view=rev
Log:
Remove redundant null-check; NFC

Modified:
cfe/trunk/lib/Parse/ParseDeclCXX.cpp

Modified: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDeclCXX.cpp?rev=266226&r1=266225&r2=266226&view=diff
==
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp Wed Apr 13 13:41:03 2016
@@ -1403,7 +1403,7 @@ void Parser::ParseClassSpecifier(tok::To
   // Strip off the last template parameter list if it was empty, since
   // we've removed its template argument list.
   if (TemplateParams && TemplateInfo.LastParameterListWasEmpty) {
-if (TemplateParams && TemplateParams->size() > 1) {
+if (TemplateParams->size() > 1) {
   TemplateParams->pop_back();
 } else {
   TemplateParams = nullptr;


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


[PATCH] D19068: Lit C++11 Compatibility Patch #7

2016-04-13 Thread Charles Li via cfe-commits
tigerleapgorge created this revision.
tigerleapgorge added a reviewer: rsmith.
tigerleapgorge added a subscriber: cfe-commits.

13 tests have been updated for C++11 compatibility.


CXX/class.access/class.access.dcl/p1.cpp
  Access declarations are deprecated in C++11.
  As a result, there are 4 types of diagnostics changes:

  For simple access declarations, there is a change in diagnostics.
C++98: warning: access declarations are deprecated; use using declarations 
instead
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead

  For Self-referential access declarations, there is also an additional error 
message.
C++98: warning: access declarations are deprecated; use using declarations 
instead
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead
C++11: error: using declaration refers to its own class

  For an access declaration of a non-base method, there is a different 
additional error message.
C++98: warning: access declarations are deprecated; use using declarations 
instead
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead
C++11: error: using declaration refers into 'Subclass::', which is not a 
base class of 'C'

  For self-referential access declaration with local declaration, there is the 
additional error message but one less note message.
C++98: warning: access declarations are deprecated; use using declarations 
instead [-Wdeprecated]
C++98: error: using declaration refers to its own class
C++98: note: target of using declaration
C++11: error: ISO C++11 does not allow access declarations; use using 
declarations instead
C++11: error: using declaration refers to its own class

CXX/temp/temp.spec/temp.expl.spec/p2.cpp
  Guard multiple instances of the following diagnostics to C++98.
C++98: warning: first declaration of function template specialization of 
'f0' outside namespace 'N0' is a C++11 extension
C++98: note: explicitly specialized declaration is here

CXX/temp/temp.spec/temp.expl.spec/p3.cpp
  Guard one instance of the following diagnostics to C++98.
C++98: warning: first declaration of class template specialization of 'X' 
outside namespace 'N' is a C++11 extension
C++98: note: explicitly specialized declaration is here

CXX/temp/temp.spec/temp.explicit/p2.cpp
CXX/temp/temp.spec/temp.explicit/p5.cpp
  In C++98 with -Wc++11-compat, Out-of-scope explicit instantiations of 
template is a Warning.
  In C++11, it is now an Error.
C++98: warning: explicit instantiation of 'N::f1' must occur in namespace 
'N'
C++11: error: explicit instantiation of 'N::f1' must occur in namespace 'N'

CodeGenCXX/debug-info-static-member.cpp
  In C++11, replace “const” with “constexpr” for in-class static initializer of 
non-integral type.
  Otherwise compiler would complain: 
C++11: error: in-class initializer for static data member of type 'const 
float' requires 'constexpr' specifier

SemaCXX/dcl_init_aggr.cpp
  Diagnostic change due to initializer list
C++98: error: non-aggregate type 'NonAggregate' cannot be initialized with 
an initializer list
C++11: error no matching constructor for initialization of 'NonAggregate'
   note: candidate constructor (the implicit copy constructor) not 
viable
   note: candidate constructor (the implicit move constructor) not 
viable
   note: candidate constructor not viable

  Diagnostic Change
C++98: conversion from string literal to 'char *' is deprecated
C++11: ISO C++11 does not allow conversion from string literal to 'char *'

  Addition C++11 move constructor diagnostics
C++11: note: candidate constructor (the implicit move constructor) not 
viable

  The next 2 lines caused a lot of diff.
Source: TooFewError too_few_error = { 1 }
C++98: error: no matching constructor for initialization of 
'NoDefaultConstructor'
   note: candidate constructor not viable: requires 1 argument, but 0 
were provided
   note: candidate constructor (the implicit copy constructor) not 
viable
   note: in implicit initialization of field 'nodef' with omitted 
initializer
   error: implicit default constructor for 'TooFewError' must 
explicitly initialize
  the member 'nodef' which does not have a default constructor
   note: member is declared here
   note: 'NoDefaultConstructor' declared here

C++11: error: no matching constructor for initialization of 
'NoDefaultConstructor'
   note: candidate constructor not viable: requires 1 argument, but 0 
were provided
   note: candidate constructor (the implicit copy constructor) not 
viable
   note: candidate constructor (the implicit move constructor) not 
viable
   note: in implicit initialization of field 'nodef' with omitted 
initializer

Source: TooFewError too_few_okay2[2] = { 1, 1 };
C+

Re: [PATCH] D19066: clang-format: `SpaceAfterTemplate` and `SpacesInBraces` options

2016-04-13 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Please read 
http://clang.llvm.org/docs/ClangFormatStyleOptions.html#adding-additional-style-options.

The "template" option was discussed multiple times and I remain convinced that 
the costs outweigh the benefit here.

For the other option:

- Can you make statements wrt. to the requirements made on that page.
- This is pulling many things into one option that don't belong together. For 
braced lists, there is already the Cpp11BracedListStyle option which does the 
same thing (but also something else). We need a clear strategy for that option.
- Similar to the template option, I am not convinced that an option to control 
whether "{}" or "{ }" carries its weight.


http://reviews.llvm.org/D19066



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


[PATCH] D19069: clang-format: Fixed various brace wrapping and block merging bugs

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic created this revision.
mxbOctasic added a reviewer: djasper.
mxbOctasic added subscribers: cameron314, cfe-commits.
Herald added a subscriber: klimek.

Multiple brace wrapping flag combination were broken. 

First, IndentBraces + !AfterControlStatement caused the whole If-Else construct 
to be indented.

Currently, only function blocks can be merged into one line when the opening 
brace wrapped.
The short block merging logic checks the AfterFunction flag for all block types.
With AllowShortFunctions (All), !BraceWrapping.AfterFunction and 
BraceWrapping.AfterControlStatement I ended up with this: 
  if(true)
  {}
This happened with all other non-function blocks with the opening brace wrapped 
on its own line.


http://reviews.llvm.org/D19069

Files:
  lib/Format/FormatToken.h
  lib/Format/TokenAnnotator.cpp
  lib/Format/UnwrappedLineFormatter.cpp
  lib/Format/UnwrappedLineParser.cpp
  unittests/Format/FormatTest.cpp

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -423,6 +423,119 @@
"  f();\n"
"}",
AllowSimpleBracedStatements);
+
+  AllowSimpleBracedStatements.BreakBeforeBraces = FormatStyle::BS_Custom;
+  AllowSimpleBracedStatements.BraceWrapping.AfterControlStatement = true;
+  AllowSimpleBracedStatements.BraceWrapping.BeforeElse = true;
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = false;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = false;
+
+  verifyFormat("if (true)\n"
+   "{\n"
+   "  f();\n"
+   "}\n"
+   "else\n"
+   "{\n"
+   "  f();\n"
+   "}\n",
+   AllowSimpleBracedStatements);
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = false;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = true;
+
+  verifyFormat("if (true)\n"
+   "{\n"
+   "  f();\n"
+   "}\n"
+   "else\n"
+   "{\n"
+   "  f();\n"
+   "}\n",
+   AllowSimpleBracedStatements);
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = true;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = false;
+
+  verifyFormat("if (true)\n"
+   "{\n"
+   "  f();\n"
+   "}\n"
+   "else\n"
+   "{\n"
+   "  f();\n"
+   "}\n",
+   AllowSimpleBracedStatements);
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = true;
+  AllowSimpleBracedStatements.AllowShortIfStatementsOnASingleLine = true;
+
+  EXPECT_EQ("if (true) { f(); }\nelse { f(); }",
+format("if (true)\n"
+   "{\n"
+   "  f();\n"
+   "}\n"
+   "else\n"
+   "{\n"
+   "  f();\n"
+   "}",
+   AllowSimpleBracedStatements));
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = false;
+  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = false;
+
+  verifyFormat("while (true)\n"
+   "{\n"
+   "  f();\n"
+   "}",
+   AllowSimpleBracedStatements);
+  verifyFormat("for (;;)\n"
+   "{\n"
+   "  f();\n"
+   "}",
+   AllowSimpleBracedStatements);
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = false;
+  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
+
+  verifyFormat("while (true)\n"
+   "{\n"
+   "  f();\n"
+   "}",
+   AllowSimpleBracedStatements);
+  verifyFormat("for (;;)\n"
+   "{\n"
+   "  f();\n"
+   "}",
+   AllowSimpleBracedStatements);
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = true;
+  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = false;
+
+  verifyFormat("while (true)\n"
+   "{\n"
+   "  f();\n"
+   "}",
+   AllowSimpleBracedStatements);
+  verifyFormat("for (;;)\n"
+   "{\n"
+   "  f();\n"
+   "}",
+   AllowSimpleBracedStatements);
+
+  AllowSimpleBracedStatements.AllowShortBlocksOnASingleLine = true;
+  AllowSimpleBracedStatements.AllowShortLoopsOnASingleLine = true;
+
+  EXPECT_EQ("while (true) { f(); }", format("while (true)\n"
+"{\n"
+"  f();\n"
+"}",
+AllowSimpleBracedStatements));
+  EXPECT_EQ("for (;;) { f(); }", format("for (;;)\n"
+"{\n"
+  

Re: [PATCH] D19069: clang-format: Fixed various brace wrapping and block merging bugs

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic added inline comments.


Comment at: lib/Format/UnwrappedLineParser.cpp:789-790
@@ -773,4 +788,4 @@
   if (FormatTok->Tok.is(tok::l_brace)) {
-if (Style.BraceWrapping.AfterObjCDeclaration)
-  addUnwrappedLine();
+CompoundStatementIndenter Indenter(
+this, Style, Line->Level, 
Style.BraceWrapping.AfterObjCDeclaration);
 parseBlock(/*MustBeDeclaration=*/false);

We may not want this.


Comment at: lib/Format/UnwrappedLineParser.cpp:1388-1390
@@ -1372,3 +1387,5 @@
 parseBlock(/*MustBeDeclaration=*/false);
-if (Style.BraceWrapping.BeforeElse)
+if (Style.BraceWrapping.BeforeElse ||
+Style.BraceWrapping.AfterControlStatement &&
+Style.BraceWrapping.IndentBraces)
   addUnwrappedLine();

IndentBraces can only work properly when both AfterControlStatement and 
BeforeElse are active.
The opening brace can only be indented when it is wrapped on its own line, and 
the else keyword has to be on another line too.
We have to decide which option has precedence over the others.
Right now I'm overriding BeforeElse when the opening brace is wrapped.


Comment at: unittests/Format/FormatTest.cpp:2454-2456
@@ -2340,3 +2453,5 @@
   // Function-level try statements.
-  verifyFormat("int f() try { return 4; } catch (...) {\n"
+  verifyFormat("int f() try {\n"
+   "  return 4;\n"
+   "} catch (...) {\n"
"  return 5;\n"

This test probably should not have been changed.
However, it's strange to have the try on one line but not the catch.


http://reviews.llvm.org/D19069



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


Re: [PATCH] D18265: [clang-tidy] New: checker misc-assign-operator-return

2016-04-13 Thread Samuel Benzaquen via cfe-commits
sbenza added inline comments.


Comment at: clang-tidy/misc/AssignOperatorCheck.cpp:63
@@ +62,3 @@
+
+  Finder->addMatcher(returnStmt(IsBadReturnStatement, 
hasAncestor(IsGoodAssign))
+ .bind("returnStmt"),

baloghadamsoftware wrote:
> sbenza wrote:
> > baloghadamsoftware wrote:
> > > sbenza wrote:
> > > > baloghadamsoftware wrote:
> > > > > sbenza wrote:
> > > > > > I dislike these uses of hasAnscestor. They are kind of slow.
> > > > > > But more importantly, they break with nested functions/types.
> > > > > > This particular example is not checking that the return statement 
> > > > > > is from the assignment operator, only that it is within it. For 
> > > > > > example, it would match a lambda.
> > > > > > I think this would trip the check:
> > > > > > 
> > > > > > F& operator=(const F& o) {
> > > > > >   std::copy_if(o.begin(), o.end(), begin(), [](V v) { return v 
> > > > > > > 0; });
> > > > > >   return *this;
> > > > > > }
> > > > > I can change it to hasDescendant if it is faster, but it does not 
> > > > > solve the lambda problem. No solution for that comes to my mind with 
> > > > > the existing matchers. Maybe a new matcher hasDescendantStatement 
> > > > > could help which only traverses statements down the AST. Is this the 
> > > > > right way to go?
> > > > hasDescendant has the same problem has hasAnscestor.
> > > > I think the best is to write a matcher like:
> > > > 
> > > > AST_MATCHER_P(ReturnStmt, forFunction, 
> > > > internal::Matcher, InnerMatcher) {
> > > >   ...
> > > > }
> > > > 
> > > > In there we can find the right FunctionDecl that encloses the return 
> > > > statement and apply the matcher.
> > > > This matcher seems like a good candidate to add to ASTMatchers.h
> > > Maybe I am wrong, but your proposal also seems a bottom-up matcher which 
> > > is slow. That is the reason I proposed a top-down matcher, e.g. 
> > > hasDescendantStatement or something like this which is top-down and only 
> > > traverses statements so it does not search in a lambda which is a 
> > > declaration.
> > hasAnscestor is slow because it is way too general. There are tons of 
> > virtual function calls, cache lookups, memory allocations, etc. And the 
> > search will not stop until it find a match or runs out of anscestors. This 
> > means it will go all the way to the translationUnitDecl before it figures 
> > out that there are no matches.
> > Every parent will be run through the matcher.
> > 
> > What I propose is a simple matcher that:
> >  1. Finds the enclosing FunctionDecl for a statement.
> >  2. Runs the matcher on it, if there is an enclosing function.
> > 
> > (1) can be done without any virtual function call and with no/minimal 
> > memory allocations.
> > (2) will be done only once on the found node.
> > 
> I did something like your proposal and it is working, but before uploading a 
> patch I have a question. There are some nodes, even statement having multiple 
> parents, probably due to template instantiations. Is it enough if we chose 
> the first parent here (thus going up only to the template itself) or should 
> we do a depth-first (better to say height-search here, since we are not 
> searching downwards in a tree but upwards in a DAG) search here and go up to 
> every parent? hasAncestor uses breadth-first search which is out of the 
> question here.
Yes, with templates you can have multiple parents.
I think you can use any of the parents, but it would be unspecified which 
FunctionDecl you get.
Maybe step (1) can return a list of FunctionDecls instead.
In this particular case you might need the particular template instantiation 
because the return type might be a dependent type.


http://reviews.llvm.org/D18265



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


r266235 - [CrashReproducer] Add test to run the reproducer script + modules

2016-04-13 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 13 14:28:24 2016
New Revision: 266235

URL: http://llvm.org/viewvc/llvm-project?rev=266235&view=rev
Log:
[CrashReproducer] Add test to run the reproducer script + modules

Now that we have basic support in place, make sure the reproducer script
works with modules for a simple testcase.

Added:
cfe/trunk/test/Modules/crash-vfs-run-reproducer.m

Added: cfe/trunk/test/Modules/crash-vfs-run-reproducer.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-run-reproducer.m?rev=266235&view=auto
==
--- cfe/trunk/test/Modules/crash-vfs-run-reproducer.m (added)
+++ cfe/trunk/test/Modules/crash-vfs-run-reproducer.m Wed Apr 13 14:28:24 2016
@@ -0,0 +1,57 @@
+// REQUIRES: crash-recovery, shell, system-darwin
+
+// RUN: rm -rf %t
+// RUN: mkdir -p %t/i %t/m %t
+
+// RUN: not env FORCE_CLANG_DIAGNOSTICS_CRASH= TMPDIR=%t TEMP=%t TMP=%t \
+// RUN: %clang -fsyntax-only -nostdinc %s \
+// RUN: -I %S/Inputs/crash-recovery/usr/include -isysroot %/t/i/ \
+// RUN: -fmodules -fmodules-cache-path=%t/m/ 2>&1 | FileCheck %s
+
+// RUN: FileCheck --check-prefix=CHECKSRC %s -input-file %t/crash-vfs-*.m
+// RUN: FileCheck --check-prefix=CHECKSH %s -input-file %t/crash-vfs-*.sh
+// RUN: FileCheck --check-prefix=CHECKYAML %s -input-file \
+// RUN: %t/crash-vfs-*.cache/vfs/vfs.yaml
+// RUN: find %t/crash-vfs-*.cache/vfs | \
+// RUN:   grep "Inputs/crash-recovery/usr/include/stdio.h" | count 1
+
+#include 
+
+// CHECK: Preprocessed source(s) and associated run script(s) are located at:
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.m
+// CHECK-NEXT: note: diagnostic msg: {{.*}}.cache
+
+// CHECKSRC: @import cstd.stdio;
+
+// CHECKSH: # Crash reproducer
+// CHECKSH-NEXT: # Driver args: "-fsyntax-only"
+// CHECKSH-NEXT: # Original command: {{.*$}}
+// CHECKSH-NEXT: "-cc1"
+// CHECKSH: "-resource-dir"
+// CHECKSH: "-isysroot" "{{[^"]*}}/i/"
+// CHECKSH: "crash-vfs-{{[^ ]*}}.m"
+// CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
+// CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules"
+
+// CHECKYAML: 'case-sensitive':
+// CHECKYAML-NEXT: 'use-external-names': 'false',
+// CHECKYAML-NEXT: 'overlay-relative': 'true',
+// CHECKYAML: 'type': 'directory'
+// CHECKYAML: 'name': "/[[PATH:.*]]/Inputs/crash-recovery/usr/include",
+// CHECKYAML-NEXT: 'contents': [
+// CHECKYAML-NEXT:   {
+// CHECKYAML-NEXT: 'type': 'file',
+// CHECKYAML-NEXT: 'name': "module.map",
+// CHECKYAML-NOT:  'external-contents': "{{[^ ]*}}.cache
+// CHECKYAML-NEXT: 'external-contents': 
"/[[PATH]]/Inputs/crash-recovery/usr/include/module.map"
+// CHECKYAML-NEXT:   },
+
+// Run the reproducer script - regular exit code is enough to test it works.
+// Note that we don't yet support reusing the modules pcm; what we do
+// support is re-building the modules relying solely on the header files dumped
+// inside .cache/vfs, mapped by .cache/vfs/vfs.yaml.
+
+// RUN: cd %t
+// RUN: rm -rf crash-vfs-run-reproducer-*.cache/modules/*
+// RUN: chmod 755 crash-vfs-*.sh
+// RUN: ./crash-vfs-*.sh


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


r266234 - [CrashReproducer] Setup 'use-external-names' in YAML files.

2016-04-13 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 13 14:28:21 2016
New Revision: 266234

URL: http://llvm.org/viewvc/llvm-project?rev=266234&view=rev
Log:
[CrashReproducer] Setup 'use-external-names' in YAML files.

Hide the real paths when rebuilding from VFS by setting up the crash
reproducer to use 'use-external-names' = false. This way we avoid
module redifinition errors and consistently use the same paths against
all modules.

With this change on Darwin we are able to simulate a crash for a simple
application using "Foundation/Foundation.h" (which relies on a bunch of
different frameworks and headers) and successfully rebuild all the
modules by relying solely at the VFS overlay.

Modified:
cfe/trunk/include/clang/Basic/VirtualFileSystem.h
cfe/trunk/lib/Basic/VirtualFileSystem.cpp
cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp
cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
cfe/trunk/test/Modules/crash-vfs-path-traversal.m
cfe/trunk/test/Modules/crash-vfs-relative-overlay.m

Modified: cfe/trunk/include/clang/Basic/VirtualFileSystem.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/VirtualFileSystem.h?rev=266234&r1=266233&r2=266234&view=diff
==
--- cfe/trunk/include/clang/Basic/VirtualFileSystem.h (original)
+++ cfe/trunk/include/clang/Basic/VirtualFileSystem.h Wed Apr 13 14:28:21 2016
@@ -325,6 +325,7 @@ class YAMLVFSWriter {
   std::vector Mappings;
   Optional IsCaseSensitive;
   Optional IsOverlayRelative;
+  Optional UseExternalNames;
   std::string OverlayDir;
 
 public:
@@ -333,6 +334,9 @@ public:
   void setCaseSensitivity(bool CaseSensitive) {
 IsCaseSensitive = CaseSensitive;
   }
+  void setUseExternalNames(bool UseExtNames) {
+UseExternalNames = UseExtNames;
+  }
   void setOverlayDir(StringRef OverlayDirectory) {
 IsOverlayRelative = true;
 OverlayDir.assign(OverlayDirectory.str());

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=266234&r1=266233&r2=266234&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Apr 13 14:28:21 2016
@@ -1504,8 +1504,9 @@ class JSONWriter {
 
 public:
   JSONWriter(llvm::raw_ostream &OS) : OS(OS) {}
-  void write(ArrayRef Entries, Optional IsCaseSensitive,
- Optional IsOverlayRelative, StringRef OverlayDir);
+  void write(ArrayRef Entries, Optional UseExternalNames,
+ Optional IsCaseSensitive, Optional IsOverlayRelative,
+ StringRef OverlayDir);
 };
 }
 
@@ -1558,6 +1559,7 @@ void JSONWriter::writeEntry(StringRef VP
 }
 
 void JSONWriter::write(ArrayRef Entries,
+   Optional UseExternalNames,
Optional IsCaseSensitive,
Optional IsOverlayRelative,
StringRef OverlayDir) {
@@ -1568,6 +1570,9 @@ void JSONWriter::write(ArrayRefhttp://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp?rev=266234&r1=266233&r2=266234&view=diff
==
--- cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp (original)
+++ cfe/trunk/lib/Frontend/ModuleDependencyCollector.cpp Wed Apr 13 14:28:21 
2016
@@ -112,6 +112,10 @@ void ModuleDependencyCollector::writeFil
   // the sensitivity at the path where the headers all collected to.
   VFSWriter.setCaseSensitivity(isCaseSensitivePath(VFSDir));
 
+  // Do not rely on real path names when executing the crash reproducer scripts
+  // since we only want to actually use the files we have on the VFS cache.
+  VFSWriter.setUseExternalNames(false);
+
   std::error_code EC;
   SmallString<256> YAMLPath = VFSDir;
   llvm::sys::path::append(YAMLPath, "vfs.yaml");

Modified: cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m?rev=266234&r1=266233&r2=266234&view=diff
==
--- cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m (original)
+++ cfe/trunk/test/Modules/crash-vfs-path-symlink-component.m Wed Apr 13 
14:28:21 2016
@@ -40,6 +40,9 @@
 // CHECKSH: "-ivfsoverlay" "crash-vfs-{{[^ ]*}}.cache/vfs/vfs.yaml"
 // CHECKSH: "-fmodules-cache-path=crash-vfs-{{[^ ]*}}.cache/modules"
 
+// CHECKYAML: 'case-sensitive':
+// CHECKYAML-NEXT: 'use-external-names': 'false',
+// CHECKYAML-NEXT: 'overlay-relative': 'true',
 // CHECKYAML: 'type': 'directory'
 // CHECKYAML: 'name': "/[[PATH:.*]]/i/usr/include",
 // CHECKYAML-NEXT: 'contents': [
@@ -70,4 +73,4 @@
 // RUN: -fmodules-cache-path=%t/m/ 2>&1 \
 // RUN: | FileCheck %s --check-prefix=CHECKOVERLAY
 
-// CHECKOVERLAY: @import cstd.std

r266233 - [VFS] Move default values to in-class member initialization. NFC

2016-04-13 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Wed Apr 13 14:28:16 2016
New Revision: 266233

URL: http://llvm.org/viewvc/llvm-project?rev=266233&view=rev
Log:
[VFS] Move default values to in-class member initialization. NFC

Modified:
cfe/trunk/lib/Basic/VirtualFileSystem.cpp

Modified: cfe/trunk/lib/Basic/VirtualFileSystem.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/VirtualFileSystem.cpp?rev=266233&r1=266232&r2=266233&view=diff
==
--- cfe/trunk/lib/Basic/VirtualFileSystem.cpp (original)
+++ cfe/trunk/lib/Basic/VirtualFileSystem.cpp Wed Apr 13 14:28:16 2016
@@ -834,7 +834,7 @@ class RedirectingFileSystem : public vfs
   /// \brief Whether to perform case-sensitive comparisons.
   ///
   /// Currently, case-insensitive matching only works correctly with ASCII.
-  bool CaseSensitive;
+  bool CaseSensitive = true;
 
   /// IsRelativeOverlay marks whether a IsExternalContentsPrefixDir path must
   /// be prefixed in every 'external-contents' when reading from YAML files.
@@ -842,7 +842,7 @@ class RedirectingFileSystem : public vfs
 
   /// \brief Whether to use to use the value of 'external-contents' for the
   /// names of files.  This global value is overridable on a per-file basis.
-  bool UseExternalNames;
+  bool UseExternalNames = true;
   /// @}
 
   /// Virtual file paths and external files could be canonicalized without 
"..",
@@ -859,7 +859,7 @@ class RedirectingFileSystem : public vfs
 
 private:
   RedirectingFileSystem(IntrusiveRefCntPtr ExternalFS)
-  : ExternalFS(ExternalFS), CaseSensitive(true), UseExternalNames(true) {}
+  : ExternalFS(ExternalFS) {}
 
   /// \brief Looks up \p Path in \c Roots.
   ErrorOr lookupPath(const Twine &Path);


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


Re: [PATCH] D19058: clang-format: Pointer `*` is seen as multiplication in C-style casts

2016-04-13 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/TokenAnnotator.cpp:1272
@@ +1271,3 @@
+// Casts are never binary operators, regardless of IsExpression
+if (NextToken->isOneOf(tok::r_paren, tok::greater))
+  return TT_PointerOrReference;

I think it would be better to not have such cast detection heuristics in 
several places. Could we change the type of the "*" to TT_PointerOrReference 
after the fact, when rParenEndsCast returns true?


http://reviews.llvm.org/D19058



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


Re: [PATCH] D19063: clang-format: Fixed line merging of more than two lines

2016-04-13 Thread Daniel Jasper via cfe-commits
djasper added a comment.

Nice catch.



Comment at: unittests/Format/FormatTest.cpp:285
@@ +284,3 @@
+
+  EXPECT_EQ("class Foo\n"
+"{\n"

How does this break? I generally add an Before and After of one of the test 
cases into my patch descriptions.


http://reviews.llvm.org/D19063



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


Re: [PATCH] D19064: clang-format: Allow include of clangFormat.h in managed context

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

Looks good.



Comment at: include/clang/Format/Format.h:30
@@ +29,3 @@
+namespace vfs {
+
+class FileSystem;

nit: Remove this empty line.


http://reviews.llvm.org/D19064



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


Re: [PATCH] D19065: clang-format: Last line in incomplete block is indented incorrectly

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

Looks good.


http://reviews.llvm.org/D19065



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


Re: [PATCH] D19069: clang-format: Fixed various brace wrapping and block merging bugs

2016-04-13 Thread Daniel Jasper via cfe-commits
djasper added inline comments.


Comment at: lib/Format/UnwrappedLineParser.cpp:1388-1390
@@ -1372,3 +1387,5 @@
 parseBlock(/*MustBeDeclaration=*/false);
-if (Style.BraceWrapping.BeforeElse)
+if (Style.BraceWrapping.BeforeElse ||
+Style.BraceWrapping.AfterControlStatement &&
+Style.BraceWrapping.IndentBraces)
   addUnwrappedLine();

mxbOctasic wrote:
> IndentBraces can only work properly when both AfterControlStatement and 
> BeforeElse are active.
> The opening brace can only be indented when it is wrapped on its own line, 
> and the else keyword has to be on another line too.
> We have to decide which option has precedence over the others.
> Right now I'm overriding BeforeElse when the opening brace is wrapped.
Maybe we should put logic like this into expandPresets (possibly renaming it)?


Comment at: unittests/Format/FormatTest.cpp:427
@@ +426,3 @@
+
+  AllowSimpleBracedStatements.BreakBeforeBraces = FormatStyle::BS_Custom;
+  AllowSimpleBracedStatements.BraceWrapping.AfterControlStatement = true;

I think we need a better way to structure these tests. And reusing a style with 
the name "AllowSimpleBracedStatements" doesn't make sense here.


Comment at: unittests/Format/FormatTest.cpp:474
@@ +473,3 @@
+  EXPECT_EQ("if (true) { f(); }\nelse { f(); }",
+format("if (true)\n"
+   "{\n"

I'd remove all the line breaks and "\n"s here.


Comment at: unittests/Format/FormatTest.cpp:2454-2456
@@ -2340,3 +2453,5 @@
   // Function-level try statements.
-  verifyFormat("int f() try { return 4; } catch (...) {\n"
+  verifyFormat("int f() try {\n"
+   "  return 4;\n"
+   "} catch (...) {\n"
"  return 5;\n"

mxbOctasic wrote:
> This test probably should not have been changed.
> However, it's strange to have the try on one line but not the catch.
Yeah, I agree.


http://reviews.llvm.org/D19069



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


Re: [PATCH] D18596: [MSVC] PR27132: Proper mangling for __unaligned qualifier

2016-04-13 Thread Reid Kleckner via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

Thanks! This looks great.



Comment at: test/SemaCXX/MicrosoftExtensions.cpp:89
@@ +88,3 @@
+void foo_unaligned(int *arg) {}
+void foo_unaligned(__unaligned int *arg) {}
+void foo_unaligned(int arg) {} // expected-note {{previous definition is here}}

andreybokhanko wrote:
> Reid, thanks for looking into this patch!
> 
> I added more comprehensive overloading tests.
> 
> As for printing a warning, I added it -- in C mode. In C++ mode we don't 
> allow types conversion that loses qualifiers. I do the same for __unaligned. 
> If you want me to implement printing a warning in C++ mode as well (as MS 
> compiler does), I would appreciate any hints on where the best place to do 
> it. Putting it directly into code that verifies qualifiers compatibility 
> seems to be odd.
> 
> Andrey
> 
I think we can keep it as you have it for now. We can wait and see if users 
complain about the C++ mode error.


http://reviews.llvm.org/D18596



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


r266239 - Lit C++11 Compatibility Patch #7

2016-04-13 Thread Charles Li via cfe-commits
Author: lcharles
Date: Wed Apr 13 15:00:45 2016
New Revision: 266239

URL: http://llvm.org/viewvc/llvm-project?rev=266239&view=rev
Log:
Lit C++11 Compatibility Patch #7

13 tests have been updated for C++11 compatibility.
Differential Revision: http://reviews.llvm.org/D19068

Modified:
cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
cfe/trunk/test/SemaCXX/dcl_init_aggr.cpp
cfe/trunk/test/SemaCXX/type-convert-construct.cpp
cfe/trunk/test/SemaCXX/vararg-non-pod.cpp
cfe/trunk/test/SemaTemplate/class-template-spec.cpp
cfe/trunk/test/SemaTemplate/instantiate-cast.cpp
cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
cfe/trunk/test/SemaTemplate/instantiate-member-class.cpp

Modified: cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp?rev=266239&r1=266238&r2=266239&view=diff
==
--- cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp (original)
+++ cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp Wed Apr 13 15:00:45 
2016
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // This is just the test for [namespace.udecl]p4 with 'using'
 // uniformly stripped out.
@@ -24,10 +26,33 @@ namespace test0 {
   }
 
   class Test0 {
-NonClass::type; // expected-error {{not a class}} expected-warning 
{{access declarations are deprecated}}
-NonClass::hiding; // expected-error {{not a class}} expected-warning 
{{access declarations are deprecated}}
-NonClass::union_member; // expected-error {{not a class}} expected-warning 
{{access declarations are deprecated}}
-NonClass::enumerator; // expected-error {{not a class}} expected-warning 
{{access declarations are deprecated}}
+NonClass::type; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
using declarations instead}}
+#endif
+
+NonClass::hiding; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
using declarations instead}}
+#endif
+
+NonClass::union_member; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
using declarations instead}}
+#endif
+
+NonClass::enumerator; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
using declarations instead}}
+#endif
   };
 }
 
@@ -43,11 +68,39 @@ namespace test1 {
   };
 
   struct B : A {
-A::type; // expected-warning {{access declarations are deprecated}}
-A::hiding; // expected-warning {{access declarations are deprecated}}
-A::union_member; // expected-warning {{access declarations are deprecated}}
-A::enumerator; // expected-warning {{access declarations are deprecated}}
-A::tagname; // expected-warning {{access declarations are deprecated}}
+A::type;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
using declarations instead}}
+#endif
+A::hiding;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
using declarations instead}}
+#endif
+
+A::union_member;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
using declarations instead}}
+#endif
+
+A::enumerator;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using 
declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use 
usi

Re: [PATCH] D19068: Lit C++11 Compatibility Patch #7

2016-04-13 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL266239: Lit C++11 Compatibility Patch #7 (authored by 
lcharles).

Changed prior to commit:
  http://reviews.llvm.org/D19068?vs=53603&id=53607#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19068

Files:
  cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp
  cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p2.cpp
  cfe/trunk/test/CXX/temp/temp.spec/temp.expl.spec/p3.cpp
  cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p2.cpp
  cfe/trunk/test/CXX/temp/temp.spec/temp.explicit/p5.cpp
  cfe/trunk/test/CodeGenCXX/debug-info-static-member.cpp
  cfe/trunk/test/SemaCXX/dcl_init_aggr.cpp
  cfe/trunk/test/SemaCXX/type-convert-construct.cpp
  cfe/trunk/test/SemaCXX/vararg-non-pod.cpp
  cfe/trunk/test/SemaTemplate/class-template-spec.cpp
  cfe/trunk/test/SemaTemplate/instantiate-cast.cpp
  cfe/trunk/test/SemaTemplate/instantiate-expr-4.cpp
  cfe/trunk/test/SemaTemplate/instantiate-member-class.cpp

Index: cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp
===
--- cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp
+++ cfe/trunk/test/CXX/class.access/class.access.dcl/p1.cpp
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
 
 // This is just the test for [namespace.udecl]p4 with 'using'
 // uniformly stripped out.
@@ -24,10 +26,33 @@
   }
 
   class Test0 {
-NonClass::type; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
-NonClass::hiding; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
-NonClass::union_member; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
-NonClass::enumerator; // expected-error {{not a class}} expected-warning {{access declarations are deprecated}}
+NonClass::type; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
+
+NonClass::hiding; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
+
+NonClass::union_member; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
+
+NonClass::enumerator; // expected-error {{not a class}}
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
   };
 }
 
@@ -43,11 +68,39 @@
   };
 
   struct B : A {
-A::type; // expected-warning {{access declarations are deprecated}}
-A::hiding; // expected-warning {{access declarations are deprecated}}
-A::union_member; // expected-warning {{access declarations are deprecated}}
-A::enumerator; // expected-warning {{access declarations are deprecated}}
-A::tagname; // expected-warning {{access declarations are deprecated}}
+A::type;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
+A::hiding;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
+
+A::union_member;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
+
+A::enumerator;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarations; use using declarations instead}}
+#endif
+
+A::tagname;
+#if __cplusplus <= 199711L
+// expected-warning@-2 {{access declarations are deprecated; use using declarations instead}}
+#else
+// expected-error@-4 {{ISO C++11 does not allow access declarati

Re: [PATCH] D19064: clang-format: Allow include of clangFormat.h in managed context

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic updated this revision to Diff 53608.
mxbOctasic added a comment.

Removed empty line.


http://reviews.llvm.org/D19064

Files:
  include/clang/Format/Format.h
  lib/Format/Format.cpp

Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -27,6 +26,10 @@
 class SourceManager;
 class DiagnosticConsumer;
 
+namespace vfs {
+class FileSystem;
+}
+
 namespace format {
 
 enum class ParseError { Success = 0, Error, Unsuitable };


Index: lib/Format/Format.cpp
===
--- lib/Format/Format.cpp
+++ lib/Format/Format.cpp
@@ -22,6 +22,7 @@
 #include "clang/Basic/Diagnostic.h"
 #include "clang/Basic/DiagnosticOptions.h"
 #include "clang/Basic/SourceManager.h"
+#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Lex/Lexer.h"
 #include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/Allocator.h"
Index: include/clang/Format/Format.h
===
--- include/clang/Format/Format.h
+++ include/clang/Format/Format.h
@@ -16,7 +16,6 @@
 #define LLVM_CLANG_FORMAT_FORMAT_H
 
 #include "clang/Basic/LangOptions.h"
-#include "clang/Basic/VirtualFileSystem.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/ArrayRef.h"
 #include 
@@ -27,6 +26,10 @@
 class SourceManager;
 class DiagnosticConsumer;
 
+namespace vfs {
+class FileSystem;
+}
+
 namespace format {
 
 enum class ParseError { Success = 0, Error, Unsuitable };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19014: [clang-tidy] Add new checker for suspicious sizeof expressions

2016-04-13 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


Comment at: clang-tidy/misc/SizeofExpressionCheck.cpp:28
@@ +27,3 @@
+  return Node.getValue().getZExtValue() > N;
+}
+

alexfh wrote:
> There are no firm rules. It mostly depends on how generic/useful in other 
> tools the matcher could be. This one seems pretty generic and it could be 
> used in a couple of other clang-tidy checks at least (e.g. 
> readability/ContainerSizeEmptyCheck.cpp), so it seems to be a good fit for 
> ASTMatchers.h. This can also be done as a separate step, if you prefer.
I'm not against at all to lift this.
Now, or in a separate step.

I just leave it here so the patch is still working as-is (if people want to 
play with it and found invalid cases!).


Comment at: clang-tidy/misc/SizeofExpressionCheck.cpp:197
@@ +196,3 @@
+  this);
+}
+

alexfh wrote:
> I see the reasoning, but in this case I'd still prefer if this custom matcher 
> looked at the children instead of the parents, since it's a more effective 
> approach in general (at least because it doesn't use the parent map).
> 
> We should probably add a variant of `hasDescendant` (and maybe `hasAncestor`) 
> with a way to limit which nodes it can look through.
I was thinking it's more effective to look to ancestor than descendants?
There are less ancestors than descendants?


Comment at: clang-tidy/misc/SizeofExpressionCheck.cpp:198
@@ +197,3 @@
+}
+
+void SizeofExpressionCheck::check(const MatchFinder::MatchResult &Result) {

alexfh wrote:
> I'm probably wrong about "a more effective approach in general", but for 
> `sizeof` case it might be more effective, if we assume that `sizeof` doesn't 
> have large subtrees under it.
> 
> A separate concern is that the matchers looking up the tree are somewhat more 
> difficult to understand (at least to me).
> 
> Ultimately, I'm not sure what's the best approach here. Maybe find a huge 
> file and measure runtime of both implementations? ;)
I'm uploading the top-down approach.
As I suspected, this is changing nothing on large cases I tried.

I put the limit of 8 level depth, which won't cause any combinatory explosion.
Worse case: 2^8 nodes.



http://reviews.llvm.org/D19014



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


Re: [PATCH] D19014: [clang-tidy] Add new checker for suspicious sizeof expressions

2016-04-13 Thread Etienne Bergeron via cfe-commits
etienneb updated this revision to Diff 53609.
etienneb marked 2 inline comments as done.
etienneb added a comment.

alexfh@ comment: top-down approach.


http://reviews.llvm.org/D19014

Files:
  clang-tidy/misc/CMakeLists.txt
  clang-tidy/misc/MiscTidyModule.cpp
  clang-tidy/misc/SizeofExpressionCheck.cpp
  clang-tidy/misc/SizeofExpressionCheck.h
  docs/ReleaseNotes.rst
  docs/clang-tidy/checks/list.rst
  docs/clang-tidy/checks/misc-sizeof-expression.rst
  test/clang-tidy/misc-sizeof-expression.cpp

Index: test/clang-tidy/misc-sizeof-expression.cpp
===
--- /dev/null
+++ test/clang-tidy/misc-sizeof-expression.cpp
@@ -0,0 +1,186 @@
+// RUN: %check_clang_tidy %s misc-sizeof-expression %t
+
+class C {
+  int size() { return sizeof(this); }
+  // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: suspicious usage of 'sizeof(this)'
+};
+
+#define LEN 8
+
+int X;
+extern int A[10];
+extern short B[10];
+
+#pragma pack(1)
+struct  S { char a, b, c; };
+
+int Test1(const char* ptr) {
+  int sum = 0;
+  sum += sizeof(LEN);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(K)'
+  sum += sizeof(LEN + 1);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(K)'
+  sum += sizeof(sum, LEN);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(..., ...)'
+  sum += sizeof(sizeof(X));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
+  sum += sizeof(LEN + sizeof(X));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
+  sum += sizeof(LEN + LEN + sizeof(X));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
+  sum += sizeof(LEN + (LEN + sizeof(X)));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
+  sum += sizeof(LEN + -sizeof(X));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
+  sum += sizeof(LEN + - + -sizeof(X));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(sizeof(...))'
+  sum += sizeof(char) / sizeof(char);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T)/sizeof(T)'
+  sum += sizeof(A) / sizeof(S);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  sum += sizeof(char) / sizeof(int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  sum += sizeof(char) / sizeof(A);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  sum += sizeof(B[0]) / sizeof(A);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of 'sizeof(...)/sizeof(...)'; numerator is not a multiple of denominator
+  sum += sizeof(ptr) / sizeof(char);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  sum += sizeof(ptr) / sizeof(ptr[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  sum += sizeof(ptr) / sizeof(char*);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  sum += sizeof(ptr) / sizeof(void*);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  sum += sizeof(ptr) / sizeof(const void volatile*);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(P*)/sizeof(Q*)'
+  sum += sizeof(ptr) / sizeof(char);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  sum += sizeof(ptr) / sizeof(ptr[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious usage of sizeof pointer 'sizeof(T*)/sizeof(T)'
+  sum += sizeof(int) * sizeof(char);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious 'sizeof' by 'sizeof' multiplication
+  sum += sizeof(ptr) * sizeof(ptr[0]);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious 'sizeof' by 'sizeof' multiplication
+  sum += sizeof(int) * (2 * sizeof(char));
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious 'sizeof' by 'sizeof' multiplication
+  sum += (2 * sizeof(char)) * sizeof(int);
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: suspicious 'sizeof' by 'sizeof' multiplication
+  if (sizeof(A) < 0x10) sum += 42;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: suspicious comparison of 'sizeof(expr)' to a constant 
+  if (sizeof(A) <= 0xFFFEU) sum += 42;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: suspicious comparison of 'sizeof(expr)' to a constant 
+  return sum;
+}
+
+typedef char MyChar;
+typedef const MyChar MyConstChar;
+
+int CE0 = sizeof sizeof(char);
+// CHECK-MESSAGES: :[[@LINE-1]]

[PATCH] D19071: [OpenCL] Add predefined macros.

2016-04-13 Thread Yaxun Liu via cfe-commits
yaxunl created this revision.
yaxunl added reviewers: Anastasia, bader, pxli168.
yaxunl added subscribers: tstellarAMD, cfe-commits.

OpenCL spec 1.2/2.0 requires `__OPENCL_C_VERSION__` to be defined based on 
-cl-std option. This patch implements that.

OpenCL spec 1.0/1.1 does not have a predefined macro to indicate the language 
version with which the program is compiled. Since a shared OpenCL header file 
needs that, `__CLANG_OPENCL_C_VERSION__` is defined.

Note all OpenCL versions requires macro __OPENCL_VERSION__ to be defined. 
However it is to indicate OpenCL version supported by the device, which is not 
necessarily the language version with which the program is compiled. E.g. an 
OpenCL 2.0 device may compile a program with either -cl-std=CL1.2 or CL2.0. 
`__OPENCL_VERSION__` needs to be defined by the host program when invoking the 
compiler based on the OpenCL version supported by the device.

The same with other device dependent macros.

The patch also defines __FAST_RELAXED_MATH__ based on -cl-fast-relaxed-math 
option.

http://reviews.llvm.org/D19071

Files:
  lib/Frontend/InitPreprocessor.cpp
  test/Preprocessor/predefined-macros.c

Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-macros.c
+++ test/Preprocessor/predefined-macros.c
@@ -146,3 +146,30 @@
 // CHECK-SYNC_CAS_MIPS: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 1
 // CHECK-SYNC_CAS_MIPS32-NOT: __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 // CHECK-SYNC_CAS_MIPS64: #define __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 1
+
+// RUN: %clang_cc1 %s -E -dM -o - -x cl \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL10
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.1 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL11
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL1.2 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL12
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-std=CL2.0 \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-CL20
+// RUN: %clang_cc1 %s -E -dM -o - -x cl -cl-fast-relaxed-math \
+// RUN:   | FileCheck -match-full-lines %s --check-prefix=CHECK-FRM
+// CHECK-CL10: #define CL_VERSION_1_0 100
+// CHECK-CL10: #define __CLANG_OPENCL_C_VERSION__ 100
+// CHECK-CL11: #define CL_VERSION_1_0 100
+// CHECK-CL11: #define CL_VERSION_1_1 110
+// CHECK-CL11: #define __CLANG_OPENCL_C_VERSION__ 110
+// CHECK-CL12: #define CL_VERSION_1_0 100
+// CHECK-CL12: #define CL_VERSION_1_1 110
+// CHECK-CL12: #define CL_VERSION_1_2 120
+// CHECK-CL12: #define __OPENCL_C_VERSION__ 120
+// CHECK-CL20: #define CL_VERSION_1_0 100
+// CHECK-CL20: #define CL_VERSION_1_1 110
+// CHECK-CL20: #define CL_VERSION_1_2 120
+// CHECK-CL20: #define CL_VERSION_2_0 200
+// CHECK-CL20: #define __OPENCL_C_VERSION__ 200
+// CHECK-FRM: #define __FAST_RELAXED_MATH__ 1
+
Index: lib/Frontend/InitPreprocessor.cpp
===
--- lib/Frontend/InitPreprocessor.cpp
+++ lib/Frontend/InitPreprocessor.cpp
@@ -408,6 +408,43 @@
   if (LangOpts.ObjC1)
 Builder.defineMacro("__OBJC__");
 
+  // OpenCL v1.0/1.1 s6.9, v1.2/2.0 s6.10: Preprocessor Directives and Macros.
+  if (LangOpts.OpenCL) {
+// OpenCL v1.0 and v1.1 do not have a predefined macro to indicate the
+// language standard with which the program is compiled. __OPENCL_VERSION__
+// is for the OpenCL version supported by the OpenCL device, which is not
+// necessarily the language standard with which the program is compiled.
+// A shared OpenCL header file requires a macro to indicate the language
+// standard. As a workaround, __CLANG_OPENCL_C_VERSION__ is defined for
+// OpenCL v1.0 and v1.1.
+switch (LangOpts.OpenCLVersion) {
+case 0:
+case 100:
+  Builder.defineMacro("__CLANG_OPENCL_C_VERSION__", "100");
+  break;
+case 110:
+  Builder.defineMacro("__CLANG_OPENCL_C_VERSION__", "110");
+  break;
+case 120:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "120");
+  break;
+case 200:
+  Builder.defineMacro("__OPENCL_C_VERSION__", "200");
+  break;
+default:
+  llvm_unreachable("Unsupported OpenCL version");
+}
+Builder.defineMacro("CL_VERSION_1_0", "100");
+if (LangOpts.OpenCLVersion >= 110)
+  Builder.defineMacro("CL_VERSION_1_1", "110");
+if (LangOpts.OpenCLVersion >= 120)
+  Builder.defineMacro("CL_VERSION_1_2", "120");
+if (LangOpts.OpenCLVersion >= 200)
+  Builder.defineMacro("CL_VERSION_2_0", "200");
+
+if (LangOpts.FastRelaxedMath)
+  Builder.defineMacro("__FAST_RELAXED_MATH__");
+  }
   // Not "standard" per se, but available even with the -undef flag.
   if (LangOpts.AsmPreprocessor)
 Builder.defineMacro("__ASSEMBLER__");


Index: test/Preprocessor/predefined-macros.c
===
--- test/Preprocessor/predefined-mac

Re: [PATCH] D14274: Add alloc_size attribute to clang

2016-04-13 Thread George Burgess IV via cfe-commits
george.burgess.iv updated this revision to Diff 53611.
george.burgess.iv added a comment.

Now that `allocsize` is in LLVM (r266032), this isn't blocked. Yay!

Rebased, added a few tests, did a few tiny refactors, and fixed an overflow bug 
when the user tried to allocate `2**63 < N < 2**64` bytes (because `CharUnits` 
uses an `int64_t` as storage).


http://reviews.llvm.org/D14274

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/AST/ExprConstant.cpp
  lib/CodeGen/CGCall.cpp
  lib/Sema/SemaDeclAttr.cpp
  test/CodeGen/alloc-size.c
  test/CodeGenCXX/global-init.cpp
  test/Sema/alloc-size.c
  test/SemaCXX/constant-expression-cxx11.cpp

Index: test/SemaCXX/constant-expression-cxx11.cpp
===
--- test/SemaCXX/constant-expression-cxx11.cpp
+++ test/SemaCXX/constant-expression-cxx11.cpp
@@ -1156,7 +1156,7 @@
 constexpr int m2b = const_cast(n2); // expected-error {{constant expression}} expected-note {{read of volatile object 'n2'}}
 
 struct T { int n; };
-const T t = { 42 }; // expected-note {{declared here}}
+const T t = { 42 };
 
 constexpr int f(volatile int &&r) {
   return r; // expected-note {{read of volatile-qualified type 'volatile int'}}
@@ -1168,7 +1168,7 @@
   int j : f(0); // expected-error {{constant expression}} expected-note {{in call to 'f(0)'}}
   int k : g(0); // expected-error {{constant expression}} expected-note {{temporary created here}} expected-note {{in call to 'g(0)'}}
   int l : n3; // expected-error {{constant expression}} expected-note {{read of non-const variable}}
-  int m : t.n; // expected-error {{constant expression}} expected-note {{read of non-constexpr variable}}
+  int m : t.n; // expected-warning{{width of bit-field 'm' (42 bits)}}
 };
 
 }
Index: test/Sema/alloc-size.c
===
--- /dev/null
+++ test/Sema/alloc-size.c
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 %s -verify
+
+void *fail1(int a) __attribute__((alloc_size)); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
+void *fail2(int a) __attribute__((alloc_size())); //expected-error{{'alloc_size' attribute takes at least 1 argument}}
+
+void *fail3(int a) __attribute__((alloc_size(0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail4(int a) __attribute__((alloc_size(2))); //expected-error{{'alloc_size' attribute parameter 2 is out of bounds}}
+
+void *fail5(int a, int b) __attribute__((alloc_size(0, 1))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail6(int a, int b) __attribute__((alloc_size(3, 1))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+
+void *fail7(int a, int b) __attribute__((alloc_size(1, 0))); //expected-error{{'alloc_size' attribute parameter 0 is out of bounds}}
+void *fail8(int a, int b) __attribute__((alloc_size(1, 3))); //expected-error{{'alloc_size' attribute parameter 3 is out of bounds}}
+
+int fail9(int a) __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to return values that are pointers}}
+
+int fail10 __attribute__((alloc_size(1))); //expected-warning{{'alloc_size' attribute only applies to non-K&R-style functions}}
+
+void *fail11(void *a) __attribute__((alloc_size(1))); //expected-error{{'alloc_size' attribute argument may only refer to a function parameter of integer type}}
+
+void *fail12(int a) __attribute__((alloc_size("abc"))); //expected-error{{'alloc_size' attribute requires parameter 1 to be an integer constant}}
+void *fail12(int a) __attribute__((alloc_size(1, "abc"))); //expected-error{{'alloc_size' attribute requires parameter 2 to be an integer constant}}
+void *fail13(int a) __attribute__((alloc_size(1U<<31))); //expected-error{{integer constant expression evaluates to value 2147483648 that cannot be represented in a 32-bit signed integer type}}
Index: test/CodeGenCXX/global-init.cpp
===
--- test/CodeGenCXX/global-init.cpp
+++ test/CodeGenCXX/global-init.cpp
@@ -18,9 +18,6 @@
 // CHECK: @__dso_handle = external global i8
 // CHECK: @c = global %struct.C zeroinitializer, align 8
 
-// It's okay if we ever implement the IR-generation optimization to remove this.
-// CHECK: @_ZN5test3L3varE = internal constant i8* getelementptr inbounds ([7 x i8], [7 x i8]* 
-
 // PR6205: The casts should not require global initializers
 // CHECK: @_ZN6PR59741cE = external global %"struct.PR5974::C"
 // CHECK: @_ZN6PR59741aE = global %"struct.PR5974::A"* getelementptr inbounds (%"struct.PR5974::C", %"struct.PR5974::C"* @_ZN6PR59741cE, i32 0, i32 0)
Index: test/CodeGen/alloc-size.c
===
--- /dev/null
+++ test/CodeGen/alloc-size.c
@@ -0,0 +1,370 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin -emit-llvm %s -o - 2>&1 | FileCheck %

r266242 - Make sure CheckDestructor gets called on dllimported classes if the vtable is used (PR27319)

2016-04-13 Thread Hans Wennborg via cfe-commits
Author: hans
Date: Wed Apr 13 15:21:15 2016
New Revision: 266242

URL: http://llvm.org/viewvc/llvm-project?rev=266242&view=rev
Log:
Make sure CheckDestructor gets called on dllimported classes if the vtable is 
used (PR27319)

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/CodeGenCXX/dllimport.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=266242&r1=266241&r2=266242&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Apr 13 15:21:15 2016
@@ -13314,13 +13314,20 @@ void Sema::MarkVTableUsed(SourceLocation
 // the deleting destructor is emitted with the vtable, not with the
 // destructor definition as in the Itanium ABI.
 // If it has a definition, we do the check at that point instead.
-if (Context.getTargetInfo().getCXXABI().isMicrosoft() &&
-Class->hasUserDeclaredDestructor() &&
-!Class->getDestructor()->isDefined() &&
-!Class->getDestructor()->isDeleted()) {
-  CXXDestructorDecl *DD = Class->getDestructor();
-  ContextRAII SavedContext(*this, DD);
-  CheckDestructor(DD);
+if (Context.getTargetInfo().getCXXABI().isMicrosoft()) {
+  if (Class->hasUserDeclaredDestructor() &&
+  !Class->getDestructor()->isDefined() &&
+  !Class->getDestructor()->isDeleted()) {
+CXXDestructorDecl *DD = Class->getDestructor();
+ContextRAII SavedContext(*this, DD);
+CheckDestructor(DD);
+  } else if (Class->hasAttr()) {
+// We always synthesize vtables on the import side. To make sure
+// CheckDestructor gets called, mark the destructor referenced.
+assert(Class->getDestructor() &&
+   "The destructor has always been declared on a dllimport class");
+MarkFunctionReferenced(Loc, Class->getDestructor());
+  }
 }
   }
 

Modified: cfe/trunk/test/CodeGenCXX/dllimport.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/dllimport.cpp?rev=266242&r1=266241&r2=266242&view=diff
==
--- cfe/trunk/test/CodeGenCXX/dllimport.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/dllimport.cpp Wed Apr 13 15:21:15 2016
@@ -743,6 +743,17 @@ namespace PR21366 {
   inline void S::outOfClassInlineMethod() {}
 }
 
+namespace PR27319 {
+  // Make sure we don't assert due to not having checked for operator delete on
+  // the destructor.
+  template  struct A {
+virtual ~A() = default;
+  };
+  extern template struct __declspec(dllimport) A;
+  void f() { new A(); }
+  // MO1-DAG: @"\01??_S?$A@H@PR27319@@6B@" = linkonce_odr unnamed_addr 
constant [1 x i8*]
+}
+
 // MS ignores DLL attributes on partial specializations.
 template  struct PartiallySpecializedClassTemplate {};
 template  struct __declspec(dllimport) 
PartiallySpecializedClassTemplate { void f(); };


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


Re: [PATCH] D19063: clang-format: Fixed line merging of more than two lines

2016-04-13 Thread Maxime Beaulieu via cfe-commits
mxbOctasic added inline comments.


Comment at: unittests/Format/FormatTest.cpp:285
@@ +284,3 @@
+
+  EXPECT_EQ("class Foo\n"
+"{\n"

djasper wrote:
> How does this break? I generally add an Before and After of one of the test 
> cases into my patch descriptions.
This is a fun one.

The newline between `Foo() {}` and `void Funk() {}` is removed.
This is a combination of the line merge problem and 
`KeepEmptyLinesAtTheStartOfBlocks`.

`Last` on the merged line for `Foo() {}` points to `{` instead of `}`, so the 
newline before `void` is seen as a newline at the start of a block. (Checks 
`PreviousLine->Last->is(tok::l_brace)`)


http://reviews.llvm.org/D19063



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


  1   2   >