[libcxxabi] r268477 - libc++abi: fix visibility of personalities

2016-05-03 Thread Saleem Abdulrasool via cfe-commits
Author: compnerd
Date: Tue May  3 23:22:29 2016
New Revision: 268477

URL: http://llvm.org/viewvc/llvm-project?rev=268477=rev
Log:
libc++abi: fix visibility of personalities

The personality routines need to be exposed to the users as the functions
reference the personality routine to handle exceptions.

Modified:
libcxxabi/trunk/src/cxa_personality.cpp

Modified: libcxxabi/trunk/src/cxa_personality.cpp
URL: 
http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_personality.cpp?rev=268477=268476=268477=diff
==
--- libcxxabi/trunk/src/cxa_personality.cpp (original)
+++ libcxxabi/trunk/src/cxa_personality.cpp Tue May  3 23:22:29 2016
@@ -17,6 +17,7 @@
 #include 
 #include 
 
+#include "__cxxabi_config.h"
 #include "config.h"
 #include "cxa_exception.hpp"
 #include "cxa_handlers.hpp"
@@ -928,7 +929,7 @@ _UA_CLEANUP_PHASE
 */
 
 #if !LIBCXXABI_ARM_EHABI
-_Unwind_Reason_Code
+_LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
 #ifdef __USING_SJLJ_EXCEPTIONS__
 __gxx_personality_sj0
 #else
@@ -1059,7 +1060,7 @@ static void load_results_from_barrier_ca
 results.ttypeIndex = 
(int64_t)(int32_t)unwind_exception->barrier_cache.bitpattern[4];
 }
 
-extern "C" _Unwind_Reason_Code
+extern "C" _LIBCXXABI_FUNC_VIS _Unwind_Reason_Code
 __gxx_personality_v0(_Unwind_State state,
  _Unwind_Exception* unwind_exception,
  _Unwind_Context* context)


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


Re: [PATCH] D18815: [ObjC] Enter a new evaluation context before calling BuildBlockForLambdaConversion.

2016-05-03 Thread Akira Hatanaka via cfe-commits
ahatanak added reviewers: manmanren, doug.gregor, rjmccall.
ahatanak updated this revision to Diff 56092.
ahatanak added a comment.

Rebase and add reviewers.


http://reviews.llvm.org/D18815

Files:
  lib/Sema/SemaExprCXX.cpp
  test/SemaObjCXX/block-cleanup.mm

Index: test/SemaObjCXX/block-cleanup.mm
===
--- /dev/null
+++ test/SemaObjCXX/block-cleanup.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o 
/dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys 
count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6229,9 +6229,12 @@
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;


Index: test/SemaObjCXX/block-cleanup.mm
===
--- /dev/null
+++ test/SemaObjCXX/block-cleanup.mm
@@ -0,0 +1,16 @@
+// RUN: %clang_cc1 -triple x86_64-apple-macosx10.11.0 -std=gnu++11 -o /dev/null -x objective-c++ -fblocks -ast-dump %s 2>&1 | FileCheck %s
+
+// CHECK:  -FunctionDecl {{.*}} test 'id (void)'
+// CHECK-NEXT:   -CompoundStmt
+// CHECK-NEXT: -ReturnStmt
+// CHECK-NEXT:   -ExprWithCleanups
+// CHECK-NEXT: -cleanup Block
+// CHECK-NEXT: -cleanup Block
+
+@interface NSDictionary
++ (id)dictionaryWithObjects:(const id [])objects forKeys:(const id [])keys count:(unsigned long)cnt;
+@end
+
+id test() {
+  return @{@"a": [](){}, @"b": [](){}};
+}
Index: lib/Sema/SemaExprCXX.cpp
===
--- lib/Sema/SemaExprCXX.cpp
+++ lib/Sema/SemaExprCXX.cpp
@@ -6229,9 +6229,12 @@
   // follows the normal lifetime rules for block literals instead of being
   // autoreleased.
   DiagnosticErrorTrap Trap(Diags);
+  PushExpressionEvaluationContext(PotentiallyEvaluated);
   ExprResult Exp = BuildBlockForLambdaConversion(E->getExprLoc(),
  E->getExprLoc(),
  Method, E);
+  PopExpressionEvaluationContext();
+
   if (Exp.isInvalid())
 Diag(E->getExprLoc(), diag::note_lambda_to_block_conv);
   return Exp;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19536: [CodeGenObjCXX] Fix handling of blocks in lambda

2016-05-03 Thread Akira Hatanaka via cfe-commits
ahatanak updated this revision to Diff 56090.
ahatanak added a comment.

Apply John's patch with a few modifications.

I had to special case __block variables and remove the line creating a load 
from a reference to fix the failing regression tests.


http://reviews.llvm.org/D19536

Files:
  lib/CodeGen/CGBlocks.cpp
  test/CodeGenObjCXX/block-nested-in-lambda.cpp

Index: test/CodeGenObjCXX/block-nested-in-lambda.cpp
===
--- /dev/null
+++ test/CodeGenObjCXX/block-nested-in-lambda.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -triple=x86_64-apple-darwin10 -emit-llvm -std=c++11 -fblocks -o - %s | FileCheck %s
+
+// CHECK: %[[BLOCK_CAPTURED0:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK:.*]], i32 0, i32 5
+// CHECK: %[[V0:.*]] = getelementptr inbounds %[[LAMBDA_CLASS:.*]], %[[LAMBDA_CLASS]]* %[[THIS:.*]], i32 0, i32 0
+// CHECK: %[[V1:.*]] = load i32*, i32** %[[V0]], align 8
+// CHECK: store i32* %[[V1]], i32** %[[BLOCK_CAPTURED0]], align 8
+// CHECK: %[[BLOCK_CAPTURED1:.*]] = getelementptr inbounds <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>, <{ i8*, i32, i32, i8*, %struct.__block_descriptor*, i32*, i32* }>* %[[BLOCK]], i32 0, i32 6
+// CHECK: %[[V2:.*]] = getelementptr inbounds %[[LAMBDA_CLASS]], %[[LAMBDA_CLASS]]* %[[THIS]], i32 0, i32 1
+// CHECK: %[[V3:.*]] = load i32*, i32** %[[V2]], align 8
+// CHECK: store i32* %[[V3]], i32** %[[BLOCK_CAPTURED1]], align 8
+
+void foo1(int &, int &);
+
+void block_in_lambda(int , int ) {
+  auto lambda = [, ]() {
+auto block = ^{
+  foo1(s1, s2);
+};
+block();
+  };
+
+  lambda();
+}
Index: lib/CodeGen/CGBlocks.cpp
===
--- lib/CodeGen/CGBlocks.cpp
+++ lib/CodeGen/CGBlocks.cpp
@@ -14,6 +14,7 @@
 #include "CGBlocks.h"
 #include "CGDebugInfo.h"
 #include "CGObjCRuntime.h"
+#include "CGRecordLayout.h"
 #include "CodeGenFunction.h"
 #include "CodeGenModule.h"
 #include "clang/AST/DeclObjC.h"
@@ -775,35 +776,34 @@
 // Compute the address of the thing we're going to move into the
 // block literal.
 Address src = Address::invalid();
-if (BlockInfo && CI.isNested()) {
-  // We need to use the capture from the enclosing block.
-  const CGBlockInfo::Capture  =
-BlockInfo->getCapture(variable);
-
-  // This is a [[type]]*, except that a byref entry wil just be an i8**.
-  src = Builder.CreateStructGEP(LoadBlockStruct(),
-enclosingCapture.getIndex(),
-enclosingCapture.getOffset(),
-"block.capture.addr");
-} else if (blockDecl->isConversionFromLambda()) {
+
+if (blockDecl->isConversionFromLambda()) {
   // The lambda capture in a lambda's conversion-to-block-pointer is
   // special; we'll simply emit it directly.
   src = Address::invalid();
+} else if (CI.isByRef()) {
+   if (BlockInfo && CI.isNested()) {
+ // We need to use the capture from the enclosing block.
+ const CGBlockInfo::Capture  =
+ BlockInfo->getCapture(variable);
+
+ // This is a [[type]]*, except that a byref entry wil just be an i8**.
+ src = Builder.CreateStructGEP(LoadBlockStruct(),
+   enclosingCapture.getIndex(),
+   enclosingCapture.getOffset(),
+   "block.capture.addr");
+   } else {
+ auto I = LocalDeclMap.find(variable);
+ assert(I != LocalDeclMap.end());
+ src = I->second;
+   }
 } else {
-  // Just look it up in the locals map, which will give us back a
-  // [[type]]*.  If that doesn't work, do the more elaborate DRE
-  // emission.
-  auto it = LocalDeclMap.find(variable);
-  if (it != LocalDeclMap.end()) {
-src = it->second;
-  } else {
-DeclRefExpr declRef(
-const_cast(variable),
-/*RefersToEnclosingVariableOrCapture*/ CI.isNested(), type,
-VK_LValue, SourceLocation());
-src = EmitDeclRefLValue().getAddress();
-  }
-}
+  DeclRefExpr declRef(
+  const_cast(variable),
+  /*RefersToEnclosingVariableOrCapture*/ CI.isNested(),
+  type.getNonReferenceType(), VK_LValue, SourceLocation());
+  src = EmitDeclRefLValue().getAddress();
+};
 
 // For byrefs, we just write the pointer to the byref struct into
 // the block field.  There's no need to chase the forwarding
