[PATCH] D24933: Enable configuration files in clang

2017-10-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff marked 28 inline comments as done.
sepavloff added a comment.

@hfinkel Thank you for explanations!


https://reviews.llvm.org/D24933



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


[PATCH] D24933: Enable configuration files in clang

2017-10-09 Thread Serge Pavlov via Phabricator via cfe-commits
sepavloff updated this revision to Diff 118315.
sepavloff added a comment.

Updated patch according to reviewer's notes


https://reviews.llvm.org/D24933

Files:
  docs/UsersManual.rst
  include/clang/Basic/DiagnosticDriverKinds.td
  include/clang/Config/config.h.cmake
  include/clang/Driver/Driver.h
  include/clang/Driver/Options.td
  lib/Driver/Driver.cpp
  test/Driver/Inputs/config-1.cfg
  test/Driver/Inputs/config-2.cfg
  test/Driver/Inputs/config-2a.cfg
  test/Driver/Inputs/config-3.cfg
  test/Driver/Inputs/config-4.cfg
  test/Driver/Inputs/config-5.cfg
  test/Driver/Inputs/config/config-4.cfg
  test/Driver/config-file-errs.c
  test/Driver/config-file.c
  test/Driver/config-file.cpp

Index: test/Driver/config-file.cpp
===
--- /dev/null
+++ test/Driver/config-file.cpp
@@ -0,0 +1,65 @@
+// REQUIRES: shell
+
+//--- Invocation qqq-clang-g++ tries to find config file qqq-clang-g++.cfg first ...
+//
+// RUN: mkdir -p %T/testdmode
+// RUN: [ ! -s %T/testdmode/qqq-clang-g++ ] || rm %T/testdmode/qqq-clang-g++
+// RUN: ln -s %clang %T/testdmode/qqq-clang-g++
+// RUN: echo "-Wundefined-func-template" > %T/testdmode/qqq-clang-g++.cfg
+// RUN: echo "-Werror" > %T/testdmode/qqq.cfg
+//
+// RUN: %T/testdmode/qqq-clang-g++ -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix FULL-NAME
+//
+// FULL-NAME: Configuration file: {{.*}}/testdmode/qqq-clang-g++.cfg
+// FULL-NAME: -Wundefined-func-template
+// FULL-NAME-NOT: -Werror
+//
+//--- ... and qqq.cfg if qqq-clang-g++.cfg is not found.
+//
+// RUN: rm %T/testdmode/qqq-clang-g++.cfg
+//
+// RUN: %T/testdmode/qqq-clang-g++ -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix SHORT-NAME
+//
+// SHORT-NAME: Configuration file: {{.*}}/testdmode/qqq.cfg
+// SHORT-NAME: -Werror
+// SHORT-NAME-NOT: -Wundefined-func-template
+
+
+//--- Config files are searched for in binary directory as well.
+//
+// RUN: [ ! -s %T/testbin/clang ] || rm %T/testbin/clang
+// RUN: ln -s %clang %T/testbin/clang
+// RUN: echo "-Werror" > %T/testbin/aaa.cfg
+//
+// RUN: %T/testbin/clang --config aaa.cfg -c -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-BIN
+//
+// CHECK-BIN: Configuration file: {{.*}}/testbin/aaa.cfg
+// CHECK-BIN: -Werror
+
+
+//--- If command line contains options that change triple (for instance, -m32), clang tries
+//reloading config file.
+
+//--- When reloading config file, target-clang-g++ tries to find config target32-clang-g++.cfg first ...
+//
+// RUN: mkdir -p %T/testreload
+// RUN: [ ! -s %T/testreload/x86_64-clang-g++ ] || rm %T/testreload/x86_64-clang-g++
+// RUN: ln -s %clang %T/testreload/x86_64-clang-g++
+// RUN: echo "-Wundefined-func-template" > %T/testreload/i386-clang-g++.cfg
+// RUN: echo "-Werror" > %T/testreload/i386.cfg
+//
+// RUN: %T/testreload/x86_64-clang-g++ -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD
+//
+// CHECK-RELOAD: Configuration file: {{.*}}/testreload/i386-clang-g++.cfg
+// CHECK-RELOAD: -Wundefined-func-template
+// CHECK-RELOAD-NOT: -Werror
+
+//--- and target32.cfg if target32-g++.cfg is not found.
+//
+// RUN: rm %T/testreload/i386-clang-g++.cfg
+//
+// RUN: %T/testreload/x86_64-clang-g++ -c -m32 -no-canonical-prefixes %s -### 2>&1 | FileCheck %s -check-prefix CHECK-RELOAD2
+//
+// CHECK-RELOAD2: Configuration file: {{.*}}/testreload/i386.cfg
+// CHECK-RELOAD2: -Werror
+// CHECK-RELOAD2-NOT: -Wundefined-func-template
Index: test/Driver/config-file.c
===
--- /dev/null
+++ test/Driver/config-file.c
@@ -0,0 +1,50 @@
+//--- Config file (full path) in output of -###
+//
+// RUN: %clang --config %S/Inputs/config-1.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-HHH
+// CHECK-HHH: Target: x86_64-apple-darwin
+// CHECK-HHH: Configuration file: {{.*}}Inputs{{.}}config-1.cfg
+// CHECK-HHH: -Werror
+// CHECK-HHH: -std=c99
+
+
+//--- Nested config files
+//
+// RUN: %clang --config %S/Inputs/config-2.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-HHH2
+// CHECK-HHH2: Target: x86_64-unknown-linux
+// CHECK-HHH2: Configuration file: {{.*}}Inputs{{.}}config-2.cfg
+// CHECK-HHH2: -Wundefined-func-template
+//
+
+// RUN: %clang --config %S/Inputs/config-2a.cfg -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-HHH2a
+// CHECK-HHH2a: Target: x86_64-unknown-linux
+// CHECK-HHH2a: Configuration file: {{.*}}Inputs{{.}}config-2a.cfg
+// CHECK-HHH2a: -isysroot
+// CHECK-HHH2a-SAME: /opt/data
+
+
+//--- If config file isspecified by relative path (workdir/cfg-s2), it is searched for by that path.
+//
+// RUN: mkdir -p %T/workdir
+// RUN: echo "@subdir/cfg-s2" > %T/workdir/cfg-1
+// RUN: mkdir -p %T/workdir/subdir
+// RUN: echo "-Wundefined-var-template" > %T/workdir/subdir/cfg-s2
+//
+// RUN: ( cd %T && %clang --config workdir/cfg-1 -c %s -### 2>&1 | FileCheck %s -check-prefix CHECK-REL )
+//
+// CHECK-REL: Configuration 

[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-09 Thread Nemanja Ivanovic via Phabricator via cfe-commits
nemanjai added a comment.

In https://reviews.llvm.org/D38656#892072, @Carrot wrote:

> I worked on a similar bug as 31161, and then found this one, it should be 
> same as in comment7.
>  What is the current status of the work on that bug?


No one has had time to finalize a fix to it. Please go ahead with this patch. 
If this patch indeed fixes the bug, please close it.


https://reviews.llvm.org/D38656



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


[PATCH] D37478: [analyzer] Implement pointer arithmetic on constants

2017-10-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

This looks good to me! Thanks for adding this. Do you have commit access, or do 
you need someone to commit it for you?


https://reviews.llvm.org/D37478



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


[PATCH] D38659: [Sema][ObjC] Preserve syntactic sugar when removing ARCReclaimReturnedObject cast

2017-10-09 Thread Akira Hatanaka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315261: [Sema][ObjC] Preserve syntactic sugar when removing 
(authored by ahatanak).

Changed prior to commit:
  https://reviews.llvm.org/D38659?vs=118121=118302#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38659

Files:
  cfe/trunk/lib/Sema/SemaExprObjC.cpp
  cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m


Index: cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
===
--- cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
+++ cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
@@ -102,5 +102,6 @@
   // CHECK-NOT: call i8* @objc_retainAutoreleasedReturnValue(
   // CHECK-NOT: call void @objc_release(
   CFStringRef r = (__bridge CFStringRef)(CreateNSString());
+  r = (__bridge CFStringRef)((NSString *)(CreateNSString()));
   return r;
 }
Index: cfe/trunk/lib/Sema/SemaExprObjC.cpp
===
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp
@@ -4317,14 +4317,37 @@
 
 /// Look for an ObjCReclaimReturnedObject cast and destroy it.
 static Expr *maybeUndoReclaimObject(Expr *e) {
-  // For now, we just undo operands that are *immediately* reclaim
-  // expressions, which prevents the vast majority of potential
-  // problems here.  To catch them all, we'd need to rebuild arbitrary
-  // value-propagating subexpressions --- we can't reliably rebuild
-  // in-place because of expression sharing.
-  if (auto *ice = dyn_cast(e->IgnoreParens()))
-if (ice->getCastKind() == CK_ARCReclaimReturnedObject)
-  return ice->getSubExpr();
+  Expr *curExpr = e, *prevExpr = nullptr;
+
+  // Walk down the expression until we hit an implicit cast of kind
+  // ARCReclaimReturnedObject or an Expr that is neither a Paren nor a Cast.
+  while (true) {
+if (auto *pe = dyn_cast(curExpr)) {
+  prevExpr = curExpr;
+  curExpr = pe->getSubExpr();
+  continue;
+}
+
+if (auto *ce = dyn_cast(curExpr)) {
+  if (auto *ice = dyn_cast(ce))
+if (ice->getCastKind() == CK_ARCReclaimReturnedObject) {
+  if (!prevExpr)
+return ice->getSubExpr();
+  if (auto *pe = dyn_cast(prevExpr))
+pe->setSubExpr(ice->getSubExpr());
+  else
+cast(prevExpr)->setSubExpr(ice->getSubExpr());
+  return e;
+}
+
+  prevExpr = curExpr;
+  curExpr = ce->getSubExpr();
+  continue;
+}
+
+// Break out of the loop if curExpr is neither a Paren nor a Cast.
+break;
+  }
 
   return e;
 }


Index: cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
===
--- cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
+++ cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
@@ -102,5 +102,6 @@
   // CHECK-NOT: call i8* @objc_retainAutoreleasedReturnValue(
   // CHECK-NOT: call void @objc_release(
   CFStringRef r = (__bridge CFStringRef)(CreateNSString());
+  r = (__bridge CFStringRef)((NSString *)(CreateNSString()));
   return r;
 }
Index: cfe/trunk/lib/Sema/SemaExprObjC.cpp
===
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp
@@ -4317,14 +4317,37 @@
 
 /// Look for an ObjCReclaimReturnedObject cast and destroy it.
 static Expr *maybeUndoReclaimObject(Expr *e) {
-  // For now, we just undo operands that are *immediately* reclaim
-  // expressions, which prevents the vast majority of potential
-  // problems here.  To catch them all, we'd need to rebuild arbitrary
-  // value-propagating subexpressions --- we can't reliably rebuild
-  // in-place because of expression sharing.
-  if (auto *ice = dyn_cast(e->IgnoreParens()))
-if (ice->getCastKind() == CK_ARCReclaimReturnedObject)
-  return ice->getSubExpr();
+  Expr *curExpr = e, *prevExpr = nullptr;
+
+  // Walk down the expression until we hit an implicit cast of kind
+  // ARCReclaimReturnedObject or an Expr that is neither a Paren nor a Cast.
+  while (true) {
+if (auto *pe = dyn_cast(curExpr)) {
+  prevExpr = curExpr;
+  curExpr = pe->getSubExpr();
+  continue;
+}
+
+if (auto *ce = dyn_cast(curExpr)) {
+  if (auto *ice = dyn_cast(ce))
+if (ice->getCastKind() == CK_ARCReclaimReturnedObject) {
+  if (!prevExpr)
+return ice->getSubExpr();
+  if (auto *pe = dyn_cast(prevExpr))
+pe->setSubExpr(ice->getSubExpr());
+  else
+cast(prevExpr)->setSubExpr(ice->getSubExpr());
+  return e;
+}
+
+  prevExpr = curExpr;
+  curExpr = ce->getSubExpr();
+  continue;
+}
+
+// Break out of the loop if curExpr is neither a Paren nor a Cast.
+break;
+  }
 
   return e;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org

r315261 - [Sema][ObjC] Preserve syntactic sugar when removing

2017-10-09 Thread Akira Hatanaka via cfe-commits
Author: ahatanak
Date: Mon Oct  9 18:24:33 2017
New Revision: 315261

URL: http://llvm.org/viewvc/llvm-project?rev=315261=rev
Log:
[Sema][ObjC] Preserve syntactic sugar when removing
ARCReclaimReturnedObject cast.

This is a follow-up to r314370.

Rather than throwing away the enclosing parentheses, this commit walks
down the expression until an ARCReclaimReturnedObject cast is found and
removes just the cast, preserving the syntactic sugar expressions
(parens and casts) that were visited up to that point.

rdar://problem/34705720

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

Modified:
cfe/trunk/lib/Sema/SemaExprObjC.cpp
cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m

Modified: cfe/trunk/lib/Sema/SemaExprObjC.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExprObjC.cpp?rev=315261=315260=315261=diff
==
--- cfe/trunk/lib/Sema/SemaExprObjC.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExprObjC.cpp Mon Oct  9 18:24:33 2017
@@ -4317,14 +4317,37 @@ bool Sema::CheckObjCARCUnavailableWeakCo
 
 /// Look for an ObjCReclaimReturnedObject cast and destroy it.
 static Expr *maybeUndoReclaimObject(Expr *e) {
-  // For now, we just undo operands that are *immediately* reclaim
-  // expressions, which prevents the vast majority of potential
-  // problems here.  To catch them all, we'd need to rebuild arbitrary
-  // value-propagating subexpressions --- we can't reliably rebuild
-  // in-place because of expression sharing.
-  if (auto *ice = dyn_cast(e->IgnoreParens()))
-if (ice->getCastKind() == CK_ARCReclaimReturnedObject)
-  return ice->getSubExpr();
+  Expr *curExpr = e, *prevExpr = nullptr;
+
+  // Walk down the expression until we hit an implicit cast of kind
+  // ARCReclaimReturnedObject or an Expr that is neither a Paren nor a Cast.
+  while (true) {
+if (auto *pe = dyn_cast(curExpr)) {
+  prevExpr = curExpr;
+  curExpr = pe->getSubExpr();
+  continue;
+}
+
+if (auto *ce = dyn_cast(curExpr)) {
+  if (auto *ice = dyn_cast(ce))
+if (ice->getCastKind() == CK_ARCReclaimReturnedObject) {
+  if (!prevExpr)
+return ice->getSubExpr();
+  if (auto *pe = dyn_cast(prevExpr))
+pe->setSubExpr(ice->getSubExpr());
+  else
+cast(prevExpr)->setSubExpr(ice->getSubExpr());
+  return e;
+}
+
+  prevExpr = curExpr;
+  curExpr = ce->getSubExpr();
+  continue;
+}
+
+// Break out of the loop if curExpr is neither a Paren nor a Cast.
+break;
+  }
 
   return e;
 }

Modified: cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m?rev=315261=315260=315261=diff
==
--- cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m (original)
+++ cfe/trunk/test/CodeGenObjC/arc-bridged-cast.m Mon Oct  9 18:24:33 2017
@@ -102,5 +102,6 @@ CFStringRef bridge_of_paren_expr() {
   // CHECK-NOT: call i8* @objc_retainAutoreleasedReturnValue(
   // CHECK-NOT: call void @objc_release(
   CFStringRef r = (__bridge CFStringRef)(CreateNSString());
+  r = (__bridge CFStringRef)((NSString *)(CreateNSString()));
   return r;
 }


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


[PATCH] D37897: [StaticAnalyzer] Fix ProgramState for static variables that are not written

2017-10-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin requested changes to this revision.
dcoughlin added a comment.
This revision now requires changes to proceed.

Apologies for the delay reviewing! As I noted inline, I'm pretty worried about 
the performance impact of this. Is it possible to do the analysis in a single 
traversal of the translation unit?




Comment at: lib/StaticAnalyzer/Core/ExprEngine.cpp:123
+  // Is variable changed anywhere in TU?
+  for (const Decl *D : AMgr.getASTContext().getTranslationUnitDecl()->decls()) 
{
+if (isChanged(D, VD))

Since you are calling `getInitialStateForGlobalStaticVar()` in 
`getInitialState()` for each static variable declaration and 
`getInitialState()` is called for each top-level function, you are doing an n^3 
operation in the size of the translation unit, which is going to be very, very 
expensive for large translation units.

Have you considered doing the analysis for static variables that are never 
changed during call-graph construction? This should be a linear operation and 
doing it during call-graph construction would avoid an extra walk of the entire 
translation unit.


Repository:
  rL LLVM

https://reviews.llvm.org/D37897



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


r315256 - [Modules TS] Avoid computing the linkage of the enclosing DeclContext for a declaration in the global module.

2017-10-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct  9 17:49:38 2017
New Revision: 315256

URL: http://llvm.org/viewvc/llvm-project?rev=315256=rev
Log:
[Modules TS] Avoid computing the linkage of the enclosing DeclContext for a 
declaration in the global module.

This works around a language issue where adding a typedef name for linkage
purposes changes the linkage of an already-defined class after it becomes
complete.

Added:
cfe/trunk/test/Modules/anon-linkage.cpp
Modified:
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315256=315255=315256=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 17:49:38 2017
@@ -740,7 +740,10 @@ public:
 
   /// Get the module that owns this declaration for linkage purposes.
   /// There only ever is such a module under the C++ Modules TS.
-  Module *getOwningModuleForLinkage() const;
+  ///
+  /// \param IgnoreLinkage Ignore the linkage of the entity; assume that
+  /// all declarations in a global module fragment are unowned.
+  Module *getOwningModuleForLinkage(bool IgnoreLinkage = false) const;
 
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns

Modified: cfe/trunk/include/clang/Sema/Sema.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Sema.h?rev=315256=315255=315256=diff
==
--- cfe/trunk/include/clang/Sema/Sema.h (original)
+++ cfe/trunk/include/clang/Sema/Sema.h Mon Oct  9 17:49:38 2017
@@ -3051,8 +3051,11 @@ public:
 
   RedeclarationKind forRedeclarationInCurContext() {
 // A declaration with an owning module for linkage can never link against
-// anything that is not visible.
-if (cast(CurContext)->getOwningModuleForLinkage())
+// anything that is not visible. We don't need to check linkage here; if
+// the context has internal linkage, redeclaration lookup won't find things
+// from other TUs, and we can't safely compute linkage yet in general.
+if (cast(CurContext)
+->getOwningModuleForLinkage(/*IgnoreLinkage*/true))
   return ForVisibleRedeclaration;
 return ForExternalRedeclaration;
   }

Modified: cfe/trunk/lib/AST/Decl.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/Decl.cpp?rev=315256=315255=315256=diff
==
--- cfe/trunk/lib/AST/Decl.cpp (original)
+++ cfe/trunk/lib/AST/Decl.cpp Mon Oct  9 17:49:38 2017
@@ -1395,7 +1395,7 @@ LinkageInfo LinkageComputer::getDeclLink
 : NamedDecl::VisibilityForValue));
 }
 
