[PATCH] D38009: [Sema] Fix using old initializer during switch statement transformation.

2017-09-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak accepted this revision.
ahatanak added a comment.
This revision is now accepted and ready to land.

I think this is correct.


https://reviews.llvm.org/D38009



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


[PATCH] D38118: [CodeGen][ObjC] Build the global block structure before emitting the body of global block invoke functions

2017-09-20 Thread Akira Hatanaka via Phabricator via cfe-commits
ahatanak created this revision.

This patch fixes an infinite loop in IRGen that occurs when compiling the 
following code:

  void FUNC2() {
static void (^const block1)(int) = ^(int a){
  if (a--)
block1(a);
};
  
  When IRGen visits the call to "block1", it knows that it always calls the 
block defined in Func2 enclosing the call (because "block1" is const 
qualified), so it tries to emit the reference to "block1" as a constant and 
calls CodeGenModule::GetAddrOfGlobalBlock to get the address of the block. 
CodeGenModule::GetAddrOfGlobalBlock checks whether the block has already been 
emitted (calling getAddrOfGlobalBlockIfEmitted). If the block hasn't been 
emitted, it starts generating the block invoke function, which causes the 
infinite loop.
  
  I believe this happens because clang's constant folding got smarter (see 
commit log of r290661, for example) and the call "refExpr->EvaluateAsRValue" in 
CodeGenFunction::tryEmitAsConstant returns true now as a result.
  
  This patch prevents the infinite loop by building the global block in 
GenerateBlockFunction before it emits the IR of the body of the function.
  
  rdar://problem/34541684


https://reviews.llvm.org/D38118

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CodeGenFunction.h
  test/CodeGen/mangle-blocks.c
  test/CodeGenObjC/local-static-block.m
  test/CodeGenObjC/mangle-blocks.m

Index: test/CodeGenObjC/mangle-blocks.m
===
--- test/CodeGenObjC/mangle-blocks.m
+++ test/CodeGenObjC/mangle-blocks.m
@@ -18,11 +18,11 @@
 @end
 
 // CHECK: @"__func__.__14-[Test mangle]_block_invoke_2" = private unnamed_addr constant [30 x i8] c"-[Test mangle]_block_invoke_2\00", align 1
-// CHECK: @.str = private unnamed_addr constant {{.*}}, align 1
-// CHECK: @.str.1 = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
+// CHECK: @.str{{.*}} = private unnamed_addr constant {{.*}}, align 1
+// CHECK: @.str[[STR1:.*]] = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
 
 // CHECK: define internal void @"__14-[Test mangle]_block_invoke"(i8* %.block_descriptor)
 
 // CHECK: define internal void @"__14-[Test mangle]_block_invoke_2"(i8* %.block_descriptor){{.*}}{
-// CHECK: call void @__assert_rtn(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @"__func__.__14-[Test mangle]_block_invoke_2", i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0))
+// CHECK: call void @__assert_rtn(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @"__func__.__14-[Test mangle]_block_invoke_2", i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 14, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str[[STR1]], i32 0, i32 0))
 // CHECK: }
Index: test/CodeGenObjC/local-static-block.m
===
--- test/CodeGenObjC/local-static-block.m
+++ test/CodeGenObjC/local-static-block.m
@@ -46,6 +46,17 @@
  }
 }
 
+void FUNC2() {
+  static void (^const block1)(int) = ^(int a){
+if (a--)
+  block1(a);
+  };
+}
+
+// CHECK-LABEL-LP64: define void @FUNC2(
+// CHECK: define internal void @_block_invoke{{.*}}(
+// CHECK: call void %{{.*}}(i8* bitcast ({ i8**, i32, i32, i8*, %struct.__block_descriptor* }* @__block_literal_global{{.*}} to i8*), i32 %{{.*}})
+
 void FUNC1()
 {
  static  NSArray *(^ArrayRecurs)(NSArray *addresses, unsigned long level) = ^(NSArray *addresses, unsigned long level) {
Index: test/CodeGen/mangle-blocks.c
===
--- test/CodeGen/mangle-blocks.c
+++ test/CodeGen/mangle-blocks.c
@@ -12,12 +12,12 @@
 }
 
 // CHECK: @__func__.__mangle_block_invoke_2 = private unnamed_addr constant [22 x i8] c"mangle_block_invoke_2\00", align 1
-// CHECK: @.str = private unnamed_addr constant {{.*}}, align 1
-// CHECK: @.str.1 = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
+// CHECK: @.str{{.*}} = private unnamed_addr constant {{.*}}, align 1
+// CHECK: @.str[[STR1:.*]] = private unnamed_addr constant [7 x i8] c"mangle\00", align 1
 
 // CHECK: define internal void @__mangle_block_invoke(i8* %.block_descriptor)
 
 // CHECK: define internal void @__mangle_block_invoke_2(i8* %.block_descriptor){{.*}}{
-// CHECK:   call void @__assert_rtn(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__func__.__mangle_block_invoke_2, i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i32 0, i32 0))
+// CHECK:   call void @__assert_rtn(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @__func__.__mangle_block_invoke_2, i32 0, i32 0), i8* getelementptr inbounds {{.*}}, i32 9, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str[[STR1]], i32 0, i32 0))
 // CHECK: }
 
Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ 

Re: r313827 - Give external linkage and mangling to lambdas inside inline variables and variable templates.

2017-09-20 Thread Vitaly Buka via cfe-commits
reverted by r313856

On Wed, Sep 20, 2017 at 6:30 PM, Richard Smith 
wrote:

> Thanks, I'll fix this tomorrow; if that's not soon enough, please go ahead
> and revert (or fix by adding a dummy enumerator in lib/AST/Linkage.h).
>
> On 20 Sep 2017 17:39, "Vitaly Buka via cfe-commits" <
> cfe-commits@lists.llvm.org> wrote:
>
>> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8038/steps/check-clang%20ubsan/logs/stdio
>>
>>
>> --
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42:
>>  runtime error: load of value 15, which is not a valid value for type 
>> 'clang::LVComputationKind'
>> #0 0x7084fd9 in 
>> clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*, 
>> clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42
>> #1 0x7085874 in 
>> clang::LinkageComputer::getLVForClosure(clang::DeclContext const*, 
>> clang::Decl*, clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1135:14
>> #2 0x708224e in clang::LinkageComputer::getLVForDecl(clang::NamedDecl 
>> const*, clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
>> #3 0x7085242 in clang::NamedDecl::getLinkageInternal() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
>> #4 0x731c021 in computeCachedProperties(clang::Type const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3379:22
>> #5 0x7311b2d in clang::TypePropertyCache<(anonymous 
>> namespace)::Private>::ensure(clang::Type const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3330:31
>> #6 0x7311bb2 in clang::TypePropertyCache<(anonymous 
>> namespace)::Private>::ensure(clang::Type const*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3322:7
>> #7 0x7311a8f in clang::Type::getLinkage() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3438:3
>> #8 0x7081a61 in clang::LinkageComputer::getLVForType(clang::Type const&, 
>> clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:194:26
>> #9 0x70831d3 in 
>> clang::LinkageComputer::getLVForNamespaceScopeDecl(clang::NamedDecl const*, 
>> clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:724:28
>> #10 0x708224e in clang::LinkageComputer::getLVForDecl(clang::NamedDecl 
>> const*, clang::LVComputationKind) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
>> #11 0x7085242 in clang::NamedDecl::getLinkageInternal() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
>> #12 0x38d3ddd in clang::NamedDecl::isExternallyVisible() const 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/AST/Decl.h:339:39
>> #13 0x5a69da3 in 
>> clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:11042:12
>> #14 0x5a693c9 in clang::Sema::AddInitializerToDecl(clang::Decl*, 
>> clang::Expr*, bool) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:10645:3
>> #15 0x555b6d1 in 
>> clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
>>  clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2276:17
>> #16 0x5559ce1 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, 
>> unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2013:21
>> #17 0x553611a in 
>> clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
>>  clang::ParsingDeclSpec&, clang::AccessSpecifier) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:979:10
>> #18 0x55359a2 in 
>> clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
>>  clang::ParsingDeclSpec*, clang::AccessSpecifier) 
>> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:995:12
>> #19 0x5534fbf in 
>> 

r313856 - Revert "Give external linkage and mangling to lambdas inside inline variables and variable templates."

2017-09-20 Thread Vitaly Buka via cfe-commits
Author: vitalybuka
Date: Wed Sep 20 19:51:56 2017
New Revision: 313856

URL: http://llvm.org/viewvc/llvm-project?rev=313856=rev
Log:
Revert "Give external linkage and mangling to lambdas inside inline variables 
and variable templates."

To fix: runtime error: load of value 15, which is not a valid value for type 
'clang::LVComputationKind'

This reverts commit r313827.

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Linkage.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CodeGenCXX/mangle-lambdas.cpp
cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=313856=313855=313856=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Sep 20 19:51:56 2017
@@ -676,10 +676,10 @@ LinkageComputer::getLVForNamespaceScopeD
 if (!LV.isVisibilityExplicit()) {
   // Use global type/value visibility as appropriate.
   Visibility globalVisibility;
-  if ((computation & ~IgnoreTypeLinkageBit) == LVForValue) {
+  if (computation == LVForValue) {
 globalVisibility = Context.getLangOpts().getValueVisibilityMode();
   } else {
-assert((computation & ~IgnoreTypeLinkageBit) == LVForType);
+assert(computation == LVForType);
 globalVisibility = Context.getLangOpts().getTypeVisibilityMode();
   }
   LV.mergeVisibility(globalVisibility, /*explicit*/ false);
@@ -719,8 +719,7 @@ LinkageComputer::getLVForNamespaceScopeD
 //
 // Note that we don't want to make the variable non-external
 // because of this, but unique-external linkage suits us.
-if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var) &&
-!(computation & IgnoreTypeLinkageBit)) {
+if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var)) {
   LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
   if (!isExternallyVisible(TypeLV.getLinkage()))
 return LinkageInfo::uniqueExternal();
@@ -760,8 +759,8 @@ LinkageComputer::getLVForNamespaceScopeD
 // unique-external linkage, it's not legally usable from outside
 // this translation unit.  However, we should use the C linkage
 // rules instead for extern "C" declarations.
-if (Context.getLangOpts().CPlusPlus && !Function->isInExternCContext() &&
-!(computation & IgnoreTypeLinkageBit)) {
+if (Context.getLangOpts().CPlusPlus &&
+!Function->isInExternCContext()) {
   // Only look at the type-as-written. If this function has an auto-deduced
   // return type, we can't compute the linkage of that type because it 
could
   // require looking at the linkage of this function, and we don't need 
this
@@ -1123,18 +1122,8 @@ LinkageInfo LinkageComputer::getLVForClo
   // calculation determines the lambda has external linkage, it should be
   // downgraded to VisibleNoLinkage.
   if (ContextDecl) {
-auto *VD = dyn_cast(ContextDecl);
 if (isa(ContextDecl))
   DC = ContextDecl->getDeclContext()->getRedeclContext();
-else if (VD && VD->getType()->getContainedDeducedType())
-  // If the declaration has a deduced type, we need to skip querying the
-  // linkage and visibility of that type, because it might involve this
-  // closure type. The only effect of this is that we might give a lambda
-  // VisibleNoLinkage rather than NoLinkage when we don't strictly need to,
-  // which is benign.
-  return computeLVForDecl(
-  cast(ContextDecl),
-  LVComputationKind(computation | IgnoreTypeLinkageBit));
 else
   return getLVForDecl(cast(ContextDecl), computation);
   }

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=313856=313855=313856=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Sep 20 19:51:56 2017
@@ -1691,16 +1691,10 @@ void CXXNameMangler::mangleLambda(const
   // to emit that last part of the prefix here.
   if (Decl *Context = Lambda->getLambdaContextDecl()) {
 if ((isa(Context) || isa(Context)) &&
-!isa(Context)) {
-  // FIXME: 'inline auto [a, b] = []{ return ... };' does not get a
-  // reasonable mangling here.
+Context->getDeclContext()->isRecord()) {
   if (const IdentifierInfo *Name
 = cast(Context)->getIdentifier()) {
 mangleSourceName(Name);
-const TemplateArgumentList *TemplateArgs = nullptr;
-if (const TemplateDecl *TD =
-

Re: r313827 - Give external linkage and mangling to lambdas inside inline variables and variable templates.

2017-09-20 Thread Richard Smith via cfe-commits
Thanks, I'll fix this tomorrow; if that's not soon enough, please go ahead
and revert (or fix by adding a dummy enumerator in lib/AST/Linkage.h).

On 20 Sep 2017 17:39, "Vitaly Buka via cfe-commits" <
cfe-commits@lists.llvm.org> wrote:

> http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8038/steps/check-clang%20ubsan/logs/stdio
>
>
> --
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42:
>  runtime error: load of value 15, which is not a valid value for type 
> 'clang::LVComputationKind'
> #0 0x7084fd9 in clang::LinkageComputer::computeLVForDecl(clang::NamedDecl 
> const*, clang::LVComputationKind) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42
> #1 0x7085874 in 
> clang::LinkageComputer::getLVForClosure(clang::DeclContext const*, 
> clang::Decl*, clang::LVComputationKind) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1135:14
> #2 0x708224e in clang::LinkageComputer::getLVForDecl(clang::NamedDecl 
> const*, clang::LVComputationKind) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
> #3 0x7085242 in clang::NamedDecl::getLinkageInternal() const 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
> #4 0x731c021 in computeCachedProperties(clang::Type const*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3379:22
> #5 0x7311b2d in clang::TypePropertyCache<(anonymous 
> namespace)::Private>::ensure(clang::Type const*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3330:31
> #6 0x7311bb2 in clang::TypePropertyCache<(anonymous 
> namespace)::Private>::ensure(clang::Type const*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3322:7
> #7 0x7311a8f in clang::Type::getLinkage() const 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3438:3
> #8 0x7081a61 in clang::LinkageComputer::getLVForType(clang::Type const&, 
> clang::LVComputationKind) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:194:26
> #9 0x70831d3 in 
> clang::LinkageComputer::getLVForNamespaceScopeDecl(clang::NamedDecl const*, 
> clang::LVComputationKind) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:724:28
> #10 0x708224e in clang::LinkageComputer::getLVForDecl(clang::NamedDecl 
> const*, clang::LVComputationKind) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
> #11 0x7085242 in clang::NamedDecl::getLinkageInternal() const 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
> #12 0x38d3ddd in clang::NamedDecl::isExternallyVisible() const 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/AST/Decl.h:339:39
> #13 0x5a69da3 in 
> clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:11042:12
> #14 0x5a693c9 in clang::Sema::AddInitializerToDecl(clang::Decl*, 
> clang::Expr*, bool) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:10645:3
> #15 0x555b6d1 in 
> clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
>  clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2276:17
> #16 0x5559ce1 in clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, 
> unsigned int, clang::SourceLocation*, clang::Parser::ForRangeInit*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2013:21
> #17 0x553611a in 
> clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
>  clang::ParsingDeclSpec&, clang::AccessSpecifier) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:979:10
> #18 0x55359a2 in 
> clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
>  clang::ParsingDeclSpec*, clang::AccessSpecifier) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:995:12
> #19 0x5534fbf in 
> clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
>  clang::ParsingDeclSpec*) 
> /mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:845:12
> #20 0x553431c in 

[PATCH] D37925: Allow specifying sanitizers in blacklists

2017-09-20 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis added a subscriber: dberris.
eugenis added inline comments.



Comment at: include/clang/Basic/SanitizerSpecialCaseList.h:39
+  // Initialize SanitizerSections.
+  void sanitizerCompile();
+

"compile" in this method name is confusing. It's used in the base class to 
refer to regexp compilation. Let's call this one createSanitizerSections.




Comment at: lib/AST/Decl.cpp:3932
   ASTContext  = getASTContext();