@@ -837,8 +837,7 @@
 
 // If it's a reference variable, copy the reference into the block field.
 } else if (type->isReferenceType()) {
-  llvm::Value *ref = Builder.CreateLoad(src, "ref.val");
-  Builder.CreateStore(ref, blockField);
+  

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

2016-05-03 Thread Etienne Bergeron via cfe-commits
etienneb added inline comments.


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

aaron.ballman wrote:
> Perhaps we can adjust the `hasSize()` matcher instead? It currently works 
> with ConstantArrayType, but it seems reasonable for it to also work with 
> StringLiteral.
I didn't like the term "size" as it typically refer to the size in bytes.
Which is not the same for a wide-string.

Now, there is two different convention for naming matchers:
  hasLength   and  lengthIs  ?

Any toughs on that?




http://reviews.llvm.org/D19876



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


r268473 - [X86] Add -malign-double support

2016-05-03 Thread Reid Kleckner via cfe-commits
Author: rnk
Date: Tue May  3 21:58:24 2016
New Revision: 268473

URL: http://llvm.org/viewvc/llvm-project?rev=268473=rev
Log:
[X86] Add -malign-double support

The -malign-double flag causes i64 and f64 types to have alignment 8
instead of 4. On x86-64, the behavior of -malign-double is enabled by default.

Rebases and cleans phosek's work here: http://reviews.llvm.org/D12860

Patch by Sean Klein

Reviewers: rnk

Subscribers: rnk, jfb, dschuff, phosek

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

Added:
cfe/trunk/test/CodeGen/malign-double.cpp
Modified:
cfe/trunk/include/clang/Basic/LangOptions.def
cfe/trunk/include/clang/Driver/Options.td
cfe/trunk/lib/Basic/TargetInfo.cpp
cfe/trunk/lib/Frontend/CompilerInvocation.cpp

Modified: cfe/trunk/include/clang/Basic/LangOptions.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/LangOptions.def?rev=268473=268472=268473=diff
==
--- cfe/trunk/include/clang/Basic/LangOptions.def (original)
+++ cfe/trunk/include/clang/Basic/LangOptions.def Tue May  3 21:58:24 2016
@@ -156,6 +156,7 @@ VALUE_LANGOPT(PackStruct  , 32, 0,
   "default struct packing maximum alignment")
 VALUE_LANGOPT(MaxTypeAlign  , 32, 0,
   "default maximum alignment for types")
+VALUE_LANGOPT(AlignDouble, 1, 0, "Controls if doubles should be 
aligned to 8 bytes (x86 only)")
 COMPATIBLE_VALUE_LANGOPT(PICLevel, 2, 0, "__PIC__ level")
 COMPATIBLE_VALUE_LANGOPT(PIELevel, 2, 0, "__PIE__ level")
 COMPATIBLE_LANGOPT(GNUInline , 1, 0, "GNU inline semantics")

Modified: cfe/trunk/include/clang/Driver/Options.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Options.td?rev=268473=268472=268473=diff
==
--- cfe/trunk/include/clang/Driver/Options.td (original)
+++ cfe/trunk/include/clang/Driver/Options.td Tue May  3 21:58:24 2016
@@ -1320,6 +1320,8 @@ def mfix_and_continue : Flag<["-"], "mfi
 def mieee_fp : Flag<["-"], "mieee-fp">, Group;
 def minline_all_stringops : Flag<["-"], "minline-all-stringops">, 
Group;
 def mno_inline_all_stringops : Flag<["-"], "mno-inline-all-stringops">, 
Group;
+def malign_double : Flag<["-"], "malign-double">, Group, 
Flags<[CC1Option]>,
+  HelpText<"Align doubles to two words in structs (x86 only)">;
 def mfloat_abi_EQ : Joined<["-"], "mfloat-abi=">, Group;
 def mfpmath_EQ : Joined<["-"], "mfpmath=">, Group;
 def mfpu_EQ : Joined<["-"], "mfpu=">, Group;

Modified: cfe/trunk/lib/Basic/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/TargetInfo.cpp?rev=268473=268472=268473=diff
==
--- cfe/trunk/lib/Basic/TargetInfo.cpp (original)
+++ cfe/trunk/lib/Basic/TargetInfo.cpp Tue May  3 21:58:24 2016
@@ -275,6 +275,10 @@ void TargetInfo::adjust(const LangOption
 UseBitFieldTypeAlignment = false;
   if (Opts.ShortWChar)
 WCharType = UnsignedShort;
+  if (Opts.AlignDouble) {
+DoubleAlign = LongLongAlign = 64;
+LongDoubleAlign = 64;
+  }
 
   if (Opts.OpenCL) {
 // OpenCL C requires specific widths for types, irrespective of

Modified: cfe/trunk/lib/Frontend/CompilerInvocation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInvocation.cpp?rev=268473=268472=268473=diff
==
--- cfe/trunk/lib/Frontend/CompilerInvocation.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInvocation.cpp Tue May  3 21:58:24 2016
@@ -1758,6 +1758,7 @@ static void ParseLangArgs(LangOptions 
   Opts.EmitAllDecls = Args.hasArg(OPT_femit_all_decls);
   Opts.PackStruct = getLastArgIntValue(Args, OPT_fpack_struct_EQ, 0, Diags);
   Opts.MaxTypeAlign = getLastArgIntValue(Args, OPT_fmax_type_align_EQ, 0, 
Diags);
+  Opts.AlignDouble = Args.hasArg(OPT_malign_double);
   Opts.PICLevel = getLastArgIntValue(Args, OPT_pic_level, 0, Diags);
   Opts.PIELevel = getLastArgIntValue(Args, OPT_pie_level, 0, Diags);
   Opts.Static = Args.hasArg(OPT_static_define);

Added: cfe/trunk/test/CodeGen/malign-double.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/malign-double.cpp?rev=268473=auto
==
--- cfe/trunk/test/CodeGen/malign-double.cpp (added)
+++ cfe/trunk/test/CodeGen/malign-double.cpp Tue May  3 21:58:24 2016
@@ -0,0 +1,115 @@
+// RUN: %clang_cc1 -malign-double -triple i386-unknown-linux -emit-llvm %s -o 
- \
+// RUN:   | FileCheck --check-prefix=CHECK-ON --check-prefix=CHECK %s
+
+// RUN: %clang_cc1 -triple i386-unknown-linux -emit-llvm %s -o - \
+// RUN:   | FileCheck --check-prefix=CHECK-OFF --check-prefix=CHECK %s
+
+/* Structs S1, S2, S3, S4, and union U5 are taken from Intel, "IA-64
+   Software Conventions and Runtime Architecture 

r268471 - Fix CodeCompletion & TypoCorrection when combining a PCH with Modules

2016-05-03 Thread Ben Langmuir via cfe-commits
Author: benlangmuir
Date: Tue May  3 19:53:13 2016
New Revision: 268471

URL: http://llvm.org/viewvc/llvm-project?rev=268471=rev
Log:
Fix CodeCompletion & TypoCorrection when combining a PCH with Modules

This commit fixes the IdentifierIterator to actually include identifiers
from a PCH or precompiled preamble when there is also a global module
index. This was causing code-completion (outside of C++) and
typo-correction to be missing global identifiers defined in the
PCH/preamble. Typo-correction has been broken since we first started
using the module index, whereas code-completion only started relying on
identifier iterator in r232793.

rdar://problem/25642879

Added:
cfe/trunk/test/CodeCompletion/Inputs/ModuleA/
cfe/trunk/test/CodeCompletion/Inputs/ModuleA/module.modulemap
cfe/trunk/test/CodeCompletion/Inputs/ModuleA/moduleA.h
cfe/trunk/test/CodeCompletion/Inputs/import_moduleA.h
cfe/trunk/test/CodeCompletion/pch-and-module.m
cfe/trunk/test/Modules/Inputs/typo.h
cfe/trunk/test/Modules/typo.m
Modified:
cfe/trunk/lib/Serialization/ASTReader.cpp
cfe/trunk/test/Modules/Inputs/module.map

Modified: cfe/trunk/lib/Serialization/ASTReader.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Serialization/ASTReader.cpp?rev=268471=268470=268471=diff
==
--- cfe/trunk/lib/Serialization/ASTReader.cpp (original)
+++ cfe/trunk/lib/Serialization/ASTReader.cpp Tue May  3 19:53:13 2016
@@ -7014,19 +7014,20 @@ namespace clang {
 /// the current AST file.
 ASTIdentifierLookupTable::key_iterator End;
 
+/// \brief Whether to skip any modules in the ASTReader.
+bool SkipModules;
+
   public:
-explicit ASTIdentifierIterator(const ASTReader );
+explicit ASTIdentifierIterator(const ASTReader ,
+   bool SkipModules = false);
 
 StringRef Next() override;
   };
 }
 
-ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader )
-  : Reader(Reader), Index(Reader.ModuleMgr.size() - 1) {
-  ASTIdentifierLookupTable *IdTable
-= (ASTIdentifierLookupTable 
*)Reader.ModuleMgr[Index].IdentifierLookupTable;
-  Current = IdTable->key_begin();
-  End = IdTable->key_end();
+ASTIdentifierIterator::ASTIdentifierIterator(const ASTReader ,
+ bool SkipModules)
+: Reader(Reader), Index(Reader.ModuleMgr.size()), SkipModules(SkipModules) 
{
 }
 
 StringRef ASTIdentifierIterator::Next() {
@@ -7036,9 +7037,12 @@ StringRef ASTIdentifierIterator::Next()
   return StringRef();
 
 --Index;
-ASTIdentifierLookupTable *IdTable
-  = (ASTIdentifierLookupTable *)Reader.ModuleMgr[Index].
-IdentifierLookupTable;
+ModuleFile  = Reader.ModuleMgr[Index];
+if (SkipModules && F.isModule())
+  continue;
+
+ASTIdentifierLookupTable *IdTable =
+(ASTIdentifierLookupTable *)F.IdentifierLookupTable;
 Current = IdTable->key_begin();
 End = IdTable->key_end();
   }
@@ -7050,9 +7054,42 @@ StringRef ASTIdentifierIterator::Next()
   return Result;
 }
 
+namespace {
+/// A utility for appending two IdentifierIterators.
+class ChainedIdentifierIterator : public IdentifierIterator {
+  std::unique_ptr Current;
+  std::unique_ptr Queued;
+
+public:
+  ChainedIdentifierIterator(std::unique_ptr First,
+std::unique_ptr Second)
+  : Current(std::move(First)), Queued(std::move(Second)) {}
+
+  StringRef Next() override {
+if (!Current)
+  return StringRef();
+
+StringRef result = Current->Next();
+if (!result.empty())
+  return result;
+
+// Try the queued iterator, which may itself be empty.
+Current.reset();
+std::swap(Current, Queued);
+return Next();
+  }
+};
+} // end anonymous namespace.
+
 IdentifierIterator *ASTReader::getIdentifiers() {
-  if (!loadGlobalIndex())
-return GlobalIndex->createIdentifierIterator();
+  if (!loadGlobalIndex()) {
+std::unique_ptr ReaderIter(
+new ASTIdentifierIterator(*this, /*SkipModules=*/true));
+std::unique_ptr ModulesIter(
+GlobalIndex->createIdentifierIterator());
+return new ChainedIdentifierIterator(std::move(ReaderIter),
+ std::move(ModulesIter));
+  }
 
   return new ASTIdentifierIterator(*this);
 }

Added: cfe/trunk/test/CodeCompletion/Inputs/ModuleA/module.modulemap
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeCompletion/Inputs/ModuleA/module.modulemap?rev=268471=auto
==
--- cfe/trunk/test/CodeCompletion/Inputs/ModuleA/module.modulemap (added)
+++ cfe/trunk/test/CodeCompletion/Inputs/ModuleA/module.modulemap Tue May  3 
19:53:13 2016
@@ -0,0 +1,4 @@
+module ModuleA {
+  header "moduleA.h"
+  export *
+}

Added: cfe/trunk/test/CodeCompletion/Inputs/ModuleA/moduleA.h
URL: 

Re: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-03 Thread Paul Robinson via cfe-commits
probinson updated this revision to Diff 56079.
probinson marked an inline comment as done.
probinson added a comment.

Correct the attribute condition, and refine the Objective-C test.


http://reviews.llvm.org/D19754

Files:
  include/clang/Basic/Attr.td
  include/clang/Basic/AttrDocs.td
  lib/CodeGen/CGDebugInfo.cpp
  test/CodeGenCXX/debug-info-nodebug.cpp
  test/CodeGenObjC/debug-info-nodebug.m
  test/Sema/attr-nodebug.c

Index: test/Sema/attr-nodebug.c
===
--- test/Sema/attr-nodebug.c
+++ test/Sema/attr-nodebug.c
@@ -2,8 +2,8 @@
 
 int a __attribute__((nodebug));
 
-void b() {
-  int b __attribute__((nodebug)); // expected-warning {{'nodebug' attribute only applies to functions and global variables}}
+void b(int p __attribute__((nodebug))) { // expected-warning {{'nodebug' attribute only applies to variables and functions}}
+  int b __attribute__((nodebug));
 }
 
 void t1() __attribute__((nodebug));
Index: test/CodeGenObjC/debug-info-nodebug.m
===
--- test/CodeGenObjC/debug-info-nodebug.m
+++ test/CodeGenObjC/debug-info-nodebug.m
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -triple arm-apple-ios -emit-llvm -debug-info-kind=limited -fblocks  %s -o - | FileCheck %s
+// Objective-C code cargo-culted from debug-info-lifetime-crash.m.
+@protocol NSObject
+- (id)copy;
+@end
+@class W;
+@interface View1
+@end
+@implementation Controller {
+void (^Block)(void);
+}
+- (void)View:(View1 *)View foo:(W *)W
+{
+  // The reference from inside the block implicitly creates another
+  // local variable for the referenced member. That is what gets
+  // suppressed by the attribute.  It still gets debug info as a
+  // member, though.
+  // CHECK-NOT: !DILocalVariable(name: "weakSelf"
+  // CHECK: !DIDerivedType({{.*}} name: "weakSelf"
+  // CHECK-NOT: !DILocalVariable(name: "weakSelf"
+  __attribute__((nodebug)) __typeof(self) weakSelf = self;
+  Block = [^{
+__typeof(self) strongSelf = weakSelf;
+} copy];
+}
+@end
Index: test/CodeGenCXX/debug-info-nodebug.cpp
===
--- test/CodeGenCXX/debug-info-nodebug.cpp
+++ test/CodeGenCXX/debug-info-nodebug.cpp
@@ -44,9 +44,15 @@
 // YESINFO-DAG: !DIDerivedType({{.*}} name: "static_const_member"
 // NOINFO-NOT:  !DIDerivedType({{.*}} name: "static_const_member"
 
-// Function-local static variable.
+// Function-local static, const, and normal variables.
 void func4() {
   NODEBUG static int static_local = 6;
+  NODEBUG const  int const_local = 7;
+  NODEBUGint normal_local = 8;
 }
 // YESINFO-DAG: !DIGlobalVariable(name: "static_local"
 // NOINFO-NOT:  !DIGlobalVariable(name: "static_local"
+// YESINFO-DAG: !DILocalVariable(name: "const_local"
+// NOINFO-NOT:  !DILocalVariable(name: "const_local"
+// YESINFO-DAG: !DILocalVariable(name: "normal_local"
+// NOINFO-NOT:  !DILocalVariable(name: "normal_local"
Index: lib/CodeGen/CGDebugInfo.cpp
===
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -2974,6 +2974,8 @@
   CGBuilderTy ) {
   assert(DebugKind >= codegenoptions::LimitedDebugInfo);
   assert(!LexicalBlockStack.empty() && "Region stack mismatch, stack empty!");
+  if (VD->hasAttr())
+return;
 
   bool Unwritten =
   VD->isImplicit() || (isa(VD->getDeclContext()) &&
@@ -3118,6 +3120,8 @@
 
   if (Builder.GetInsertBlock() == nullptr)
 return;
+  if (VD->hasAttr())
+return;
 
   bool isByRef = VD->hasAttr();
 
Index: include/clang/Basic/AttrDocs.td
===
--- include/clang/Basic/AttrDocs.td
+++ include/clang/Basic/AttrDocs.td
@@ -498,8 +498,8 @@
   let Category = DocCatVariable;
   let Content = [{
 The ``nodebug`` attribute allows you to suppress debugging information for a
-function, or for a variable declared with static storage duration, such as
-globals, class static data members, and static locals.
+function or method, or for a variable that is not a parameter or a non-static
+data member.
   }];
 }
 
Index: include/clang/Basic/Attr.td
===
--- include/clang/Basic/Attr.td
+++ include/clang/Basic/Attr.td
@@ -82,6 +82,8 @@
 S->getKind() != Decl::ImplicitParam &&
 S->getKind() != Decl::ParmVar &&
 S->getKind() != Decl::NonTypeTemplateParm}]>;