-Module *Decl::getOwningModuleForLinkage() const {
+Module *Decl::getOwningModuleForLinkage(bool IgnoreLinkage) const {
   Module *M = getOwningModule();
   if (!M)
 return nullptr;
@@ -1413,6 +1413,8 @@ Module *Decl::getOwningModuleForLinkage(
 // for linkage purposes. But internal linkage declarations in the global
 // module fragment of a particular module are owned by that module for
 // linkage purposes.
+if (IgnoreLinkage)
+  return nullptr;
 bool InternalLinkage;
 if (auto *ND = dyn_cast(this))
   InternalLinkage = !ND->hasExternalFormalLinkage();

Added: cfe/trunk/test/Modules/anon-linkage.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Modules/anon-linkage.cpp?rev=315256=auto
==
--- cfe/trunk/test/Modules/anon-linkage.cpp (added)
+++ cfe/trunk/test/Modules/anon-linkage.cpp Mon Oct  9 17:49:38 2017
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -std=c++17 -fmodules-ts %s
+
+typedef struct {
+  int c;
+  union {
+int n;
+char c[4];
+  } v;
+} mbstate;
+
+export module M;
+export using ::mbstate;


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


[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315255: R13575: Fix USR mangling for function pointer types 
(authored by jkorous).

Changed prior to commit:
  https://reviews.llvm.org/D38707?vs=118287=118300#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38707

Files:
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/test/Index/USR/func-type.cpp


Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;
Index: cfe/trunk/test/Index/USR/func-type.cpp
===
--- cfe/trunk/test/Index/USR/func-type.cpp
+++ cfe/trunk/test/Index/USR/func-type.cpp
@@ -0,0 +1,18 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures 
should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
+
+void Func( void (* (*)(int, int))(int, int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
+void Func( void (* (*)(int, int, int))(int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |


Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;
Index: cfe/trunk/test/Index/USR/func-type.cpp
===
--- cfe/trunk/test/Index/USR/func-type.cpp
+++ cfe/trunk/test/Index/USR/func-type.cpp
@@ -0,0 +1,18 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
+
+void Func( void (* (*)(int, int))(int, int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
+void Func( void (* (*)(int, int, int))(int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315255 - R13575: Fix USR mangling for function pointer types

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 17:35:16 2017
New Revision: 315255

URL: http://llvm.org/viewvc/llvm-project?rev=315255=rev
Log:
R13575: Fix USR mangling for function pointer types

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

Added:
cfe/trunk/test/Index/USR/func-type.cpp
Modified:
cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=315255=315254=315255=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Oct  9 17:35:16 2017
@@ -754,8 +754,12 @@ void USRGenerator::VisitType(QualType T)
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;

Added: cfe/trunk/test/Index/USR/func-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/func-type.cpp?rev=315255=auto
==
--- cfe/trunk/test/Index/USR/func-type.cpp (added)
+++ cfe/trunk/test/Index/USR/func-type.cpp Mon Oct  9 17:35:16 2017
@@ -0,0 +1,18 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures 
should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
+
+void Func( void (* (*)(int, int))(int, int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
+void Func( void (* (*)(int, int, int))(int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |


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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

> Are you 100% sure that you're not just a person with broken code?

Absolutely, since it isn't my code ;) I maintain the toolchain and this is a 
behavioral change when switching from libstdc++ to libc++.

> In other words, what did this guy from 2013 get wrong? -- or, if "he got 
> nothing wrong", then why can't you just follow his advice to eliminate the 
> duplicate typeinfos from your code? 
> http://www.russellmcc.com/posts/2013-08-03-rtti.html

That post is all about binaries that were built with hidden visibility and says 
nothing about the case of `dlopen`. There's nothing wrong with the code as 
built. All the symbols have public visibility, all the `type_infos` are weak, 
everything works correctly if you explicitly link the libraries to the final 
executable or `dlopen` only one library (not always an option).

If anyone is still skeptical, libsupc++ went through this at one point too and 
eventually decided to use `strcmp` by default because otherwise RTTI doesn't 
work in plugin architectures (which is essentially what JNI is). 
https://gcc.gnu.org/ml/gcc-patches/2009-07/msg01239.html


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D38707



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


[PATCH] D38711: typos in documentation?

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315252: Fix typos in documentation (authored by jkorous).

Changed prior to commit:
  https://reviews.llvm.org/D38711?vs=118295=118296#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38711

Files:
  cfe/trunk/docs/InternalsManual.rst


Index: cfe/trunk/docs/InternalsManual.rst
===
--- cfe/trunk/docs/InternalsManual.rst
+++ cfe/trunk/docs/InternalsManual.rst
@@ -1540,7 +1540,7 @@
 After trying several different approaches, we've finally converged on a design
 (Note, at the time of this writing, not all of this has been implemented,
 consider this a design goal!).  Our basic approach is to define a single
-recursive method evaluation method (``Expr::Evaluate``), which is implemented
+recursive evaluation method (``Expr::Evaluate``), which is implemented
 in ``AST/ExprConstant.cpp``.  Given an expression with "scalar" type (integer,
 fp, complex, or pointer) this method returns the following information:
 
@@ -2037,7 +2037,7 @@
* ``CodeGenFunction`` contains functions ``ConvertType`` and
  ``ConvertTypeForMem`` that convert Clang's types (``clang::Type*`` or
  ``clang::QualType``) to LLVM types.  Use the former for values, and the
- later for memory locations: test with the C++ "``bool``" type to check
+ latter for memory locations: test with the C++ "``bool``" type to check
  this.  If you find that you are having to use LLVM bitcasts to make the
  subexpressions of your expression have the type that your expression
  expects, STOP!  Go fix semantic analysis and the AST so that you don't


Index: cfe/trunk/docs/InternalsManual.rst
===
--- cfe/trunk/docs/InternalsManual.rst
+++ cfe/trunk/docs/InternalsManual.rst
@@ -1540,7 +1540,7 @@
 After trying several different approaches, we've finally converged on a design
 (Note, at the time of this writing, not all of this has been implemented,
 consider this a design goal!).  Our basic approach is to define a single
-recursive method evaluation method (``Expr::Evaluate``), which is implemented
+recursive evaluation method (``Expr::Evaluate``), which is implemented
 in ``AST/ExprConstant.cpp``.  Given an expression with "scalar" type (integer,
 fp, complex, or pointer) this method returns the following information:
 
@@ -2037,7 +2037,7 @@
* ``CodeGenFunction`` contains functions ``ConvertType`` and
  ``ConvertTypeForMem`` that convert Clang's types (``clang::Type*`` or
  ``clang::QualType``) to LLVM types.  Use the former for values, and the
- later for memory locations: test with the C++ "``bool``" type to check
+ latter for memory locations: test with the C++ "``bool``" type to check
  this.  If you find that you are having to use LLVM bitcasts to make the
  subexpressions of your expression have the type that your expression
  expects, STOP!  Go fix semantic analysis and the AST so that you don't
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315252 - Fix typos in documentation

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 16:45:20 2017
New Revision: 315252

URL: http://llvm.org/viewvc/llvm-project?rev=315252=rev
Log:
Fix typos in documentation

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

Modified:
cfe/trunk/docs/InternalsManual.rst

Modified: cfe/trunk/docs/InternalsManual.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/InternalsManual.rst?rev=315252=315251=315252=diff
==
--- cfe/trunk/docs/InternalsManual.rst (original)
+++ cfe/trunk/docs/InternalsManual.rst Mon Oct  9 16:45:20 2017
@@ -1540,7 +1540,7 @@ Implementation Approach
 After trying several different approaches, we've finally converged on a design
 (Note, at the time of this writing, not all of this has been implemented,
 consider this a design goal!).  Our basic approach is to define a single
-recursive method evaluation method (``Expr::Evaluate``), which is implemented
+recursive evaluation method (``Expr::Evaluate``), which is implemented
 in ``AST/ExprConstant.cpp``.  Given an expression with "scalar" type (integer,
 fp, complex, or pointer) this method returns the following information:
 
@@ -2037,7 +2037,7 @@ are similar.
* ``CodeGenFunction`` contains functions ``ConvertType`` and
  ``ConvertTypeForMem`` that convert Clang's types (``clang::Type*`` or
  ``clang::QualType``) to LLVM types.  Use the former for values, and the
- later for memory locations: test with the C++ "``bool``" type to check
+ latter for memory locations: test with the C++ "``bool``" type to check
  this.  If you find that you are having to use LLVM bitcasts to make the
  subexpressions of your expression have the type that your expression
  expects, STOP!  Go fix semantic analysis and the AST so that you don't


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


r315251 - [Modules TS] Module ownership semantics for redeclarations.

2017-10-09 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Mon Oct  9 16:42:09 2017
New Revision: 315251

URL: http://llvm.org/viewvc/llvm-project?rev=315251=rev
Log:
[Modules TS] Module ownership semantics for redeclarations.

When declaring an entity in the "purview" of a module, it's never a
redeclaration of an entity in the purview of a default module or in no module
("in the global module"). Don't consider those other declarations as possible
redeclaration targets if they're not visible, and reject any cases where we
pick a prior visible declaration that violates this rule.

Added:
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/global-vs-module.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-global.cpp
cfe/trunk/test/CXX/modules-ts/basic/basic.def.odr/p6/module-vs-module.cpp
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/include/clang/AST/DeclBase.h
cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
cfe/trunk/include/clang/Sema/Lookup.h
cfe/trunk/include/clang/Sema/Sema.h
cfe/trunk/lib/AST/Decl.cpp
cfe/trunk/lib/AST/DeclBase.cpp
cfe/trunk/lib/AST/DeclCXX.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaDeclObjC.cpp
cfe/trunk/lib/Sema/SemaExprMember.cpp
cfe/trunk/lib/Sema/SemaLookup.cpp
cfe/trunk/lib/Sema/SemaOpenMP.cpp
cfe/trunk/lib/Sema/SemaTemplate.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/modules-ts.cppm

Modified: cfe/trunk/include/clang/AST/Decl.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=315251=315250=315251=diff
==
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Mon Oct  9 16:42:09 2017
@@ -339,6 +339,12 @@ public:
 return clang::isExternallyVisible(getLinkageInternal());
   }
 
+  /// Determine whether this declaration can be redeclared in a
+  /// different translation unit.
+  bool isExternallyDeclarable() const {
+return isExternallyVisible() && !getOwningModuleForLinkage();
+  }
+
   /// \brief Determines the visibility of this entity.
   Visibility getVisibility() const {
 return getLinkageAndVisibility().getVisibility();
@@ -379,10 +385,6 @@ public:
 return hasCachedLinkage();
   }
 
-  /// Get the module that owns this declaration for linkage purposes.
-  /// There only ever is such a module under the C++ Modules TS.
-  Module *getOwningModuleForLinkage() const;
-
   /// \brief Looks through UsingDecls and ObjCCompatibleAliasDecls for
   /// the underlying named decl.
   NamedDecl *getUnderlyingDecl() {

Modified: cfe/trunk/include/clang/AST/DeclBase.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/DeclBase.h?rev=315251=315250=315251=diff
==
--- cfe/trunk/include/clang/AST/DeclBase.h (original)
+++ cfe/trunk/include/clang/AST/DeclBase.h Mon Oct  9 16:42:09 2017
@@ -738,6 +738,10 @@ public:
 return isFromASTFile() ? getImportedOwningModule() : 
getLocalOwningModule();
   }
 
+  /// Get the module that owns this declaration for linkage purposes.
+  /// There only ever is such a module under the C++ Modules TS.
+  Module *getOwningModuleForLinkage() const;
+
   /// \brief Determine whether this declaration might be hidden from name
   /// lookup. Note that the declaration might be visible even if this returns
   /// \c false, if the owning module is visible within the query context.

Modified: cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td?rev=315251=315250=315251=diff
==
--- cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td (original)
+++ cfe/trunk/include/clang/Basic/DiagnosticSemaKinds.td Mon Oct  9 16:42:09 
2017
@@ -4801,6 +4801,9 @@ def err_thread_non_thread : Error<
 def err_thread_thread_different_kind : Error<
   "thread-local declaration of %0 with %select{static|dynamic}1 initialization 
"
   "follows declaration with %select{dynamic|static}1 initialization">;
+def err_mismatched_owning_module : Error<
+  "declaration of %0 in %select{the global module|module %2}1 follows "
+  "declaration in %select{the global module|module %4}3">;
 def err_redefinition_different_type : Error<
   "redefinition of %0 with a different type%diff{: $ vs $|}1,2">;
 def err_redefinition_different_kind : Error<

Modified: cfe/trunk/include/clang/Sema/Lookup.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Sema/Lookup.h?rev=315251=315250=315251=diff
==
--- cfe/trunk/include/clang/Sema/Lookup.h (original)
+++ cfe/trunk/include/clang/Sema/Lookup.h Mon 

[PATCH] D38711: typos in documentation?

2017-10-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs accepted this revision.
jroelofs added a comment.
This revision is now accepted and ready to land.

LGTM


https://reviews.llvm.org/D38711



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


[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-09 Thread Saleem Abdulrasool via Phabricator via cfe-commits
compnerd requested changes to this revision.
compnerd added a comment.
This revision now requires changes to proceed.

I think that the problem is that we are using the generic register name, but we 
need to use the target specific register name.  On x86, EIP/ESP are swapped.  
We should also have a test case for this.  I had reduced this down to a simpler 
test case of:

  void f(int,int,int,int,int,int,int,int,int);
  
  int main() {
try {
  f(0,1,2,3,4,5,6,7,8);
} catch (int) {
  return 0;
}
return 1;
  }


https://reviews.llvm.org/D38680



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


[PATCH] D38711: typos in documentation?

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.

I have found two possible typos in documentation. Since English is not my first 
language I would like to ask for verification.


https://reviews.llvm.org/D38711

Files:
  docs/InternalsManual.rst


Index: docs/InternalsManual.rst
===
--- docs/InternalsManual.rst
+++ docs/InternalsManual.rst
@@ -1540,7 +1540,7 @@
 After trying several different approaches, we've finally converged on a design
 (Note, at the time of this writing, not all of this has been implemented,
 consider this a design goal!).  Our basic approach is to define a single
-recursive method evaluation method (``Expr::Evaluate``), which is implemented
+recursive evaluation method (``Expr::Evaluate``), which is implemented
 in ``AST/ExprConstant.cpp``.  Given an expression with "scalar" type (integer,
 fp, complex, or pointer) this method returns the following information:
 
@@ -2037,7 +2037,7 @@
* ``CodeGenFunction`` contains functions ``ConvertType`` and
  ``ConvertTypeForMem`` that convert Clang's types (``clang::Type*`` or
  ``clang::QualType``) to LLVM types.  Use the former for values, and the
- later for memory locations: test with the C++ "``bool``" type to check
+ latter for memory locations: test with the C++ "``bool``" type to check
  this.  If you find that you are having to use LLVM bitcasts to make the
  subexpressions of your expression have the type that your expression
  expects, STOP!  Go fix semantic analysis and the AST so that you don't


Index: docs/InternalsManual.rst
===
--- docs/InternalsManual.rst
+++ docs/InternalsManual.rst
@@ -1540,7 +1540,7 @@
 After trying several different approaches, we've finally converged on a design
 (Note, at the time of this writing, not all of this has been implemented,
 consider this a design goal!).  Our basic approach is to define a single
-recursive method evaluation method (``Expr::Evaluate``), which is implemented
+recursive evaluation method (``Expr::Evaluate``), which is implemented
 in ``AST/ExprConstant.cpp``.  Given an expression with "scalar" type (integer,
 fp, complex, or pointer) this method returns the following information:
 
@@ -2037,7 +2037,7 @@
* ``CodeGenFunction`` contains functions ``ConvertType`` and
  ``ConvertTypeForMem`` that convert Clang's types (``clang::Type*`` or
  ``clang::QualType``) to LLVM types.  Use the former for values, and the
- later for memory locations: test with the C++ "``bool``" type to check
+ latter for memory locations: test with the C++ "``bool``" type to check
  this.  If you find that you are having to use LLVM bitcasts to make the
  subexpressions of your expression have the type that your expression
  expects, STOP!  Go fix semantic analysis and the AST so that you don't
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple added inline comments.



Comment at: lib/Index/USRGeneration.cpp:757
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {

arphaman wrote:
> I believe you can drop the '(' and ')'. The '#' should be enough to prevent 
> the USR collision.
Actually, this is a great question!

I was worried it might not be the case so I created two more test cases. 
Let's try to imagine there are no parentheses in those USRs.
First two test cases could be solved by using 'v' or something for functions 
taking no arguments. But 3rd and 4th test cases would definitely need some 
disambiguation then.

I am not saying this is the only possible way how to represent function 
pointers but for proposed solution those parentheses are needed.


https://reviews.llvm.org/D38707



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread George Karpenkov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315250: [Analyzer] Do not segfault on unexpected call_once 
implementation (authored by george.karpenkov).

Changed prior to commit:
  https://reviews.llvm.org/D38702?vs=118291=118294#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38702

Files:
  cfe/trunk/lib/Analysis/BodyFarm.cpp
  cfe/trunk/test/Analysis/call_once.cpp


Index: cfe/trunk/lib/Analysis/BodyFarm.cpp
===
--- cfe/trunk/lib/Analysis/BodyFarm.cpp
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp
@@ -327,6 +327,28 @@
   const ParmVarDecl *Flag = D->getParamDecl(0);
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
+  QualType FlagType = Flag->getType().getNonReferenceType();
+  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (!FlagCXXDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
+
+  // Note: here we are assuming libc++ implementation of call_once,
+  // which has a struct with a field `__state_`.
+  // Body farming might not work for other `call_once` implementations.
+  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
+  ValueDecl *FieldDecl;
+  if (FoundDecl) {
+FieldDecl = dyn_cast(FoundDecl);
+  } else {
+DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
+   << "unable to synthesize call_once body, ignoring "
+   << "the call.\n");
+return nullptr;
+  }
 
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&
   CallbackType->getAsCXXRecordDecl()->isLambda();
@@ -355,27 +377,11 @@
 CallbackCall = create_call_once_funcptr_call(C, M, Callback, CallArgs);
   }
 
-  QualType FlagType = Flag->getType().getNonReferenceType();
   DeclRefExpr *FlagDecl =
   M.makeDeclRefExpr(Flag,
 /* RefersToEnclosingVariableOrCapture=*/true,
 /* GetNonReferenceType=*/true);
 
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
-DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
-return nullptr;
-  }
 
   MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FieldDecl);
   assert(Deref->isLValue());
Index: cfe/trunk/test/Analysis/call_once.cpp
===
--- cfe/trunk/test/Analysis/call_once.cpp
+++ cfe/trunk/test/Analysis/call_once.cpp
@@ -231,3 +231,12 @@
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}


Index: cfe/trunk/lib/Analysis/BodyFarm.cpp
===
--- cfe/trunk/lib/Analysis/BodyFarm.cpp
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp
@@ -327,6 +327,28 @@
   const ParmVarDecl *Flag = D->getParamDecl(0);
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
+  QualType FlagType = Flag->getType().getNonReferenceType();
+  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (!FlagCXXDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
+
+  // Note: here we are assuming libc++ implementation of call_once,
+  // which has a struct with a field `__state_`.
+  // Body farming might not work for other `call_once` implementations.
+  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
+  ValueDecl *FieldDecl;
+  if (FoundDecl) {
+FieldDecl = dyn_cast(FoundDecl);
+  } else {
+DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
+   << "unable to synthesize call_once body, ignoring "
+   << "the call.\n");
+return nullptr;
+  }
 
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&
   CallbackType->getAsCXXRecordDecl()->isLambda();
@@ -355,27 +377,11 @@
 CallbackCall = create_call_once_funcptr_call(C, M, 

r315250 - [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread George Karpenkov via cfe-commits
Author: george.karpenkov
Date: Mon Oct  9 16:20:46 2017
New Revision: 315250

URL: http://llvm.org/viewvc/llvm-project?rev=315250=rev
Log:
[Analyzer] Do not segfault on unexpected call_once implementation

Fixes https://bugs.llvm.org/show_bug.cgi?id=34869

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

Modified:
cfe/trunk/lib/Analysis/BodyFarm.cpp
cfe/trunk/test/Analysis/call_once.cpp

Modified: cfe/trunk/lib/Analysis/BodyFarm.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Analysis/BodyFarm.cpp?rev=315250=315249=315250=diff
==
--- cfe/trunk/lib/Analysis/BodyFarm.cpp (original)
+++ cfe/trunk/lib/Analysis/BodyFarm.cpp Mon Oct  9 16:20:46 2017
@@ -327,6 +327,28 @@ static Stmt *create_call_once(ASTContext
   const ParmVarDecl *Flag = D->getParamDecl(0);
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
+  QualType FlagType = Flag->getType().getNonReferenceType();
+  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (!FlagCXXDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
+
+  // Note: here we are assuming libc++ implementation of call_once,
+  // which has a struct with a field `__state_`.
+  // Body farming might not work for other `call_once` implementations.
+  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
+  ValueDecl *FieldDecl;
+  if (FoundDecl) {
+FieldDecl = dyn_cast(FoundDecl);
+  } else {
+DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
+   << "unable to synthesize call_once body, ignoring "
+   << "the call.\n");
+return nullptr;
+  }
 
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&
   CallbackType->getAsCXXRecordDecl()->isLambda();
@@ -355,27 +377,11 @@ static Stmt *create_call_once(ASTContext
 CallbackCall = create_call_once_funcptr_call(C, M, Callback, CallArgs);
   }
 
-  QualType FlagType = Flag->getType().getNonReferenceType();
   DeclRefExpr *FlagDecl =
   M.makeDeclRefExpr(Flag,
 /* RefersToEnclosingVariableOrCapture=*/true,
 /* GetNonReferenceType=*/true);
 
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
-DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
-return nullptr;
-  }
 
   MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FieldDecl);
   assert(Deref->isLValue());

Modified: cfe/trunk/test/Analysis/call_once.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/call_once.cpp?rev=315250=315249=315250=diff
==
--- cfe/trunk/test/Analysis/call_once.cpp (original)
+++ cfe/trunk/test/Analysis/call_once.cpp Mon Oct  9 16:20:46 2017
@@ -231,3 +231,12 @@ void test_non_std_call_once() {
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}


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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread Devin Coughlin via Phabricator via cfe-commits
dcoughlin accepted this revision.
dcoughlin added a comment.
This revision is now accepted and ready to land.

Looks good to me!


https://reviews.llvm.org/D38702



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


Re: [clang-tools-extra] r315210 - [clangd] Added move-only function helpers.

2017-10-09 Thread Galina Kistanova via cfe-commits
Hello Ilya,

This commit broke build on one of our builders:

http://lab.llvm.org:8011/builders/clang-x86_64-linux-abi-test/builds/16435

Please have a look?

Thanks

Galina


On Mon, Oct 9, 2017 at 9:26 AM, Ilya Biryukov via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: ibiryukov
> Date: Mon Oct  9 09:26:26 2017
> New Revision: 315210
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315210=rev
> Log:
> [clangd] Added move-only function helpers.
>
> Summary:
> They are now used in ClangdScheduler instead of deferred std::async
> computations.
> The results of `std::async` are much less effective and do not provide
> a good abstraction for similar purposes, i.e. for storing additional
> callbacks
> to clangd async tasks. The actual callback API will follow a bit later.
>
> Reviewers: klimek, bkramer, sammccall, krasimir
>
> Reviewed By: sammccall
>
> Subscribers: cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D38627
>
> Added:
> clang-tools-extra/trunk/clangd/Function.h
> 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=315210=315209=315210=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Oct  9 09:26:26
> 2017
> @@ -99,7 +99,7 @@ ClangdScheduler::ClangdScheduler(unsigne
>for (unsigned I = 0; I < AsyncThreadsCount; ++I) {
>  Workers.push_back(std::thread([this]() {
>while (true) {
> -std::future Request;
> +UniqueFunction Request;
>
>  // Pick request from the queue
>  {
> @@ -120,7 +120,7 @@ ClangdScheduler::ClangdScheduler(unsigne
>RequestQueue.pop_front();
>  } // unlock Mutex
>
> -Request.get();
> +Request();
>}
>  }));
>}
>
> Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/ClangdServer.h?rev=315210=315209=315210=diff
> 
> ==
> --- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
> +++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Oct  9 09:26:26 2017
> @@ -20,6 +20,7 @@
>  #include "llvm/ADT/StringRef.h"
>
>  #include "ClangdUnit.h"
> +#include "Function.h"
>  #include "Protocol.h"
>
>  #include 
> @@ -132,9 +133,8 @@ public:
>
>  {
>std::lock_guard Lock(Mutex);
> -  RequestQueue.push_front(std::async(std::launch::deferred,
> - std::forward(F),
> - std::forward(As)...));
> +  RequestQueue.push_front(
> +  BindWithForward(std::forward(F),
> std::forward(As)...));
>  }
>  RequestCV.notify_one();
>}
> @@ -149,9 +149,8 @@ public:
>
>  {
>std::lock_guard Lock(Mutex);
> -  RequestQueue.push_back(std::async(std::launch::deferred,
> -std::forward(F),
> -std::forward(As)...));
> +  RequestQueue.push_back(
> +  BindWithForward(std::forward(F),
> std::forward(As)...));
>  }
>  RequestCV.notify_one();
>}
> @@ -167,7 +166,7 @@ private:
>bool Done = false;
>/// A queue of requests. Elements of this vector are async computations
> (i.e.
>/// results of calling std::async(std::launch::deferred, ...)).
> -  std::deque RequestQueue;
> +  std::deque> RequestQueue;
>/// Condition variable to wake up worker threads.
>std::condition_variable RequestCV;
>  };
>
> Added: clang-tools-extra/trunk/clangd/Function.h
> URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/
> trunk/clangd/Function.h?rev=315210=auto
> 
> ==
> --- clang-tools-extra/trunk/clangd/Function.h (added)
> +++ clang-tools-extra/trunk/clangd/Function.h Mon Oct  9 09:26:26 2017
> @@ -0,0 +1,136 @@
> +//===--- Function.h - Utility callable wrappers  -*-
> C++-*-===//
> +//
> +// The LLVM Compiler Infrastructure
> +//
> +// This file is distributed under the University of Illinois Open Source
> +// License. See LICENSE.TXT for details.
> +//
> +//===--
> ===//
> +//
> +// This file provides an analogue to std::function that supports move
> semantics.
> +//
> +//===--
> ===//
> +
> +#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
> +#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
> +
> +#include 
> +#include 
> +#include 
> +
> 

[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

2017-10-09 Thread Zachary Turner via Phabricator via cfe-commits
zturner added a comment.

I'm a little nervous about re-inventing a poor man's version of a reader writer 
lock.  Can we not just copy LLVM's?




Comment at: src/UnwindCursor.hpp:20
 #ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
+  #ifdef _WIN32
+#include 

Maybe you want to check `_MSC_VER` here?  I think MinGW compilers will have 
`pthread` support.



Comment at: src/UnwindCursor.hpp:43-45
+#if !defined(_LIBUNWIND_HAS_NO_THREADS) && defined(_WIN32)
+#define pthread_rwlock_t SRWLOCK
+#define PTHREAD_RWLOCK_INITIALIZER SRWLOCK_INIT

As a matter of principle, I'm not a huge fan of naming things with posix 
specific names if the implementation is not actually posix.  For example, these 
functions always return success, but this is not true of the posix functions 
which can fail for various reasons.  In general, if people are unaware that 
there is some abstraction behind the scenes for Windows, and they just see a 
function named `posix_rwlock_rdlock`, then they are going to assume that they 
can expect the semantics documented on the posix man pages, which is not true.

The alternative is to create a proper abstraction, which might be more work 
than you're interested in taking on, so consider this just an advisory 
suggestion.



Comment at: src/UnwindCursor.hpp:50
+static bool lockedForWrite = false;
+static int pthread_rwlock_rdlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockShared(lock);

This doesn't seem like what you want.  a global `static` function / variable in 
a header file is going to be duplicated in every translation unit.  i.e. two 
translation units will have different copies of `lockedForWrite`.  Same goes 
for the rest of the functions.



Comment at: src/UnwindCursor.hpp:61-64
+  if (lockedForWrite) {
+lockedForWrite = false;
+ReleaseSRWLockExclusive(lock);
+  } else {

Doesn't `lockedForWrite` need to be atomic?  If it is not atomic, there is no 
guarantee that thread 2 will see the results of thread 1's modifications with 
any kind of reasonable order.


https://reviews.llvm.org/D38704



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov updated this revision to Diff 118291.
george.karpenkov added a comment.

Review comments.


https://reviews.llvm.org/D38702

Files:
  lib/Analysis/BodyFarm.cpp
  test/Analysis/call_once.cpp


Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -231,3 +231,12 @@
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -327,6 +327,28 @@
   const ParmVarDecl *Flag = D->getParamDecl(0);
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
+  QualType FlagType = Flag->getType().getNonReferenceType();
+  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (!FlagCXXDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
+
+  // Note: here we are assuming libc++ implementation of call_once,
+  // which has a struct with a field `__state_`.
+  // Body farming might not work for other `call_once` implementations.
+  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
+  ValueDecl *FieldDecl;
+  if (FoundDecl) {
+FieldDecl = dyn_cast(FoundDecl);
+  } else {
+DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
+   << "unable to synthesize call_once body, ignoring "
+   << "the call.\n");
+return nullptr;
+  }
 
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&
   CallbackType->getAsCXXRecordDecl()->isLambda();
@@ -355,27 +377,11 @@
 CallbackCall = create_call_once_funcptr_call(C, M, Callback, CallArgs);
   }
 
-  QualType FlagType = Flag->getType().getNonReferenceType();
   DeclRefExpr *FlagDecl =
   M.makeDeclRefExpr(Flag,
 /* RefersToEnclosingVariableOrCapture=*/true,
 /* GetNonReferenceType=*/true);
 
-  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
-
-  // Note: here we are assuming libc++ implementation of call_once,
-  // which has a struct with a field `__state_`.
-  // Body farming might not work for other `call_once` implementations.
-  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
-  ValueDecl *FieldDecl;
-  if (FoundDecl) {
-FieldDecl = dyn_cast(FoundDecl);
-  } else {
-DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
-   << "unable to synthesize call_once body, ignoring "
-   << "the call.\n");
-return nullptr;
-  }
 
   MemberExpr *Deref = M.makeMemberExpression(FlagDecl, FieldDecl);
   assert(Deref->isLValue());


Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -231,3 +231,12 @@
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -327,6 +327,28 @@
   const ParmVarDecl *Flag = D->getParamDecl(0);
   const ParmVarDecl *Callback = D->getParamDecl(1);
   QualType CallbackType = Callback->getType().getNonReferenceType();
+  QualType FlagType = Flag->getType().getNonReferenceType();
+  CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (!FlagCXXDecl) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
+
+  // Note: here we are assuming libc++ implementation of call_once,
+  // which has a struct with a field `__state_`.
+  // Body farming might not work for other `call_once` implementations.
+  NamedDecl *FoundDecl = M.findMemberField(FlagCXXDecl, "__state_");
+  ValueDecl *FieldDecl;
+  if (FoundDecl) {
+FieldDecl = dyn_cast(FoundDecl);
+  } else {
+DEBUG(llvm::dbgs() << "No field __state_ found on std::once_flag struct, "
+   << "unable to synthesize call_once body, ignoring "
+   << "the call.\n");
+return nullptr;
+  }
 
   bool isLambdaCall = CallbackType->getAsCXXRecordDecl() &&
   

Re: [PATCH] D38464: [clangd] less boilerplate in RPC dispatch

2017-10-09 Thread David Blaikie via cfe-commits
hey Lang (& folks here) any chance there's some overlap between the RPC
functionality here and the RPC functionality in ORC that could be
deduplicated/refactored?

On Fri, Oct 6, 2017 at 5:30 AM Ilya Biryukov via Phabricator via
cfe-commits  wrote:

> ilya-biryukov accepted this revision.
> ilya-biryukov added a comment.
> This revision is now accepted and ready to land.
>
> LGTM.
> Note there's a new LSP method handler added upstream
> (`textDocument/signatureHelp`), we should add it to this change before
> submitting.
>
>
>
> 
> Comment at: clangd/ClangdLSPServer.h:47
>// Implement ProtocolCallbacks.
> -  void onInitialize(StringRef ID, InitializeParams IP,
> -JSONOutput ) override;
> -  void onShutdown(JSONOutput ) override;
> -  void onDocumentDidOpen(DidOpenTextDocumentParams Params,
> - JSONOutput ) override;
> -  void onDocumentDidChange(DidChangeTextDocumentParams Params,
> -   JSONOutput ) override;
> -  void onDocumentDidClose(DidCloseTextDocumentParams Params,
> -  JSONOutput ) override;
> -  void onDocumentOnTypeFormatting(DocumentOnTypeFormattingParams Params,
> -  StringRef ID, JSONOutput ) override;
> -  void onDocumentRangeFormatting(DocumentRangeFormattingParams Params,
> - StringRef ID, JSONOutput ) override;
> -  void onDocumentFormatting(DocumentFormattingParams Params, StringRef ID,
> -JSONOutput ) override;
> -  void onCodeAction(CodeActionParams Params, StringRef ID,
> -JSONOutput ) override;
> -  void onCompletion(TextDocumentPositionParams Params, StringRef ID,
> -JSONOutput ) override;
> -  void onGoToDefinition(TextDocumentPositionParams Params, StringRef ID,
> -JSONOutput ) override;
> -  void onSwitchSourceHeader(TextDocumentIdentifier Params, StringRef ID,
> -JSONOutput ) override;
> +  void onInitialize(Ctx , InitializeParams ) override;
> +  void onShutdown(Ctx , NoParams ) override;
> 
> sammccall wrote:
> > ilya-biryukov wrote:
> > > ilya-biryukov wrote:
> > > > Maybe there's a way to have a typed return value instead of `Ctx`?
> > > > This would give an interface that's harder to misuse: one can't
> forget to call `reply` or call it twice.
> > > >
> > > > Here's on design that comes to mind.
> > > > Notification handlers could have `void` return, normal requests can
> return `Optional` or `Optional` (with result json).
> > > > `Optional` is be used to indicate whether error occurred while
> processing the request.
> > > >
> > > After putting more thought into it, `Ctx`-based API seems to have an
> advantage: it will allow us to easily implement async responses.
> > > E.g., we can run code completion on a background thread and continue
> processing other requests. When completion is ready, we will simply call
> `Ctx.reply` to return results to the language client.
> > >
> > > To make that possible, can we allow moving `RequestContext` and pass
> it by-value instead of by-ref?
> > Yeah I thought about returning a value... it certainly reads more
> nicely, but I don't think we're ready to do a good job in this patch:
> >  - return value should be an object ready to be serialized (rather than
> a JSON string) - I don't want to bring that in scope here, but it might
> affect the details of the API
> >  - there's several cases we know about (return object, no reply, error
> reply) and some we're not sure about (async as you mention - any multiple
> responses)? I think this needs some design, and I don't yet know the
> project well enough to drive it.
> >
> > I've switched to passing Ctx by value as you suggest (though it's
> certainly cheap enough to copy, too).
> Yeah, copy is also fine there performance-wise.
>
> I do think move-only interface fits slightly better. We can check a whole
> bunch of invariants if `Ctx` is move-only (i.e., that request wasn't
> dropped without response or `reply` was not called twice).
>
>
> 
> Comment at: clangd/ClangdLSPServer.h:48
> +  void onInitialize(Ctx , InitializeParams ) override;
> +  void onShutdown(Ctx , NoParams ) override;
> +  void onDocumentDidOpen(Ctx , DidOpenTextDocumentParams )
> override;
> 
> sammccall wrote:
> > ilya-biryukov wrote:
> > > Maybe there's a way to get rid of `NoParams`?
> > > E.g. by adding a overload to `HandlerRegisterer`?
> > Even if there was, I think I prefer the regularity (changed this to
> ShutdownParams - oops!).
> >
> > Otherwise the signature's dependent on some combination of {current LSP,
> whether we actually implement the options, whether we've defined any
> extensions}. It's harder to remember, means changing lots of places when
> these factors change, and complicates the generic code.
> >
> > Maybe I've just spent too long 

[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple updated this revision to Diff 118287.
jkorous-apple added a comment.

added another test


https://reviews.llvm.org/D38707

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/func-type.cpp


Index: test/Index/USR/func-type.cpp
===
--- /dev/null
+++ test/Index/USR/func-type.cpp
@@ -0,0 +1,18 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures 
should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
+
+void Func( void (* (*)(int, int))(int, int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
+void Func( void (* (*)(int, int, int))(int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;


Index: test/Index/USR/func-type.cpp
===
--- /dev/null
+++ test/Index/USR/func-type.cpp
@@ -0,0 +1,18 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
+
+void Func( void (* (*)(int, int))(int, int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I#I)(#I#I)# |
+void Func( void (* (*)(int, int, int))(int) );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)(#I#I#I)# |
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

I'm also much out of my depth here, but I'm skeptical. You're changing the 
comments in the code from essentially saying "This workaround helps people with 
broken code" to essentially saying "This indispensable functionality helps 
people like me who use dlopen()."  Are you 100% sure that you're not just a 
person with broken code?

In other words, what did this guy from 2013 get wrong? -- or, if "he got 
nothing wrong", then why can't you just follow his advice to eliminate the 
duplicate typeinfos from your code? 
http://www.russellmcc.com/posts/2013-08-03-rtti.html


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

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

> @dcoughlin Any advice on how to handle different stdlib implementations?
>  Can we conjure a separate symbol instead of relying on a particular struct 
> layout?
>  For now this implementation will simply not go inside a differently 
> implemented call_once.

I think that for now your solution is the best to avoid the crashes. Let's see 
what Alexander has to say about the standard library causing the crashes. 
Ideally, we don't want to fall down too hard on libstdc++.

If we really need to handle a variety of standard libraries (or versions of 
standard libraries) we'll probably want to to treat `std::call_once` more 
abstractly and write a checker that models its behavior instead of body farming 
it.




Comment at: lib/Analysis/BodyFarm.cpp:365
   CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (FlagCXXDecl == nullptr) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "

LLVM style is to write this null check as `if (!FlagCXXDecl)`.



Comment at: lib/Analysis/BodyFarm.cpp:369
+   << "Ignoring the call.\n");
+return nullptr;
+  }

This return will leak the allocated AST nodes (as will the return for 
`__state__` below). Can you hoist the validation checks to above the AST 
creation?


https://reviews.llvm.org/D38702



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


[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Index/USRGeneration.cpp:757
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {

I believe you can drop the '(' and ')'. The '#' should be enough to prevent the 
USR collision.


https://reviews.llvm.org/D38707



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


[PATCH] D38680: [libunwind] Fix handling of DW_CFA_GNU_args_size

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38680#892487, @compnerd wrote:

> I think that the problem is that we are using the generic register name, but 
> we need to use the target specific register name.  On x86, EIP/ESP are 
> swapped.


You mean EBP/ESP? I think the code here does the right thing, with `UNW_REG_SP` 
always mapping to the actual ESP.

> We should also have a test case for this.  I had reduced this down to a 
> simpler test case of:
> 
>   void f(int,int,int,int,int,int,int,int,int);
>
>   int main() {
> try {
>   f(0,1,2,3,4,5,6,7,8);
> } catch (int) {
>   return 0;
> }
> return 1;
>   }
>

Oh, great if you can reproduce the issue with that! Feel free to try to dig 
into the issue and figure out a better fix then.


https://reviews.llvm.org/D38680



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


[PATCH] D38708: [AST] Flag the typo-corrected nodes for better tooling

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.

This patch adds a new boolean field to the `DeclRefExpr`, `MemberExpr`, 
`CXXCtorInitializer`, `ObjCIvarRefExpr`, `ObjCPropertyRefExpr` nodes which is 
set to true when these nodes have been produced during typo-correction.

This is useful for Clang-based tooling as it can distinguish between true 
references and the typo-corrected references. The initial tooling support uses 
the flag to prevent token annotation for typo-corrected references and to 
prevent finding typo-corrected references during single TU reference search.


Repository:
  rL LLVM

https://reviews.llvm.org/D38708

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/Expr.h
  include/clang/AST/ExprObjC.h
  include/clang/AST/Stmt.h
  lib/AST/DeclCXX.cpp
  lib/AST/Expr.cpp
  lib/Sema/SemaDecl.cpp
  lib/Sema/SemaDeclCXX.cpp
  lib/Sema/SemaExprCXX.cpp
  lib/Sema/SemaExprMember.cpp
  lib/Sema/SemaExprObjC.cpp
  lib/Sema/SemaOverload.cpp
  lib/Sema/SemaPseudoObject.cpp
  lib/Sema/SemaTemplateInstantiateDecl.cpp
  lib/Sema/TreeTransform.h
  lib/Serialization/ASTReader.cpp
  lib/Serialization/ASTReaderStmt.cpp
  lib/Serialization/ASTWriter.cpp
  lib/Serialization/ASTWriterDecl.cpp
  lib/Serialization/ASTWriterStmt.cpp
  test/Index/typo-annotate-tokens.mm
  test/Index/typo-file-refs.cpp
  test/Index/typo-file-refs.m
  tools/libclang/CIndex.cpp
  tools/libclang/CIndexHigh.cpp
  tools/libclang/CursorVisitor.h

Index: tools/libclang/CursorVisitor.h
===
--- tools/libclang/CursorVisitor.h
+++ tools/libclang/CursorVisitor.h
@@ -96,6 +96,9 @@
   /// record entries.
   bool VisitDeclsOnly;
 
+  /// \brief Whether we should visit typo-corrected references.
+  bool VisitTypoCorrected = true;
+
   // FIXME: Eventually remove.  This part of a hack to support proper
   // iteration over all Decls contained lexically within an ObjC container.
   DeclContext::decl_iterator *DI_current;
@@ -187,6 +190,8 @@
 return VisitIncludedEntities;
   }
 
+  void setVisitTypoCorrected(bool V = true) { VisitTypoCorrected = V; }
+
   template
   bool visitPreprocessedEntities(InputIterator First, InputIterator Last,
  PreprocessingRecord ,
Index: tools/libclang/CIndexHigh.cpp
===
--- tools/libclang/CIndexHigh.cpp
+++ tools/libclang/CIndexHigh.cpp
@@ -169,7 +169,9 @@
 if (clang_isExpression(cursor.kind)) {
   if (cursor.kind == CXCursor_DeclRefExpr ||
   cursor.kind == CXCursor_MemberRefExpr) {
-// continue..
+// Avoid visiting typo-corrected references.
+if (cxcursor::getCursorExpr(cursor)->isTypoCorrected())
+  return CXChildVisit_Continue;
 
   } else if (cursor.kind == CXCursor_ObjCMessageExpr &&
  cxcursor::getSelectorIdentifierIndex(cursor) != -1) {
@@ -228,8 +230,11 @@
   Visitor);
 
   if (const DeclContext *DC = Dcl->getParentFunctionOrMethod()) {
-return clang_visitChildren(cxcursor::MakeCXCursor(cast(DC), TU),
-   findFileIdRefVisit, );
+CursorVisitor CursorVis(TU, findFileIdRefVisit, ,
+/*VisitPreprocessorLast=*/false);
+// Don't include the typo-corrected references.
+CursorVis.setVisitTypoCorrected(false);
+return CursorVis.VisitChildren(cxcursor::MakeCXCursor(cast(DC), TU));
   }
 
   SourceRange Range(SM.getLocForStartOfFile(FID), SM.getLocForEndOfFile(FID));
@@ -239,6 +244,8 @@
   /*VisitIncludedEntities=*/false,
   Range,
   /*VisitDeclsOnly=*/true);
+  // Don't include the typo-corrected references.
+  FindIdRefsVisitor.setVisitTypoCorrected(false);
   return FindIdRefsVisitor.visitFileRegion();
 }
 
Index: tools/libclang/CIndex.cpp
===
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -847,13 +847,15 @@
   // Visit the initializers in source order
   for (unsigned I = 0, N = WrittenInits.size(); I != N; ++I) {
 CXXCtorInitializer *Init = WrittenInits[I];
-if (Init->isAnyMemberInitializer()) {
-  if (Visit(MakeCursorMemberRef(Init->getAnyMember(),
-Init->getMemberLocation(), TU)))
-return true;
-} else if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo()) {
-  if (Visit(TInfo->getTypeLoc()))
-return true;
+if (VisitTypoCorrected | !Init->isTypoCorrected()) {
+  if (Init->isAnyMemberInitializer()) {
+if (Visit(MakeCursorMemberRef(Init->getAnyMember(),
+  Init->getMemberLocation(), TU)))
+  return true;
+  } else if (TypeSourceInfo *TInfo = Init->getTypeSourceInfo()) {
+if (Visit(TInfo->getTypeLoc()))
+  

[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added a comment.

In https://reviews.llvm.org/D38704#892479, @zturner wrote:

> I'm a little nervous about re-inventing a poor man's version of a reader 
> writer lock.  Can we not just copy LLVM's?


I guess I could have a look to see how much extra either kitchen sink it would 
bring. Since it almost mapped 1:1 to the windows functions, I thought it 
wouldn't end up too large - unfortunately the return values and unlock 
functions made it a bit harder though.




Comment at: src/UnwindCursor.hpp:20
 #ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
+  #ifdef _WIN32
+#include 

zturner wrote:
> Maybe you want to check `_MSC_VER` here?  I think MinGW compilers will have 
> `pthread` support.
MinGW compilers can have optional pthread support (it's not a feature of the 
compiler itself but an extra library that one can choose to build), but not 
everybody wants to use it and at least I wouldn't want to use it as mandatory 
dependency for any C++ support based on libunwind.



Comment at: src/UnwindCursor.hpp:50
+static bool lockedForWrite = false;
+static int pthread_rwlock_rdlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockShared(lock);

zturner wrote:
> This doesn't seem like what you want.  a global `static` function / variable 
> in a header file is going to be duplicated in every translation unit.  i.e. 
> two translation units will have different copies of `lockedForWrite`.  Same 
> goes for the rest of the functions.
Oh, right - I would need to make it match the static class member `_lock` 
instead.



Comment at: src/UnwindCursor.hpp:61-64
+  if (lockedForWrite) {
+lockedForWrite = false;
+ReleaseSRWLockExclusive(lock);
+  } else {

zturner wrote:
> Doesn't `lockedForWrite` need to be atomic?  If it is not atomic, there is no 
> guarantee that thread 2 will see the results of thread 1's modifications with 
> any kind of reasonable order.
I don't think it needs to be atomic, although the `rdlock` function perhaps 
shouldn't touch it at all. It only ever gets set to true once we have an 
exclusive lock, and in those cases gets set back to false before the exclusive 
lock gets released. So without touching it in the `rdlock` function, we only 
ever write to it while holding the exclusive write lock.


https://reviews.llvm.org/D38704



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


[PATCH] D38707: PR13575: Fix USR mangling for functions taking function pointers as arguments.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple created this revision.

https://reviews.llvm.org/D38707

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/func-type.cpp


Index: test/Index/USR/func-type.cpp
===
--- /dev/null
+++ test/Index/USR/func-type.cpp
@@ -0,0 +1,13 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures 
should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;


Index: test/Index/USR/func-type.cpp
===
--- /dev/null
+++ test/Index/USR/func-type.cpp
@@ -0,0 +1,13 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Functions taking function pointer parameters with different signatures should result in unique USRs.
+
+typedef void (*_VoidToVoidPtr_)();
+typedef void (*_IntToVoidPtr_)( int );
+typedef _VoidToVoidPtr_ (*IntTo_VoidToVoidPtr_Ptr)( int );
+typedef _IntToVoidPtr_ (*VoidTo_IntToVoidPtr_Ptr)();
+
+void Func( IntTo_VoidToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv()(#I)# |
+void Func( VoidTo_IntToVoidPtr_Ptr );
+// CHECK: {{[0-9]+}}:6 | function/C | Func | c:@F@Func#*F*Fv(#I)()# |
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -754,8 +754,12 @@
 if (const FunctionProtoType *FT = T->getAs()) {
   Out << 'F';
   VisitType(FT->getReturnType());
-  for (const auto  : FT->param_types())
+  Out << '(';
+  for (const auto  : FT->param_types()) {
+Out << '#';
 VisitType(I);
+  }
+  Out << ')';
   if (FT->isVariadic())
 Out << '.';
   return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38704: [libunwind] Emulate pthread rwlocks via SRW locks for windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
Herald added a subscriber: mehdi_amini.

This makes sure that the FDE cache is thread safe.

This requires building with `_WIN32_WINNT >= 0x0600`.

The alternative would be to skip the FDE cache altogether if building without 
threads.


https://reviews.llvm.org/D38704

Files:
  src/UnwindCursor.hpp


Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -17,7 +17,11 @@
 #include 
 #include 
 #ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
+  #ifdef _WIN32
+#include 
+  #else
+#include 
+  #endif
 #endif
 #include 
 
@@ -36,6 +40,34 @@
 #include "Registers.hpp"
 #include "Unwind-EHABI.h"
 
+#if !defined(_LIBUNWIND_HAS_NO_THREADS) && defined(_WIN32)
+#define pthread_rwlock_t SRWLOCK
+#define PTHREAD_RWLOCK_INITIALIZER SRWLOCK_INIT
+// As long as these functions are only ever used with one lock,
+// we can get away with a global flag to decide which kind of
+// unlock to do.
+static bool lockedForWrite = false;
+static int pthread_rwlock_rdlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockShared(lock);
+  lockedForWrite = false;
+  return 0;
+}
+static int pthread_rwlock_wrlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockExclusive(lock);
+  lockedForWrite = true;
+  return 0;
+}
+static int pthread_rwlock_unlock(pthread_rwlock_t *lock) {
+  if (lockedForWrite) {
+lockedForWrite = false;
+ReleaseSRWLockExclusive(lock);
+  } else {
+ReleaseSRWLockShared(lock);
+  }
+  return 0;
+}
+#endif
+
 namespace libunwind {
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)


Index: src/UnwindCursor.hpp
===
--- src/UnwindCursor.hpp
+++ src/UnwindCursor.hpp
@@ -17,7 +17,11 @@
 #include 
 #include 
 #ifndef _LIBUNWIND_HAS_NO_THREADS
-  #include 
+  #ifdef _WIN32
+#include 
+  #else
+#include 
+  #endif
 #endif
 #include 
 
@@ -36,6 +40,34 @@
 #include "Registers.hpp"
 #include "Unwind-EHABI.h"
 
+#if !defined(_LIBUNWIND_HAS_NO_THREADS) && defined(_WIN32)
+#define pthread_rwlock_t SRWLOCK
+#define PTHREAD_RWLOCK_INITIALIZER SRWLOCK_INIT
+// As long as these functions are only ever used with one lock,
+// we can get away with a global flag to decide which kind of
+// unlock to do.
+static bool lockedForWrite = false;
+static int pthread_rwlock_rdlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockShared(lock);
+  lockedForWrite = false;
+  return 0;
+}
+static int pthread_rwlock_wrlock(pthread_rwlock_t *lock) {
+  AcquireSRWLockExclusive(lock);
+  lockedForWrite = true;
+  return 0;
+}
+static int pthread_rwlock_unlock(pthread_rwlock_t *lock) {
+  if (lockedForWrite) {
+lockedForWrite = false;
+ReleaseSRWLockExclusive(lock);
+  } else {
+ReleaseSRWLockShared(lock);
+  }
+  return 0;
+}
+#endif
+
 namespace libunwind {
 
 #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs resigned from this revision.
jroelofs added a comment.

I'm not sure I'm the right person to review this.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[PATCH] D38599: Remove warnings for dynamic_cast fallback.

2017-10-09 Thread Dan Albert via Phabricator via cfe-commits
danalbert added a comment.

In https://reviews.llvm.org/D38599#889842, @smeenai wrote:

> Does dlopen cause issues even with `RTLD_GLOBAL`?


From my testing, yes. Regardless, `RTLD_LOCAL` is how JNI libraries get loaded 
when `System.loadLibrary` is used, so the `strcmp` fallback is a requirement 
for that use case.


Repository:
  rL LLVM

https://reviews.llvm.org/D38599



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


[clang-tools-extra] r315242 - Revert r315214 since diff -Z isn't portable, this is breaking:

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Author: bruno
Date: Mon Oct  9 13:22:05 2017
New Revision: 315242

URL: http://llvm.org/viewvc/llvm-project?rev=315242=rev
Log:
Revert r315214 since diff -Z isn't portable, this is breaking:

http://green.lab.llvm.org/green/job/clang-stage1-cmake-RA-expensive
http://green.lab.llvm.org/green/job/clang-stage1-configure-RA


Removed:
clang-tools-extra/trunk/test/clangd/input-mirror.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315242=315241=315242=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 13:22:05 
2017
@@ -37,14 +37,6 @@ void JSONOutput::log(const Twine 
   Logs.flush();
 }
 
-void JSONOutput::mirrorInput(const Twine ) {
-  if (!InputMirror)
-return;
-
-  *InputMirror << Message;
-  InputMirror->flush();
-}
-
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
   Output.log("Method ignored.\n");
   // Return that this method is unsupported.
@@ -155,14 +147,6 @@ void clangd::runLanguageServerLoop(std::
 continue;
   }
 
-  Out.mirrorInput(Line);
-  // Mirror '\n' that gets consumed by std::getline, but is not included in
-  // the resulting Line.
-  // Note that '\r' is part of Line, so we don't need to mirror it
-  // separately.
-  if (!In.eof())
-Out.mirrorInput("\n");
-
   llvm::StringRef LineRef(Line);
 
   // We allow YAML-style comments in headers. Technically this isn't part
@@ -179,8 +163,9 @@ void clangd::runLanguageServerLoop(std::
   if (LineRef.consume_front("Content-Length: ")) {
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
-  "The previous value for this message (" +
-  std::to_string(ContentLength) + ") was ignored.\n");
+  "The previous value for this message ("
+  + std::to_string(ContentLength)
+  + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -200,13 +185,15 @@ void clangd::runLanguageServerLoop(std::
   // parser.
   std::vector JSON(ContentLength + 1, '\0');
   In.read(JSON.data(), ContentLength);
-  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
 
   // If the stream is aborted before we read ContentLength bytes, In
   // will have eofbit and failbit set.
   if (!In) {
-Out.log("Input was aborted. Read only " + std::to_string(In.gcount()) +
-" bytes of expected " + std::to_string(ContentLength) + ".\n");
+Out.log("Input was aborted. Read only "
++ std::to_string(In.gcount())
++ " bytes of expected "
++ std::to_string(ContentLength)
++ ".\n");
 break;
   }
 
@@ -222,8 +209,8 @@ void clangd::runLanguageServerLoop(std::
   if (IsDone)
 break;
 } else {
-  Out.log("Warning: Missing Content-Length header, or message has zero "
-  "length.\n");
+  Out.log( "Warning: Missing Content-Length header, or message has zero "
+   "length.\n" );
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315242=315241=315242=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 13:22:05 2017
@@ -24,9 +24,8 @@ namespace clangd {
 /// them.
 class JSONOutput : public Logger {
 public:
-  JSONOutput(llvm::raw_ostream , llvm::raw_ostream ,
- llvm::raw_ostream *InputMirror = nullptr)
-  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
+  JSONOutput(llvm::raw_ostream , llvm::raw_ostream )
+  : Outs(Outs), Logs(Logs) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const Twine );
@@ -34,15 +33,9 @@ public:
   /// Write to the logging stream.
   void log(const Twine ) override;
 
-  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is
-  /// null.
-  /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
-  void mirrorInput(const Twine );
-
 private:
   llvm::raw_ostream 
   llvm::raw_ostream 
-  llvm::raw_ostream *InputMirror;
 
   std::mutex StreamMutex;
 };

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: docs/index.rst:53
 NetBSD   x86_64   Clang, GCC   DWARF CFI
+Windows  i386 ClangDWARF CFI
 Any  i386, x86_64, ARMClangSjLj

FWIW, for this to actually work correct which this docs change claims, this 
also depends on D38680.


https://reviews.llvm.org/D38679



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

mstorsjo wrote:
> mstorsjo wrote:
> > jroelofs wrote:
> > > Would it work to implement the win32 side of this via `SymFromAddr`?
> > Hmm, I guess that would work.
> ... actually, I'm not sure how useful it is - it requires initializing the 
> symbol handler with `SymInitialize` and point to a path to find the symbols. 
> Plus that the symbol handler is single threaded and any calls to that would 
> need to be guarded with a global mutex. So I think I'd defer that for now at 
> least.
alright, fine with me.


https://reviews.llvm.org/D38679



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


r315241 - PR13575: Fix test

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 13:17:28 2017
New Revision: 315241

URL: http://llvm.org/viewvc/llvm-project?rev=315241=rev
Log:
PR13575: Fix test

Ignore OS-specific mangled name.

Modified:
cfe/trunk/test/Index/USR/array-type.cpp

Modified: cfe/trunk/test/Index/USR/array-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/array-type.cpp?rev=315241=315240=315241=diff
==
--- cfe/trunk/test/Index/USR/array-type.cpp (original)
+++ cfe/trunk/test/Index/USR/array-type.cpp Mon Oct  9 13:17:28 2017
@@ -3,9 +3,9 @@
 // Function template specializations differing in array type parameter should 
have unique USRs.
 
 template void foo(buffer);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C#
 template<> void foo(char[16]);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C#
 template<> void foo(char[32]);
-// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C#
 template<> void foo(char[64]);


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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo updated this revision to Diff 118263.
mstorsjo added a comment.

Added a fixme comment about the truncated section name, flipped the ifdef in 
the assembly source. Didn't implement findFunctionName.


https://reviews.llvm.org/D38679

Files:
  docs/index.rst
  src/AddressSpace.hpp
  src/UnwindRegistersRestore.S
  src/assembly.h
  src/config.h

Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -37,6 +37,8 @@
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
+#elif defined(_WIN32)
+  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/assembly.h
===
--- src/assembly.h
+++ src/assembly.h
@@ -26,6 +26,14 @@
 
 #if defined(__APPLE__)
 #define HIDDEN_DIRECTIVE .private_extern
+#elif defined(_WIN32)
+// In the COFF object file format, there's no attributes for a global,
+// non-static symbol to make it somehow hidden. So on windows, we don't
+// want to set this at all. To avoid conditionals in
+// DEFINE_LIBUNWIND_PRIVATE_FUNCTION below, make it .globl (which it already
+// is, defined in the same DEFINE_LIBUNWIND_PRIVATE_FUNCTION macro; the
+// duplicate .globl directives are harmless).
+#define HIDDEN_DIRECTIVE .globl
 #else
 #define HIDDEN_DIRECTIVE .hidden
 #endif
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -18,6 +18,10 @@
 #
 # void libunwind::Registers_x86::jumpto()
 #
+#if defined(_WIN32)
+# On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#else
 # On entry:
 #  +   +
 #  +---+
@@ -27,6 +31,7 @@
 #  +---+   <-- SP
 #  +   +
   movl   4(%esp), %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx
Index: src/AddressSpace.hpp
===
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,43 @@
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), ))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)>FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+// FIXME: This section name actually is truncated, ideally we
+// should locate and check the full long name instead.
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +520,7 @@
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr, )) {
 

[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

mstorsjo wrote:
> jroelofs wrote:
> > Would it work to implement the win32 side of this via `SymFromAddr`?
> Hmm, I guess that would work.
... actually, I'm not sure how useful it is - it requires initializing the 
symbol handler with `SymInitialize` and point to a path to find the symbols. 
Plus that the symbol handler is single threaded and any calls to that would 
need to be guarded with a global mutex. So I think I'd defer that for now at 
least.


https://reviews.llvm.org/D38679



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


[PATCH] D36527: Implemented P0428R2 - Familiar template syntax for generic lambdas

2017-10-09 Thread Hamza Sood via Phabricator via cfe-commits
hamzasood updated this revision to Diff 118261.
hamzasood added a comment.

- Updated lambda mangling to include explicit template parameters
- Allow explicit template parameter lists on lambdas pre-c++2a as an extension.
- Improved the somewhat fragile template depth handling.
- Reformatted some asserts.

Could you expand on your first point a bit more? Do you have an example that 
shows the issue?


https://reviews.llvm.org/D36527

Files:
  include/clang/AST/DeclCXX.h
  include/clang/AST/DeclTemplate.h
  include/clang/AST/ExprCXX.h
  include/clang/AST/RecursiveASTVisitor.h
  include/clang/Basic/DiagnosticParseKinds.td
  include/clang/Parse/Parser.h
  include/clang/Sema/ScopeInfo.h
  include/clang/Sema/Sema.h
  lib/AST/DeclCXX.cpp
  lib/AST/DeclPrinter.cpp
  lib/AST/ExprCXX.cpp
  lib/AST/ItaniumMangle.cpp
  lib/AST/StmtPrinter.cpp
  lib/AST/TypePrinter.cpp
  lib/Parse/ParseExprCXX.cpp
  lib/Sema/Sema.cpp
  lib/Sema/SemaLambda.cpp
  lib/Sema/SemaType.cpp
  test/CXX/temp/temp.decls/temp.variadic/p4.cpp
  test/CodeGenCXX/mangle-lambda-explicit-template-params.cpp
  test/PCH/cxx11-lambdas.mm
  test/PCH/cxx1y-lambdas.mm
  test/PCH/cxx2a-template-lambdas.cpp
  test/Parser/cxx2a-template-lambdas.cpp
  test/SemaCXX/cxx2a-template-lambdas.cpp
  unittests/AST/StmtPrinterTest.cpp
  unittests/Tooling/RecursiveASTVisitorTest.cpp
  unittests/Tooling/TestVisitor.h
  www/cxx_status.html

Index: www/cxx_status.html
===
--- www/cxx_status.html
+++ www/cxx_status.html
@@ -823,7 +823,7 @@
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2;>P0428R2
-  No
+  SVN
 
 
   Initializer list constructors in class template argument deduction
Index: unittests/Tooling/TestVisitor.h
===
--- unittests/Tooling/TestVisitor.h
+++ unittests/Tooling/TestVisitor.h
@@ -44,6 +44,8 @@
 Lang_CXX98,
 Lang_CXX11,
 Lang_CXX14,
+Lang_CXX17,
+Lang_CXX2a,
 Lang_OBJC,
 Lang_OBJCXX11,
 Lang_CXX = Lang_CXX98
@@ -60,6 +62,8 @@
   case Lang_CXX98: Args.push_back("-std=c++98"); break;
   case Lang_CXX11: Args.push_back("-std=c++11"); break;
   case Lang_CXX14: Args.push_back("-std=c++14"); break;
+  case Lang_CXX17: Args.push_back("-std=c++17"); break;
+  case Lang_CXX2a: Args.push_back("-std=c++2a"); break;
   case Lang_OBJC:
 Args.push_back("-ObjC");
 Args.push_back("-fobjc-runtime=macosx-10.12.0");
Index: unittests/Tooling/RecursiveASTVisitorTest.cpp
===
--- unittests/Tooling/RecursiveASTVisitorTest.cpp
+++ unittests/Tooling/RecursiveASTVisitorTest.cpp
@@ -79,6 +79,41 @@
   LambdaDefaultCaptureVisitor::Lang_CXX11));
 }
 
+// Matches (optional) explicit template parameters.
+class LambdaTemplateParametersVisitor
+  : public ExpectedLocationVisitor {
+public:
+  bool shouldVisitImplicitCode() const { return false; }
+
+  bool VisitTemplateTypeParmDecl(TemplateTypeParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+  bool VisitNonTypeTemplateParmDecl(NonTypeTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+  bool VisitTemplateTemplateParmDecl(TemplateTemplateParmDecl *D) {
+EXPECT_FALSE(D->isImplicit());
+Match(D->getName(), D->getLocStart());
+return true;
+  }
+};
+
+TEST(RecursiveASTVisitor, VisitsLambdaExplicitTemplateParameters) {
+  LambdaTemplateParametersVisitor Visitor;
+  Visitor.ExpectMatch("T",  2, 15);
+  Visitor.ExpectMatch("I",  2, 24);
+  Visitor.ExpectMatch("TT", 2, 31);
+  EXPECT_TRUE(Visitor.runOver(
+  "void f() { \n"
+  "  auto l = [] class TT>(auto p) { }; \n"
+  "}",
+  LambdaTemplateParametersVisitor::Lang_CXX2a));
+}
+
 // Checks for lambda classes that are not marked as implicitly-generated.
 // (There should be none.)
 class ClassVisitor : public ExpectedLocationVisitor {
Index: unittests/AST/StmtPrinterTest.cpp
===
--- unittests/AST/StmtPrinterTest.cpp
+++ unittests/AST/StmtPrinterTest.cpp
@@ -67,9 +67,8 @@
 
 template 
 ::testing::AssertionResult
-PrintedStmtMatches(StringRef Code, const std::vector ,
-   const T , StringRef ExpectedPrinted) {
-
+PrintedStmtMatchesInternal(StringRef Code, const std::vector ,
+   const T , StringRef ExpectedPrinted) {
   PrintMatch Printer;
   MatchFinder Finder;
   Finder.addMatcher(NodeMatch, );
@@ -97,65 +96,52 @@
   return ::testing::AssertionSuccess();
 }
 
+enum class StdVer { CXX98, CXX11, CXX14, CXX17, CXX2a };
+
+DeclarationMatcher FunctionBodyMatcher(StringRef ContainingFunction) {
+  return functionDecl(hasName(ContainingFunction),
+  

[PATCH] D38698: AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm closed this revision.
arsenm added a comment.

r315238


https://reviews.llvm.org/D38698



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


r315238 - AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Oct  9 13:06:37 2017
New Revision: 315238

URL: http://llvm.org/viewvc/llvm-project?rev=315238=rev
Log:
AMDGPU: Add read_exec_lo/hi builtins

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=315238=315237=315238=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Mon Oct  9 13:06:37 2017
@@ -121,6 +121,8 @@ TARGET_BUILTIN(__builtin_amdgcn_fmed3h,
 // Special builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc")
 
 
//===--===//
 // R600-NI only builtins.

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=315238=315237=315238=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct  9 13:06:37 2017
@@ -9103,6 +9103,15 @@ Value *CodeGenFunction::EmitAMDGPUBuilti
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
+StringRef RegName = BuiltinID == AMDGPU::BI__builtin_amdgcn_read_exec_lo ?
+  "exec_lo" : "exec_hi";
+CallInst *CI = cast(
+  EmitSpecialRegisterBuiltin(*this, E, Int32Ty, Int32Ty, true, RegName));
+CI->setConvergent();
+return CI;
+  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=315238=315237=315238=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Mon Oct  9 13:06:37 2017
@@ -421,6 +421,18 @@ void test_read_exec(global ulong* out) {
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_read_exec_lo(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_LO:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_lo(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_lo();
+}
+
+// CHECK-LABEL: @test_read_exec_hi(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_HI:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_hi(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_hi();
+}
+
 // CHECK-LABEL: @test_dispatch_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
 void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
@@ -499,3 +511,5 @@ void test_s_getpc(global ulong* out)
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[EXEC]] = !{!"exec"}
+// CHECK-DAG: ![[EXEC_LO]] = !{!"exec_lo"}
+// CHECK-DAG: ![[EXEC_HI]] = !{!"exec_hi"}


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


[PATCH] D38698: AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Konstantin Zhuravlyov via Phabricator via cfe-commits
kzhuravl accepted this revision.
kzhuravl added a comment.
This revision is now accepted and ready to land.

LGTM.


https://reviews.llvm.org/D38698



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov added a comment.

Ooops, updated to https://bugs.llvm.org/show_bug.cgi?id=34869


https://reviews.llvm.org/D38702



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread Gábor Horváth via Phabricator via cfe-commits
xazax.hun added a comment.

Did you link the correct bug in the description? The one you linked was closed 
long ago.


https://reviews.llvm.org/D38702



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


[PATCH] D38702: [Analyzer] Do not segfault on unexpected call_once implementation

2017-10-09 Thread George Karpenkov via Phabricator via cfe-commits
george.karpenkov created this revision.
Herald added subscribers: szepet, xazax.hun, javed.absar.

Fixes https://bugs.llvm.org/show_bug.cgi?id=30565

@dcoughlin Any advice on how to handle different stdlib implementations?
Can we conjure a separate symbol instead of relying on a particular struct 
layout?
For now this implementation will simply not go inside a differently implemented 
`call_once`.


https://reviews.llvm.org/D38702

Files:
  lib/Analysis/BodyFarm.cpp
  test/Analysis/call_once.cpp


Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -231,3 +231,12 @@
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -362,6 +362,12 @@
 /* GetNonReferenceType=*/true);
 
   CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (FlagCXXDecl == nullptr) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
 
   // Note: here we are assuming libc++ implementation of call_once,
   // which has a struct with a field `__state_`.


Index: test/Analysis/call_once.cpp
===
--- test/Analysis/call_once.cpp
+++ test/Analysis/call_once.cpp
@@ -231,3 +231,12 @@
   int x = call_once();
   clang_analyzer_eval(x == 5); // expected-warning{{TRUE}}
 }
+
+namespace std {
+template 
+void call_once(d, e);
+}
+void g();
+void test_no_segfault_on_different_impl() {
+  std::call_once(g, false); // no-warning
+}
Index: lib/Analysis/BodyFarm.cpp
===
--- lib/Analysis/BodyFarm.cpp
+++ lib/Analysis/BodyFarm.cpp
@@ -362,6 +362,12 @@
 /* GetNonReferenceType=*/true);
 
   CXXRecordDecl *FlagCXXDecl = FlagType->getAsCXXRecordDecl();
+  if (FlagCXXDecl == nullptr) {
+DEBUG(llvm::dbgs() << "Flag field is not a CXX record: "
+   << "unknown std::call_once implementation."
+   << "Ignoring the call.\n");
+return nullptr;
+  }
 
   // Note: here we are assuming libc++ implementation of call_once,
   // which has a struct with a field `__state_`.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315236: PR13575: Fix USR mangling for fixed-size arrays 
(authored by jkorous).

Changed prior to commit:
  https://reviews.llvm.org/D38643?vs=118247=118257#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38643

Files:
  cfe/trunk/lib/Index/USRGeneration.cpp
  cfe/trunk/test/Index/USR/array-type.cpp


Index: cfe/trunk/test/Index/USR/array-type.cpp
===
--- cfe/trunk/test/Index/USR/array-type.cpp
+++ cfe/trunk/test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';


Index: cfe/trunk/test/Index/USR/array-type.cpp
===
--- cfe/trunk/test/Index/USR/array-type.cpp
+++ cfe/trunk/test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | __Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | __Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | __Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: cfe/trunk/lib/Index/USRGeneration.cpp
===
--- cfe/trunk/lib/Index/USRGeneration.cpp
+++ cfe/trunk/lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315236 - PR13575: Fix USR mangling for fixed-size arrays

2017-10-09 Thread Jan Korous via cfe-commits
Author: jkorous
Date: Mon Oct  9 12:51:33 2017
New Revision: 315236

URL: http://llvm.org/viewvc/llvm-project?rev=315236=rev
Log:
PR13575: Fix USR mangling for fixed-size arrays

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

Added:
cfe/trunk/test/Index/USR/
cfe/trunk/test/Index/USR/array-type.cpp
Modified:
cfe/trunk/lib/Index/USRGeneration.cpp

Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=315236=315235=315236=diff
==
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Mon Oct  9 12:51:33 2017
@@ -816,6 +816,25 @@ void USRGenerator::VisitType(QualType T)
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';

Added: cfe/trunk/test/Index/USR/array-type.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/USR/array-type.cpp?rev=315236=auto
==
--- cfe/trunk/test/Index/USR/array-type.cpp (added)
+++ cfe/trunk/test/Index/USR/array-type.cpp Mon Oct  9 12:51:33 2017
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);


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


[libclc] r315235 - Implement mem_fence on ptx

2017-10-09 Thread Jeroen Ketema via cfe-commits
Author: jketema
Date: Mon Oct  9 12:43:04 2017
New Revision: 315235

URL: http://llvm.org/viewvc/llvm-project?rev=315235=rev
Log:
Implement mem_fence on ptx

PTX does not differentiate between read and write fences. Hence, these a
lowered to a mem_fence call. The mem_fence function compiles to the
“member.cta” instruction, which commits all outstanding reads and writes
of a thread such that these become visible to all other threads in the same
CTA (i.e., work-group). The instruction does not differentiate between
global and local memory. Hence, the flags parameter is ignored, except
for deciding whether a “member.cta” instruction should be issued at all.

Reviewed-by: Jan Vesely 

Added:
libclc/trunk/ptx-nvidiacl/lib/mem_fence/
libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl
Modified:
libclc/trunk/ptx-nvidiacl/lib/SOURCES

Modified: libclc/trunk/ptx-nvidiacl/lib/SOURCES
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx-nvidiacl/lib/SOURCES?rev=315235=315234=315235=diff
==
--- libclc/trunk/ptx-nvidiacl/lib/SOURCES (original)
+++ libclc/trunk/ptx-nvidiacl/lib/SOURCES Mon Oct  9 12:43:04 2017
@@ -1,3 +1,4 @@
+mem_fence/fence.cl
 synchronization/barrier.cl
 workitem/get_global_id.cl
 workitem/get_group_id.cl

Added: libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl?rev=315235=auto
==
--- libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl (added)
+++ libclc/trunk/ptx-nvidiacl/lib/mem_fence/fence.cl Mon Oct  9 12:43:04 2017
@@ -0,0 +1,15 @@
+#include 
+
+_CLC_DEF void mem_fence(cl_mem_fence_flags flags) {
+   if (flags & (CLK_GLOBAL_MEM_FENCE | CLK_LOCAL_MEM_FENCE))
+ __nvvm_membar_cta();
+}
+
+// We do not have separate mechanism for read and write fences.
+_CLC_DEF void read_mem_fence(cl_mem_fence_flags flags) {
+  mem_fence(flags);
+}
+
+_CLC_DEF void write_mem_fence(cl_mem_fence_flags flags) {
+  mem_fence(flags);
+}


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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: src/AddressSpace.hpp:388-389
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;

mstorsjo wrote:
> rnk wrote:
> > ".eh_frame" is 9 characters, right? I thought mingw linkers took sections 
> > with long names and moved them to an extended symbol table. Does that not 
> > apply to .eh_frame?
> Yes, they do, so this actually only matches `.eh_fram`. I didn't yet look at 
> how to navigate the IMAGE_*_HEADERS structs to find the coresponding full 
> long name.
Can you add a FIXME here? No need to read the long-form symbol table yet, I 
just want to document that we will need that for compatibility with ld.bfd.


https://reviews.llvm.org/D38679



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

jroelofs wrote:
> Would it work to implement the win32 side of this via `SymFromAddr`?
Hmm, I guess that would work.



Comment at: src/UnwindRegistersRestore.S:29
 #  +   +
+#if !defined(_WIN32)
   movl   4(%esp), %eax

jroelofs wrote:
> Please invert the condition, and swap the if/else on this. That will make it 
> more straightforward to adjust this for other platforms later.
Ok, will do.


https://reviews.llvm.org/D38679



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


[libcxx] r315234 - [libc++] Support Microsoft ABI without vcruntime headers

2017-10-09 Thread Shoaib Meenai via cfe-commits
Author: smeenai
Date: Mon Oct  9 12:25:17 2017
New Revision: 315234

URL: http://llvm.org/viewvc/llvm-project?rev=315234=rev
Log:
[libc++] Support Microsoft ABI without vcruntime headers

The vcruntime headers are hairy and clash with both libc++ headers
themselves and other libraries. libc++ normally deals with the clashes
by deferring to the vcruntime headers and silencing its own definitions,
but for clients which don't want to depend on vcruntime headers, it's
desirable to support the opposite, i.e. have libc++ provide its own
definitions.

Certain operator new/delete replacement scenarios are not currently
supported in this mode, which requires some tests to be marked XFAIL.
The added documentation has more details.

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

Modified:
libcxx/trunk/CMakeLists.txt
libcxx/trunk/docs/UsingLibcxx.rst
libcxx/trunk/include/__config_site.in
libcxx/trunk/include/exception
libcxx/trunk/include/new
libcxx/trunk/src/new.cpp
libcxx/trunk/src/support/runtime/exception_msvc.ipp
libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp

libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
libcxx/trunk/utils/libcxx/test/config.py

Modified: libcxx/trunk/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/CMakeLists.txt?rev=315234=315233=315234=diff
==
--- libcxx/trunk/CMakeLists.txt (original)
+++ libcxx/trunk/CMakeLists.txt Mon Oct  9 12:25:17 2017
@@ -615,6 +615,7 @@ config_define_if(LIBCXX_HAS_PTHREAD_API
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API 
_LIBCPP_HAS_THREAD_API_EXTERNAL)
 config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY 
_LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
+config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
 
 if (LIBCXX_ABI_DEFINES)
   set(abi_defines)

Modified: libcxx/trunk/docs/UsingLibcxx.rst
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/docs/UsingLibcxx.rst?rev=315234=315233=315234=diff
==
--- libcxx/trunk/docs/UsingLibcxx.rst (original)
+++ libcxx/trunk/docs/UsingLibcxx.rst Mon Oct  9 12:25:17 2017
@@ -185,6 +185,26 @@ thread safety annotations.
 * Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
   const callable.
 
+**_LIBCPP_NO_VCRUNTIME**:
+  Microsoft's C and C++ headers are fairly entangled, and some of their C++
+  headers are fairly hard to avoid. In particular, `vcruntime_new.h` gets 
pulled
+  in from a lot of other headers and provides definitions which clash with
+  libc++ headers, such as `nothrow_t` (note that `nothrow_t` is a struct, so
+  there's no way for libc++ to provide a compatible definition, since you can't
+  have multiple definitions).
+
+  By default, libc++ solves this problem by deferring to Microsoft's vcruntime
+  headers where needed. However, it may be undesirable to depend on vcruntime
+  headers, since they may not always be available in cross-compilation setups,
+  or they may clash with other headers. The `_LIBCPP_NO_VCRUNTIME` macro
+  prevents libc++ from depending on vcruntime headers. Consequently, it also
+  prevents libc++ headers from being interoperable with vcruntime headers (from
+  the aforementioned clashes), so users of this macro are promising to not
+  attempt to combine libc++ headers with the problematic vcruntime headers. 
This
+  macro also currently prevents certain `operator new`/`operator delete`
+  replacement scenarios from working, e.g. replacing `operator new` and
+  expecting a non-replaced `operator new[]` to call the replaced `operator 
new`.
+
 C++17 Specific Configuration Macros
 ---
 **_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:

Modified: libcxx/trunk/include/__config_site.in
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/__config_site.in?rev=315234=315233=315234=diff
==
--- libcxx/trunk/include/__config_site.in (original)
+++ libcxx/trunk/include/__config_site.in Mon Oct  9 12:25:17 2017
@@ -25,6 +25,7 @@
 #cmakedefine _LIBCPP_HAS_THREAD_API_EXTERNAL
 #cmakedefine _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL
 #cmakedefine _LIBCPP_DISABLE_VISIBILITY_ANNOTATIONS
+#cmakedefine _LIBCPP_NO_VCRUNTIME
 
 @_LIBCPP_ABI_DEFINES@
 

Modified: libcxx/trunk/include/exception
URL: 
http://llvm.org/viewvc/llvm-project/libcxx/trunk/include/exception?rev=315234=315233=315234=diff
==
--- 

[PATCH] D38522: [libc++] Support Microsoft ABI without vcruntime headers

2017-10-09 Thread Shoaib Meenai via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315234: [libc++] Support Microsoft ABI without vcruntime 
headers (authored by smeenai).

Changed prior to commit:
  https://reviews.llvm.org/D38522?vs=117613=118251#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D38522

Files:
  libcxx/trunk/CMakeLists.txt
  libcxx/trunk/docs/UsingLibcxx.rst
  libcxx/trunk/include/__config_site.in
  libcxx/trunk/include/exception
  libcxx/trunk/include/new
  libcxx/trunk/src/new.cpp
  libcxx/trunk/src/support/runtime/exception_msvc.ipp
  libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_nothrow_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.array/new_array_replace.pass.cpp
  
libcxx/trunk/test/std/language.support/support.dynamic/new.delete/new.delete.single/new_nothrow_replace.pass.cpp
  libcxx/trunk/utils/libcxx/test/config.py

Index: libcxx/trunk/CMakeLists.txt
===
--- libcxx/trunk/CMakeLists.txt
+++ libcxx/trunk/CMakeLists.txt
@@ -615,6 +615,7 @@
 config_define_if(LIBCXX_HAS_EXTERNAL_THREAD_API _LIBCPP_HAS_THREAD_API_EXTERNAL)
 config_define_if(LIBCXX_BUILD_EXTERNAL_THREAD_LIBRARY _LIBCPP_HAS_THREAD_LIBRARY_EXTERNAL)
 config_define_if(LIBCXX_HAS_MUSL_LIBC _LIBCPP_HAS_MUSL_LIBC)
+config_define_if(LIBCXX_NO_VCRUNTIME _LIBCPP_NO_VCRUNTIME)
 
 if (LIBCXX_ABI_DEFINES)
   set(abi_defines)
Index: libcxx/trunk/utils/libcxx/test/config.py
===
--- libcxx/trunk/utils/libcxx/test/config.py
+++ libcxx/trunk/utils/libcxx/test/config.py
@@ -668,6 +668,9 @@
 self.config.available_features.add('libcpp-abi-version-v%s'
 % feature_macros[m])
 continue
+if m == '_LIBCPP_NO_VCRUNTIME':
+self.config.available_features.add('libcpp-no-vcruntime')
+continue
 assert m.startswith('_LIBCPP_HAS_') or m.startswith('_LIBCPP_ABI_')
 m = m.lower()[1:].replace('_', '-')
 self.config.available_features.add(m)
Index: libcxx/trunk/docs/UsingLibcxx.rst
===
--- libcxx/trunk/docs/UsingLibcxx.rst
+++ libcxx/trunk/docs/UsingLibcxx.rst
@@ -185,6 +185,26 @@
 * Giving `set`, `map`, `multiset`, `multimap` a comparator which is not
   const callable.
 
+**_LIBCPP_NO_VCRUNTIME**:
+  Microsoft's C and C++ headers are fairly entangled, and some of their C++
+  headers are fairly hard to avoid. In particular, `vcruntime_new.h` gets pulled
+  in from a lot of other headers and provides definitions which clash with
+  libc++ headers, such as `nothrow_t` (note that `nothrow_t` is a struct, so
+  there's no way for libc++ to provide a compatible definition, since you can't
+  have multiple definitions).
+
+  By default, libc++ solves this problem by deferring to Microsoft's vcruntime
+  headers where needed. However, it may be undesirable to depend on vcruntime
+  headers, since they may not always be available in cross-compilation setups,
+  or they may clash with other headers. The `_LIBCPP_NO_VCRUNTIME` macro
+  prevents libc++ from depending on vcruntime headers. Consequently, it also
+  prevents libc++ headers from being interoperable with vcruntime headers (from
+  the aforementioned clashes), so users of this macro are promising to not
+  attempt to combine libc++ headers with the problematic vcruntime headers. This
+  macro also currently prevents certain `operator new`/`operator delete`
+  replacement scenarios from working, e.g. replacing `operator new` and
+  expecting a non-replaced `operator new[]` to call the replaced `operator new`.
+
 C++17 Specific Configuration Macros
 ---
 **_LIBCPP_ENABLE_CXX17_REMOVED_FEATURES**:
Index: libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
===
--- libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
+++ libcxx/trunk/src/support/runtime/exception_pointer_msvc.ipp
@@ -10,26 +10,32 @@
 
 #include 
 #include 
-#include  // for _CRTIMP2_PURE
 
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(_Out_ void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(_Inout_ void*);
-_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCopy(_Out_ void*,
-  _In_ const void*);
+#if !defined(_CRTIMP2_PURE)
+#define _CRTIMP2_PURE __declspec(dllimport)
+#endif
+
+#if !defined(__CLRCALL_PURE_OR_CDECL)
+#define __CLRCALL_PURE_OR_CDECL __cdecl
+#endif
+
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrCreate(void*);
+_CRTIMP2_PURE void __CLRCALL_PURE_OR_CDECL __ExceptionPtrDestroy(void*);
+_CRTIMP2_PURE 

[PATCH] D38522: [libc++] Support Microsoft ABI without vcruntime headers

2017-10-09 Thread Shoaib Meenai via Phabricator via cfe-commits
smeenai accepted this revision.
smeenai added a comment.
This revision is now accepted and ready to land.

I spoke to @EricWF on IRC last week and got his approval to commit this without 
review if no one had gotten to it in a couple of days, so I'm going ahead with 
that.


https://reviews.llvm.org/D38522



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Jonathan Roelofs via Phabricator via cfe-commits
jroelofs added inline comments.



Comment at: src/AddressSpace.hpp:521
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;

Would it work to implement the win32 side of this via `SymFromAddr`?



Comment at: src/UnwindRegistersRestore.S:29
 #  +   +
+#if !defined(_WIN32)
   movl   4(%esp), %eax

Please invert the condition, and swap the if/else on this. That will make it 
more straightforward to adjust this for other platforms later.


https://reviews.llvm.org/D38679



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: src/AddressSpace.hpp:388-389
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;

rnk wrote:
> ".eh_frame" is 9 characters, right? I thought mingw linkers took sections 
> with long names and moved them to an extended symbol table. Does that not 
> apply to .eh_frame?
Yes, they do, so this actually only matches `.eh_fram`. I didn't yet look at 
how to navigate the IMAGE_*_HEADERS structs to find the coresponding full long 
name.


https://reviews.llvm.org/D38679



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


r315231 - Testing commit access.

2017-10-09 Thread Hamza Sood via cfe-commits
Author: hamzasood
Date: Mon Oct  9 12:07:09 2017
New Revision: 315231

URL: http://llvm.org/viewvc/llvm-project?rev=315231=rev
Log:
Testing commit access.

Modified:
cfe/trunk/lib/Driver/Compilation.cpp

Modified: cfe/trunk/lib/Driver/Compilation.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/Compilation.cpp?rev=315231=315230=315231=diff
==
--- cfe/trunk/lib/Driver/Compilation.cpp (original)
+++ cfe/trunk/lib/Driver/Compilation.cpp Mon Oct  9 12:07:09 2017
@@ -28,7 +28,7 @@ Compilation::Compilation(const Driver 
 : TheDriver(D), DefaultToolChain(_DefaultToolChain), ActiveOffloadMask(0u),
   Args(_Args), TranslatedArgs(_TranslatedArgs), ForDiagnostics(false),
   ContainsError(ContainsError) {
-  // The offloading host toolchain is the default tool chain.
+  // The offloading host toolchain is the default toolchain.
   OrderedOffloadingToolchains.insert(
   std::make_pair(Action::OFK_Host, ));
 }


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


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple updated this revision to Diff 118247.
jkorous-apple added a comment.

Single char constants don't need to be c-strings.


https://reviews.llvm.org/D38643

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/array-type.cpp


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | __Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | __Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | __Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << '{';
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << 's';
+break;
+  case ArrayType::Star:
+Out << '*';
+break;
+  case ArrayType::Normal:
+Out << 'n';
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38646: [MS] Raise the default value of _MSC_VER to 1910, which is in VS 2017

2017-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added a comment.

In https://reviews.llvm.org/D38646#892246, @STL_MSFT wrote:

> FYI: 1910 was the value for VS 2017 RTM. 1911 is the value for VS 2017 15.3, 
> the first toolset update. 1912 will be the value for VS 2017 15.5, the second 
> toolset update.


Yep. The initial draft of this patch had the wrong commit message, but 
everything is fixed in the committed version.

I had 1910 installed on my machine locally, and spent this morning untangling 
that. Apparently now you have to install updates through the VS "Tools -> 
Extesions & Updates -> mumble" menu. Downloading and running the VS update 3 
installer isn't enough.


Repository:
  rL LLVM

https://reviews.llvm.org/D38646



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


Re: [clang-tools-extra] r315214 - [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Bruno Cardoso Lopes via cfe-commits
Hi,

On Mon, Oct 9, 2017 at 9:58 AM, Ilya Biryukov via cfe-commits
 wrote:
> Author: ibiryukov
> Date: Mon Oct  9 09:58:16 2017
> New Revision: 315214
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315214=rev
> Log:
> [clangd] Added a command-line arg to mirror clangd input into a file.
>
> Summary: The arg is useful for debugging and creating test cases.
>
> Reviewers: bkramer, krasimir
>
> Reviewed By: bkramer
>
> Subscribers: klimek, cfe-commits
>
> Differential Revision: https://reviews.llvm.org/D37970
>
> Added:
> clang-tools-extra/trunk/test/clangd/input-mirror.test
> Modified:
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315214=315213=315214=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 09:58:16 
> 2017
> @@ -37,6 +37,14 @@ void JSONOutput::log(const Twine 
>Logs.flush();
>  }
>
> +void JSONOutput::mirrorInput(const Twine ) {
> +  if (!InputMirror)
> +return;
> +
> +  *InputMirror << Message;
> +  InputMirror->flush();
> +}
> +
>  void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
>Output.log("Method ignored.\n");
>// Return that this method is unsupported.
> @@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
>  continue;
>}
>
> +  Out.mirrorInput(Line);
> +  // Mirror '\n' that gets consumed by std::getline, but is not included 
> in
> +  // the resulting Line.
> +  // Note that '\r' is part of Line, so we don't need to mirror it
> +  // separately.
> +  if (!In.eof())
> +Out.mirrorInput("\n");
> +
>llvm::StringRef LineRef(Line);
>
>// We allow YAML-style comments in headers. Technically this isn't part
> @@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
>if (LineRef.consume_front("Content-Length: ")) {
>  if (ContentLength != 0) {
>Out.log("Warning: Duplicate Content-Length header received. "
> -  "The previous value for this message ("
> -  + std::to_string(ContentLength)
> -  + ") was ignored.\n");
> +  "The previous value for this message (" +
> +  std::to_string(ContentLength) + ") was ignored.\n");
>  }
>
>  llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
> @@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
>// parser.
>std::vector JSON(ContentLength + 1, '\0');
>In.read(JSON.data(), ContentLength);
> +  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
>
>// If the stream is aborted before we read ContentLength bytes, In
>// will have eofbit and failbit set.
>if (!In) {
> -Out.log("Input was aborted. Read only "
> -+ std::to_string(In.gcount())
> -+ " bytes of expected "
> -+ std::to_string(ContentLength)
> -+ ".\n");
> +Out.log("Input was aborted. Read only " + 
> std::to_string(In.gcount()) +
> +" bytes of expected " + std::to_string(ContentLength) + 
> ".\n");
>  break;
>}
>
> @@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
>if (IsDone)
>  break;
>  } else {
> -  Out.log( "Warning: Missing Content-Length header, or message has zero "
> -   "length.\n" );
> +  Out.log("Warning: Missing Content-Length header, or message has zero "
> +  "length.\n");
>  }
>}
>  }
>
> Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
> URL: 
> http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315214=315213=315214=diff
> ==
> --- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
> +++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 09:58:16 
> 2017
> @@ -24,8 +24,9 @@ namespace clangd {
>  /// them.
>  class JSONOutput : public Logger {
>  public:
> -  JSONOutput(llvm::raw_ostream , llvm::raw_ostream )
> -  : Outs(Outs), Logs(Logs) {}
> +  JSONOutput(llvm::raw_ostream , llvm::raw_ostream ,
> + llvm::raw_ostream *InputMirror = nullptr)
> +  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
>
>/// Emit a JSONRPC message.
>void writeMessage(const Twine );
> @@ -33,9 +34,15 @@ public:
>/// Write to the logging stream.
>void log(const Twine ) override;
>
> +  /// Mirror \p Message into InputMirror stream. Does 

[libclc] r315228 - Make ptx barrier work irrespective of the cl_mem_fence_flags

2017-10-09 Thread Jeroen Ketema via cfe-commits
Author: jketema
Date: Mon Oct  9 11:36:48 2017
New Revision: 315228

URL: http://llvm.org/viewvc/llvm-project?rev=315228=rev
Log:
Make ptx barrier work irrespective of the cl_mem_fence_flags

This generates a "bar.sync 0” instruction, which not only causes the
threads to wait, but does acts as a memory fence, as required by
OpenCL. The fence does not differentiate between local and global
memory. Unfortunately, there is no similar instruction which does
not include a memory fence. Hence, we cannot optimize the case
where neither CLK_LOCAL_MEM_FENCE nor CLK_GLOBAL_MEM_FENCE is
passed.

Modified:
libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl

Modified: libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl
URL: 
http://llvm.org/viewvc/llvm-project/libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl?rev=315228=315227=315228=diff
==
--- libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl (original)
+++ libclc/trunk/ptx-nvidiacl/lib/synchronization/barrier.cl Mon Oct  9 
11:36:48 2017
@@ -1,8 +1,6 @@
 #include 
 
 _CLC_DEF void barrier(cl_mem_fence_flags flags) {
-  if (flags & CLK_LOCAL_MEM_FENCE) {
-__syncthreads();
-  }
+  __syncthreads();
 }
 


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


[PATCH] D38700: [Sema][Crash] Correctly handle an non-dependent noexcept expr in function template

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

It seems that all of the other templated cases are handled correctly,
however the function template case was not correctly handled.  This
patch recovers from this condition by setting the function to noexcept
after diagnosing.  Previously it simply set NoexceptExpr to null,
which caused an Assert when this was evaluated during substitution.


https://reviews.llvm.org/D38700

Files:
  lib/Sema/SemaDeclCXX.cpp
  test/CXX/except/except.spec/p1.cpp


Index: test/CXX/except/except.spec/p1.cpp
===
--- test/CXX/except/except.spec/p1.cpp
+++ test/CXX/except/except.spec/p1.cpp
@@ -86,3 +86,12 @@
 f<0>(); // expected-note{{in instantiation of function template 
specialization}}
   }
 }
+
+namespace FuncTmplNoexceptError {
+  int a = 0;
+  // expected-error@+1{{argument to noexcept specifier must be a constant 
expression}}
+  template  T f() noexcept(a++){ return {};}
+  void g(){
+f();
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -14858,10 +14858,16 @@
 return;
   }
 
-  if (!NoexceptExpr->isValueDependent())
-NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr,
- diag::err_noexcept_needs_constant_expression,
- /*AllowFold*/ false).get();
+  if (!NoexceptExpr->isValueDependent()) {
+ExprResult Result = VerifyIntegerConstantExpression(
+NoexceptExpr, nullptr, 
diag::err_noexcept_needs_constant_expression,
+/*AllowFold*/ false);
+if (Result.isInvalid()) {
+  ESI.Type = EST_BasicNoexcept;
+  return;
+}
+NoexceptExpr = Result.get();
+  }
   ESI.NoexceptExpr = NoexceptExpr;
 }
 return;


Index: test/CXX/except/except.spec/p1.cpp
===
--- test/CXX/except/except.spec/p1.cpp
+++ test/CXX/except/except.spec/p1.cpp
@@ -86,3 +86,12 @@
 f<0>(); // expected-note{{in instantiation of function template specialization}}
   }
 }
+
+namespace FuncTmplNoexceptError {
+  int a = 0;
+  // expected-error@+1{{argument to noexcept specifier must be a constant expression}}
+  template  T f() noexcept(a++){ return {};}
+  void g(){
+f();
+  }
+};
Index: lib/Sema/SemaDeclCXX.cpp
===
--- lib/Sema/SemaDeclCXX.cpp
+++ lib/Sema/SemaDeclCXX.cpp
@@ -14858,10 +14858,16 @@
 return;
   }
 
-  if (!NoexceptExpr->isValueDependent())
-NoexceptExpr = VerifyIntegerConstantExpression(NoexceptExpr, nullptr,
- diag::err_noexcept_needs_constant_expression,
- /*AllowFold*/ false).get();
+  if (!NoexceptExpr->isValueDependent()) {
+ExprResult Result = VerifyIntegerConstantExpression(
+NoexceptExpr, nullptr, diag::err_noexcept_needs_constant_expression,
+/*AllowFold*/ false);
+if (Result.isInvalid()) {
+  ESI.Type = EST_BasicNoexcept;
+  return;
+}
+NoexceptExpr = Result.get();
+  }
   ESI.NoexceptExpr = NoexceptExpr;
 }
 return;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38698: AMDGPU: Add read_exec_lo/hi builtins

2017-10-09 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
Herald added subscribers: t-tye, tpr, dstuttard, nhaehnle, wdng, kzhuravl.

https://reviews.llvm.org/D38698

Files:
  include/clang/Basic/BuiltinsAMDGPU.def
  lib/CodeGen/CGBuiltin.cpp
  test/CodeGenOpenCL/builtins-amdgcn.cl


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -421,6 +421,18 @@
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_read_exec_lo(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_LO:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_lo(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_lo();
+}
+
+// CHECK-LABEL: @test_read_exec_hi(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_HI:[0-9]+]]) 
#[[READ_EXEC_ATTRS]]
+void test_read_exec_hi(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_hi();
+}
+
 // CHECK-LABEL: @test_dispatch_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
 void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
@@ -499,3 +511,5 @@
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[EXEC]] = !{!"exec"}
+// CHECK-DAG: ![[EXEC_LO]] = !{!"exec_lo"}
+// CHECK-DAG: ![[EXEC_HI]] = !{!"exec_hi"}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9103,6 +9103,15 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
+StringRef RegName = BuiltinID == AMDGPU::BI__builtin_amdgcn_read_exec_lo ?
+  "exec_lo" : "exec_hi";
+CallInst *CI = cast(
+  EmitSpecialRegisterBuiltin(*this, E, Int32Ty, Int32Ty, true, RegName));
+CI->setConvergent();
+return CI;
+  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -121,6 +121,8 @@
 // Special builtins.
 
//===--===//
 BUILTIN(__builtin_amdgcn_read_exec, "LUi", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_lo, "Ui", "nc")
+BUILTIN(__builtin_amdgcn_read_exec_hi, "Ui", "nc")
 
 
//===--===//
 // R600-NI only builtins.


Index: test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- test/CodeGenOpenCL/builtins-amdgcn.cl
+++ test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -421,6 +421,18 @@
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) #[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_read_exec_lo(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_LO:[0-9]+]]) #[[READ_EXEC_ATTRS]]
+void test_read_exec_lo(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_lo();
+}
+
+// CHECK-LABEL: @test_read_exec_hi(
+// CHECK: call i32 @llvm.read_register.i32(metadata ![[EXEC_HI:[0-9]+]]) #[[READ_EXEC_ATTRS]]
+void test_read_exec_hi(global uint* out) {
+  *out = __builtin_amdgcn_read_exec_hi();
+}
+
 // CHECK-LABEL: @test_dispatch_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
 void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
@@ -499,3 +511,5 @@
 // CHECK-DAG: attributes #[[NOUNWIND_READONLY:[0-9]+]] = { nounwind readonly }
 // CHECK-DAG: attributes #[[READ_EXEC_ATTRS]] = { convergent }
 // CHECK-DAG: ![[EXEC]] = !{!"exec"}
+// CHECK-DAG: ![[EXEC_LO]] = !{!"exec_lo"}
+// CHECK-DAG: ![[EXEC_HI]] = !{!"exec_hi"}
Index: lib/CodeGen/CGBuiltin.cpp
===
--- lib/CodeGen/CGBuiltin.cpp
+++ lib/CodeGen/CGBuiltin.cpp
@@ -9103,6 +9103,15 @@
 CI->setConvergent();
 return CI;
   }
+  case AMDGPU::BI__builtin_amdgcn_read_exec_lo:
+  case AMDGPU::BI__builtin_amdgcn_read_exec_hi: {
+StringRef RegName = BuiltinID == AMDGPU::BI__builtin_amdgcn_read_exec_lo ?
+  "exec_lo" : "exec_hi";
+CallInst *CI = cast(
+  EmitSpecialRegisterBuiltin(*this, E, Int32Ty, Int32Ty, true, RegName));
+CI->setConvergent();
+return CI;
+  }
 
   // amdgcn workitem
   case AMDGPU::BI__builtin_amdgcn_workitem_id_x:
Index: include/clang/Basic/BuiltinsAMDGPU.def
===
--- include/clang/Basic/BuiltinsAMDGPU.def
+++ include/clang/Basic/BuiltinsAMDGPU.def
@@ -121,6 +121,8 @@
 // Special builtins.
 //===--===//
 BUILTIN(__builtin_amdgcn_read_exec, 

Re: r315194 - Make SourceLocation, QualType and friends have constexpr constructors.

2017-10-09 Thread Benjamin Kramer via cfe-commits
Looks like a bug in the compiler, the warning doesn't make any sense.
Does creating a FileID() variable and passing that instead work?

On Mon, Oct 9, 2017 at 8:02 PM, Galina Kistanova  wrote:
> Hello Benjamin,
>
> I look s like this commit broke build on one of our builders:
>
> http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/5327
>
> . . .
> FAILED:
> tools/clang/lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.obj
> C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  /nologo /TP -DEXPENSIVE_CHECKS
> -DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
> -D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
> -D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE -D_HAS_EXCEPTIONS=0
> -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS -D_UNICODE
> -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS
> -Itools\clang\lib\Serialization
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include
> -Itools\clang\include -Iinclude
> -IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include
> /DWIN32 /D_WINDOWS   /WX /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast /W4
> -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351
> -wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
> -wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706
> -wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091
> -wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1/EHs-c-
> /GR- /showIncludes
> /Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
> /Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\clangSerialization.pdb
> /FS -c
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
> error C2220: warning treated as error - no 'object' file generated
> C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
> warning C4709: comma operator within array index expression
>
> Please have a look?
>
> Thanks
>
> Galina
>
> On Sun, Oct 8, 2017 at 1:53 PM, Benjamin Kramer via cfe-commits
>  wrote:
>>
>> Author: d0k
>> Date: Sun Oct  8 13:53:36 2017
>> New Revision: 315194
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=315194=rev
>> Log:
>> Make SourceLocation, QualType and friends have constexpr constructors.
>>
>> No functionality change intended.
>>
>> Modified:
>> cfe/trunk/include/clang/AST/CharUnits.h
>> cfe/trunk/include/clang/AST/Type.h
>> cfe/trunk/include/clang/Basic/SourceLocation.h
>>
>> Modified: cfe/trunk/include/clang/AST/CharUnits.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/CharUnits.h?rev=315194=315193=315194=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/CharUnits.h (original)
>> +++ cfe/trunk/include/clang/AST/CharUnits.h Sun Oct  8 13:53:36 2017
>> @@ -40,14 +40,14 @@ namespace clang {
>>typedef int64_t QuantityType;
>>
>>  private:
>> -  QuantityType Quantity;
>> +  QuantityType Quantity = 0;
>>
>>explicit CharUnits(QuantityType C) : Quantity(C) {}
>>
>>  public:
>>
>>/// CharUnits - A default constructor.
>> -  CharUnits() : Quantity(0) {}
>> +  CharUnits() = default;
>>
>>/// Zero - Construct a CharUnits quantity of zero.
>>static CharUnits Zero() {
>>
>> Modified: cfe/trunk/include/clang/AST/Type.h
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Type.h?rev=315194=315193=315194=diff
>>
>> ==
>> --- cfe/trunk/include/clang/AST/Type.h (original)
>> +++ cfe/trunk/include/clang/AST/Type.h Sun Oct  8 13:53:36 2017
>> @@ -162,8 +162,6 @@ public:
>>  FastMask = (1 << FastWidth) - 1
>>};
>>
>> -  Qualifiers() : Mask(0) {}
>> -
>>/// Returns the common set of qualifiers while removing them from
>>/// the given sets.
>>static Qualifiers removeCommonQualifiers(Qualifiers , Qualifiers )
>> {
>> @@ -539,7 +537,7 @@ private:
>>
>>// bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
>>//   |C R V|U|GCAttr|Lifetime|AddressSpace|
>> -  uint32_t Mask;
>> +  uint32_t Mask = 0;
>>
>>static const uint32_t UMask = 0x8;
>>static const uint32_t UShift = 3;
>> @@ -634,7 +632,7 @@ class QualType {
>>
>>friend class QualifierCollector;
>>  public:
>> -  QualType() {}
>> +  QualType() = default;
>>
>>QualType(const Type *Ptr, unsigned Quals)
>>  : Value(Ptr, Quals) {}
>>
>> Modified: 

[PATCH] D38646: [MS] Raise the default value of _MSC_VER to 1910, which is in VS 2017

2017-10-09 Thread Stephan T. Lavavej via Phabricator via cfe-commits
STL_MSFT added a comment.

FYI: 1910 was the value for VS 2017 RTM. 1911 is the value for VS 2017 15.3, 
the first toolset update. 1912 will be the value for VS 2017 15.5, the second 
toolset update.


Repository:
  rL LLVM

https://reviews.llvm.org/D38646



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


[PATCH] D38126: Make TBAA information to be part of LValueBaseInfo

2017-10-09 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev added a comment.

Please take a look at https://reviews.llvm.org/D38695, if you want this by 
smaller pieces. Thanks.


https://reviews.llvm.org/D38126



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


[PATCH] D38695: [CodeGen] Do not construct complete LValue base info in trivial cases

2017-10-09 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev created this revision.
kosarev added a project: clang.

Besides obvious code simplification, avoiding explicit creation of 
LValueBaseInfo objects makes it easier to make TBAA information to be part of 
such objects.

This is part of https://reviews.llvm.org/D38126 reworked to be a separate patch 
to simplify review.


Repository:
  rL LLVM

https://reviews.llvm.org/D38695

Files:
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CodeGenFunction.h

Index: lib/CodeGen/CodeGenFunction.h
===
--- lib/CodeGen/CodeGenFunction.h
+++ lib/CodeGen/CodeGenFunction.h
@@ -1911,15 +1911,26 @@
   //======//
 
   LValue MakeAddrLValue(Address Addr, QualType T,
-LValueBaseInfo BaseInfo =
-LValueBaseInfo(AlignmentSource::Type)) {
+AlignmentSource Source = AlignmentSource::Type) {
+return LValue::MakeAddr(Addr, T, getContext(),
+LValueBaseInfo(Source, false),
+CGM.getTBAAAccessInfo(T));
+  }
+
+  LValue MakeAddrLValue(Address Addr, QualType T, LValueBaseInfo BaseInfo) {
 return LValue::MakeAddr(Addr, T, getContext(), BaseInfo,
 CGM.getTBAAAccessInfo(T));
   }
 
   LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
-LValueBaseInfo BaseInfo =
-LValueBaseInfo(AlignmentSource::Type)) {
+AlignmentSource Source = AlignmentSource::Type) {
+return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
+LValueBaseInfo(Source, false),
+CGM.getTBAAAccessInfo(T));
+  }
+
+  LValue MakeAddrLValue(llvm::Value *V, QualType T, CharUnits Alignment,
+LValueBaseInfo BaseInfo) {
 return LValue::MakeAddr(Address(V, Alignment), T, getContext(),
 BaseInfo, CGM.getTBAAAccessInfo(T));
   }
@@ -3058,8 +3069,15 @@
   /// the LLVM value representation.
   llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
 SourceLocation Loc,
-LValueBaseInfo BaseInfo =
-LValueBaseInfo(AlignmentSource::Type),
+AlignmentSource Source = AlignmentSource::Type,
+bool isNontemporal = false) {
+return EmitLoadOfScalar(Addr, Volatile, Ty, Loc,
+LValueBaseInfo(Source, false),
+CGM.getTBAAAccessInfo(Ty), isNontemporal);
+  }
+
+  llvm::Value *EmitLoadOfScalar(Address Addr, bool Volatile, QualType Ty,
+SourceLocation Loc, LValueBaseInfo BaseInfo,
 bool isNontemporal = false) {
 return EmitLoadOfScalar(Addr, Volatile, Ty, Loc, BaseInfo,
 CGM.getTBAAAccessInfo(Ty), isNontemporal);
@@ -3081,8 +3099,14 @@
   /// the LLVM value representation.
   void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
  bool Volatile, QualType Ty,
- LValueBaseInfo BaseInfo =
- LValueBaseInfo(AlignmentSource::Type),
+ AlignmentSource Source = AlignmentSource::Type,
+ bool isInit = false, bool isNontemporal = false) {
+EmitStoreOfScalar(Value, Addr, Volatile, Ty, LValueBaseInfo(Source, false),
+  CGM.getTBAAAccessInfo(Ty), isInit, isNontemporal);
+  }
+
+  void EmitStoreOfScalar(llvm::Value *Value, Address Addr,
+ bool Volatile, QualType Ty, LValueBaseInfo BaseInfo,
  bool isInit = false, bool isNontemporal = false) {
 EmitStoreOfScalar(Value, Addr, Volatile, Ty, BaseInfo,
   CGM.getTBAAAccessInfo(Ty), isInit, isNontemporal);
Index: lib/CodeGen/CGStmtOpenMP.cpp
===
--- lib/CodeGen/CGStmtOpenMP.cpp
+++ lib/CodeGen/CGStmtOpenMP.cpp
@@ -392,15 +392,14 @@
   continue;
 }
 
-LValueBaseInfo BaseInfo(AlignmentSource::Decl, false);
-LValue ArgLVal =
-CGF.MakeAddrLValue(LocalAddr, Args[Cnt]->getType(), BaseInfo);
+LValue ArgLVal = CGF.MakeAddrLValue(LocalAddr, Args[Cnt]->getType(),
+AlignmentSource::Decl);
 if (FD->hasCapturedVLAType()) {
   if (FO.UIntPtrCastRequired) {
 ArgLVal = CGF.MakeAddrLValue(castValueFromUintptr(CGF, FD->getType(),
   Args[Cnt]->getName(),
   ArgLVal),
-   

Re: r315194 - Make SourceLocation, QualType and friends have constexpr constructors.

2017-10-09 Thread Galina Kistanova via cfe-commits
Hello Benjamin,

I look s like this commit broke build on one of our builders:

http://lab.llvm.org:8011/builders/llvm-clang-x86_64-expensive-checks-win/builds/5327

. . .
FAILED:
tools/clang/lib/Serialization/CMakeFiles/clangSerialization.dir/ASTReader.cpp.obj

C:\PROGRA~2\MICROS~1.0\VC\bin\amd64\cl.exe  /nologo /TP -DEXPENSIVE_CHECKS
-DGTEST_HAS_RTTI=0 -DUNICODE -D_CRT_NONSTDC_NO_DEPRECATE
-D_CRT_NONSTDC_NO_WARNINGS -D_CRT_SECURE_NO_DEPRECATE
-D_CRT_SECURE_NO_WARNINGS -D_GLIBCXX_DEBUG -D_GNU_SOURCE
-D_HAS_EXCEPTIONS=0 -D_SCL_SECURE_NO_DEPRECATE -D_SCL_SECURE_NO_WARNINGS
-D_UNICODE -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS
-D__STDC_LIMIT_MACROS -Itools\clang\lib\Serialization
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\include
-Itools\clang\include -Iinclude
-IC:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\include
/DWIN32 /D_WINDOWS   /WX /Zc:inline /Zc:strictStrings /Oi /Zc:rvalueCast
/W4 -wd4141 -wd4146 -wd4180 -wd4244 -wd4258 -wd4267 -wd4291 -wd4345 -wd4351
-wd4355 -wd4456 -wd4457 -wd4458 -wd4459 -wd4503 -wd4624 -wd4722 -wd4800
-wd4100 -wd4127 -wd4512 -wd4505 -wd4610 -wd4510 -wd4702 -wd4245 -wd4706
-wd4310 -wd4701 -wd4703 -wd4389 -wd4611 -wd4805 -wd4204 -wd4577 -wd4091
-wd4592 -wd4319 -wd4324 -w14062 -we4238 /MDd /Zi /Ob0 /Od /RTC1/EHs-c-
/GR- /showIncludes
/Fotools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\ASTReader.cpp.obj
/Fdtools\clang\lib\Serialization\CMakeFiles\clangSerialization.dir\clangSerialization.pdb
/FS -c
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
error C2220: warning treated as error - no 'object' file generated
C:\ps4-buildslave2\llvm-clang-x86_64-expensive-checks-win\llvm\tools\clang\lib\Serialization\ASTReader.cpp(5731):
warning C4709: comma operator within array index expression

Please have a look?

Thanks

Galina

On Sun, Oct 8, 2017 at 1:53 PM, Benjamin Kramer via cfe-commits <
cfe-commits@lists.llvm.org> wrote:

> Author: d0k
> Date: Sun Oct  8 13:53:36 2017
> New Revision: 315194
>
> URL: http://llvm.org/viewvc/llvm-project?rev=315194=rev
> Log:
> Make SourceLocation, QualType and friends have constexpr constructors.
>
> No functionality change intended.
>
> Modified:
> cfe/trunk/include/clang/AST/CharUnits.h
> cfe/trunk/include/clang/AST/Type.h
> cfe/trunk/include/clang/Basic/SourceLocation.h
>
> Modified: cfe/trunk/include/clang/AST/CharUnits.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/CharUnits.h?rev=315194=315193=315194=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/CharUnits.h (original)
> +++ cfe/trunk/include/clang/AST/CharUnits.h Sun Oct  8 13:53:36 2017
> @@ -40,14 +40,14 @@ namespace clang {
>typedef int64_t QuantityType;
>
>  private:
> -  QuantityType Quantity;
> +  QuantityType Quantity = 0;
>
>explicit CharUnits(QuantityType C) : Quantity(C) {}
>
>  public:
>
>/// CharUnits - A default constructor.
> -  CharUnits() : Quantity(0) {}
> +  CharUnits() = default;
>
>/// Zero - Construct a CharUnits quantity of zero.
>static CharUnits Zero() {
>
> Modified: cfe/trunk/include/clang/AST/Type.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/AST/Type.h?rev=315194=315193=315194=diff
> 
> ==
> --- cfe/trunk/include/clang/AST/Type.h (original)
> +++ cfe/trunk/include/clang/AST/Type.h Sun Oct  8 13:53:36 2017
> @@ -162,8 +162,6 @@ public:
>  FastMask = (1 << FastWidth) - 1
>};
>
> -  Qualifiers() : Mask(0) {}
> -
>/// Returns the common set of qualifiers while removing them from
>/// the given sets.
>static Qualifiers removeCommonQualifiers(Qualifiers , Qualifiers )
> {
> @@ -539,7 +537,7 @@ private:
>
>// bits: |0 1 2|3|4 .. 5|6  ..  8|9   ...   31|
>//   |C R V|U|GCAttr|Lifetime|AddressSpace|
> -  uint32_t Mask;
> +  uint32_t Mask = 0;
>
>static const uint32_t UMask = 0x8;
>static const uint32_t UShift = 3;
> @@ -634,7 +632,7 @@ class QualType {
>
>friend class QualifierCollector;
>  public:
> -  QualType() {}
> +  QualType() = default;
>
>QualType(const Type *Ptr, unsigned Quals)
>  : Value(Ptr, Quals) {}
>
> Modified: cfe/trunk/include/clang/Basic/SourceLocation.h
> URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/
> clang/Basic/SourceLocation.h?rev=315194=315193=315194=diff
> 
> ==
> --- cfe/trunk/include/clang/Basic/SourceLocation.h (original)
> +++ cfe/trunk/include/clang/Basic/SourceLocation.h Sun Oct  8 

[PATCH] D38656: [CGExprScalar] In EmitCompare trunc the result if it has different type as E->getType()

2017-10-09 Thread Guozhi Wei via Phabricator via cfe-commits
Carrot updated this revision to Diff 118236.
Carrot marked 3 inline comments as done.

https://reviews.llvm.org/D38656

Files:
  lib/CodeGen/CGExprScalar.cpp
  test/CodeGen/ppc-vector-compare.cc


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown 
-emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, 
E->getType(),
   E->getExprLoc());
 }


Index: test/CodeGen/ppc-vector-compare.cc
===
--- test/CodeGen/ppc-vector-compare.cc
+++ test/CodeGen/ppc-vector-compare.cc
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -target-feature +altivec -triple powerpc64-unknown-unknown -emit-llvm %s \
+// RUN:-o - | FileCheck %s
+
+#include 
+
+// CHECK-LABEL: @_Z5test1Dv8_tS_
+// CHECK: @llvm.ppc.altivec.vcmpequh.p
+bool test1(vector unsigned short v1, vector unsigned short v2) {
+  return v1 == v2;
+}
+
Index: lib/CodeGen/CGExprScalar.cpp
===
--- lib/CodeGen/CGExprScalar.cpp
+++ lib/CodeGen/CGExprScalar.cpp
@@ -3214,6 +3214,16 @@
   Value *CR6Param = Builder.getInt32(CR6);
   llvm::Function *F = CGF.CGM.getIntrinsic(ID);
   Result = Builder.CreateCall(F, {CR6Param, FirstVecArg, SecondVecArg});
+
+  // The result type of intrinsic may not be same as E->getType().
+  // If E->getType() is not BoolTy, EmitScalarConversion will do the
+  // conversion work. If E->getType() is BoolTy, EmitScalarConversion will
+  // do nothing, if ResultTy is not i1 at the same time, it will cause
+  // crash later.
+  llvm::IntegerType *ResultTy = cast(Result->getType());
+  if (ResultTy->getBitWidth() > 1 &&
+  E->getType() == CGF.getContext().BoolTy)
+Result = Builder.CreateTrunc(Result, Builder.getInt1Ty());
   return EmitScalarConversion(Result, CGF.getContext().BoolTy, E->getType(),
   E->getExprLoc());
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315219 - AMDGPU: Fix missing declaration for __builtin_amdgcn_dispatch_ptr

2017-10-09 Thread Matt Arsenault via cfe-commits
Author: arsenm
Date: Mon Oct  9 10:44:18 2017
New Revision: 315219

URL: http://llvm.org/viewvc/llvm-project?rev=315219=rev
Log:
AMDGPU: Fix missing declaration for __builtin_amdgcn_dispatch_ptr

Modified:
cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl

Modified: cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def?rev=315219=315218=315219=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsAMDGPU.def Mon Oct  9 10:44:18 2017
@@ -21,6 +21,7 @@
 // SI+ only builtins.
 
//===--===//
 
+BUILTIN(__builtin_amdgcn_dispatch_ptr, "Uc*2", "nc")
 BUILTIN(__builtin_amdgcn_kernarg_segment_ptr, "Uc*2", "nc")
 BUILTIN(__builtin_amdgcn_implicitarg_ptr, "Uc*2", "nc")
 

Modified: cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl?rev=315219=315218=315219=diff
==
--- cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/builtins-amdgcn.cl Mon Oct  9 10:44:18 2017
@@ -421,6 +421,13 @@ void test_read_exec(global ulong* out) {
 
 // CHECK: declare i64 @llvm.read_register.i64(metadata) 
#[[NOUNWIND_READONLY:[0-9]+]]
 
+// CHECK-LABEL: @test_dispatch_ptr
+// CHECK: call i8 addrspace(2)* @llvm.amdgcn.dispatch.ptr()
+void test_dispatch_ptr(__attribute__((address_space(2))) unsigned char ** out)
+{
+  *out = __builtin_amdgcn_dispatch_ptr();
+}
+
 // CHECK-LABEL: @test_kernarg_segment_ptr
 // CHECK: call i8 addrspace(2)* @llvm.amdgcn.kernarg.segment.ptr()
 void test_kernarg_segment_ptr(__attribute__((address_space(2))) unsigned char 
** out)


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


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman added inline comments.



Comment at: lib/Index/USRGeneration.cpp:820
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";
+  switch (AT->getSizeModifier()) {

You might also want to use the character literals for one char strings for 
efficiency.


https://reviews.llvm.org/D38643



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


[PATCH] D38694: [ASTImporter] Support importing CXXUnresolvedConstructExpr and UnresolvedLookupExpr

2017-10-09 Thread Peter Szecsi via Phabricator via cfe-commits
szepet created this revision.

This patch adds support for importing two different kind of C++ AST Node.
Note: This solution is based on 
https://github.com/haoNoQ/clang/blob/summary-ipa-draft/lib/AST/ASTImporter.cpp#L7605
 .


https://reviews.llvm.org/D38694

Files:
  lib/AST/ASTImporter.cpp
  unittests/AST/ASTImporterTest.cpp

Index: unittests/AST/ASTImporterTest.cpp
===
--- unittests/AST/ASTImporterTest.cpp
+++ unittests/AST/ASTImporterTest.cpp
@@ -457,7 +457,6 @@
   vaArgExpr();
 }
 
-
 TEST(ImportType, ImportAtomicType) {
   MatchVerifier Verifier;
   EXPECT_TRUE(testImport("void declToImport() { typedef _Atomic(int) a_int; }",
@@ -502,5 +501,39 @@
  has(cxxDependentScopeMemberExpr();
 }
 
+TEST(ImportExpr, ImportUnresolvedLookupExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(testImport("template int foo();"
+ "template  void declToImport() {"
+ "  ::foo;"
+ "  ::template foo;"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(
+ compoundStmt(has(unresolvedLookupExpr();
+}
+
+TEST(ImportExpr, ImportCXXUnresolvedConstructExpr) {
+  MatchVerifier Verifier;
+  EXPECT_TRUE(
+  testImport("template  class C { T t; };"
+ "template  void declToImport() {"
+ "C d;"
+ "d.t = T()"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(has(
+ binaryOperator(has(cxxUnresolvedConstructExpr()));
+  EXPECT_TRUE(
+  testImport("template  class C { T t; };"
+ "template  void declToImport() {"
+ "C d;"
+ "()->t = T()"
+ "}",
+ Lang_CXX, "", Lang_CXX, Verifier,
+ functionTemplateDecl(has(functionDecl(has(compoundStmt(has(
+ binaryOperator(has(cxxUnresolvedConstructExpr()));
+}
+
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -273,6 +273,8 @@
 Expr *VisitCXXConstructExpr(CXXConstructExpr *E);
 Expr *VisitCXXMemberCallExpr(CXXMemberCallExpr *E);
 Expr *VisitCXXDependentScopeMemberExpr(CXXDependentScopeMemberExpr *E);
+Expr *VisitCXXUnresolvedConstructExpr(CXXUnresolvedConstructExpr *CE);
+Expr *VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E);
 Expr *VisitExprWithCleanups(ExprWithCleanups *EWC);
 Expr *VisitCXXThisExpr(CXXThisExpr *E);
 Expr *VisitCXXBoolLiteralExpr(CXXBoolLiteralExpr *E);
@@ -5464,6 +5466,80 @@
   MemberNameInfo, ResInfo);
 }
 
+Expr *ASTNodeImporter::VisitCXXUnresolvedConstructExpr(
+CXXUnresolvedConstructExpr *CE) {
+
+  unsigned NumArgs = CE->arg_size();
+
+  llvm::SmallVector ToArgs(NumArgs);
+
+  for (unsigned ai = 0, ae = NumArgs; ai != ae; ++ai) {
+Expr *FromArg = CE->getArg(ai);
+Expr *ToArg = Importer.Import(FromArg);
+if (!ToArg)
+  return nullptr;
+ToArgs[ai] = ToArg;
+  }
+
+  Expr **ToArgs_Copied = new (Importer.getToContext()) Expr *[NumArgs];
+
+  for (unsigned ai = 0, ae = NumArgs; ai != ae; ++ai)
+ToArgs_Copied[ai] = ToArgs[ai];
+
+  return CXXUnresolvedConstructExpr::Create(
+  Importer.getToContext(), Importer.Import(CE->getTypeSourceInfo()),
+  Importer.Import(CE->getLParenLoc()),
+  llvm::makeArrayRef(ToArgs_Copied, NumArgs),
+  Importer.Import(CE->getRParenLoc()));
+}
+
+Expr *ASTNodeImporter::VisitUnresolvedLookupExpr(UnresolvedLookupExpr *E) {
+  CXXRecordDecl *NamingClass =
+  cast_or_null(Importer.Import(E->getNamingClass()));
+  if (E->getNamingClass() && !NamingClass)
+return nullptr;
+
+  DeclarationName Name = Importer.Import(E->getName());
+  if (E->getName().isEmpty() && Name.isEmpty())
+return nullptr;
+  DeclarationNameInfo NameInfo(Name, Importer.Import(E->getNameLoc()));
+  // Import additional name location/type info.
+  ImportDeclarationNameLoc(E->getNameInfo(), NameInfo);
+
+  UnresolvedSet<8> ToDecls;
+  for (Decl *D : E->decls()) {
+if (NamedDecl *To = cast_or_null(Importer.Import(D)))
+  ToDecls.addDecl(To);
+else
+  return nullptr;
+  }
+
+  TemplateArgumentListInfo ToTAInfo;
+  TemplateArgumentListInfo *ResInfo = nullptr;
+  if (E->hasExplicitTemplateArgs()) {
+for (const auto  : E->template_arguments()) {
+  bool Error = false;
+  TemplateArgumentLoc ToTALoc = ImportTemplateArgumentLoc(FromLoc, Error);
+  if (Error)
+return nullptr;
+  ToTAInfo.addArgument(ToTALoc);
+}
+ResInfo = 
+  }
+
+  if (ResInfo || 

[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman accepted this revision.
arphaman added a comment.
This revision is now accepted and ready to land.

LGTM




Comment at: lib/Index/USRGeneration.cpp:819
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";

Nit: I don't think you really need the 2nd const here and in the next if.


https://reviews.llvm.org/D38643



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Reid Kleckner via Phabricator via cfe-commits
rnk added inline comments.



Comment at: src/AddressSpace.hpp:388-389
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;

".eh_frame" is 9 characters, right? I thought mingw linkers took sections with 
long names and moved them to an extended symbol table. Does that not apply to 
.eh_frame?


https://reviews.llvm.org/D38679



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


[PATCH] D38679: [libunwind] Support dwarf unwinding on i386 windows

2017-10-09 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.

This builds on some parts from https://reviews.llvm.org/D33601 - some of them 
were commented on before. This patch contains comments and explanations about 
those non-obvious parts.


https://reviews.llvm.org/D38679

Files:
  docs/index.rst
  src/AddressSpace.hpp
  src/UnwindRegistersRestore.S
  src/assembly.h
  src/config.h

Index: src/config.h
===
--- src/config.h
+++ src/config.h
@@ -37,6 +37,8 @@
 #define _LIBUNWIND_SUPPORT_COMPACT_UNWIND
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND   1
   #endif
+#elif defined(_WIN32)
+  #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
 #else
   #if defined(__ARM_DWARF_EH__) || !defined(__arm__)
 #define _LIBUNWIND_SUPPORT_DWARF_UNWIND 1
Index: src/assembly.h
===
--- src/assembly.h
+++ src/assembly.h
@@ -26,6 +26,14 @@
 
 #if defined(__APPLE__)
 #define HIDDEN_DIRECTIVE .private_extern
+#elif defined(_WIN32)
+// In the COFF object file format, there's no attributes for a global,
+// non-static symbol to make it somehow hidden. So on windows, we don't
+// want to set this at all. To avoid conditionals in
+// DEFINE_LIBUNWIND_PRIVATE_FUNCTION below, make it .globl (which it already
+// is, defined in the same DEFINE_LIBUNWIND_PRIVATE_FUNCTION macro; the
+// duplicate .globl directives are harmless).
+#define HIDDEN_DIRECTIVE .globl
 #else
 #define HIDDEN_DIRECTIVE .hidden
 #endif
Index: src/UnwindRegistersRestore.S
===
--- src/UnwindRegistersRestore.S
+++ src/UnwindRegistersRestore.S
@@ -26,7 +26,12 @@
 #  + return address+
 #  +---+   <-- SP
 #  +   +
+#if !defined(_WIN32)
   movl   4(%esp), %eax
+#else
+  # On windows, the 'this' pointer is passed in ecx instead of on the stack
+  movl   %ecx, %eax
+#endif
   # set up eax and ret on new stack location
   movl  28(%eax), %edx # edx holds new stack pointer
   subl  $8,%edx
Index: src/AddressSpace.hpp
===
--- src/AddressSpace.hpp
+++ src/AddressSpace.hpp
@@ -18,7 +18,7 @@
 #include 
 #include 
 
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
 #include 
 #endif
 
@@ -97,7 +97,12 @@
 // independent ELF header traversal is not provided by  on some
 // systems (e.g., FreeBSD). On these systems the data structures are
 // just called Elf_XXX. Define ElfW() locally.
+#ifndef _WIN32
 #include 
+#else
+#include 
+#include 
+#endif
 #if !defined(ElfW)
 #define ElfW(type) Elf_##type
 #endif
@@ -356,6 +361,41 @@
  info.arm_section, info.arm_section_length);
   if (info.arm_section && info.arm_section_length)
 return true;
+#elif defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND) && defined(_WIN32)
+  HMODULE mods[1024];
+  HANDLE process = GetCurrentProcess();
+  DWORD needed;
+
+  if (!EnumProcessModules(process, mods, sizeof(mods), ))
+return false;
+
+  for (unsigned i = 0; i < (needed / sizeof(HMODULE)); i++) {
+PIMAGE_DOS_HEADER pidh = (PIMAGE_DOS_HEADER)mods[i];
+PIMAGE_NT_HEADERS pinh = (PIMAGE_NT_HEADERS)((BYTE *)pidh + pidh->e_lfanew);
+PIMAGE_FILE_HEADER pifh = (PIMAGE_FILE_HEADER)>FileHeader;
+PIMAGE_SECTION_HEADER pish = IMAGE_FIRST_SECTION(pinh);
+bool found_obj = false;
+bool found_hdr = false;
+
+info.dso_base = (uintptr_t)mods[i];
+for (unsigned j = 0; j < pifh->NumberOfSections; j++, pish++) {
+  uintptr_t begin = pish->VirtualAddress + (uintptr_t)mods[i];
+  uintptr_t end = begin + pish->Misc.VirtualSize;
+  if (!strncmp((const char *)pish->Name, ".text",
+   IMAGE_SIZEOF_SHORT_NAME)) {
+if (targetAddr >= begin && targetAddr < end)
+  found_obj = true;
+  } else if (!strncmp((const char *)pish->Name, ".eh_frame",
+  IMAGE_SIZEOF_SHORT_NAME)) {
+info.dwarf_section = begin;
+info.dwarf_section_length = pish->Misc.VirtualSize;
+found_hdr = true;
+  }
+  if (found_obj && found_hdr)
+return true;
+}
+  }
+  return false;
 #elif defined(_LIBUNWIND_ARM_EHABI) || defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
   struct dl_iterate_cb_data {
 LocalAddressSpace *addressSpace;
@@ -478,7 +518,7 @@
 inline bool LocalAddressSpace::findFunctionName(pint_t addr, char *buf,
 size_t bufLen,
 unw_word_t *offset) {
-#ifndef _LIBUNWIND_IS_BAREMETAL
+#if !defined(_LIBUNWIND_IS_BAREMETAL) && !defined(_WIN32)
   Dl_info dyldInfo;
   if (dladdr((void *)addr, )) {
 if (dyldInfo.dli_sname != NULL) {
Index: docs/index.rst
===
--- docs/index.rst
+++ docs/index.rst
@@ -50,6 +50,7 @@
 LinuxARM  Clang, GCC   EHABI
 

[PATCH] D38674: [analyzer] MisusedMovedObjectChecker: More precise warning message

2017-10-09 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a comment.

LGTM


https://reviews.llvm.org/D38674



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


[PATCH] D38643: PR13575: Fix USR mangling for fixed-size arrays.

2017-10-09 Thread Jan Korous via Phabricator via cfe-commits
jkorous-apple updated this revision to Diff 118231.
jkorous-apple added a comment.

clang-format


https://reviews.llvm.org/D38643

Files:
  lib/Index/USRGeneration.cpp
  test/Index/USR/array-type.cpp


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should 
have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | 
__Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | 
__Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | 
__Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << "s";
+break;
+  case ArrayType::Star:
+Out << "*";
+break;
+  case ArrayType::Normal:
+Out << "n";
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';


Index: test/Index/USR/array-type.cpp
===
--- /dev/null
+++ test/Index/USR/array-type.cpp
@@ -0,0 +1,11 @@
+// RUN: c-index-test core -print-source-symbols -- %s | FileCheck %s
+
+// Function template specializations differing in array type parameter should have unique USRs.
+
+template void foo(buffer);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n16C>#*C# | __Z3fooIA16_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[16]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n32C>#*C# | __Z3fooIA32_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[32]);
+// CHECK: {{[0-9]+}}:17 | function(Gen,TS)/C++ | foo | c:@F@foo<#{n64C>#*C# | __Z3fooIA64_cEvT_ | Decl,RelSpecialization | rel: 1
+template<> void foo(char[64]);
Index: lib/Index/USRGeneration.cpp
===
--- lib/Index/USRGeneration.cpp
+++ lib/Index/USRGeneration.cpp
@@ -816,6 +816,25 @@
   T = VT->getElementType();
   continue;
 }
+if (const auto *const AT = dyn_cast(T)) {
+  Out << "{";
+  switch (AT->getSizeModifier()) {
+  case ArrayType::Static:
+Out << "s";
+break;
+  case ArrayType::Star:
+Out << "*";
+break;
+  case ArrayType::Normal:
+Out << "n";
+break;
+  }
+  if (const auto *const CAT = dyn_cast(T))
+Out << CAT->getSize();
+
+  T = AT->getElementType();
+  continue;
+}
 
 // Unhandled type.
 Out << ' ';
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D38629: [clangd] Added a callback-based codeComplete in clangd.

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

We had a discussion with @sammccall  offline, probably

> - what's the goal? Make the code read more naturally, change the async model, 
> or something else?

Callback API is more flexible (if `std::future` that we use had `then`, they'd 
be equivalent).
We have internal clients that want to be notified about results of code 
completion without

> - what's the end state for codeComplete specifically? will we switch to the 
> new overload and delete the other, or is `makeFutureAPIFromCallback` here to 
> stay?

I think the way to go would be exactly that, switch to the new API and remove 
the older one. There are usages in tests, `ClangdLSPServer` and in our internal 
client, but I'll remove them with a separate commit later.
Added a deprecation notice for the API.


https://reviews.llvm.org/D38629



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


[PATCH] D38629: [clangd] Added a callback-based codeComplete in clangd.

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 118225.
ilya-biryukov added a comment.

- Added a deprecation notice to function description.


https://reviews.llvm.org/D38629

Files:
  clangd/ClangdServer.cpp
  clangd/ClangdServer.h

Index: clangd/ClangdServer.h
===
--- clangd/ClangdServer.h
+++ clangd/ClangdServer.h
@@ -233,6 +233,9 @@
   /// and AST and rebuild them from scratch.
   std::future forceReparse(PathRef File);
 
+  /// DEPRECATED. Please use a callback-based version, this API is deprecated
+  /// and will soon be removed.
+  ///
   /// Run code completion for \p File at \p Pos.
   ///
   /// Request is processed asynchronously. You can use the returned future to
@@ -252,6 +255,14 @@
llvm::Optional OverridenContents = llvm::None,
IntrusiveRefCntPtr *UsedFS = nullptr);
 
+  /// A version of `codeComplete` that runs \p Callback on the processing thread
+  /// when codeComplete results become available.
+  void codeComplete(
+  UniqueFunction)> Callback,
+  PathRef File, Position Pos,
+  llvm::Optional OverridenContents = llvm::None,
+  IntrusiveRefCntPtr *UsedFS = nullptr);
+
   /// Provide signature help for \p File at \p Pos. If \p OverridenContents is
   /// not None, they will used only for signature help, i.e. no diagnostics
   /// update will be scheduled and a draft for \p File will not be updated. If
Index: clangd/ClangdServer.cpp
===
--- clangd/ClangdServer.cpp
+++ clangd/ClangdServer.cpp
@@ -48,6 +48,25 @@
   return CompilerInvocation::GetResourcesPath("clangd", (void *));
 }
 
+template 
+std::future makeFutureAPIFromCallback(
+ClangdServer *Server,
+void (ClangdServer::*CallbackFunPtr)(UniqueFunction, Args...),
+Args... As) {
+  std::promise ResultPromise;
+  std::future ResultFuture = ResultPromise.get_future();
+
+  auto Callback = [](std::promise ResultPromise, Ret Result) -> void {
+ResultPromise.set_value(std::move(Result));
+  };
+
+  (Server->*CallbackFunPtr)(
+  BindWithForward(std::move(Callback), std::move(ResultPromise)),
+  std::forward(As)...);
+
+  return ResultFuture;
+}
+
 } // namespace
 
 size_t clangd::positionToOffset(StringRef Code, Position P) {
@@ -198,6 +217,17 @@
 ClangdServer::codeComplete(PathRef File, Position Pos,
llvm::Optional OverridenContents,
IntrusiveRefCntPtr *UsedFS) {
+  return makeFutureAPIFromCallback(this, ::codeComplete, File, Pos,
+   OverridenContents, UsedFS);
+}
+
+void ClangdServer::codeComplete(
+UniqueFunction)> Callback,
+PathRef File, Position Pos, llvm::Optional OverridenContents,
+IntrusiveRefCntPtr *UsedFS) {
+  using CallbackType =
+  UniqueFunction)>;
+
   std::string Contents;
   if (OverridenContents) {
 Contents = *OverridenContents;
@@ -216,36 +246,33 @@
   std::shared_ptr Resources = Units.getFile(File);
   assert(Resources && "Calling completion on non-added file");
 
-  using PackagedTask =
-  std::packaged_task()>;
-
   // Remember the current Preamble and use it when async task starts executing.
   // At the point when async task starts executing, we may have a different
   // Preamble in Resources. However, we assume the Preamble that we obtain here
   // is reusable in completion more often.
   std::shared_ptr Preamble =
   Resources->getPossiblyStalePreamble();
-  // A task that will be run asynchronously.
-  PackagedTask Task([=]() mutable { // 'mutable' to reassign Preamble variable.
-if (!Preamble) {
-  // Maybe we built some preamble before processing this request.
-  Preamble = Resources->getPossiblyStalePreamble();
-}
-// FIXME(ibiryukov): even if Preamble is non-null, we may want to check
-// both the old and the new version in case only one of them matches.
-
-std::vector Result = clangd::codeComplete(
-File, Resources->getCompileCommand(),
-Preamble ? >Preamble : nullptr, Contents, Pos, TaggedFS.Value,
-PCHs, SnippetCompletions, Logger);
-return make_tagged(std::move(Result), std::move(TaggedFS.Tag));
-  });
 
-  auto Future = Task.get_future();
-  // FIXME(ibiryukov): to reduce overhead for wrapping the same callable
-  // multiple times, ClangdScheduler should return future<> itself.
-  WorkScheduler.addToFront([](PackagedTask Task) { Task(); }, std::move(Task));
-  return Future;
+  // A task that will be run asynchronously.
+  auto Task =
+  // 'mutable' to reassign Preamble variable.
+  [=](CallbackType Callback) mutable {
+if (!Preamble) {
+  // Maybe we built some preamble before processing this request.
+  Preamble = Resources->getPossiblyStalePreamble();
+}
+// FIXME(ibiryukov): even 

[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

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



Comment at: test/CodeCompletion/enum-switch-case-qualified.cpp:25
 // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:23:8 %s -o - | 
FileCheck -check-prefix=CHECK-CC1 %s
-// CHECK-CC1: Blue : [#M::N::C::Color#]N::C::Blue
-// CHECK-CC1-NEXT: Green : [#M::N::C::Color#]N::C::Green
-// CHECK-CC1-NEXT: Indigo : [#M::N::C::Color#]N::C::Indigo
-// CHECK-CC1-NEXT: Orange : [#M::N::C::Color#]N::C::Orange
-// CHECK-CC1-NEXT: Red : [#M::N::C::Color#]N::C::Red
-// CHECK-CC1-NEXT: Violet : [#M::N::C::Color#]N::C::Violet
-// CHECK-CC1: Yellow : [#M::N::C::Color#]N::C::Yellow
+// CHECK-CC1: Blue : [#Color#]N::C::Blue
+// CHECK-CC1-NEXT: Green : [#Color#]N::C::Green

arphaman wrote:
> ilya-biryukov wrote:
> > This may be a somewhat unwanted part of this change.
> > Enum type is now written without qualifier here. I would argue that's ok, 
> > since the actual enum values are always properly qualified (they have to 
> > be, as they are actually inserted by completion) and those qualifiers 
> > provide all the necessary context for the user.
> I'm not 100% comfortable with making this kind of change right now. I'll try 
> to investigate what's best for our users.
I changed code to keep qualifiers for enums as is.
(This required moving some code from `libTooling` to `AST` in order to reuse 
it, I'll create a separate review for that if you're ok with the overall 
change).


https://reviews.llvm.org/D38538



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


[PATCH] D37970: [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315214: [clangd] Added a command-line arg to mirror clangd 
input into a file. (authored by ibiryukov).

Changed prior to commit:
  https://reviews.llvm.org/D37970?vs=115628=118223#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D37970

Files:
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
  clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
  clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
  clang-tools-extra/trunk/test/clangd/input-mirror.test

Index: clang-tools-extra/trunk/test/clangd/input-mirror.test
===
--- clang-tools-extra/trunk/test/clangd/input-mirror.test
+++ clang-tools-extra/trunk/test/clangd/input-mirror.test
@@ -0,0 +1,154 @@
+# RUN: clangd -run-synchronously -input-mirror-file %t < %s
+# Note that we have to use '-Z' as -input-mirror-file does not have a newline at the end of file.
+# RUN: diff -Z %t %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 172
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"int main() {\nint a;\na;\n}\n"}}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":0}}}
+# Go to local variable
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":2,"character":1}}}
+# Go to local variable, end of token
+
+Content-Length: 214
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":2},"contentChanges":[{"text":"struct Foo {\nint x;\n};\nint main() {\n  Foo bar = { x : 1 };\n}\n"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":14}}}
+# Go to field, GNU old-style field designator 
+
+Content-Length: 215
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":3},"contentChanges":[{"text":"struct Foo {\nint x;\n};\nint main() {\n  Foo baz = { .x = 2 };\n}\n"}]}}
+
+Content-Length: 149
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":4,"character":15}}}
+# Go to field, field designator 
+
+Content-Length: 187
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":4},"contentChanges":[{"text":"int main() {\n   main();\n   return 0;\n}"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":1,"character":3}}}
+# Go to function declaration, function call 
+
+Content-Length: 208
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"struct Foo {\n};\nint main() {\n   Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":3,"character":3}}}
+# Go to struct declaration, new struct instance 
+
+Content-Length: 231
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":5},"contentChanges":[{"text":"namespace n1 {\nstruct Foo {\n};\n}\nint main() {\n   n1::Foo bar;\n   return 0;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":4}}}
+# Go to struct declaration, new struct instance, qualified name 
+
+Content-Length: 215
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":6},"contentChanges":[{"text":"struct Foo {\n  int x;\n};\nint main() {\n   Foo bar;\n   bar.x;\n}\n"}]}}
+
+Content-Length: 148
+
+{"jsonrpc":"2.0","id":1,"method":"textDocument/definition","params":{"textDocument":{"uri":"file:///main.cpp"},"position":{"line":5,"character":7}}}
+# Go to field declaration, field reference 
+
+Content-Length: 220
+
+{"jsonrpc":"2.0","method":"textDocument/didChange","params":{"textDocument":{"uri":"file:///main.cpp","version":7},"contentChanges":[{"text":"struct Foo {\n  void x();\n};\nint main() {\n   Foo bar;\n   bar.x();\n}\n"}]}}
+
+Content-Length: 148
+

[clang-tools-extra] r315214 - [clangd] Added a command-line arg to mirror clangd input into a file.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:58:16 2017
New Revision: 315214

URL: http://llvm.org/viewvc/llvm-project?rev=315214=rev
Log:
[clangd] Added a command-line arg to mirror clangd input into a file.

Summary: The arg is useful for debugging and creating test cases.

Reviewers: bkramer, krasimir

Reviewed By: bkramer

Subscribers: klimek, cfe-commits

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

Added:
clang-tools-extra/trunk/test/clangd/input-mirror.test
Modified:
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp?rev=315214=315213=315214=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.cpp Mon Oct  9 09:58:16 
2017
@@ -37,6 +37,14 @@ void JSONOutput::log(const Twine 
   Logs.flush();
 }
 
+void JSONOutput::mirrorInput(const Twine ) {
+  if (!InputMirror)
+return;
+
+  *InputMirror << Message;
+  InputMirror->flush();
+}
+
 void Handler::handleMethod(llvm::yaml::MappingNode *Params, StringRef ID) {
   Output.log("Method ignored.\n");
   // Return that this method is unsupported.
@@ -147,6 +155,14 @@ void clangd::runLanguageServerLoop(std::
 continue;
   }
 
+  Out.mirrorInput(Line);
+  // Mirror '\n' that gets consumed by std::getline, but is not included in
+  // the resulting Line.
+  // Note that '\r' is part of Line, so we don't need to mirror it
+  // separately.
+  if (!In.eof())
+Out.mirrorInput("\n");
+
   llvm::StringRef LineRef(Line);
 
   // We allow YAML-style comments in headers. Technically this isn't part
@@ -163,9 +179,8 @@ void clangd::runLanguageServerLoop(std::
   if (LineRef.consume_front("Content-Length: ")) {
 if (ContentLength != 0) {
   Out.log("Warning: Duplicate Content-Length header received. "
-  "The previous value for this message ("
-  + std::to_string(ContentLength)
-  + ") was ignored.\n");
+  "The previous value for this message (" +
+  std::to_string(ContentLength) + ") was ignored.\n");
 }
 
 llvm::getAsUnsignedInteger(LineRef.trim(), 0, ContentLength);
@@ -185,15 +200,13 @@ void clangd::runLanguageServerLoop(std::
   // parser.
   std::vector JSON(ContentLength + 1, '\0');
   In.read(JSON.data(), ContentLength);
+  Out.mirrorInput(StringRef(JSON.data(), In.gcount()));
 
   // If the stream is aborted before we read ContentLength bytes, In
   // will have eofbit and failbit set.
   if (!In) {
-Out.log("Input was aborted. Read only "
-+ std::to_string(In.gcount())
-+ " bytes of expected "
-+ std::to_string(ContentLength)
-+ ".\n");
+Out.log("Input was aborted. Read only " + std::to_string(In.gcount()) +
+" bytes of expected " + std::to_string(ContentLength) + ".\n");
 break;
   }
 
@@ -209,8 +222,8 @@ void clangd::runLanguageServerLoop(std::
   if (IsDone)
 break;
 } else {
-  Out.log( "Warning: Missing Content-Length header, or message has zero "
-   "length.\n" );
+  Out.log("Warning: Missing Content-Length header, or message has zero "
+  "length.\n");
 }
   }
 }

Modified: clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h?rev=315214=315213=315214=diff
==
--- clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h (original)
+++ clang-tools-extra/trunk/clangd/JSONRPCDispatcher.h Mon Oct  9 09:58:16 2017
@@ -24,8 +24,9 @@ namespace clangd {
 /// them.
 class JSONOutput : public Logger {
 public:
-  JSONOutput(llvm::raw_ostream , llvm::raw_ostream )
-  : Outs(Outs), Logs(Logs) {}
+  JSONOutput(llvm::raw_ostream , llvm::raw_ostream ,
+ llvm::raw_ostream *InputMirror = nullptr)
+  : Outs(Outs), Logs(Logs), InputMirror(InputMirror) {}
 
   /// Emit a JSONRPC message.
   void writeMessage(const Twine );
@@ -33,9 +34,15 @@ public:
   /// Write to the logging stream.
   void log(const Twine ) override;
 
+  /// Mirror \p Message into InputMirror stream. Does nothing if InputMirror is
+  /// null.
+  /// Unlike other methods of JSONOutput, mirrorInput is not thread-safe.
+  void mirrorInput(const Twine );
+
 private:
   llvm::raw_ostream 
   llvm::raw_ostream 
+  llvm::raw_ostream *InputMirror;
 
   std::mutex StreamMutex;
 };

Modified: clang-tools-extra/trunk/clangd/tool/ClangdMain.cpp
URL: 

[PATCH] D38126: Make TBAA information to be part of LValueBaseInfo

2017-10-09 Thread Ivan A. Kosarev via Phabricator via cfe-commits
kosarev updated this revision to Diff 118200.
kosarev added a comment.

Removed the extra ###include##.


https://reviews.llvm.org/D38126

Files:
  lib/CodeGen/CGAtomic.cpp
  lib/CodeGen/CGBlocks.cpp
  lib/CodeGen/CGExpr.cpp
  lib/CodeGen/CGObjC.cpp
  lib/CodeGen/CGObjCRuntime.cpp
  lib/CodeGen/CGOpenMPRuntime.cpp
  lib/CodeGen/CGStmtOpenMP.cpp
  lib/CodeGen/CGValue.h
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/CodeGen/CodeGenTBAA.cpp
  lib/CodeGen/CodeGenTBAA.h

Index: lib/CodeGen/CodeGenTBAA.h
===
--- lib/CodeGen/CodeGenTBAA.h
+++ lib/CodeGen/CodeGenTBAA.h
@@ -47,6 +47,20 @@
 : TBAAAccessInfo(/* AccessType= */ nullptr)
   {}
 
+  bool operator==(const TBAAAccessInfo ) const {
+return BaseType == Other.BaseType &&
+   AccessType == Other.AccessType &&
+   Offset == Other.Offset;
+  }
+
+  bool operator!=(const TBAAAccessInfo ) const {
+return !(*this == Other);
+  }
+
+  explicit operator bool() const {
+return *this != TBAAAccessInfo();
+  }
+
   /// BaseType - The base/leading access type. May be null if this access
   /// descriptor represents an access that is not considered to be an access
   /// to an aggregate or union member.
@@ -136,6 +150,19 @@
   /// getMayAliasAccessInfo - Get TBAA information that represents may-alias
   /// accesses.
   TBAAAccessInfo getMayAliasAccessInfo();
+
+  /// isMayAliasAccessInfo - Test for the may-alias TBAA access descriptor.
+  bool isMayAliasAccessInfo(TBAAAccessInfo Info);
+
+  /// mergeTBAAInfoForCast - Get merged TBAA information for the purpose of
+  /// type casts.
+  TBAAAccessInfo mergeTBAAInfoForCast(TBAAAccessInfo SourceInfo,
+  TBAAAccessInfo TargetInfo);
+
+  /// mergeTBAAInfoForConditionalOperator - Get merged TBAA information for the
+  /// purpose of conditional operator.
+  TBAAAccessInfo mergeTBAAInfoForConditionalOperator(TBAAAccessInfo InfoA,
+ TBAAAccessInfo InfoB);
 };
 
 }  // end namespace CodeGen
@@ -166,9 +193,7 @@
 
   static bool isEqual(const clang::CodeGen::TBAAAccessInfo ,
   const clang::CodeGen::TBAAAccessInfo ) {
-return LHS.BaseType == RHS.BaseType &&
-   LHS.AccessType == RHS.AccessType &&
-   LHS.Offset == RHS.Offset;
+return LHS == RHS;
   }
 };
 
Index: lib/CodeGen/CodeGenTBAA.cpp
===
--- lib/CodeGen/CodeGenTBAA.cpp
+++ lib/CodeGen/CodeGenTBAA.cpp
@@ -88,18 +88,45 @@
   return false;
 }
 
+/// Check if the given type is a valid base type to be used in access tags.
+static bool isValidBaseType(QualType QTy) {
+  if (QTy->isReferenceType())
+return false;
+  if (const RecordType *TTy = QTy->getAs()) {
+const RecordDecl *RD = TTy->getDecl()->getDefinition();
+// Incomplete types are not valid base access types.
+if (!RD)
+  return false;
+if (RD->hasFlexibleArrayMember())
+  return false;
+// RD can be struct, union, class, interface or enum.
+// For now, we only handle struct and class.
+if (RD->isStruct() || RD->isClass())
+  return true;
+  }
+  return false;
+}
+
 llvm::MDNode *CodeGenTBAA::getTypeInfo(QualType QTy) {
   // At -O0 or relaxed aliasing, TBAA is not emitted for regular types.
   if (CodeGenOpts.OptimizationLevel == 0 || CodeGenOpts.RelaxedAliasing)
 return nullptr;
 
+  // In some cases, such as dereferencing a structure member, the final access
+  // type may well itself be an aggregate. Since it is possible to dereference
+  // a member of that aggregate, this function shall be able to generate
+  // descriptors for any object types, including aggregate ones, without
+  // falling back to returning the "omnipotent char" type node.
+  // TODO: Combine getTypeInfo() and getBaseTypeInfo() into a single function.
+  if (isValidBaseType(QTy))
+return getBaseTypeInfo(QTy);
+
   // If the type has the may_alias attribute (even on a typedef), it is
   // effectively in the general char alias class.
   if (TypeHasMayAlias(QTy))
 return getChar();
 
   const Type *Ty = Context.getCanonicalType(QTy).getTypePtr();
-
   if (llvm::MDNode *N = MetadataCache[Ty])
 return N;
 
@@ -232,20 +259,6 @@
   return StructMetadataCache[Ty] = nullptr;
 }
 
-/// Check if the given type is a valid base type to be used in access tags.
-static bool isValidBaseType(QualType QTy) {
-  if (const RecordType *TTy = QTy->getAs()) {
-const RecordDecl *RD = TTy->getDecl()->getDefinition();
-if (RD->hasFlexibleArrayMember())
-  return false;
-// RD can be struct, union, class, interface or enum.
-// For now, we only handle struct and class.
-if (RD->isStruct() || RD->isClass())
-  return true;
-  }
-  return false;
-}
-
 llvm::MDNode *CodeGenTBAA::getBaseTypeInfo(QualType QTy) {
   if 

[PATCH] D38629: [clangd] Added a callback-based codeComplete in clangd.

2017-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

I'm missing some context for this one:

- what's the goal? Make the code read more naturally, change the async model, 
or something else?
- what's the end state for codeComplete specifically? will we switch to the new 
overload and delete the other, or is makeFutureAPIFromCallback here to stay?


https://reviews.llvm.org/D38629



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


[PATCH] D38617: Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

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

In https://reviews.llvm.org/D38617#892092, @bkramer wrote:

> A testcase would be nice, but this can go in to unblock things.


Thanks for reviewing this!
Added a test case to clangd in https://reviews.llvm.org/rL315213.


Repository:
  rL LLVM

https://reviews.llvm.org/D38617



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


[PATCH] D38675: [analyzer] MisusedMovedObjectChecker: Moving the checker out of alpha state

2017-10-09 Thread Daniel Marjamäki via Phabricator via cfe-commits
danielmarjamaki added a reviewer: danielmarjamaki.
danielmarjamaki added a comment.

> However, the checker seems to work with a low false positive rate.  (<15 on 
> the LLVM, 6 effectively different)

This does not sound like a low false positive rate to me. Could you describe 
what the false positives are? Is it possible to fix them?

> Is it enough or should I check it on other open source projects?

you should check a number of different projects. There might be idioms/usages 
in other projects that are not seen in LLVM.

However I don't know what other open source C++11 projects there are.

But I have a script that runs clang on various Debian projects and I can run 
that and provide you with the results.


https://reviews.llvm.org/D38675



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


[clang-tools-extra] r315213 - [clangd] Added a test for r315212.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:53:00 2017
New Revision: 315213

URL: http://llvm.org/viewvc/llvm-project?rev=315213=rev
Log:
[clangd] Added a test for r315212.

Added:
clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test

Added: clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test?rev=315213=auto
==
--- clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test (added)
+++ clang-tools-extra/trunk/test/clangd/diagnostics-preamble.test Mon Oct  9 
09:53:00 2017
@@ -0,0 +1,15 @@
+# RUN: clangd -run-synchronously < %s | FileCheck %s
+# It is absolutely vital that this file has CRLF line endings.
+#
+Content-Length: 125
+
+{"jsonrpc":"2.0","id":0,"method":"initialize","params":{"processId":123,"rootPath":"clangd","capabilities":{},"trace":"off"}}
+
+Content-Length: 206
+
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"file:///main.cpp","languageId":"cpp","version":1,"text":"#ifndef
 FOO\n#define FOO\nint a;\n#else\nint a = b;#endif\n\n\n"}}}
+# CHECK: 
{"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"uri":"file:///main.cpp","diagnostics":[]}}
+
+Content-Length: 58
+
+{"jsonrpc":"2.0","id":2,"method":"shutdown","params":null}


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


[PATCH] D38617: Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315212: Set PreprocessorOpts.GeneratePreamble=true in 
PrecompiledPreamble. (authored by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38617

Files:
  cfe/trunk/lib/Frontend/ASTUnit.cpp
  cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1698,7 +1698,6 @@
   PreprocessorOptions  = CI->getPreprocessorOpts();
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
-  PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0;
   PPOpts.SingleFileParseMode = SingleFileParse;
   
   // Override the resources path.
Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -234,6 +234,8 @@
   FrontendOpts.OutputFile = PreamblePCHFile->getFilePath();
   PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
   PreprocessorOpts.PrecompiledPreambleBytes.second = false;
+  // Inform preprocessor to record conditional stack when building the 
preamble.
+  PreprocessorOpts.GeneratePreamble = true;
 
   // Create the compiler instance to use for building the precompiled preamble.
   std::unique_ptr Clang(


Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -1698,7 +1698,6 @@
   PreprocessorOptions  = CI->getPreprocessorOpts();
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
-  PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0;
   PPOpts.SingleFileParseMode = SingleFileParse;
   
   // Override the resources path.
Index: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
===
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
@@ -234,6 +234,8 @@
   FrontendOpts.OutputFile = PreamblePCHFile->getFilePath();
   PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
   PreprocessorOpts.PrecompiledPreambleBytes.second = false;
+  // Inform preprocessor to record conditional stack when building the preamble.
+  PreprocessorOpts.GeneratePreamble = true;
 
   // Create the compiler instance to use for building the precompiled preamble.
   std::unique_ptr Clang(
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r315212 - Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:52:12 2017
New Revision: 315212

URL: http://llvm.org/viewvc/llvm-project?rev=315212=rev
Log:
Set PreprocessorOpts.GeneratePreamble=true in PrecompiledPreamble.

Summary:
It was previsouly set only in ASTUnit, but it should be set for all client of
PrecompiledPreamble.

Reviewers: erikjv, bkramer, klimek

Reviewed By: bkramer

Subscribers: cfe-commits

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

Modified:
cfe/trunk/lib/Frontend/ASTUnit.cpp
cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=315212=315211=315212=diff
==
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Mon Oct  9 09:52:12 2017
@@ -1698,7 +1698,6 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   PreprocessorOptions  = CI->getPreprocessorOpts();
   PPOpts.RemappedFilesKeepOriginalName = RemappedFilesKeepOriginalName;
   PPOpts.AllowPCHWithCompilerErrors = AllowPCHWithCompilerErrors;
-  PPOpts.GeneratePreamble = PrecompilePreambleAfterNParses != 0;
   PPOpts.SingleFileParseMode = SingleFileParse;
   
   // Override the resources path.

Modified: cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp?rev=315212=315211=315212=diff
==
--- cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp (original)
+++ cfe/trunk/lib/Frontend/PrecompiledPreamble.cpp Mon Oct  9 09:52:12 2017
@@ -234,6 +234,8 @@ llvm::ErrorOr Preco
   FrontendOpts.OutputFile = PreamblePCHFile->getFilePath();
   PreprocessorOpts.PrecompiledPreambleBytes.first = 0;
   PreprocessorOpts.PrecompiledPreambleBytes.second = false;
+  // Inform preprocessor to record conditional stack when building the 
preamble.
+  PreprocessorOpts.GeneratePreamble = true;
 
   // Create the compiler instance to use for building the precompiled preamble.
   std::unique_ptr Clang(


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


[PATCH] D38538: Avoid printing some redundant name qualifiers in completion

2017-10-09 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 118185.
ilya-biryukov added a comment.
Herald added a subscriber: mgorny.

- Restore qualifiers for types of EnumConstantDecl.


https://reviews.llvm.org/D38538

Files:
  include/clang/AST/QualTypeNames.h
  include/clang/Tooling/Core/QualTypeNames.h
  lib/AST/CMakeLists.txt
  lib/AST/QualTypeNames.cpp
  lib/Sema/SemaCodeComplete.cpp
  lib/Tooling/Core/CMakeLists.txt
  lib/Tooling/Core/QualTypeNames.cpp
  test/CodeCompletion/call.cpp
  test/CodeCompletion/qualifiers-as-written.cpp
  test/CodeCompletion/uninstantiated_params.cpp
  test/Index/complete-cxx-inline-methods.cpp
  unittests/Tooling/QualTypeNamesTest.cpp

Index: unittests/Tooling/QualTypeNamesTest.cpp
===
--- unittests/Tooling/QualTypeNamesTest.cpp
+++ unittests/Tooling/QualTypeNamesTest.cpp
@@ -7,7 +7,7 @@
 //
 //===--===//
 
-#include "clang/Tooling/Core/QualTypeNames.h"
+#include "clang/AST/QualTypeNames.h"
 #include "TestVisitor.h"
 using namespace clang;
 
Index: test/Index/complete-cxx-inline-methods.cpp
===
--- test/Index/complete-cxx-inline-methods.cpp
+++ test/Index/complete-cxx-inline-methods.cpp
@@ -25,7 +25,7 @@
 
 // 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 )} (79)
+// CHECK:  CXXMethod:{ResultType Vec &}{TypedText operator=}{LeftParen (}{Placeholder const 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)
Index: test/CodeCompletion/uninstantiated_params.cpp
===
--- test/CodeCompletion/uninstantiated_params.cpp
+++ test/CodeCompletion/uninstantiated_params.cpp
@@ -9,5 +9,5 @@
   unique_ptr x;
   x.
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:10:5 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
-  // CHECK-CC1: [#void#]reset({#<#unique_ptr::pointer ptr = pointer()#>#})
+  // CHECK-CC1: [#void#]reset({#<#pointer ptr = pointer()#>#})
 }
Index: test/CodeCompletion/qualifiers-as-written.cpp
===
--- /dev/null
+++ test/CodeCompletion/qualifiers-as-written.cpp
@@ -0,0 +1,11 @@
+struct foo {
+  typedef int type;
+
+  type method(type, foo::type, ::foo::type, ::foo::foo::type);
+};
+
+void test() {
+  foo().
+  // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:8:9 %s -o - | FileCheck %s
+  // CHECK: COMPLETION: method : [#type#]method(<#type#>, <#foo::type#>, <#::foo::type#>, <#::foo::foo::type#>)
+}
Index: test/CodeCompletion/call.cpp
===
--- test/CodeCompletion/call.cpp
+++ test/CodeCompletion/call.cpp
@@ -19,10 +19,10 @@
   f(Y(), 0, 0);
   // RUN: %clang_cc1 -fsyntax-only -code-completion-patterns -code-completion-at=%s:19:9 %s -o - | FileCheck -check-prefix=CHECK-CC1 %s
   // CHECK-CC1: COMPLETION: Pattern : dynamic_cast<<#type#>>(<#expression#>)
-  // CHECK-CC1: f(N::Y y, <#int ZZ#>)
+  // CHECK-CC1: f(Y y, <#int ZZ#>)
   // CHECK-CC1-NEXT: f(int i, <#int j#>, int k)
   // CHECK-CC1-NEXT: f(float x, <#float y#>)
   // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:19:13 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s
-  // CHECK-CC2-NOT: f(N::Y y, int ZZ)
+  // CHECK-CC2-NOT: f(Y y, int ZZ)
   // CHECK-CC2: f(int i, int j, <#int k#>)
 }
Index: lib/Tooling/Core/CMakeLists.txt
===
--- lib/Tooling/Core/CMakeLists.txt
+++ lib/Tooling/Core/CMakeLists.txt
@@ -3,7 +3,6 @@
 add_clang_library(clangToolingCore
   Lookup.cpp
   Replacement.cpp
-  QualTypeNames.cpp
   Diagnostic.cpp
 
   LINK_LIBS
Index: lib/Sema/SemaCodeComplete.cpp
===
--- lib/Sema/SemaCodeComplete.cpp
+++ lib/Sema/SemaCodeComplete.cpp
@@ -14,6 +14,7 @@
 #include "clang/AST/DeclObjC.h"
 #include "clang/AST/ExprCXX.h"
 #include "clang/AST/ExprObjC.h"
+#include "clang/AST/QualTypeNames.h"
 #include "clang/Basic/CharInfo.h"
 #include "clang/Lex/HeaderSearch.h"
 #include "clang/Lex/MacroInfo.h"
@@ -1495,6 +1496,7 @@
   Policy.AnonymousTagLocations = false;
   Policy.SuppressStrongLifetime = true;
   Policy.SuppressUnwrittenScope = true;
+  Policy.SuppressScope = true;
   return Policy;
 }
 
@@ -2137,9 +2139,10 @@
   T = Method->getSendResultType(BaseType);
 else
   T = Method->getReturnType();
-  } else if (const EnumConstantDecl *Enumerator = dyn_cast(ND))
+  } else if (const EnumConstantDecl *Enumerator = 

[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-09 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added inline comments.
This revision is now accepted and ready to land.



Comment at: clangd/Function.h:9
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H

Maybe add a file comment "provides analogues to std::function that supports 
move semantics"?



Comment at: clangd/Function.h:36
+  template 
+  UniqueFunction(Callable Func)
+  : CallablePtr(llvm::make_unique<

Do you want this constructor to be explicit?

If not, I think you should be able to simplify the callsites in ClangdServer.h



Comment at: clangd/Function.h:77
+/// `operator()` can only be called once, as some of the arguments could be
+/// std::move'ed into the callable on first call.
+template  struct ForwardBinder {

nit: just 'moved'? std::move is just a cast...



Comment at: clangd/Function.h:117
+
+/// Creates an object that stores a callable (\p F) and first arguments to the
+/// callable (\p As) and allows to call \p F with \Args at a later point.

I find these "first arg" APIs a bit awkward, and can lead to writing confusing 
APIs for easier binding. Not sure there's a good alternative, though.



Comment at: clangd/Function.h:121
+///
+/// The returned object can only be called once, as \p As are std::forwarded'ed
+/// (therefore can be std::move`d) into \p F for the call.

nit: can -> must?


https://reviews.llvm.org/D38627



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


[PATCH] D38596: Implement attribute target multiversioning

2017-10-09 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 118218.
erichkeane added reviewers: rnk, rsmith.
erichkeane added a comment.

1 more const-auto.  Also noticed I'd missed that removing the 'default' caused 
the function to fallthrough, so I added llvm_unreachable to the bottom.


https://reviews.llvm.org/D38596

Files:
  include/clang/AST/Decl.h
  include/clang/Basic/Attr.td
  include/clang/Basic/DiagnosticSemaKinds.td
  include/clang/Basic/TargetInfo.h
  include/clang/Sema/Sema.h
  lib/Basic/Targets/X86.cpp
  lib/Basic/Targets/X86.h
  lib/CodeGen/CGBuiltin.cpp
  lib/CodeGen/CodeGenFunction.cpp
  lib/CodeGen/CodeGenFunction.h
  lib/CodeGen/CodeGenModule.cpp
  lib/CodeGen/CodeGenModule.h
  lib/Sema/SemaDecl.cpp
  test/CodeGen/attr-target-multiversion.c
  test/CodeGenCXX/attr-target-multiversion.cpp
  test/Sema/attr-target-multiversion.c
  test/SemaCXX/attr-target-multiversion.cpp

Index: test/SemaCXX/attr-target-multiversion.cpp
===
--- /dev/null
+++ test/SemaCXX/attr-target-multiversion.cpp
@@ -0,0 +1,49 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+
+struct S {
+  __attribute__((target("arch=sandybridge")))
+  void mv(){}
+  __attribute__((target("arch=ivybridge")))
+  void mv(){}
+  __attribute__((target("default")))
+  void mv(){}
+
+  // NOTE: Virtual functions aren't implement for multiversioning in GCC either,
+  // so this is a 'TBD' feature.
+  // expected-error@+2 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  __attribute__((target("arch=sandybridge")))
+  virtual void mv_2(){}
+  // expected-error@+4 {{function multiversioning with 'target' doesn't support virtual functions yet}}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-3 {{previous definition is here}}
+  __attribute__((target("arch=ivybridge")))
+  virtual void mv_2(){}
+  // expected-error@+3 {{class member cannot be redeclared}}
+  // expected-note@-7 {{previous definition is here}}
+  __attribute__((target("default")))
+  virtual void mv_2(){}
+};
+
+// Note: Template attribute 'target' isn't implemented in GCC either, and would
+// end up causing some nasty issues attempting it, so ensure that it still gives
+// the same errors as without the attribute.
+
+template
+__attribute__((target("arch=sandybridge")))
+void mv_temp(){}
+
+template
+__attribute__((target("arch=ivybridge")))
+//expected-error@+2 {{redefinition of}}
+//expected-note@-5{{previous definition is here}}
+void mv_temp(){}
+
+template
+__attribute__((target("default")))
+void mv_temp(){}
+
+void foo() {
+  //expected-error@+2{{no matching function for call to}}
+  //expected-note@-8{{candidate template ignored}}
+  mv_temp();
+}
Index: test/Sema/attr-target-multiversion.c
===
--- /dev/null
+++ test/Sema/attr-target-multiversion.c
@@ -0,0 +1,136 @@
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only %s
+// RUN: %clang_cc1 -triple x86_64-linux -fsyntax-only -verify -emit-llvm-only -DCHECK_DEFAULT %s
+
+#if defined(CHECK_DEFAULT)
+__attribute__((target("arch=sandybridge")))
+//expected-error@+1 {{function multiversioning with 'target' requires a 'default' implementation}}
+void no_default(){}
+__attribute__((target("arch=ivybridge")))
+void no_default(){}
+#else
+// Only multiversioning causes issues with redeclaration changing 'target'.
+__attribute__((target("arch=sandybridge")))
+void fine_since_no_mv();
+void fine_since_no_mv();
+
+void also_fine_since_no_mv();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv();
+
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+__attribute__((target("arch=sandybridge")))
+void also_fine_since_no_mv2();
+void also_fine_since_no_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void mv(){}
+__attribute__((target("arch=ivybridge")))
+void mv(){}
+__attribute__((target("default")))
+void mv(){}
+
+void redecl_causes_mv();
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-4 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_causes_mv2();
+void redecl_causes_mv2();
+// expected-error@+3 {{function redeclaration declares a multiversioned function, but a previous declaration lacks a 'target' attribute}}
+// expected-note@-2 {{previous declaration is here}}
+__attribute__((target("arch=ivybridge")))
+void redecl_causes_mv2();
+
+__attribute__((target("arch=sandybridge")))
+void redecl_without_attr();
+__attribute__((target("arch=ivybridge")))
+void redecl_without_attr();
+// expected-error@+2 {{function redeclaration is missing 'target' 

[PATCH] D38672: [X86][AVX512] lowering shuffle f/i intrinsic - clang part

2017-10-09 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman accepted this revision.
m_zuckerman added a comment.
This revision is now accepted and ready to land.

after LLVM-SIDE


https://reviews.llvm.org/D38672



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


[PATCH] D38627: [clangd] Added move-only function helpers.

2017-10-09 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL315210: [clangd] Added move-only function helpers. (authored 
by ibiryukov).

Repository:
  rL LLVM

https://reviews.llvm.org/D38627

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

Index: clang-tools-extra/trunk/clangd/Function.h
===
--- clang-tools-extra/trunk/clangd/Function.h
+++ clang-tools-extra/trunk/clangd/Function.h
@@ -0,0 +1,136 @@
+//===--- Function.h - Utility callable wrappers  -*- C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file provides an analogue to std::function that supports move semantics.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// A move-only type-erasing function wrapper. Similar to `std::function`, but
+/// allows to store move-only callables.
+template  class UniqueFunction;
+
+template  class UniqueFunction {
+public:
+  UniqueFunction() = default;
+  UniqueFunction(std::nullptr_t) : UniqueFunction(){};
+
+  UniqueFunction(UniqueFunction const &) = delete;
+  UniqueFunction =(UniqueFunction const &) = delete;
+
+  UniqueFunction(UniqueFunction &&) noexcept = default;
+  UniqueFunction =(UniqueFunction &&) noexcept = default;
+
+  template 
+  UniqueFunction(Callable &)
+  : CallablePtr(llvm::make_unique<
+FunctionCallImpl::type>>(
+std::forward(Func))) {}
+
+  operator bool() { return CallablePtr; }
+
+  Ret operator()(Args... As) {
+assert(CallablePtr);
+CallablePtr->Call(std::forward(As)...);
+  }
+
+private:
+  class FunctionCallBase {
+  public:
+virtual ~FunctionCallBase() = default;
+virtual Ret Call(Args... As) = 0;
+  };
+
+  template 
+  class FunctionCallImpl final : public FunctionCallBase {
+static_assert(
+std::is_same::value,
+"FunctionCallImpl must be instanstiated with std::decay'ed types");
+
+  public:
+FunctionCallImpl(Callable Func) : Func(std::move(Func)) {}
+
+Ret Call(Args... As) override { return Func(std::forward(As)...); }
+
+  private:
+Callable Func;
+  };
+
+  std::unique_ptr CallablePtr;
+};
+
+/// Stores a callable object (Func) and arguments (Args) and allows to call the
+/// callable with provided arguments later using `operator ()`. The arguments
+/// are std::forward'ed into the callable in the body of `operator()`. Therefore
+/// `operator()` can only be called once, as some of the arguments could be
+/// std::move'ed into the callable on first call.
+template  struct ForwardBinder {
+  using Tuple = std::tuple::type,
+   typename std::decay::type...>;
+  Tuple FuncWithArguments;
+#ifndef NDEBUG
+  bool WasCalled = false;
+#endif
+
+public:
+  ForwardBinder(Tuple FuncWithArguments)
+  : FuncWithArguments(std::move(FuncWithArguments)) {}
+
+private:
+  template 
+  auto CallImpl(llvm::integer_sequence Seq,
+RestArgs &&... Rest)
+  -> decltype(std::get<0>(this->FuncWithArguments)(
+  std::forward(std::get(this->FuncWithArguments))...,
+  std::forward(Rest)...)) {
+return std::get<0>(this->FuncWithArguments)(
+std::forward(std::get(this->FuncWithArguments))...,
+std::forward(Rest)...);
+  }
+
+public:
+  template 
+  auto operator()(RestArgs &&... Rest)
+  -> decltype(CallImpl(llvm::index_sequence_for(),
+   std::forward(Rest)...)) {
+
+#ifndef NDEBUG
+assert(!WasCalled && "Can only call result of BindWithForward once.");
+WasCalled = true;
+#endif
+return CallImpl(llvm::index_sequence_for(),
+std::forward(Rest)...);
+  }
+};
+
+/// Creates an object that stores a callable (\p F) and first arguments to the
+/// callable (\p As) and allows to call \p F with \Args at a later point.
+/// Similar to std::bind, but also works with move-only \p F and \p As.
+///
+/// The returned object must be called no more than once, as \p As are
+/// std::forwarded'ed (therefore can be moved) into \p F during the call.
+template 
+ForwardBinder BindWithForward(Func F, Args &&... As) {
+  return ForwardBinder(
+  std::make_tuple(std::forward(F), std::forward(As)...));
+}
+
+} // namespace clangd
+} // namespace clang
+
+#endif
Index: clang-tools-extra/trunk/clangd/ClangdServer.h

[clang-tools-extra] r315210 - [clangd] Added move-only function helpers.

2017-10-09 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Mon Oct  9 09:26:26 2017
New Revision: 315210

URL: http://llvm.org/viewvc/llvm-project?rev=315210=rev
Log:
[clangd] Added move-only function helpers.

Summary:
They are now used in ClangdScheduler instead of deferred std::async
computations.
The results of `std::async` are much less effective and do not provide
a good abstraction for similar purposes, i.e. for storing additional callbacks
to clangd async tasks. The actual callback API will follow a bit later.

Reviewers: klimek, bkramer, sammccall, krasimir

Reviewed By: sammccall

Subscribers: cfe-commits

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

Added:
clang-tools-extra/trunk/clangd/Function.h
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=315210=315209=315210=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Mon Oct  9 09:26:26 2017
@@ -99,7 +99,7 @@ ClangdScheduler::ClangdScheduler(unsigne
   for (unsigned I = 0; I < AsyncThreadsCount; ++I) {
 Workers.push_back(std::thread([this]() {
   while (true) {
-std::future Request;
+UniqueFunction Request;
 
 // Pick request from the queue
 {
@@ -120,7 +120,7 @@ ClangdScheduler::ClangdScheduler(unsigne
   RequestQueue.pop_front();
 } // unlock Mutex
 
-Request.get();
+Request();
   }
 }));
   }

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=315210=315209=315210=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Mon Oct  9 09:26:26 2017
@@ -20,6 +20,7 @@
 #include "llvm/ADT/StringRef.h"
 
 #include "ClangdUnit.h"
+#include "Function.h"
 #include "Protocol.h"
 
 #include 
@@ -132,9 +133,8 @@ public:
 
 {
   std::lock_guard Lock(Mutex);
-  RequestQueue.push_front(std::async(std::launch::deferred,
- std::forward(F),
- std::forward(As)...));
+  RequestQueue.push_front(
+  BindWithForward(std::forward(F), std::forward(As)...));
 }
 RequestCV.notify_one();
   }
@@ -149,9 +149,8 @@ public:
 
 {
   std::lock_guard Lock(Mutex);
-  RequestQueue.push_back(std::async(std::launch::deferred,
-std::forward(F),
-std::forward(As)...));
+  RequestQueue.push_back(
+  BindWithForward(std::forward(F), std::forward(As)...));
 }
 RequestCV.notify_one();
   }
@@ -167,7 +166,7 @@ private:
   bool Done = false;
   /// A queue of requests. Elements of this vector are async computations (i.e.
   /// results of calling std::async(std::launch::deferred, ...)).
-  std::deque RequestQueue;
+  std::deque> RequestQueue;
   /// Condition variable to wake up worker threads.
   std::condition_variable RequestCV;
 };

Added: clang-tools-extra/trunk/clangd/Function.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/Function.h?rev=315210=auto
==
--- clang-tools-extra/trunk/clangd/Function.h (added)
+++ clang-tools-extra/trunk/clangd/Function.h Mon Oct  9 09:26:26 2017
@@ -0,0 +1,136 @@
+//===--- Function.h - Utility callable wrappers  -*- 
C++-*-===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===--===//
+//
+// This file provides an analogue to std::function that supports move 
semantics.
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_FUNCTION_H
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// A move-only type-erasing function wrapper. Similar to `std::function`, but
+/// allows to store move-only callables.
+template  class UniqueFunction;
+
+template  class UniqueFunction {
+public:
+  UniqueFunction() = default;
+  UniqueFunction(std::nullptr_t) : UniqueFunction(){};
+
+  UniqueFunction(UniqueFunction const &) = delete;
+  UniqueFunction =(UniqueFunction const &) = delete;
+
+  UniqueFunction(UniqueFunction &&) noexcept = default;
+  UniqueFunction 

[PATCH] D38672: [X86][AVX512] lowering shuffle f/i intrinsic - clang part

2017-10-09 Thread michael zuckerman via Phabricator via cfe-commits
m_zuckerman added a comment.

Please add depended parent. 
LGTM After the parent commit (LLVM side).


https://reviews.llvm.org/D38672



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


  1   2   >