-  if (!Context.getLangOpts().Sanitize.hasOneOf(
-  SanitizerKind::Address | SanitizerKind::KernelAddress) ||
+  const SanitizerMask ASanMask =
+  SanitizerKind::Address | SanitizerKind::KernelAddress;

"Asan" is a more common spelling in clang & compiler-rt identifiers (even 
though official abbreviation is ASan).



Comment at: lib/AST/Decl.cpp:3953
 ReasonToReject = 5;  // is standard layout.
-  else if (Blacklist.isBlacklistedLocation(getLocation(), "field-padding"))
+  else if (Blacklist.isBlacklistedLocation(ASanMask, getLocation(),
+   "field-padding"))

Looks like this is another case of missing "& LangOpts.Sanitize.Mask" ?



Comment at: lib/Basic/XRayLists.cpp:29
   // whether it's treated as a "never" instrument function.
-  if (AlwaysInstrument->inSection("fun", FunctionName, "arg1"))
+  if (AlwaysInstrument->inSection("xray_always_instrument", "fun", 
FunctionName,
+  "arg1"))

It feels redundant to have AlwaysInstrument and NeverInstrument lists, and then 
the same distinction in section names. Maybe sections could be named "xray" in  
both cases? Or, better, the lists could be merged into a single list with 
always and never sections? There is also an issue of backward compatibility. 
Anyway, that's for xray devs to decide. @dberris 



Comment at: lib/CodeGen/CodeGenModule.cpp:1564
   // For now globals can be blacklisted only in ASan and KASan.
-  if (!LangOpts.Sanitize.hasOneOf(
-  SanitizerKind::Address | SanitizerKind::KernelAddress))
+  const SanitizerMask ASanMask =
+  SanitizerKind::Address | SanitizerKind::KernelAddress;

AsanMask


https://reviews.llvm.org/D37925



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


[PATCH] D37562: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR

2017-09-20 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB added a comment.

In https://reviews.llvm.org/D37562#877209, @craig.topper wrote:

> Was the code not using emmintrin.h and instead copied code from it that used 
> the builtins?


Turned out to be code that had been preprocessed in the past. I'll unpreprocess 
the xmmintrin.h/emmintrin.h parts now.


Repository:
  rL LLVM

https://reviews.llvm.org/D37562



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


[PATCH] D37562: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR

2017-09-20 Thread Craig Topper via Phabricator via cfe-commits
craig.topper added a comment.

Was the code not using emmintrin.h and instead copied code from it that used 
the builtins?


Repository:
  rL LLVM

https://reviews.llvm.org/D37562



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


Re: r313827 - Give external linkage and mangling to lambdas inside inline variables and variable templates.

2017-09-20 Thread Vitaly Buka via cfe-commits
http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-fast/builds/8038/steps/check-clang%20ubsan/logs/stdio


--
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42:
runtime error: load of value 15, which is not a valid value for type
'clang::LVComputationKind'
#0 0x7084fd9 in
clang::LinkageComputer::computeLVForDecl(clang::NamedDecl const*,
clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1333:42
#1 0x7085874 in
clang::LinkageComputer::getLVForClosure(clang::DeclContext const*,
clang::Decl*, clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1135:14
#2 0x708224e in
clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*,
clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
#3 0x7085242 in clang::NamedDecl::getLinkageInternal() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
#4 0x731c021 in computeCachedProperties(clang::Type const*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3379:22
#5 0x7311b2d in clang::TypePropertyCache<(anonymous
namespace)::Private>::ensure(clang::Type const*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3330:31
#6 0x7311bb2 in clang::TypePropertyCache<(anonymous
namespace)::Private>::ensure(clang::Type const*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3322:7
#7 0x7311a8f in clang::Type::getLinkage() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Type.cpp:3438:3
#8 0x7081a61 in clang::LinkageComputer::getLVForType(clang::Type
const&, clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:194:26
#9 0x70831d3 in
clang::LinkageComputer::getLVForNamespaceScopeDecl(clang::NamedDecl
const*, clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:724:28
#10 0x708224e in
clang::LinkageComputer::getLVForDecl(clang::NamedDecl const*,
clang::LVComputationKind)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1377:20
#11 0x7085242 in clang::NamedDecl::getLinkageInternal() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/AST/Decl.cpp:1036:28
#12 0x38d3ddd in clang::NamedDecl::isExternallyVisible() const
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/include/clang/AST/Decl.h:339:39
#13 0x5a69da3 in
clang::Sema::CheckCompleteVariableDeclaration(clang::VarDecl*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:11042:12
#14 0x5a693c9 in clang::Sema::AddInitializerToDecl(clang::Decl*,
clang::Expr*, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Sema/SemaDecl.cpp:10645:3
#15 0x555b6d1 in
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&,
clang::Parser::ParsedTemplateInfo const&,
clang::Parser::ForRangeInit*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2276:17
#16 0x5559ce1 in
clang::Parser::ParseDeclGroup(clang::ParsingDeclSpec&, unsigned int,
clang::SourceLocation*, clang::Parser::ForRangeInit*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseDecl.cpp:2013:21
#17 0x553611a in
clang::Parser::ParseDeclOrFunctionDefInternal(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec&, clang::AccessSpecifier)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:979:10
#18 0x55359a2 in
clang::Parser::ParseDeclarationOrFunctionDefinition(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*, clang::AccessSpecifier)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:995:12
#19 0x5534fbf in
clang::Parser::ParseExternalDeclaration(clang::Parser::ParsedAttributesWithRange&,
clang::ParsingDeclSpec*)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:845:12
#20 0x553431c in
clang::Parser::ParseTopLevelDecl(clang::OpaquePtr&)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/Parser.cpp:613:12
#21 0x552f0e0 in clang::ParseAST(clang::Sema&, bool, bool)
/mnt/b/sanitizer-buildbot3/sanitizer-x86_64-linux-fast/build/llvm/tools/clang/lib/Parse/ParseAST.cpp:147:18
#22 0x4045c32 in clang::FrontendAction::Execute()

[PATCH] D37562: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR

2017-09-20 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB added a comment.

Actually, looking at the change it seems like it is and we better try to update 
emmintrin.h...


Repository:
  rL LLVM

https://reviews.llvm.org/D37562



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


[PATCH] D38113: OpenCL: Assume functions are convergent

2017-09-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm updated this revision to Diff 116125.
arsenm added a comment.
Herald added a subscriber: nhaehnle.

Missed test update


https://reviews.llvm.org/D38113

Files:
  include/clang/Basic/LangOptions.h
  lib/CodeGen/CGCall.cpp
  test/CodeGenOpenCL/amdgpu-attrs.cl
  test/CodeGenOpenCL/convergent.cl

Index: test/CodeGenOpenCL/convergent.cl
===
--- test/CodeGenOpenCL/convergent.cl
+++ test/CodeGenOpenCL/convergent.cl
@@ -1,9 +1,19 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck -enable-var-scope %s
+
+// This is initially assumed convergent, but can be deduced to not require it.
+
+// CHECK-LABEL: define spir_func void @non_convfun() local_unnamed_addr #0
+// CHECK: ret void
+__attribute__((noinline))
+void non_convfun(void) {
+  volatile int* p;
+  *p = 0;
+}
 
 void convfun(void) __attribute__((convergent));
-void non_convfun(void);
 void nodupfun(void) __attribute__((noduplicate));
 
+// External functions should be assumed convergent.
 void f(void);
 void g(void);
 
@@ -17,19 +27,23 @@
 //  non_convfun();
 //}
 //
-// CHECK: define spir_func void @test_merge_if(i32 %[[a:.+]])
-// CHECK: %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK-LABEL: define spir_func void @test_merge_if(i32 %a) local_unnamed_addr #1 {
+// CHECK: %[[tobool:.+]] = icmp eq i32 %a, 0
 // CHECK: br i1 %[[tobool]], label %[[if_end3_critedge:.+]], label %[[if_then:.+]]
+
 // CHECK: [[if_then]]:
 // CHECK: tail call spir_func void @f()
 // CHECK: tail call spir_func void @non_convfun()
 // CHECK: tail call spir_func void @g()
+
 // CHECK: br label %[[if_end3:.+]]
+
 // CHECK: [[if_end3_critedge]]:
 // CHECK: tail call spir_func void @non_convfun()
 // CHECK: br label %[[if_end3]]
+
 // CHECK: [[if_end3]]:
-// CHECK-LABEL: ret void
+// CHECK: ret void
 
 void test_merge_if(int a) {
   if (a) {
@@ -41,22 +55,22 @@
   }
 }
 
-// CHECK-DAG: declare spir_func void @f()
-// CHECK-DAG: declare spir_func void @non_convfun()
-// CHECK-DAG: declare spir_func void @g()
+// CHECK-DAG: declare spir_func void @f() local_unnamed_addr #2
+// CHECK-DAG: declare spir_func void @g() local_unnamed_addr #2
+
 
 // Test two if's are not merged.
-// CHECK: define spir_func void @test_no_merge_if(i32 %[[a:.+]])
-// CHECK:  %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK-LABEL: define spir_func void @test_no_merge_if(i32 %a) local_unnamed_addr #1
+// CHECK:  %[[tobool:.+]] = icmp eq i32 %a, 0
 // CHECK: br i1 %[[tobool]], label %[[if_end:.+]], label %[[if_then:.+]]
 // CHECK: [[if_then]]:
 // CHECK: tail call spir_func void @f()
 // CHECK-NOT: call spir_func void @convfun()
 // CHECK-NOT: call spir_func void @g()
 // CHECK: br label %[[if_end]]
 // CHECK: [[if_end]]:
 // CHECK:  %[[tobool_pr:.+]] = phi i1 [ true, %[[if_then]] ], [ false, %{{.+}} ]
-// CHECK:  tail call spir_func void @convfun() #[[attr5:.+]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4:.+]]
 // CHECK:  br i1 %[[tobool_pr]], label %[[if_then2:.+]], label %[[if_end3:.+]]
 // CHECK: [[if_then2]]:
 // CHECK: tail call spir_func void @g()
@@ -74,20 +88,20 @@
   }
 }
 
-// CHECK: declare spir_func void @convfun(){{[^#]*}} #[[attr2:[0-9]+]]
+// CHECK: declare spir_func void @convfun(){{[^#]*}} #2
 
 // Test loop is unrolled for convergent function.
-// CHECK-LABEL: define spir_func void @test_unroll()
-// CHECK:  tail call spir_func void @convfun() #[[attr5:[0-9]+]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK-LABEL: define spir_func void @test_unroll() local_unnamed_addr #1
+// CHECK:  tail call spir_func void @convfun() #[[attr4:[0-9]+]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
 // CHECK-LABEL:  ret void
 
 void test_unroll() {
@@ -101,7 +115,7 @@
 // CHECK: [[for_cond_cleanup:.+]]:
 // CHECK:  ret void
 // CHECK: [[for_body]]:
-// CHECK:  tail call spir_func void @nodupfun() #[[attr6:[0-9]+]]

[PATCH] D38113: OpenCL: Assume functions are convergent

2017-09-20 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added a comment.

LGTM for the changes other than the test (I don't read opencl).


https://reviews.llvm.org/D38113



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


[PATCH] D37562: [X86] Lower _mm[256|512]_[mask[z]]_avg_epu[8|16] intrinsics to native llvm IR

2017-09-20 Thread Matthias Braun via Phabricator via cfe-commits
MatzeB added a comment.

With this commit some (old) code stops to compile as it seems to remove some 
builtins, was that intentional?

Reproducer:

  typedef long long __m128i __attribute__((__vector_size__(16)));
  typedef short __v8hi __attribute__((__vector_size__(16)));
  typedef char __v16qi __attribute__((__vector_size__(16)));
  
  __m128i __attribute__((__always_inline__, __nodebug__))
  _mm_avg_epu8(__m128i a, __m128i b)
  {
return (__m128i)__builtin_ia32_pavgb128((__v16qi)a, (__v16qi)b);
  }
  
  __m128i __attribute__((__always_inline__, __nodebug__))
  _mm_avg_epu16(__m128i a, __m128i b)
  {
return (__m128i)__builtin_ia32_pavgw128((__v8hi)a, (__v8hi)b);
  }



  $ clang t.c
  /Users/mbraun/t.c:8:19: error: use of unknown builtin 
'__builtin_ia32_pavgb128'
[-Wimplicit-function-declaration]
return (__m128i)__builtin_ia32_pavgb128((__v16qi)a, (__v16qi)b);
^
  /Users/mbraun/t.c:8:10: error: invalid conversion between vector type 
'__m128i'
(vector of 2 'long long' values) and integer type 'int' of different 
size
return (__m128i)__builtin_ia32_pavgb128((__v16qi)a, (__v16qi)b);
   ^~~~
  /Users/mbraun/t.c:14:19: error: use of unknown builtin 
'__builtin_ia32_pavgw128'
[-Wimplicit-function-declaration]
return (__m128i)__builtin_ia32_pavgw128((__v8hi)a, (__v8hi)b);
^
  /Users/mbraun/t.c:14:10: error: invalid conversion between vector type 
'__m128i'
(vector of 2 'long long' values) and integer type 'int' of different 
size
return (__m128i)__builtin_ia32_pavgw128((__v8hi)a, (__v8hi)b);
   ^~
  4 errors generated.


Repository:
  rL LLVM

https://reviews.llvm.org/D37562



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


[PATCH] D38113: OpenCL: Assume functions are convergent

2017-09-20 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
Herald added a subscriber: wdng.

This was done for CUDA functions in r261779, and for the same
reason this also needs to be done for OpenCL. An arbitrary
function could have a barrier() call in it, which in turn
requires the calling function to be convergent.


https://reviews.llvm.org/D38113

Files:
  include/clang/Basic/LangOptions.h
  lib/CodeGen/CGCall.cpp
  test/CodeGenOpenCL/convergent.cl

Index: test/CodeGenOpenCL/convergent.cl
===
--- test/CodeGenOpenCL/convergent.cl
+++ test/CodeGenOpenCL/convergent.cl
@@ -1,9 +1,19 @@
-// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck %s
+// RUN: %clang_cc1 -triple spir-unknown-unknown -emit-llvm %s -o - | opt -instnamer -S | FileCheck -enable-var-scope %s
+
+// This is initially assumed convergent, but can be deduced to not require it.
+
+// CHECK-LABEL: define spir_func void @non_convfun() local_unnamed_addr #0
+// CHECK: ret void
+__attribute__((noinline))
+void non_convfun(void) {
+  volatile int* p;
+  *p = 0;
+}
 
 void convfun(void) __attribute__((convergent));
-void non_convfun(void);
 void nodupfun(void) __attribute__((noduplicate));
 
+// External functions should be assumed convergent.
 void f(void);
 void g(void);
 
@@ -17,19 +27,23 @@
 //  non_convfun();
 //}
 //
-// CHECK: define spir_func void @test_merge_if(i32 %[[a:.+]])
-// CHECK: %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK-LABEL: define spir_func void @test_merge_if(i32 %a) local_unnamed_addr #1 {
+// CHECK: %[[tobool:.+]] = icmp eq i32 %a, 0
 // CHECK: br i1 %[[tobool]], label %[[if_end3_critedge:.+]], label %[[if_then:.+]]
+
 // CHECK: [[if_then]]:
 // CHECK: tail call spir_func void @f()
 // CHECK: tail call spir_func void @non_convfun()
 // CHECK: tail call spir_func void @g()
+
 // CHECK: br label %[[if_end3:.+]]
+
 // CHECK: [[if_end3_critedge]]:
 // CHECK: tail call spir_func void @non_convfun()
 // CHECK: br label %[[if_end3]]
+
 // CHECK: [[if_end3]]:
-// CHECK-LABEL: ret void
+// CHECK: ret void
 
 void test_merge_if(int a) {
   if (a) {
@@ -41,22 +55,22 @@
   }
 }
 
-// CHECK-DAG: declare spir_func void @f()
-// CHECK-DAG: declare spir_func void @non_convfun()
-// CHECK-DAG: declare spir_func void @g()
+// CHECK-DAG: declare spir_func void @f() local_unnamed_addr #2
+// CHECK-DAG: declare spir_func void @g() local_unnamed_addr #2
+
 
 // Test two if's are not merged.
-// CHECK: define spir_func void @test_no_merge_if(i32 %[[a:.+]])
-// CHECK:  %[[tobool:.+]] = icmp eq i32 %[[a]], 0
+// CHECK-LABEL: define spir_func void @test_no_merge_if(i32 %a) local_unnamed_addr #1
+// CHECK:  %[[tobool:.+]] = icmp eq i32 %a, 0
 // CHECK: br i1 %[[tobool]], label %[[if_end:.+]], label %[[if_then:.+]]
 // CHECK: [[if_then]]:
 // CHECK: tail call spir_func void @f()
 // CHECK-NOT: call spir_func void @convfun()
 // CHECK-NOT: call spir_func void @g()
 // CHECK: br label %[[if_end]]
 // CHECK: [[if_end]]:
 // CHECK:  %[[tobool_pr:.+]] = phi i1 [ true, %[[if_then]] ], [ false, %{{.+}} ]
-// CHECK:  tail call spir_func void @convfun() #[[attr5:.+]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4:.+]]
 // CHECK:  br i1 %[[tobool_pr]], label %[[if_then2:.+]], label %[[if_end3:.+]]
 // CHECK: [[if_then2]]:
 // CHECK: tail call spir_func void @g()
@@ -74,20 +88,20 @@
   }
 }
 
-// CHECK: declare spir_func void @convfun(){{[^#]*}} #[[attr2:[0-9]+]]
+// CHECK: declare spir_func void @convfun(){{[^#]*}} #2
 
 // Test loop is unrolled for convergent function.
-// CHECK-LABEL: define spir_func void @test_unroll()
-// CHECK:  tail call spir_func void @convfun() #[[attr5:[0-9]+]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
-// CHECK:  tail call spir_func void @convfun() #[[attr5]]
+// CHECK-LABEL: define spir_func void @test_unroll() local_unnamed_addr #1
+// CHECK:  tail call spir_func void @convfun() #[[attr4:[0-9]+]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
+// CHECK:  tail call spir_func void @convfun() #[[attr4]]
 // CHECK-LABEL:  ret void
 
 void test_unroll() {
@@ -101,7 +115,7 @@
 // CHECK: 

[PATCH] D38109: [fixup][Sema] Allow in C to define tags inside enumerations.

2017-09-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm


https://reviews.llvm.org/D38109



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


[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Submitted for review https://reviews.llvm.org/D38109 - [fixup][Sema] Allow in C 
to define tags inside enumerations.


Repository:
  rL LLVM

https://reviews.llvm.org/D37089



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


[PATCH] D38109: [fixup][Sema] Allow in C to define tags inside enumerations.

2017-09-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai created this revision.

Fix for too aggressive error err_type_defined_in_enum introduced in
r313386. Defining tags inside enumerations is prohibited in C++ but
allowed in C.


https://reviews.llvm.org/D38109

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/Sema/enum.c


Index: clang/test/Sema/enum.c
===
--- clang/test/Sema/enum.c
+++ clang/test/Sema/enum.c
@@ -125,9 +125,10 @@
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag 
type that does not match previous declaration}}
 
 // PR28903
+// In C it is valid to define tags inside enums.
 struct PR28903 {
   enum {
-PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at 
{{.*}})' cannot be defined in an enumeration}}
+PR28903_A = (enum {
   PR28903_B,
   PR28903_C = PR28903_B
 })0
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13916,7 +13916,8 @@
 Invalid = true;
   }
 
-  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+  if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition &&
+  DC->getDeclKind() == Decl::Enum) {
 Diag(New->getLocation(), diag::err_type_defined_in_enum)
   << Context.getTagDeclType(New);
 Invalid = true;


Index: clang/test/Sema/enum.c
===
--- clang/test/Sema/enum.c
+++ clang/test/Sema/enum.c
@@ -125,9 +125,10 @@
 typedef struct Color NewColor; // expected-error {{use of 'Color' with tag type that does not match previous declaration}}
 
 // PR28903
+// In C it is valid to define tags inside enums.
 struct PR28903 {
   enum {
-PR28903_A = (enum { // expected-error-re {{'enum PR28903::(anonymous at {{.*}})' cannot be defined in an enumeration}}
+PR28903_A = (enum {
   PR28903_B,
   PR28903_C = PR28903_B
 })0
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13916,7 +13916,8 @@
 Invalid = true;
   }
 
-  if (!Invalid && TUK == TUK_Definition && DC->getDeclKind() == Decl::Enum) {
+  if (!Invalid && getLangOpts().CPlusPlus && TUK == TUK_Definition &&
+  DC->getDeclKind() == Decl::Enum) {
 Diag(New->getLocation(), diag::err_type_defined_in_enum)
   << Context.getTagDeclType(New);
 Invalid = true;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Wei Mi via Phabricator via cfe-commits
wmi updated this revision to Diff 116107.
wmi added a comment.
Herald added a subscriber: eraman.

Address Eli's comments.


Repository:
  rL LLVM

https://reviews.llvm.org/D38046

Files:
  include/clang/Basic/TargetInfo.h
  lib/Basic/Targets.cpp
  lib/Basic/Targets/X86.h
  test/CodeGenCXX/atomic-inline.cpp
  test/OpenMP/atomic_capture_codegen.cpp
  test/OpenMP/atomic_read_codegen.c
  test/OpenMP/atomic_update_codegen.cpp
  test/OpenMP/atomic_write_codegen.c

Index: test/OpenMP/atomic_write_codegen.c
===
--- test/OpenMP/atomic_write_codegen.c
+++ test/OpenMP/atomic_write_codegen.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 // expected-no-diagnostics
 // REQUIRES: x86-registered-target
 #ifndef HEADER
Index: test/OpenMP/atomic_update_codegen.cpp
===
--- test/OpenMP/atomic_update_codegen.cpp
+++ test/OpenMP/atomic_update_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
Index: test/OpenMP/atomic_read_codegen.c
===
--- test/OpenMP/atomic_read_codegen.c
+++ test/OpenMP/atomic_read_codegen.c
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 // expected-no-diagnostics
 // REQUIRES: x86-registered-target
 #ifndef HEADER
Index: test/OpenMP/atomic_capture_codegen.cpp
===
--- test/OpenMP/atomic_capture_codegen.cpp
+++ test/OpenMP/atomic_capture_codegen.cpp
@@ -1,6 +1,6 @@
-// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -emit-pch -o %t %s
-// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -verify -triple x86_64-apple-darwin10 -target-cpu core2 -fopenmp -x c -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -x c -triple x86_64-apple-darwin10 -target-cpu core2 -include-pch %t -verify %s -emit-llvm -o - | FileCheck %s
 // expected-no-diagnostics
 #ifndef HEADER
 #define HEADER
Index: test/CodeGenCXX/atomic-inline.cpp
===
--- test/CodeGenCXX/atomic-inline.cpp
+++ test/CodeGenCXX/atomic-inline.cpp
@@ -0,0 +1,69 @@
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu | FileCheck %s
+// RUN: %clang_cc1 %s -std=c++11 -emit-llvm -o - -triple=x86_64-linux-gnu -target-cpu core2 | FileCheck %s --check-prefix=CORE2
+// Check the atomic code generation for cpu targets w/wo cx16 support.
+
+struct alignas(8) AM8 {
+  int f1, f2;
+};
+AM8 m8;
+AM8 load8() {
+  AM8 am;
+  // CHECK-LABEL: @_Z5load8v
+  // CHECK: load atomic i64, {{.*}} monotonic
+  // CORE2-LABEL: @_Z5load8v
+  // CORE2: load atomic i64, 

[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Wei Mi via Phabricator via cfe-commits
wmi added inline comments.



Comment at: lib/Basic/Targets/X86.h:898
+  MaxAtomicPromoteWidth = 64;
+  MaxAtomicInlineWidth = 64;
+}

efriedma wrote:
> wmi wrote:
> > efriedma wrote:
> > > I don't think we need to mess with MaxAtomicPromoteWidth?
> > > 
> > > Probably more intuitive to check "if (hasFeature" rather than "if 
> > > (!hasFeature".
> > > 
> > > Adding a dedicated hook for this seems a bit overkill, but I don't have a 
> > > better suggestion.
> > If 128 bits inline atomic is not supported, what is the point to promote 
> > atomic type to 128 bits?
> MaxAtomicPromoteWidth affects the ABI, so it can't vary based on the target 
> CPU.
That make senses. Thanks for the explanation.


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


r313831 - [MSan] Disable sanitization for __sanitizer_dtor_callback.

2017-09-20 Thread Matt Morehouse via cfe-commits
Author: morehouse
Date: Wed Sep 20 15:53:08 2017
New Revision: 313831

URL: http://llvm.org/viewvc/llvm-project?rev=313831=rev
Log:
[MSan] Disable sanitization for __sanitizer_dtor_callback.

Summary:
Eliminate unnecessary instrumentation at __sanitizer_dtor_callback
call sites.  Fixes https://github.com/google/sanitizers/issues/861.

Reviewers: eugenis, kcc

Reviewed By: eugenis

Subscribers: vitalybuka, llvm-commits, cfe-commits, hiraditya

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

Modified:
cfe/trunk/lib/CodeGen/CGClass.cpp
cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=313831=313830=313831=diff
==
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Sep 20 15:53:08 2017
@@ -1577,6 +1577,7 @@ namespace {
 
  static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
  CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope();
// Pass in void pointer and size of region as arguments to runtime
// function
llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),

Modified: cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp?rev=313831=313830=313831=diff
==
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp Wed Sep 20 15:53:08 
2017
@@ -55,16 +55,19 @@ Defaulted_Non_Trivial def_non_trivial;
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void


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


[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.

2017-09-20 Thread Matt Morehouse via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313831: [MSan] Disable sanitization for 
__sanitizer_dtor_callback. (authored by morehouse).

Changed prior to commit:
  https://reviews.llvm.org/D38063?vs=116100=116103#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38063

Files:
  cfe/trunk/lib/CodeGen/CGClass.cpp
  cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp
  llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll


Index: llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
===
--- llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
@@ -0,0 +1,16 @@
+; Verify that calls with !nosanitize are not instrumented by MSan.
+; RUN: opt < %s -msan -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @bar(i32 %x)
+
+define void @foo() {
+  call void @bar(i32 7), !nosanitize !{}
+  ret void
+}
+
+; CHECK-LABEL: define void @foo
+; CHECK-NOT: store i{{[0-9]+}} 0, {{.*}} @__msan_param_tls
+; CHECK: call void @bar
+; CHECK: ret void
Index: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction  = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast();
Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
  CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope();
// Pass in void pointer and size of region as arguments to runtime
// function
llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
Index: cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp
===
--- cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ cfe/trunk/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void


Index: llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
===
--- llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
+++ llvm/trunk/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
@@ -0,0 +1,16 @@
+; Verify that calls with !nosanitize are not instrumented by MSan.
+; RUN: opt < %s -msan -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @bar(i32 %x)
+
+define void @foo() {
+  call void @bar(i32 7), !nosanitize !{}
+  ret void
+}
+
+; CHECK-LABEL: define void @foo
+; CHECK-NOT: store i{{[0-9]+}} 0, {{.*}} @__msan_param_tls
+; CHECK: call void @bar
+; CHECK: ret void
Index: llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/trunk/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction  = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast();
Index: cfe/trunk/lib/CodeGen/CGClass.cpp
===
--- cfe/trunk/lib/CodeGen/CGClass.cpp
+++ cfe/trunk/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void 

[PATCH] D34512: Add preliminary Cross Translation Unit support library

2017-09-20 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin added a comment.

I'm OK with this going into the repo a is (although it is light on tests!), as 
long as we have an agreement that you'll be OK with iteration on both the 
interface and the implementation to handle real-world projects.

More specifically, for this to work well on large/complicated projects we'll 
need to:

- Move conflict resolution from index generation where it is now to query time 
so that clients can pick the best implementation of a function when multiple 
are found. This is important for projects that have multiple functions with the 
same name or that build the same file in multiple ways.
- Change function lookup from needing to traverse over the entire AST.
- Move away from a linear, flat-file index to something that can handle larger 
projects more efficiently.

For this last point, I suspect it will be good to adopt whatever Clangd ends up 
using to support indexing. (There has been some discussion of this relatively 
recently on the cfe-dev list.)


https://reviews.llvm.org/D34512



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


[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.

2017-09-20 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 116100.
morehouse added a comment.

- Add LLVM test.


https://reviews.llvm.org/D38063

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/test/Instrumentation/MemorySanitizer/call-nosanitize.ll


Index: llvm/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
@@ -0,0 +1,16 @@
+; Verify that calls with !nosanitize are not instrumented by MSan.
+; RUN: opt < %s -msan -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @bar(i32 %x)
+
+define void @foo() {
+  call void @bar(i32 7), !nosanitize !{}
+  ret void
+}
+
+; CHECK-LABEL: define void @foo
+; CHECK-NOT: store i{{[0-9]+}} 0, {{.*}} @__msan_param_tls
+; CHECK: call void @bar
+; CHECK: ret void
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction  = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast();
Index: clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
  CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope();
// Pass in void pointer and size of region as arguments to runtime
// function
llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),


Index: llvm/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
===
--- /dev/null
+++ llvm/test/Instrumentation/MemorySanitizer/call-nosanitize.ll
@@ -0,0 +1,16 @@
+; Verify that calls with !nosanitize are not instrumented by MSan.
+; RUN: opt < %s -msan -S | FileCheck %s
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+declare void @bar(i32 %x)
+
+define void @foo() {
+  call void @bar(i32 7), !nosanitize !{}
+  ret void
+}
+
+; CHECK-LABEL: define void @foo
+; CHECK-NOT: store i{{[0-9]+}} 0, {{.*}} @__msan_param_tls
+; CHECK: call void @bar
+; CHECK: ret void
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction  = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast();
Index: clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, 

[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313828: [MS Compat]Allow __interfaces to have properties. 
(authored by erichkeane).

Changed prior to commit:
  https://reviews.llvm.org/D38092?vs=116046=116097#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38092

Files:
  cfe/trunk/lib/Sema/SemaDeclCXX.cpp
  cfe/trunk/test/SemaCXX/ms-interface.cpp

Index: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
===
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp
@@ -143,7 +143,7 @@
 if (Lambda->capture_begin() == Lambda->capture_end())
   return false;
 
-return S->Diag(Lambda->getLocStart(), 
+return S->Diag(Lambda->getLocStart(),
diag::err_lambda_capture_default_arg);
   }
 }
@@ -276,18 +276,18 @@
   // Okay: add the default argument to the parameter
   Param->setDefaultArg(Arg);
 
-  // We have already instantiated this parameter; provide each of the 
+  // We have already instantiated this parameter; provide each of the
   // instantiations with the uninstantiated default argument.
   UnparsedDefaultArgInstantiationsMap::iterator InstPos
 = UnparsedDefaultArgInstantiations.find(Param);
   if (InstPos != UnparsedDefaultArgInstantiations.end()) {
 for (unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
   InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
-
+
 // We're done tracking this parameter's instantiations.
 UnparsedDefaultArgInstantiations.erase(InstPos);
   }
-  
+
   return false;
 }
 
@@ -524,8 +524,8 @@
   Invalid = false;
 }
   }
-  
-  // FIXME: If we knew where the '=' was, we could easily provide a fix-it 
+
+  // FIXME: If we knew where the '=' was, we could easily provide a fix-it
   // hint here. Alternatively, we could walk the type-source information
   // for NewParam to find the last source location in the type... but it
   // isn't worth the effort right now. This is the kind of test case that
@@ -535,7 +535,7 @@
   //   void g(int (*fp)(int) = );
   Diag(NewParam->getLocation(), DiagDefaultParamID)
 << NewParam->getDefaultArgRange();
-  
+
   // Look for the function declaration where the default argument was
   // actually written, which may be a declaration prior to Old.
   for (auto Older = PrevForDefaultArgs;
@@ -581,36 +581,36 @@
 //   or a definition for one of the following explicit specializations:
 // - the explicit specialization of a function template;
 // - the explicit specialization of a member function template;
-// - the explicit specialization of a member function of a class 
+// - the explicit specialization of a member function of a class
 //   template where the class template specialization to which the
-//   member function specialization belongs is implicitly 
+//   member function specialization belongs is implicitly
 //   instantiated.
 Diag(NewParam->getLocation(), diag::err_template_spec_default_arg)
   << (New->getTemplateSpecializationKind() ==TSK_ExplicitSpecialization)
   << New->getDeclName()
   << NewParam->getDefaultArgRange();
   } else if (New->getDeclContext()->isDependentContext()) {
 // C++ [dcl.fct.default]p6 (DR217):
-//   Default arguments for a member function of a class template shall 
-//   be specified on the initial declaration of the member function 
+//   Default arguments for a member function of a class template shall
+//   be specified on the initial declaration of the member function
 //   within the class template.
 //
-// Reading the tea leaves a bit in DR217 and its reference to DR205 
-// leads me to the conclusion that one cannot add default function 
-// arguments for an out-of-line definition of a member function of a 
+// Reading the tea leaves a bit in DR217 and its reference to DR205
+// leads me to the conclusion that one cannot add default function
+// arguments for an out-of-line definition of a member function of a
 // dependent type.
 int WhichKind = 2;
-if (CXXRecordDecl *Record 
+if (CXXRecordDecl *Record
   = dyn_cast(New->getDeclContext())) {
   if (Record->getDescribedClassTemplate())
 WhichKind = 0;
   else if (isa(Record))
 WhichKind = 1;
   else
 WhichKind = 2;
 }
-
-Diag(NewParam->getLocation(), 
+
+Diag(NewParam->getLocation(),
  diag::err_param_default_argument_member_template_redecl)
   << WhichKind
   << NewParam->getDefaultArgRange();
@@ -2148,7 +2148,7 @@
 return nullptr;
   }
 
-  if (EllipsisLoc.isValid() && 
+  if 

r313828 - [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via cfe-commits
Author: erichkeane
Date: Wed Sep 20 15:28:24 2017
New Revision: 313828

URL: http://llvm.org/viewvc/llvm-project?rev=313828=rev
Log:
[MS Compat]Allow __interfaces to have properties.

__interface types are allowed in MSVC to have "property" data members
(marked with declspec property). This patch alters Sema to allow property
data members.

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


Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/ms-interface.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=313828=313827=313828=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Sep 20 15:28:24 2017
@@ -143,7 +143,7 @@ namespace {
 if (Lambda->capture_begin() == Lambda->capture_end())
   return false;
 
-return S->Diag(Lambda->getLocStart(), 
+return S->Diag(Lambda->getLocStart(),
diag::err_lambda_capture_default_arg);
   }
 }
@@ -276,18 +276,18 @@ Sema::SetParamDefaultArgument(ParmVarDec
   // Okay: add the default argument to the parameter
   Param->setDefaultArg(Arg);
 
-  // We have already instantiated this parameter; provide each of the 
+  // We have already instantiated this parameter; provide each of the
   // instantiations with the uninstantiated default argument.
   UnparsedDefaultArgInstantiationsMap::iterator InstPos
 = UnparsedDefaultArgInstantiations.find(Param);
   if (InstPos != UnparsedDefaultArgInstantiations.end()) {
 for (unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
   InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
-
+
 // We're done tracking this parameter's instantiations.
 UnparsedDefaultArgInstantiations.erase(InstPos);
   }
-  
+
   return false;
 }
 
@@ -524,8 +524,8 @@ bool Sema::MergeCXXFunctionDecl(Function
   Invalid = false;
 }
   }
-  
-  // FIXME: If we knew where the '=' was, we could easily provide a fix-it 
+
+  // FIXME: If we knew where the '=' was, we could easily provide a fix-it
   // hint here. Alternatively, we could walk the type-source information
   // for NewParam to find the last source location in the type... but it
   // isn't worth the effort right now. This is the kind of test case that
@@ -535,7 +535,7 @@ bool Sema::MergeCXXFunctionDecl(Function
   //   void g(int (*fp)(int) = );
   Diag(NewParam->getLocation(), DiagDefaultParamID)
 << NewParam->getDefaultArgRange();
-  
+
   // Look for the function declaration where the default argument was
   // actually written, which may be a declaration prior to Old.
   for (auto Older = PrevForDefaultArgs;
@@ -581,9 +581,9 @@ bool Sema::MergeCXXFunctionDecl(Function
 //   or a definition for one of the following explicit specializations:
 // - the explicit specialization of a function template;
 // - the explicit specialization of a member function template;
-// - the explicit specialization of a member function of a class 
+// - the explicit specialization of a member function of a class
 //   template where the class template specialization to which the
-//   member function specialization belongs is implicitly 
+//   member function specialization belongs is implicitly
 //   instantiated.
 Diag(NewParam->getLocation(), diag::err_template_spec_default_arg)
   << (New->getTemplateSpecializationKind() 
==TSK_ExplicitSpecialization)
@@ -591,16 +591,16 @@ bool Sema::MergeCXXFunctionDecl(Function
   << NewParam->getDefaultArgRange();
   } else if (New->getDeclContext()->isDependentContext()) {
 // C++ [dcl.fct.default]p6 (DR217):
-//   Default arguments for a member function of a class template shall 
-//   be specified on the initial declaration of the member function 
+//   Default arguments for a member function of a class template shall
+//   be specified on the initial declaration of the member function
 //   within the class template.
 //
-// Reading the tea leaves a bit in DR217 and its reference to DR205 
-// leads me to the conclusion that one cannot add default function 
-// arguments for an out-of-line definition of a member function of a 
+// Reading the tea leaves a bit in DR217 and its reference to DR205
+// leads me to the conclusion that one cannot add default function
+// arguments for an out-of-line definition of a member function of a
 // dependent type.
 int WhichKind = 2;
-if (CXXRecordDecl *Record 
+if (CXXRecordDecl *Record
   = dyn_cast(New->getDeclContext())) {
   if (Record->getDescribedClassTemplate())
 WhichKind 

[PATCH] D35743: [clang-format] Adjust space around &/&& of structured bindings

2017-09-20 Thread Chih-Hung Hsieh via Phabricator via cfe-commits
chh updated this revision to Diff 116092.
chh edited the summary of this revision.

https://reviews.llvm.org/D35743

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

Index: unittests/Format/FormatTest.cpp
===
--- unittests/Format/FormatTest.cpp
+++ unittests/Format/FormatTest.cpp
@@ -11579,24 +11579,58 @@
   EXPECT_EQ("auto const volatile [a, b] = f();",
 format("auto  const   volatile[a, b] = f();"));
   EXPECT_EQ("auto [a, b, c] = f();", format("auto   [  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto & [a, b, c] = f();",
+  EXPECT_EQ("auto &[a, b, c] = f();",
 format("auto   &[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto && [a, b, c] = f();",
+  EXPECT_EQ("auto &&[a, b, c] = f();",
 format("auto   &&[  a  ,  b,c   ] = f();"));
-  EXPECT_EQ("auto const & [a, b] = f();", format("auto  const&[a, b] = f();"));
-  EXPECT_EQ("auto const volatile && [a, b] = f();",
+  EXPECT_EQ("auto const &[a, b] = f();", format("auto  const&[a, b] = f();"));
+  EXPECT_EQ("auto const volatile &&[a, b] = f();",
 format("auto  const  volatile  &&[a, b] = f();"));
-  EXPECT_EQ("auto && [a, b] = f();", format("auto  &&[a, b] = f();"));
+  EXPECT_EQ("auto const &&[a, b] = f();", format("auto  const   &&  [a, b] = f();"));
+  EXPECT_EQ("const auto &[a, b] = f();", format("const  auto  &  [a, b] = f();"));
+  EXPECT_EQ("const auto volatile &&[a, b] = f();",
+format("const  auto   volatile  &&[a, b] = f();"));
+  EXPECT_EQ("volatile const auto &&[a, b] = f();",
+format("volatile  const  auto   &&[a, b] = f();"));
+  EXPECT_EQ("const auto &&[a, b] = f();", format("const  auto  &&  [a, b] = f();"));
 
   // Make sure we don't mistake structured bindings for lambdas.
   verifyFormat("auto [a, b]{A * i};");
   verifyFormat("auto const [a, b]{A * i};");
-  verifyFormat("auto const && [a, b]{A * i};");
+  verifyFormat("auto const& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const&& [a1, b]{A * i};", getGoogleStyle());
+  verifyFormat("auto const &&[a2, b]{A * i};", getLLVMStyle());
+  verifyFormat("auto const & = y1;", getGoogleStyle());
+  verifyFormat("auto const & = y1;", getLLVMStyle());
+  verifyFormat("auto const  = y2;", getGoogleStyle());
+  verifyFormat("auto const  = y2;", getLLVMStyle());
+  verifyFormat("auto const  = y2;", getGoogleStyle());
+  verifyFormat("auto const *x1, *x2;", getGoogleStyle());
+  verifyFormat("auto const *x3, *x4;", getLLVMStyle());
+
+  EXPECT_EQ("for (const auto &&[a, b] : some_range) {\n}",
+format("for (const auto   &&   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto &[a, b] : some_range) {\n}",
+format("for (const auto   &   [a, b] : some_range) {\n}"));
+  EXPECT_EQ("for (const auto [a, b] : some_range) {\n}",
+format("for (const auto[a, b] : some_range) {\n}"));
+  EXPECT_EQ("auto [x, y](expr);", format("auto[x,y]  (expr);"));
+  EXPECT_EQ("auto &[x, y](expr);", format("auto  &  [x,y]  (expr);"));
+  EXPECT_EQ("auto &&[x, y](expr);", format("auto  &&  [x,y]  (expr);"));
+  EXPECT_EQ("auto const &[x, y](expr);", format("auto  const  &  [x,y]  (expr);"));
+  EXPECT_EQ("auto const &&[x, y](expr);", format("auto  const  &&  [x,y]  (expr);"));
+  EXPECT_EQ("auto [x, y]{expr};", format("auto[x,y] {expr};"));
+  EXPECT_EQ("auto const &[x, y]{expr};", format("auto  const  &  [x,y]  {expr};"));
+  EXPECT_EQ("auto const &&[x, y]{expr};", format("auto  const  &&  [x,y]  {expr};"));
 
   format::FormatStyle Spaces = format::getLLVMStyle();
   Spaces.SpacesInSquareBrackets = true;
   verifyFormat("auto [ a, b ] = f();", Spaces);
-  verifyFormat("auto && [ a, b ] = f();", Spaces);
+  verifyFormat("auto &&[ a, b ] = f();", Spaces);
+  verifyFormat("auto &[ a, b ] = f();", Spaces);
+  verifyFormat("auto const &&[ a, b ] = f();", Spaces);
+  verifyFormat("auto const &[ a, b ] = f();", Spaces);
 }
 
 } // end namespace
Index: lib/Format/TokenAnnotator.cpp
===
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -342,10 +342,10 @@
 bool ColonFound = false;
 
 unsigned BindingIncrease = 1;
-if (Left->is(TT_Unknown)) {
-  if (Left->isCppStructuredBinding(Style)) {
-Left->Type = TT_StructuredBindingLSquare;
-  } else if (StartsObjCMethodExpr) {
+if (Left->isCppStructuredBinding(Style)) {
+  Left->Type = TT_StructuredBindingLSquare;
+} else if (Left->is(TT_Unknown)) {
+  if (StartsObjCMethodExpr) {
 Left->Type = TT_ObjCMethodExpr;
   } else if (Style.Language == FormatStyle::LK_JavaScript && Parent &&
  Contexts.back().ContextKind == tok::l_brace &&
@@ -2513,6 +2513,14 @@
   TT_TemplateOpener));
   if ((Left.is(TT_TemplateOpener)) != 

r313827 - Give external linkage and mangling to lambdas inside inline variables and variable templates.

2017-09-20 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Wed Sep 20 15:17:55 2017
New Revision: 313827

URL: http://llvm.org/viewvc/llvm-project?rev=313827=rev
Log:
Give external linkage and mangling to lambdas inside inline variables and 
variable templates.

This implements the proposed approach in 
https://github.com/itanium-cxx-abi/cxx-abi/issues/33

Modified:
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/ItaniumMangle.cpp
cfe/trunk/lib/AST/Linkage.h
cfe/trunk/lib/Parse/ParseDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaLambda.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/CodeGenCXX/mangle-lambdas.cpp
cfe/trunk/test/SemaCXX/vartemplate-lambda.cpp
cfe/trunk/test/SemaTemplate/instantiate-static-var.cpp

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=313827=313826=313827=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Wed Sep 20 15:17:55 2017
@@ -676,10 +676,10 @@ LinkageComputer::getLVForNamespaceScopeD
 if (!LV.isVisibilityExplicit()) {
   // Use global type/value visibility as appropriate.
   Visibility globalVisibility;
-  if (computation == LVForValue) {
+  if ((computation & ~IgnoreTypeLinkageBit) == LVForValue) {
 globalVisibility = Context.getLangOpts().getValueVisibilityMode();
   } else {
-assert(computation == LVForType);
+assert((computation & ~IgnoreTypeLinkageBit) == LVForType);
 globalVisibility = Context.getLangOpts().getTypeVisibilityMode();
   }
   LV.mergeVisibility(globalVisibility, /*explicit*/ false);
@@ -719,7 +719,8 @@ LinkageComputer::getLVForNamespaceScopeD
 //
 // Note that we don't want to make the variable non-external
 // because of this, but unique-external linkage suits us.
-if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var)) {
+if (Context.getLangOpts().CPlusPlus && !isFirstInExternCContext(Var) &&
+!(computation & IgnoreTypeLinkageBit)) {
   LinkageInfo TypeLV = getLVForType(*Var->getType(), computation);
   if (!isExternallyVisible(TypeLV.getLinkage()))
 return LinkageInfo::uniqueExternal();
@@ -759,8 +760,8 @@ LinkageComputer::getLVForNamespaceScopeD
 // unique-external linkage, it's not legally usable from outside
 // this translation unit.  However, we should use the C linkage
 // rules instead for extern "C" declarations.
-if (Context.getLangOpts().CPlusPlus &&
-!Function->isInExternCContext()) {
+if (Context.getLangOpts().CPlusPlus && !Function->isInExternCContext() &&
+!(computation & IgnoreTypeLinkageBit)) {
   // Only look at the type-as-written. If this function has an auto-deduced
   // return type, we can't compute the linkage of that type because it 
could
   // require looking at the linkage of this function, and we don't need 
this
@@ -1122,8 +1123,18 @@ LinkageInfo LinkageComputer::getLVForClo
   // calculation determines the lambda has external linkage, it should be
   // downgraded to VisibleNoLinkage.
   if (ContextDecl) {
+auto *VD = dyn_cast(ContextDecl);
 if (isa(ContextDecl))
   DC = ContextDecl->getDeclContext()->getRedeclContext();
+else if (VD && VD->getType()->getContainedDeducedType())
+  // If the declaration has a deduced type, we need to skip querying the
+  // linkage and visibility of that type, because it might involve this
+  // closure type. The only effect of this is that we might give a lambda
+  // VisibleNoLinkage rather than NoLinkage when we don't strictly need to,
+  // which is benign.
+  return computeLVForDecl(
+  cast(ContextDecl),
+  LVComputationKind(computation | IgnoreTypeLinkageBit));
 else
   return getLVForDecl(cast(ContextDecl), computation);
   }

Modified: cfe/trunk/lib/AST/ItaniumMangle.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ItaniumMangle.cpp?rev=313827=313826=313827=diff
==
--- cfe/trunk/lib/AST/ItaniumMangle.cpp (original)
+++ cfe/trunk/lib/AST/ItaniumMangle.cpp Wed Sep 20 15:17:55 2017
@@ -1691,10 +1691,16 @@ void CXXNameMangler::mangleLambda(const
   // to emit that last part of the prefix here.
   if (Decl *Context = Lambda->getLambdaContextDecl()) {
 if ((isa(Context) || isa(Context)) &&
-Context->getDeclContext()->isRecord()) {
+!isa(Context)) {
+  // FIXME: 'inline auto [a, b] = []{ return ... };' does not get a
+  // reasonable mangling here.
   if (const IdentifierInfo *Name
 = cast(Context)->getIdentifier()) {
 mangleSourceName(Name);
+const TemplateArgumentList *TemplateArgs = nullptr;
+if (const TemplateDecl *TD =
+isTemplate(cast(Context), TemplateArgs))
+  

[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.

2017-09-20 Thread Evgenii Stepanov via Phabricator via cfe-commits
eugenis accepted this revision.
eugenis added a comment.
This revision is now accepted and ready to land.

Please also add a tiny LLVM test that call instructions with nosanitize 
metadata are not instrumented.


https://reviews.llvm.org/D38063



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


Re: [clang-tools-extra] r313752 - [clang-tidy] Fix linkage-related compiler errors in clang-tidy tests

2017-09-20 Thread Richard Smith via cfe-commits
Thank you!

On 20 September 2017 at 05:16, Alexander Kornienko via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: alexfh
> Date: Wed Sep 20 05:16:35 2017
> New Revision: 313752
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313752=rev
> Log:
> [clang-tidy] Fix linkage-related compiler errors in clang-tidy tests
>
> Modified:
> clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
> clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
>
> Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-
> algorithm.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/misc-inefficient-algorithm.cpp?rev=
> 313752=313751=313752=diff
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
> Wed Sep 20 05:16:35 2017
> @@ -43,19 +43,23 @@ template  struct
>
>  template > struct multiset : set Cmp> {};
>
> -template  FwIt find(FwIt, FwIt, const K &);
> +template 
> +FwIt find(FwIt, FwIt end, const K &) { return end; }
>
>  template 
> -FwIt find(FwIt, FwIt, const K &, Cmp);
> +FwIt find(FwIt, FwIt end, const K &, Cmp) { return end; }
>
> -template  FwIt find_if(FwIt, FwIt, Pred);
> +template 
> +FwIt find_if(FwIt, FwIt end, Pred) { return end; }
>
> -template  FwIt count(FwIt, FwIt, const K &);
> +template 
> +unsigned count(FwIt, FwIt, const K &) { return 0; }
>
> -template  FwIt lower_bound(FwIt, FwIt, const K
> &);
> +template 
> +FwIt lower_bound(FwIt, FwIt end, const K &) { return end; }
>
>  template 
> -FwIt lower_bound(FwIt, FwIt, const K &, Ord);
> +FwIt lower_bound(FwIt, FwIt end, const K &, Ord) { return end; }
>  }
>
>  #define FIND_IN_SET(x) find(x.begin(), x.end(), 10)
>
> Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/test/clang-tidy/misc-move-const-arg.cpp?rev=313752&
> r1=313751=313752=diff
> 
> ==
> --- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
> (original)
> +++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp Wed
> Sep 20 05:16:35 2017
> @@ -10,7 +10,9 @@ template  struct remove_re
>  template  struct remove_reference<_Tp &&> { typedef _Tp
> type; };
>
>  template 
> -constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t);
> +constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t) {
> +  return static_cast::type &&>(__t);
> +}
>
>  } // namespace std
>
>
>
> ___
> 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


[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added inline comments.



Comment at: lib/Basic/Targets/X86.h:898
+  MaxAtomicPromoteWidth = 64;
+  MaxAtomicInlineWidth = 64;
+}

wmi wrote:
> efriedma wrote:
> > I don't think we need to mess with MaxAtomicPromoteWidth?
> > 
> > Probably more intuitive to check "if (hasFeature" rather than "if 
> > (!hasFeature".
> > 
> > Adding a dedicated hook for this seems a bit overkill, but I don't have a 
> > better suggestion.
> If 128 bits inline atomic is not supported, what is the point to promote 
> atomic type to 128 bits?
MaxAtomicPromoteWidth affects the ABI, so it can't vary based on the target CPU.


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: lib/Sema/SemaDeclCXX.cpp:2871
+  InvalidDecl =
+  (DS.getStorageClassSpec() == DeclSpec::SCS_typedef || MSPropertyAttr)
+  ? 0

erichkeane wrote:
> Note: Clang format did this craziness... I'm open to whatever format you guys 
> would prefer.
Maybe this would be better expressed in an if /else if chain like:
  if (!isFunc && (DS.getStorageClassSpec() == SCS_typedef || MSPropertyAttr))
InvalidDecl = 0;
  else if (!isFunc)
InvalidDecl = 1;
...


https://reviews.llvm.org/D38092



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


[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Wei Mi via Phabricator via cfe-commits
wmi added inline comments.



Comment at: lib/Basic/Targets/X86.h:898
+  MaxAtomicPromoteWidth = 64;
+  MaxAtomicInlineWidth = 64;
+}

efriedma wrote:
> I don't think we need to mess with MaxAtomicPromoteWidth?
> 
> Probably more intuitive to check "if (hasFeature" rather than "if 
> (!hasFeature".
> 
> Adding a dedicated hook for this seems a bit overkill, but I don't have a 
> better suggestion.
If 128 bits inline atomic is not supported, what is the point to promote atomic 
type to 128 bits?


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


[PATCH] D38101: [Sema] Diagnose tautological comparison with type's min/max values

2017-09-20 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added a project: clang.

Currently, clang only diagnoses completely out-of-range comparisons (e.g. 
`char` and constant `300`),
and comparisons of unsigned and `0`. But gcc also does diagnose the comparisons 
with the
`std::numeric_limits<>::max()` / `std::numeric_limits<>::min()` so to speak

I don't really like this code, but given the previous feedback in 
https://reviews.llvm.org/D37629,
i decided to do it in the most simple way possible for now, and change it given 
on review feedback.

Finally Fixes https://bugs.llvm.org/show_bug.cgi?id=34147
Continuation of https://reviews.llvm.org/D37565


Repository:
  rL LLVM

https://reviews.llvm.org/D38101

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaChecking.cpp
  test/Sema/outof-range-constant-compare.c

Index: test/Sema/outof-range-constant-compare.c
===
--- test/Sema/outof-range-constant-compare.c
+++ test/Sema/outof-range-constant-compare.c
@@ -102,6 +102,7 @@
   return 1;
 
 short s = value();
+
 if (s == 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always false}}
 return 0;
 if (s != 0x1234567812345678L) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
@@ -128,6 +129,112 @@
 if (0x1234567812345678L >= s) // expected-warning {{comparison of constant 1311768465173141112 with expression of type 'short' is always true}}
 return 0;
 
+if (s == 32767)
+return 0;
+if (s != 32767)
+return 0;
+if (s < 32767)
+return 0;
+if (s <= 32767) // expected-warning {{comparison 'short' <= 32767 is always true}}
+return 0;
+if (s > 32767) // expected-warning {{comparison 'short' > 32767 is always false}}
+return 0;
+if (s >= 32767)
+return 0;
+
+if (32767 == s)
+return 0;
+if (32767 != s)
+return 0;
+if (32767 < s) // expected-warning {{comparison 32767 < 'short' is always false}}
+return 0;
+if (32767 <= s)
+return 0;
+if (32767 > s)
+return 0;
+if (32767 >= s) // expected-warning {{comparison 32767 >= 'short' is always true}}
+return 0;
+
+// FIXME: assumes two's complement
+if (s == -32768)
+return 0;
+if (s != -32768)
+return 0;
+if (s < -32768) // expected-warning {{comparison 'short' < -32768 is always false}}
+return 0;
+if (s <= -32768)
+return 0;
+if (s > -32768)
+return 0;
+if (s >= -32768) // expected-warning {{comparison 'short' >= -32768 is always true}}
+return 0;
+
+if (-32768 == s)
+return 0;
+if (-32768 != s)
+return 0;
+if (-32768 < s)
+return 0;
+if (-32768 <= s) // expected-warning {{comparison -32768 <= 'short' is always true}}
+return 0;
+if (-32768 > s) // expected-warning {{comparison -32768 > 'short' is always false}}
+return 0;
+if (-32768 >= s)
+return 0;
+
+if (s == 32767UL)
+return 0;
+if (s != 32767UL)
+return 0;
+if (s < 32767UL)
+return 0;
+if (s <= 32767UL) // expected-warning {{comparison 'short' <= 32767 is always true}}
+return 0;
+if (s > 32767UL) // expected-warning {{comparison 'short' > 32767 is always false}}
+return 0;
+if (s >= 32767UL)
+return 0;
+
+if (32767UL == s)
+return 0;
+if (32767UL != s)
+return 0;
+if (32767UL < s) // expected-warning {{comparison 32767 < 'short' is always false}}
+return 0;
+if (32767UL <= s)
+return 0;
+if (32767UL > s)
+return 0;
+if (32767UL >= s) // expected-warning {{comparison 32767 >= 'short' is always true}}
+return 0;
+
+// FIXME: assumes two's complement
+if (s == -32768L)
+return 0;
+if (s != -32768L)
+return 0;
+if (s < -32768L) // expected-warning {{comparison 'short' < -32768 is always false}}
+return 0;
+if (s <= -32768L)
+return 0;
+if (s > -32768L)
+return 0;
+if (s >= -32768L) // expected-warning {{comparison 'short' >= -32768 is always true}}
+return 0;
+
+if (-32768L == s)
+return 0;
+if (-32768L != s)
+return 0;
+if (-32768L < s)
+return 0;
+if (-32768L <= s) // expected-warning {{comparison -32768 <= 'short' is always true}}
+return 0;
+if (-32768L > s) // expected-warning {{comparison -32768 > 'short' is always false}}
+return 0;
+if (-32768L >= s)
+return 0;
+
 long l = value();
 if (l == 0x1234567812345678L)
 return 0;
@@ -208,6 +315,60 @@
 if (0xUL >= un)
 return 0;
 
+unsigned short us = value();
+
+if (us 

[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313820: [NVPTX] Implemented shfl.sync instruction and 
supporting intrinsics/builtins. (authored by tra).

Changed prior to commit:
  https://reviews.llvm.org/D38090?vs=116047=116073#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38090

Files:
  cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
  cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
  cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
  cfe/trunk/test/CodeGen/builtins-nvptx.c
  llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
  llvm/trunk/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll

Index: llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
===
--- llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
+++ llvm/trunk/include/llvm/IR/IntrinsicsNVVM.td
@@ -3736,4 +3736,48 @@
   Intrinsic<[llvm_float_ty], [llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
 [IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.idx.f32">,
   GCCBuiltin<"__nvvm_shfl_idx_f32">;
+
+// Synchronizing shfl variants available in CUDA-9.
+// On sm_70 these don't have to be convergent, so we may eventually want to
+// implement non-convergent variant of this intrinsic.
+
+// shfl.sync.down.b32 dest, threadmask, val, offset , mask_and_clamp
+def int_nvvm_shfl_sync_down_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.down.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_down_i32">;
+def int_nvvm_shfl_sync_down_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.down.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_down_f32">;
+
+// shfl.sync.up.b32 dest, threadmask, val, offset, mask_and_clamp
+def int_nvvm_shfl_sync_up_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.up.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_up_i32">;
+def int_nvvm_shfl_sync_up_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.up.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_up_f32">;
+
+// shfl.sync.bfly.b32 dest, threadmask, val, offset, mask_and_clamp
+def int_nvvm_shfl_sync_bfly_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.bfly.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_bfly_i32">;
+def int_nvvm_shfl_sync_bfly_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.bfly.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_bfly_f32">;
+
+// shfl.sync.idx.b32 dest, threadmask, val, lane, mask_and_clamp
+def int_nvvm_shfl_sync_idx_i32 :
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.idx.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_idx_i32">;
+def int_nvvm_shfl_sync_idx_f32 :
+  Intrinsic<[llvm_float_ty], [llvm_i32_ty, llvm_float_ty, llvm_i32_ty, llvm_i32_ty],
+[IntrNoMem, IntrConvergent], "llvm.nvvm.shfl.sync.idx.f32">,
+  GCCBuiltin<"__nvvm_shfl_sync_idx_f32">;
 }
Index: llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll
===
--- llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll
+++ llvm/trunk/test/CodeGen/NVPTX/shfl-sync.ll
@@ -0,0 +1,94 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 | FileCheck %s
+
+declare i32 @llvm.nvvm.shfl.sync.down.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.down.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.up.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.up.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.bfly.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.idx.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.idx.f32(float, i32, i32, i32)
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rrr
+define i32 @shfl.sync.rrr(i32 %mask, i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.irr
+define i32 @shfl.sync.irr(i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: 

r313820 - [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via cfe-commits
Author: tra
Date: Wed Sep 20 14:23:07 2017
New Revision: 313820

URL: http://llvm.org/viewvc/llvm-project?rev=313820=rev
Log:
[NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

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

Added:
cfe/trunk/test/CodeGen/builtins-nvptx-ptx60.cu
Modified:
cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
cfe/trunk/test/CodeGen/builtins-nvptx.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def?rev=313820=313819=313820=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsNVPTX.def Wed Sep 20 14:23:07 2017
@@ -390,6 +390,15 @@ BUILTIN(__nvvm_shfl_bfly_f32, "ffii", ""
 BUILTIN(__nvvm_shfl_idx_i32, "", "")
 BUILTIN(__nvvm_shfl_idx_f32, "ffii", "")
 
+TARGET_BUILTIN(__nvvm_shfl_sync_down_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_down_f32, "fUifii", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_up_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_up_f32, "fUifii", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_bfly_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_bfly_f32, "fUifii", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_idx_i32, "iU", "", "ptx60")
+TARGET_BUILTIN(__nvvm_shfl_sync_idx_f32, "fUifii", "", "ptx60")
+
 // Membar
 
 BUILTIN(__nvvm_membar_cta, "v", "")

Modified: cfe/trunk/lib/Driver/ToolChains/Cuda.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Cuda.cpp?rev=313820=313819=313820=diff
==
--- cfe/trunk/lib/Driver/ToolChains/Cuda.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Cuda.cpp Wed Sep 20 14:23:07 2017
@@ -507,11 +507,17 @@ void CudaToolChain::addClangTargetOption
   CC1Args.push_back("-mlink-cuda-bitcode");
   CC1Args.push_back(DriverArgs.MakeArgString(LibDeviceFile));
 
-  // Libdevice in CUDA-7.0 requires PTX version that's more recent
-  // than LLVM defaults to. Use PTX4.2 which is the PTX version that
-  // came with CUDA-7.0.
-  CC1Args.push_back("-target-feature");
-  CC1Args.push_back("+ptx42");
+  if (CudaInstallation.version() >= CudaVersion::CUDA_90) {
+// CUDA-9 uses new instructions that are only available in PTX6.0
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+ptx60");
+  } else {
+// Libdevice in CUDA-7.0 requires PTX version that's more recent
+// than LLVM defaults to. Use PTX4.2 which is the PTX version that
+// came with CUDA-7.0.
+CC1Args.push_back("-target-feature");
+CC1Args.push_back("+ptx42");
+  }
 }
 
 void CudaToolChain::AddCudaIncludeArgs(const ArgList ,

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=313820=313819=313820=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Wed Sep 20 14:23:07 2017
@@ -92,6 +92,74 @@ __MAKE_SHUFFLES(__shfl_xor, __nvvm_shfl_
 
 #endif // !defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300
 
+// __shfl_sync_* variants available in CUDA-9
+#if CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ >= 300)
+#pragma push_macro("__MAKE_SYNC_SHUFFLES")
+#define __MAKE_SYNC_SHUFFLES(__FnName, __IntIntrinsic, __FloatIntrinsic,   
\
+ __Mask)   
\
+  inline __device__ int __FnName(unsigned int __mask, int __val, int __offset, 
\
+ int __width = warpSize) { 
\
+return __IntIntrinsic(__mask, __val, __offset, 
\
+  ((warpSize - __width) << 8) | (__Mask)); 
\
+  }
\
+  inline __device__ float __FnName(unsigned int __mask, float __val,   
\
+   int __offset, int __width = warpSize) { 
\
+return __FloatIntrinsic(__mask, __val, __offset,   
\
+((warpSize - __width) << 8) | (__Mask));   
\
+  }
\
+  inline __device__ unsigned int __FnName(unsigned int __mask, 
\
+  unsigned int __val, int __offset,
\
+  int __width = warpSize) {
\
+return static_cast(  
\
+::__FnName(__mask, 

[PATCH] D38063: [MSan] Disable sanitization for __sanitizer_dtor_callback.

2017-09-20 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse updated this revision to Diff 116072.
morehouse added a comment.

- Add test case.
- Use SanitizerScope.


https://reviews.llvm.org/D38063

Files:
  clang/lib/CodeGen/CGClass.cpp
  clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction  = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast();
Index: clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
  CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope();
// Pass in void pointer and size of region as arguments to runtime
// function
llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),


Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2588,6 +2588,7 @@
 
   void visitCallSite(CallSite CS) {
 Instruction  = *CS.getInstruction();
+if (I.getMetadata("nosanitize")) return;
 assert((CS.isCall() || CS.isInvoke()) && "Unknown type of CallSite");
 if (CS.isCall()) {
   CallInst *Call = cast();
Index: clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
===
--- clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
+++ clang/test/CodeGenCXX/sanitize-dtor-callback.cpp
@@ -55,16 +55,19 @@
 // to confirm that all invoked dtors have member poisoning
 // instrumentation inserted.
 // CHECK-LABEL: define {{.*}}SimpleD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}InlinedD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
 
 // CHECK-LABEL: define {{.*}}Defaulted_Non_TrivialD2Ev
+// CHECK-NOT: store i{{[0-9]+}} 0, {{.*}}@__msan_param_tls
 // CHECK: call void @__sanitizer_dtor_callback
 // CHECK-NOT: call void @__sanitizer_dtor_callback
 // CHECK: ret void
Index: clang/lib/CodeGen/CGClass.cpp
===
--- clang/lib/CodeGen/CGClass.cpp
+++ clang/lib/CodeGen/CGClass.cpp
@@ -1577,6 +1577,7 @@
 
  static void EmitSanitizerDtorCallback(CodeGenFunction , llvm::Value *Ptr,
  CharUnits::QuantityType PoisonSize) {
+   CodeGenFunction::SanitizerScope SanScope();
// Pass in void pointer and size of region as arguments to runtime
// function
llvm::Value *Args[] = {CGF.Builder.CreateBitCast(Ptr, CGF.VoidPtrTy),
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38046: [Atomic][X8664] set max atomic inline/promote width according to the target

2017-09-20 Thread Eli Friedman via Phabricator via cfe-commits
efriedma added a comment.

Needs testcase.




Comment at: lib/Basic/Targets/X86.h:898
+  MaxAtomicPromoteWidth = 64;
+  MaxAtomicInlineWidth = 64;
+}

I don't think we need to mess with MaxAtomicPromoteWidth?

Probably more intuitive to check "if (hasFeature" rather than "if (!hasFeature".

Adding a dedicated hook for this seems a bit overkill, but I don't have a 
better suggestion.


Repository:
  rL LLVM

https://reviews.llvm.org/D38046



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


[PATCH] D38060: Remove offset size check in nullptr arithmetic handling

2017-09-20 Thread Andy Kaylor via Phabricator via cfe-commits
andrew.w.kaylor closed this revision.
andrew.w.kaylor added a comment.

This was committed as r313784.  I put the wrong differential revision number in 
the comment for that check-in.


https://reviews.llvm.org/D38060



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


[libclc] r313810 - Implement cl_khr_int64_base_atomics builtins

2017-09-20 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Sep 20 13:42:14 2017
New Revision: 313810

URL: http://llvm.org/viewvc/llvm-project?rev=313810=rev
Log:
Implement cl_khr_int64_base_atomics builtins

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 
Tested-by: Aaron Watry 

Added:
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_xchg.h
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_add.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_cmpxchg.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_dec.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_inc.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_sub.cl
libclc/trunk/generic/lib/cl_khr_int64_base_atomics/atom_xchg.cl
Modified:
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h?rev=313810=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_add.h Wed 
Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_add(volatile global long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile global unsigned long 
*p, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_add(volatile local long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_add(volatile local unsigned long 
*p, unsigned long val);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h?rev=313810=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_cmpxchg.h 
Wed Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile global long *p, long cmp, 
long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile global unsigned 
long *p, unsigned long cmp, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_cmpxchg(volatile local long *p, long cmp, 
long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_cmpxchg(volatile local unsigned 
long *p, unsigned long cmp, unsigned long val);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h?rev=313810=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_dec.h Wed 
Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile global long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile global unsigned long 
*p);
+_CLC_OVERLOAD _CLC_DECL long atom_dec(volatile local long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_dec(volatile local unsigned long 
*p);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h?rev=313810=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_inc.h Wed 
Sep 20 13:42:14 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile global long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile global unsigned long 
*p);
+_CLC_OVERLOAD _CLC_DECL long atom_inc(volatile local long *p);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_inc(volatile local unsigned long 
*p);

Added: libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_base_atomics/atom_sub.h?rev=313810=auto

[libclc] r313811 - Implement cl_khr_int64_extended_atomics builtins

2017-09-20 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Sep 20 13:42:19 2017
New Revision: 313811

URL: http://llvm.org/viewvc/llvm-project?rev=313811=rev
Log:
Implement cl_khr_int64_extended_atomics builtins

Signed-off-by: Jan Vesely 
Reviewed-by: Aaron Watry 
Tested-by: Aaron Watry 

Added:
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/
libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_max.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_min.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_or.h
libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_xor.h
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_and.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_max.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_min.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_or.cl
libclc/trunk/generic/lib/cl_khr_int64_extended_atomics/atom_xor.cl
Modified:
libclc/trunk/amdgcn/lib/SOURCES
libclc/trunk/generic/include/clc/clc.h
libclc/trunk/generic/lib/SOURCES

Modified: libclc/trunk/amdgcn/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/SOURCES?rev=313811=313810=313811=diff
==
--- libclc/trunk/amdgcn/lib/SOURCES (original)
+++ libclc/trunk/amdgcn/lib/SOURCES Wed Sep 20 13:42:19 2017
@@ -1,3 +1,4 @@
+cl_khr_int64_extended_atomics/minmax_helpers.ll
 math/ldexp.cl
 mem_fence/fence.cl
 mem_fence/waitcnt.ll

Added: libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll?rev=313811=auto
==
--- libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll 
(added)
+++ libclc/trunk/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll Wed 
Sep 20 13:42:19 2017
@@ -0,0 +1,47 @@
+define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umin_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_min_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile min i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umin_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umin i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_max_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umax_global_8(i64 addrspace(1)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i64 addrspace(1)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_max_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile max i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}
+
+define i64 @__clc__sync_fetch_and_umax_local_8(i64 addrspace(3)* nocapture 
%ptr, i64 %value) nounwind alwaysinline {
+entry:
+  %0 = atomicrmw volatile umax i64 addrspace(3)* %ptr, i64 %value seq_cst
+  ret i64 %0
+}

Added: libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h?rev=313811=auto
==
--- libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h 
(added)
+++ libclc/trunk/generic/include/clc/cl_khr_int64_extended_atomics/atom_and.h 
Wed Sep 20 13:42:19 2017
@@ -0,0 +1,4 @@
+_CLC_OVERLOAD _CLC_DECL long atom_and(volatile global long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_and(volatile global unsigned long 
*p, unsigned long val);
+_CLC_OVERLOAD _CLC_DECL long atom_and(volatile local long *p, long val);
+_CLC_OVERLOAD _CLC_DECL unsigned long atom_and(volatile local unsigned long 

[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Alberto Magni via Phabricator via cfe-commits
alberto_magni added a comment.

Yes, restricting the error to C++ would work. Many thanks.


Repository:
  rL LLVM

https://reviews.llvm.org/D37089



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


Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Alex L via cfe-commits
Perfect, thanks!

On 20 September 2017 at 20:33, Ilya Biryukov  wrote:

> Fixed by r313801.
> Sorry for all the trouble.
>
> On Wed, Sep 20, 2017 at 9:22 PM, Ilya Biryukov 
> wrote:
>
>> I think I know what's wrong. I've already seen those failures. std::mutex
>> gets destroyed before threads waiting on it are joined.
>> Will submit a fix shortly.
>>
>> On Wed, Sep 20, 2017 at 8:22 PM, Alex L  wrote:
>>
>>> This commit causes the formatting.test to fail on macOS with an uncaught
>>> exception:
>>>
>>> libc++abi.dylib: terminating with uncaught exception of type
>>> std::__1::system_error: mutex lock failed: Invalid argument
>>> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA
>>> _check/35642/
>>>
>>> I'm still looking into it. It doesn't look like the sanitizers are
>>> reporting anything suspicious. Do you by any chance know what went wrong?
>>> If it will turn out to be a macOS only thing it might make sense to
>>> XFAIL formatting.test until the issue is resolved.
>>>
>>> Thanks,
>>> Alex
>>>
>>> On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
>>> cfe-commits@lists.llvm.org> wrote:
>>>
 Author: ibiryukov
 Date: Wed Sep 20 05:58:55 2017
 New Revision: 313754

 URL: http://llvm.org/viewvc/llvm-project?rev=313754=rev
 Log:
 [clangd] Serialize onDiagnosticsReady callbacks for the same file.

 Summary:
 Calls to onDiagnosticsReady were done concurrently before. This
 sometimes
 led to older versions of diagnostics being reported to the user after
 the newer versions.

 Reviewers: klimek, bkramer, krasimir

 Reviewed By: klimek

 Subscribers: cfe-commits

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

 Modified:
 clang-tools-extra/trunk/clangd/ClangdServer.cpp
 clang-tools-extra/trunk/clangd/ClangdServer.h
 clang-tools-extra/trunk/clangd/DraftStore.h
 clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

 Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clangd/ClangdServer.cpp?rev=313754=313753=313754=diff
 
 ==
 --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
 +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20
 05:58:55 2017
 @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
  auto Diags = DeferredRebuild.get();
  if (!Diags)
return; // A new reparse was requested before this one completed.
 +
 +// We need to serialize access to resulting diagnostics to avoid
 calling
 +// `onDiagnosticsReady` in the wrong order.
 +std::lock_guard DiagsLock(DiagnosticsMutex);
 +DocVersion  =
 ReportedDiagnosticVersions[FileStr];
 +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
 +// implementation diagnostics will not be reported after version
 counters'
 +// overflow. This should not happen in practice, since DocVersion
 is a
 +// 64-bit unsigned integer.
 +if (Version < LastReportedDiagsVersion)
 +  return;
 +LastReportedDiagsVersion = Version;
 +
  DiagConsumer.onDiagnosticsReady(FileStr,
  make_tagged(std::move(*Diags),
 Tag));
};

 Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clangd/ClangdServer.h?rev=313754=313753=313754=diff
 
 ==
 --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
 +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55
 2017
 @@ -284,6 +284,13 @@ private:
// ClangdServer
ClangdScheduler WorkScheduler;
bool SnippetCompletions;
 +
 +  /// Used to serialize diagnostic callbacks.
 +  /// FIXME(ibiryukov): get rid of an extra map and put all version
 counters
 +  /// into CppFile.
 +  std::mutex DiagnosticsMutex;
 +  /// Maps from a filename to the latest version of reported
 diagnostics.
 +  llvm::StringMap ReportedDiagnosticVersions;
  };

  } // namespace clangd

 Modified: clang-tools-extra/trunk/clangd/DraftStore.h
 URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
 clangd/DraftStore.h?rev=313754=313753=313754=diff
 
 ==
 --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
 +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55
 2017
 @@ -13,6 +13,7 @@
  #include "Path.h"
  #include 

[PATCH] D35796: [analyzer] Delete with non-virtual destructor check

2017-09-20 Thread Reka Kovacs via Phabricator via cfe-commits
rnkovacs updated this revision to Diff 116060.
rnkovacs added a comment.

- Accidentally left-in comment removed.
- Checker file clang-formatted.


https://reviews.llvm.org/D35796

Files:
  include/clang/StaticAnalyzer/Checkers/Checkers.td
  lib/StaticAnalyzer/Checkers/CMakeLists.txt
  lib/StaticAnalyzer/Checkers/DeleteWithNonVirtualDtorChecker.cpp
  test/Analysis/DeleteWithNonVirtualDtor.cpp

Index: test/Analysis/DeleteWithNonVirtualDtor.cpp
===
--- /dev/null
+++ test/Analysis/DeleteWithNonVirtualDtor.cpp
@@ -0,0 +1,187 @@
+// RUN: %clang_cc1 -analyze -analyzer-checker=alpha.cplusplus.DeleteWithNonVirtualDtor -std=c++11 -verify -analyzer-output=text %s
+
+struct Virtual {
+  virtual ~Virtual() {}
+};
+
+struct VDerived : public Virtual {};
+
+struct NonVirtual {
+  ~NonVirtual() {}
+};
+
+struct NVDerived : public NonVirtual {};
+struct NVDoubleDerived : public NVDerived {};
+
+struct Base {
+  virtual void destroy() = 0;
+};
+
+class PrivateDtor final : public Base {
+public:
+  void destroy() { delete this; }
+private:
+  ~PrivateDtor() {}
+};
+
+struct ImplicitNV {
+  virtual void f();
+};
+
+struct ImplicitNVDerived : public ImplicitNV {};
+
+NVDerived *get();
+
+NonVirtual *create() {
+  NonVirtual *x = new NVDerived(); // expected-note{{Conversion from derived to base happened here}}
+  return x;
+}
+
+void sink(NonVirtual *x) {
+  delete x; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void sinkCast(NonVirtual *y) {
+  delete reinterpret_cast(y);
+}
+
+void sinkParamCast(NVDerived *z) {
+  delete z;
+}
+
+void singleDerived() {
+  NonVirtual *sd;
+  sd = new NVDerived(); // expected-note{{Conversion from derived to base happened here}}
+  delete sd; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void singleDerivedArr() {
+  NonVirtual *sda = new NVDerived[5]; // expected-note{{Conversion from derived to base happened here}}
+  delete[] sda; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void doubleDerived() {
+  NonVirtual *dd = new NVDoubleDerived(); // expected-note{{Conversion from derived to base happened here}}
+  delete (dd); // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void assignThroughFunction() {
+  NonVirtual *atf = get(); // expected-note{{Conversion from derived to base happened here}}
+  delete atf; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void assignThroughFunction2() {
+  NonVirtual *atf2;
+  atf2 = get(); // expected-note{{Conversion from derived to base happened here}}
+  delete atf2; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void createThroughFunction() {
+  NonVirtual *ctf = create(); // expected-note{{Calling 'create'}}
+  // expected-note@-1{{Returning from 'create'}}
+  delete ctf; // expected-warning {{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void deleteThroughFunction() {
+  NonVirtual *dtf = new NVDerived(); // expected-note{{Conversion from derived to base happened here}}
+  sink(dtf); // expected-note{{Calling 'sink'}}
+}
+
+void singleCastCStyle() {
+  NVDerived *sccs = new NVDerived();
+  NonVirtual *sccs2 = (NonVirtual*)sccs; // expected-note{{Conversion from derived to base happened here}}
+  delete sccs2; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void doubleCastCStyle() {
+  NonVirtual *dccs = new NVDerived();
+  NVDerived *dccs2 = (NVDerived*)dccs;
+  dccs = (NonVirtual*)dccs2; // expected-note{{Conversion from derived to base happened here}}
+  delete dccs; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // expected-note@-1{{Destruction of a polymorphic object with no virtual destructor}}
+}
+
+void singleCast() {
+  NVDerived *sc = new NVDerived();
+  NonVirtual *sc2 = reinterpret_cast(sc); // expected-note{{Conversion from derived to base happened here}}
+  delete sc2; // expected-warning{{Destruction of a polymorphic object with no virtual destructor}}
+  // 

r313805 - [OPENMP] Support for re-declarations when checking captured variables.

2017-09-20 Thread Alexey Bataev via cfe-commits
Author: abataev
Date: Wed Sep 20 13:11:31 2017
New Revision: 313805

URL: http://llvm.org/viewvc/llvm-project?rev=313805=rev
Log:
[OPENMP] Support for re-declarations when checking captured variables.

Need to check for variables re-declarations when checking that the
variable was already captured in the captured region.

Modified:
cfe/trunk/lib/AST/Stmt.cpp
cfe/trunk/test/OpenMP/target_codegen.cpp

Modified: cfe/trunk/lib/AST/Stmt.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Stmt.cpp?rev=313805=313804=313805=diff
==
--- cfe/trunk/lib/AST/Stmt.cpp (original)
+++ cfe/trunk/lib/AST/Stmt.cpp Wed Sep 20 13:11:31 2017
@@ -1114,11 +1114,7 @@ bool CapturedStmt::capturesVariable(cons
   for (const auto  : captures()) {
 if (!I.capturesVariable() && !I.capturesVariableByCopy())
   continue;
-
-// This does not handle variable redeclarations. This should be
-// extended to capture variables with redeclarations, for example
-// a thread-private variable in OpenMP.
-if (I.getCapturedVar() == Var)
+if (I.getCapturedVar()->getCanonicalDecl() == Var->getCanonicalDecl())
   return true;
   }
 

Modified: cfe/trunk/test/OpenMP/target_codegen.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/OpenMP/target_codegen.cpp?rev=313805=313804=313805=diff
==
--- cfe/trunk/test/OpenMP/target_codegen.cpp (original)
+++ cfe/trunk/test/OpenMP/target_codegen.cpp Wed Sep 20 13:11:31 2017
@@ -79,6 +79,9 @@ struct TT{
   ty Y;
 };
 
+int global;
+extern int global;
+
 // CHECK: define {{.*}}[[FOO:@.+]](
 int foo(int n) {
   int a = 0;
@@ -109,7 +112,7 @@ int foo(int n) {
   // CHECK:   call void [[HVT1:@.+]](i[[SZ]] {{[^,]+}})
   #pragma omp target if(0)
   {
-a += 1;
+global += 1;
   }
 
   // CHECK-DAG:   [[RET:%.+]] = call i32 @__tgt_target(i32 -1, i8* @{{[^,]+}}, 
i32 1, i8** [[BP:%[^,]+]], i8** [[P:%[^,]+]], i[[SZ]]* getelementptr inbounds 
([1 x i[[SZ]]], [1 x i[[SZ]]]* [[SIZET2]], i32 0, i32 0), i32* getelementptr 
inbounds ([1 x i32], [1 x i32]* [[MAPT2]], i32 0, i32 0))


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


[PATCH] D38075: Fix PR34668 - P0704R1 implementation is too permissive

2017-09-20 Thread Tim Song via Phabricator via cfe-commits
tcanens added inline comments.



Comment at: lib/Sema/SemaExprCXX.cpp:5185
   if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
 // C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst() && !Proto->isVolatile())

Rakete wrote:
> I think you should update the comment to something like "also 'const', but 
> not if they're 'volatile'."
"if their cv-qualifier-seq is (exactly) 'const'", maybe?


https://reviews.llvm.org/D38075



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


[PATCH] D37881: [Sema] Prevent InstantiateClass from checking unrelated exception specs.

2017-09-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai updated this revision to Diff 116056.
vsapsai added a comment.

- Rename SavePendingDelayedStateRAII to SavePendingParsedClassStateRAII.


https://reviews.llvm.org/D37881

Files:
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/test/SemaTemplate/crash-unparsed-exception.cpp
  clang/test/SemaTemplate/default-arguments-cxx0x.cpp

Index: clang/test/SemaTemplate/default-arguments-cxx0x.cpp
===
--- clang/test/SemaTemplate/default-arguments-cxx0x.cpp
+++ clang/test/SemaTemplate/default-arguments-cxx0x.cpp
@@ -87,3 +87,30 @@
 A<1> m_target;
   };
 }
+
+// rdar://problem/34167492
+// Template B is instantiated during checking if defaulted A copy constructor
+// is constexpr. For this we check if S copy constructor is constexpr. And
+// for this we check S constructor template with default argument that mentions
+// template B. In  turn, template instantiation triggers checking defaulted
+// members exception spec. The problem is that it checks defaulted members not
+// for instantiated class only, but all defaulted members so far. In this case
+// we try to check exception spec for A default constructor which requires
+// initializer for the field _a. But initializers are added after constexpr
+// check so we reject the code because cannot find _a initializer.
+namespace rdar34167492 {
+  template  struct B { using type = bool; };
+
+  template  struct S {
+S() noexcept;
+
+template ::type = true>
+S(const S&) noexcept;
+  };
+
+  class A {
+A() noexcept = default;
+A(const A&) noexcept = default;
+S _a{};
+  };
+}
Index: clang/test/SemaTemplate/crash-unparsed-exception.cpp
===
--- clang/test/SemaTemplate/crash-unparsed-exception.cpp
+++ clang/test/SemaTemplate/crash-unparsed-exception.cpp
@@ -1,4 +1,5 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify -fcxx-exceptions -fexceptions %s
+// expected-no-diagnostics
 
 struct A {
   virtual ~A();
@@ -11,7 +12,7 @@
 ~D() throw();
   };
   struct E : A {
-D d; //expected-error{{exception specification is not available until end of class definition}}
+D d;
   };
-  B b; //expected-note{{in instantiation of template class 'B' requested here}}
+  B b;
 };
Index: clang/lib/Sema/SemaTemplateInstantiate.cpp
===
--- clang/lib/Sema/SemaTemplateInstantiate.cpp
+++ clang/lib/Sema/SemaTemplateInstantiate.cpp
@@ -2026,12 +2026,11 @@
   bool MergeWithParentScope = !Instantiation->isDefinedOutsideFunctionOrMethod();
   LocalInstantiationScope Scope(*this, MergeWithParentScope);
 
-  // All dllexported classes created during instantiation should be fully
-  // emitted after instantiation completes. We may not be ready to emit any
-  // delayed classes already on the stack, so save them away and put them back
-  // later.
-  decltype(DelayedDllExportClasses) ExportedClasses;
-  std::swap(ExportedClasses, DelayedDllExportClasses);
+  // Some class state isn't processed immediately but delayed till class
+  // instantiation completes. We may not be ready to handle any delayed state
+  // already on the stack as it might correspond to a different class, so save
+  // it now and put it back later.
+  SavePendingParsedClassStateRAII SavedPendingParsedClassState(*this);
 
   // Pull attributes from the pattern onto the instantiation.
   InstantiateAttrs(TemplateArgs, Pattern, Instantiation);
@@ -2118,9 +2117,6 @@
   // default arg exprs for default constructors if necessary now.
   ActOnFinishCXXNonNestedClass(Instantiation);
 
-  // Put back the delayed exported classes that we moved out of the way.
-  std::swap(ExportedClasses, DelayedDllExportClasses);
-
   // Instantiate late parsed attributes, and attach them to their decls.
   // See Sema::InstantiateAttrs
   for (LateInstantiatedAttrVec::iterator I = LateAttrs.begin(),
Index: clang/include/clang/Sema/Sema.h
===
--- clang/include/clang/Sema/Sema.h
+++ clang/include/clang/Sema/Sema.h
@@ -10490,6 +10490,36 @@
   SmallVector DelayedDllExportClasses;
 
 private:
+  class SavePendingParsedClassStateRAII {
+  public:
+SavePendingParsedClassStateRAII(Sema ) : S(S) { swapSavedState(); }
+
+~SavePendingParsedClassStateRAII() {
+  assert(S.DelayedExceptionSpecChecks.empty() &&
+ "there shouldn't be any pending delayed exception spec checks");
+  assert(S.DelayedDefaultedMemberExceptionSpecs.empty() &&
+ "there shouldn't be any pending delayed defaulted member "
+ "exception specs");
+  assert(S.DelayedDllExportClasses.empty() &&
+ "there shouldn't be any pending delayed DLL export classes");
+  swapSavedState();
+}
+
+  private:
+Sema 
+decltype(DelayedExceptionSpecChecks) SavedExceptionSpecChecks;
+

[libcxx] r313803 - Revert 313789 because gcc doesn't like it

2017-09-20 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Sep 20 12:38:43 2017
New Revision: 313803

URL: http://llvm.org/viewvc/llvm-project?rev=313803=rev
Log:
Revert 313789 because gcc doesn't like it

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/random

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=313803=313802=313803=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Sep 20 12:38:43 2017
@@ -2962,8 +2962,8 @@ public:
 result_type operator()() {return __eval(integral_constant());}
 
 private:
-result_type __eval(false_type) const;
-result_type __eval(true_type)  const;
+result_type __eval(false_type);
+result_type __eval(true_type);
 };
 
 template
@@ -3004,14 +3004,14 @@ __independent_bits_engine<_Engine, _UInt
 template
 inline
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(false_type) const
+__independent_bits_engine<_Engine, _UIntType>::__eval(false_type)
 {
 return static_cast(__e_() & __mask0_);
 }
 
 template
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(true_type) const
+__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
 {
 const size_t _WRt = numeric_limits::digits;
 result_type _Sp = 0;

Modified: libcxx/trunk/include/random
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=313803=313802=313803=diff
==
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Wed Sep 20 12:38:43 2017
@@ -3124,8 +3124,8 @@ public:
 
 private:
 _LIBCPP_INLINE_VISIBILITY
-result_type __eval(false_type) const;
-result_type __eval(true_type) const;
+result_type __eval(false_type);
+result_type __eval(true_type);
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -3151,14 +3151,14 @@ private:
 template
 inline
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) const
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type)
 {
 return static_cast(__e_() & __mask0);
 }
 
 template
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) const
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type)
 {
 result_type _Sp = 0;
 for (size_t __k = 0; __k < __n0; ++__k)


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


r313802 - Fixed unused variable warning introduced in r313796 causing build failure

2017-09-20 Thread Cameron Desrochers via cfe-commits
Author: cameron314
Date: Wed Sep 20 12:37:37 2017
New Revision: 313802

URL: http://llvm.org/viewvc/llvm-project?rev=313802=rev
Log:
Fixed unused variable warning introduced in r313796 causing build failure

Modified:
cfe/trunk/lib/Lex/Lexer.cpp

Modified: cfe/trunk/lib/Lex/Lexer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Lexer.cpp?rev=313802=313801=313802=diff
==
--- cfe/trunk/lib/Lex/Lexer.cpp (original)
+++ cfe/trunk/lib/Lex/Lexer.cpp Wed Sep 20 12:37:37 2017
@@ -564,9 +564,6 @@ PreambleBounds Lexer::ComputePreamble(St
  Buffer.end());
   TheLexer.SetCommentRetentionState(true);
 
-  // StartLoc will differ from FileLoc if there is a BOM that was skipped.
-  SourceLocation StartLoc = TheLexer.getSourceLocation();
-
   bool InPreprocessorDirective = false;
   Token TheTok;
   SourceLocation ActiveCommentLoc;


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


Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Fixed by r313801.
Sorry for all the trouble.

On Wed, Sep 20, 2017 at 9:22 PM, Ilya Biryukov  wrote:

> I think I know what's wrong. I've already seen those failures. std::mutex
> gets destroyed before threads waiting on it are joined.
> Will submit a fix shortly.
>
> On Wed, Sep 20, 2017 at 8:22 PM, Alex L  wrote:
>
>> This commit causes the formatting.test to fail on macOS with an uncaught
>> exception:
>>
>> libc++abi.dylib: terminating with uncaught exception of type
>> std::__1::system_error: mutex lock failed: Invalid argument
>> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/35642/
>>
>> I'm still looking into it. It doesn't look like the sanitizers are
>> reporting anything suspicious. Do you by any chance know what went wrong?
>> If it will turn out to be a macOS only thing it might make sense to XFAIL
>> formatting.test until the issue is resolved.
>>
>> Thanks,
>> Alex
>>
>> On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: ibiryukov
>>> Date: Wed Sep 20 05:58:55 2017
>>> New Revision: 313754
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=313754=rev
>>> Log:
>>> [clangd] Serialize onDiagnosticsReady callbacks for the same file.
>>>
>>> Summary:
>>> Calls to onDiagnosticsReady were done concurrently before. This sometimes
>>> led to older versions of diagnostics being reported to the user after
>>> the newer versions.
>>>
>>> Reviewers: klimek, bkramer, krasimir
>>>
>>> Reviewed By: klimek
>>>
>>> Subscribers: cfe-commits
>>>
>>> Differential Revision: https://reviews.llvm.org/D38032
>>>
>>> Modified:
>>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>>> clang-tools-extra/trunk/clangd/ClangdServer.h
>>> clang-tools-extra/trunk/clangd/DraftStore.h
>>> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>>>
>>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/ClangdServer.cpp?rev=313754=313753=313754=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55
>>> 2017
>>> @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
>>>  auto Diags = DeferredRebuild.get();
>>>  if (!Diags)
>>>return; // A new reparse was requested before this one completed.
>>> +
>>> +// We need to serialize access to resulting diagnostics to avoid
>>> calling
>>> +// `onDiagnosticsReady` in the wrong order.
>>> +std::lock_guard DiagsLock(DiagnosticsMutex);
>>> +DocVersion  =
>>> ReportedDiagnosticVersions[FileStr];
>>> +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
>>> +// implementation diagnostics will not be reported after version
>>> counters'
>>> +// overflow. This should not happen in practice, since DocVersion
>>> is a
>>> +// 64-bit unsigned integer.
>>> +if (Version < LastReportedDiagsVersion)
>>> +  return;
>>> +LastReportedDiagsVersion = Version;
>>> +
>>>  DiagConsumer.onDiagnosticsReady(FileStr,
>>>  make_tagged(std::move(*Diags),
>>> Tag));
>>>};
>>>
>>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/ClangdServer.h?rev=313754=313753=313754=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
>>> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55
>>> 2017
>>> @@ -284,6 +284,13 @@ private:
>>>// ClangdServer
>>>ClangdScheduler WorkScheduler;
>>>bool SnippetCompletions;
>>> +
>>> +  /// Used to serialize diagnostic callbacks.
>>> +  /// FIXME(ibiryukov): get rid of an extra map and put all version
>>> counters
>>> +  /// into CppFile.
>>> +  std::mutex DiagnosticsMutex;
>>> +  /// Maps from a filename to the latest version of reported
>>> diagnostics.
>>> +  llvm::StringMap ReportedDiagnosticVersions;
>>>  };
>>>
>>>  } // namespace clangd
>>>
>>> Modified: clang-tools-extra/trunk/clangd/DraftStore.h
>>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>>> clangd/DraftStore.h?rev=313754=313753=313754=diff
>>> 
>>> ==
>>> --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
>>> +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
>>> @@ -13,6 +13,7 @@
>>>  #include "Path.h"
>>>  #include "clang/Basic/LLVM.h"
>>>  #include "llvm/ADT/StringMap.h"
>>> +#include 
>>>  #include 
>>>  #include 
>>>  #include 
>>> @@ -20,8 +21,8 @@
>>>  namespace clang {
>>>  namespace clangd {
>>>
>>> -/// Using 'unsigned' here to avoid undefined 

[PATCH] D38083: [clangd] Skip informative qualifier chunks.

2017-09-20 Thread Raoul Wols via Phabricator via cfe-commits
rwols added inline comments.



Comment at: test/clangd/completion-qualifiers.test:12
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHEKC-DAG: {"label":"foo() 
const","kind":2,"detail":"int","sortText":"00035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHEKC-DAG: {"label":"bar() 
const","kind":2,"detail":"int","sortText":"00037bar","filterText":"bar","insertText":"bar","insertTextFormat":1}

CHECK-DAG typo?


https://reviews.llvm.org/D38083



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


[clang-tools-extra] r313801 - [clangd] Fixed crash on MacOS.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 12:32:06 2017
New Revision: 313801

URL: http://llvm.org/viewvc/llvm-project?rev=313801=rev
Log:
[clangd] Fixed crash on MacOS.

Caused by invalid order of members in ClangdServer.
DiagnosticsMutex was used after destruction.

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=313801=313800=313801=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 12:32:06 2017
@@ -151,7 +151,7 @@ ClangdServer::ClangdServer(GlobalCompila
   FSProvider(FSProvider),
   ResourceDir(ResourceDir ? ResourceDir->str() : getStandardResourceDir()),
   PCHs(std::make_shared()),
-  WorkScheduler(AsyncThreadsCount), SnippetCompletions(SnippetCompletions) 
{
+  SnippetCompletions(SnippetCompletions), WorkScheduler(AsyncThreadsCount) 
{
 }
 
 std::future ClangdServer::addDocument(PathRef File, StringRef Contents) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=313801=313800=313801=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 12:32:06 2017
@@ -279,18 +279,17 @@ private:
   CppFileCollection Units;
   std::string ResourceDir;
   std::shared_ptr PCHs;
-  // WorkScheduler has to be the last member, because its destructor has to be
-  // called before all other members to stop the worker thread that references
-  // ClangdServer
-  ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
-
   /// Used to serialize diagnostic callbacks.
   /// FIXME(ibiryukov): get rid of an extra map and put all version counters
   /// into CppFile.
   std::mutex DiagnosticsMutex;
   /// Maps from a filename to the latest version of reported diagnostics.
   llvm::StringMap ReportedDiagnosticVersions;
+  // WorkScheduler has to be the last member, because its destructor has to be
+  // called before all other members to stop the worker thread that references
+  // ClangdServer
+  ClangdScheduler WorkScheduler;
 };
 
 } // namespace clangd


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


Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via cfe-commits
I think I know what's wrong. I've already seen those failures. std::mutex
gets destroyed before threads waiting on it are joined.
Will submit a fix shortly.

On Wed, Sep 20, 2017 at 8:22 PM, Alex L  wrote:

> This commit causes the formatting.test to fail on macOS with an uncaught
> exception:
>
> libc++abi.dylib: terminating with uncaught exception of type
> std::__1::system_error: mutex lock failed: Invalid argument
> http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/35642/
>
> I'm still looking into it. It doesn't look like the sanitizers are
> reporting anything suspicious. Do you by any chance know what went wrong?
> If it will turn out to be a macOS only thing it might make sense to XFAIL
> formatting.test until the issue is resolved.
>
> Thanks,
> Alex
>
> On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>> Author: ibiryukov
>> Date: Wed Sep 20 05:58:55 2017
>> New Revision: 313754
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=313754=rev
>> Log:
>> [clangd] Serialize onDiagnosticsReady callbacks for the same file.
>>
>> Summary:
>> Calls to onDiagnosticsReady were done concurrently before. This sometimes
>> led to older versions of diagnostics being reported to the user after
>> the newer versions.
>>
>> Reviewers: klimek, bkramer, krasimir
>>
>> Reviewed By: klimek
>>
>> Subscribers: cfe-commits
>>
>> Differential Revision: https://reviews.llvm.org/D38032
>>
>> Modified:
>> clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> clang-tools-extra/trunk/clangd/ClangdServer.h
>> clang-tools-extra/trunk/clangd/DraftStore.h
>> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdServer.cpp?rev=313754=313753=313754=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55
>> 2017
>> @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
>>  auto Diags = DeferredRebuild.get();
>>  if (!Diags)
>>return; // A new reparse was requested before this one completed.
>> +
>> +// We need to serialize access to resulting diagnostics to avoid
>> calling
>> +// `onDiagnosticsReady` in the wrong order.
>> +std::lock_guard DiagsLock(DiagnosticsMutex);
>> +DocVersion  = ReportedDiagnosticVersions[Fil
>> eStr];
>> +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
>> +// implementation diagnostics will not be reported after version
>> counters'
>> +// overflow. This should not happen in practice, since DocVersion is
>> a
>> +// 64-bit unsigned integer.
>> +if (Version < LastReportedDiagsVersion)
>> +  return;
>> +LastReportedDiagsVersion = Version;
>> +
>>  DiagConsumer.onDiagnosticsReady(FileStr,
>>  make_tagged(std::move(*Diags),
>> Tag));
>>};
>>
>> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/ClangdServer.h?rev=313754=313753=313754=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
>> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55
>> 2017
>> @@ -284,6 +284,13 @@ private:
>>// ClangdServer
>>ClangdScheduler WorkScheduler;
>>bool SnippetCompletions;
>> +
>> +  /// Used to serialize diagnostic callbacks.
>> +  /// FIXME(ibiryukov): get rid of an extra map and put all version
>> counters
>> +  /// into CppFile.
>> +  std::mutex DiagnosticsMutex;
>> +  /// Maps from a filename to the latest version of reported diagnostics.
>> +  llvm::StringMap ReportedDiagnosticVersions;
>>  };
>>
>>  } // namespace clangd
>>
>> Modified: clang-tools-extra/trunk/clangd/DraftStore.h
>> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/
>> clangd/DraftStore.h?rev=313754=313753=313754=diff
>> 
>> ==
>> --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
>> +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
>> @@ -13,6 +13,7 @@
>>  #include "Path.h"
>>  #include "clang/Basic/LLVM.h"
>>  #include "llvm/ADT/StringMap.h"
>> +#include 
>>  #include 
>>  #include 
>>  #include 
>> @@ -20,8 +21,8 @@
>>  namespace clang {
>>  namespace clangd {
>>
>> -/// Using 'unsigned' here to avoid undefined behaviour on overflow.
>> -typedef unsigned DocVersion;
>> +/// Using unsigned int type here to avoid undefined behaviour on
>> overflow.
>> +typedef uint64_t DocVersion;
>>
>>  /// Document draft with a version of this draft.
>>  struct VersionedDraft {
>>
>> 

[PATCH] D38075: Fix PR34668 - P0704R1 implementation is too permissive

2017-09-20 Thread Nicolas Lesser via Phabricator via cfe-commits
Rakete added a comment.

Thanks! That was an oversight on my part, sorry.




Comment at: lib/Sema/SemaExprCXX.cpp:5185
   if (!isIndirect && !LHS.get()->Classify(Context).isLValue()) {
 // C++2a allows functions with ref-qualifier & if they are also 
'const'.
+if (Proto->isConst() && !Proto->isVolatile())

I think you should update the comment to something like "also 'const', but not 
if they're 'volatile'."


https://reviews.llvm.org/D38075



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


[PATCH] D37804: [OpenCL] Handle address space conversion while setting type alignment

2017-09-20 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added inline comments.



Comment at: lib/CodeGen/CGExpr.cpp:957
 
-return Builder.CreateBitCast(Addr, ConvertType(E->getType()));
+return Builder.CreatePointerBitCastOrAddrSpaceCast(
+Addr, ConvertType(E->getType()));

Anastasia wrote:
> Anastasia wrote:
> > yaxunl wrote:
> > > Better assert that only CK_AddressSpaceConversion allows different addr 
> > > spaces in target type.
> > It seems for consistency then we would have to assert for both different 
> > ASes in non-`addrspacecast` case and equivalent ASes in the other case.
> > 
> > As condition becomes complicated then, I could as well split into either 
> > creating `bitcast` or `addrspacecast` explicitly at a cost of one simple 
> > check in the return statement but that would be in release build too. 
> Sam, do you prefer an assert that will check both things or a runtime check 
> that would make sure to build the right IR node here?
splitting into bitcast and addrspacecast seems better.


https://reviews.llvm.org/D37804



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


[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-20 Thread Cameron via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313796: [PCH] Fixed preamble breaking with BOM presence (and 
particularly, fluctuating… (authored by cameron314).

Changed prior to commit:
  https://reviews.llvm.org/D37491?vs=116043=116049#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37491

Files:
  cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
  cfe/trunk/include/clang/Lex/Lexer.h
  cfe/trunk/include/clang/Lex/PreprocessorOptions.h
  cfe/trunk/lib/Frontend/FrontendActions.cpp
  cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
  cfe/trunk/lib/Lex/Lexer.cpp
  cfe/trunk/lib/Lex/Preprocessor.cpp
  cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp

Index: cfe/trunk/lib/Lex/Preprocessor.cpp
===
--- cfe/trunk/lib/Lex/Preprocessor.cpp
+++ cfe/trunk/lib/Lex/Preprocessor.cpp
@@ -516,9 +516,9 @@
 // If we've been asked to skip bytes in the main file (e.g., as part of a
 // precompiled preamble), do so now.
 if (SkipMainFilePreamble.first > 0)
-  CurLexer->SkipBytes(SkipMainFilePreamble.first, 
-  SkipMainFilePreamble.second);
-
+  CurLexer->SetByteOffset(SkipMainFilePreamble.first,
+  SkipMainFilePreamble.second);
+
 // Tell the header info that the main file was entered.  If the file is later
 // #imported, it won't be re-entered.
 if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
Index: cfe/trunk/lib/Lex/Lexer.cpp
===
--- cfe/trunk/lib/Lex/Lexer.cpp
+++ cfe/trunk/lib/Lex/Lexer.cpp
@@ -552,9 +552,9 @@
 
 } // end anonymous namespace
 
-std::pair Lexer::ComputePreamble(StringRef Buffer,
- const LangOptions ,
- unsigned MaxLines) {
+PreambleBounds Lexer::ComputePreamble(StringRef Buffer,
+  const LangOptions ,
+  unsigned MaxLines) {
   // Create a lexer starting at the beginning of the file. Note that we use a
   // "fake" file source location at offset 1 so that the lexer will track our
   // position within the file.
@@ -688,7 +688,7 @@
   else
 End = TheTok.getLocation();
 
-  return std::make_pair(End.getRawEncoding() - StartLoc.getRawEncoding(),
+  return PreambleBounds(End.getRawEncoding() - FileLoc.getRawEncoding(),
 TheTok.isAtStartOfLine());
 }
 
@@ -1394,9 +1394,9 @@
 // Helper methods for lexing.
 //===--===//
 
-/// \brief Routine that indiscriminately skips bytes in the source file.
-void Lexer::SkipBytes(unsigned Bytes, bool StartOfLine) {
-  BufferPtr += Bytes;
+/// \brief Routine that indiscriminately sets the offset into the source file.
+void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) {
+  BufferPtr = BufferStart + Offset;
   if (BufferPtr > BufferEnd)
 BufferPtr = BufferEnd;
   // FIXME: What exactly does the StartOfLine bit mean?  There are two
Index: cfe/trunk/lib/Frontend/FrontendActions.cpp
===
--- cfe/trunk/lib/Frontend/FrontendActions.cpp
+++ cfe/trunk/lib/Frontend/FrontendActions.cpp
@@ -591,7 +591,7 @@
   auto Buffer = CI.getFileManager().getBufferForFile(getCurrentFile());
   if (Buffer) {
 unsigned Preamble =
-Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).first;
+Lexer::ComputePreamble((*Buffer)->getBuffer(), CI.getLangOpts()).Size;
 llvm::outs().write((*Buffer)->getBufferStart(), Preamble);
   }
 }
Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -195,8 +195,7 @@
 PreambleBounds clang::ComputePreambleBounds(const LangOptions ,
 llvm::MemoryBuffer *Buffer,
 unsigned MaxLines) {
-  auto Pre = Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines);
-  return PreambleBounds(Pre.first, Pre.second);
+  return Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines);
 }
 
 llvm::ErrorOr PrecompiledPreamble::Build(
Index: cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
===
--- cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
+++ cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp
@@ -153,4 +153,48 @@
   ASSERT_EQ(initialCounts[2], GetFileReadCount(Header2));
 }
 
+TEST_F(PCHPreambleTest, ParseWithBom) {
+  std::string Header = "//./header.h";
+  std::string Main = "//./main.cpp";
+  AddFile(Header, "int random() { return 4; }");
+  AddFile(Main,
+"\xef\xbb\xbf"
+

r313796 - [PCH] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-20 Thread Cameron Desrochers via cfe-commits
Author: cameron314
Date: Wed Sep 20 12:03:37 2017
New Revision: 313796

URL: http://llvm.org/viewvc/llvm-project?rev=313796=rev
Log:
[PCH] Fixed preamble breaking with BOM presence (and particularly, fluctuating 
BOM presence)

This patch fixes broken preamble-skipping when the preamble region includes a 
byte order mark (BOM). Previously, parsing would fail if preamble PCH 
generation was enabled and a BOM was present.

This also fixes preamble invalidation when a BOM appears or disappears. This 
may seem to be an obscure edge case, but it happens regularly with IDEs that 
pass buffer overrides that never (or always) have a BOM, yet the underlying 
file from the initial parse that generated a PCH might (or might not) have a 
BOM.

I've included a test case for these scenarios.

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

Modified:
cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
cfe/trunk/include/clang/Lex/Lexer.h
cfe/trunk/include/clang/Lex/PreprocessorOptions.h
cfe/trunk/lib/Frontend/FrontendActions.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
cfe/trunk/lib/Lex/Lexer.cpp
cfe/trunk/lib/Lex/Preprocessor.cpp
cfe/trunk/unittests/Frontend/PCHPreambleTest.cpp

Modified: cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h?rev=313796=313795=313796=diff
==
--- cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h (original)
+++ cfe/trunk/include/clang/Frontend/PrecompiledPreamble.h Wed Sep 20 12:03:37 
2017
@@ -36,21 +36,6 @@ class CompilerInvocation;
 class DeclGroupRef;
 class PCHContainerOperations;
 
-/// A size of the preamble and a flag required by
-/// PreprocessorOptions::PrecompiledPreambleBytes.
-struct PreambleBounds {
-  PreambleBounds(unsigned Size, bool PreambleEndsAtStartOfLine)
-  : Size(Size), PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
-
-  /// \brief Size of the preamble in bytes.
-  unsigned Size;
-  /// \brief Whether the preamble ends at the start of a new line.
-  ///
-  /// Used to inform the lexer as to whether it's starting at the beginning of
-  /// a line after skipping the preamble.
-  bool PreambleEndsAtStartOfLine;
-};
-
 /// \brief Runs lexer to compute suggested preamble bounds.
 PreambleBounds ComputePreambleBounds(const LangOptions ,
  llvm::MemoryBuffer *Buffer,

Modified: cfe/trunk/include/clang/Lex/Lexer.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Lexer.h?rev=313796=313795=313796=diff
==
--- cfe/trunk/include/clang/Lex/Lexer.h (original)
+++ cfe/trunk/include/clang/Lex/Lexer.h Wed Sep 20 12:03:37 2017
@@ -39,6 +39,23 @@ enum ConflictMarkerKind {
   CMK_Perforce
 };
 
+/// Describes the bounds (start, size) of the preamble and a flag required by
+/// PreprocessorOptions::PrecompiledPreambleBytes.
+/// The preamble includes the BOM, if any.
+struct PreambleBounds {
+  PreambleBounds(unsigned Size, bool PreambleEndsAtStartOfLine)
+: Size(Size),
+  PreambleEndsAtStartOfLine(PreambleEndsAtStartOfLine) {}
+
+  /// \brief Size of the preamble in bytes.
+  unsigned Size;
+  /// \brief Whether the preamble ends at the start of a new line.
+  ///
+  /// Used to inform the lexer as to whether it's starting at the beginning of
+  /// a line after skipping the preamble.
+  bool PreambleEndsAtStartOfLine;
+};
+
 /// Lexer - This provides a simple interface that turns a text buffer into a
 /// stream of tokens.  This provides no support for file reading or buffering,
 /// or buffering/seeking of tokens, only forward lexing is supported.  It 
relies
@@ -443,11 +460,11 @@ public:
   /// to fewer than this number of lines.
   ///
   /// \returns The offset into the file where the preamble ends and the rest
-  /// of the file begins along with a boolean value indicating whether 
+  /// of the file begins along with a boolean value indicating whether
   /// the preamble ends at the beginning of a new line.
-  static std::pair ComputePreamble(StringRef Buffer,
-   const LangOptions ,
-   unsigned MaxLines = 0);
+  static PreambleBounds ComputePreamble(StringRef Buffer,
+const LangOptions ,
+unsigned MaxLines = 0);
 
   /// \brief Checks that the given token is the first token that occurs after
   /// the given location (this excludes comments and whitespace). Returns the
@@ -618,7 +635,7 @@ private:
   
//======//
   // Other lexer functions.
 
-  void SkipBytes(unsigned Bytes, bool StartOfLine);
+  void SetByteOffset(unsigned Offset, bool 

[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: lib/Sema/SemaDeclCXX.cpp:2871
+  InvalidDecl =
+  (DS.getStorageClassSpec() == DeclSpec::SCS_typedef || MSPropertyAttr)
+  ? 0

Note: Clang format did this craziness... I'm open to whatever format you guys 
would prefer.


https://reviews.llvm.org/D38092



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


[PATCH] D38092: [MS Compat]Allow __interfaces to have properties.

2017-09-20 Thread Erich Keane via Phabricator via cfe-commits
erichkeane created this revision.

__interface types are allowed in MSVC to have "property" data members 
(marked with declspec property).  This patch alters Sema to allow property
data members.


https://reviews.llvm.org/D38092

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/SemaCXX/ms-interface.cpp

Index: test/SemaCXX/ms-interface.cpp
===
--- test/SemaCXX/ms-interface.cpp
+++ test/SemaCXX/ms-interface.cpp
@@ -77,3 +77,32 @@
 
 class C2 : I6 {
 };
+
+
+// MSVC makes a special case in that an interface is allowed to have a data
+// member if it is a property.
+__interface HasProp {
+  __declspec(property(get = Get, put = Put)) int data;
+  int Get(void);
+  void Put(int);
+};
+
+struct __declspec(uuid("---C000-0046"))
+IUnknown {
+  void foo();
+  __declspec(property(get = Get, put = Put), deprecated) int data;
+  int Get(void);
+  void Put(int);
+};
+
+struct IFaceStruct : IUnknown {
+  __declspec(property(get = Get2, put = Put2), deprecated) int data2;
+  int Get2(void);
+  void Put2(int);
+};
+
+__interface IFaceInheritsStruct : IFaceStruct {};
+static_assert(!__is_interface_class(HasProp), "oops");
+static_assert(!__is_interface_class(IUnknown), "oops");
+static_assert(!__is_interface_class(IFaceStruct), "oops");
+static_assert(!__is_interface_class(IFaceInheritsStruct), "oops");
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -143,7 +143,7 @@
 if (Lambda->capture_begin() == Lambda->capture_end())
   return false;
 
-return S->Diag(Lambda->getLocStart(), 
+return S->Diag(Lambda->getLocStart(),
diag::err_lambda_capture_default_arg);
   }
 }
@@ -276,18 +276,18 @@
   // Okay: add the default argument to the parameter
   Param->setDefaultArg(Arg);
 
-  // We have already instantiated this parameter; provide each of the 
+  // We have already instantiated this parameter; provide each of the
   // instantiations with the uninstantiated default argument.
   UnparsedDefaultArgInstantiationsMap::iterator InstPos
 = UnparsedDefaultArgInstantiations.find(Param);
   if (InstPos != UnparsedDefaultArgInstantiations.end()) {
 for (unsigned I = 0, N = InstPos->second.size(); I != N; ++I)
   InstPos->second[I]->setUninstantiatedDefaultArg(Arg);
-
+
 // We're done tracking this parameter's instantiations.
 UnparsedDefaultArgInstantiations.erase(InstPos);
   }
-  
+
   return false;
 }
 
@@ -524,8 +524,8 @@
   Invalid = false;
 }
   }
-  
-  // FIXME: If we knew where the '=' was, we could easily provide a fix-it 
+
+  // FIXME: If we knew where the '=' was, we could easily provide a fix-it
   // hint here. Alternatively, we could walk the type-source information
   // for NewParam to find the last source location in the type... but it
   // isn't worth the effort right now. This is the kind of test case that
@@ -535,7 +535,7 @@
   //   void g(int (*fp)(int) = );
   Diag(NewParam->getLocation(), DiagDefaultParamID)
 << NewParam->getDefaultArgRange();
-  
+
   // Look for the function declaration where the default argument was
   // actually written, which may be a declaration prior to Old.
   for (auto Older = PrevForDefaultArgs;
@@ -581,36 +581,36 @@
 //   or a definition for one of the following explicit specializations:
 // - the explicit specialization of a function template;
 // - the explicit specialization of a member function template;
-// - the explicit specialization of a member function of a class 
+// - the explicit specialization of a member function of a class
 //   template where the class template specialization to which the
-//   member function specialization belongs is implicitly 
+//   member function specialization belongs is implicitly
 //   instantiated.
 Diag(NewParam->getLocation(), diag::err_template_spec_default_arg)
   << (New->getTemplateSpecializationKind() ==TSK_ExplicitSpecialization)
   << New->getDeclName()
   << NewParam->getDefaultArgRange();
   } else if (New->getDeclContext()->isDependentContext()) {
 // C++ [dcl.fct.default]p6 (DR217):
-//   Default arguments for a member function of a class template shall 
-//   be specified on the initial declaration of the member function 
+//   Default arguments for a member function of a class template shall
+//   be specified on the initial declaration of the member function
 //   within the class template.
 //
-// Reading the tea leaves a bit in DR217 and its reference to DR205 
-// leads me to the conclusion that one cannot add default function 
-// arguments for an out-of-line definition of a 

[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra updated this revision to Diff 116047.
tra added a comment.

Addressed Justin's comments.


https://reviews.llvm.org/D38090

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/shfl-sync.ll

Index: llvm/test/CodeGen/NVPTX/shfl-sync.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/shfl-sync.ll
@@ -0,0 +1,94 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 | FileCheck %s
+
+declare i32 @llvm.nvvm.shfl.sync.down.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.down.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.up.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.up.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.bfly.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.idx.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.idx.f32(float, i32, i32, i32)
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rrr
+define i32 @shfl.sync.rrr(i32 %mask, i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.irr
+define i32 @shfl.sync.irr(i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rri
+define i32 @shfl.sync.rri(i32 %mask, i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 1, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 1)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iri
+define i32 @shfl.sync.iri(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 2, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rir
+define i32 @shfl.sync.rir(i32 %mask, i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iir
+define i32 @shfl.sync.iir(i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rii
+define i32 @shfl.sync.rii(i32 %mask, i32 %a) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, 2, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iii
+define i32 @shfl.sync.iii(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, 3, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 3)
+  ret i32 %val
+}
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -111,9 +111,81 @@
 defm INT_SHFL_IDX_I32 : SHFL;
 defm INT_SHFL_IDX_F32 : SHFL;
 
+multiclass SHFL_SYNC {
+  // Threadmask and the last two parameters to shfl.sync 

[PATCH] D37491: [Preamble] Fixed preamble breaking with BOM presence (and particularly, fluctuating BOM presence)

2017-09-20 Thread Cameron via Phabricator via cfe-commits
cameron314 updated this revision to Diff 116043.
cameron314 added a comment.

Final diff. Test passes!


https://reviews.llvm.org/D37491

Files:
  include/clang/Frontend/PrecompiledPreamble.h
  include/clang/Lex/Lexer.h
  include/clang/Lex/PreprocessorOptions.h
  lib/Frontend/FrontendActions.cpp
  lib/Frontend/PrecompiledPreamble.cpp
  lib/Lex/Lexer.cpp
  lib/Lex/Preprocessor.cpp
  unittests/Frontend/PCHPreambleTest.cpp

Index: unittests/Frontend/PCHPreambleTest.cpp
===
--- unittests/Frontend/PCHPreambleTest.cpp
+++ unittests/Frontend/PCHPreambleTest.cpp
@@ -153,4 +153,48 @@
   ASSERT_EQ(initialCounts[2], GetFileReadCount(Header2));
 }
 
+TEST_F(PCHPreambleTest, ParseWithBom) {
+  std::string Header = "//./header.h";
+  std::string Main = "//./main.cpp";
+  AddFile(Header, "int random() { return 4; }");
+  AddFile(Main,
+"\xef\xbb\xbf"
+"#include \"//./header.h\"\n"
+"int main() { return random() -2; }");
+
+  std::unique_ptr AST(ParseAST(Main));
+  ASSERT_TRUE(AST.get());
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  unsigned HeaderReadCount = GetFileReadCount(Header);
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+  
+  // Check preamble PCH was really reused
+  ASSERT_EQ(HeaderReadCount, GetFileReadCount(Header));
+
+  // Remove BOM
+  RemapFile(Main,
+"#include \"//./header.h\"\n"
+"int main() { return random() -2; }");
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  ASSERT_LE(HeaderReadCount, GetFileReadCount(Header));
+  HeaderReadCount = GetFileReadCount(Header);
+
+  // Add BOM back
+  RemapFile(Main,
+"\xef\xbb\xbf"
+"#include \"//./header.h\"\n"
+"int main() { return random() -2; }");
+
+  ASSERT_TRUE(ReparseAST(AST));
+  ASSERT_FALSE(AST->getDiagnostics().hasErrorOccurred());
+
+  ASSERT_LE(HeaderReadCount, GetFileReadCount(Header));
+}
+
 } // anonymous namespace
Index: lib/Lex/Preprocessor.cpp
===
--- lib/Lex/Preprocessor.cpp
+++ lib/Lex/Preprocessor.cpp
@@ -516,9 +516,9 @@
 // If we've been asked to skip bytes in the main file (e.g., as part of a
 // precompiled preamble), do so now.
 if (SkipMainFilePreamble.first > 0)
-  CurLexer->SkipBytes(SkipMainFilePreamble.first, 
-  SkipMainFilePreamble.second);
-
+  CurLexer->SetByteOffset(SkipMainFilePreamble.first,
+  SkipMainFilePreamble.second);
+
 // Tell the header info that the main file was entered.  If the file is later
 // #imported, it won't be re-entered.
 if (const FileEntry *FE = SourceMgr.getFileEntryForID(MainFileID))
Index: lib/Lex/Lexer.cpp
===
--- lib/Lex/Lexer.cpp
+++ lib/Lex/Lexer.cpp
@@ -552,9 +552,9 @@
 
 } // end anonymous namespace
 
-std::pair Lexer::ComputePreamble(StringRef Buffer,
- const LangOptions ,
- unsigned MaxLines) {
+PreambleBounds Lexer::ComputePreamble(StringRef Buffer,
+  const LangOptions ,
+  unsigned MaxLines) {
   // Create a lexer starting at the beginning of the file. Note that we use a
   // "fake" file source location at offset 1 so that the lexer will track our
   // position within the file.
@@ -688,7 +688,7 @@
   else
 End = TheTok.getLocation();
 
-  return std::make_pair(End.getRawEncoding() - StartLoc.getRawEncoding(),
+  return PreambleBounds(End.getRawEncoding() - FileLoc.getRawEncoding(),
 TheTok.isAtStartOfLine());
 }
 
@@ -1394,9 +1394,9 @@
 // Helper methods for lexing.
 //===--===//
 
-/// \brief Routine that indiscriminately skips bytes in the source file.
-void Lexer::SkipBytes(unsigned Bytes, bool StartOfLine) {
-  BufferPtr += Bytes;
+/// \brief Routine that indiscriminately sets the offset into the source file.
+void Lexer::SetByteOffset(unsigned Offset, bool StartOfLine) {
+  BufferPtr = BufferStart + Offset;
   if (BufferPtr > BufferEnd)
 BufferPtr = BufferEnd;
   // FIXME: What exactly does the StartOfLine bit mean?  There are two
Index: lib/Frontend/PrecompiledPreamble.cpp
===
--- lib/Frontend/PrecompiledPreamble.cpp
+++ lib/Frontend/PrecompiledPreamble.cpp
@@ -195,8 +195,7 @@
 PreambleBounds clang::ComputePreambleBounds(const LangOptions ,
 llvm::MemoryBuffer *Buffer,
 unsigned MaxLines) {
-  auto Pre = Lexer::ComputePreamble(Buffer->getBuffer(), LangOpts, MaxLines);
-  return PreambleBounds(Pre.first, Pre.second);
+  return 

[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Justin Lebar via Phabricator via cfe-commits
jlebar added inline comments.



Comment at: clang/lib/Headers/__clang_cuda_intrinsics.h:161
+#endif // __CUDA_VERSION >= 9000 && (!defined(__CUDA_ARCH__) || __CUDA_ARCH__ 
>=
+   // 300)
+

Nit, better linebreaking in the comment?



Comment at: llvm/include/llvm/IR/IntrinsicsNVVM.td:3744
+  Intrinsic<[llvm_i32_ty], [llvm_i32_ty, llvm_i32_ty, llvm_i32_ty, 
llvm_i32_ty],
+[IntrNoMem], "llvm.nvvm.shfl.sync.down.i32">,
+  GCCBuiltin<"__nvvm_shfl_sync_down_i32">;

IntrConvergent?


https://reviews.llvm.org/D38090



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


[libcxx] r313789 - Mark the __eval methods on independent_bits_engine (and __independent_bits_engine) as const, since they make no changes to the object. NFC.

2017-09-20 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Sep 20 11:32:08 2017
New Revision: 313789

URL: http://llvm.org/viewvc/llvm-project?rev=313789=rev
Log:
Mark the __eval methods on independent_bits_engine (and 
__independent_bits_engine) as const, since they make no changes to the object. 
NFC.

Modified:
libcxx/trunk/include/algorithm
libcxx/trunk/include/random

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=313789=313788=313789=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Sep 20 11:32:08 2017
@@ -2962,8 +2962,8 @@ public:
 result_type operator()() {return __eval(integral_constant());}
 
 private:
-result_type __eval(false_type);
-result_type __eval(true_type);
+result_type __eval(false_type) const;
+result_type __eval(true_type)  const;
 };
 
 template
@@ -3004,14 +3004,14 @@ __independent_bits_engine<_Engine, _UInt
 template
 inline
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(false_type)
+__independent_bits_engine<_Engine, _UIntType>::__eval(false_type) const
 {
 return static_cast(__e_() & __mask0_);
 }
 
 template
 _UIntType
-__independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
+__independent_bits_engine<_Engine, _UIntType>::__eval(true_type) const
 {
 const size_t _WRt = numeric_limits::digits;
 result_type _Sp = 0;

Modified: libcxx/trunk/include/random
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/random?rev=313789=313788=313789=diff
==
--- libcxx/trunk/include/random (original)
+++ libcxx/trunk/include/random Wed Sep 20 11:32:08 2017
@@ -3124,8 +3124,8 @@ public:
 
 private:
 _LIBCPP_INLINE_VISIBILITY
-result_type __eval(false_type);
-result_type __eval(true_type);
+result_type __eval(false_type) const;
+result_type __eval(true_type) const;
 
 template 
 _LIBCPP_INLINE_VISIBILITY
@@ -3151,14 +3151,14 @@ private:
 template
 inline
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type)
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(false_type) const
 {
 return static_cast(__e_() & __mask0);
 }
 
 template
 _UIntType
-independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type)
+independent_bits_engine<_Engine, __w, _UIntType>::__eval(true_type) const
 {
 result_type _Sp = 0;
 for (size_t __k = 0; __k < __n0; ++__k)


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


[PATCH] D36423: [libc++] Introsort based sorting function

2017-09-20 Thread DIVYA SHANMUGHAN via Phabricator via cfe-commits
DIVYA added a comment.

ping


https://reviews.llvm.org/D36423



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


[PATCH] D37482: run-clang-tidy: Use check_call instead of check_output

2017-09-20 Thread Kevin Funk via Phabricator via cfe-commits
kfunk added a comment.

Bump? This is a trivial one


https://reviews.llvm.org/D37482



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


[PATCH] D36150: [clangd] LSP extension to switch between source/header file

2017-09-20 Thread William Enright via Phabricator via cfe-commits
Nebiroth updated this revision to Diff 116038.
Nebiroth added a comment.

Added unit test.


https://reviews.llvm.org/D36150

Files:
  clangd/ClangdLSPServer.cpp
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/ProtocolHandlers.cpp
  clangd/ProtocolHandlers.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -892,5 +892,83 @@
   }
 }
 
+TEST_F(ClangdVFSTest, CheckSourceHeaderSwitch) {
+  MockFSProvider FS;
+  ErrorCheckingDiagConsumer DiagConsumer;
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+
+  ClangdServer Server(CDB, DiagConsumer, FS, getDefaultAsyncThreadsCount(),
+  /*SnippetCompletions=*/false);
+
+  auto SourceContents = R"cpp(
+  #include "foo.h"
+  int b = a;
+  )cpp";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  auto FooH = getVirtualTestFilePath("foo.h");
+  auto invalid = getVirtualTestFilePath("main.cpp");
+
+  FS.Files[FooCpp] = SourceContents;
+  FS.Files[FooH] = "int a;";   
+  FS.Files[invalid] = "int main() { \n return 0; \n }";
+
+  llvm::Optional pathResult = Server.switchSourceHeader(FooCpp);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), FooH);
+
+  pathResult = Server.switchSourceHeader(FooH);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), FooCpp);
+
+  SourceContents = R"c(
+  #include "foo.HH"
+  int b = a;
+  )c";
+
+  // Test with header file in capital letters and different extension, source file with different extension
+  auto FooC = getVirtualTestFilePath("bar.c");
+  auto FooHH = getVirtualTestFilePath("bar.HH");
+
+  FS.Files[FooC] = SourceContents; 
+  FS.Files[FooHH] = "int a;";
+
+  pathResult = Server.switchSourceHeader(FooC);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), FooHH);
+
+  // Test with both capital letters
+  auto Foo2C = getVirtualTestFilePath("foo2.C");
+  auto Foo2HH = getVirtualTestFilePath("foo2.HH");
+  FS.Files[Foo2C] = SourceContents;
+  FS.Files[Foo2HH] = "int a;"; 
+
+  pathResult = Server.switchSourceHeader(Foo2C);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), Foo2HH);
+
+  // Test with source file as capital letter and .hxx header file
+  auto Foo3C = getVirtualTestFilePath("foo3.C");
+  auto Foo3HXX = getVirtualTestFilePath("foo3.hxx");
+
+  SourceContents = R"c(
+  #include "foo3.hxx"
+  int b = a;
+  )c";
+
+  FS.Files[Foo3C] = SourceContents;
+  FS.Files[Foo3HXX] = "int a;"; 
+
+  pathResult = Server.switchSourceHeader(Foo3C);
+  EXPECT_TRUE(pathResult.hasValue());
+  ASSERT_EQ(pathResult.getValue(), Foo3HXX);
+  
+
+  // Test if asking for a corresponding file that doesn't exist returns an empty string.
+  pathResult = Server.switchSourceHeader(invalid);
+  EXPECT_FALSE(pathResult.hasValue());
+
+} 
+
 } // namespace clangd
 } // namespace clang
Index: clangd/ProtocolHandlers.h
===
--- clangd/ProtocolHandlers.h
+++ clangd/ProtocolHandlers.h
@@ -48,6 +48,8 @@
 JSONOutput ) = 0;
   virtual void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
 JSONOutput ) = 0;
+  virtual void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
+JSONOutput ) = 0;  
 };
 
 void regiterCallbackHandlers(JSONRPCDispatcher , JSONOutput ,
Index: clangd/ProtocolHandlers.cpp
===
--- clangd/ProtocolHandlers.cpp
+++ clangd/ProtocolHandlers.cpp
@@ -204,6 +204,22 @@
   ProtocolCallbacks 
 };
 
+struct SwitchSourceHeaderHandler : Handler {
+  SwitchSourceHeaderHandler(JSONOutput , ProtocolCallbacks )
+  : Handler(Output), Callbacks(Callbacks) {}
+
+  void handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) override {
+auto TDPP = TextDocumentIdentifier::parse(Params);
+if (!TDPP)
+  return;
+
+Callbacks.onSwitchSourceHeader(*TDPP, ID, Output);
+  }
+
+private:
+  ProtocolCallbacks 
+};
+
 } // namespace
 
 void clangd::regiterCallbackHandlers(JSONRPCDispatcher ,
@@ -240,4 +256,7 @@
   Dispatcher.registerHandler(
   "textDocument/definition",
   llvm::make_unique(Out, Callbacks));
+  Dispatcher.registerHandler(
+  "textDocument/switchSourceHeader",
+  llvm::make_unique(Out, Callbacks));
 }
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -241,6 +241,10 @@
   /// Get definition of symbol at a specified \p Line and \p Column in \p File.
   Tagged findDefinitions(PathRef File, Position Pos);
 
+  /// Helper function that returns a path to the corresponding source file when
+  /// 

Re: [clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Alex L via cfe-commits
This commit causes the formatting.test to fail on macOS with an uncaught
exception:

libc++abi.dylib: terminating with uncaught exception of type
std::__1::system_error: mutex lock failed: Invalid argument
http://lab.llvm.org:8080/green/job/clang-stage1-configure-RA_check/35642/

I'm still looking into it. It doesn't look like the sanitizers are
reporting anything suspicious. Do you by any chance know what went wrong?
If it will turn out to be a macOS only thing it might make sense to XFAIL
formatting.test until the issue is resolved.

Thanks,
Alex

On 20 September 2017 at 13:58, Ilya Biryukov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ibiryukov
> Date: Wed Sep 20 05:58:55 2017
> New Revision: 313754
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313754=rev
> Log:
> [clangd] Serialize onDiagnosticsReady callbacks for the same file.
>
> Summary:
> Calls to onDiagnosticsReady were done concurrently before. This sometimes
> led to older versions of diagnostics being reported to the user after
> the newer versions.
>
> Reviewers: klimek, bkramer, krasimir
>
> Reviewed By: klimek
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D38032
>
> Modified:
> clang-tools-extra/trunk/clangd/ClangdServer.cpp
> clang-tools-extra/trunk/clangd/ClangdServer.h
> clang-tools-extra/trunk/clangd/DraftStore.h
> clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.cpp?rev=313754=313753=313754=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55
> 2017
> @@ -315,6 +315,19 @@ std::future ClangdServer::schedule
>  auto Diags = DeferredRebuild.get();
>  if (!Diags)
>return; // A new reparse was requested before this one completed.
> +
> +// We need to serialize access to resulting diagnostics to avoid
> calling
> +// `onDiagnosticsReady` in the wrong order.
> +std::lock_guard DiagsLock(DiagnosticsMutex);
> +DocVersion  = ReportedDiagnosticVersions[
> FileStr];
> +// FIXME(ibiryukov): get rid of '<' comparison here. In the current
> +// implementation diagnostics will not be reported after version
> counters'
> +// overflow. This should not happen in practice, since DocVersion is a
> +// 64-bit unsigned integer.
> +if (Version < LastReportedDiagsVersion)
> +  return;
> +LastReportedDiagsVersion = Version;
> +
>  DiagConsumer.onDiagnosticsReady(FileStr,
>  make_tagged(std::move(*Diags), Tag));
>};
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.h?rev=313754=313753=313754=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55 2017
> @@ -284,6 +284,13 @@ private:
>// ClangdServer
>ClangdScheduler WorkScheduler;
>bool SnippetCompletions;
> +
> +  /// Used to serialize diagnostic callbacks.
> +  /// FIXME(ibiryukov): get rid of an extra map and put all version
> counters
> +  /// into CppFile.
> +  std::mutex DiagnosticsMutex;
> +  /// Maps from a filename to the latest version of reported diagnostics.
> +  llvm::StringMap ReportedDiagnosticVersions;
>  };
>
>  } // namespace clangd
>
> Modified: clang-tools-extra/trunk/clangd/DraftStore.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/DraftStore.h?rev=313754=313753=313754=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/DraftStore.h (original)
> +++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
> @@ -13,6 +13,7 @@
>  #include "Path.h"
>  #include "clang/Basic/LLVM.h"
>  #include "llvm/ADT/StringMap.h"
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -20,8 +21,8 @@
>  namespace clang {
>  namespace clangd {
>
> -/// Using 'unsigned' here to avoid undefined behaviour on overflow.
> -typedef unsigned DocVersion;
> +/// Using unsigned int type here to avoid undefined behaviour on overflow.
> +typedef uint64_t DocVersion;
>
>  /// Document draft with a version of this draft.
>  struct VersionedDraft {
>
> Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/unittests/clangd/ClangdTests.cpp?rev=313754=
> 313753=313754=diff
> 
> ==
> --- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
> +++ 

Re: [PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Aaron Ballman via cfe-commits
On Wed, Sep 20, 2017 at 2:17 PM, Volodymyr Sapsai via Phabricator via
cfe-commits  wrote:
> vsapsai added a comment.
>
> Thanks for following up, Alberto. I haven't expected such a use case. It is 
> possible to achieve the same with `LSA_SIZEOF_SA = sizeof(((len_and_sockaddr 
> *)0)->u)` but I don't like it and don't want to force developers using such 
> approach.
>
> For solving this problem I think to restrict error only to C++ and to allow 
> tags inside enums for C. Alberto, what do you think, will it work for you? 
> And from implementation perspective allowing tags in enums for C should be 
> safe because things go haywire for C++ while checking access rules and C 
> doesn't have access rules.

That construct is well-formed C code, but isn't in C++ (C++ restricts
the places where you can define a new type compared to what C allows).

~Aaron

>
>
> Repository:
>   rL LLVM
>
> https://reviews.llvm.org/D37089
>
>
>
> ___
> 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


[PATCH] D38090: [NVPTX] Implemented shfl.sync instruction and supporting intrinsics/builtins.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra created this revision.
Herald added subscribers: hiraditya, sanjoy, jholewinski.

https://reviews.llvm.org/D38090

Files:
  clang/include/clang/Basic/BuiltinsNVPTX.def
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Headers/__clang_cuda_intrinsics.h
  clang/test/CodeGen/builtins-nvptx-ptx60.cu
  clang/test/CodeGen/builtins-nvptx.c
  llvm/include/llvm/IR/IntrinsicsNVVM.td
  llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
  llvm/test/CodeGen/NVPTX/shfl-sync.ll

Index: llvm/test/CodeGen/NVPTX/shfl-sync.ll
===
--- /dev/null
+++ llvm/test/CodeGen/NVPTX/shfl-sync.ll
@@ -0,0 +1,94 @@
+; RUN: llc < %s -march=nvptx64 -mcpu=sm_30 | FileCheck %s
+
+declare i32 @llvm.nvvm.shfl.sync.down.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.down.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.up.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.up.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.bfly.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.bfly.f32(float, i32, i32, i32)
+declare i32 @llvm.nvvm.shfl.sync.idx.i32(i32, i32, i32, i32)
+declare float @llvm.nvvm.shfl.sync.idx.f32(float, i32, i32, i32)
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rrr
+define i32 @shfl.sync.rrr(i32 %mask, i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.irr
+define i32 @shfl.sync.irr(i32 %a, i32 %b, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rri
+define i32 @shfl.sync.rri(i32 %mask, i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 1, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 %b, i32 1)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iri
+define i32 @shfl.sync.iri(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[B:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], [[B]], 2, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 %b, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rir
+define i32 @shfl.sync.rir(i32 %mask, i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, [[C]], [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iir
+define i32 @shfl.sync.iir(i32 %a, i32 %c) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[C:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, [[C]], 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 %c)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.rii
+define i32 @shfl.sync.rii(i32 %mask, i32 %a) {
+  ; CHECK: ld.param.u32 [[MASK:%r[0-9]+]]
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 1, 2, [[MASK]];
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 %mask, i32 %a, i32 1, i32 2)
+  ret i32 %val
+}
+
+; CHECK-LABEL: .func{{.*}}shfl.sync.iii
+define i32 @shfl.sync.iii(i32 %a, i32 %b) {
+  ; CHECK: ld.param.u32 [[A:%r[0-9]+]]
+  ; CHECK: shfl.sync.down.b32 [[OUT:%r[0-9]+]], [[A]], 2, 3, 1;
+  ; CHECK: st.param.{{.}}32 {{.*}}, [[OUT]]
+  %val = call i32 @llvm.nvvm.shfl.sync.down.i32(i32 1, i32 %a, i32 2, i32 3)
+  ret i32 %val
+}
Index: llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
===
--- llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
+++ llvm/lib/Target/NVPTX/NVPTXIntrinsics.td
@@ -113,6 +113,76 @@
 
 } // isConvergent = 1
 
+multiclass SHFL_SYNC {
+  // The last two parameters to shfl can be regs or imms.  ptxas is smart
+  // enough to inline constant registers, so strictly speaking we don't need to
+  // handle immediates here.  

[PATCH] D37089: [Sema] Error out early for tags defined inside an enumeration.

2017-09-20 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for following up, Alberto. I haven't expected such a use case. It is 
possible to achieve the same with `LSA_SIZEOF_SA = sizeof(((len_and_sockaddr 
*)0)->u)` but I don't like it and don't want to force developers using such 
approach.

For solving this problem I think to restrict error only to C++ and to allow 
tags inside enums for C. Alberto, what do you think, will it work for you? And 
from implementation perspective allowing tags in enums for C should be safe 
because things go haywire for C++ while checking access rules and C doesn't 
have access rules.


Repository:
  rL LLVM

https://reviews.llvm.org/D37089



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


r313784 - Remove offset size check in nullptr arithmetic handling

2017-09-20 Thread Andrew Kaylor via cfe-commits
Author: akaylor
Date: Wed Sep 20 11:06:44 2017
New Revision: 313784

URL: http://llvm.org/viewvc/llvm-project?rev=313784=rev
Log:
Remove offset size check in nullptr arithmetic handling

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


Modified:
cfe/trunk/lib/AST/Expr.cpp
cfe/trunk/test/CodeGen/nullptr-arithmetic.c
cfe/trunk/test/Sema/pointer-addition.c
cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp

Modified: cfe/trunk/lib/AST/Expr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Expr.cpp?rev=313784=313783=313784=diff
==
--- cfe/trunk/lib/AST/Expr.cpp (original)
+++ cfe/trunk/lib/AST/Expr.cpp Wed Sep 20 11:06:44 2017
@@ -1837,17 +1837,14 @@ bool BinaryOperator::isNullPointerArithm
 
   // Check that we have one pointer and one integer operand.
   Expr *PExp;
-  Expr *IExp;
   if (LHS->getType()->isPointerType()) {
 if (!RHS->getType()->isIntegerType())
   return false;
 PExp = LHS;
-IExp = RHS;
   } else if (RHS->getType()->isPointerType()) {
 if (!LHS->getType()->isIntegerType())
   return false;
 PExp = RHS;
-IExp = LHS;
   } else {
 return false;
   }
@@ -1862,10 +1859,6 @@ bool BinaryOperator::isNullPointerArithm
   if (!PTy || !PTy->getPointeeType()->isCharType())
 return false;
 
-  // Check that the integer type is pointer-sized.
-  if (Ctx.getTypeSize(IExp->getType()) != Ctx.getTypeSize(PExp->getType()))
-return false;
-
   return true;
 }
 InitListExpr::InitListExpr(const ASTContext , SourceLocation lbraceloc,

Modified: cfe/trunk/test/CodeGen/nullptr-arithmetic.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/nullptr-arithmetic.c?rev=313784=313783=313784=diff
==
--- cfe/trunk/test/CodeGen/nullptr-arithmetic.c (original)
+++ cfe/trunk/test/CodeGen/nullptr-arithmetic.c Wed Sep 20 11:06:44 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 -S %s -emit-llvm -o - | FileCheck %s
+// RUN: %clang_cc1 -S %s -emit-llvm -triple i686-unknown-unknown -o - | 
FileCheck %s
+// RUN: %clang_cc1 -S %s -emit-llvm -triple x86_64-unknown-unknown -o - | 
FileCheck %s
 
 #include 
 
@@ -32,3 +34,14 @@ int8_t* test3(intptr_t n) {
 // CHECK-LABEL: test3
 // CHECK: getelementptr
 // CHECK-NOT: inttoptr
+
+// This checks the case where the offset isn't pointer-sized.
+// The front end will implicitly cast the offset to an integer, so we need to
+// make sure that doesn't cause problems on targets where integers and pointers
+// are not the same size.
+int8_t *test4(int8_t b) {
+  return NULLPTRI8 + b;
+}
+// CHECK-LABEL: test4
+// CHECK: inttoptr
+// CHECK-NOT: getelementptr

Modified: cfe/trunk/test/Sema/pointer-addition.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/pointer-addition.c?rev=313784=313783=313784=diff
==
--- cfe/trunk/test/Sema/pointer-addition.c (original)
+++ cfe/trunk/test/Sema/pointer-addition.c Wed Sep 20 11:06:44 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify 
-pedantic -Wextra -std=c11
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify 
-pedantic -Wextra -std=c11
 
 #include 
 

Modified: cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp?rev=313784=313783=313784=diff
==
--- cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp (original)
+++ cfe/trunk/test/SemaCXX/nullptr-arithmetic.cpp Wed Sep 20 11:06:44 2017
@@ -1,4 +1,6 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -pedantic -Wextra -std=c++11
+// RUN: %clang_cc1 %s -fsyntax-only -triple i686-unknown-unknown -verify 
-pedantic -Wextra -std=c++11
+// RUN: %clang_cc1 %s -fsyntax-only -triple x86_64-unknown-unknown -verify 
-pedantic -Wextra -std=c++11
 
 #include 
 


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


Re: r313316 - [Module map] Introduce a private module re-export directive.

2017-09-20 Thread Galina Kistanova via cfe-commits
Thanks for looking.
It seems  your commit exposed some other issue. Now, unfortunately, it has
stopped being reproducible.
Thanks for looking anyway.

A good bug will show itself sooner or later.

Thanks

Galina


On Mon, Sep 18, 2017 at 3:49 PM, Douglas Gregor  wrote:

>
> On Sep 18, 2017, at 3:11 PM, Richard Smith  wrote:
>
> On 18 September 2017 at 14:34, Douglas Gregor via cfe-commits <
> cfe-commits@lists.llvm.org> wrote:
>
>>
>> On Sep 18, 2017, at 1:45 PM, Galina Kistanova 
>> wrote:
>>
>> Hello Douglas,
>>
>> Your r313316 commit broke one of our builders on Thursday, Sep-14th.
>> http://lab.llvm.org:8011/builders/llvm-clang-lld-x86_64-
>> scei-ps4-ubuntu-fast/builds/17506
>>
>> Are you about to commit the fix, or shall I revert that commit to give
>> you more time?
>>
>>
>> I’m unable to reproduce this issue, and it’s weirdly not hitting the
>> other bots.
>>
>> Is anyone able to reproduce this? The stack trace is… insufficient… to
>> figure out what’s going on.
>>
>
> I think that bot might be the only one with a target whose default C++
> language mode is C++11.
>
>
> Hmm. It’s not the C++ RUN lines that are failing, though; it’s the default
> (Objective-C) one.
>
> - Doug
>
>
>
>> - Doug
>>
>>
>> Thanks
>>
>> Galina
>>
>> On Thu, Sep 14, 2017 at 4:38 PM, Douglas Gregor via cfe-commits <
>> cfe-commits@lists.llvm.org> wrote:
>>
>>> Author: dgregor
>>> Date: Thu Sep 14 16:38:44 2017
>>> New Revision: 313316
>>>
>>> URL: http://llvm.org/viewvc/llvm-project?rev=313316=rev
>>> Log:
>>> [Module map] Introduce a private module re-export directive.
>>>
>>> Introduce a new "export_as" directive for top-level modules, which
>>> indicates that the current module is a "private" module whose symbols
>>> will eventually be exported through the named "public" module. This is
>>> in support of a common pattern in the Darwin ecosystem where a single
>>> public framework is constructed of several private frameworks, with
>>> (currently) header duplication and some support from the linker.
>>>
>>> Addresses rdar://problem/34438420.
>>>
>>> Added:
>>> cfe/trunk/test/Modules/Inputs/export_as_test.modulemap
>>> cfe/trunk/test/Modules/export_as_test.c
>>> Modified:
>>> cfe/trunk/docs/Modules.rst
>>> cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>> cfe/trunk/include/clang/Basic/Module.h
>>> cfe/trunk/include/clang/Serialization/ASTBitCodes.h
>>> cfe/trunk/lib/Basic/Module.cpp
>>> cfe/trunk/lib/Lex/ModuleMap.cpp
>>> cfe/trunk/lib/Serialization/ASTReader.cpp
>>> cfe/trunk/lib/Serialization/ASTWriter.cpp
>>>
>>> Modified: cfe/trunk/docs/Modules.rst
>>> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/Modules.r
>>> st?rev=313316=313315=313316=diff
>>> 
>>> ==
>>> --- cfe/trunk/docs/Modules.rst (original)
>>> +++ cfe/trunk/docs/Modules.rst Thu Sep 14 16:38:44 2017
>>> @@ -323,11 +323,12 @@ Module map files use a simplified form o
>>>
>>>  .. parsed-literal::
>>>
>>> -  ``config_macros`` ``export`` ``private``
>>> +  ``config_macros`` ``export_as``  ``private``
>>>``conflict``  ``framework``  ``requires``
>>>``exclude``   ``header`` ``textual``
>>>``explicit``  ``link``   ``umbrella``
>>>``extern````module`` ``use``
>>> +  ``export``
>>>
>>>  Module map file
>>>  ---
>>> @@ -387,6 +388,7 @@ Modules can have a number of different k
>>>  *umbrella-dir-declaration*
>>>  *submodule-declaration*
>>>  *export-declaration*
>>> +*export-as-declaration*
>>>  *use-declaration*
>>>  *link-declaration*
>>>  *config-macros-declaration*
>>> @@ -666,6 +668,31 @@ Note that, if ``Derived.h`` includes ``B
>>>compatibility for programs that rely on transitive inclusion (i.e.,
>>>all of them).
>>>
>>> +Re-export Declaration
>>> +~~
>>> +An *export-as-declaration* specifies that the current module is a
>>> private
>>> +module whose interface will be re-exported by the named public module.
>>> +
>>> +.. parsed-literal::
>>> +
>>> +  *export-as-declaration*:
>>> +``export_as`` *identifier*
>>> +
>>> +The *export-as-declaration* names the public module that the current
>>> +(private) module will be re-exported through. Only top-level modules
>>> +can be re-exported, and any given module may only be re-exported
>>> +through a single public module.
>>> +
>>> +**Example:** In the following example, the (private) module
>>> +``MyFrameworkCore`` will be re-exported via the public module
>>> +``MyFramework``:
>>> +
>>> +.. parsed-literal::
>>> +
>>> +  module MyFrameworkCore {
>>> +export_as MyFramework
>>> +  }
>>> +
>>>  Use declaration
>>>  ~~~
>>>  A *use-declaration* specifies another module that the current top-level
>>> module
>>>
>>> Modified: cfe/trunk/include/clang/Basic/DiagnosticLexKinds.td
>>> URL: 

[libcxx] r313776 - Fix a bit of UB in __independent_bits_engine. Fixes PR#34663

2017-09-20 Thread Marshall Clow via cfe-commits
Author: marshall
Date: Wed Sep 20 10:34:11 2017
New Revision: 313776

URL: http://llvm.org/viewvc/llvm-project?rev=313776=rev
Log:
Fix a bit of UB in __independent_bits_engine. Fixes PR#34663

Modified:
libcxx/trunk/include/algorithm

Modified: libcxx/trunk/include/algorithm
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/algorithm?rev=313776=313775=313776=diff
==
--- libcxx/trunk/include/algorithm (original)
+++ libcxx/trunk/include/algorithm Wed Sep 20 10:34:11 2017
@@ -3013,6 +3013,7 @@ template
 _UIntType
 __independent_bits_engine<_Engine, _UIntType>::__eval(true_type)
 {
+const size_t _WRt = numeric_limits::digits;
 result_type _Sp = 0;
 for (size_t __k = 0; __k < __n0_; ++__k)
 {
@@ -3021,7 +3022,7 @@ __independent_bits_engine<_Engine, _UInt
 {
 __u = __e_() - _Engine::min();
 } while (__u >= __y0_);
-if (__w0_ < _WDt)
+if (__w0_ < _WRt)
 _Sp <<= __w0_;
 else
 _Sp = 0;
@@ -3034,7 +3035,7 @@ __independent_bits_engine<_Engine, _UInt
 {
 __u = __e_() - _Engine::min();
 } while (__u >= __y1_);
-if (__w0_ < _WDt - 1)
+if (__w0_ < _WRt - 1)
 _Sp <<= __w0_ + 1;
 else
 _Sp = 0;


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


[libclc] r313773 - Add travis CI configuration file

2017-09-20 Thread Jan Vesely via cfe-commits
Author: jvesely
Date: Wed Sep 20 10:28:58 2017
New Revision: 313773

URL: http://llvm.org/viewvc/llvm-project?rev=313773=rev
Log:
Add travis CI configuration file

Signed-off-by: Jan Vesely 

Added:
libclc/trunk/.travis.yml

Added: libclc/trunk/.travis.yml
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/.travis.yml?rev=313773=auto
==
--- libclc/trunk/.travis.yml (added)
+++ libclc/trunk/.travis.yml Wed Sep 20 10:28:58 2017
@@ -0,0 +1,42 @@
+language: cpp
+
+sudo: false
+dist: trusty
+
+cache:
+  apt: true
+
+
+matrix:
+  include:
+- env:
+- LABEL="make gcc LLVM-4.0"
+- LLVM_VERSION=4.0
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-4.0
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-4.0-dev
+- clang-4.0
+- env:
+- LABEL="make gcc LLVM-5.0"
+- LLVM_VERSION=5.0
+- LLVM_CONFIG="llvm-config-${LLVM_VERSION}"
+  addons:
+apt:
+  sources:
+- llvm-toolchain-trusty-5.0
+  packages:
+- libedit-dev
+- g++-4.8
+# From sources above
+- llvm-5.0-dev
+- clang-5.0
+
+script:
+  - $PYTHON ./configure.py --with-llvm-config=$LLVM_CONFIG 
--with-cxx-compiler=$CXX && make -j4


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


[PATCH] D38040: [OpenMP] Add an additional test for D34888

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra added inline comments.



Comment at: test/OpenMP/target_map_codegen.cpp:4845
+///==///
+// RUN: %clang_cc1 -DCK30 -std=c++11 -fopenmp -S -emit-llvm -fopenmp 
-fopenmp-targets=nvptx64-nvidia-cuda %s -o - 2>&1 | FileCheck 
-check-prefix=CK30 %s
+

tra wrote:
> Please break the line to make it easier to read.
Better, but the line still wraps.  I'd split it again somewhere between 
-emit-llvm and -fopenmp.
BTW, you have -fopenmp specified twice. Is that intentional?


Repository:
  rL LLVM

https://reviews.llvm.org/D38040



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


[PATCH] D37913: [OpenMP] Enable the existing nocudalib flag for OpenMP offloading toolchain.

2017-09-20 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

One small nit. LGTM otherwise.




Comment at: test/Driver/openmp-offload-gpu.c:133
+/// Check that the flag is passed when -fopenmp-relocatable-target is used.
+// RUN:   %clang -### -fopenmp=libomp -fopenmp-targets=nvptx64-nvidia-cuda 
-Xopenmp-target -march=sm_60 -nocudalib -fopenmp-relocatable-target -save-temps 
-no-canonical-prefixes %s 2>&1 \
+// RUN:   | FileCheck -check-prefix=CHK-FLAG-NOLIBDEVICE %s

Please split this RUN line further.


Repository:
  rL LLVM

https://reviews.llvm.org/D37913



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


[libcxx] r313763 - Make libcxx tests work when llvm sources are not present.

2017-09-20 Thread Zachary Turner via cfe-commits
Author: zturner
Date: Wed Sep 20 09:01:50 2017
New Revision: 313763

URL: http://llvm.org/viewvc/llvm-project?rev=313763=rev
Log:
Make libcxx tests work when llvm sources are not present.

Despite a strong CMake warning that this is an unsupported
libcxx build configuration, some bots still rely on being
able to check out lit and libcxx independently with no
LLVM sources, and then run lit against libcxx.

A previous patch broke that workflow, so this is making it work
again.  Unfortunately, it breaks generation of the llvm-lit
script for libcxx, but we will just have to live with that until
a solution is found that allows libcxx to make more use of
llvm build pieces.  libcxx can still run tests by using the
ninja check target, or by running lit.py directly against the
build tree or source tree.

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

Modified:
libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake

Modified: libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake?rev=313763=313762=313763=diff
==
--- libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake (original)
+++ libcxx/trunk/cmake/Modules/HandleOutOfTreeLLVM.cmake Wed Sep 20 09:01:50 
2017
@@ -111,14 +111,17 @@ macro(configure_out_of_tree_llvm)
   # the configurator should write the script into.
   set(LLVM_LIT_OUTPUT_DIR "${libcxx_BINARY_DIR}/bin")
 
-  # Required LIT Configuration 
-  # Define the default arguments to use with 'lit', and an option for the user
-  # to override.
-  set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
-  if (MSVC OR XCODE)
-set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+  if (LLVM_INCLUDE_TESTS)
+# Required LIT Configuration 

+# Define the default arguments to use with 'lit', and an option for the 
user
+# to override.
+set(LLVM_EXTERNAL_LIT "${LLVM_MAIN_SRC_DIR}/utils/lit/lit.py")
+set(LIT_ARGS_DEFAULT "-sv --show-xfail --show-unsupported")
+if (MSVC OR XCODE)
+  set(LIT_ARGS_DEFAULT "${LIT_ARGS_DEFAULT} --no-progress-bar")
+endif()
+set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for 
lit")
   endif()
-  set(LLVM_LIT_ARGS "${LIT_ARGS_DEFAULT}" CACHE STRING "Default options for 
lit")
 
   # Required doc configuration
   if (LLVM_ENABLE_SPHINX)


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


[PATCH] D33722: [clang-tidy] Add checker for undelegated copy of base classes

2017-09-20 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:24
+withInitializer(cxxConstructExpr(unless(hasDescendant(implicitCastExpr(
+.bind("cruct-expr")));
+

You pick a more readable name than `cruct-expr`, like `construct-expr`?



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:37
+
+  // We match here because we want one warning (and FixIt) for every ctor.
+  const auto Matches = match(

Wouldn't registering this matcher achieve the same goal instead of needing to 
re-match?



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:59
+  // We want to write in the FixIt the template arguments too.
+  if (const auto *Decl = dyn_cast(
+  Init->getBaseClass()->getAsCXXRecordDecl())) {

Please pick a name other than `Decl`, since that's a type name.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:80
+
+  auto  = Result.Context->getSourceManager();
+  SourceLocation StartLoc = Ctor->getLocation();

Please do not use `auto` here.



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:95
+  if (Tok.is(tok::l_brace))
+FixItMsg += ": ";
+  FixItMsg += FixItInitList;

Space before the colon?



Comment at: clang-tidy/misc/CopyConstructorInitCheck.cpp:104
+
+  diag(Tok.getLocation(),
+   "calling an inherited constructor other than the copy constructor")

Insteaad of having to re-lex the physical source, can the AST should be 
modified to carry the information you need if it doesn't already have it? For 
instance, you can tell there is not initializer list by looking at 
`CXXConstructorDecl::getNumCtorInitializers()`.



Comment at: test/clang-tidy/misc-copy-constructor-init.cpp:27
+   // CHECK-MESSAGES: :[[@LINE-1]]:23: warning: calling an inherited 
constructor other than the copy constructor [misc-copy-constructor-init]
+   // CHECK-FIXES: X3(const X3& other): Copyable2(other), Copyable(other) 
{};
+};

Don't we want the ctor-inits to be in the same order as the bases are specified?


https://reviews.llvm.org/D33722



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


r313760 - Put target deduced from executable name at the start of argument list

2017-09-20 Thread Serge Pavlov via cfe-commits
Author: sepavloff
Date: Wed Sep 20 08:22:27 2017
New Revision: 313760

URL: http://llvm.org/viewvc/llvm-project?rev=313760=rev
Log:
Put target deduced from executable name at the start of argument list

When clang is called as 'target-clang', put deduced target option at
the start of argument list so that option '--target=' specified in command
line could override it.

This change fixes PR34671.

Added:
cfe/trunk/test/Driver/target-override.c
Modified:
cfe/trunk/tools/driver/driver.cpp

Added: cfe/trunk/test/Driver/target-override.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/target-override.c?rev=313760=auto
==
--- cfe/trunk/test/Driver/target-override.c (added)
+++ cfe/trunk/test/Driver/target-override.c Wed Sep 20 08:22:27 2017
@@ -0,0 +1,16 @@
+// REQUIRES: shell
+// REQUIRES: x86-registered-target
+
+// RUN: mkdir -p %T/testbin
+// RUN: [ ! -s %T/testbin/i386-clang ] || rm %T/testbin/i386-clang
+// RUN: ln -s %clang %T/testbin/i386-clang
+
+// Check if invocation of "foo-clang" adds option "-target foo".
+//
+// RUN: %T/testbin/i386-clang -c -no-canonical-prefixes %s -### 2>&1 | 
FileCheck -check-prefix CHECK-TG1 %s
+// CHECK-TG1: Target: i386
+
+// Check if invocation of "foo-clang -target bar" overrides option "-target 
foo".
+//
+// RUN: %T/testbin/i386-clang -c -no-canonical-prefixes -target x86_64 %s -### 
2>&1 | FileCheck -check-prefix CHECK-TG2 %s
+// CHECK-TG2: Target: x86_64

Modified: cfe/trunk/tools/driver/driver.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/driver/driver.cpp?rev=313760=313759=313760=diff
==
--- cfe/trunk/tools/driver/driver.cpp (original)
+++ cfe/trunk/tools/driver/driver.cpp Wed Sep 20 08:22:27 2017
@@ -209,16 +209,23 @@ extern int cc1as_main(ArrayRef ,
 std::set ) {
+  // Put target and mode arguments at the start of argument list so that
+  // arguments specified in command line could override them. Avoid putting
+  // them at index 0, as an option like '-cc1' must remain the first.
+  auto InsertionPoint = ArgVector.begin();
+  if (InsertionPoint != ArgVector.end())
+++InsertionPoint;
+
   if (NameParts.DriverMode) {
 // Add the mode flag to the arguments.
-ArgVector.insert(ArgVector.end(),
+ArgVector.insert(InsertionPoint,
  GetStableCStr(SavedStrings, NameParts.DriverMode));
   }
 
   if (NameParts.TargetIsValid) {
 const char *arr[] = {"-target", GetStableCStr(SavedStrings,
   NameParts.TargetPrefix)};
-ArgVector.insert(ArgVector.end(), std::begin(arr), std::end(arr));
+ArgVector.insert(InsertionPoint, std::begin(arr), std::end(arr));
   }
 }
 


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


[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-20 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

That's precisely what I've written, but, as I'd said before, such tests pass 
already without any modification in `NamespaceEndCommentsFixer`.


https://reviews.llvm.org/D37904



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


[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for quick review!


https://reviews.llvm.org/D38077



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


[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313759: [clangd] Put inacessible items to the end of 
completion list. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38077

Files:
  clang-tools-extra/trunk/clangd/ClangdUnit.cpp
  clang-tools-extra/trunk/test/clangd/authority-less-uri.test
  clang-tools-extra/trunk/test/clangd/completion-priorities.test
  clang-tools-extra/trunk/test/clangd/completion-snippet.test
  clang-tools-extra/trunk/test/clangd/completion.test
  clang-tools-extra/trunk/test/clangd/protocol.test

Index: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp
@@ -368,13 +368,39 @@
 }
   }
 
-  void FillSortText(const CodeCompletionString ,
-CompletionItem ) const {
+  static int GetSortPriority(const CodeCompletionString ) {
+int Score = CCS.getPriority();
 // Fill in the sortText of the CompletionItem.
-assert(CCS.getPriority() < 9 && "Expecting code completion result "
-"priority to have at most 5-digits");
+assert(Score <= 9 && "Expecting code completion result "
+ "priority to have at most 5-digits");
+
+const int Penalty = 10;
+switch (static_cast(CCS.getAvailability())) {
+case CXAvailability_Available:
+  // No penalty.
+  break;
+case CXAvailability_Deprecated:
+  Score += Penalty;
+  break;
+case CXAvailability_NotAccessible:
+  Score += 2 * Penalty;
+  break;
+case CXAvailability_NotAvailable:
+  Score += 3 * Penalty;
+  break;
+}
+
+return Score;
+  }
+
+  static void FillSortText(const CodeCompletionString ,
+   CompletionItem ) {
+int Priority = GetSortPriority(CCS);
+// Fill in the sortText of the CompletionItem.
+assert(Priority <= 99 &&
+   "Expecting sort priority to have at most 6-digits");
 llvm::raw_string_ostream(Item.sortText)
-<< llvm::format("%05d%s", CCS.getPriority(), Item.filterText.c_str());
+<< llvm::format("%06d%s", Priority, Item.filterText.c_str());
   }
 
   std::vector 
Index: clang-tools-extra/trunk/test/clangd/completion-priorities.test
===
--- clang-tools-extra/trunk/test/clangd/completion-priorities.test
+++ clang-tools-extra/trunk/test/clangd/completion-priorities.test
@@ -0,0 +1,36 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+
+Content-Length: 127
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 312
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class Foo {\npublic:\n  void pub();\n\nprotected:\n  void prot();\n\nprivate:\n  void priv();\n};\n\nvoid Foo::pub() {\n  this->\n}\n\nvoid test() {\n  Foo f;\n  f.\n}"}}}
+
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":12,"character":8}}}
+# The order of results returned by codeComplete seems to be
+# nondeterministic, so we check regardless of order.
+#
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHECK-DAG: {"label":"pub()","kind":2,"detail":"void","sortText":"34pub","filterText":"pub","insertText":"pub","insertTextFormat":1}
+# CHECK-DAG: {"label":"prot()","kind":2,"detail":"void","sortText":"34prot","filterText":"prot","insertText":"prot","insertTextFormat":1}
+# CHECK-DAG: {"label":"priv()","kind":2,"detail":"void","sortText":"34priv","filterText":"priv","insertText":"priv","insertTextFormat":1}
+# CHECK: ]}
+
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":3,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":17,"character":4}}}
+# CHECK: {"jsonrpc":"2.0","id":3,"result":[
+# CHECK-DAG: {"label":"pub()","kind":2,"detail":"void","sortText":"34pub","filterText":"pub","insertText":"pub","insertTextFormat":1}
+# CHECK-DAG: {"label":"prot()","kind":2,"detail":"void","sortText":"200034prot","filterText":"prot","insertText":"prot","insertTextFormat":1}
+# CHECK-DAG: {"label":"priv()","kind":2,"detail":"void","sortText":"200034priv","filterText":"priv","insertText":"priv","insertTextFormat":1}
+# CHECK: ]}
+
+Content-Length: 58
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown","params":null}
Index: clang-tools-extra/trunk/test/clangd/completion.test
===
--- clang-tools-extra/trunk/test/clangd/completion.test
+++ clang-tools-extra/trunk/test/clangd/completion.test

[clang-tools-extra] r313759 - [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 08:09:14 2017
New Revision: 313759

URL: http://llvm.org/viewvc/llvm-project?rev=313759=rev
Log:
[clangd] Put inacessible items to the end of completion list.

Reviewers: bkramer, krasimir

Reviewed By: krasimir

Subscribers: klimek, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clangd/completion-priorities.test
Modified:
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/test/clangd/authority-less-uri.test
clang-tools-extra/trunk/test/clangd/completion-snippet.test
clang-tools-extra/trunk/test/clangd/completion.test
clang-tools-extra/trunk/test/clangd/protocol.test

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=313759=313758=313759=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Sep 20 08:09:14 2017
@@ -368,13 +368,39 @@ private:
 }
   }
 
-  void FillSortText(const CodeCompletionString ,
-CompletionItem ) const {
+  static int GetSortPriority(const CodeCompletionString ) {
+int Score = CCS.getPriority();
 // Fill in the sortText of the CompletionItem.
-assert(CCS.getPriority() < 9 && "Expecting code completion result "
-"priority to have at most 5-digits");
+assert(Score <= 9 && "Expecting code completion result "
+ "priority to have at most 5-digits");
+
+const int Penalty = 10;
+switch (static_cast(CCS.getAvailability())) {
+case CXAvailability_Available:
+  // No penalty.
+  break;
+case CXAvailability_Deprecated:
+  Score += Penalty;
+  break;
+case CXAvailability_NotAccessible:
+  Score += 2 * Penalty;
+  break;
+case CXAvailability_NotAvailable:
+  Score += 3 * Penalty;
+  break;
+}
+
+return Score;
+  }
+
+  static void FillSortText(const CodeCompletionString ,
+   CompletionItem ) {
+int Priority = GetSortPriority(CCS);
+// Fill in the sortText of the CompletionItem.
+assert(Priority <= 99 &&
+   "Expecting sort priority to have at most 6-digits");
 llvm::raw_string_ostream(Item.sortText)
-<< llvm::format("%05d%s", CCS.getPriority(), Item.filterText.c_str());
+<< llvm::format("%06d%s", Priority, Item.filterText.c_str());
   }
 
   std::vector 

Modified: clang-tools-extra/trunk/test/clangd/authority-less-uri.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/authority-less-uri.test?rev=313759=313758=313759=diff
==
--- clang-tools-extra/trunk/test/clangd/authority-less-uri.test (original)
+++ clang-tools-extra/trunk/test/clangd/authority-less-uri.test Wed Sep 20 
08:09:14 2017
@@ -16,7 +16,7 @@ Content-Length: 146
 # Test authority-less URI
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 
 Content-Length: 172
@@ -25,7 +25,7 @@ Content-Length: 172
 # Test params parsing in the presence of a 1.x-compatible client (inlined 
"uri")
 #
 # CHECK: {"jsonrpc":"2.0","id":2,"result":[
-# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: 
{"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 44
 

Added: clang-tools-extra/trunk/test/clangd/completion-priorities.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/completion-priorities.test?rev=313759=auto
==
--- clang-tools-extra/trunk/test/clangd/completion-priorities.test (added)
+++ clang-tools-extra/trunk/test/clangd/completion-priorities.test Wed Sep 20 
08:09:14 2017
@@ -0,0 +1,36 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+
+Content-Length: 127
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 312
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class
 Foo {\npublic:\n  void pub();\n\nprotected:\n  void prot();\n\nprivate:\n  
void priv();\n};\n\nvoid Foo::pub() {\n  this->\n}\n\nvoid test() {\n  Foo 

[PATCH] D38083: [clangd] Skip informative qualifier chunks.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

Completion results look much nicer without them.
Informative qualifiers are stored for every method from a base class, even when
calling those methods does not require any qualifiers. For example,

  struct Foo { int foo(); };
  struct Bar : Foo { };
  void test() { Bar(). // Completion item label was 'Foo::foo' before,
   // but inserted text was simply 'foo'.
   // We now simply show 'foo' in completion item label.

They effectively cluttered the completion list without providing much value.


https://reviews.llvm.org/D38083

Files:
  clangd/ClangdUnit.cpp
  test/clangd/completion-qualifiers.test


Index: test/clangd/completion-qualifiers.test
===
--- /dev/null
+++ test/clangd/completion-qualifiers.test
@@ -0,0 +1,18 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 297
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class
 Foo {\n  public:\nint foo() const;\nint bar() const;\n};\n\nclass Bar 
: public Foo {\n  int foo() const;\n};\n\nvoid test() {\n  Bar().\n}"}}}
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":11,"character":8}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHEKC-DAG: {"label":"foo() 
const","kind":2,"detail":"int","sortText":"00035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHEKC-DAG: {"label":"bar() 
const","kind":2,"detail":"int","sortText":"00037bar","filterText":"bar","insertText":"bar","insertTextFormat":1}
+# CHEKC-DAG: {"label":"Foo::foo() 
const","kind":2,"detail":"int","sortText":"00037foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
Index: clangd/ClangdUnit.cpp
===
--- clangd/ClangdUnit.cpp
+++ clangd/ClangdUnit.cpp
@@ -383,6 +383,11 @@
 
 }; // CompletionItemsCollector
 
+bool isInformativeQualifierChunk(CodeCompletionString::Chunk const ) {
+  return Chunk.Kind == CodeCompletionString::CK_Informative &&
+ StringRef(Chunk.Text).endswith("::");
+}
+
 class PlainTextCompletionItemsCollector final
 : public CompletionItemsCollector {
 
@@ -395,6 +400,11 @@
   void ProcessChunks(const CodeCompletionString ,
  CompletionItem ) const override {
 for (const auto  : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // There's always exactly one CK_TypedText chunk.
@@ -427,6 +437,11 @@
  CompletionItem ) const override {
 unsigned ArgCount = 0;
 for (const auto  : CCS) {
+  // Informative qualifier chunks only clutter completion results, skip
+  // them.
+  if (isInformativeQualifierChunk(Chunk))
+continue;
+
   switch (Chunk.Kind) {
   case CodeCompletionString::CK_TypedText:
 // The piece of text that the user is expected to type to match


Index: test/clangd/completion-qualifiers.test
===
--- /dev/null
+++ test/clangd/completion-qualifiers.test
@@ -0,0 +1,18 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+Content-Length: 297
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"class Foo {\n  public:\nint foo() const;\nint bar() const;\n};\n\nclass Bar : public Foo {\n  int foo() const;\n};\n\nvoid test() {\n  Bar().\n}"}}}
+Content-Length: 151
+
+{"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":11,"character":8}}}
+# CHECK: {"jsonrpc":"2.0","id":2,"result":[
+# CHEKC-DAG: {"label":"foo() const","kind":2,"detail":"int","sortText":"00035foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHEKC-DAG: {"label":"bar() const","kind":2,"detail":"int","sortText":"00037bar","filterText":"bar","insertText":"bar","insertTextFormat":1}
+# CHEKC-DAG: {"label":"Foo::foo() const","kind":2,"detail":"int","sortText":"00037foo","filterText":"foo","insertText":"foo","insertTextFormat":1}
+# CHECK: ]}
+Content-Length: 44
+
+{"jsonrpc":"2.0","id":4,"method":"shutdown"}
Index: 

[PATCH] D38081: Set completion priority of destructors and operators to CCP_Unlikely.

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

+1! I totally agree with this!


https://reviews.llvm.org/D38081



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


[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir accepted this revision.
krasimir added a comment.
This revision is now accepted and ready to land.

Makes sense.


https://reviews.llvm.org/D38077



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


[PATCH] D37263: [clang-format] Ignore case when sorting using-declarations

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir updated this revision to Diff 115998.
krasimir added a comment.

- Stable sort using declarations


https://reviews.llvm.org/D37263

Files:
  lib/Format/UsingDeclarationsSorter.cpp
  unittests/Format/UsingDeclarationsSorterTest.cpp

Index: unittests/Format/UsingDeclarationsSorterTest.cpp
===
--- unittests/Format/UsingDeclarationsSorterTest.cpp
+++ unittests/Format/UsingDeclarationsSorterTest.cpp
@@ -86,6 +86,77 @@
   "using a, b;"));
 }
 
+TEST_F(UsingDeclarationsSorterTest, SortsCaseInsensitively) {
+  EXPECT_EQ("using A;\n"
+"using a;",
+sortUsingDeclarations("using A;\n"
+  "using a;"));
+  EXPECT_EQ("using a;\n"
+"using A;",
+sortUsingDeclarations("using a;\n"
+  "using A;"));
+  EXPECT_EQ("using a;\n"
+"using B;",
+sortUsingDeclarations("using B;\n"
+  "using a;"));
+  EXPECT_EQ("using _;\n"
+"using a;",
+sortUsingDeclarations("using a;\n"
+  "using _;"));
+  EXPECT_EQ("using a::_;\n"
+"using a::a;",
+sortUsingDeclarations("using a::a;\n"
+  "using a::_;"));
+
+  EXPECT_EQ("using ::testing::_;\n"
+"using ::testing::Aardvark;\n"
+"using ::testing::apple::Honeycrisp;\n"
+"using ::testing::Xylophone;\n"
+"using ::testing::zebra::Stripes;",
+sortUsingDeclarations("using ::testing::Aardvark;\n"
+  "using ::testing::Xylophone;\n"
+  "using ::testing::_;\n"
+  "using ::testing::apple::Honeycrisp;\n"
+  "using ::testing::zebra::Stripes;"));
+}
+
+TEST_F(UsingDeclarationsSorterTest, SortsStably) {
+  EXPECT_EQ("using a;\n"
+"using a;\n"
+"using A;\n"
+"using a;\n"
+"using A;\n"
+"using a;\n"
+"using A;\n"
+"using a;\n"
+"using B;\n"
+"using b;\n"
+"using b;\n"
+"using B;\n"
+"using b;\n"
+"using b;\n"
+"using b;\n"
+"using B;\n"
+"using b;",
+sortUsingDeclarations("using a;\n"
+  "using B;\n"
+  "using a;\n"
+  "using b;\n"
+  "using A;\n"
+  "using a;\n"
+  "using b;\n"
+  "using B;\n"
+  "using b;\n"
+  "using A;\n"
+  "using a;\n"
+  "using b;\n"
+  "using b;\n"
+  "using B;\n"
+  "using b;\n"
+  "using A;\n"
+  "using a;"));
+}
+
 TEST_F(UsingDeclarationsSorterTest, SortsMultipleTopLevelDeclarations) {
   EXPECT_EQ("using a;\n"
 "using b;\n"
Index: lib/Format/UsingDeclarationsSorter.cpp
===
--- lib/Format/UsingDeclarationsSorter.cpp
+++ lib/Format/UsingDeclarationsSorter.cpp
@@ -34,7 +34,7 @@
   : Line(Line), Label(Label) {}
 
   bool operator<(const UsingDeclaration ) const {
-return Label < Other.Label;
+return StringRef(Label).compare_lower(Other.Label) < 0;
   }
 };
 
@@ -78,7 +78,8 @@
 const SourceManager , tooling::Replacements *Fixes) {
   SmallVector SortedUsingDeclarations(
   UsingDeclarations->begin(), UsingDeclarations->end());
-  std::sort(SortedUsingDeclarations.begin(), SortedUsingDeclarations.end());
+  std::stable_sort(SortedUsingDeclarations.begin(),
+   SortedUsingDeclarations.end());
   for (size_t I = 0, E = UsingDeclarations->size(); I < E; ++I) {
 if ((*UsingDeclarations)[I].Line == SortedUsingDeclarations[I].Line)
   continue;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38081: Set completion priority of destructors and operators to CCP_Unlikely.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.
Herald added a subscriber: eraman.

It will move destructors and operators to the end of completion list.
Destructors and operators are currently very high on the completion
list, as they have the same priority as member functions. However,
they are clearly not something users usually choose in completion
lists.


https://reviews.llvm.org/D38081

Files:
  lib/Sema/SemaCodeComplete.cpp
  test/Index/complete-access-checks.cpp
  test/Index/complete-cxx-inline-methods.cpp
  test/Index/complete-qualified.cpp
  test/Index/complete-with-annotations.cpp

Index: test/Index/complete-with-annotations.cpp
===
--- test/Index/complete-with-annotations.cpp
+++ test/Index/complete-with-annotations.cpp
@@ -17,7 +17,7 @@
 // CHECK: FieldDecl:{ResultType int}{TypedText field} (35) ("three", "two", "one")
 // CHECK: CXXMethod:{ResultType void}{TypedText func2}{LeftParen (}{RightParen )} (34) ("some annotation")
 // CHECK: FieldDecl:{ResultType int}{TypedText member2} (35) ("another annotation", "some annotation")
-// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (34)
+// CHECK: CXXMethod:{ResultType X &}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (79)
 // CHECK: ClassDecl:{TypedText X}{Text ::} (75)
-// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (34)
+// CHECK: CXXDestructor:{ResultType void}{TypedText ~X}{LeftParen (}{RightParen )} (79)
 
Index: test/Index/complete-qualified.cpp
===
--- test/Index/complete-qualified.cpp
+++ test/Index/complete-qualified.cpp
@@ -17,4 +17,4 @@
 // CHECK-CC1: FieldDecl:{ResultType C}{TypedText c} (35)
 // CHECK-CC1: ClassDecl:{TypedText Foo} (35)
 // CHECK-CC1: CXXMethod:{ResultType Foo &}{TypedText operator=}{LeftParen (}{Placeholder const Foo &}{RightParen )}
-// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (35)
+// CHECK-CC1: CXXDestructor:{ResultType void}{TypedText ~Foo}{LeftParen (}{RightParen )} (80)
Index: test/Index/complete-cxx-inline-methods.cpp
===
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -25,11 +25,11 @@
 
 // RUN: c-index-test -code-completion-at=%s:4:9 -std=c++98 %s | FileCheck %s
 // RUN: c-index-test -code-completion-at=%s:13:7 -std=c++98 %s | FileCheck %s
-// CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (34)
+// CHECK:  CXXMethod:{ResultType MyCls::Vec &}{TypedText operator=}{LeftParen (}{Placeholder const MyCls::Vec &}{RightParen )} (79)
 // CHECK-NEXT: StructDecl:{TypedText Vec}{Text ::} (75)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText x} (35)
 // CHECK-NEXT: FieldDecl:{ResultType int}{TypedText y} (35)
-// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (34)
+// CHECK-NEXT: CXXDestructor:{ResultType void}{TypedText ~Vec}{LeftParen (}{RightParen )} (79)
 // CHECK-NEXT: Completion contexts:
 // CHECK-NEXT: Dot member access
 // CHECK-NEXT: Container Kind: StructDecl
Index: test/Index/complete-access-checks.cpp
===
--- test/Index/complete-access-checks.cpp
+++ test/Index/complete-access-checks.cpp
@@ -41,22 +41,22 @@
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member1} (37)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member2} (37) (inaccessible)
 // CHECK-SUPER-ACCESS: FieldDecl:{ResultType int}{Informative X::}{TypedText member3} (37) (inaccessible)
-// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (34)
-// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (36)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType Y &}{TypedText operator=}{LeftParen (}{Placeholder const Y &}{RightParen )} (79)
+// CHECK-SUPER-ACCESS: CXXMethod:{ResultType X &}{Text X::}{TypedText operator=}{LeftParen (}{Placeholder const X &}{RightParen )} (81)
 // CHECK-SUPER-ACCESS: StructDecl:{TypedText X}{Text ::} (77)
 // CHECK-SUPER-ACCESS: StructDecl:{TypedText Y}{Text ::} (75)
-// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (36)
-// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (34)
+// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{Informative X::}{TypedText ~X}{LeftParen (}{RightParen )} (81)
+// CHECK-SUPER-ACCESS: CXXDestructor:{ResultType void}{TypedText ~Y}{LeftParen (}{RightParen )} (79)
 
 // CHECK-ACCESS: 

[PATCH] D37904: [clang-format] Fix FixNamespaceComments when BraceWrapping AfterNamespace is true.

2017-09-20 Thread Krasimir Georgiev via Phabricator via cfe-commits
krasimir added a comment.

This is how you could add a test in `NamespaceEndCommentsFixerTest.cpp`:

  TEST_F(NamespaceEndCommentsFixerTest, FixesNamespaceCommentsInAllmanStyle) {
FormatStyle AllmanStyle = getLLVMStyle();
AllmanStyle.BreakBeforeBraces = FormatStyle::BS_Allman;
EXPECT_EQ("namespace a\n"
  "{\n"
  "void f();\n"
  "void g();\n"
  "}// namespace a\n",
  fixNamespaceEndComments("namespace a\n"
  "{\n"
  "void f();\n"
  "void g();\n"
  "}\n",
  AllmanStyle));
  }


https://reviews.llvm.org/D37904



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


r313756 - Replace r313747, don't always warn on enums, rework testcases.

2017-09-20 Thread Roman Lebedev via cfe-commits
Author: lebedevri
Date: Wed Sep 20 06:50:01 2017
New Revision: 313756

URL: http://llvm.org/viewvc/llvm-project?rev=313756=rev
Log:
Replace r313747, don't always warn on enums, rework testcases.

As Aaron Ballman has pointed out, that is not really correct.
So the key problem there is the invalidity of the testcase.

Revert r313747, and rework testcase in such a way, so these
details (platform-specific default enum sigdness) are
accounted for.

Also, add a C++-specific testcase.

Added:
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.cpp
Modified:
cfe/trunk/lib/Sema/SemaChecking.cpp
cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c

Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=313756=313755=313756=diff
==
--- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
+++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 20 06:50:01 2017
@@ -8592,26 +8592,22 @@ bool CheckTautologicalComparisonWithZero
 
   bool Match = true;
 
-  if (Op == BO_LT && IsZero(S, RHS) &&
-  (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
+  if (Op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison
 : diag::warn_lunsigned_always_true_comparison)
 << "< 0" << false << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_GE && IsZero(S, RHS) &&
- (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
+  } else if (Op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(LHS) ? diag::warn_lunsigned_enum_always_true_comparison
 : diag::warn_lunsigned_always_true_comparison)
 << ">= 0" << true << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_GT && IsZero(S, LHS) &&
- (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
+  } else if (Op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison
 : diag::warn_runsigned_always_true_comparison)
 << "0 >" << false << LHS->getSourceRange() << RHS->getSourceRange();
-  } else if (Op == BO_LE && IsZero(S, LHS) &&
- (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
+  } else if (Op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, LHS)) {
 S.Diag(E->getOperatorLoc(),
HasEnumType(RHS) ? diag::warn_runsigned_enum_always_true_comparison
 : diag::warn_runsigned_always_true_comparison)

Modified: cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c?rev=313756=313755=313756=diff
==
--- cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c (original)
+++ cfe/trunk/test/Sema/tautological-unsigned-enum-zero-compare.c Wed Sep 20 
06:50:01 2017
@@ -1,11 +1,16 @@
-// RUN: %clang_cc1 -fsyntax-only -DTEST -verify %s
-// RUN: %clang_cc1 -fsyntax-only -Wno-tautological-unsigned-enum-zero-compare 
-verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-linux-gnu -fsyntax-only -DALL_WARN 
-verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only -DSIGN_WARN -verify %s
+// RUN: %clang_cc1 -triple=x86_64-pc-win32 -fsyntax-only 
-Wno-tautological-unsigned-enum-zero-compare -verify %s
+
+// Okay, this is where it gets complicated.
+// Then default enum sigdness is target-specific.
+// On windows, it is signed by default. We do not want to warn in that case.
 
 int main() {
   enum A { A_foo, A_bar };
   enum A a;
 
-#ifdef TEST
+#ifdef ALL_WARN
   if (a < 0) // expected-warning {{comparison of unsigned enum expression < 0 
is always false}}
 return 0;
   if (a >= 0) // expected-warning {{comparison of unsigned enum expression >= 
0 is always true}}
@@ -16,6 +21,23 @@ int main() {
 return 0;
   if (a < 0U) // expected-warning {{comparison of unsigned enum expression < 0 
is always false}}
 return 0;
+  if (a >= 0U) // expected-warning {{comparison of unsigned enum expression >= 
0 is always true}}
+return 0;
+  if (0U <= a) // expected-warning {{comparison of 0 <= unsigned enum 
expression is always true}}
+return 0;
+  if (0U > a) // expected-warning {{comparison of 0 > unsigned enum expression 
is always false}}
+return 0;
+#elif defined(SIGN_WARN)
+  if (a < 0) // ok
+return 0;
+  if (a >= 0) // ok
+return 0;
+  if (0 <= a) // ok
+return 0;
+  if (0 > a) // ok
+return 0;
+  if (a < 0U) // expected-warning {{comparison of unsigned enum 

Re: r310983 - PR19668, PR23034: Fix handling of move constructors and deleted copy

2017-09-20 Thread Alex L via cfe-commits
On 16 August 2017 at 02:49, Richard Smith via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: rsmith
> Date: Tue Aug 15 18:49:53 2017
> New Revision: 310983
>
> URL: http://llvm.org/viewvc/llvm-project?rev=310983=rev
> Log:
> PR19668, PR23034: Fix handling of move constructors and deleted copy
> constructors when deciding whether classes should be passed indirectly.
>
> This fixes ABI differences between Clang and GCC:
>
>  * Previously, Clang ignored the move constructor when making this
>determination. It now takes the move constructor into account, per
>https://github.com/itanium-cxx-abi/cxx-abi/pull/17 (this change may
>seem recent, but the ABI change was agreed on the Itanium C++ ABI
>list a long time ago).
>
>  * Previously, Clang's behavior when the copy constructor was deleted
>was unstable -- depending on whether the lazy declaration of the
>copy constructor had been triggered, you might get different behavior.
>We now eagerly declare the copy constructor whenever its deletedness
>is unclear, and ignore deleted copy/move constructors when looking for
>a trivial such constructor.
>
> This also fixes an ABI difference between Clang and MSVC:
>
>  * If the copy constructor would be implicitly deleted (but has not been
>lazily declared yet), for instance because the class has an rvalue
>reference member, we would pass it directly. We now pass such a class
>indirectly, matching MSVC.
>
> Based on a patch by Vassil Vassilev, which was based on a patch by Bernd
> Schmidt, which was based on a patch by Reid Kleckner!
>
> This is a re-commit of r310401, which was reverted in r310464 due to ARM
> failures (which should now be fixed).
>
> Modified:
> cfe/trunk/include/clang/AST/DeclCXX.h
> cfe/trunk/lib/AST/ASTImporter.cpp
> cfe/trunk/lib/AST/DeclCXX.cpp
> cfe/trunk/lib/CodeGen/CGCXXABI.cpp
> cfe/trunk/lib/CodeGen/ItaniumCXXABI.cpp
> cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
> cfe/trunk/lib/Sema/SemaDeclCXX.cpp
> cfe/trunk/lib/Serialization/ASTReaderDecl.cpp
> cfe/trunk/lib/Serialization/ASTWriter.cpp
> cfe/trunk/test/CodeGenCXX/uncopyable-args.cpp
> cfe/trunk/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp
>
> Modified: cfe/trunk/include/clang/AST/DeclCXX.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/DeclCXX.h?rev=310983=310982=310983=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/DeclCXX.h (original)
> +++ cfe/trunk/include/clang/AST/DeclCXX.h Tue Aug 15 18:49:53 2017
> @@ -374,6 +374,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if a defaulted corresponding
> special
>  /// member can't be fully analyzed without performing overload
> resolution.
>  /// @{
> +unsigned NeedOverloadResolutionForCopyConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveConstructor : 1;
>  unsigned NeedOverloadResolutionForMoveAssignment : 1;
>  unsigned NeedOverloadResolutionForDestructor : 1;
> @@ -382,6 +383,7 @@ class CXXRecordDecl : public RecordDecl
>  /// \brief These flags are \c true if an implicit defaulted
> corresponding
>  /// special member would be defined as deleted.
>  /// @{
> +unsigned DefaultedCopyConstructorIsDeleted : 1;
>  unsigned DefaultedMoveConstructorIsDeleted : 1;
>  unsigned DefaultedMoveAssignmentIsDeleted : 1;
>  unsigned DefaultedDestructorIsDeleted : 1;
> @@ -414,6 +416,12 @@ class CXXRecordDecl : public RecordDecl
>  /// constructor.
>  unsigned HasDefaultedDefaultConstructor : 1;
>
> +/// \brief True if this class can be passed in a
> non-address-preserving
> +/// fashion (such as in registers) according to the C++ language
> rules.
> +/// This does not imply anything about how the ABI in use will
> actually
> +/// pass an object of this class.
> +unsigned CanPassInRegisters : 1;
> +
>  /// \brief True if a defaulted default constructor for this class
> would
>  /// be constexpr.
>  unsigned DefaultedDefaultConstructorIsConstexpr : 1;
> @@ -810,18 +818,50 @@ public:
>  return data().FirstFriend.isValid();
>}
>
> +  /// \brief \c true if a defaulted copy constructor for this class would
> be
> +  /// deleted.
> +  bool defaultedCopyConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForCopyConstructor() ||
> +(data().DeclaredSpecialMembers & SMF_CopyConstructor)) &&
> +   "this property has not yet been computed by Sema");
> +return data().DefaultedCopyConstructorIsDeleted;
> +  }
> +
> +  /// \brief \c true if a defaulted move constructor for this class would
> be
> +  /// deleted.
> +  bool defaultedMoveConstructorIsDeleted() const {
> +assert((!needsOverloadResolutionForMoveConstructor() ||
> +(data().DeclaredSpecialMembers & SMF_MoveConstructor)) &&
> +   "this property 

[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL313754: [clangd] Serialize onDiagnosticsReady callbacks for 
the same file. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38032

Files:
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/DraftStore.h
  clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Index: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
===
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -898,5 +899,67 @@
   }
 }
 
+TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
+  class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
+  public:
+NoConcurrentAccessDiagConsumer(std::promise StartSecondReparse)
+: StartSecondReparse(std::move(StartSecondReparse)) {}
+
+void onDiagnosticsReady(
+PathRef File,
+Tagged Diagnostics) override {
+
+  std::unique_lock Lock(Mutex, std::try_to_lock_t());
+  ASSERT_TRUE(Lock.owns_lock())
+  << "Detected concurrent onDiagnosticsReady calls for the same file.";
+  if (FirstRequest) {
+FirstRequest = false;
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));
+  }
+}
+
+  private:
+std::mutex Mutex;
+bool FirstRequest = true;
+std::promise StartSecondReparse;
+  };
+
+  const auto SourceContentsWithoutErrors = R"cpp(
+int a;
+int b;
+int c;
+int d;
+)cpp";
+
+  const auto SourceContentsWithErrors = R"cpp(
+int a = x;
+int b;
+int c;
+int d;
+)cpp";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  llvm::StringMap FileContents;
+  FileContents[FooCpp] = "";
+  ConstantFSProvider FS(buildTestFS(FileContents));
+
+  std::promise StartSecondReparsePromise;
+  std::future StartSecondReparse = StartSecondReparsePromise.get_future();
+
+  NoConcurrentAccessDiagConsumer DiagConsumer(
+  std::move(StartSecondReparsePromise));
+
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  ClangdServer Server(CDB, DiagConsumer, FS, 4, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
+  Server.addDocument(FooCpp, SourceContentsWithErrors);
+  StartSecondReparse.wait();
+
+  auto Future = Server.addDocument(FooCpp, SourceContentsWithoutErrors);
+  Future.wait();
+}
+
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -284,6 +284,13 @@
   // ClangdServer
   ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
+
+  /// Used to serialize diagnostic callbacks.
+  /// FIXME(ibiryukov): get rid of an extra map and put all version counters
+  /// into CppFile.
+  std::mutex DiagnosticsMutex;
+  /// Maps from a filename to the latest version of reported diagnostics.
+  llvm::StringMap ReportedDiagnosticVersions;
 };
 
 } // namespace clangd
Index: clang-tools-extra/trunk/clangd/DraftStore.h
===
--- clang-tools-extra/trunk/clangd/DraftStore.h
+++ clang-tools-extra/trunk/clangd/DraftStore.h
@@ -13,15 +13,16 @@
 #include "Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include 
 #include 
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
-/// Using 'unsigned' here to avoid undefined behaviour on overflow.
-typedef unsigned DocVersion;
+/// Using unsigned int type here to avoid undefined behaviour on overflow.
+typedef uint64_t DocVersion;
 
 /// Document draft with a version of this draft.
 struct VersionedDraft {
Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -315,6 +315,19 @@
 auto Diags = DeferredRebuild.get();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
+
+// We need to serialize access to resulting diagnostics to avoid calling
+// `onDiagnosticsReady` in the wrong order.
+std::lock_guard DiagsLock(DiagnosticsMutex);
+DocVersion  = ReportedDiagnosticVersions[FileStr];
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.
+if (Version 

[clang-tools-extra] r313754 - [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Sep 20 05:58:55 2017
New Revision: 313754

URL: http://llvm.org/viewvc/llvm-project?rev=313754=rev
Log:
[clangd] Serialize onDiagnosticsReady callbacks for the same file.

Summary:
Calls to onDiagnosticsReady were done concurrently before. This sometimes
led to older versions of diagnostics being reported to the user after
the newer versions.

Reviewers: klimek, bkramer, krasimir

Reviewed By: klimek

Subscribers: cfe-commits

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

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/DraftStore.h
clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=313754=313753=313754=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Sep 20 05:58:55 2017
@@ -315,6 +315,19 @@ std::future ClangdServer::schedule
 auto Diags = DeferredRebuild.get();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
+
+// We need to serialize access to resulting diagnostics to avoid calling
+// `onDiagnosticsReady` in the wrong order.
+std::lock_guard DiagsLock(DiagnosticsMutex);
+DocVersion  = ReportedDiagnosticVersions[FileStr];
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.
+if (Version < LastReportedDiagsVersion)
+  return;
+LastReportedDiagsVersion = Version;
+
 DiagConsumer.onDiagnosticsReady(FileStr,
 make_tagged(std::move(*Diags), Tag));
   };

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=313754=313753=313754=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Sep 20 05:58:55 2017
@@ -284,6 +284,13 @@ private:
   // ClangdServer
   ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
+
+  /// Used to serialize diagnostic callbacks.
+  /// FIXME(ibiryukov): get rid of an extra map and put all version counters
+  /// into CppFile.
+  std::mutex DiagnosticsMutex;
+  /// Maps from a filename to the latest version of reported diagnostics.
+  llvm::StringMap ReportedDiagnosticVersions;
 };
 
 } // namespace clangd

Modified: clang-tools-extra/trunk/clangd/DraftStore.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/DraftStore.h?rev=313754=313753=313754=diff
==
--- clang-tools-extra/trunk/clangd/DraftStore.h (original)
+++ clang-tools-extra/trunk/clangd/DraftStore.h Wed Sep 20 05:58:55 2017
@@ -13,6 +13,7 @@
 #include "Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include 
 #include 
 #include 
 #include 
@@ -20,8 +21,8 @@
 namespace clang {
 namespace clangd {
 
-/// Using 'unsigned' here to avoid undefined behaviour on overflow.
-typedef unsigned DocVersion;
+/// Using unsigned int type here to avoid undefined behaviour on overflow.
+typedef uint64_t DocVersion;
 
 /// Document draft with a version of this draft.
 struct VersionedDraft {

Modified: clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp?rev=313754=313753=313754=diff
==
--- clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp (original)
+++ clang-tools-extra/trunk/unittests/clangd/ClangdTests.cpp Wed Sep 20 
05:58:55 2017
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -898,5 +899,67 @@ int d;
   }
 }
 
+TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
+  class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
+  public:
+NoConcurrentAccessDiagConsumer(std::promise StartSecondReparse)
+: StartSecondReparse(std::move(StartSecondReparse)) {}
+
+void onDiagnosticsReady(
+PathRef File,
+Tagged Diagnostics) override {
+
+  std::unique_lock Lock(Mutex, std::try_to_lock_t());
+  ASSERT_TRUE(Lock.owns_lock())
+  << "Detected concurrent onDiagnosticsReady calls for the same file.";
+  if (FirstRequest) {
+FirstRequest = false;
+StartSecondReparse.set_value();
+// Sleep long 

[PATCH] D13811: [clang-format] AllowShortFunctionsOnASingleLine: true/Empty didn't work with BreakBeforeBraces: Linux/Allman.

2017-09-20 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius abandoned this revision.
curdeius added a comment.

This was fixed by https://reviews.llvm.org/rL312904 and other commits.


https://reviews.llvm.org/D13811



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


Re: r313747 - [Sema] CheckTautologicalComparisonWithZero(): always complain about enums

2017-09-20 Thread Aaron Ballman via cfe-commits
On Wed, Sep 20, 2017 at 6:15 AM, Roman Lebedev via cfe-commits
 wrote:
> Author: lebedevri
> Date: Wed Sep 20 03:15:27 2017
> New Revision: 313747
>
> URL: http://llvm.org/viewvc/llvm-project?rev=313747=rev
> Log:
> [Sema] CheckTautologicalComparisonWithZero(): always complain about enums
>
> Hopefully fixes test-clang-msc-x64-on-i686-linux-RA build.
>
> The underlying problem is that the enum is signed there.
> Yet still, it is invalid for it to contain negative values,
> so the comparison is always tautological in this case.

Why is it invalid for the comparand to contain a negative value when
the enum type is signed?

~Aaron

>
> No differential, but related to https://reviews.llvm.org/D37629
>
> Modified:
> cfe/trunk/lib/Sema/SemaChecking.cpp
>
> Modified: cfe/trunk/lib/Sema/SemaChecking.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaChecking.cpp?rev=313747=313746=313747=diff
> ==
> --- cfe/trunk/lib/Sema/SemaChecking.cpp (original)
> +++ cfe/trunk/lib/Sema/SemaChecking.cpp Wed Sep 20 03:15:27 2017
> @@ -8592,22 +8592,26 @@ bool CheckTautologicalComparisonWithZero
>
>bool Match = true;
>
> -  if (Op == BO_LT && isNonBooleanUnsignedValue(LHS) && IsZero(S, RHS)) {
> +  if (Op == BO_LT && IsZero(S, RHS) &&
> +  (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(LHS) ? 
> diag::warn_lunsigned_enum_always_true_comparison
>  : diag::warn_lunsigned_always_true_comparison)
>  << "< 0" << false << LHS->getSourceRange() << RHS->getSourceRange();
> -  } else if (Op == BO_GE && isNonBooleanUnsignedValue(LHS) && IsZero(S, 
> RHS)) {
> +  } else if (Op == BO_GE && IsZero(S, RHS) &&
> + (isNonBooleanUnsignedValue(LHS) || HasEnumType(LHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(LHS) ? 
> diag::warn_lunsigned_enum_always_true_comparison
>  : diag::warn_lunsigned_always_true_comparison)
>  << ">= 0" << true << LHS->getSourceRange() << RHS->getSourceRange();
> -  } else if (Op == BO_GT && isNonBooleanUnsignedValue(RHS) && IsZero(S, 
> LHS)) {
> +  } else if (Op == BO_GT && IsZero(S, LHS) &&
> + (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(RHS) ? 
> diag::warn_runsigned_enum_always_true_comparison
>  : diag::warn_runsigned_always_true_comparison)
>  << "0 >" << false << LHS->getSourceRange() << RHS->getSourceRange();
> -  } else if (Op == BO_LE && isNonBooleanUnsignedValue(RHS) && IsZero(S, 
> LHS)) {
> +  } else if (Op == BO_LE && IsZero(S, LHS) &&
> + (isNonBooleanUnsignedValue(RHS) || HasEnumType(RHS))) {
>  S.Diag(E->getOperatorLoc(),
> HasEnumType(RHS) ? 
> diag::warn_runsigned_enum_always_true_comparison
>  : diag::warn_runsigned_always_true_comparison)
>
>
> ___
> cfe-commits mailing list
> cfe-commits@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r313752 - [clang-tidy] Fix linkage-related compiler errors in clang-tidy tests

2017-09-20 Thread Alexander Kornienko via cfe-commits
Author: alexfh
Date: Wed Sep 20 05:16:35 2017
New Revision: 313752

URL: http://llvm.org/viewvc/llvm-project?rev=313752=rev
Log:
[clang-tidy] Fix linkage-related compiler errors in clang-tidy tests

Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp?rev=313752=313751=313752=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp 
(original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-inefficient-algorithm.cpp Wed 
Sep 20 05:16:35 2017
@@ -43,19 +43,23 @@ template  struct
 
 template > struct multiset : set {};
 
-template  FwIt find(FwIt, FwIt, const K &);
+template 
+FwIt find(FwIt, FwIt end, const K &) { return end; }
 
 template 
-FwIt find(FwIt, FwIt, const K &, Cmp);
+FwIt find(FwIt, FwIt end, const K &, Cmp) { return end; }
 
-template  FwIt find_if(FwIt, FwIt, Pred);
+template 
+FwIt find_if(FwIt, FwIt end, Pred) { return end; }
 
-template  FwIt count(FwIt, FwIt, const K &);
+template 
+unsigned count(FwIt, FwIt, const K &) { return 0; }
 
-template  FwIt lower_bound(FwIt, FwIt, const K &);
+template 
+FwIt lower_bound(FwIt, FwIt end, const K &) { return end; }
 
 template 
-FwIt lower_bound(FwIt, FwIt, const K &, Ord);
+FwIt lower_bound(FwIt, FwIt end, const K &, Ord) { return end; }
 }
 
 #define FIND_IN_SET(x) find(x.begin(), x.end(), 10)

Modified: clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp?rev=313752=313751=313752=diff
==
--- clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-move-const-arg.cpp Wed Sep 20 
05:16:35 2017
@@ -10,7 +10,9 @@ template  struct remove_re
 template  struct remove_reference<_Tp &&> { typedef _Tp type; };
 
 template 
-constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t);
+constexpr typename std::remove_reference<_Tp>::type &(_Tp &&__t) {
+  return static_cast::type &&>(__t);
+}
 
 } // namespace std
 


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


[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

Thanks for the review!


https://reviews.llvm.org/D38032



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


[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 115985.
ilya-biryukov marked an inline comment as done.
ilya-biryukov added a comment.

- Added a comment to version map.
- Fixed compilation after rebase.


https://reviews.llvm.org/D38032

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h
  clangd/DraftStore.h
  unittests/clangd/ClangdTests.cpp

Index: unittests/clangd/ClangdTests.cpp
===
--- unittests/clangd/ClangdTests.cpp
+++ unittests/clangd/ClangdTests.cpp
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 
 namespace clang {
@@ -898,5 +899,67 @@
   }
 }
 
+TEST_F(ClangdThreadingTest, NoConcurrentDiagnostics) {
+  class NoConcurrentAccessDiagConsumer : public DiagnosticsConsumer {
+  public:
+NoConcurrentAccessDiagConsumer(std::promise StartSecondReparse)
+: StartSecondReparse(std::move(StartSecondReparse)) {}
+
+void onDiagnosticsReady(
+PathRef File,
+Tagged Diagnostics) override {
+
+  std::unique_lock Lock(Mutex, std::try_to_lock_t());
+  ASSERT_TRUE(Lock.owns_lock())
+  << "Detected concurrent onDiagnosticsReady calls for the same file.";
+  if (FirstRequest) {
+FirstRequest = false;
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));
+  }
+}
+
+  private:
+std::mutex Mutex;
+bool FirstRequest = true;
+std::promise StartSecondReparse;
+  };
+
+  const auto SourceContentsWithoutErrors = R"cpp(
+int a;
+int b;
+int c;
+int d;
+)cpp";
+
+  const auto SourceContentsWithErrors = R"cpp(
+int a = x;
+int b;
+int c;
+int d;
+)cpp";
+
+  auto FooCpp = getVirtualTestFilePath("foo.cpp");
+  llvm::StringMap FileContents;
+  FileContents[FooCpp] = "";
+  ConstantFSProvider FS(buildTestFS(FileContents));
+
+  std::promise StartSecondReparsePromise;
+  std::future StartSecondReparse = StartSecondReparsePromise.get_future();
+
+  NoConcurrentAccessDiagConsumer DiagConsumer(
+  std::move(StartSecondReparsePromise));
+
+  MockCompilationDatabase CDB(/*AddFreestandingFlag=*/true);
+  ClangdServer Server(CDB, DiagConsumer, FS, 4, /*SnippetCompletions=*/false,
+  EmptyLogger::getInstance());
+  Server.addDocument(FooCpp, SourceContentsWithErrors);
+  StartSecondReparse.wait();
+
+  auto Future = Server.addDocument(FooCpp, SourceContentsWithoutErrors);
+  Future.wait();
+}
+
 } // namespace clangd
 } // namespace clang
Index: clangd/DraftStore.h
===
--- clangd/DraftStore.h
+++ clangd/DraftStore.h
@@ -13,15 +13,16 @@
 #include "Path.h"
 #include "clang/Basic/LLVM.h"
 #include "llvm/ADT/StringMap.h"
+#include 
 #include 
 #include 
 #include 
 
 namespace clang {
 namespace clangd {
 
-/// Using 'unsigned' here to avoid undefined behaviour on overflow.
-typedef unsigned DocVersion;
+/// Using unsigned int type here to avoid undefined behaviour on overflow.
+typedef uint64_t DocVersion;
 
 /// Document draft with a version of this draft.
 struct VersionedDraft {
Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -284,6 +284,13 @@
   // ClangdServer
   ClangdScheduler WorkScheduler;
   bool SnippetCompletions;
+
+  /// Used to serialize diagnostic callbacks.
+  /// FIXME(ibiryukov): get rid of an extra map and put all version counters
+  /// into CppFile.
+  std::mutex DiagnosticsMutex;
+  /// Maps from a filename to the latest version of reported diagnostics.
+  llvm::StringMap ReportedDiagnosticVersions;
 };
 
 } // namespace clangd
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -315,6 +315,19 @@
 auto Diags = DeferredRebuild.get();
 if (!Diags)
   return; // A new reparse was requested before this one completed.
+
+// We need to serialize access to resulting diagnostics to avoid calling
+// `onDiagnosticsReady` in the wrong order.
+std::lock_guard DiagsLock(DiagnosticsMutex);
+DocVersion  = ReportedDiagnosticVersions[FileStr];
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.
+if (Version < LastReportedDiagsVersion)
+  return;
+LastReportedDiagsVersion = Version;
+
 DiagConsumer.onDiagnosticsReady(FileStr,
 make_tagged(std::move(*Diags), Tag));
   };
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG




Comment at: clangd/ClangdServer.h:287
+  std::mutex DiagnosticsMutex;
+  llvm::StringMap ReportedDiagnosticVersions;
 };

Comment what it maps from.



Comment at: unittests/clangd/ClangdTests.cpp:912
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));

ilya-biryukov wrote:
> klimek wrote:
> > Why not hand in a signal to wait for?
> The signal should be fired on a second call to `onDiagnosticsReady`, but the 
> second call won't happen before the fist one returns.
> Is there some other way to fire the signal that I'm missing?
Thinking a bit more about it, I can't find a better way.


https://reviews.llvm.org/D38032



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


[PATCH] D38077: [clangd] Put inacessible items to the end of completion list.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov created this revision.

https://reviews.llvm.org/D38077

Files:
  clangd/ClangdUnit.cpp
  test/clangd/authority-less-uri.test
  test/clangd/completion-priorities.test
  test/clangd/completion-snippet.test
  test/clangd/completion.test
  test/clangd/protocol.test

Index: test/clangd/protocol.test
===
--- test/clangd/protocol.test
+++ test/clangd/protocol.test
@@ -31,7 +31,7 @@
 # Test message with Content-Type before Content-Length
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 
 X-Test: Testing
@@ -50,7 +50,7 @@
 # Test message with duplicate Content-Length headers
 #
 # CHECK: {"jsonrpc":"2.0","id":3,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 # STDERR: Warning: Duplicate Content-Length header received. The previous value for this message (10) was ignored.
 
@@ -69,7 +69,7 @@
 # Test message with Content-Type before Content-Length
 #
 # CHECK: {"jsonrpc":"2.0","id":5,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
 # CHECK: ]}
 
 Content-Length: 1024
Index: test/clangd/completion.test
===
--- test/clangd/completion.test
+++ test/clangd/completion.test
@@ -16,25 +16,25 @@
 # nondeterministic, so we check regardless of order.
 #
 # CHECK: {"jsonrpc":"2.0","id":1,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
+# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"35a","filterText":"a","insertText":"a","insertTextFormat":1}
+# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"35bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
+# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"35ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
+# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"34operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
+# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"34~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
+# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"35f","filterText":"f","insertText":"f","insertTextFormat":1}
 # CHECK: ]}
 Content-Length: 148
 
 {"jsonrpc":"2.0","id":2,"method":"textDocument/completion","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":5}}}
 # Repeat the completion request, expect the same results.
 #
 # CHECK: {"jsonrpc":"2.0","id":2,"result":[
-# CHECK-DAG: {"label":"a","kind":5,"detail":"int","sortText":"00035a","filterText":"a","insertText":"a","insertTextFormat":1}
-# CHECK-DAG: {"label":"bb","kind":5,"detail":"int","sortText":"00035bb","filterText":"bb","insertText":"bb","insertTextFormat":1}
-# CHECK-DAG: {"label":"ccc","kind":5,"detail":"int","sortText":"00035ccc","filterText":"ccc","insertText":"ccc","insertTextFormat":1}
-# CHECK-DAG: {"label":"operator=(const fake &)","kind":2,"detail":"fake &","sortText":"00034operator=","filterText":"operator=","insertText":"operator=","insertTextFormat":1}
-# CHECK-DAG: {"label":"~fake()","kind":4,"detail":"void","sortText":"00034~fake","filterText":"~fake","insertText":"~fake","insertTextFormat":1}
-# CHECK-DAG: {"label":"f(int i, const float f) const","kind":2,"detail":"int","sortText":"00035f","filterText":"f","insertText":"f","insertTextFormat":1}
+# CHECK-DAG: 

[PATCH] D38032: [clangd] Serialize onDiagnosticsReady callbacks for the same file.

2017-09-20 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clangd/ClangdServer.cpp:321-324
+// FIXME(ibiryukov): get rid of '<' comparison here. In the current
+// implementation diagnostics will not be reported after version counters'
+// overflow. This should not happen in practice, since DocVersion is a
+// 64-bit unsigned integer.

klimek wrote:
> Why is this a FIXME? Do we intend to use a different mechanism? 2^64 versions 
> of a file seem to be a lot?
I think we can get rid of it after refactoring threading. But we should 
definitely be fine with 2^64 versions.



Comment at: unittests/clangd/ClangdTests.cpp:912
+StartSecondReparse.set_value();
+// Sleep long enough for the second request to be processed.
+std::this_thread::sleep_for(std::chrono::milliseconds(50));

klimek wrote:
> Why not hand in a signal to wait for?
The signal should be fired on a second call to `onDiagnosticsReady`, but the 
second call won't happen before the fist one returns.
Is there some other way to fire the signal that I'm missing?


https://reviews.llvm.org/D38032



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


  1   2   >