+def NonParmVar : SubsetSubjectgetKind() != Decl::ParmVar}]>;
 def NonBitField : SubsetSubjectisBitField()}]>;
 
@@ -973,8 +975,8 @@
 
 def NoDebug : InheritableAttr {
   let Spellings = [GCC<"nodebug">];
-  let Subjects = SubjectList<[FunctionLike, ObjCMethod, GlobalVar], WarnDiag,
-   

Re: [PATCH] D19754: Allow 'nodebug' on local variables

2016-05-03 Thread Paul Robinson via cfe-commits
probinson marked 2 inline comments as done.


Comment at: include/clang/Basic/Attr.td:86-88
@@ -85,1 +85,5 @@
+def NonParmVar : SubsetSubjectgetKind() != Decl::ImplicitParam &&
+ S->getKind() != Decl::ParmVar &&
+ S->getKind() != Decl::NonTypeTemplateParm}]>;
 def NonBitField : SubsetSubject aaron.ballman wrote:
> > Can you add tests for each of these cases to ensure that the diagnostic 
> > fires on all of them?
> Actually not sure how to apply an attribute to an ImplicitParam
Well, this is all very exciting.  I tried 
```
template<__attribute__((nodebug)) int i> int t() { return i; }
int g() { return t<2>(); }
```
but got no diagnostic.  In fact. putting assert(false) in handleNoDebugAttr 
shows that it's never called.  Unsurprisingly, debug info for the template 
parameter still appears.
Maybe nobody has ever been so foolish as to try to put an attribute on a 
template parameter before?  (It is mildly disturbing that putting an attribute 
in an apparently impossible place yields no diagnostic and no semantic effect.)
I was obviously modeling this check on NormalVar, which (it turns out) is never 
used. And if you can't put attributes on template parameters or (it would seem 
likely) implicit parameters, then NonParmVar should check for nothing more than 
ParmVar.
And that's what I'll do.

(Marking as Done because the set of tests now matches the specified condition.)


Comment at: test/CodeGenCXX/debug-info-nodebug.cpp:50
@@ -49,1 +49,3 @@
   NODEBUG static int static_local = 6;
+  NODEBUG const  int const_local = 7;
+  NODEBUGint normal_local = 8;

dblaikie wrote:
> Doesn't look like the const case is any different from the non-const case, is 
> it?
Given a white-box analysis of the compiler internals, you are correct; this is 
in contrast to the static const/non-const handling, which *does* use different 
paths.
I am unwilling to trust that the const/non-const paths for locals will forever 
use the same path.  You could also look at it as "the test is the spec."


Comment at: test/CodeGenObjC/debug-info-nodebug.m:17
@@ +16,3 @@
+  // CHECK-NOT: !DILocalVariable(name: "strongSelf"
+  __attribute__((nodebug)) __typeof(self) weakSelf = self;
+  Block = [^{

dblaikie wrote:
> Is this case outside of the block interesting in some way? It doesn't look 
> like it.
The attribute on "weakSelf" is what triggers the second modified path in 
CGDebugInfo and suppresses the DILocalVariable for that name.
The attribute on "strongSelf" goes through the normal EmitDeclare path.  So in 
that sense, it is not interesting.

I should not have been so hesitant to work out what was going on here, sorry 
about that.  My cluelessness about Objective-C knows no bounds.
I'm changing the test to verify that the DILocalVariable does not appear, while 
the member info does still appear, and updating the comment to reflect this new 
knowledge.


http://reviews.llvm.org/D19754



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


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

2016-05-03 Thread Felix Berger via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268461: [clang-tidy] MoveConstructorInitCheck - Add 
parameter name to check message. (authored by flx).

Changed prior to commit:
  http://reviews.llvm.org/D19849?vs=55975=56076#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19849

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

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


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


[clang-tools-extra] r268461 - [clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

2016-05-03 Thread Felix Berger via cfe-commits
Author: flx
Date: Tue May  3 18:07:44 2016
New Revision: 268461

URL: http://llvm.org/viewvc/llvm-project?rev=268461=rev
Log:
[clang-tidy] MoveConstructorInitCheck - Add parameter name to check message.

Reviewers: alexfh

Subscribers: aaron.ballman, cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp?rev=268461=268460=268461=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp 
(original)
+++ clang-tools-extra/trunk/clang-tidy/misc/MoveConstructorInitCheck.cpp Tue 
May  3 18:07:44 2016
@@ -109,8 +109,9 @@ void MoveConstructorInitCheck::handlePar
   if (parmVarDeclRefExprOccurences(*MovableParam, *ConstructorDecl,
*Result.Context) > 1)
 return;
-  auto DiagOut =
-  diag(InitArg->getLocStart(), "value argument can be moved to avoid 
copy");
+  auto DiagOut = diag(InitArg->getLocStart(),
+  "value argument %0 can be moved to avoid copy")
+ << MovableParam;
   DiagOut << FixItHint::CreateReplacement(
   InitArg->getSourceRange(),
   (Twine("std::move(") + MovableParam->getName() + ")").str());

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp?rev=268461=268460=268461=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-constructor-init.cpp Tue 
May  3 18:07:44 2016
@@ -96,7 +96,7 @@ struct TriviallyCopyable {
 
 struct Positive {
   Positive(Movable M) : M_(M) {}
-  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument can be moved to 
avoid copy [misc-move-constructor-init]
+  // CHECK-MESSAGES: [[@LINE-1]]:28: warning: value argument 'M' can be moved 
to avoid copy [misc-move-constructor-init]
   // CHECK-FIXES: Positive(Movable M) : M_(std::move(M)) {}
   Movable M_;
 };


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


r268460 - [modules][debuginfo] Only include imported modules when targeting LLDB

2016-05-03 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue May  3 18:06:40 2016
New Revision: 268460

URL: http://llvm.org/viewvc/llvm-project?rev=268460=rev
Log:
[modules][debuginfo] Only include imported modules when targeting LLDB

These constructs are only applicable to a debugger capable of loading a
Clang AST, so omit them for brevity when not doing so.

We could potentially propagate more of CodeGenOptions through the
ObjectFilePCGContainerOperations for consistency (so the next person who
adds some CodeGenOpts feature that tweaks debug info output doesn't get
caught by this), so I'm open to objections/alternatives there, but went
with this for now.

Tested just a couple of basic cases (one direct, one indirect (through
the ObjectFilePCHContainerOperations) & fixed up other cases to pass the
-debugger-tuning flag as appropriate.

Modified:
cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c
cfe/trunk/test/Modules/DebugInfoTransitiveImport.m
cfe/trunk/test/Modules/debug-info-moduleimport.m
cfe/trunk/test/Modules/getSourceDescriptor-crash.cpp

Modified: cfe/trunk/lib/CodeGen/CGDebugInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDebugInfo.cpp?rev=268460=268459=268460=diff
==
--- cfe/trunk/lib/CodeGen/CGDebugInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDebugInfo.cpp Tue May  3 18:06:40 2016
@@ -3505,6 +3505,8 @@ void CGDebugInfo::EmitUsingDecl(const Us
 }
 
 void CGDebugInfo::EmitImportDecl(const ImportDecl ) {
+  if (CGM.getCodeGenOpts().getDebuggerTuning() != llvm::DebuggerKind::LLDB)
+return;
   if (Module *M = ID.getImportedModule()) {
 auto Info = ExternalASTSource::ASTSourceDescriptor(*M);
 DBuilder.createImportedDeclaration(

Modified: cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp?rev=268460=268459=268460=diff
==
--- cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp (original)
+++ cfe/trunk/lib/CodeGen/ObjectFilePCHContainerOperations.cpp Tue May  3 
18:06:40 2016
@@ -152,6 +152,7 @@ public:
 CodeGenOpts.ThreadModel = "single";
 CodeGenOpts.DebugTypeExtRefs = true;
 CodeGenOpts.setDebugInfo(codegenoptions::FullDebugInfo);
+CodeGenOpts.setDebuggerTuning(CI.getCodeGenOpts().getDebuggerTuning());
   }
 
   ~PCHContainerGenerator() override = default;

Modified: cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c?rev=268460=268459=268460=diff
==
--- cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c (original)
+++ cfe/trunk/test/Modules/DebugInfoSubmoduleImport.c Tue May  3 18:06:40 2016
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited 
-dwarf-ext-refs \
 // RUN: -fimplicit-module-maps -x c -fmodules-cache-path=%t -I %S/Inputs \
-// RUN: %s -emit-llvm -o - | FileCheck %s
+// RUN: %s -emit-llvm -debugger-tuning=lldb -o - | FileCheck %s
 #include "DebugSubmoduleA.h"
 #include "DebugSubmoduleB.h"
 

Modified: cfe/trunk/test/Modules/DebugInfoTransitiveImport.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/DebugInfoTransitiveImport.m?rev=268460=268459=268460=diff
==
--- cfe/trunk/test/Modules/DebugInfoTransitiveImport.m (original)
+++ cfe/trunk/test/Modules/DebugInfoTransitiveImport.m Tue May  3 18:06:40 2016
@@ -1,7 +1,7 @@
 // RUN: rm -rf %t
 // RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited 
-dwarf-ext-refs \
 // RUN: -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs \
-// RUN: %s -mllvm -debug-only=pchcontainer 2>&1 | FileCheck %s
+// RUN: %s -mllvm -debug-only=pchcontainer -debugger-tuning=lldb 2>&1 | 
FileCheck %s
 // REQUIRES: asserts
 
 @import diamond_left;
@@ -20,3 +20,9 @@
 // Skeleton for top:
 // CHECK: !DICompileUnit({{.*}}splitDebugFilename: 
{{.*}}diamond_top{{.*}}dwoId:
 
+// RUN: rm -rf %t
+// RUN: %clang_cc1 -fmodules -fmodule-format=obj -debug-info-kind=limited 
-dwarf-ext-refs \
+// RUN: -fimplicit-module-maps -fmodules-cache-path=%t -I %S/Inputs \
+// RUN: %s -mllvm -debug-only=pchcontainer 2>&1 | FileCheck %s 
--check-prefix=NOIMPORT
+
+// NOIMPORT-NOT: !DIImportedEntity

Modified: cfe/trunk/test/Modules/debug-info-moduleimport.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/debug-info-moduleimport.m?rev=268460=268459=268460=diff
==
--- cfe/trunk/test/Modules/debug-info-moduleimport.m (original)

[libcxx] r268459 - Update version numbers in docs

2016-05-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  3 17:50:33 2016
New Revision: 268459

URL: http://llvm.org/viewvc/llvm-project?rev=268459=rev
Log:
Update version numbers in docs

Modified:
libcxx/trunk/docs/conf.py

Modified: libcxx/trunk/docs/conf.py
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/conf.py?rev=268459=268458=268459=diff
==
--- libcxx/trunk/docs/conf.py (original)
+++ libcxx/trunk/docs/conf.py Tue May  3 17:50:33 2016
@@ -40,16 +40,16 @@ master_doc = 'index'
 
 # General information about the project.
 project = u'libc++'
-copyright = u'2011-2015, LLVM Project'
+copyright = u'2011-2016, LLVM Project'
 
 # The version info for the project you're documenting, acts as replacement for
 # |version| and |release|, also used in various other places throughout the
 # built documents.
 #
 # The short X.Y version.
-version = '3.8'
+version = '3.9'
 # The full version, including alpha/beta/rc tags.
-release = '3.8'
+release = '3.9'
 
 # The language for content autogenerated by Sphinx. Refer to documentation
 # for a list of supported languages.


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


[libcxx] r268456 - Add documentation for new experimental library

2016-05-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  3 17:32:08 2016
New Revision: 268456

URL: http://llvm.org/viewvc/llvm-project?rev=268456=rev
Log:
Add documentation for new experimental library

Modified:
libcxx/trunk/docs/BuildingLibcxx.rst
libcxx/trunk/docs/UsingLibcxx.rst

Modified: libcxx/trunk/docs/BuildingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/BuildingLibcxx.rst?rev=268456=268455=268456=diff
==
--- libcxx/trunk/docs/BuildingLibcxx.rst (original)
+++ libcxx/trunk/docs/BuildingLibcxx.rst Tue May  3 17:32:08 2016
@@ -6,6 +6,8 @@ Building libc++
 .. contents::
   :local:
 
+.. _build instructions:
+
 Getting Started
 ===
 
@@ -119,6 +121,18 @@ CMake docs or execute ``cmake --help-var
 libc++ specific options
 ---
 
+.. option:: LIBCXX_INSTALL_LIBRARY:BOOL
+
+  **Default**: ``ON``
+
+  Toggle the installation of the library portion of libc++.
+
+.. option:: LIBCXX_INSTALL_HEADERS:BOOL
+
+  **Default**: ``ON``
+
+  Toggle the installation of the libc++ headers.
+
 .. option:: LIBCXX_ENABLE_ASSERTIONS:BOOL
 
   **Default**: ``ON``
@@ -143,6 +157,25 @@ libc++ specific options
   Extra suffix to append to the directory where libraries are to be installed.
   This option overrides :option:`LLVM_LIBDIR_SUFFIX`.
 
+
+.. _libc++experimental options:
+
+libc++experimental Specific Options
+
+
+.. option:: LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY:BOOL
+
+  **Default**: ``ON``
+
+  Build and test libc++experimental.a.
+
+.. option:: LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY:BOOL
+
+  **Default**: ``OFF``
+
+  Install libc++experimental.a alongside libc++.
+
+
 .. _ABI Library Specific Options:
 
 ABI Library Specific Options

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=268456=268455=268456=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Tue May  3 17:32:08 2016
@@ -49,7 +49,30 @@ An example of using ``LD_LIBRARY_PATH``:
   $ export LD_LIBRARY_PATH=/lib
   $ ./a.out # Searches for libc++ along LD_LIBRARY_PATH
 
+Using libc++experimental and 
+=
 
+Libc++ provides implementations of experimental technical specifications
+in a separate library, ``libc++experimental.a``. Users of 

+headers may requiring linking with ``-lc++experimental``.
+
+.. code-block:: bash
+
+  $ clang++ -std=c++14 -stdlib=libc++ test.cpp -lc++experimental
+
+Libc++experimental.a may not always be available, even when libc++ is already
+installed. For information on building libc++experimental from source see
+:ref:`Building Libc++ ` and
+:ref:`libc++experimental CMake Options `.
+
+Also see the `Experimental Library Implementation Status 
`__
+page.
+
+.. warning::
+  Experimental libraries are Experimental.
+* The contents of the  headers and 
``libc++experimental.a``
+  library will not remain compatible between versions.
+* No guarantees of API or ABI stability are provided.
 
 Using libc++ on Linux
 =


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


[PATCH] D19891: [clang] [SystemZ] Add -mbackchain option.

2016-05-03 Thread Marcin Kościelnicki via cfe-commits
koriakin created this revision.
koriakin added reviewers: uweigand, rjmccall.
koriakin added a subscriber: cfe-commits.
koriakin set the repository for this revision to rL LLVM.
koriakin added a dependency: D19889: [SystemZ] Implement backchain attribute..

This option, like the corresponding gcc option, is SystemZ-specific and
enables storing frame backchain links, as specified in the ABI.

Depends on D19889.

Repository:
  rL LLVM

http://reviews.llvm.org/D19891

Files:
  include/clang/Driver/Options.td
  include/clang/Frontend/CodeGenOptions.def
  lib/CodeGen/CGCall.cpp
  lib/Driver/Tools.cpp
  lib/Frontend/CompilerInvocation.cpp
  test/CodeGen/mbackchain-2.c
  test/CodeGen/mbackchain-3.c
  test/CodeGen/mbackchain.c

Index: test/CodeGen/mbackchain.c
===
--- /dev/null
+++ test/CodeGen/mbackchain.c
@@ -0,0 +1,7 @@
+// RUN: %clang_cc1 -mbackchain -triple s390x-linux -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @foo() [[NUW:#[0-9]+]]
+void foo(void) {
+}
+
+// CHECK: attributes [[NUW]] = { {{.*}} "backchain" {{.*}} }
Index: test/CodeGen/mbackchain-3.c
===
--- /dev/null
+++ test/CodeGen/mbackchain-3.c
@@ -0,0 +1,7 @@
+// RUN: %clang -mno-backchain --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @foo() [[NUW:#[0-9]+]]
+void foo(void) {
+}
+
+// CHECK-NOT: "backchain"
Index: test/CodeGen/mbackchain-2.c
===
--- /dev/null
+++ test/CodeGen/mbackchain-2.c
@@ -0,0 +1,7 @@
+// RUN: %clang -mbackchain --target=s390x-linux -S -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @foo() [[NUW:#[0-9]+]]
+void foo(void) {
+}
+
+// CHECK: attributes [[NUW]] = { {{.*}} "backchain" {{.*}} }
Index: lib/Frontend/CompilerInvocation.cpp
===
--- lib/Frontend/CompilerInvocation.cpp
+++ lib/Frontend/CompilerInvocation.cpp
@@ -782,6 +782,8 @@
   Opts.CudaGpuBinaryFileNames =
   Args.getAllArgValues(OPT_fcuda_include_gpubinary);
 
+  Opts.Backchain = Args.hasArg(OPT_mbackchain);
+
   return Success;
 }
 
Index: lib/Driver/Tools.cpp
===
--- lib/Driver/Tools.cpp
+++ lib/Driver/Tools.cpp
@@ -1655,6 +1655,12 @@
   }
 }
 
+void Clang::AddSystemZTargetArgs(const ArgList ,
+ ArgStringList ) const {
+  if (Args.hasFlag(options::OPT_mbackchain, options::OPT_mno_backchain, false))
+CmdArgs.push_back("-mbackchain");
+}
+
 static const char *getSystemZTargetCPU(const ArgList ) {
   if (const Arg *A = Args.getLastArg(options::OPT_march_EQ))
 return A->getValue();
@@ -4241,6 +4247,10 @@
 AddSparcTargetArgs(Args, CmdArgs);
 break;
 
+  case llvm::Triple::systemz:
+AddSystemZTargetArgs(Args, CmdArgs);
+break;
+
   case llvm::Triple::x86:
   case llvm::Triple::x86_64:
 AddX86TargetArgs(Args, CmdArgs);
Index: lib/CodeGen/CGCall.cpp
===
--- lib/CodeGen/CGCall.cpp
+++ lib/CodeGen/CGCall.cpp
@@ -1714,6 +1714,8 @@
 
 if (CodeGenOpts.StackRealignment)
   FuncAttrs.addAttribute("stackrealign");
+if (CodeGenOpts.Backchain)
+  FuncAttrs.addAttribute("backchain");
 
 // Add target-cpu and target-features attributes to functions. If
 // we have a decl for the function and it has a target attribute then
Index: include/clang/Frontend/CodeGenOptions.def
===
--- include/clang/Frontend/CodeGenOptions.def
+++ include/clang/Frontend/CodeGenOptions.def
@@ -34,6 +34,7 @@
 CODEGENOPT(AssumeSaneOperatorNew , 1, 1) ///< implicit __attribute__((malloc)) operator new
 CODEGENOPT(Autolink  , 1, 1) ///< -fno-autolink
 CODEGENOPT(ObjCAutoRefCountExceptions , 1, 0) ///< Whether ARC should be EH-safe.
+CODEGENOPT(Backchain , 1, 0) ///< -mbackchain
 CODEGENOPT(CoverageExtraChecksum, 1, 0) ///< Whether we need a second checksum for functions in GCNO files.
 CODEGENOPT(CoverageNoFunctionNamesInData, 1, 0) ///< Do not include function names in GCDA files.
 CODEGENOPT(CoverageExitBlockBeforeBody, 1, 0) ///< Whether to emit the exit block before the body blocks in GCNO files.
Index: include/clang/Driver/Options.td
===
--- include/clang/Driver/Options.td
+++ include/clang/Driver/Options.td
@@ -1519,6 +1519,10 @@
 def mzvector : Flag<["-"], "mzvector">, Alias;
 def mno_zvector : Flag<["-"], "mno-zvector">, Alias;
 
+def mbackchain : Flag<["-"], "mbackchain">, Group, Flags<[DriverOption,CC1Option]>,
+  HelpText<"Link stack frames through backchain on System Z">;
+def mno_backchain : Flag<["-"], "mno-backchain">, Group, Flags<[DriverOption,CC1Option]>;
+
 def mno_warn_nonportable_cfstrings : Flag<["-"], 

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

2016-05-03 Thread David Blaikie via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268453: [scan-build] fix dead store warnings emitted on 
clang code base (authored by dblaikie).

Changed prior to commit:
  http://reviews.llvm.org/D19831?vs=56059=56071#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19831

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

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


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


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

2016-05-03 Thread David Blaikie via cfe-commits
Author: dblaikie
Date: Tue May  3 17:14:14 2016
New Revision: 268453

URL: http://llvm.org/viewvc/llvm-project?rev=268453=rev
Log:
[scan-build] fix dead store warnings emitted on clang code base

This fixes dead store warnings of the type "dead assignment" reported
by CLang Static Analyzer on the following file:

- tools/c-index-test/c-index-test.c.

Patch by Apelete Seketeli !

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

Modified:
cfe/trunk/tools/c-index-test/c-index-test.c

Modified: cfe/trunk/tools/c-index-test/c-index-test.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/c-index-test/c-index-test.c?rev=268453=268452=268453=diff
==
--- cfe/trunk/tools/c-index-test/c-index-test.c (original)
+++ cfe/trunk/tools/c-index-test/c-index-test.c Tue May  3 17:14:14 2016
@@ -1432,10 +1432,10 @@ static enum CXChildVisitResult PrintType
 CXString FieldSpelling = clang_getCursorSpelling(cursor);
 const char *FieldName = clang_getCString(FieldSpelling);
 /* recurse to get the first parent record that is not anonymous. */
-CXCursor Parent, Record;
 unsigned RecordIsAnonymous = 0;
 if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
-  Record = Parent = p;
+  CXCursor Record;
+  CXCursor Parent = p;
   do {
 Record = Parent;
 Parent = clang_getCursorSemanticParent(Record);


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


[libcxx] r268451 - Make check-libcxx dependant on libc++experimental if present.

2016-05-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  3 16:58:07 2016
New Revision: 268451

URL: http://llvm.org/viewvc/llvm-project?rev=268451=rev
Log:
Make check-libcxx dependant on libc++experimental if present.

Modified:
libcxx/trunk/test/CMakeLists.txt

Modified: libcxx/trunk/test/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/test/CMakeLists.txt?rev=268451=268450=268451=diff
==
--- libcxx/trunk/test/CMakeLists.txt (original)
+++ libcxx/trunk/test/CMakeLists.txt Tue May  3 16:58:07 2016
@@ -44,10 +44,14 @@ configure_file(
   ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg
   @ONLY)
 
+if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
+  set(experimental_dep cxx_experimental)
+endif()
+
 add_lit_testsuite(check-libcxx
   "Running libcxx tests"
   ${CMAKE_CURRENT_BINARY_DIR}
-  DEPENDS cxx)
+  DEPENDS cxx ${experimental_dep})
 
 if (LIBCXX_GENERATE_COVERAGE)
   include(CodeCoverage)


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


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

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

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

> Thanks - do you need someone (me) to commit this, or do you have commit
>  access?


I would appreciate if you could commit this for me since I don't have commit 
access.
Thanks.


http://reviews.llvm.org/D19831



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


[libcxx] r268443 - Create new library 'libc++experimental.a' for packaging TS symbols.

2016-05-03 Thread Eric Fiselier via cfe-commits
Author: ericwf
Date: Tue May  3 16:30:18 2016
New Revision: 268443

URL: http://llvm.org/viewvc/llvm-project?rev=268443=rev
Log:
Create new library 'libc++experimental.a' for packaging TS symbols.

Summary:
Out-of-line symbols for  headers are not ABI or API stable 
and cannot live in the 'libc++.dylib'. Currently they have nowhere to live. I 
would like to add a new library target `libc++experimental.a` to fix this. 

Previously I had suggested different libraries for different TS's 
(`libc++filesystem.a`, 'libc++LFTS.a`, ect). I no longer think this is the 
right approach.
Instead `c++experimental` will hold *all* TS implementations as a single 
monolithic library. I see two main benefits to this:

1. Users only have to know about and manually link one library.
2. It makes it easy to implement TS's with one or two out-of-line symbols. (Ex. 
PMRs)

`c++experimental` provides NO ABI compatibility. Symbols can freely be 
added/removed/changed without concern for ABI stability.
I will add documentation for this after landing this patch (but before adding 
anything to it).

`c++experimental` only builds as a static library. By default CMake will 
build/test this library but will *NOT* install it.

This patch adds the CMake and LIT logic needed to build/test the new library. 
Once this lands I plan on using it to implement parts of 
``.



Reviewers: mclow.lists

Subscribers: cfe-commits, theraven, krememek, dexonsmith, bcraig, beanz, 
danalbert

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

Added:
libcxx/trunk/src/experimental/
libcxx/trunk/src/experimental/placeholder.cpp
Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/lib/CMakeLists.txt
libcxx/trunk/test/CMakeLists.txt
libcxx/trunk/test/libcxx/test/config.py
libcxx/trunk/test/lit.site.cfg.in

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=268443=268442=268443=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Tue May  3 16:30:18 2016
@@ -52,7 +52,7 @@ MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
 # Basic options ---
 option(LIBCXX_ENABLE_ASSERTIONS "Enable assertions independent of build mode." 
ON)
 option(LIBCXX_ENABLE_SHARED "Build libc++ as a shared library." ON)
-
+option(LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY "Build libc++experimental.a" ON)
 option(LIBCXX_INCLUDE_TESTS "Build the libc++ tests." ${LLVM_INCLUDE_TESTS})
 option(LIBCXX_INCLUDE_DOCS "Build the libc++ documentation." 
${LLVM_INCLUDE_DOCS})
 set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_SUFFIX}" CACHE STRING
@@ -60,6 +60,7 @@ set(LIBCXX_LIBDIR_SUFFIX "${LLVM_LIBDIR_
 option(LIBCXX_INSTALL_HEADERS "Install the libc++ headers." ON)
 option(LIBCXX_INSTALL_LIBRARY "Install the libc++ library." ON)
 option(LIBCXX_INSTALL_SUPPORT_HEADERS "Install libc++ support headers." ON)
+option(LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY "Install libc++experimental.a" OFF)
 set(LIBCXX_ABI_VERSION 1 CACHE STRING "ABI version of libc++.")
 option(LIBCXX_ABI_UNSTABLE "Unstable ABI of libc++." OFF)
 

Modified: libcxx/trunk/lib/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/lib/CMakeLists.txt?rev=268443=268442=268443=diff
==
--- libcxx/trunk/lib/CMakeLists.txt (original)
+++ libcxx/trunk/lib/CMakeLists.txt Tue May  3 16:30:18 2016
@@ -138,6 +138,17 @@ set_target_properties(cxx
 SOVERSION "${LIBCXX_ABI_VERSION}"
   )
 
+if (LIBCXX_ENABLE_EXPERIMENTAL_LIBRARY)
+  file(GLOB LIBCXX_EXPERIMENTAL_SOURCES ../src/experimental/*.cpp)
+  add_library(cxx_experimental STATIC ${LIBCXX_EXPERIMENTAL_SOURCES})
+  target_link_libraries(cxx_experimental cxx)
+  set_target_properties(cxx_experimental
+PROPERTIES
+  COMPILE_FLAGS "${LIBCXX_COMPILE_FLAGS}"
+  OUTPUT_NAME   "c++experimental"
+  )
+endif()
+
 # Generate a linker script inplace of a libc++.so symlink. Rerun this command
 # after cxx builds.
 if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
@@ -160,7 +171,10 @@ if (LIBCXX_ENABLE_ABI_LINKER_SCRIPT)
 endif()
 
 if (LIBCXX_INSTALL_LIBRARY)
-  install(TARGETS cxx
+  if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
+set(experimental_lib cxx_experimental)
+  endif()
+  install(TARGETS cxx ${experimental_lib}
 LIBRARY DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
 ARCHIVE DESTINATION lib${LIBCXX_LIBDIR_SUFFIX} COMPONENT libcxx
 )
@@ -180,11 +194,16 @@ if (NOT CMAKE_CONFIGURATION_TYPES AND (L
 if(LIBCXX_INSTALL_LIBRARY)
   set(lib_install_target cxx)
 endif()
+if (LIBCXX_INSTALL_EXPERIMENTAL_LIBRARY)
+  set(experimental_lib_install_target cxx_experimental)
+endif()
 if(LIBCXX_INSTALL_HEADERS)
   set(header_install_target install-libcxx-headers)
 endif()
 add_custom_target(install-libcxx
-  DEPENDS 

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

2016-05-03 Thread Eric Fiselier via cfe-commits
EricWF added a comment.

In http://reviews.llvm.org/D19856#420366, @mclow.lists wrote:

> Q:  Should the .a file get installed into /lib when you do a make install?
>
> That will make it easier to link against.


For now the install rule is off by default. 
`-DLIBCXX_INSTALL_EXPERIMENTAL_LIBRARY=ON` will install it alongside 
`libc++.so`.
We can turn it `ON` by default once the library actually contains some code.


http://reviews.llvm.org/D19856



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


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

2016-05-03 Thread Richard Smith via cfe-commits
On Tue, May 3, 2016 at 12:51 PM, Dmitry Polukhin via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> DmitryPolukhin added a comment.
>
> Richard, could you please share your counterexample so I could test it on
> my patch and GCC?
>

Sure:

  struct __attribute__((abi_tag("X"))) Foo {};
  void __attribute__((abi_tag("X"))) f(Foo) {}

This should not generate an ABI tag for 'f', because there's one implied by
the first parameter type. But as far as I can see, this patch doesn't look
at the parameter types at all until after it's already streamed out the
mangling for the function name.

I think a reasonable way to deal with this is:

1) Collect the ABI tags for the overall entity. Whenever we subsequently
emit an ABI tag (or emit an inline namespace and suppress emitting its ABI
tags), remove that tag from our list of ABI tags for the overall entity (if
it's there).
2) Mangle up to and including the name of the entity. If there are any ABI
tags left for the entity, do subsequent mangling into a temporary buffer
instead of directly into the output stream.
3) Mangle the rest of the declaration.
4) If there are any ABI tags left for the overall entity, and we have not
already mangled the return type, then mangle it to a scratch buffer (which
we'll throw away).
5) If we mangled to a temporary buffer, emit any remaining ABI tags now
followed by the contents of the temporary buffer.

As for separate pass, it was my first reaction on the original patch from
> Stefan but soon I realized that I'll have to copy parts of magnler to some
> simplified mangler but with high probability of forgetting something and
> with code duplication. So now I think approach which runs full mangler in
> special mode is better and less error prone.
>
>
> http://reviews.llvm.org/D18035
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-05-03 Thread David Blaikie via cfe-commits
Thanks - do you need someone (me) to commit this, or do you have commit
access?

On Tue, May 3, 2016 at 1:32 PM, Apelete Seketeli via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> apelete updated this revision to Diff 56059.
> apelete added a comment.
>
> [scan-build] fix dead store warnings emitted on clang code base
>
> Changes since last revision:
>
> - Move 'Record' and 'Parent' variables into if() {} scope where they are
> actually used.
>
>
> http://reviews.llvm.org/D19831
>
> Files:
>   tools/c-index-test/c-index-test.c
>
> Index: tools/c-index-test/c-index-test.c
> ===
> --- tools/c-index-test/c-index-test.c
> +++ tools/c-index-test/c-index-test.c
> @@ -1432,10 +1432,10 @@
>  CXString FieldSpelling = clang_getCursorSpelling(cursor);
>  const char *FieldName = clang_getCString(FieldSpelling);
>  /* recurse to get the first parent record that is not anonymous. */
> -CXCursor Parent, Record;
>  unsigned RecordIsAnonymous = 0;
>  if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
> -  Record = Parent = p;
> +  CXCursor Record;
> +  CXCursor Parent = p;
>do {
>  Record = Parent;
>  Parent = clang_getCursorSemanticParent(Record);
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


Re: [PATCH] D19684: Power9 - Support for -mcpu=pwr9 in the front end

2016-05-03 Thread Eric Christopher via cfe-commits
echristo accepted this revision.
echristo added a reviewer: echristo.
echristo added a comment.

Please do add tests before committing. Otherwise ok.

Thanks.

-eric



Comment at: lib/Basic/Targets.cpp:1239
@@ -1227,1 +1238,3 @@
+  if (defs & ArchDefinePwr9)
+Builder.defineMacro("_ARCH_PWR9");
   if (defs & ArchDefineA2)

nemanjai wrote:
> Come to think of it - I should add a test case for this macro. It will be on 
> the next revision if one is required or in the actual commit otherwise.
Please add a test for everything you just added, yes. :)


Repository:
  rL LLVM

http://reviews.llvm.org/D19684



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


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

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

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

Changes since last revision:

- Move 'Record' and 'Parent' variables into if() {} scope where they are 
actually used.


http://reviews.llvm.org/D19831

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

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


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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-03 Thread John McCall via cfe-commits
rjmccall added a comment.

In http://reviews.llvm.org/D19678#420358, @hfinkel wrote:

> In http://reviews.llvm.org/D19678#419445, @rjmccall wrote:
>
> > This discussion of the command line interface makes me think that we should 
> > be taking Richard's suggestion one step further.  Why is Clang's 
> > involvement here more than just handing down specific requests for 
> > optimization data to LLVM and packaging that information back into some 
> > reasonable format?
>
>
> The static analyzer supports outputting its data in plist format (with which 
> I'm not familiar in detail, but it looks like a fairly-simple xml format). Is 
> that close to what you had in mind? Maybe YAML would be better (since LLVM 
> actually has a parser for that)?


YAML makes a lot of sense to me.

> > If we did that, then Clang just needs (1) an output filename, (2) an 
> > optional list of passes to collect data from, and (3) maybe some 
> > stringly-typed configuration data for each.

> 

> 

> Sure. Although I'd prefer to leave the filtering to the tool unless the I/O 
> requirements become unmanageable. Users don't know, and shouldn't know, what 
> passes do what.


Sure, seems reasonable.  So we can start with just some way to turn the feature 
on and specify a filename.


http://reviews.llvm.org/D19678



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


r268432 - Add address space 258 (X86 SS segment) to clang documentation.

2016-05-03 Thread David L Kreitzer via cfe-commits
Author: dlkreitz
Date: Tue May  3 15:20:59 2016
New Revision: 268432

URL: http://llvm.org/viewvc/llvm-project?rev=268432=rev
Log:
Add address space 258 (X86 SS segment) to clang documentation.
The change reflects llvm r268431.

Patch by Michael Lemay (michael.le...@intel.com)

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

Modified:
cfe/trunk/docs/LanguageExtensions.rst

Modified: cfe/trunk/docs/LanguageExtensions.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/LanguageExtensions.rst?rev=268432=268431=268432=diff
==
--- cfe/trunk/docs/LanguageExtensions.rst (original)
+++ cfe/trunk/docs/LanguageExtensions.rst Tue May  3 15:20:59 2016
@@ -1912,12 +1912,13 @@ X86/X86-64 Language Extensions
 
 The X86 backend has these language extensions:
 
-Memory references off the GS segment
-
+Memory references to specified segments
+^^^
 
 Annotating a pointer with address space #256 causes it to be code generated
-relative to the X86 GS segment register, and address space #257 causes it to be
-relative to the X86 FS segment.  Note that this is a very very low-level
+relative to the X86 GS segment register, address space #257 causes it to be
+relative to the X86 FS segment, and address space #258 causes it to be
+relative to the X86 SS segment.  Note that this is a very very low-level
 feature that should only be used if you know what you're doing (for example in
 an OS kernel).
 


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


Re: [PATCH] D19458: Add address space 258 to Clang documentation

2016-05-03 Thread Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268432: Add address space 258 (X86 SS segment) to clang 
documentation. (authored by dlkreitz).

Changed prior to commit:
  http://reviews.llvm.org/D19458?vs=54877=56056#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19458

Files:
  cfe/trunk/docs/LanguageExtensions.rst

Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -1912,12 +1912,13 @@
 
 The X86 backend has these language extensions:
 
-Memory references off the GS segment
-
+Memory references to specified segments
+^^^
 
 Annotating a pointer with address space #256 causes it to be code generated
-relative to the X86 GS segment register, and address space #257 causes it to be
-relative to the X86 FS segment.  Note that this is a very very low-level
+relative to the X86 GS segment register, address space #257 causes it to be
+relative to the X86 FS segment, and address space #258 causes it to be
+relative to the X86 SS segment.  Note that this is a very very low-level
 feature that should only be used if you know what you're doing (for example in
 an OS kernel).
 


Index: cfe/trunk/docs/LanguageExtensions.rst
===
--- cfe/trunk/docs/LanguageExtensions.rst
+++ cfe/trunk/docs/LanguageExtensions.rst
@@ -1912,12 +1912,13 @@
 
 The X86 backend has these language extensions:
 
-Memory references off the GS segment
-
+Memory references to specified segments
+^^^
 
 Annotating a pointer with address space #256 causes it to be code generated
-relative to the X86 GS segment register, and address space #257 causes it to be
-relative to the X86 FS segment.  Note that this is a very very low-level
+relative to the X86 GS segment register, address space #257 causes it to be
+relative to the X86 FS segment, and address space #258 causes it to be
+relative to the X86 SS segment.  Note that this is a very very low-level
 feature that should only be used if you know what you're doing (for example in
 an OS kernel).
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

2016-05-03 Thread Marshall Clow via cfe-commits
mclow.lists added a comment.

Q:  Should the .a file get installed into /lib when you do a make install?

That will make it easier to link against.


http://reviews.llvm.org/D19856



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


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

2016-05-03 Thread Samuel Benzaquen via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL268430: [clang-tidy] Speedup misc-static-assert. (authored 
by sbenza).

Changed prior to commit:
  http://reviews.llvm.org/D19877?vs=56028=56053#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D19877

Files:
  clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp

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


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


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

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

I like this approach. LGTM.


http://reviews.llvm.org/D19856



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


[clang-tools-extra] r268430 - [clang-tidy] Speedup misc-static-assert.

2016-05-03 Thread Samuel Benzaquen via cfe-commits
Author: sbenza
Date: Tue May  3 15:11:09 2016
New Revision: 268430

URL: http://llvm.org/viewvc/llvm-project?rev=268430=rev
Log:
[clang-tidy] Speedup misc-static-assert.

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

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

Reviewers: alexfh

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp?rev=268430=268429=268430=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/StaticAssertCheck.cpp Tue May  3 
15:11:09 2016
@@ -63,11 +63,15 @@ void StaticAssertCheck::registerMatchers
 hasArgument(0, AssertCondition))),
 AssertCondition);
 
-  Finder->addMatcher(stmt(anyOf(conditionalOperator(hasCondition(Condition)),
-ifStmt(hasCondition(Condition))),
-  unless(isInTemplateInstantiation()))
+  Finder->addMatcher(conditionalOperator(hasCondition(Condition),
+ unless(isInTemplateInstantiation()))
  .bind("condStmt"),
  this);
+
+  Finder->addMatcher(
+  ifStmt(hasCondition(Condition), unless(isInTemplateInstantiation()))
+  .bind("condStmt"),
+  this);
 }
 
 void StaticAssertCheck::check(const MatchFinder::MatchResult ) {


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


Re: [PATCH] D19678: Annotated-source optimization reports (a.k.a. "listing" files)

2016-05-03 Thread Hal Finkel via cfe-commits
hfinkel added a comment.

In http://reviews.llvm.org/D19678#419445, @rjmccall wrote:

> This discussion of the command line interface makes me think that we should 
> be taking Richard's suggestion one step further.  Why is Clang's involvement 
> here more than just handing down specific requests for optimization data to 
> LLVM and packaging that information back into some reasonable format?


The static analyzer supports outputting its data in plist format (with which 
I'm not familiar in detail, but it looks like a fairly-simple xml format). Is 
that close to what you had in mind? Maybe YAML would be better (since LLVM 
actually has a parser for that)?

> The actual presentation of that data seems like it belongs in a separate 
> library / tool, which can have a rich set of visualization options.  This is 
> also a more rigorously testable design, since the tool has a well-defined 
> input format that's not just an incidental by-product of the compiler.


I think this makes sense.

> If we did that, then Clang just needs (1) an output filename, (2) an optional 
> list of passes to collect data from, and (3) maybe some stringly-typed 
> configuration data for each.


Sure. Although I'd prefer to leave the filtering to the tool unless the I/O 
requirements become unmanageable. Users don't know, and shouldn't know, what 
passes do what.


http://reviews.llvm.org/D19678



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


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

2016-05-03 Thread David Blaikie via cfe-commits
dblaikie accepted this revision.
dblaikie added a reviewer: dblaikie.
This revision is now accepted and ready to land.


Comment at: tools/c-index-test/c-index-test.c:1435-1436
@@ -1434,3 +1434,4 @@
 /* recurse to get the first parent record that is not anonymous. */
-CXCursor Parent, Record;
+CXCursor Record;
+CXCursor Parent = p;
 unsigned RecordIsAnonymous = 0;

Could you move these two declarations into the if (1438) since they appear to 
only be used within that scope anyway?


http://reviews.llvm.org/D19831



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


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

2016-05-03 Thread Dmitry Polukhin via cfe-commits
DmitryPolukhin added a comment.

Richard, could you please share your counterexample so I could test it on my 
patch and GCC?

As for separate pass, it was my first reaction on the original patch from 
Stefan but soon I realized that I'll have to copy parts of magnler to some 
simplified mangler but with high probability of forgetting something and with 
code duplication. So now I think approach which runs full mangler in special 
mode is better and less error prone.


http://reviews.llvm.org/D18035



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


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

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


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

Split these onto two lines?


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

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


http://reviews.llvm.org/D19876



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


r268423 - AArch64: fixup comment after change

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

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

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

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


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


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

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


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

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


http://reviews.llvm.org/D19869



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


r268422 - AArch64: simplify illegal vector check. NFC.

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

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

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

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

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


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


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

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


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

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


http://reviews.llvm.org/D19869



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


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

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

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

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


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

Thanks.


http://reviews.llvm.org/D19831



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


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

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

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

Changes since last revision:

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


http://reviews.llvm.org/D19831

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

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


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


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

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


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

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

Will fix in next revision.


http://reviews.llvm.org/D19831



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


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

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

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

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


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


http://reviews.llvm.org/D19881



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


r268419 - Fix use of LLVM IR names in lit test

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

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

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

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


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


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

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

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

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


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

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


http://reviews.llvm.org/D19881



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


r268418 - [MS] Pass CalleeDecl to adjustThisArgumentForVirtualFunctionCall

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

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

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

Fixes PR27621

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

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

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


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


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

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

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

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


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

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


http://reviews.llvm.org/D19881



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


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

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

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

What's the workaround for current cmake releases?


http://reviews.llvm.org/D19881



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


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

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

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

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

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

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

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

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

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

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

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

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


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


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

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

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

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


http://reviews.llvm.org/D19881



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


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

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


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

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


http://reviews.llvm.org/D19881



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


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

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


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

Doesn't do that for me:

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


http://reviews.llvm.org/D19881



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


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

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


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

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

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


http://reviews.llvm.org/D19871



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


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

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

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

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

http://reviews.llvm.org/D19877

Files:
  clang-tidy/misc/StaticAssertCheck.cpp

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


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


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

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

LGTM, thank you for noticing that!


http://reviews.llvm.org/D19877



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


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

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



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

> 

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

> 

> 

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


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


http://reviews.llvm.org/D19871



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


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

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


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

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


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

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


http://reviews.llvm.org/D19869



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


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

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

- Addressed reviewer comment.


http://reviews.llvm.org/D19869

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

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

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

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

fix doc


http://reviews.llvm.org/D19876

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

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


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

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

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

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

http://reviews.llvm.org/D19876

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

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


Re: [PATCH] D19684: Power9 - Support for -mcpu=pwr9 in the front end

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

LGTM


Repository:
  rL LLVM

http://reviews.llvm.org/D19684



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


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

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

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

> apelete updated this revision to Diff 55952.
> apelete added a comment.
>
> [scan-build] fix dead store warnings emitted on clang code base
>
> Changes since last revision:
>
> - remove dead store since the do {} while() loop overwrite it immediatly
> anyway.
>
>
> http://reviews.llvm.org/D19831
>
> Files:
>   tools/c-index-test/c-index-test.c
>
> Index: tools/c-index-test/c-index-test.c
> ===
> --- tools/c-index-test/c-index-test.c
> +++ tools/c-index-test/c-index-test.c
> @@ -1435,7 +1435,6 @@
>  CXCursor Parent, Record;
>  unsigned RecordIsAnonymous = 0;
>  if (clang_getCursorKind(cursor) == CXCursor_FieldDecl) {
> -  Record = Parent = p;
>do {
>  Record = Parent;
>  Parent = clang_getCursorSemanticParent(Record);
>
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>
>
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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

nit


http://reviews.llvm.org/D19871

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

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

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

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

add dynamic parsing


http://reviews.llvm.org/D19871

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

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

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

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

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


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


http://reviews.llvm.org/D19871



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


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

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

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

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


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

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


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

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

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


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


http://reviews.llvm.org/D19871



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


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

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



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




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

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

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

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


http://reviews.llvm.org/D19871



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


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

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

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

Based on post commit feedback from Eric Fiselier.

Modified:
libcxx/trunk/include/CMakeLists.txt

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


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


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

2016-05-03 Thread Serge Pavlov via cfe-commits
2016-04-26 0:55 GMT+06:00 Richard Smith :

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


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

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


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

Removed.


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

http://reviews.llvm.org/D16989

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


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

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


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

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


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

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


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

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


Repository:
  rL LLVM

http://reviews.llvm.org/D19816



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


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

2016-05-03 Thread Serge Pavlov via cfe-commits
sepavloff updated this revision to Diff 56015.
sepavloff added a comment.

Updated patch.


http://reviews.llvm.org/D16989

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

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

[Clang] Convergent Attribute

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

the attached patch introduces the `convergent` attribute.

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

Bye,
Ettore Speziale



convergent.diff
Description: Binary data


--
Ettore Speziale — Compiler Engineer
speziale.ett...@gmail.com
espezi...@apple.com
--___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


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

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


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

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


http://reviews.llvm.org/D19324



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


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

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

Thanks for fixing!

Devin, what do you think about the BugType wording?



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

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


http://reviews.llvm.org/D19866



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


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

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


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

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


http://reviews.llvm.org/D19324



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


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

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


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

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


http://reviews.llvm.org/D19324



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


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

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

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

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


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


http://reviews.llvm.org/D19871



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


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

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

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


http://reviews.llvm.org/D18035



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


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

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

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


That was my original idea.

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

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


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


http://reviews.llvm.org/D19871



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


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

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

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


http://reviews.llvm.org/D19062



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


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

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

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

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


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


http://reviews.llvm.org/D19871



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


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

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


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

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


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

This should return `iterator_range`


http://reviews.llvm.org/D19324



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


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

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


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

I'd make that a const ref.


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

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


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

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


http://reviews.llvm.org/D19869



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


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

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

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

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


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

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

> 

> > 

> 

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

> 

> 

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


You're welcome!


http://reviews.llvm.org/D19871



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


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

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


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

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


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

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


http://reviews.llvm.org/D19534



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


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

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

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

> Is this required for some purpose?


It's used in clang-tidy checkers.

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

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

> 

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


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


http://reviews.llvm.org/D19871



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


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

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

Is this required for some purpose?

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

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


http://reviews.llvm.org/D19871



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


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

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

Cosmetics + change error message.


http://reviews.llvm.org/D19534

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

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

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

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

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

http://reviews.llvm.org/D19871

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

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


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


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

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

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

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


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


Repository:
  rL LLVM

http://reviews.llvm.org/D19827



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


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

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

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

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


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

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

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


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


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

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

Hi Alexey,

Any comments on this patch?

Thanks.


http://reviews.llvm.org/D19484



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


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

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

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


Repository:
  rL LLVM

http://reviews.llvm.org/D19827



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


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

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

ping @Alexfh have you check it?


http://reviews.llvm.org/D19165



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


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

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

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



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

clang-format, please.


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

This should be done in `registerMatchers` instead.


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

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

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

1. Install sphinx:

$ sudo apt-get install sphinx-common

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

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


http://reviews.llvm.org/D16962



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


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

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

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

Patch by Phil Camp, SN Systems

http://reviews.llvm.org/D19866

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

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


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

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

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

LG. Thanks!


Repository:
  rL LLVM

http://reviews.llvm.org/D19849



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


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

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

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

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


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

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

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

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

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

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


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

Can this take a `const Expr *` instead?


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

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


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

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


http://reviews.llvm.org/D19851



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


  1   2   >