[PATCH] D66796: [clang] Loop pragma vectorize(disable)

2019-09-03 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added a comment.

friendly ping.

Shall we get this in, so that I can commit this and  D66290 
? Then, we can perhaps continue the interleave 
discussion separately? 
I will then return to the doc patch first in D66199 
, so that we can start wrapping up the loop 
pragma business, and hopefully it is a lot more consistent!


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66796/new/

https://reviews.llvm.org/D66796



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


r370709 - [RISCV] Correct Logic around ilp32e macros

2019-09-03 Thread Sam Elliott via cfe-commits
Author: lenary
Date: Tue Sep  3 01:47:58 2019
New Revision: 370709

URL: http://llvm.org/viewvc/llvm-project?rev=370709&view=rev
Log:
[RISCV] Correct Logic around ilp32e macros

Summary:
GCC seperates the `__riscv_float_abi_*` macros and the
`__riscv_abi_rve` macro. If the chosen abi is ilp32e, `gcc -march=rv32i
-mabi=ilp32i -E -dM` shows that both `__riscv_float_abi_soft` and
`__riscv_abi_rve` are set.

This patch corrects the compiler logic around these defines.

At the moment, this patch will not change clang's behaviour, because we do not
accept the `ilp32e` abi yet.

Reviewers: luismarques, asb

Reviewed By: luismarques

Subscribers: rbar, johnrusso, simoncook, apazos, sabuasal, niosHD, kito-cheng, 
shiva0217, jrtc27, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, 
brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, 
pzheng, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/lib/Basic/Targets/RISCV.cpp

Modified: cfe/trunk/lib/Basic/Targets/RISCV.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Basic/Targets/RISCV.cpp?rev=370709&r1=370708&r2=370709&view=diff
==
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp (original)
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp Tue Sep  3 01:47:58 2019
@@ -96,11 +96,12 @@ void RISCVTargetInfo::getTargetDefines(c
 Builder.defineMacro("__riscv_float_abi_single");
   else if (ABIName == "ilp32d" || ABIName == "lp64d")
 Builder.defineMacro("__riscv_float_abi_double");
-  else if (ABIName == "ilp32e")
-Builder.defineMacro("__riscv_abi_rve");
   else
 Builder.defineMacro("__riscv_float_abi_soft");
 
+  if (ABIName == "ilp32e")
+Builder.defineMacro("__riscv_abi_rve");
+
   if (HasM) {
 Builder.defineMacro("__riscv_mul");
 Builder.defineMacro("__riscv_div");


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


[PATCH] D66990: [clangd] Add distinct highlightings for declarations of functions and methods

2019-09-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

In D66990#1655030 , @nridge wrote:

> I was hoping though that a patch like this, which would bring us largely to 
> parity with Eclipse CDT's highlightings, wouldn't need to blocked on a change 
> to the upstream protocol proposal, which could take a while.


Is feature parity a hard requirement? Having slightly different highlightings 
in that case should not be too disruptive.

> I think the way cquery does it 
> 
>  it better in this regard: in place of a single kind enum, they essentially 
> have a 4-tuple of `(kind, parent kind, storage class, role)`.

A design like this definitely makes more sense. I was thinking of a slightly 
simpler model: adding a set of "modifiers" to each highlighting should be 
enough to encode all of it, e.g. a modifier 'is class member' could be used to 
distinguish methods and fields from global functions and variables, a modifier 
'is usage' can be used to distinguish usages from declarations, etc.
But there's no combinatorial explosion in the cquery's model, which is the 
important bit.

>> That would also mean we would rely on every editor to apply consistent 
>> styling for this, at least by default: make `somethind-decl` just like 
>> `decl` but bold.
>>  I don't think there's any way to enforce this.

Different designs lead to different interpretations: if we encode this as a 
separate highlighting kind, there's a greater chance this would be highlighted 
in different color rather than just applying modifiers.
If we model this as "something in addition to the main highlighting", there's a 
greater chance this would be interpreted as something that should be "bold".

Agree there is no way to enforce this.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66990/new/

https://reviews.llvm.org/D66990



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


[PATCH] D57450: [RISCV] Set MaxAtomicInlineWidth and MaxAtomicPromoteWidth for RV32/RV64 targets with atomics

2019-09-03 Thread Sam Elliott via Phabricator via cfe-commits
lenary added a comment.

Backported to 9.0 in rL370181 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D57450/new/

https://reviews.llvm.org/D57450



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


[PATCH] D66591: [RISCV] Correct Logic around ilp32e macros

2019-09-03 Thread Sam Elliott via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370709: [RISCV] Correct Logic around ilp32e macros (authored 
by lenary, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66591?vs=216612&id=218409#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66591/new/

https://reviews.llvm.org/D66591

Files:
  cfe/trunk/lib/Basic/Targets/RISCV.cpp


Index: cfe/trunk/lib/Basic/Targets/RISCV.cpp
===
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp
@@ -96,11 +96,12 @@
 Builder.defineMacro("__riscv_float_abi_single");
   else if (ABIName == "ilp32d" || ABIName == "lp64d")
 Builder.defineMacro("__riscv_float_abi_double");
-  else if (ABIName == "ilp32e")
-Builder.defineMacro("__riscv_abi_rve");
   else
 Builder.defineMacro("__riscv_float_abi_soft");
 
+  if (ABIName == "ilp32e")
+Builder.defineMacro("__riscv_abi_rve");
+
   if (HasM) {
 Builder.defineMacro("__riscv_mul");
 Builder.defineMacro("__riscv_div");


Index: cfe/trunk/lib/Basic/Targets/RISCV.cpp
===
--- cfe/trunk/lib/Basic/Targets/RISCV.cpp
+++ cfe/trunk/lib/Basic/Targets/RISCV.cpp
@@ -96,11 +96,12 @@
 Builder.defineMacro("__riscv_float_abi_single");
   else if (ABIName == "ilp32d" || ABIName == "lp64d")
 Builder.defineMacro("__riscv_float_abi_double");
-  else if (ABIName == "ilp32e")
-Builder.defineMacro("__riscv_abi_rve");
   else
 Builder.defineMacro("__riscv_float_abi_soft");
 
+  if (ABIName == "ilp32e")
+Builder.defineMacro("__riscv_abi_rve");
+
   if (HasM) {
 Builder.defineMacro("__riscv_mul");
 Builder.defineMacro("__riscv_div");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66588: [ARM NEON] Avoid duplicated decarations

2019-09-03 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio updated this revision to Diff 218412.
dnsampaio added a comment.

- Fix comment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66588/new/

https://reviews.llvm.org/D66588

Files:
  clang/utils/TableGen/NeonEmitter.cpp


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -332,6 +332,17 @@
   NeonEmitter &Emitter;
   std::stringstream OS;
 
+  bool isBigEndianSafe() const {
+if (BigEndianSafe)
+  return true;
+
+for (const auto &T : Types){
+  if (T.isVector() && T.getNumElements() > 1)
+return false;
+}
+return true;
+  }
+
 public:
   Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
 TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
@@ -1293,7 +1304,7 @@
 }
 
 void Intrinsic::emitArgumentReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
 
   // Reverse all vector arguments.
@@ -1314,7 +1325,7 @@
 }
 
 void Intrinsic::emitReturnReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
   if (!getReturnType().isVector() || getReturnType().isVoid() ||
   getReturnType().getNumElements() == 1)
@@ -1578,7 +1589,10 @@
   Intr.Dependencies.insert(&Callee);
 
   // Now create the call itself.
-  std::string S = CallPrefix.str() + Callee.getMangledName(true) + "(";
+  std::string S = "";
+  if (!Callee.isBigEndianSafe())
+S += CallPrefix.str();
+  S += Callee.getMangledName(true) + "(";
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
 if (I != 0)
   S += ", ";
@@ -1889,6 +1903,11 @@
 }
 
 std::string Intrinsic::generate() {
+  // Avoid duplicated code for big and little endian
+  if (isBigEndianSafe()) {
+generateImpl(false, "", "");
+return OS.str();
+  }
   // Little endian intrinsics are simple and don't require any argument
   // swapping.
   OS << "#ifdef __LITTLE_ENDIAN__\n";


Index: clang/utils/TableGen/NeonEmitter.cpp
===
--- clang/utils/TableGen/NeonEmitter.cpp
+++ clang/utils/TableGen/NeonEmitter.cpp
@@ -332,6 +332,17 @@
   NeonEmitter &Emitter;
   std::stringstream OS;
 
+  bool isBigEndianSafe() const {
+if (BigEndianSafe)
+  return true;
+
+for (const auto &T : Types){
+  if (T.isVector() && T.getNumElements() > 1)
+return false;
+}
+return true;
+  }
+
 public:
   Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
 TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
@@ -1293,7 +1304,7 @@
 }
 
 void Intrinsic::emitArgumentReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
 
   // Reverse all vector arguments.
@@ -1314,7 +1325,7 @@
 }
 
 void Intrinsic::emitReturnReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
   if (!getReturnType().isVector() || getReturnType().isVoid() ||
   getReturnType().getNumElements() == 1)
@@ -1578,7 +1589,10 @@
   Intr.Dependencies.insert(&Callee);
 
   // Now create the call itself.
-  std::string S = CallPrefix.str() + Callee.getMangledName(true) + "(";
+  std::string S = "";
+  if (!Callee.isBigEndianSafe())
+S += CallPrefix.str();
+  S += Callee.getMangledName(true) + "(";
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
 if (I != 0)
   S += ", ";
@@ -1889,6 +1903,11 @@
 }
 
 std::string Intrinsic::generate() {
+  // Avoid duplicated code for big and little endian
+  if (isBigEndianSafe()) {
+generateImpl(false, "", "");
+return OS.str();
+  }
   // Little endian intrinsics are simple and don't require any argument
   // swapping.
   OS << "#ifdef __LITTLE_ENDIAN__\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r370716 - [ARM NEON] Avoid duplicated decarations

2019-09-03 Thread Diogo N. Sampaio via cfe-commits
Author: dnsampaio
Date: Tue Sep  3 02:16:44 2019
New Revision: 370716

URL: http://llvm.org/viewvc/llvm-project?rev=370716&view=rev
Log:
[ARM NEON] Avoid duplicated decarations

Summary:
The declaration of arm neon intrinsics that are
"big endian safe" print the same code for big
and small endian targets.
This patch avoids duplicates by checking if an
intrinsic is safe to have a single definition.
(decreases header 11k lines out of 73k).

Reviewers: t.p.northover, ostannard, labrinea

Reviewed By: ostannard

Subscribers: kristof.beyls, cfe-commits, olista01

Tags: #clang

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


Modified:
cfe/trunk/utils/TableGen/NeonEmitter.cpp

Modified: cfe/trunk/utils/TableGen/NeonEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/NeonEmitter.cpp?rev=370716&r1=370715&r2=370716&view=diff
==
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp Tue Sep  3 02:16:44 2019
@@ -332,6 +332,17 @@ class Intrinsic {
   NeonEmitter &Emitter;
   std::stringstream OS;
 
+  bool isBigEndianSafe() const {
+if (BigEndianSafe)
+  return true;
+
+for (const auto &T : Types){
+  if (T.isVector() && T.getNumElements() > 1)
+return false;
+}
+return true;
+  }
+
 public:
   Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
 TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
@@ -1293,7 +1304,7 @@ void Intrinsic::emitReverseVariable(Vari
 }
 
 void Intrinsic::emitArgumentReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
 
   // Reverse all vector arguments.
@@ -1314,7 +1325,7 @@ void Intrinsic::emitArgumentReversal() {
 }
 
 void Intrinsic::emitReturnReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
   if (!getReturnType().isVector() || getReturnType().isVoid() ||
   getReturnType().getNumElements() == 1)
@@ -1578,7 +1589,10 @@ std::pair Intrinsic::
   Intr.Dependencies.insert(&Callee);
 
   // Now create the call itself.
-  std::string S = CallPrefix.str() + Callee.getMangledName(true) + "(";
+  std::string S = "";
+  if (!Callee.isBigEndianSafe())
+S += CallPrefix.str();
+  S += Callee.getMangledName(true) + "(";
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
 if (I != 0)
   S += ", ";
@@ -1889,6 +1903,11 @@ Intrinsic::DagEmitter::emitDagArg(Init *
 }
 
 std::string Intrinsic::generate() {
+  // Avoid duplicated code for big and little endian
+  if (isBigEndianSafe()) {
+generateImpl(false, "", "");
+return OS.str();
+  }
   // Little endian intrinsics are simple and don't require any argument
   // swapping.
   OS << "#ifdef __LITTLE_ENDIAN__\n";


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


[PATCH] D66588: [ARM NEON] Avoid duplicated decarations

2019-09-03 Thread Diogo N. Sampaio via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370716: [ARM NEON] Avoid duplicated decarations (authored by 
dnsampaio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66588?vs=218412&id=218414#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66588/new/

https://reviews.llvm.org/D66588

Files:
  cfe/trunk/utils/TableGen/NeonEmitter.cpp


Index: cfe/trunk/utils/TableGen/NeonEmitter.cpp
===
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp
@@ -332,6 +332,17 @@
   NeonEmitter &Emitter;
   std::stringstream OS;
 
+  bool isBigEndianSafe() const {
+if (BigEndianSafe)
+  return true;
+
+for (const auto &T : Types){
+  if (T.isVector() && T.getNumElements() > 1)
+return false;
+}
+return true;
+  }
+
 public:
   Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
 TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
@@ -1293,7 +1304,7 @@
 }
 
 void Intrinsic::emitArgumentReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
 
   // Reverse all vector arguments.
@@ -1314,7 +1325,7 @@
 }
 
 void Intrinsic::emitReturnReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
   if (!getReturnType().isVector() || getReturnType().isVoid() ||
   getReturnType().getNumElements() == 1)
@@ -1578,7 +1589,10 @@
   Intr.Dependencies.insert(&Callee);
 
   // Now create the call itself.
-  std::string S = CallPrefix.str() + Callee.getMangledName(true) + "(";
+  std::string S = "";
+  if (!Callee.isBigEndianSafe())
+S += CallPrefix.str();
+  S += Callee.getMangledName(true) + "(";
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
 if (I != 0)
   S += ", ";
@@ -1889,6 +1903,11 @@
 }
 
 std::string Intrinsic::generate() {
+  // Avoid duplicated code for big and little endian
+  if (isBigEndianSafe()) {
+generateImpl(false, "", "");
+return OS.str();
+  }
   // Little endian intrinsics are simple and don't require any argument
   // swapping.
   OS << "#ifdef __LITTLE_ENDIAN__\n";


Index: cfe/trunk/utils/TableGen/NeonEmitter.cpp
===
--- cfe/trunk/utils/TableGen/NeonEmitter.cpp
+++ cfe/trunk/utils/TableGen/NeonEmitter.cpp
@@ -332,6 +332,17 @@
   NeonEmitter &Emitter;
   std::stringstream OS;
 
+  bool isBigEndianSafe() const {
+if (BigEndianSafe)
+  return true;
+
+for (const auto &T : Types){
+  if (T.isVector() && T.getNumElements() > 1)
+return false;
+}
+return true;
+  }
+
 public:
   Intrinsic(Record *R, StringRef Name, StringRef Proto, TypeSpec OutTS,
 TypeSpec InTS, ClassKind CK, ListInit *Body, NeonEmitter &Emitter,
@@ -1293,7 +1304,7 @@
 }
 
 void Intrinsic::emitArgumentReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
 
   // Reverse all vector arguments.
@@ -1314,7 +1325,7 @@
 }
 
 void Intrinsic::emitReturnReversal() {
-  if (BigEndianSafe)
+  if (isBigEndianSafe())
 return;
   if (!getReturnType().isVector() || getReturnType().isVoid() ||
   getReturnType().getNumElements() == 1)
@@ -1578,7 +1589,10 @@
   Intr.Dependencies.insert(&Callee);
 
   // Now create the call itself.
-  std::string S = CallPrefix.str() + Callee.getMangledName(true) + "(";
+  std::string S = "";
+  if (!Callee.isBigEndianSafe())
+S += CallPrefix.str();
+  S += Callee.getMangledName(true) + "(";
   for (unsigned I = 0; I < DI->getNumArgs() - 1; ++I) {
 if (I != 0)
   S += ", ";
@@ -1889,6 +1903,11 @@
 }
 
 std::string Intrinsic::generate() {
+  // Avoid duplicated code for big and little endian
+  if (isBigEndianSafe()) {
+generateImpl(false, "", "");
+return OS.str();
+  }
   // Little endian intrinsics are simple and don't require any argument
   // swapping.
   OS << "#ifdef __LITTLE_ENDIAN__\n";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66302: [SVE][Inline-Asm] Support for SVE asm operands

2019-09-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp:5836-5837
   if (VT.getSizeInBits() == 128)
 return std::make_pair(0U, &AArch64::FPR128_loRegClass);
+case 'y':
+  if (!Subtarget->hasFPARMv8())

```
AArch64ISelLowering.cpp:5837:5: warning: unannotated fall-through between 
switch labels [-Wimplicit-fallthrough]
AArch64ISelLowering.cpp:5837:5: note: insert 'LLVM_FALLTHROUGH;' to silence 
this warning
AArch64ISelLowering.cpp:5837:5: note: insert 'break;' to avoid fall-through
```

Is the fallthrough intentional?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66302/new/

https://reviews.llvm.org/D66302



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


[PATCH] D66042: [analyzer] Analysis: Silence checkers

2019-09-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added a comment.

In D66042#1655119 , @sylvestre.ledru 
wrote:

> @Charusso This probably should be added to the release notes:
>  https://clang.llvm.org/docs/ReleaseNotes.html#static-analyzer
>  and detailed in the doc.
>  Please let me know if you need help!


For the time being, we are keeping this as a developer only feature, but we're 
working on potentially promoting it to a regular frontend flag!


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66042/new/

https://reviews.llvm.org/D66042



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


[PATCH] D66945: [clang-tidy] Fix a false positive in unused-using-decl check.

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 218422.
hokein marked an inline comment as done.
hokein added a comment.

Use a matcher to catch all template arguments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66945/new/

https://reviews.llvm.org/D66945

Files:
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  class P {};
 const int Constant = 0;
 
+template  class Q {};
+
 class Base {
  public:
   void f();
@@ -169,6 +171,8 @@
 using n::Constant;
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
 
+using n::Q;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -202,3 +206,8 @@
 template 
 void i(n::P* t) {}
 template void i(n::P* t);
+
+template  class U> class Bar {};
+// We used to report Q unsued, because we only checked the first template
+// argument.
+Bar *bar;
Index: clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -17,6 +17,27 @@
 namespace tidy {
 namespace misc {
 
+// FIXME: Move ASTMatcher library.
+AST_POLYMORPHIC_MATCHER_P(
+forEachTemplateArgument,
+AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,
+TemplateSpecializationType, FunctionDecl),
+clang::ast_matchers::internal::Matcher, InnerMatcher) {
+  ArrayRef TemplateArgs =
+  clang::ast_matchers::internal::getTemplateSpecializationArgs(Node);
+  clang::ast_matchers::internal::BoundNodesTreeBuilder Result;
+  bool Matched = false;
+  for (const auto &Arg : TemplateArgs) {
+clang::ast_matchers::internal::BoundNodesTreeBuilder ArgBuilder(*Builder);
+if (InnerMatcher.matches(Arg, Finder, &ArgBuilder)) {
+  Matched = true;
+  Result.addMatch(ArgBuilder);
+}
+  }
+  *Builder = std::move(Result);
+  return Matched;
+}
+
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
 // checked. Only variable, function, function template, class template, class,
 // enum declaration and enum constant declaration are considered.
@@ -37,11 +58,10 @@
   Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
  this);
   Finder->addMatcher(
-  callExpr(hasDeclaration(functionDecl(hasAnyTemplateArgument(
-  anyOf(refersToTemplate(templateName().bind("used")),
-refersToDeclaration(functionDecl().bind("used"))),
+  callExpr(hasDeclaration(functionDecl(
+  forEachTemplateArgument(templateArgument().bind("used"),
   this);
-  Finder->addMatcher(loc(templateSpecializationType(hasAnyTemplateArgument(
+  Finder->addMatcher(loc(templateSpecializationType(forEachTemplateArgument(
  templateArgument().bind("used",
  this);
 }
@@ -85,47 +105,43 @@
   // corresponding using declaration has been found.
   // FIXME: This currently doesn't look at whether the type reference is
   // actually found with the help of the using declaration.
-  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+  auto RemoveNamedDecl = [&](const NamedDecl *Used) {
+removeFromFoundDecls(Used);
+// Also remove variants of Used.
 if (const auto *FD = dyn_cast(Used)) {
   removeFromFoundDecls(FD->getPrimaryTemplate());
 } else if (const auto *Specialization =
dyn_cast(Used)) {
-  Used = Specialization->getSpecializedTemplate();
+  removeFromFoundDecls(Specialization->getSpecializedTemplate());
+} else if (const auto *FD = dyn_cast(Used)) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT);
+} else if (const auto *ECD = dyn_cast(Used)) {
+  if (const auto *ET = ECD->getType()->getAs())
+removeFromFoundDecls(ET->getDecl());
 }
-removeFromFoundDecls(Used);
+  };
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+RemoveNamedDecl(Used);
 return;
   }
 
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
-// FIXME: Support non-type template parameters.
 if (Used->getKind() == TemplateArgument::Template) {
   if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
 removeFromFoundDecls(TD);
 } else if (Used->getKind() == TemplateArgument::Type) {
   if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
 removeFromFoundDecls(RD);
+} else if (Used->getKind() == TemplateArgument::Declaration) {
+  RemoveNamedDecl(Used->get

[PATCH] D66945: [clang-tidy] Fix a false positive in unused-using-decl check.

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 218423.
hokein added a comment.

minor fix


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66945/new/

https://reviews.llvm.org/D66945

Files:
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  class P {};
 const int Constant = 0;
 
+template  class Q {};
+
 class Base {
  public:
   void f();
@@ -169,6 +171,8 @@
 using n::Constant;
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
 
+using n::Q;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -202,3 +206,8 @@
 template 
 void i(n::P* t) {}
 template void i(n::P* t);
+
+template  class U> class Bar {};
+// We used to report Q unsued, because we only checked the first template
+// argument.
+Bar *bar;
Index: clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -17,6 +17,29 @@
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move ASTMatcher library.
+AST_POLYMORPHIC_MATCHER_P(
+forEachTemplateArgument,
+AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,
+TemplateSpecializationType, FunctionDecl),
+clang::ast_matchers::internal::Matcher, InnerMatcher) {
+  ArrayRef TemplateArgs =
+  clang::ast_matchers::internal::getTemplateSpecializationArgs(Node);
+  clang::ast_matchers::internal::BoundNodesTreeBuilder Result;
+  bool Matched = false;
+  for (const auto &Arg : TemplateArgs) {
+clang::ast_matchers::internal::BoundNodesTreeBuilder ArgBuilder(*Builder);
+if (InnerMatcher.matches(Arg, Finder, &ArgBuilder)) {
+  Matched = true;
+  Result.addMatch(ArgBuilder);
+}
+  }
+  *Builder = std::move(Result);
+  return Matched;
+}
+} // namespace
+
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
 // checked. Only variable, function, function template, class template, class,
 // enum declaration and enum constant declaration are considered.
@@ -37,11 +60,10 @@
   Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
  this);
   Finder->addMatcher(
-  callExpr(hasDeclaration(functionDecl(hasAnyTemplateArgument(
-  anyOf(refersToTemplate(templateName().bind("used")),
-refersToDeclaration(functionDecl().bind("used"))),
+  callExpr(hasDeclaration(functionDecl(
+  forEachTemplateArgument(templateArgument().bind("used"),
   this);
-  Finder->addMatcher(loc(templateSpecializationType(hasAnyTemplateArgument(
+  Finder->addMatcher(loc(templateSpecializationType(forEachTemplateArgument(
  templateArgument().bind("used",
  this);
 }
@@ -85,47 +107,43 @@
   // corresponding using declaration has been found.
   // FIXME: This currently doesn't look at whether the type reference is
   // actually found with the help of the using declaration.
-  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+  auto RemoveNamedDecl = [&](const NamedDecl *Used) {
+removeFromFoundDecls(Used);
+// Also remove variants of Used.
 if (const auto *FD = dyn_cast(Used)) {
   removeFromFoundDecls(FD->getPrimaryTemplate());
 } else if (const auto *Specialization =
dyn_cast(Used)) {
-  Used = Specialization->getSpecializedTemplate();
+  removeFromFoundDecls(Specialization->getSpecializedTemplate());
+} else if (const auto *FD = dyn_cast(Used)) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT);
+} else if (const auto *ECD = dyn_cast(Used)) {
+  if (const auto *ET = ECD->getType()->getAs())
+removeFromFoundDecls(ET->getDecl());
 }
-removeFromFoundDecls(Used);
+  };
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+RemoveNamedDecl(Used);
 return;
   }
 
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
-// FIXME: Support non-type template parameters.
 if (Used->getKind() == TemplateArgument::Template) {
   if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
 removeFromFoundDecls(TD);
 } else if (Used->getKind() == TemplateArgument::Type) {
   if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
 removeFromFoundDecls(RD);
+} else if (Used->getKind() == TemplateArgument::Declaration) {
+  RemoveNamedDecl(Used->getAsDecl());
 }
 return;
   }
 
-  if (con

r370737 - Added fixit notes for -Wfinal-dtor-non-final-class

2019-09-03 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Tue Sep  3 03:32:21 2019
New Revision: 370737

URL: http://llvm.org/viewvc/llvm-project?rev=370737&view=rev
Log:
Added fixit notes for -Wfinal-dtor-non-final-class

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=370737&r1=370736&r2=370737&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep  3 03:32:21 2019
@@ -6241,10 +6241,14 @@ void Sema::CheckCompletedCXXClass(CXXRec
 if (const CXXDestructorDecl *dtor = Record->getDestructor()) {
   if (const FinalAttr *FA = dtor->getAttr()) {
 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
-  << FA->isSpelledAsSealed();
-Diag(Record->getLocation(), 
diag::note_final_dtor_non_final_class_silence)
-  << Context.getRecordType(Record)
-  << FA->isSpelledAsSealed();
+<< FA->isSpelledAsSealed()
+<< FixItHint::CreateRemoval(FA->getLocation())
+<< FixItHint::CreateInsertion(
+   getLocForEndOfToken(Record->getLocation()),
+   (FA->isSpelledAsSealed() ? " sealed" : " final"));
+Diag(Record->getLocation(),
+ diag::note_final_dtor_non_final_class_silence)
+<< Context.getRecordType(Record) << FA->isSpelledAsSealed();
   }
 }
   }

Modified: cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp?rev=370737&r1=370736&r2=370737&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp Tue Sep  3 
03:32:21 2019
@@ -1,11 +1,14 @@
 // RUN: %clang_cc1 -fsyntax-only -std=c++11 -verify %s 
-Wfinal-dtor-non-final-class
+// RUN: %clang_cc1 -fsyntax-only -std=c++11 %s -Wfinal-dtor-non-final-class 
-fdiagnostics-parseable-fixits 2>&1 | FileCheck %s
 
 class A {
 ~A();
 };
 
 class B { // expected-note {{mark 'B' as 'final' to silence this warning}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:8-[[@LINE-1]]:8}:" final"
 virtual ~B() final; // expected-warning {{class with destructor marked 
'final' cannot be inherited from}}
+// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:23}:""
 };
 
 class C final {


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


[PATCH] D66711: [clang] Warning for non-final classes with final destructors

2019-09-03 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 added a comment.

rL370737 


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66711/new/

https://reviews.llvm.org/D66711



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


[PATCH] D66951: [ASTImporter] Add comprehensive tests for ODR violation handling strategies

2019-09-03 Thread Balázs Kéri via Phabricator via cfe-commits
balazske added inline comments.



Comment at: clang/unittests/AST/ASTImporterODRStrategiesTest.cpp:1
+//===- unittest/AST/ASTImporterTest.cpp - AST node import test 
===//
+//

Change the file name here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66951/new/

https://reviews.llvm.org/D66951



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


[PATCH] D67091: Fix for headers having the same name as a directory

2019-09-03 Thread Kousik Kumar via Phabricator via cfe-commits
kousikk created this revision.
kousikk added a reviewer: arphaman.
Herald added subscribers: cfe-commits, jfb, dexonsmith.
Herald added a project: clang.

Scan deps tool crashes when called on a C++ file, containing an include
that has the same name as a directory. For example:

test.cpp:
#include 
int main() { return 0; }

In directory foo/ :
dir/ bar/dir(file)

Now if the compile command is:
clang++ -I foo/ -I foo/bar/ -c test.cpp

The tool crashes since it finds foo/dir and tries to read that as a file and 
fails.
In this change, I add a defence against that scenario in the Dependency Scanning
File system.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67091

Files:
  clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
  clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -190,8 +190,11 @@
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
   // Check the local cache first.
-  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename))
-return createFile(Entry);
+  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) {
+if (Entry->isDirectory()) {
+  return 
llvm::ErrorOr>(std::make_error_code(std::errc::is_a_directory));
+}
+  }
 
   // FIXME: Handle PCM/PCH files.
   // FIXME: Handle module map files.
Index: 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ 
clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -55,6 +55,11 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const {
+return MaybeStat && MaybeStat->isDirectory();
+  }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)


Index: clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
===
--- clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
+++ clang/lib/Tooling/DependencyScanning/DependencyScanningFilesystem.cpp
@@ -190,8 +190,11 @@
   StringRef Filename = Path.toStringRef(OwnedFilename);
 
   // Check the local cache first.
-  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename))
-return createFile(Entry);
+  if (const CachedFileSystemEntry *Entry = getCachedEntry(Filename)) {
+if (Entry->isDirectory()) {
+  return llvm::ErrorOr>(std::make_error_code(std::errc::is_a_directory));
+}
+  }
 
   // FIXME: Handle PCM/PCH files.
   // FIXME: Handle module map files.
Index: clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
===
--- clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
+++ clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h
@@ -55,6 +55,11 @@
   /// \returns True if the entry is valid.
   bool isValid() const { return !MaybeStat || MaybeStat->isStatusKnown(); }
 
+  /// \returns True if the current entry points to a directory.
+  bool isDirectory() const {
+return MaybeStat && MaybeStat->isDirectory();
+  }
+
   /// \returns The error or the file's contents.
   llvm::ErrorOr getContents() const {
 if (!MaybeStat)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r370740 - Fixit for -Wfinal-dtor-non-final-class

2019-09-03 Thread David Bolvansky via cfe-commits
Author: xbolva00
Date: Tue Sep  3 03:54:25 2019
New Revision: 370740

URL: http://llvm.org/viewvc/llvm-project?rev=370740&view=rev
Log:
Fixit for -Wfinal-dtor-non-final-class

Modified:
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp

Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=370740&r1=370739&r2=370740&view=diff
==
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Tue Sep  3 03:54:25 2019
@@ -6242,7 +6242,6 @@ void Sema::CheckCompletedCXXClass(CXXRec
   if (const FinalAttr *FA = dtor->getAttr()) {
 Diag(FA->getLocation(), diag::warn_final_dtor_non_final_class)
 << FA->isSpelledAsSealed()
-<< FixItHint::CreateRemoval(FA->getLocation())
 << FixItHint::CreateInsertion(
getLocForEndOfToken(Record->getLocation()),
(FA->isSpelledAsSealed() ? " sealed" : " final"));

Modified: cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp?rev=370740&r1=370739&r2=370740&view=diff
==
--- cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp (original)
+++ cfe/trunk/test/SemaCXX/warn-final-dtor-non-final-class.cpp Tue Sep  3 
03:54:25 2019
@@ -8,7 +8,6 @@ class A {
 class B { // expected-note {{mark 'B' as 'final' to silence this warning}}
 // CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:8-[[@LINE-1]]:8}:" final"
 virtual ~B() final; // expected-warning {{class with destructor marked 
'final' cannot be inherited from}}
-// CHECK: fix-it:"{{.*}}":{[[@LINE-1]]:18-[[@LINE-1]]:23}:""
 };
 
 class C final {


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


[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
sammccall added reviewers: hokein, kadircet.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Relegate "updating the extension" docs to a separate file.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67092

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/clangd/clients/clangd-vscode/README.md
  clang-tools-extra/clangd/clients/clangd-vscode/complete.png
  clang-tools-extra/clangd/clients/clangd-vscode/diagnostics.png
  clang-tools-extra/clangd/clients/clangd-vscode/format.png
  clang-tools-extra/clangd/clients/clangd-vscode/include.png
  clang-tools-extra/clangd/clients/clangd-vscode/symbolsearch.png
  clang-tools-extra/clangd/clients/clangd-vscode/xrefs.png

Index: clang-tools-extra/clangd/clients/clangd-vscode/README.md
===
--- clang-tools-extra/clangd/clients/clangd-vscode/README.md
+++ clang-tools-extra/clangd/clients/clangd-vscode/README.md
@@ -1,81 +1,89 @@
 # vscode-clangd
 
-Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html).
+Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html):
 
-## Usage
+ - code completion
+ - compile errors and warnings
+ - go-to-definition and cross references
+ - include management
+ - code formatting
 
-`vscode-clangd` provides the features designated by the [Language Server
-Protocol](https://github.com/Microsoft/language-server-protocol), such as
-code completion, code formatting and goto definition.
+## Setup
 
-**Note**: `clangd` is under heavy development, not all LSP features are
-implemented. See [Current Status](https://clang.llvm.org/extra/clangd/Features.html#complete-list-of-features)
-for details.
+### `clangd` server
 
-To use `vscode-clangd` extension in VS Code, you need to install `vscode-clangd`
-from VS Code extension marketplace.
+`clangd` is a language server that must be installed separately, see
+[https://clangd.github.io/installation.html](getting started).
+The vscode-clangd plugin will look for `clangd` on your PATH (you can change
+this in the settings).
 
-`vscode-clangd` will attempt to find the `clangd` binary on your `PATH`.
-Alternatively, the `clangd` executable can be specified in your VS Code
-`settings.json` file:
+### Project setup
 
-```json
-{
-"clangd.path": "/absolute/path/to/clangd"
-}
-```
+clangd is based on the clang C++ compiler, and understands even complex C++
+code.  However, you must tell clangd how your project is built (compile flags).
+[A `compile_commands.json` file](http://clang.llvm.org/docs/JSONCompilationDatabase.html)
+can usually be generated by your build system
+(e.g. by setting `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` when building with CMake,
+or with
+[many other tools](https://sarcasm.github.io/notes/dev/compilation-database.html)).
 
-To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd/Installation.html#installing-clangd).
+It should live at the top of your source tree: symlink or copy it there.
 
-## Development
+## Features
 
-A guide of developing `vscode-clangd` extension.
+### Code completion
 
-### Requirements
+Suggestions will appear as you type names, or after `.` or `->`.
+Because clangd uses a full C++ parser, code completion has access to precise
+type information.
 
-* VS Code
-* node.js and npm
+![Code completion](complete.png)
 
-### Steps
+### Errors, warnings, and clang-tidy
 
-1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
-2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
-point to the binary.
-3. In order to start a development instance of VS code extended with this, run:
+Code errors are shown as you type (both as red squiggle underlines, and in the
+"Problems" panel). These are the same as produced by the clang compiler, and
+suggested fixes can automatically be applied.
 
-```bash
-   $ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
-   $ npm install
-   $ code .
-   # When VS Code starts, press .
-```
+![Error with fix](diagnostics.png)
 
-## Contributing
+Most clang-tidy checks are supported (these can be enabled using a [.clang-tidy
+file](https://clang.llvm.org/extra/clang-tidy/)).
 
-Please follow the exsiting code style when contributing to the extension, we
-recommend to run `npm run format` before sending a patch.
+### Cross-references
 
-## Publish to VS Code Marketplace
+Go-to-definition and find-references work across your code, using a project-wide
+index.
 
-New changes to `clangd-vscode` are not released until a new version is published
-to the marketplace.
+![Cross-reference list](xrefs.png)
 
-### Requirements
+Press `Ctrl-P #` to quickly navigate to a symbol by name.
 
-* Make sure install the `vsce` command (`npm install -g vsce`

[PATCH] D66751: [clangd] Add targetDecl(), which determines what declaration an AST node refers to.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 218432.
sammccall added a comment.

fix accidental reverted change


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66751/new/

https://reviews.llvm.org/D66751

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/FindTarget.cpp
  clang-tools-extra/clangd/FindTarget.h
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/clangd/unittests/FindTargetTests.cpp
===
--- /dev/null
+++ clang-tools-extra/clangd/unittests/FindTargetTests.cpp
@@ -0,0 +1,468 @@
+//===-- FindSymbolsTests.cpp -*- C++ -*===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+#include "FindTarget.h"
+
+#include "Selection.h"
+#include "TestTU.h"
+#include "llvm/Support/raw_ostream.h"
+#include "llvm/Testing/Support/Annotations.h"
+#include "gmock/gmock.h"
+#include "gtest/gtest.h"
+#include 
+
+namespace clang {
+namespace clangd {
+namespace {
+
+// A referenced Decl together with its DeclRelationSet, for assertions.
+//
+// There's no great way to assert on the "content" of a Decl in the general case
+// that's both expressive and unambiguous (e.g. clearly distinguishes between
+// templated decls and their specializations).
+//
+// We use the result of pretty-printing the decl, with the {body} truncated.
+struct PrintedDecl {
+  PrintedDecl(const char *Name, DeclRelationSet Relations = {})
+  : Name(Name), Relations(Relations) {}
+  PrintedDecl(const Decl *D, DeclRelationSet Relations = {})
+  : Relations(Relations) {
+std::string S;
+llvm::raw_string_ostream OS(S);
+D->print(OS);
+llvm::StringRef FirstLine =
+llvm::StringRef(OS.str()).take_until([](char C) { return C == '\n'; });
+FirstLine = FirstLine.rtrim(" {");
+Name = FirstLine.rtrim(" {");
+  }
+
+  std::string Name;
+  DeclRelationSet Relations;
+};
+bool operator==(const PrintedDecl &L, const PrintedDecl &R) {
+  return std::tie(L.Name, L.Relations) == std::tie(R.Name, R.Relations);
+}
+llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, const PrintedDecl &D) {
+  return OS << D.Name << " Rel=" << D.Relations;
+}
+
+// The test cases in for targetDecl() take the form
+//  - a piece of code (Code = "...")
+//  - Code should have a single AST node marked as a [[range]]
+//  - an EXPECT_DECLS() assertion that verify the type of node selected, and
+//all the decls that targetDecl() considers it to reference
+// Despite the name, these cases actually test allTargetDecls() for brevity.
+class TargetDeclTest : public ::testing::Test {
+protected:
+  using Rel = DeclRelation;
+  std::string Code;
+  std::vector Flags;
+
+  // Asserts that `Code` has a marked selection of a node `NodeType`,
+  // and returns allTargetDecls() as PrintedDecl structs.
+  // Use via EXPECT_DECLS().
+  std::vector assertNodeAndPrintDecls(const char *NodeType) {
+llvm::Annotations A(Code);
+auto TU = TestTU::withCode(A.code());
+TU.ExtraArgs = Flags;
+auto AST = TU.build();
+EXPECT_THAT(AST.getDiagnostics(), ::testing::IsEmpty()) << Code;
+llvm::Annotations::Range R = A.range();
+SelectionTree Selection(AST.getASTContext(), AST.getTokens(), R.Begin,
+R.End);
+const SelectionTree::Node *N = Selection.commonAncestor();
+if (!N) {
+  ADD_FAILURE() << "No node selected!\n" << Code;
+  return {};
+}
+EXPECT_EQ(N->kind(), NodeType) << Selection;
+
+std::vector ActualDecls;
+for (const auto &Entry : allTargetDecls(N->ASTNode))
+  ActualDecls.emplace_back(Entry.first, Entry.second);
+return ActualDecls;
+  }
+};
+
+// This is a macro to preserve line numbers in assertion failures.
+// It takes the expected decls as varargs to work around comma-in-macro issues.
+#define EXPECT_DECLS(NodeType, ...)\
+  EXPECT_THAT(assertNodeAndPrintDecls(NodeType),   \
+  ::testing::UnorderedElementsAreArray(\
+  std::vector({__VA_ARGS__})))\
+  << Code
+using ExpectedDecls = std::vector;
+
+TEST_F(TargetDeclTest, Exprs) {
+  Code = R"cpp(
+int f();
+int x = [[f]]();
+  )cpp";
+  EXPECT_DECLS("DeclRefExpr", "int f()");
+
+  Code = R"cpp(
+struct S { S operator+(S) const; };
+auto X = S() [[+]] S();
+  )cpp";
+  EXPECT_DECLS("DeclRefExpr", "S operator+(S) const");
+}
+
+TEST_F(TargetDeclTest, UsingDecl) {
+  Code = R"cpp(
+namespace foo {
+  int f(in

r370744 - [OpenCL] Drop spurious semicolon in generated file; NFC

2019-09-03 Thread Sven van Haastregt via cfe-commits
Author: svenvh
Date: Tue Sep  3 04:23:24 2019
New Revision: 370744

URL: http://llvm.org/viewvc/llvm-project?rev=370744&view=rev
Log:
[OpenCL] Drop spurious semicolon in generated file; NFC

Modified:
cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp

Modified: cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp?rev=370744&r1=370743&r2=370744&view=diff
==
--- cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp (original)
+++ cfe/trunk/utils/TableGen/ClangOpenCLBuiltinEmitter.cpp Tue Sep  3 04:23:24 
2019
@@ -473,7 +473,7 @@ static void OCL2Qual(ASTContext &Context
<< T->getValueAsDef("QTName")->getValueAsString("Name") << ", ";
   }
 }
-OS << "});\n;";
+OS << "});\n";
 // GenTypeNumTypes is the number of types in the GenType
 // (e.g. float/double/half).
 OS << "  GenTypeNumTypes = "


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


[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet accepted this revision.
kadircet added a comment.
This revision is now accepted and ready to land.

LGTM, thanks for working on this!




Comment at: clang-tools-extra/clangd/clients/clangd-vscode/README.md:5
 
-## Usage
+ - code completion
+ - compile errors and warnings

can we also have links to sections below?



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/README.md:9
+ - include management
+ - code formatting
 

what about code-actions(and also some screenshots)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092



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


[PATCH] D66572: [analyzer] NFC: BugReporter Separation Ep.I.

2019-09-03 Thread Kristóf Umann via Phabricator via cfe-commits
Szelethus added inline comments.



Comment at: 
clang/include/clang/StaticAnalyzer/Core/BugReporter/BugReporter.h:108
+
+  StringRef getDescription() const { return Description; }
+

gribozavr wrote:
> What's the difference between description and short description?
> 
> What are the expected grammatical conventions? For example, Clang and 
> ClangTidy warning are sentence fragments that start with a lowercase letter 
> and don't end with a period.
I just did some work related to this! For 99% of the cases (and for one, I'm 
pretty sure this estimate is quite accurate) there is no difference. AFAIK 
CodeChecker doesnt even use the short description field emitted in the plist 
output.

There is one checker however that uses it, RetainCount, though I dislike that 
particular case (the short version is something like "the counter here isn't 
zero", and the full version is "the counter here is +2"). Could we get rid of 
this?

As for diagnostic messages, we start with uppercase but dont terminate the 
sentence.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66572/new/

https://reviews.llvm.org/D66572



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


[PATCH] D66945: [clang-tidy] Fix a false positive in unused-using-decl check.

2019-09-03 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp:105
   }
   // Mark using declarations as used by setting FoundDecls' value to zero. As
   // the AST is walked in order, usages are only marked after a the

Please move the comment below the lambda. The lambda is not doing what this 
comment says.



Comment at: clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp:138
 removeFromFoundDecls(RD);
+} else if (Used->getKind() == TemplateArgument::Declaration) {
+  RemoveNamedDecl(Used->getAsDecl());

Could you add a test for this case?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66945/new/

https://reviews.llvm.org/D66945



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


[clang-tools-extra] r370746 - [clangd] Add targetDecl(), which determines what declaration an AST node refers to.

2019-09-03 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Sep  3 04:35:50 2019
New Revision: 370746

URL: http://llvm.org/viewvc/llvm-project?rev=370746&view=rev
Log:
[clangd] Add targetDecl(), which determines what declaration an AST node refers 
to.

Summary:
This is the first part of an effort to "unbundle" our libIndex use into separate
concerns (AST traversal, token<->node mapping, node<->decl mapping,
decl<->decl relationshipes).

Currently, clangd relies on libIndex to associate tokens, AST nodes, and decls.
This leads to rather convoluted implementations of e.g. hover and
extract-function, which are not naturally thought of as indexing applications.

The idea is that by decoupling different concerns, we make them easier
to use, test, and combine, and more efficient when only one part is needed.
There are some synergies between e.g. traversal and finding
relationships between decls, hopefully the benefits outweight these.

Reviewers: kadircet, ilya-biryukov

Subscribers: mgorny, MaskRay, jkorous, arphaman, jfb, cfe-commits

Tags: #clang

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

Added:
clang-tools-extra/trunk/clangd/FindTarget.cpp
clang-tools-extra/trunk/clangd/FindTarget.h
clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp
Modified:
clang-tools-extra/trunk/clangd/CMakeLists.txt
clang-tools-extra/trunk/clangd/unittests/ASTTests.cpp
clang-tools-extra/trunk/clangd/unittests/CMakeLists.txt

Modified: clang-tools-extra/trunk/clangd/CMakeLists.txt
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CMakeLists.txt?rev=370746&r1=370745&r2=370746&view=diff
==
--- clang-tools-extra/trunk/clangd/CMakeLists.txt (original)
+++ clang-tools-extra/trunk/clangd/CMakeLists.txt Tue Sep  3 04:35:50 2019
@@ -48,6 +48,7 @@ add_clang_library(clangDaemon
   DraftStore.cpp
   ExpectedTypes.cpp
   FindSymbols.cpp
+  FindTarget.cpp
   FileDistance.cpp
   Format.cpp
   FS.cpp

Added: clang-tools-extra/trunk/clangd/FindTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindTarget.cpp?rev=370746&view=auto
==
--- clang-tools-extra/trunk/clangd/FindTarget.cpp (added)
+++ clang-tools-extra/trunk/clangd/FindTarget.cpp Tue Sep  3 04:35:50 2019
@@ -0,0 +1,381 @@
+//===--- FindTarget.cpp - What does an AST node refer to? 
-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM 
Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "FindTarget.h"
+#include "AST.h"
+#include "Logger.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DeclVisitor.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/ExprObjC.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLocVisitor.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+LLVM_DUMP_METHOD std::string
+nodeToString(const ast_type_traits::DynTypedNode &N) {
+  std::string S = N.getNodeKind().asStringRef();
+  {
+llvm::raw_string_ostream OS(S);
+OS << ": ";
+N.print(OS, PrintingPolicy(LangOptions()));
+  }
+  std::replace(S.begin(), S.end(), '\n', ' ');
+  return S;
+}
+
+// TargetFinder locates the entities that an AST node refers to.
+//
+// Typically this is (possibly) one declaration and (possibly) one type, but
+// may be more:
+//  - for ambiguous nodes like OverloadExpr
+//  - if we want to include e.g. both typedefs and the underlying type
+//
+// This is organized as a set of mutually recursive helpers for particular node
+// types, but for most nodes this is a short walk rather than a deep traversal.
+//
+// It's tempting to do e.g. typedef resolution as a second normalization step,
+// after finding the 'primary' decl etc. But we do this monolithically instead
+// because:
+//  - normalization may require these traversals again (e.g. unwrapping a
+//typedef reveals a decltype which must be traversed)
+//  - it doesn't simplify that much, e.g. the first stage must still be able
+//to yield multiple decls to handle OverloadExpr
+//  - there are cases where it's required for correctness. e.g:
+//  template using pvec = vector; pvec x;
+//There's no Decl `pvec`, we must choose `pvec` or `vector`
+//and both are lossy. We must know upfront what the caller ultimately 
wants.
+//
+// FIXME: improve common dependent scope using name lookup in primary 
templates.
+// e.g. template int foo() { return std::vector().size(); }
+// formally size

[PATCH] D66751: [clangd] Add targetDecl(), which determines what declaration an AST node refers to.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370746: [clangd] Add targetDecl(), which determines what 
declaration an AST node refers… (authored by sammccall, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66751?vs=218432&id=218435#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66751/new/

https://reviews.llvm.org/D66751

Files:
  clang-tools-extra/trunk/clangd/CMakeLists.txt
  clang-tools-extra/trunk/clangd/FindTarget.cpp
  clang-tools-extra/trunk/clangd/FindTarget.h
  clang-tools-extra/trunk/clangd/unittests/ASTTests.cpp
  clang-tools-extra/trunk/clangd/unittests/CMakeLists.txt
  clang-tools-extra/trunk/clangd/unittests/FindTargetTests.cpp

Index: clang-tools-extra/trunk/clangd/FindTarget.cpp
===
--- clang-tools-extra/trunk/clangd/FindTarget.cpp
+++ clang-tools-extra/trunk/clangd/FindTarget.cpp
@@ -0,0 +1,381 @@
+//===--- FindTarget.cpp - What does an AST node refer to? -===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#include "FindTarget.h"
+#include "AST.h"
+#include "Logger.h"
+#include "clang/AST/ASTTypeTraits.h"
+#include "clang/AST/DeclCXX.h"
+#include "clang/AST/DeclTemplate.h"
+#include "clang/AST/DeclVisitor.h"
+#include "clang/AST/DeclarationName.h"
+#include "clang/AST/ExprObjC.h"
+#include "clang/AST/StmtVisitor.h"
+#include "clang/AST/Type.h"
+#include "clang/AST/TypeLocVisitor.h"
+#include "clang/Basic/SourceLocation.h"
+#include "llvm/Support/Casting.h"
+#include "llvm/Support/Compiler.h"
+#include "llvm/Support/raw_ostream.h"
+
+namespace clang {
+namespace clangd {
+namespace {
+
+LLVM_DUMP_METHOD std::string
+nodeToString(const ast_type_traits::DynTypedNode &N) {
+  std::string S = N.getNodeKind().asStringRef();
+  {
+llvm::raw_string_ostream OS(S);
+OS << ": ";
+N.print(OS, PrintingPolicy(LangOptions()));
+  }
+  std::replace(S.begin(), S.end(), '\n', ' ');
+  return S;
+}
+
+// TargetFinder locates the entities that an AST node refers to.
+//
+// Typically this is (possibly) one declaration and (possibly) one type, but
+// may be more:
+//  - for ambiguous nodes like OverloadExpr
+//  - if we want to include e.g. both typedefs and the underlying type
+//
+// This is organized as a set of mutually recursive helpers for particular node
+// types, but for most nodes this is a short walk rather than a deep traversal.
+//
+// It's tempting to do e.g. typedef resolution as a second normalization step,
+// after finding the 'primary' decl etc. But we do this monolithically instead
+// because:
+//  - normalization may require these traversals again (e.g. unwrapping a
+//typedef reveals a decltype which must be traversed)
+//  - it doesn't simplify that much, e.g. the first stage must still be able
+//to yield multiple decls to handle OverloadExpr
+//  - there are cases where it's required for correctness. e.g:
+//  template using pvec = vector; pvec x;
+//There's no Decl `pvec`, we must choose `pvec` or `vector`
+//and both are lossy. We must know upfront what the caller ultimately wants.
+//
+// FIXME: improve common dependent scope using name lookup in primary templates.
+// e.g. template int foo() { return std::vector().size(); }
+// formally size() is unresolved, but the primary template is a good guess.
+// This affects:
+//  - DependentTemplateSpecializationType,
+//  - DependentScopeMemberExpr
+//  - DependentScopeDeclRefExpr
+//  - DependentNameType
+struct TargetFinder {
+  using RelSet = DeclRelationSet;
+  using Rel = DeclRelation;
+  llvm::SmallDenseMap Decls;
+  RelSet Flags;
+
+  static const Decl *getTemplatePattern(const Decl *D) {
+if (const CXXRecordDecl *CRD = dyn_cast(D)) {
+  return CRD->getTemplateInstantiationPattern();
+} else if (const FunctionDecl *FD = dyn_cast(D)) {
+  return FD->getTemplateInstantiationPattern();
+} else if (auto *VD = dyn_cast(D)) {
+  // Hmm: getTIP returns its arg if it's not an instantiation?!
+  VarDecl *T = VD->getTemplateInstantiationPattern();
+  return (T == D) ? nullptr : T;
+} else if (const auto *ED = dyn_cast(D)) {
+  return ED->getInstantiatedFromMemberEnum();
+} else if (isa(D) || isa(D)) {
+  const auto *ND = cast(D);
+  if (const DeclContext *Parent = dyn_cast_or_null(
+  getTemplatePattern(llvm::cast(ND->getDeclContext()
+for (const NamedDecl *BaseND : Parent->lookup(ND->getDeclName()))
+  if (!BaseND->isImplicit() && BaseND->getKind() == ND->getKind())
+return BaseND;
+} else if (const auto *ECD 

[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 218436.
sammccall added a comment.

describe refactoring features


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/clangd/clients/clangd-vscode/README.md
  clang-tools-extra/clangd/clients/clangd-vscode/complete.png
  clang-tools-extra/clangd/clients/clangd-vscode/diagnostics.png
  clang-tools-extra/clangd/clients/clangd-vscode/extract.png
  clang-tools-extra/clangd/clients/clangd-vscode/format.png
  clang-tools-extra/clangd/clients/clangd-vscode/include.png
  clang-tools-extra/clangd/clients/clangd-vscode/symbolsearch.png
  clang-tools-extra/clangd/clients/clangd-vscode/xrefs.png

Index: clang-tools-extra/clangd/clients/clangd-vscode/README.md
===
--- clang-tools-extra/clangd/clients/clangd-vscode/README.md
+++ clang-tools-extra/clangd/clients/clangd-vscode/README.md
@@ -1,81 +1,102 @@
 # vscode-clangd
 
-Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html).
+Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html):
 
-## Usage
+ - code completion
+ - compile errors and warnings
+ - go-to-definition and cross references
+ - include management
+ - code formatting
+ - simple refactorings
 
-`vscode-clangd` provides the features designated by the [Language Server
-Protocol](https://github.com/Microsoft/language-server-protocol), such as
-code completion, code formatting and goto definition.
+## Setup
 
-**Note**: `clangd` is under heavy development, not all LSP features are
-implemented. See [Current Status](https://clang.llvm.org/extra/clangd/Features.html#complete-list-of-features)
-for details.
+### `clangd` server
 
-To use `vscode-clangd` extension in VS Code, you need to install `vscode-clangd`
-from VS Code extension marketplace.
+`clangd` is a language server that must be installed separately, see
+[https://clangd.github.io/installation.html](getting started).
+The vscode-clangd plugin will look for `clangd` on your PATH (you can change
+this in the settings).
 
-`vscode-clangd` will attempt to find the `clangd` binary on your `PATH`.
-Alternatively, the `clangd` executable can be specified in your VS Code
-`settings.json` file:
+### Project setup
 
-```json
-{
-"clangd.path": "/absolute/path/to/clangd"
-}
-```
+clangd is based on the clang C++ compiler, and understands even complex C++
+code.  However, you must tell clangd how your project is built (compile flags).
+[A `compile_commands.json` file](http://clang.llvm.org/docs/JSONCompilationDatabase.html)
+can usually be generated by your build system
+(e.g. by setting `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` when building with CMake,
+or with
+[many other tools](https://sarcasm.github.io/notes/dev/compilation-database.html)).
 
-To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd/Installation.html#installing-clangd).
+It should live at the top of your source tree: symlink or copy it there.
 
-## Development
+## Features
 
-A guide of developing `vscode-clangd` extension.
+### Code completion
 
-### Requirements
+Suggestions will appear as you type names, or after `.` or `->`.
+Because clangd uses a full C++ parser, code completion has access to precise
+type information.
 
-* VS Code
-* node.js and npm
+![Code completion](complete.png)
 
-### Steps
+### Errors, warnings, and clang-tidy
 
-1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
-2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
-point to the binary.
-3. In order to start a development instance of VS code extended with this, run:
+Code errors are shown as you type (both as red squiggle underlines, and in the
+"Problems" panel). These are the same as produced by the clang compiler, and
+suggested fixes can automatically be applied.
 
-```bash
-   $ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
-   $ npm install
-   $ code .
-   # When VS Code starts, press .
-```
+![Error with fix](diagnostics.png)
 
-## Contributing
+Most clang-tidy checks are supported (these can be enabled using a [.clang-tidy
+file](https://clang.llvm.org/extra/clang-tidy/)).
 
-Please follow the exsiting code style when contributing to the extension, we
-recommend to run `npm run format` before sending a patch.
+### Cross-references
 
-## Publish to VS Code Marketplace
+Go-to-definition and find-references work across your code, using a project-wide
+index.
 
-New changes to `clangd-vscode` are not released until a new version is published
-to the marketplace.
+![Cross-reference list](xrefs.png)
 
-### Requirements
+Press `Ctrl-P #` to quickly navigate to a symbol by name.
 
-* Make sure install the `vsce` command (`npm install -g

[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

could we move the png files to a separate directory like 
`clangd/clients/clangd-vscode/assets`?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092



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


[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 218437.
sammccall added a comment.

mention rename


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/clangd/clients/clangd-vscode/README.md
  clang-tools-extra/clangd/clients/clangd-vscode/complete.png
  clang-tools-extra/clangd/clients/clangd-vscode/diagnostics.png
  clang-tools-extra/clangd/clients/clangd-vscode/extract.png
  clang-tools-extra/clangd/clients/clangd-vscode/format.png
  clang-tools-extra/clangd/clients/clangd-vscode/include.png
  clang-tools-extra/clangd/clients/clangd-vscode/symbolsearch.png
  clang-tools-extra/clangd/clients/clangd-vscode/xrefs.png

Index: clang-tools-extra/clangd/clients/clangd-vscode/README.md
===
--- clang-tools-extra/clangd/clients/clangd-vscode/README.md
+++ clang-tools-extra/clangd/clients/clangd-vscode/README.md
@@ -1,81 +1,103 @@
 # vscode-clangd
 
-Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html).
+Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html):
 
-## Usage
+ - code completion
+ - compile errors and warnings
+ - go-to-definition and cross references
+ - include management
+ - code formatting
+ - simple refactorings
 
-`vscode-clangd` provides the features designated by the [Language Server
-Protocol](https://github.com/Microsoft/language-server-protocol), such as
-code completion, code formatting and goto definition.
+## Setup
 
-**Note**: `clangd` is under heavy development, not all LSP features are
-implemented. See [Current Status](https://clang.llvm.org/extra/clangd/Features.html#complete-list-of-features)
-for details.
+### `clangd` server
 
-To use `vscode-clangd` extension in VS Code, you need to install `vscode-clangd`
-from VS Code extension marketplace.
+`clangd` is a language server that must be installed separately, see
+[https://clangd.github.io/installation.html](getting started).
+The vscode-clangd plugin will look for `clangd` on your PATH (you can change
+this in the settings).
 
-`vscode-clangd` will attempt to find the `clangd` binary on your `PATH`.
-Alternatively, the `clangd` executable can be specified in your VS Code
-`settings.json` file:
+### Project setup
 
-```json
-{
-"clangd.path": "/absolute/path/to/clangd"
-}
-```
+clangd is based on the clang C++ compiler, and understands even complex C++
+code.  However, you must tell clangd how your project is built (compile flags).
+[A `compile_commands.json` file](http://clang.llvm.org/docs/JSONCompilationDatabase.html)
+can usually be generated by your build system
+(e.g. by setting `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` when building with CMake,
+or with
+[many other tools](https://sarcasm.github.io/notes/dev/compilation-database.html)).
 
-To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd/Installation.html#installing-clangd).
+It should live at the top of your source tree: symlink or copy it there.
 
-## Development
+## Features
 
-A guide of developing `vscode-clangd` extension.
+### Code completion
 
-### Requirements
+Suggestions will appear as you type names, or after `.` or `->`.
+Because clangd uses a full C++ parser, code completion has access to precise
+type information.
 
-* VS Code
-* node.js and npm
+![Code completion](complete.png)
 
-### Steps
+### Errors, warnings, and clang-tidy
 
-1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
-2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
-point to the binary.
-3. In order to start a development instance of VS code extended with this, run:
+Code errors are shown as you type (both as red squiggle underlines, and in the
+"Problems" panel). These are the same as produced by the clang compiler, and
+suggested fixes can automatically be applied.
 
-```bash
-   $ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
-   $ npm install
-   $ code .
-   # When VS Code starts, press .
-```
+![Error with fix](diagnostics.png)
 
-## Contributing
+Most clang-tidy checks are supported (these can be enabled using a [.clang-tidy
+file](https://clang.llvm.org/extra/clang-tidy/)).
 
-Please follow the exsiting code style when contributing to the extension, we
-recommend to run `npm run format` before sending a patch.
+### Cross-references
 
-## Publish to VS Code Marketplace
+Go-to-definition and find-references work across your code, using a project-wide
+index.
 
-New changes to `clangd-vscode` are not released until a new version is published
-to the marketplace.
+![Cross-reference list](xrefs.png)
 
-### Requirements
+Press `Ctrl-P #` to quickly navigate to a symbol by name.
 
-* Make sure install the `vsce` command (`npm install -g vsce`)
-* `llv

[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/README.md:95
+ - use raw strings
+ - rerame (bound to ``, rather than a contextual code action)
+

s/rerame/rename


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092



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


[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall marked 3 inline comments as done.
sammccall added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/README.md:5
 
-## Usage
+ - code completion
+ - compile errors and warnings

kadircet wrote:
> can we also have links to sections below?
The intent here is a summary rather than a TOC, and that the page is short 
enough that the first is already visible and the others would jump down only a 
screen or so. I think the links would distract more than help.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/README.md:9
+ - include management
+ - code formatting
 

kadircet wrote:
> what about code-actions(and also some screenshots)
Added a section for refactoring. (code-actions is a mechanism, but not really a 
user-visible feature I think).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092



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


[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/README.md:9
+ - include management
+ - code formatting
 

sammccall wrote:
> kadircet wrote:
> > what about code-actions(and also some screenshots)
> Added a section for refactoring. (code-actions is a mechanism, but not really 
> a user-visible feature I think).
thanks, I was implying refactorings


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092



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


[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 218438.
sammccall marked an inline comment as done.
sammccall added a comment.

move images into doc-assets/


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/clangd/clients/clangd-vscode/README.md
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/complete.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/diagnostics.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/extract.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/format.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/include.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/symbolsearch.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/xrefs.png

Index: clang-tools-extra/clangd/clients/clangd-vscode/README.md
===
--- clang-tools-extra/clangd/clients/clangd-vscode/README.md
+++ clang-tools-extra/clangd/clients/clangd-vscode/README.md
@@ -1,81 +1,103 @@
 # vscode-clangd
 
-Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html).
+Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html):
 
-## Usage
+ - code completion
+ - compile errors and warnings
+ - go-to-definition and cross references
+ - include management
+ - code formatting
+ - simple refactorings
 
-`vscode-clangd` provides the features designated by the [Language Server
-Protocol](https://github.com/Microsoft/language-server-protocol), such as
-code completion, code formatting and goto definition.
+## Setup
 
-**Note**: `clangd` is under heavy development, not all LSP features are
-implemented. See [Current Status](https://clang.llvm.org/extra/clangd/Features.html#complete-list-of-features)
-for details.
+### `clangd` server
 
-To use `vscode-clangd` extension in VS Code, you need to install `vscode-clangd`
-from VS Code extension marketplace.
+`clangd` is a language server that must be installed separately, see
+[https://clangd.github.io/installation.html](getting started).
+The vscode-clangd plugin will look for `clangd` on your PATH (you can change
+this in the settings).
 
-`vscode-clangd` will attempt to find the `clangd` binary on your `PATH`.
-Alternatively, the `clangd` executable can be specified in your VS Code
-`settings.json` file:
+### Project setup
 
-```json
-{
-"clangd.path": "/absolute/path/to/clangd"
-}
-```
+clangd is based on the clang C++ compiler, and understands even complex C++
+code.  However, you must tell clangd how your project is built (compile flags).
+[A `compile_commands.json` file](http://clang.llvm.org/docs/JSONCompilationDatabase.html)
+can usually be generated by your build system
+(e.g. by setting `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` when building with CMake,
+or with
+[many other tools](https://sarcasm.github.io/notes/dev/compilation-database.html)).
 
-To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd/Installation.html#installing-clangd).
+It should live at the top of your source tree: symlink or copy it there.
 
-## Development
+## Features
 
-A guide of developing `vscode-clangd` extension.
+### Code completion
 
-### Requirements
+Suggestions will appear as you type names, or after `.` or `->`.
+Because clangd uses a full C++ parser, code completion has access to precise
+type information.
 
-* VS Code
-* node.js and npm
+![Code completion](doc-assets/complete.png)
 
-### Steps
+### Errors, warnings, and clang-tidy
 
-1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
-2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
-point to the binary.
-3. In order to start a development instance of VS code extended with this, run:
+Code errors are shown as you type (both as red squiggle underlines, and in the
+"Problems" panel). These are the same as produced by the clang compiler, and
+suggested fixes can automatically be applied.
 
-```bash
-   $ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
-   $ npm install
-   $ code .
-   # When VS Code starts, press .
-```
+![Error with fix](doc-assets/diagnostics.png)
 
-## Contributing
+Most clang-tidy checks are supported (these can be enabled using a [.clang-tidy
+file](https://clang.llvm.org/extra/clang-tidy/)).
 
-Please follow the exsiting code style when contributing to the extension, we
-recommend to run `npm run format` before sending a patch.
+### Cross-references
 
-## Publish to VS Code Marketplace
+Go-to-definition and find-references work across your code, using a project-wide
+index.
 
-New changes to `clangd-vscode` are not released until a new version is published
-to the marketplace.
+![Cross-reference list](doc-as

[PATCH] D66018: [ARM] Take into account -mcpu and -mfpu options while handling 'crypto' feature

2019-09-03 Thread Diogo N. Sampaio via Phabricator via cfe-commits
dnsampaio accepted this revision.
dnsampaio added a comment.
This revision is now accepted and ready to land.

LGTM. Thanks. Will commit for you as requested soon.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66018/new/

https://reviews.llvm.org/D66018



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


[PATCH] D65863: [ARM] Add support for the s,j,x,N,O inline asm constraints

2019-09-03 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard accepted this revision.
ostannard added a comment.
This revision is now accepted and ready to land.

LGTM with one small change.




Comment at: clang/test/Sema/arm_inline_asm_constraints.c:47
+// I: An immediate integer valid for a data-processing instruction. 
(ARM/Thumb2)
+//An immediate integer between -255 and -1. (Thumb1)
+int test_I(int i) {

Copy-paste error, should be "between 0 and 255".


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65863/new/

https://reviews.llvm.org/D65863



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


[clang-tools-extra] r370750 - Fix MSVC "not all control paths return a value" warning. NFCI.

2019-09-03 Thread Simon Pilgrim via cfe-commits
Author: rksimon
Date: Tue Sep  3 06:05:13 2019
New Revision: 370750

URL: http://llvm.org/viewvc/llvm-project?rev=370750&view=rev
Log:
Fix MSVC "not all control paths return a value" warning. NFCI.

Modified:
clang-tools-extra/trunk/clangd/FindTarget.cpp

Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindTarget.cpp?rev=370750&r1=370749&r2=370750&view=diff
==
--- clang-tools-extra/trunk/clangd/FindTarget.cpp (original)
+++ clang-tools-extra/trunk/clangd/FindTarget.cpp Tue Sep  3 06:05:13 2019
@@ -365,6 +365,7 @@ llvm::raw_ostream &operator<<(llvm::raw_
 REL_CASE(TemplatePattern);
 #undef REL_CASE
   };
+  llvm_unreachable("Unhandled DeclRelation enum");
 }
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, DeclRelationSet RS) {
   const char *Sep = "";


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


[PATCH] D67092: [clangd] Update clangd-vscode docs to be more user-focused.

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall updated this revision to Diff 218444.
sammccall added a comment.

Fix mailing list link again


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67092/new/

https://reviews.llvm.org/D67092

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/DEVELOPING.md
  clang-tools-extra/clangd/clients/clangd-vscode/README.md
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/complete.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/diagnostics.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/extract.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/format.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/include.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/symbolsearch.png
  clang-tools-extra/clangd/clients/clangd-vscode/doc-assets/xrefs.png

Index: clang-tools-extra/clangd/clients/clangd-vscode/README.md
===
--- clang-tools-extra/clangd/clients/clangd-vscode/README.md
+++ clang-tools-extra/clangd/clients/clangd-vscode/README.md
@@ -1,81 +1,103 @@
 # vscode-clangd
 
-Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html).
+Provides C/C++ language IDE features for VS Code using [clangd](https://clang.llvm.org/extra/clangd.html):
 
-## Usage
+ - code completion
+ - compile errors and warnings
+ - go-to-definition and cross references
+ - include management
+ - code formatting
+ - simple refactorings
 
-`vscode-clangd` provides the features designated by the [Language Server
-Protocol](https://github.com/Microsoft/language-server-protocol), such as
-code completion, code formatting and goto definition.
+## Setup
 
-**Note**: `clangd` is under heavy development, not all LSP features are
-implemented. See [Current Status](https://clang.llvm.org/extra/clangd/Features.html#complete-list-of-features)
-for details.
+### `clangd` server
 
-To use `vscode-clangd` extension in VS Code, you need to install `vscode-clangd`
-from VS Code extension marketplace.
+`clangd` is a language server that must be installed separately, see
+[https://clangd.github.io/installation.html](getting started).
+The vscode-clangd plugin will look for `clangd` on your PATH (you can change
+this in the settings).
 
-`vscode-clangd` will attempt to find the `clangd` binary on your `PATH`.
-Alternatively, the `clangd` executable can be specified in your VS Code
-`settings.json` file:
+### Project setup
 
-```json
-{
-"clangd.path": "/absolute/path/to/clangd"
-}
-```
+clangd is based on the clang C++ compiler, and understands even complex C++
+code.  However, you must tell clangd how your project is built (compile flags).
+[A `compile_commands.json` file](http://clang.llvm.org/docs/JSONCompilationDatabase.html)
+can usually be generated by your build system
+(e.g. by setting `-DCMAKE_EXPORT_COMPILE_COMMANDS=1` when building with CMake,
+or with
+[many other tools](https://sarcasm.github.io/notes/dev/compilation-database.html)).
 
-To obtain `clangd` binary, please see the [installing Clangd](https://clang.llvm.org/extra/clangd/Installation.html#installing-clangd).
+It should live at the top of your source tree: symlink or copy it there.
 
-## Development
+## Features
 
-A guide of developing `vscode-clangd` extension.
+### Code completion
 
-### Requirements
+Suggestions will appear as you type names, or after `.` or `->`.
+Because clangd uses a full C++ parser, code completion has access to precise
+type information.
 
-* VS Code
-* node.js and npm
+![Code completion](doc-assets/complete.png)
 
-### Steps
+### Errors, warnings, and clang-tidy
 
-1. Make sure you disable the installed `vscode-clangd` extension in VS Code.
-2. Make sure you have clangd in /usr/bin/clangd or edit src/extension.ts to
-point to the binary.
-3. In order to start a development instance of VS code extended with this, run:
+Code errors are shown as you type (both as red squiggle underlines, and in the
+"Problems" panel). These are the same as produced by the clang compiler, and
+suggested fixes can automatically be applied.
 
-```bash
-   $ cd /path/to/clang-tools-extra/clangd/clients/clangd-vscode/
-   $ npm install
-   $ code .
-   # When VS Code starts, press .
-```
+![Error with fix](doc-assets/diagnostics.png)
 
-## Contributing
+Most clang-tidy checks are supported (these can be enabled using a [.clang-tidy
+file](https://clang.llvm.org/extra/clang-tidy/)).
 
-Please follow the exsiting code style when contributing to the extension, we
-recommend to run `npm run format` before sending a patch.
+### Cross-references
 
-## Publish to VS Code Marketplace
+Go-to-definition and find-references work across your code, using a project-wide
+index.
 
-New changes to `clangd-vscode` are not released until a new version is published
-to the marketplace.
+![Cross-reference list](doc-assets/xrefs.png)
 
-### Requirements
+Press `C

[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc

2019-09-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

I prefer this to be in the place where the ifunc gets created, otherwise we 
definitely need tests.  There are sufficient tests for this that show the ifunc 
having been created, so I'd suggest just adding to them.




Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2957
+if (!AliasFunc) {
+  auto *IFunc = cast(GetOrCreateLLVMFunction(
+  AliasName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/true,

I think we want this in GetOrCreateMultiVersionResolver, so that it gets 
created when the ifunc does.  That way you just need a 
"FD->isCPUDispatchMultiVersion() || isCPUSpecificMultiVersion()" check inside 
the supportsIFunc branch.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67058/new/

https://reviews.llvm.org/D67058



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


[PATCH] D67095: [SVE][Inline-Asm] Fix -Wimplicit-fallthrough in AArch64ISelLowering.cpp

2019-09-03 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin created this revision.
kmclaughlin added reviewers: sdesmalen, rovka, cameron.mcinally, greened, 
gribozavr, ruiu.
Herald added subscribers: psnobl, rkruppe, kristof.beyls, tschuett, javed.absar.
Herald added a project: LLVM.

Adds break to 'x' case in getRegForInlineAsmConstraint added by D66302 
, fixing the unintentional fallthrough.


Repository:
  rL LLVM

https://reviews.llvm.org/D67095

Files:
  lib/Target/AArch64/AArch64ISelLowering.cpp


Index: lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- lib/Target/AArch64/AArch64ISelLowering.cpp
+++ lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -5834,6 +5834,7 @@
 return std::make_pair(0U, &AArch64::ZPR_4bRegClass);
   if (VT.getSizeInBits() == 128)
 return std::make_pair(0U, &AArch64::FPR128_loRegClass);
+  break;
 case 'y':
   if (!Subtarget->hasFPARMv8())
 break;


Index: lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- lib/Target/AArch64/AArch64ISelLowering.cpp
+++ lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -5834,6 +5834,7 @@
 return std::make_pair(0U, &AArch64::ZPR_4bRegClass);
   if (VT.getSizeInBits() == 128)
 return std::make_pair(0U, &AArch64::FPR128_loRegClass);
+  break;
 case 'y':
   if (!Subtarget->hasFPARMv8())
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: ilya-biryukov.
Herald added subscribers: kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67096

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
  clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts


Index: 
clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
@@ -58,6 +58,10 @@
   highlighter: Highlighter;
   // Any disposables that should be cleaned up when clangd crashes.
   private subscriptions: vscode.Disposable[] = [];
+  // Whether the semantic highlighting feature is enabled in the extension.
+  private enable: boolean;
+
+  constructor(enable: boolean) { this.enable = enable; }
   fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) {
 // Extend the ClientCapabilities type and add semantic highlighting
 // capability to the object.
@@ -65,7 +69,7 @@
 {semanticHighlightingCapabilities?: {semanticHighlighting : boolean}} =
 capabilities.textDocument;
 textDocumentCapabilities.semanticHighlightingCapabilities = {
-  semanticHighlighting : true,
+  semanticHighlighting : this.enable,
 };
   }
 
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -110,7 +110,8 @@
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));
   context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
   clangdClient.registerFeature(semanticHighlightingFeature);
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a 
performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/semantic-highlighting.ts
@@ -58,6 +58,10 @@
   highlighter: Highlighter;
   // Any disposables that should be cleaned up when clangd crashes.
   private subscriptions: vscode.Disposable[] = [];
+  // Whether the semantic highlighting feature is enabled in the extension.
+  private enable: boolean;
+
+  constructor(enable: boolean) { this.enable = enable; }
   fillClientCapabilities(capabilities: vscodelc.ClientCapabilities) {
 // Extend the ClientCapabilities type and add semantic highlighting
 // capability to the object.
@@ -65,7 +69,7 @@
 {semanticHighlightingCapabilities?: {semanticHighlighting : boolean}} =
 capabilities.textDocument;
 textDocumentCapabilities.semanticHighlightingCapabilities = {
-  semanticHighlighting : true,
+  semanticHighlighting : this.enable,
 };
   }
 
Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -110,7 +110,8 @@
   const clangdClient = new ClangdLanguageClient('Clang Language Server',
 serverOptions, clientOptions);
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));
   context.subscriptions.push(
   vscode.Disposable.from(semanti

[clang-tools-extra] r370757 - [clangd] Wrong attribute on debug function in r370746

2019-09-03 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Sep  3 06:54:27 2019
New Revision: 370757

URL: http://llvm.org/viewvc/llvm-project?rev=370757&view=rev
Log:
[clangd] Wrong attribute on debug function in r370746

Modified:
clang-tools-extra/trunk/clangd/FindTarget.cpp

Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindTarget.cpp?rev=370757&r1=370756&r2=370757&view=diff
==
--- clang-tools-extra/trunk/clangd/FindTarget.cpp (original)
+++ clang-tools-extra/trunk/clangd/FindTarget.cpp Tue Sep  3 06:54:27 2019
@@ -27,7 +27,7 @@ namespace clang {
 namespace clangd {
 namespace {
 
-LLVM_DUMP_METHOD std::string
+LLVM_ATTRIBUTE_UNUSED std::string
 nodeToString(const ast_type_traits::DynTypedNode &N) {
   std::string S = N.getNodeKind().asStringRef();
   {


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


[PATCH] D67095: [SVE][Inline-Asm] Fix -Wimplicit-fallthrough in AArch64ISelLowering.cpp

2019-09-03 Thread Sander de Smalen via Phabricator via cfe-commits
sdesmalen accepted this revision.
sdesmalen added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67095/new/

https://reviews.llvm.org/D67095



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


[clang-tools-extra] r370758 - [clangd] Fix a data race in test code

2019-09-03 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Tue Sep  3 06:56:03 2019
New Revision: 370758

URL: http://llvm.org/viewvc/llvm-project?rev=370758&view=rev
Log:
[clangd] Fix a data race in test code

Found by TSan, thanks bkramer for pointing this out.

Modified:
clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp

Modified: clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp?rev=370758&r1=370757&r2=370758&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/TUSchedulerTests.cpp Tue Sep  3 
06:56:03 2019
@@ -740,12 +740,14 @@ TEST_F(TUSchedulerTests, CommandLineErro
   // We should see errors from command-line parsing inside the main file.
   CDB.ExtraClangFlags = {"-fsome-unknown-flag"};
 
+  // (!) 'Ready' must live longer than TUScheduler.
+  Notification Ready;
+
   TUScheduler S(CDB, /*AsyncThreadsCount=*/getDefaultAsyncThreadsCount(),
 /*StorePreambleInMemory=*/true, 
/*ASTCallbacks=*/captureDiags(),
 /*UpdateDebounce=*/std::chrono::steady_clock::duration::zero(),
 ASTRetentionPolicy());
 
-  Notification Ready;
   std::vector Diagnostics;
   updateWithDiags(S, testPath("foo.cpp"), "void test() {}",
   WantDiagnostics::Yes, [&](std::vector D) {


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


[PATCH] D66945: [clang-tidy] Fix a false positive in unused-using-decl check.

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp:105
   }
   // Mark using declarations as used by setting FoundDecls' value to zero. As
   // the AST is walked in order, usages are only marked after a the

gribozavr wrote:
> Please move the comment below the lambda. The lambda is not doing what this 
> comment says.
I think the comment is pretty old (it was added in the first patch, but the 
check has been evolved a lot). I updated the comment here.



Comment at: clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp:138
 removeFromFoundDecls(RD);
+} else if (Used->getKind() == TemplateArgument::Declaration) {
+  RemoveNamedDecl(Used->getAsDecl());

gribozavr wrote:
> Could you add a test for this case?
This is already covered by the existing test case `a.func2(t3);` -- in 
this patch, we change the matcher of `callExpr` on Line 63, and the callback of 
it now runs into this codepath  (previously it falls into the `if (const auto 
*Used = Result.Nodes.getNodeAs("used")` branch above).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66945/new/

https://reviews.llvm.org/D66945



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


[PATCH] D66945: [clang-tidy] Fix a false positive in unused-using-decl check.

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 218450.
hokein marked 3 inline comments as done.
hokein added a comment.

Update the comment.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66945/new/

https://reviews.llvm.org/D66945

Files:
  clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
  clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp

Index: clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
===
--- clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
+++ clang-tools-extra/test/clang-tidy/misc-unused-using-decls.cpp
@@ -31,6 +31,8 @@
 template  class P {};
 const int Constant = 0;
 
+template  class Q {};
+
 class Base {
  public:
   void f();
@@ -169,6 +171,8 @@
 using n::Constant;
 // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: using decl 'Constant' is unused
 
+using n::Q;
+
 // - Usages -
 void f(B b);
 void g() {
@@ -202,3 +206,8 @@
 template 
 void i(n::P* t) {}
 template void i(n::P* t);
+
+template  class U> class Bar {};
+// We used to report Q unsued, because we only checked the first template
+// argument.
+Bar *bar;
Index: clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
===
--- clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
+++ clang-tools-extra/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
@@ -17,6 +17,29 @@
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move ASTMatcher library.
+AST_POLYMORPHIC_MATCHER_P(
+forEachTemplateArgument,
+AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,
+TemplateSpecializationType, FunctionDecl),
+clang::ast_matchers::internal::Matcher, InnerMatcher) {
+  ArrayRef TemplateArgs =
+  clang::ast_matchers::internal::getTemplateSpecializationArgs(Node);
+  clang::ast_matchers::internal::BoundNodesTreeBuilder Result;
+  bool Matched = false;
+  for (const auto &Arg : TemplateArgs) {
+clang::ast_matchers::internal::BoundNodesTreeBuilder ArgBuilder(*Builder);
+if (InnerMatcher.matches(Arg, Finder, &ArgBuilder)) {
+  Matched = true;
+  Result.addMatch(ArgBuilder);
+}
+  }
+  *Builder = std::move(Result);
+  return Matched;
+}
+} // namespace
+
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
 // checked. Only variable, function, function template, class template, class,
 // enum declaration and enum constant declaration are considered.
@@ -37,11 +60,10 @@
   Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
  this);
   Finder->addMatcher(
-  callExpr(hasDeclaration(functionDecl(hasAnyTemplateArgument(
-  anyOf(refersToTemplate(templateName().bind("used")),
-refersToDeclaration(functionDecl().bind("used"))),
+  callExpr(hasDeclaration(functionDecl(
+  forEachTemplateArgument(templateArgument().bind("used"),
   this);
-  Finder->addMatcher(loc(templateSpecializationType(hasAnyTemplateArgument(
+  Finder->addMatcher(loc(templateSpecializationType(forEachTemplateArgument(
  templateArgument().bind("used",
  this);
 }
@@ -80,52 +102,47 @@
   Contexts.push_back(Context);
 return;
   }
-  // Mark using declarations as used by setting FoundDecls' value to zero. As
-  // the AST is walked in order, usages are only marked after a the
-  // corresponding using declaration has been found.
-  // FIXME: This currently doesn't look at whether the type reference is
-  // actually found with the help of the using declaration.
-  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+
+  // Mark a corresponding using declaration as used.
+  auto RemoveNamedDecl = [&](const NamedDecl *Used) {
+removeFromFoundDecls(Used);
+// Also remove variants of Used.
 if (const auto *FD = dyn_cast(Used)) {
   removeFromFoundDecls(FD->getPrimaryTemplate());
 } else if (const auto *Specialization =
dyn_cast(Used)) {
-  Used = Specialization->getSpecializedTemplate();
+  removeFromFoundDecls(Specialization->getSpecializedTemplate());
+} else if (const auto *FD = dyn_cast(Used)) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT);
+} else if (const auto *ECD = dyn_cast(Used)) {
+  if (const auto *ET = ECD->getType()->getAs())
+removeFromFoundDecls(ET->getDecl());
 }
-removeFromFoundDecls(Used);
+  };
+  // We rely on the fact that the clang AST is walked in order, usages are only
+  // marked after a corresponding using decl has been found.
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+RemoveNamedDecl(Used);
 return;
   }
 
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
-// FIXME: Support non-type template parameters.
 if (Used->getK

[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:113
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));

Why not avoid calling `clangdClient.registerFeature` instead?
Would allow to:
- not change the `SemanticHighlightingFeature` class, keeping it simpler,
- ensure we do not do any extra work if the feature is disabled.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67096/new/

https://reviews.llvm.org/D67096



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


[clang-tools-extra] r370759 - [clangd] Decouple macro/decl-under-cursor finding. Don't pretend there can be multiple macros. NFC.

2019-09-03 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Sep  3 07:12:48 2019
New Revision: 370759

URL: http://llvm.org/viewvc/llvm-project?rev=370759&view=rev
Log:
[clangd] Decouple macro/decl-under-cursor finding. Don't pretend there can be 
multiple macros. NFC.

Modified:
clang-tools-extra/trunk/clangd/XRefs.cpp

Modified: clang-tools-extra/trunk/clangd/XRefs.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/XRefs.cpp?rev=370759&r1=370758&r2=370759&view=diff
==
--- clang-tools-extra/trunk/clangd/XRefs.cpp (original)
+++ clang-tools-extra/trunk/clangd/XRefs.cpp Tue Sep  3 07:12:48 2019
@@ -130,16 +130,13 @@ SymbolLocation getPreferredLocation(cons
 }
 
 /// Finds declarations locations that a given source location refers to.
-class DeclarationAndMacrosFinder : public index::IndexDataConsumer {
-  std::vector MacroInfos;
+class DeclarationFinder : public index::IndexDataConsumer {
   llvm::DenseSet Decls;
   const SourceLocation &SearchedLocation;
-  Preprocessor &PP;
 
 public:
-  DeclarationAndMacrosFinder(const SourceLocation &SearchedLocation,
- Preprocessor &PP)
-  : SearchedLocation(SearchedLocation), PP(PP) {}
+  DeclarationFinder(const SourceLocation &SearchedLocation)
+  : SearchedLocation(SearchedLocation) {}
 
   // The results are sorted by declaration location.
   std::vector getFoundDecls() const {
@@ -153,22 +150,6 @@ public:
 return Result;
   }
 
-  std::vector takeMacroInfos() {
-// Don't keep the same Macro info multiple times.
-llvm::sort(MacroInfos,
-   [](const DefinedMacro &Left, const DefinedMacro &Right) {
- return Left.Info < Right.Info;
-   });
-
-auto Last =
-std::unique(MacroInfos.begin(), MacroInfos.end(),
-[](const DefinedMacro &Left, const DefinedMacro &Right) {
-  return Left.Info == Right.Info;
-});
-MacroInfos.erase(Last, MacroInfos.end());
-return std::move(MacroInfos);
-  }
-
   bool
   handleDeclOccurence(const Decl *D, index::SymbolRoleSet Roles,
   llvm::ArrayRef Relations,
@@ -210,22 +191,11 @@ public:
 }
 return true;
   }
-
-private:
-  void finish() override {
-if (auto DefinedMacro = locateMacroAt(SearchedLocation, PP))
-  MacroInfos.push_back(*DefinedMacro);
-  }
 };
 
-struct IdentifiedSymbol {
-  std::vector Decls;
-  std::vector Macros;
-};
-
-IdentifiedSymbol getSymbolAtPosition(ParsedAST &AST, SourceLocation Pos) {
-  auto DeclMacrosFinder =
-  DeclarationAndMacrosFinder(Pos, AST.getPreprocessor());
+std::vector getDeclAtPosition(ParsedAST &AST,
+SourceLocation Pos) {
+  DeclarationFinder Finder(Pos);
   index::IndexingOptions IndexOpts;
   IndexOpts.SystemSymbolFilter =
   index::IndexingOptions::SystemSymbolFilterKind::All;
@@ -233,9 +203,9 @@ IdentifiedSymbol getSymbolAtPosition(Par
   IndexOpts.IndexParametersInDeclarations = true;
   IndexOpts.IndexTemplateParameters = true;
   indexTopLevelDecls(AST.getASTContext(), AST.getPreprocessor(),
- AST.getLocalTopLevelDecls(), DeclMacrosFinder, IndexOpts);
+ AST.getLocalTopLevelDecls(), Finder, IndexOpts);
 
-  return {DeclMacrosFinder.getFoundDecls(), DeclMacrosFinder.takeMacroInfos()};
+  return Finder.getFoundDecls();
 }
 
 llvm::Optional makeLocation(ASTContext &AST, SourceLocation TokLoc,
@@ -286,16 +256,15 @@ std::vector locateSymbolA
 
   SourceLocation SourceLocationBeg =
   getBeginningOfIdentifier(AST, Pos, SM.getMainFileID());
-  auto Symbols = getSymbolAtPosition(AST, SourceLocationBeg);
 
   // Macros are simple: there's no declaration/definition distinction.
   // As a consequence, there's no need to look them up in the index either.
   std::vector Result;
-  for (auto M : Symbols.Macros) {
-if (auto Loc = makeLocation(AST.getASTContext(), 
M.Info->getDefinitionLoc(),
-*MainFilePath)) {
+  if (auto M = locateMacroAt(SourceLocationBeg, AST.getPreprocessor())) {
+if (auto Loc = makeLocation(AST.getASTContext(),
+M->Info->getDefinitionLoc(), *MainFilePath)) {
   LocatedSymbol Macro;
-  Macro.Name = M.Name;
+  Macro.Name = M->Name;
   Macro.PreferredDeclaration = *Loc;
   Macro.Definition = Loc;
   Result.push_back(std::move(Macro));
@@ -312,7 +281,7 @@ std::vector locateSymbolA
   llvm::DenseMap ResultIndex;
 
   // Emit all symbol locations (declaration or definition) from AST.
-  for (const Decl *D : Symbols.Decls) {
+  for (const Decl *D : getDeclAtPosition(AST, SourceLocationBeg)) {
 auto Loc =
 makeLocation(AST.getASTContext(), spellingLocIfSpelled(findName(D), 
SM),
  *MainFilePath);
@@ -438,10 +407,11 @@ findRefs(const std::vector
 std::vector findDocumentHighlights(ParsedAST &AST,
 

[clang-tools-extra] r370760 - [clang-tidy] Fix a false positive in unused-using-decl check

2019-09-03 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Tue Sep  3 07:13:00 2019
New Revision: 370760

URL: http://llvm.org/viewvc/llvm-project?rev=370760&view=rev
Log:
[clang-tidy] Fix a false positive in unused-using-decl check

The previous matcher "hasAnyTemplateArgument(templateArgument())" only
matches the first template argument, but the check wants to iterate all
template arguments. This patch fixes this.

Also some refactorings in this patch (to make the code reusable).

Modified:
clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/misc-unused-using-decls.cpp

Modified: clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp?rev=370760&r1=370759&r2=370760&view=diff
==
--- clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/misc/UnusedUsingDeclsCheck.cpp Tue Sep  
3 07:13:00 2019
@@ -17,6 +17,29 @@ namespace clang {
 namespace tidy {
 namespace misc {
 
+namespace {
+// FIXME: Move ASTMatcher library.
+AST_POLYMORPHIC_MATCHER_P(
+forEachTemplateArgument,
+AST_POLYMORPHIC_SUPPORTED_TYPES(ClassTemplateSpecializationDecl,
+TemplateSpecializationType, FunctionDecl),
+clang::ast_matchers::internal::Matcher, InnerMatcher) {
+  ArrayRef TemplateArgs =
+  clang::ast_matchers::internal::getTemplateSpecializationArgs(Node);
+  clang::ast_matchers::internal::BoundNodesTreeBuilder Result;
+  bool Matched = false;
+  for (const auto &Arg : TemplateArgs) {
+clang::ast_matchers::internal::BoundNodesTreeBuilder ArgBuilder(*Builder);
+if (InnerMatcher.matches(Arg, Finder, &ArgBuilder)) {
+  Matched = true;
+  Result.addMatch(ArgBuilder);
+}
+  }
+  *Builder = std::move(Result);
+  return Matched;
+}
+} // namespace
+
 // A function that helps to tell whether a TargetDecl in a UsingDecl will be
 // checked. Only variable, function, function template, class template, class,
 // enum declaration and enum constant declaration are considered.
@@ -37,11 +60,10 @@ void UnusedUsingDeclsCheck::registerMatc
   Finder->addMatcher(callExpr(callee(unresolvedLookupExpr().bind("used"))),
  this);
   Finder->addMatcher(
-  callExpr(hasDeclaration(functionDecl(hasAnyTemplateArgument(
-  anyOf(refersToTemplate(templateName().bind("used")),
-refersToDeclaration(functionDecl().bind("used"))),
+  callExpr(hasDeclaration(functionDecl(
+  forEachTemplateArgument(templateArgument().bind("used"),
   this);
-  Finder->addMatcher(loc(templateSpecializationType(hasAnyTemplateArgument(
+  Finder->addMatcher(loc(templateSpecializationType(forEachTemplateArgument(
  templateArgument().bind("used",
  this);
 }
@@ -80,52 +102,47 @@ void UnusedUsingDeclsCheck::check(const
   Contexts.push_back(Context);
 return;
   }
-  // Mark using declarations as used by setting FoundDecls' value to zero. As
-  // the AST is walked in order, usages are only marked after a the
-  // corresponding using declaration has been found.
-  // FIXME: This currently doesn't look at whether the type reference is
-  // actually found with the help of the using declaration.
-  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+
+  // Mark a corresponding using declaration as used.
+  auto RemoveNamedDecl = [&](const NamedDecl *Used) {
+removeFromFoundDecls(Used);
+// Also remove variants of Used.
 if (const auto *FD = dyn_cast(Used)) {
   removeFromFoundDecls(FD->getPrimaryTemplate());
 } else if (const auto *Specialization =
dyn_cast(Used)) {
-  Used = Specialization->getSpecializedTemplate();
+  removeFromFoundDecls(Specialization->getSpecializedTemplate());
+} else if (const auto *FD = dyn_cast(Used)) {
+  if (const auto *FDT = FD->getPrimaryTemplate())
+removeFromFoundDecls(FDT);
+} else if (const auto *ECD = dyn_cast(Used)) {
+  if (const auto *ET = ECD->getType()->getAs())
+removeFromFoundDecls(ET->getDecl());
 }
-removeFromFoundDecls(Used);
+  };
+  // We rely on the fact that the clang AST is walked in order, usages are only
+  // marked after a corresponding using decl has been found.
+  if (const auto *Used = Result.Nodes.getNodeAs("used")) {
+RemoveNamedDecl(Used);
 return;
   }
 
   if (const auto *Used = Result.Nodes.getNodeAs("used")) {
-// FIXME: Support non-type template parameters.
 if (Used->getKind() == TemplateArgument::Template) {
   if (const auto *TD = Used->getAsTemplate().getAsTemplateDecl())
 removeFromFoundDecls(TD);
 } else if (Used->getKind() == TemplateArgument::Type) {
   if (auto *RD = Used->getAsType()->getAsCXXRecordDecl())
 remo

[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:113
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));

ilya-biryukov wrote:
> Why not avoid calling `clangdClient.registerFeature` instead?
> Would allow to:
> - not change the `SemanticHighlightingFeature` class, keeping it simpler,
> - ensure we do not do any extra work if the feature is disabled.
good point, done.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67096/new/

https://reviews.llvm.org/D67096



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


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 218452.
hokein marked 2 inline comments as done.
hokein added a comment.

address the comment, don't register the feature.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67096/new/

https://reviews.llvm.org/D67096

Files:
  clang-tools-extra/clangd/clients/clangd-vscode/package.json
  clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -113,7 +113,8 @@
   new semanticHighlighting.SemanticHighlightingFeature();
   context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
-  clangdClient.registerFeature(semanticHighlightingFeature);
+  if (getConfig('semanticHighlighting'))
+clangdClient.registerFeature(semanticHighlightingFeature);
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a 
performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },


Index: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
===
--- clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
+++ clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts
@@ -113,7 +113,8 @@
   new semanticHighlighting.SemanticHighlightingFeature();
   context.subscriptions.push(
   vscode.Disposable.from(semanticHighlightingFeature));
-  clangdClient.registerFeature(semanticHighlightingFeature);
+  if (getConfig('semanticHighlighting'))
+clangdClient.registerFeature(semanticHighlightingFeature);
   console.log('Clang Language Server is now active!');
   context.subscriptions.push(clangdClient.start());
   context.subscriptions.push(vscode.commands.registerCommand(
Index: clang-tools-extra/clangd/clients/clangd-vscode/package.json
===
--- clang-tools-extra/clangd/clients/clangd-vscode/package.json
+++ clang-tools-extra/clangd/clients/clangd-vscode/package.json
@@ -89,6 +89,11 @@
 "clangd.trace": {
 "type": "string",
 "description": "Names a file that clangd should log a performance trace to, in chrome trace-viewer JSON format."
+},
+"clangd.semanticHighlighting": {
+"type": "boolean",
+"default": "false",
+"description": "Enable semantic highlighting in clangd"
 }
 }
 },
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D66945: [clang-tidy] Fix a false positive in unused-using-decl check.

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein closed this revision.
hokein added a comment.

committed in rL370760 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66945/new/

https://reviews.llvm.org/D66945



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


[PATCH] D66524: [SVE][Inline-Asm] Add constraints for SVE predicate registers

2019-09-03 Thread David Greene via Phabricator via cfe-commits
greened added inline comments.



Comment at: docs/LangRef.rst:3818
+- ``Upl``: One of the low eight SVE predicate registers (P0 to P7)
+- ``Upa``: Any of the SVE predicate registers (P0 to P15)
 

What do these names mean?  " predicate lower|all?"  I see they are 
the names used in gcc, so I guess it makes sense to use them here.  Are these 
names used in the SVE architecture manual somewhere?  I cannot find them.



Comment at: lib/Target/AArch64/AArch64ISelLowering.cpp:5747
+
+PredicateConstraint isPredicateConstraint(StringRef Constraint) {
+  PredicateConstraint P = PredicateConstraint::Invalid;

rovka wrote:
> Nit: I think get- or parsePredicateConstraint reads better, since this 
> doesn't return a simple yes/no answer.
+1.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66524/new/

https://reviews.llvm.org/D66524



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


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:113
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));

hokein wrote:
> ilya-biryukov wrote:
> > Why not avoid calling `clangdClient.registerFeature` instead?
> > Would allow to:
> > - not change the `SemanticHighlightingFeature` class, keeping it simpler,
> > - ensure we do not do any extra work if the feature is disabled.
> good point, done.
Should we update other uses of `semanticHighlightingFeature` too?

`context.subscriptions.push(vscode.Disposable.from(semanticHighlightingFeature))`
 probably ensures we call `dispose()` when the `clangdClient` is getting 
removed, I guess we definitely don't need that.

Other uses as well:
- no need to pass notification is highlighting is disabled.
- no need to cleanup if highlighting is disabled.

Maybe assign null or undefined to `semanticHighlightingFeature` when the flag 
is false?
At each usage we can check whether the `semanticHighlightingFeature` is not 
null and only call relevant methods if that's the case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67096/new/

https://reviews.llvm.org/D67096



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


[clang-tools-extra] r370763 - [clangd] Remove redundant semi-colon.

2019-09-03 Thread Michael Liao via cfe-commits
Author: hliao
Date: Tue Sep  3 08:02:46 2019
New Revision: 370763

URL: http://llvm.org/viewvc/llvm-project?rev=370763&view=rev
Log:
[clangd] Remove redundant semi-colon.

Modified:
clang-tools-extra/trunk/clangd/FindTarget.cpp

Modified: clang-tools-extra/trunk/clangd/FindTarget.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/FindTarget.cpp?rev=370763&r1=370762&r2=370763&view=diff
==
--- clang-tools-extra/trunk/clangd/FindTarget.cpp (original)
+++ clang-tools-extra/trunk/clangd/FindTarget.cpp Tue Sep  3 08:02:46 2019
@@ -364,7 +364,7 @@ llvm::raw_ostream &operator<<(llvm::raw_
 REL_CASE(TemplateInstantiation);
 REL_CASE(TemplatePattern);
 #undef REL_CASE
-  };
+  }
   llvm_unreachable("Unhandled DeclRelation enum");
 }
 llvm::raw_ostream &operator<<(llvm::raw_ostream &OS, DeclRelationSet RS) {


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


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein marked an inline comment as done.
hokein added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:113
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));

ilya-biryukov wrote:
> hokein wrote:
> > ilya-biryukov wrote:
> > > Why not avoid calling `clangdClient.registerFeature` instead?
> > > Would allow to:
> > > - not change the `SemanticHighlightingFeature` class, keeping it simpler,
> > > - ensure we do not do any extra work if the feature is disabled.
> > good point, done.
> Should we update other uses of `semanticHighlightingFeature` too?
> 
> `context.subscriptions.push(vscode.Disposable.from(semanticHighlightingFeature))`
>  probably ensures we call `dispose()` when the `clangdClient` is getting 
> removed, I guess we definitely don't need that.
> 
> Other uses as well:
> - no need to pass notification is highlighting is disabled.
> - no need to cleanup if highlighting is disabled.
> 
> Maybe assign null or undefined to `semanticHighlightingFeature` when the flag 
> is false?
> At each usage we can check whether the `semanticHighlightingFeature` is not 
> null and only call relevant methods if that's the case.
I don't think it is worth updating all usages, it is no harm to keep them here 
even when the highlighting is disabled (the dispose is a no-op; we never 
receive notifications from clangd); and it would add more guard code which I'd 
avoid.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67096/new/

https://reviews.llvm.org/D67096



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


[PATCH] D67096: [clangd][vscode] Add a flag to enable semantic highlighting in clangd

2019-09-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang-tools-extra/clangd/clients/clangd-vscode/src/extension.ts:113
   const semanticHighlightingFeature =
-  new semanticHighlighting.SemanticHighlightingFeature();
+  new semanticHighlighting.SemanticHighlightingFeature(
+  getConfig('semanticHighlighting'));

hokein wrote:
> ilya-biryukov wrote:
> > hokein wrote:
> > > ilya-biryukov wrote:
> > > > Why not avoid calling `clangdClient.registerFeature` instead?
> > > > Would allow to:
> > > > - not change the `SemanticHighlightingFeature` class, keeping it 
> > > > simpler,
> > > > - ensure we do not do any extra work if the feature is disabled.
> > > good point, done.
> > Should we update other uses of `semanticHighlightingFeature` too?
> > 
> > `context.subscriptions.push(vscode.Disposable.from(semanticHighlightingFeature))`
> >  probably ensures we call `dispose()` when the `clangdClient` is getting 
> > removed, I guess we definitely don't need that.
> > 
> > Other uses as well:
> > - no need to pass notification is highlighting is disabled.
> > - no need to cleanup if highlighting is disabled.
> > 
> > Maybe assign null or undefined to `semanticHighlightingFeature` when the 
> > flag is false?
> > At each usage we can check whether the `semanticHighlightingFeature` is not 
> > null and only call relevant methods if that's the case.
> I don't think it is worth updating all usages, it is no harm to keep them 
> here even when the highlighting is disabled (the dispose is a no-op; we never 
> receive notifications from clangd); and it would add more guard code which 
> I'd avoid.
How can we be sure that nothing bad is going to happen?
In particular, we are "binding" notification handling, but never registered a 
feature. How can we be sure we won't actually get any notifications?

If we don't create the object in the first place, we are confident nothing 
harmful can be done with it.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67096/new/

https://reviews.llvm.org/D67096



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


r370767 - [analyzer] Add a checker option to detect nested dead stores

2019-09-03 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Tue Sep  3 08:22:43 2019
New Revision: 370767

URL: http://llvm.org/viewvc/llvm-project?rev=370767&view=rev
Log:
[analyzer] Add a checker option to detect nested dead stores

Enables the users to specify an optional flag which would warn for more dead
stores.
Previously it ignored if the dead store happened e.g. in an if condition.

if ((X = generate())) { // dead store to X
}

This patch introduces the `WarnForDeadNestedAssignments` option to the checker,
which is `false` by default - so this change would not affect any previous
users.
I have updated the code, tests and the docs as well. If I missed something, tell
me.

I also ran the analysis on Clang which generated 14 more reports compared to the
unmodified version. All of them seemed reasonable for me.

Related previous patches:
rGf224820b45c6847b91071da8d7ade59f373b96f3

Reviewers: NoQ, krememek, Szelethus, baloghadamsoftware

Reviewed By: Szelethus

Patch by Balázs Benics!

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

Modified:
cfe/trunk/docs/analyzer/checkers.rst
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
cfe/trunk/test/Analysis/analyzer-config.c
cfe/trunk/test/Analysis/dead-stores.c
cfe/trunk/test/Analysis/dead-stores.cpp
cfe/trunk/test/Analysis/dead-stores.m

Modified: cfe/trunk/docs/analyzer/checkers.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/checkers.rst?rev=370767&r1=370766&r2=370767&view=diff
==
--- cfe/trunk/docs/analyzer/checkers.rst (original)
+++ cfe/trunk/docs/analyzer/checkers.rst Tue Sep  3 08:22:43 2019
@@ -319,6 +319,15 @@ Check for values stored to variables tha
x = 1; // warn
  }
 
+The ``WarnForDeadNestedAssignments`` option enables the checker to emit
+warnings for nested dead assignments. You can disable with the
+``-analyzer-config deadcode.DeadStores:WarnForDeadNestedAssignments=false``.
+*Defaults to true*.
+
+Would warn for this e.g.:
+if ((y = make_int())) {
+}
+
 .. _nullability-checkers:
 
 nullability

Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=370767&r1=370766&r2=370767&view=diff
==
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Tue Sep  3 
08:22:43 2019
@@ -648,6 +648,14 @@ let ParentPackage = DeadCode in {
 def DeadStoresChecker : Checker<"DeadStores">,
   HelpText<"Check for values stored to variables that are never read "
"afterwards">,
+  CheckerOptions<[
+CmdLineOption
+  ]>,
   Documentation;
 
 } // end DeadCode

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp?rev=370767&r1=370766&r2=370767&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp Tue Sep  3 
08:22:43 2019
@@ -130,6 +130,7 @@ class DeadStoreObs : public LiveVariable
   std::unique_ptr reachableCode;
   const CFGBlock *currentBlock;
   std::unique_ptr> InEH;
+  const bool WarnForDeadNestedAssignments;
 
   enum DeadStoreKind { Standard, Enclosing, DeadIncrement, DeadInit };
 
@@ -137,9 +138,11 @@ public:
   DeadStoreObs(const CFG &cfg, ASTContext &ctx, BugReporter &br,
const CheckerBase *checker, AnalysisDeclContext *ac,
ParentMap &parents,
-   llvm::SmallPtrSet &escaped)
+   llvm::SmallPtrSet &escaped,
+   bool warnForDeadNestedAssignments)
   : cfg(cfg), Ctx(ctx), BR(br), Checker(checker), AC(ac), Parents(parents),
-Escaped(escaped), currentBlock(nullptr) {}
+Escaped(escaped), currentBlock(nullptr),
+WarnForDeadNestedAssignments(warnForDeadNestedAssignments) {}
 
   ~DeadStoreObs() override {}
 
@@ -217,11 +220,16 @@ public:
 os << "Value stored to '" << *V << "' is never read";
 break;
 
+  // eg.: f((x = foo()))
   case Enclosing:
-// Don't report issues in this case, e.g.: "if (x = foo())",
-// where 'x' is unused later.  We have yet to see a case where
-// this is a real bug.
-return;
+if (!WarnForDeadNestedAssignments)
+  return;
+BugType = "Dead nested assignment";
+os << "Although the value stored to '" << *V
+   << "' is used in the enclosing expression, the value is never "
+  "actually read from '"
+   << *V << "'";
+break;
 }
 
 BR.EmitBasicReport(AC->getDecl(), Checke

[PATCH] D66733: [analyzer] Add a checker option to detect nested dead stores

2019-09-03 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370767: [analyzer] Add a checker option to detect nested 
dead stores (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66733?vs=217665&id=218461#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66733/new/

https://reviews.llvm.org/D66733

Files:
  cfe/trunk/docs/analyzer/checkers.rst
  cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
  cfe/trunk/lib/StaticAnalyzer/Checkers/DeadStoresChecker.cpp
  cfe/trunk/test/Analysis/analyzer-config.c
  cfe/trunk/test/Analysis/dead-stores.c
  cfe/trunk/test/Analysis/dead-stores.cpp
  cfe/trunk/test/Analysis/dead-stores.m

Index: cfe/trunk/test/Analysis/dead-stores.cpp
===
--- cfe/trunk/test/Analysis/dead-stores.cpp
+++ cfe/trunk/test/Analysis/dead-stores.cpp
@@ -1,15 +1,26 @@
-// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
-// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11 -analyzer-store=region -analyzer-checker=deadcode.DeadStores -verify -Wno-unreachable-code %s
+// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11\
+// RUN:  -analyzer-checker=deadcode.DeadStores -Wno-unreachable-code\
+// RUN:  -analyzer-config deadcode.DeadStores:WarnForDeadNestedAssignments=false\
+// RUN:  -verify=non-nested %s
+//
+// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11\
+// RUN:  -analyzer-store=region -analyzer-checker=deadcode.DeadStores   \
+// RUN:  -analyzer-config deadcode.DeadStores:WarnForDeadNestedAssignments=false\
+// RUN:  -Wno-unreachable-code -verify=non-nested %s
+//
+// RUN: %clang_analyze_cc1 -fcxx-exceptions -fexceptions -fblocks -std=c++11\
+// RUN:  -analyzer-checker=deadcode.DeadStores -Wno-unreachable-code\
+// RUN:  -verify=non-nested,nested %s
 
 //===--===//
 // Basic dead store checking (but in C++ mode).
 //===--===//
 
 int j;
+int make_int();
 void test1() {
   int x = 4;
-
-  x = x + 1; // expected-warning{{never read}}
+  x = x + 1; // non-nested-warning {{never read}}
 
   switch (j) {
   case 1:
@@ -17,6 +28,11 @@
 (void)x;
 break;
   }
+
+  int y;
+  (void)y;
+  if ((y = make_int())) // nested-warning {{Although the value stored}}
+return;
 }
 
 //===--===//
@@ -25,6 +41,7 @@
 
 class Test2 {
   int &x;
+
 public:
   Test2(int &y) : x(y) {}
   ~Test2() { ++x; }
@@ -66,17 +83,17 @@
 //===--===//
 
 void test3_a(int x) {
-   x = x + 1; // expected-warning{{never read}}
+  x = x + 1; // non-nested-warning {{never read}}
 }
 
 void test3_b(int &x) {
-  x = x + 1; // no-warninge
+  x = x + 1; // no-warning
 }
 
 void test3_c(int x) {
   int &y = x;
-  // Shows the limitation of dead stores tracking.  The write is really
-  // dead since the value cannot escape the function.
+  // Shows the limitation of dead stores tracking. The write is really dead
+  // since the value cannot escape the function.
   ++y; // no-warning
 }
 
@@ -94,7 +111,7 @@
 //===--===//
 
 static void test_new(unsigned n) {
-  char **p = new char* [n]; // expected-warning{{never read}}
+  char **p = new char *[n]; // non-nested-warning {{never read}}
 }
 
 //===--===//
@@ -102,11 +119,11 @@
 //===--===//
 
 namespace foo {
-  int test_4(int x) {
-x = 2; // expected-warning{{Value stored to 'x' is never read}}
-x = 2;
-return x;
-  }
+int test_4(int x) {
+  x = 2; // non-nested-warning {{Value stored to 'x' is never read}}
+  x = 2;
+  return x;
+}
 }
 
 //===--===//
@@ -119,42 +136,39 @@
   try {
 x = 2; // no-warning
 test_5_Aux();
-  }
-  catch (int z) {
+  } catch (int z) {
 return x + z;
   }
   return 1;
 }
 
-
 int test_6_aux(unsigned x);
-
 void test_6() {
-  unsigned currDestLen = 0;  // no-warning
+  unsigned currDestLen = 0; // no-warning
   try {
 while (test_6_aux(currDestLen)) {
   currDestLen += 2; // no-warning
-} 
+}
+  } catch (void *) {
   }
-  catch (void *) {}
 }
 
 void test_6b() {
-  unsigned currDestLen = 0;  // no-warning
+  unsigned currDestLen = 0; // no-warning
   try {
 while (test_6_aux(currDestLen)) {
-  currDestLen += 2; // expected

[clang-tools-extra] r370768 - [clangd] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop dependencies on ClangdUnit from some headers. NFC

2019-09-03 Thread Sam McCall via cfe-commits
Author: sammccall
Date: Tue Sep  3 08:34:47 2019
New Revision: 370768

URL: http://llvm.org/viewvc/llvm-project?rev=370768&view=rev
Log:
[clangd] Move getBeginningOfIdentifier from ClangdUnit to SourceCode. Drop 
dependencies on ClangdUnit from some headers. NFC

Modified:
clang-tools-extra/trunk/clangd/ClangdServer.cpp
clang-tools-extra/trunk/clangd/ClangdServer.h
clang-tools-extra/trunk/clangd/ClangdUnit.cpp
clang-tools-extra/trunk/clangd/ClangdUnit.h
clang-tools-extra/trunk/clangd/CodeComplete.h
clang-tools-extra/trunk/clangd/Selection.cpp
clang-tools-extra/trunk/clangd/Selection.h
clang-tools-extra/trunk/clangd/SourceCode.cpp
clang-tools-extra/trunk/clangd/SourceCode.h
clang-tools-extra/trunk/clangd/XRefs.cpp
clang-tools-extra/trunk/clangd/index/FileIndex.h
clang-tools-extra/trunk/clangd/refactor/Rename.cpp
clang-tools-extra/trunk/clangd/refactor/Rename.h
clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp
clang-tools-extra/trunk/clangd/unittests/SourceCodeTests.cpp

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=370768&r1=370767&r2=370768&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Tue Sep  3 08:34:47 2019
@@ -315,7 +315,7 @@ void ClangdServer::prepareRename(PathRef
   return CB(Changes.takeError());
 }
 SourceLocation Loc = getBeginningOfIdentifier(
-AST, Pos, AST.getSourceManager().getMainFileID());
+Pos, AST.getSourceManager(), AST.getASTContext().getLangOpts());
 if (auto Range = getTokenRange(AST.getSourceManager(),
AST.getASTContext().getLangOpts(), Loc))
   return CB(*Range);

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=370768&r1=370767&r2=370768&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Tue Sep  3 08:34:47 2019
@@ -11,7 +11,6 @@
 
 #include "../clang-tidy/ClangTidyOptions.h"
 #include "Cancellation.h"
-#include "ClangdUnit.h"
 #include "CodeComplete.h"
 #include "FSProvider.h"
 #include "FormattedString.h"

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=370768&r1=370767&r2=370768&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Tue Sep  3 08:34:47 2019
@@ -710,39 +710,6 @@ buildAST(PathRef FileName, std::unique_p
   std::move(VFS), Inputs.Index, Inputs.Opts);
 }
 
-SourceLocation getBeginningOfIdentifier(const ParsedAST &Unit,
-const Position &Pos, const FileID FID) 
{
-  const ASTContext &AST = Unit.getASTContext();
-  const SourceManager &SourceMgr = AST.getSourceManager();
-  auto Offset = positionToOffset(SourceMgr.getBufferData(FID), Pos);
-  if (!Offset) {
-log("getBeginningOfIdentifier: {0}", Offset.takeError());
-return SourceLocation();
-  }
-
-  // GetBeginningOfToken(pos) is almost what we want, but does the wrong thing
-  // if the cursor is at the end of the identifier.
-  // Instead, we lex at GetBeginningOfToken(pos - 1). The cases are:
-  //  1) at the beginning of an identifier, we'll be looking at something
-  //  that isn't an identifier.
-  //  2) at the middle or end of an identifier, we get the identifier.
-  //  3) anywhere outside an identifier, we'll get some non-identifier thing.
-  // We can't actually distinguish cases 1 and 3, but returning the original
-  // location is correct for both!
-  SourceLocation InputLoc = SourceMgr.getComposedLoc(FID, *Offset);
-  if (*Offset == 0) // Case 1 or 3.
-return SourceMgr.getMacroArgExpandedLocation(InputLoc);
-  SourceLocation Before = SourceMgr.getComposedLoc(FID, *Offset - 1);
-
-  Before = Lexer::GetBeginningOfToken(Before, SourceMgr, AST.getLangOpts());
-  Token Tok;
-  if (Before.isValid() &&
-  !Lexer::getRawToken(Before, Tok, SourceMgr, AST.getLangOpts(), false) &&
-  Tok.is(tok::raw_identifier))
-return SourceMgr.getMacroArgExpandedLocation(Before); // Case 2.
-  return SourceMgr.getMacroArgExpandedLocation(InputLoc); // Case 1 or 3.
-}
-
 } // namespace clangd
 namespace tidy {
 // Force the linker to link in Clang-tidy modules.

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.h?rev=370768&r1=370767&r2=370768&view=diff
=

[PATCH] D67095: [SVE][Inline-Asm] Fix -Wimplicit-fallthrough in AArch64ISelLowering.cpp

2019-09-03 Thread Kerry McLaughlin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370769: [SVE][Inline-Asm] Fix -Wimplicit-fallthrough in 
AArch64ISelLowering.cpp (authored by kmclaughlin, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D67095?vs=218443&id=218463#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67095/new/

https://reviews.llvm.org/D67095

Files:
  llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp


Index: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -5834,6 +5834,7 @@
 return std::make_pair(0U, &AArch64::ZPR_4bRegClass);
   if (VT.getSizeInBits() == 128)
 return std::make_pair(0U, &AArch64::FPR128_loRegClass);
+  break;
 case 'y':
   if (!Subtarget->hasFPARMv8())
 break;


Index: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
===
--- llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
+++ llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -5834,6 +5834,7 @@
 return std::make_pair(0U, &AArch64::ZPR_4bRegClass);
   if (VT.getSizeInBits() == 128)
 return std::make_pair(0U, &AArch64::FPR128_loRegClass);
+  break;
 case 'y':
   if (!Subtarget->hasFPARMv8())
 break;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r370773 - [LifetimeAnalysis] Fix some false positives

2019-09-03 Thread Gabor Horvath via cfe-commits
Author: xazax
Date: Tue Sep  3 09:17:24 2019
New Revision: 370773

URL: http://llvm.org/viewvc/llvm-project?rev=370773&view=rev
Log:
[LifetimeAnalysis] Fix some false positives

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

Modified:
cfe/trunk/lib/Sema/SemaInit.cpp
cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp

Modified: cfe/trunk/lib/Sema/SemaInit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaInit.cpp?rev=370773&r1=370772&r2=370773&view=diff
==
--- cfe/trunk/lib/Sema/SemaInit.cpp (original)
+++ cfe/trunk/lib/Sema/SemaInit.cpp Tue Sep  3 09:17:24 2019
@@ -6775,6 +6775,10 @@ static bool shouldTrackFirstArgument(con
 static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call,
 LocalVisitor Visit) {
   auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
+// We are not interested in the temporary base objects of gsl Pointers:
+//   Temp().ptr; // Here ptr might not dangle.
+if (isa(Arg->IgnoreImpCasts()))
+  return;
 Path.push_back({IndirectLocalPathEntry::GslPointerInit, Arg, D});
 if (Arg->isGLValue())
   visitLocalsRetainedByReferenceBinding(Path, Arg, RK_ReferenceBinding,
@@ -7295,6 +7299,8 @@ static bool pathOnlyInitializesGslPointe
   for (auto It = Path.rbegin(), End = Path.rend(); It != End; ++It) {
 if (It->Kind == IndirectLocalPathEntry::VarInit)
   continue;
+if (It->Kind == IndirectLocalPathEntry::AddressOf)
+  continue;
 return It->Kind == IndirectLocalPathEntry::GslPointerInit;
   }
   return false;

Modified: cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp?rev=370773&r1=370772&r2=370773&view=diff
==
--- cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp (original)
+++ cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp Tue Sep  3 09:17:24 
2019
@@ -7,13 +7,21 @@ struct [[gsl::Owner(int)]] MyIntOwner {
 struct [[gsl::Pointer(int)]] MyIntPointer {
   MyIntPointer(int *p = nullptr);
   // Conversion operator and constructor conversion will result in two
-  // different ASTs. The former is tested with another owner and 
+  // different ASTs. The former is tested with another owner and
   // pointer type.
   MyIntPointer(const MyIntOwner &);
   int &operator*();
   MyIntOwner toOwner();
 };
 
+struct MySpecialIntPointer : MyIntPointer {
+};
+
+// We did see examples in the wild when a derived class changes
+// the ownership model. So we have a test for it.
+struct [[gsl::Owner(int)]] MyOwnerIntPointer : MyIntPointer {
+};
+
 struct [[gsl::Pointer(long)]] MyLongPointerFromConversion {
   MyLongPointerFromConversion(long *p = nullptr);
   long &operator*();
@@ -56,21 +64,21 @@ struct Y {
 };
 
 void dangligGslPtrFromTemporary() {
-  MyIntPointer p = Y{}.a; // expected-warning {{temporary whose address is 
used as value of local variable 'p' will be destroyed at the end of the 
full-expression}}
+  MyIntPointer p = Y{}.a; // TODO
   (void)p;
 }
 
 struct DanglingGslPtrField {
-  MyIntPointer p; // expected-note 2{{pointer member declared here}}
+  MyIntPointer p; // expected-note {{pointer member declared here}}
   MyLongPointerFromConversion p2; // expected-note {{pointer member declared 
here}}
-  DanglingGslPtrField(int i) : p(&i) {} // expected-warning {{initializing 
pointer member 'p' with the stack address of parameter 'i'}}
+  DanglingGslPtrField(int i) : p(&i) {} // TODO
   DanglingGslPtrField() : p2(MyLongOwnerWithConversion{}) {} // 
expected-warning {{initializing pointer member 'p2' to point to a temporary 
object whose lifetime is shorter than the lifetime of the constructed object}}
   DanglingGslPtrField(double) : p(MyIntOwner{}) {} // expected-warning 
{{initializing pointer member 'p' to point to a temporary object whose lifetime 
is shorter than the lifetime of the constructed object}}
 };
 
 MyIntPointer danglingGslPtrFromLocal() {
   int j;
-  return &j; // expected-warning {{address of stack memory associated with 
local variable 'j' returned}}
+  return &j; // TODO
 }
 
 MyIntPointer returningLocalPointer() {
@@ -124,6 +132,7 @@ template 
 struct basic_iterator {
   basic_iterator operator++();
   T& operator*() const;
+  T* operator->() const;
 };
 
 template
@@ -141,6 +150,12 @@ typename remove_reference::type &&mov
 template 
 auto data(const C &c) -> decltype(c.data());
 
+template 
+auto begin(C &c) -> decltype(c.begin());
+
+template
+T *begin(T (&array)[N]);
+
 template 
 struct vector {
   typedef __gnu_cxx::basic_iterator iterator;
@@ -158,6 +173,8 @@ struct basic_string_view {
 
 template
 struct basic_string {
+  basic_string();
+  basic_string(const T *);
   const T *c_str() const;
   operator basic_string_view () const;
 };
@@ -188,8 +205,23 @@ struct any {};
 
 template
 

[PATCH] D66302: [SVE][Inline-Asm] Support for SVE asm operands

2019-09-03 Thread Kerry McLaughlin via Phabricator via cfe-commits
kmclaughlin marked an inline comment as done.
kmclaughlin added a subscriber: ruiu.
kmclaughlin added a comment.

Thank you to @gribozavr & @ruiu for spotting the warning caused by this patch, 
and the suggestions to use -Wimplicit-fallthrough!




Comment at: llvm/trunk/lib/Target/AArch64/AArch64ISelLowering.cpp:5836-5837
   if (VT.getSizeInBits() == 128)
 return std::make_pair(0U, &AArch64::FPR128_loRegClass);
+case 'y':
+  if (!Subtarget->hasFPARMv8())

gribozavr wrote:
> ```
> AArch64ISelLowering.cpp:5837:5: warning: unannotated fall-through between 
> switch labels [-Wimplicit-fallthrough]
> AArch64ISelLowering.cpp:5837:5: note: insert 'LLVM_FALLTHROUGH;' to silence 
> this warning
> AArch64ISelLowering.cpp:5837:5: note: insert 'break;' to avoid fall-through
> ```
> 
> Is the fallthrough intentional?
The fallthrough was not intentional; this should now be resolved by D67095


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66302/new/

https://reviews.llvm.org/D66302



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


[PATCH] D67058: [clang][CodeGen] Add alias for cpu_dispatch function with IFunc

2019-09-03 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added inline comments.



Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2957
+if (!AliasFunc) {
+  auto *IFunc = cast(GetOrCreateLLVMFunction(
+  AliasName, DeclTy, GD, /*ForVTable=*/false, /*DontDefer=*/true,

erichkeane wrote:
> I think we want this in GetOrCreateMultiVersionResolver, so that it gets 
> created when the ifunc does.  That way you just need a 
> "FD->isCPUDispatchMultiVersion() || isCPUSpecificMultiVersion()" check inside 
> the supportsIFunc branch.
After discussing this offline, I believe this is the right function to create 
the alias.  The motivating example is:

// TU1:
__attribute__((cpu_dispatch(a,b,c))) void foo(void);

// TU2:
extern void foo(void);

Currently, TU1 doesn't bother to emit the ifunc, because we've attached 
emitting this to when this is referenced.

We made that choice because we expected TU2 to mark 'foo' as 
cpu_dispatch/cpu_specific in SOME way.  I believe that it is harmless to emit 
the ifunc all the time, which this is attempting to do.  However, this needs to 
change the ifunc to have LinkOnceODR linkage in 
GetOrCreateMultiVersionResolver, otherwise this can cause linker errors.





Comment at: clang/lib/CodeGen/CodeGenModule.cpp:2961
+  auto *GA = llvm::GlobalAlias::create(
+ DeclTy, 0, getFunctionLinkage(GD), AliasName, IFunc, &getModule());
+  const auto *D = GD.getDecl();

I think the alias always needs LinkOnceODR linkage, to match the (new) IFunc 
linkage.


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67058/new/

https://reviews.llvm.org/D67058



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


[PATCH] D66806: [LifetimeAnalysis] Fix some false positives

2019-09-03 Thread Phabricator via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370773: [LifetimeAnalysis] Fix some false positives 
(authored by xazax, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66806?vs=217411&id=218466#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66806/new/

https://reviews.llvm.org/D66806

Files:
  cfe/trunk/lib/Sema/SemaInit.cpp
  cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp

Index: cfe/trunk/lib/Sema/SemaInit.cpp
===
--- cfe/trunk/lib/Sema/SemaInit.cpp
+++ cfe/trunk/lib/Sema/SemaInit.cpp
@@ -6775,6 +6775,10 @@
 static void handleGslAnnotatedTypes(IndirectLocalPath &Path, Expr *Call,
 LocalVisitor Visit) {
   auto VisitPointerArg = [&](const Decl *D, Expr *Arg) {
+// We are not interested in the temporary base objects of gsl Pointers:
+//   Temp().ptr; // Here ptr might not dangle.
+if (isa(Arg->IgnoreImpCasts()))
+  return;
 Path.push_back({IndirectLocalPathEntry::GslPointerInit, Arg, D});
 if (Arg->isGLValue())
   visitLocalsRetainedByReferenceBinding(Path, Arg, RK_ReferenceBinding,
@@ -7295,6 +7299,8 @@
   for (auto It = Path.rbegin(), End = Path.rend(); It != End; ++It) {
 if (It->Kind == IndirectLocalPathEntry::VarInit)
   continue;
+if (It->Kind == IndirectLocalPathEntry::AddressOf)
+  continue;
 return It->Kind == IndirectLocalPathEntry::GslPointerInit;
   }
   return false;
Index: cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
===
--- cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
+++ cfe/trunk/test/Sema/warn-lifetime-analysis-nocfg.cpp
@@ -7,13 +7,21 @@
 struct [[gsl::Pointer(int)]] MyIntPointer {
   MyIntPointer(int *p = nullptr);
   // Conversion operator and constructor conversion will result in two
-  // different ASTs. The former is tested with another owner and 
+  // different ASTs. The former is tested with another owner and
   // pointer type.
   MyIntPointer(const MyIntOwner &);
   int &operator*();
   MyIntOwner toOwner();
 };
 
+struct MySpecialIntPointer : MyIntPointer {
+};
+
+// We did see examples in the wild when a derived class changes
+// the ownership model. So we have a test for it.
+struct [[gsl::Owner(int)]] MyOwnerIntPointer : MyIntPointer {
+};
+
 struct [[gsl::Pointer(long)]] MyLongPointerFromConversion {
   MyLongPointerFromConversion(long *p = nullptr);
   long &operator*();
@@ -56,21 +64,21 @@
 };
 
 void dangligGslPtrFromTemporary() {
-  MyIntPointer p = Y{}.a; // expected-warning {{temporary whose address is used as value of local variable 'p' will be destroyed at the end of the full-expression}}
+  MyIntPointer p = Y{}.a; // TODO
   (void)p;
 }
 
 struct DanglingGslPtrField {
-  MyIntPointer p; // expected-note 2{{pointer member declared here}}
+  MyIntPointer p; // expected-note {{pointer member declared here}}
   MyLongPointerFromConversion p2; // expected-note {{pointer member declared here}}
-  DanglingGslPtrField(int i) : p(&i) {} // expected-warning {{initializing pointer member 'p' with the stack address of parameter 'i'}}
+  DanglingGslPtrField(int i) : p(&i) {} // TODO
   DanglingGslPtrField() : p2(MyLongOwnerWithConversion{}) {} // expected-warning {{initializing pointer member 'p2' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
   DanglingGslPtrField(double) : p(MyIntOwner{}) {} // expected-warning {{initializing pointer member 'p' to point to a temporary object whose lifetime is shorter than the lifetime of the constructed object}}
 };
 
 MyIntPointer danglingGslPtrFromLocal() {
   int j;
-  return &j; // expected-warning {{address of stack memory associated with local variable 'j' returned}}
+  return &j; // TODO
 }
 
 MyIntPointer returningLocalPointer() {
@@ -124,6 +132,7 @@
 struct basic_iterator {
   basic_iterator operator++();
   T& operator*() const;
+  T* operator->() const;
 };
 
 template
@@ -141,6 +150,12 @@
 template 
 auto data(const C &c) -> decltype(c.data());
 
+template 
+auto begin(C &c) -> decltype(c.begin());
+
+template
+T *begin(T (&array)[N]);
+
 template 
 struct vector {
   typedef __gnu_cxx::basic_iterator iterator;
@@ -158,6 +173,8 @@
 
 template
 struct basic_string {
+  basic_string();
+  basic_string(const T *);
   const T *c_str() const;
   operator basic_string_view () const;
 };
@@ -188,8 +205,23 @@
 
 template
 T any_cast(const any& operand);
+
+template
+struct reference_wrapper {
+  template
+  reference_wrapper(U &&);
+};
+
+template
+reference_wrapper ref(T& t) noexcept;
 }
 
+struct Unannotated {
+  typedef std::vector::iterator iterator;
+  iterator begin();
+  operator iterator() const;
+};
+
 void modelIterators() {
   std::vector::iterator it = std::vector().beg

r370779 - clang: default to DWARF 4 for FreeBSD 12.0 and later

2019-09-03 Thread Ed Maste via cfe-commits
Author: emaste
Date: Tue Sep  3 09:30:21 2019
New Revision: 370779

URL: http://llvm.org/viewvc/llvm-project?rev=370779&view=rev
Log:
clang: default to DWARF 4 for FreeBSD 12.0 and later

Older FreeBSD versions included GDB 6.1 and had other tools that were
unable to handle debug information newer than DWARF 2.  Those tools have
since been updated.  (An old version of GDB is still kept for kernel
crash handling, but the kernel is compiled with an explicit -gdwarf2.)

Reviewed by:dim
Differential Revision:  https://reviews.llvm.org/D66760

Modified:
cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
cfe/trunk/lib/Driver/ToolChains/FreeBSD.h
cfe/trunk/test/Driver/debug-options.c

Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp?rev=370779&r1=370778&r2=370779&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.cpp Tue Sep  3 09:30:21 2019
@@ -364,6 +364,12 @@ ToolChain::CXXStdlibType FreeBSD::GetDef
   return ToolChain::CST_Libstdcxx;
 }
 
+unsigned FreeBSD::GetDefaultDwarfVersion() const {
+  if (getTriple().getOSMajorVersion() < 12)
+return 2;
+  return 4;
+}
+
 void FreeBSD::addLibStdCxxIncludePaths(
 const llvm::opt::ArgList &DriverArgs,
 llvm::opt::ArgStringList &CC1Args) const {

Modified: cfe/trunk/lib/Driver/ToolChains/FreeBSD.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/FreeBSD.h?rev=370779&r1=370778&r2=370779&view=diff
==
--- cfe/trunk/lib/Driver/ToolChains/FreeBSD.h (original)
+++ cfe/trunk/lib/Driver/ToolChains/FreeBSD.h Tue Sep  3 09:30:21 2019
@@ -69,7 +69,7 @@ public:
   const llvm::opt::ArgList &Args) const override;
   bool isPIEDefault() const override;
   SanitizerMask getSupportedSanitizers() const override;
-  unsigned GetDefaultDwarfVersion() const override { return 2; }
+  unsigned GetDefaultDwarfVersion() const override;
   // Until dtrace (via CTF) and LLDB can deal with distributed debug info,
   // FreeBSD defaults to standalone/full debug info.
   bool GetDefaultStandaloneDebug() const override { return true; }

Modified: cfe/trunk/test/Driver/debug-options.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/debug-options.c?rev=370779&r1=370778&r2=370779&view=diff
==
--- cfe/trunk/test/Driver/debug-options.c (original)
+++ cfe/trunk/test/Driver/debug-options.c Tue Sep  3 09:30:21 2019
@@ -66,8 +66,12 @@
 // RUN: -check-prefix=G_DWARF4 %s
 
 // FreeBSD.
-// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd10.0 2>&1 \
-// RUN: | FileCheck -check-prefix=G_GDB %s
+// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd11.0 2>&1 \
+// RUN: | FileCheck -check-prefix=G_GDB \
+// RUN: -check-prefix=G_DWARF2 %s
+// RUN: %clang -### -c -g %s -target x86_64-pc-freebsd12.0 2>&1 \
+// RUN: | FileCheck -check-prefix=G_GDB \
+// RUN: -check-prefix=G_DWARF4 %s
 
 // Windows.
 // RUN: %clang -### -c -g %s -target x86_64-w64-windows-gnu 2>&1 \


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


[PATCH] D50294: [Driver] Use -gdwarf-3 by default for FreeBSD

2019-09-03 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay abandoned this revision.
MaskRay added a comment.

Abandon due to D66760 


Repository:
  rC Clang

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D50294/new/

https://reviews.llvm.org/D50294



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


[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-09-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:31-32
+
+  if (!MatchedDecl->isLocalVarDecl())
+return;
+

jpakkane wrote:
> aaron.ballman wrote:
> > I think this should be made into a local AST matcher so the check can be 
> > hoisted into the matchers.
> As was discussed earlier, the use of isLocalVarDecl is used here because:
> 
> - it has the exact semantics needed in this particular case
> - it is not available as a matcher, I could not make plain matchers replicate 
> its behaviour and even if I could, reimplementing it from scratch seems a bit 
> pointless
> 
> If there is a way to use that function directly in the matcher code, let me 
> know how it's done and I will fix this. But if not, then sadly I have no idea 
> how that should be fixed and it is probably a bigger development task than 
> this checker itself.
You can create your own AST matchers that are used only in this translation 
unit. e.g.,
```
AST_MATCHER(VarDecl, isLocalVarDecl) {
  return Node.isLocalVarDecl();
}
```
and then use this in your AST matchers.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:59
+  } else if (TypePtr->isFloatingType()) {
+InitializationString = " = (0.0/0.0)"; // NaN without needing #includes
+  } else if (TypePtr->isPointerType()) {

jpakkane wrote:
> aaron.ballman wrote:
> > I would rather see the correct NaN inserted along with the include. See 
> > StringFindStartswithCheck.cpp for an example of how to use the include 
> > inserter.
> I copied the implementation and could make it add the update. However I could 
> not for the life of me make the test framework accept this. It will always 
> flag an error even though there should be a comment that declares it in the 
> test source. Any help is appreciated.
So the include is inserted as you expect, but the test continues to fail? What 
does your test look like for it? What failures are you getting?



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:76
+  else if (TypePtr->isFloatingType()) {
+InitializationString = " = NAN";
+AddMathInclude = true;

In C++11 mode, I think this should recommend 
`std::numeric_limits::quiet_NaN()` if possible, from `` rather 
than ``.



Comment at: 
clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp:86-101
+diag(MatchedDecl->getLocation(), "variable %0 is not initialized")
+<< MatchedDecl;
+diag(MatchedDecl->getLocation(), "insert initial value",
+ DiagnosticIDs::Note)
+<< FixItHint::CreateInsertion(
+   MatchedDecl->getLocation().getLocWithOffset(
+   MatchedDecl->getName().size()),

I think you want this to be:
```
  auto Diagnostic = diag(MatchedDecl->getLocation(), "variable %0 is not 
initialized")
<< MatchedDecl
<< FixItHint::CreateInsertion(
   MatchedDecl->getLocation().getLocWithOffset(
   MatchedDecl->getName().size()),
   InitializationString);
if (AddMathInclude) {
  auto IncludeHint = IncludeInserter->CreateIncludeInsertion(
  Source.getFileID(MatchedDecl->getBeginLoc()), MathHeader, false);
  if (IncludeHint)
Diagnostic << *IncludeHint;
}
```


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64671/new/

https://reviews.llvm.org/D64671



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


[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-03 Thread David Gatwood via Phabricator via cfe-commits
dgatwood updated this revision to Diff 218478.
dgatwood added a comment.

Incorporated feedback.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65917/new/

https://reviews.llvm.org/D65917

Files:
  clang-tools-extra/clang-tidy/google/CMakeLists.txt
  clang-tools-extra/clang-tidy/google/GoogleTidyModule.cpp
  clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp
  clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m

Index: clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/google-objc-require-category-method-prefixes.m
@@ -0,0 +1,35 @@
+// RUN: %check_clang_tidy %s google-objc-require-category-method-prefixes %t -config="{CheckOptions: [{key: google-objc-require-category-method-prefixes.WhitelistedPrefixes, value: GMO}]}"
+
+@class NSString;
+
+@interface NSURL
++ (nullable instancetype)URLWithString:(NSString *)URLString;
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface NSURL (CustomExtension)
+
+- (void)unprefixedMethod;
+- (void)unprefixed;
+- (void)justprefixed_;
+
+@end
+
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'unprefixedMethod' is not properly prefixed [google-objc-require-category-method-prefixes]
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'unprefixed' is not properly prefixed [google-objc-require-category-method-prefixes]
+// CHECK-MESSAGES: :[[@LINE-6]]:1: warning: the category method 'justprefixed_' is not properly prefixed [google-objc-require-category-method-prefixes]
+
+@interface NSURL (CustomExtension2)
+- (void)gmo_prefixedMethod;
+@end
+
+@interface GMOURL
++ (nullable instancetype)URLWithString:(NSString *)URLString;
++ (instancetype)alloc;
+- (instancetype)init;
+@end
+
+@interface GMOURL (CustomExtension3)
+- (void)unprefixedMethodInWhitelistedClass;
+@end
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -230,6 +230,7 @@
google-objc-avoid-throwing-exception
google-objc-function-naming
google-objc-global-variable-declaration
+   google-objc-require-category-method-prefixes
google-readability-avoid-underscore-in-googletest-name
google-readability-braces-around-statements (redirects to readability-braces-around-statements) 
google-readability-casting
Index: clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
===
--- /dev/null
+++ clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst
@@ -0,0 +1,44 @@
+.. title:: clang-tidy - google-objc-require-category-method-prefixes
+
+google-objc-require-category-method-prefixes
+===
+
+Warns when Objective-C category method names are not properly prefixed (e.g.
+``gmo_methodName``) unless the category is extending a class with a
+(configurable) whitelisted prefix.
+
+The Google Objective-C style guide requires
+`prefixes for methods http://go/objc-style#Category_Names`_ in categories on
+classes that you don't control (for example, categories on Apple or third-party
+framework classes or classes created by other teams) to prevent name collisions
+when those frameworks are updated.
+
+This checker ensures that all methods in categories have some sort of prefix
+(e.g. ``gmo_``). It excludes categories on classes whose names have a
+whitelisted three-letter prefix.
+
+For example, the following code sample is a properly prefixed method on a
+non-owned class (``NSObject``):
+
+.. code-block:: objc
+  @interface NSObject (QEDMyCategory)
+  - (BOOL)qed_myCustomMethod;
+  @end
+
+If you whitelist the ``QED`` three-letter prefix, the following code sample
+is also allowed:
+
+.. code-block:: objc
+
+  @interface QEDMyClass (MyCategory)
+  - (BOOL)myCustomMethod;
+  @end
+
+Options
+---
+
+.. option:: WhitelistedPrefixes
+
+   A semicolon-delimited list of class name prefixes.  Methods in categories
+   that extend classes whose names begin with any of these prefixes are exempt
+   from the method name prefixing requirement.
Index: clang-tools-extra/docs/ReleaseNotes.rst
===
--- clang-tools-extra/docs/ReleaseNotes.rst
+++ clang-tools-extra/docs/ReleaseNotes.rst
@@ -67,6 +67,13 @@
 Improvements to clang-tidy
 --
 
+- New :doc:`google-objc-require-category-method-prefixes
+  ` che

[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-03 Thread Eugene Zelenko via Phabricator via cfe-commits
Eugene.Zelenko added inline comments.



Comment at: clang-tools-extra/docs/ReleaseNotes.rst:70
 
+- New :doc:`google-objc-require-category-method-prefixes
+  ` check.

Please sort new checks list alphabetically.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65917/new/

https://reviews.llvm.org/D65917



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


[PATCH] D66699: [PowerPC][Altivec] Fix constant argument for vec_dss

2019-09-03 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 218479.
jsji added a comment.

Add range check and test.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66699/new/

https://reviews.llvm.org/D66699

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Headers/altivec.h
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/altivec-dss.c
  clang/test/CodeGen/builtins-ppc-error.c


Index: clang/test/CodeGen/builtins-ppc-error.c
===
--- clang/test/CodeGen/builtins-ppc-error.c
+++ clang/test/CodeGen/builtins-ppc-error.c
@@ -73,3 +73,8 @@
   __builtin_unpack_vector_int128(vsllli, index); //expected-error {{argument 
to '__builtin_unpack_vector_int128' must be a constant integer}}
   __builtin_unpack_vector_int128(vsllli, 5); //expected-error {{argument value 
5 is outside the valid range [0, 1]}}
 }
+
+void testDSS(int index) {
+  vec_dss(index); //expected-error {{argument to '__builtin_altivec_dss' must 
be a constant integer}}
+  vec_dss(5); //expected-error {{argument value 5 is outside the valid range 
[0, 3]}}
+}
Index: clang/test/CodeGen/altivec-dss.c
===
--- /dev/null
+++ clang/test/CodeGen/altivec-dss.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-linux-gnu -S -O0 -o - %s -target-feature 
+altivec | FileCheck %s
+
+// REQUIRES: powerpc-registered-target
+
+#include 
+
+// CHECK-LABEL: test1
+// CHECK: dss 
+void test1() {
+  vec_dss(1);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3220,6 +3220,8 @@
   case PPC::BI__builtin_altivec_crypto_vshasigmad:
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
+  case PPC::BI__builtin_altivec_dss:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3);
   case PPC::BI__builtin_tbegin:
   case PPC::BI__builtin_tend: i = 0; l = 0; u = 1; break;
   case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7; break;
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers/altivec.h
@@ -3286,9 +3286,7 @@
 
 /* vec_dss */
 
-static __inline__ void __attribute__((__always_inline__)) vec_dss(int __a) {
-  __builtin_altivec_dss(__a);
-}
+#define vec_dss __builtin_altivec_dss
 
 /* vec_dssall */
 
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -55,7 +55,7 @@
 BUILTIN(__builtin_altivec_vctsxs, "V4SiV4fIi", "")
 BUILTIN(__builtin_altivec_vctuxs, "V4UiV4fIi", "")
 
-BUILTIN(__builtin_altivec_dss, "vUi", "")
+BUILTIN(__builtin_altivec_dss, "vUIi", "")
 BUILTIN(__builtin_altivec_dssall, "v", "")
 BUILTIN(__builtin_altivec_dst, "vvC*iUi", "")
 BUILTIN(__builtin_altivec_dstt, "vvC*iUi", "")


Index: clang/test/CodeGen/builtins-ppc-error.c
===
--- clang/test/CodeGen/builtins-ppc-error.c
+++ clang/test/CodeGen/builtins-ppc-error.c
@@ -73,3 +73,8 @@
   __builtin_unpack_vector_int128(vsllli, index); //expected-error {{argument to '__builtin_unpack_vector_int128' must be a constant integer}}
   __builtin_unpack_vector_int128(vsllli, 5); //expected-error {{argument value 5 is outside the valid range [0, 1]}}
 }
+
+void testDSS(int index) {
+  vec_dss(index); //expected-error {{argument to '__builtin_altivec_dss' must be a constant integer}}
+  vec_dss(5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
+}
Index: clang/test/CodeGen/altivec-dss.c
===
--- /dev/null
+++ clang/test/CodeGen/altivec-dss.c
@@ -0,0 +1,11 @@
+// RUN: %clang_cc1 -triple powerpc-linux-gnu -S -O0 -o - %s -target-feature +altivec | FileCheck %s
+
+// REQUIRES: powerpc-registered-target
+
+#include 
+
+// CHECK-LABEL: test1
+// CHECK: dss 
+void test1() {
+  vec_dss(1);
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3220,6 +3220,8 @@
   case PPC::BI__builtin_altivec_crypto_vshasigmad:
 return SemaBuiltinConstantArgRange(TheCall, 1, 0, 1) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 15);
+  case PPC::BI__builtin_altivec_dss:
+return SemaBuiltinConstantArgRange(TheCall, 0, 0, 3);
   case PPC::BI__builtin_tbegin:
   case PPC::BI__builtin_tend: i = 0; l = 0; u = 1; break;
   case PPC::BI__builtin_tsr: i = 0; l = 0; u = 7; break;
Index: clang/lib/Headers/altivec.h
===
--- clang/lib/Headers/altivec.h
+++ clang/lib/Headers

[PATCH] D66699: [PowerPC][Altivec] Fix constant argument for vec_dss

2019-09-03 Thread Jinsong Ji via Phabricator via cfe-commits
jsji marked 2 inline comments as done.
jsji added inline comments.



Comment at: clang/test/CodeGen/builtins-ppc-error.c:78
+void testDSS(int index) {
+  vec_dss(index); //expected-error {{argument to '__builtin_altivec_dss' must 
be a constant integer}}
+

wuzish wrote:
> It would be better if add range constraint check at 
> Sema::CheckPPCBuiltinFunctionCall
Good point, Done. Thanks.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66699/new/

https://reviews.llvm.org/D66699



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


[PATCH] D65917: [clang-tidy] Added check for the Google style guide's category method naming rule.

2019-09-03 Thread David Gatwood via Phabricator via cfe-commits
dgatwood marked 17 inline comments as done.
dgatwood added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/google/RequireCategoryMethodPrefixesCheck.cpp:57
+  }
+  std::string method_name = method_declaration->getNameAsString();
+  auto owning_objc_class_interface = method_declaration->getClassInterface();

aaron.ballman wrote:
> This should use `getName()` to get a `StringRef` to avoid the copy.
That's actually what I originally tried, but that method won't work here, 
unless I'm missing something.  The getName() method crashes with a message 
saying that "Name is not a simple identifier".



Comment at: 
clang-tools-extra/docs/clang-tidy/checks/google-objc-require-category-method-prefixes.rst:19
+
+You should set the clang option WhitelistedPrefixes to a semicolon-delimited
+lits of class prefixes within your project if you want to be able to create

Eugene.Zelenko wrote:
> See other checks documentation for proper option section style.
> 
> clang -> :program:`clang-tidy` and enclose WhitelistedPrefixes in single 
> back-ticks.
Removed the text in question, because it duplicates the Options info.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D65917/new/

https://reviews.llvm.org/D65917



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


[PATCH] D66361: Improve behavior in the case of stack exhaustion.

2019-09-03 Thread Kamil Rytarowski via Phabricator via cfe-commits
krytarowski added a comment.

This change broke on NetBSD.

http://lab.llvm.org:8011/builders/netbsd-amd64/builds/22003/steps/run%20unit%20tests/logs/FAIL%3A%20Clang%3A%3Astack-exhaustion.cpp

   (view as text)
  
   TEST 'Clang :: SemaTemplate/stack-exhaustion.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   /home/motus/netbsd8/netbsd8/build/bin/clang -cc1 
-internal-isystem /data/motus/netbsd8/netbsd8/build/lib/clang/10.0.0/include 
-nostdsysteminc -verify 
/data/motus/netbsd8/netbsd8/llvm/tools/clang/test/SemaTemplate/stack-exhaustion.cpp
  --
  Exit Code: 139
  
  Command Output (stderr):
  --
  + : 'RUN: at line 1'
  + /home/motus/netbsd8/netbsd8/build/bin/clang -cc1 -internal-isystem 
/data/motus/netbsd8/netbsd8/build/lib/clang/10.0.0/include -nostdsysteminc 
-verify 
/data/motus/netbsd8/netbsd8/llvm/tools/clang/test/SemaTemplate/stack-exhaustion.cpp
  Stack dump:
  0.Program arguments: /home/motus/netbsd8/netbsd8/build/bin/clang -cc1 
-internal-isystem /data/motus/netbsd8/netbsd8/build/lib/clang/10.0.0/include 
-nostdsysteminc -verify 
/data/motus/netbsd8/netbsd8/llvm/tools/clang/test/SemaTemplate/stack-exhaustion.cpp
 
  1.
/data/motus/netbsd8/netbsd8/llvm/tools/clang/test/SemaTemplate/stack-exhaustion.cpp:9:10:
 current parser token ';'
  #0 0x0242038c llvm::sys::PrintStackTrace(llvm::raw_ostream&) 
(/home/motus/netbsd8/netbsd8/build/bin/clang+0x242038c)
  #1 0x0241e5ee llvm::sys::RunSignalHandlers() 
(/home/motus/netbsd8/netbsd8/build/bin/clang+0x241e5ee)
  #2 0x0241e6ee SignalHandler(int) 
(/home/motus/netbsd8/netbsd8/build/bin/clang+0x241e6ee)
  
/data/motus/netbsd8/netbsd8/build/tools/clang/test/SemaTemplate/Output/stack-exhaustion.cpp.script:
 line 1:  7058 Segmentation fault  (core dumped) 
/home/motus/netbsd8/netbsd8/build/bin/clang -cc1 -internal-isystem 
/data/motus/netbsd8/netbsd8/build/lib/clang/10.0.0/include -nostdsysteminc 
-verify 
/data/motus/netbsd8/netbsd8/llvm/tools/clang/test/SemaTemplate/stack-exhaustion.cpp
  
  --
  
  

Please fix.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66361/new/

https://reviews.llvm.org/D66361



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


r370792 - [CUDA] Use activemask.b32 instruction to implement __activemask w/ CUDA-9.2+

2019-09-03 Thread Artem Belevich via cfe-commits
Author: tra
Date: Tue Sep  3 10:31:58 2019
New Revision: 370792

URL: http://llvm.org/viewvc/llvm-project?rev=370792&view=rev
Log:
[CUDA] Use activemask.b32 instruction to implement __activemask w/ CUDA-9.2+

vote.ballot instruction is gone in recent CUDA versions and
vote.sync.ballot can not be used because it needs a thread mask parameter.
Fortunately PTX 6.2 (introduced with CUDA-9.2) provides activemask.b32
instruction for this.

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

Modified:
cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h

Modified: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h?rev=370792&r1=370791&r2=370792&view=diff
==
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h (original)
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h Tue Sep  3 10:31:58 2019
@@ -211,7 +211,15 @@ inline __device__ unsigned int __ballot_
   return __nvvm_vote_ballot_sync(mask, pred);
 }
 
-inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); }
+inline __device__ unsigned int __activemask() {
+#if CUDA_VERSION < 9020
+  return __nvvm_vote_ballot(1);
+#else
+  unsigned int mask;
+  asm volatile("activemask.b32 %0;" : "=r"(mask));
+  return mask;
+#endif
+}
 
 inline __device__ unsigned int __fns(unsigned mask, unsigned base, int offset) 
{
   return __nvvm_fns(mask, base, offset);


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


[PATCH] D67112: [Sema] Add implicit cast for conversion of function references

2019-09-03 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
aaronpuchert marked 2 inline comments as done.
aaronpuchert added a comment.

If anyone shares my feeling that the boolean output parameters of 
`CompareReferenceRelationship` should rather move to the return value, I would 
be happy to do that.




Comment at: clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp:5
+// CHECK: VarDecl {{.*}} fp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: DeclRefExpr {{.*}} 'void () noexcept' lvalue Function {{.*}} 
'f' 'void () noexcept'

This is new.



Comment at: clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp:15
+// CHECK: VarDecl {{.*}} xp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void () noexcept':'void () noexcept' 
lvalue 

This is also new.


When initializing a reference to a non-noexcept function from a noexcept
function we didn't add an implicit cast node, which confused a type-
checking assertion in CodeGen. The same conversion is used for function
pointer conversion already.

Fixes PR43154.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67112

Files:
  clang/include/clang/AST/OperationKinds.def
  clang/include/clang/Sema/Initialization.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Sema/SemaCast.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp

Index: clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp
===
--- /dev/null
+++ clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp
@@ -0,0 +1,17 @@
+// RUN: %clang_cc1 -std=c++17 -ast-dump %s | FileCheck %s
+
+void f() noexcept;
+// CHECK: VarDecl {{.*}} fp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: DeclRefExpr {{.*}} 'void () noexcept' lvalue Function {{.*}} 'f' 'void () noexcept'
+void (&fp)() = f;
+
+struct X {
+  typedef void (&fp)() noexcept;
+  operator fp();
+} x;
+
+// CHECK: VarDecl {{.*}} xp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void () noexcept':'void () noexcept' lvalue 
+void (&xp)() = x;
Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -4296,12 +4296,10 @@
 /// reference (C++ [dcl.ref.init]p4). Neither type can be a reference
 /// type, and the first type (T1) is the pointee type of the reference
 /// type being initialized.
-Sema::ReferenceCompareResult
-Sema::CompareReferenceRelationship(SourceLocation Loc,
-   QualType OrigT1, QualType OrigT2,
-   bool &DerivedToBase,
-   bool &ObjCConversion,
-   bool &ObjCLifetimeConversion) {
+Sema::ReferenceCompareResult Sema::CompareReferenceRelationship(
+SourceLocation Loc, QualType OrigT1, QualType OrigT2, bool &DerivedToBase,
+bool &FuncRefConversion, bool &ObjCConversion,
+bool &ObjCLifetimeConversion) {
   assert(!OrigT1->isReferenceType() &&
 "T1 must be the pointee type of the reference type");
   assert(!OrigT2->isReferenceType() && "T2 cannot be a reference type");
@@ -4317,6 +4315,7 @@
   //   reference-related to "cv2 T2" if T1 is the same type as T2, or
   //   T1 is a base class of T2.
   DerivedToBase = false;
+  FuncRefConversion = false;
   ObjCConversion = false;
   ObjCLifetimeConversion = false;
   QualType ConvertedT2;
@@ -4331,15 +4330,16 @@
Context.canBindObjCObjectType(UnqualT1, UnqualT2))
 ObjCConversion = true;
   else if (UnqualT2->isFunctionType() &&
-   IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2))
+   IsFunctionConversion(UnqualT2, UnqualT1, ConvertedT2)) {
 // C++1z [dcl.init.ref]p4:
 //   cv1 T1" is reference-compatible with "cv2 T2" if [...] T2 is "noexcept
 //   function" and T1 is "function"
 //
 // We extend this to also apply to 'noreturn', so allow any function
 // conversion between function types.
+FuncRefConversion = true;
 return Ref_Compatible;
-  else
+  } else
 return Ref_Incompatible;
 
   // At this point, we know that T1 and T2 are reference-related (at
@@ -4418,6 +4418,7 @@
 
 if (AllowRvalues) {
   bool DerivedToBase = false;
+  bool FuncPtrConversion = false;
   bool ObjCConversion = false;
   bool ObjCLifetimeConversion = false;
 
@@ -4432,12 +4433,13 @@
 
   if (!ConvTemplate &&
   S.CompareReferenceRelationship(
-

[PATCH] D66665: [CUDA] Use activemask.b32 instruction to implement __activemask w/ CUDA-9.2+

2019-09-03 Thread Artem Belevich via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370792: [CUDA] Use activemask.b32 instruction to implement 
__activemask w/ CUDA-9.2+ (authored by tra, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D5?vs=216886&id=218486#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D5/new/

https://reviews.llvm.org/D5

Files:
  cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -211,7 +211,15 @@
   return __nvvm_vote_ballot_sync(mask, pred);
 }
 
-inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); }
+inline __device__ unsigned int __activemask() {
+#if CUDA_VERSION < 9020
+  return __nvvm_vote_ballot(1);
+#else
+  unsigned int mask;
+  asm volatile("activemask.b32 %0;" : "=r"(mask));
+  return mask;
+#endif
+}
 
 inline __device__ unsigned int __fns(unsigned mask, unsigned base, int offset) 
{
   return __nvvm_fns(mask, base, offset);


Index: cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
===
--- cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
+++ cfe/trunk/lib/Headers/__clang_cuda_intrinsics.h
@@ -211,7 +211,15 @@
   return __nvvm_vote_ballot_sync(mask, pred);
 }
 
-inline __device__ unsigned int __activemask() { return __nvvm_vote_ballot(1); }
+inline __device__ unsigned int __activemask() {
+#if CUDA_VERSION < 9020
+  return __nvvm_vote_ballot(1);
+#else
+  unsigned int mask;
+  asm volatile("activemask.b32 %0;" : "=r"(mask));
+  return mask;
+#endif
+}
 
 inline __device__ unsigned int __fns(unsigned mask, unsigned base, int offset) {
   return __nvvm_fns(mask, base, offset);
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67112: [Sema] Add implicit cast for conversion of function references

2019-09-03 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert marked 2 inline comments as done.
aaronpuchert added a comment.

If anyone shares my feeling that the boolean output parameters of 
`CompareReferenceRelationship` should rather move to the return value, I would 
be happy to do that.




Comment at: clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp:5
+// CHECK: VarDecl {{.*}} fp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: DeclRefExpr {{.*}} 'void () noexcept' lvalue Function {{.*}} 
'f' 'void () noexcept'

This is new.



Comment at: clang/test/CXX/dcl.decl/dcl.init/dcl.init.ref/p4-ast.cpp:15
+// CHECK: VarDecl {{.*}} xp 'void (&)()' cinit
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void ()':'void ()' lvalue 
+// CHECK-NEXT: ImplicitCastExpr {{.*}} 'void () noexcept':'void () noexcept' 
lvalue 

This is also new.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67112/new/

https://reviews.llvm.org/D67112



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


[PATCH] D66748: [PowerPC][Altivec][Clang] Check compile-time constant for vec_dst*

2019-09-03 Thread Jinsong Ji via Phabricator via cfe-commits
jsji updated this revision to Diff 218485.
jsji added a comment.

Add range check and tests.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66748/new/

https://reviews.llvm.org/D66748

Files:
  clang/include/clang/Basic/BuiltinsPPC.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/builtins-ppc-error.c


Index: clang/test/CodeGen/builtins-ppc-error.c
===
--- clang/test/CodeGen/builtins-ppc-error.c
+++ clang/test/CodeGen/builtins-ppc-error.c
@@ -73,3 +73,15 @@
   __builtin_unpack_vector_int128(vsllli, index); //expected-error {{argument 
to '__builtin_unpack_vector_int128' must be a constant integer}}
   __builtin_unpack_vector_int128(vsllli, 5); //expected-error {{argument value 
5 is outside the valid range [0, 1]}}
 }
+
+
+void testDST(int index) {
+  vec_dst(&vsi, index, index); //expected-error {{argument to 
'__builtin_altivec_dst' must be a constant integer}}
+  vec_dst(&vsi, index, 5); //expected-error {{argument value 5 is outside the 
valid range [0, 3]}}
+  vec_dstt(&vsi, index, index); //expected-error {{argument to 
'__builtin_altivec_dstt' must be a constant integer}}
+  vec_dstt(&vsi, index, 5); //expected-error {{argument value 5 is outside the 
valid range [0, 3]}}
+  vec_dstst(&vsi, index, index); //expected-error {{argument to 
'__builtin_altivec_dstst' must be a constant integer}}
+  vec_dstst(&vsi, index, 5); //expected-error {{argument value 5 is outside 
the valid range [0, 3]}}
+  vec_dststt(&vsi, index, index); //expected-error {{argument to 
'__builtin_altivec_dststt' must be a constant integer}}
+  vec_dststt(&vsi, index, 5); //expected-error {{argument value 5 is outside 
the valid range [0, 3]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3227,6 +3227,11 @@
   case PPC::BI__builtin_tabortdci:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
+  case PPC::BI__builtin_altivec_dst:
+  case PPC::BI__builtin_altivec_dstt:
+  case PPC::BI__builtin_altivec_dstst:
+  case PPC::BI__builtin_altivec_dststt:
+return SemaBuiltinConstantArgRange(TheCall, 2, 0, 3);
   case PPC::BI__builtin_vsx_xxpermdi:
   case PPC::BI__builtin_vsx_xxsldwi:
 return SemaBuiltinVSX(TheCall);
Index: clang/include/clang/Basic/BuiltinsPPC.def
===
--- clang/include/clang/Basic/BuiltinsPPC.def
+++ clang/include/clang/Basic/BuiltinsPPC.def
@@ -57,10 +57,10 @@
 
 BUILTIN(__builtin_altivec_dss, "vUi", "")
 BUILTIN(__builtin_altivec_dssall, "v", "")
-BUILTIN(__builtin_altivec_dst, "vvC*iUi", "")
-BUILTIN(__builtin_altivec_dstt, "vvC*iUi", "")
-BUILTIN(__builtin_altivec_dstst, "vvC*iUi", "")
-BUILTIN(__builtin_altivec_dststt, "vvC*iUi", "")
+BUILTIN(__builtin_altivec_dst, "vvC*iUIi", "")
+BUILTIN(__builtin_altivec_dstt, "vvC*iUIi", "")
+BUILTIN(__builtin_altivec_dstst, "vvC*iUIi", "")
+BUILTIN(__builtin_altivec_dststt, "vvC*iUIi", "")
 
 BUILTIN(__builtin_altivec_vexptefp, "V4fV4f", "")
 


Index: clang/test/CodeGen/builtins-ppc-error.c
===
--- clang/test/CodeGen/builtins-ppc-error.c
+++ clang/test/CodeGen/builtins-ppc-error.c
@@ -73,3 +73,15 @@
   __builtin_unpack_vector_int128(vsllli, index); //expected-error {{argument to '__builtin_unpack_vector_int128' must be a constant integer}}
   __builtin_unpack_vector_int128(vsllli, 5); //expected-error {{argument value 5 is outside the valid range [0, 1]}}
 }
+
+
+void testDST(int index) {
+  vec_dst(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dst' must be a constant integer}}
+  vec_dst(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
+  vec_dstt(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dstt' must be a constant integer}}
+  vec_dstt(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
+  vec_dstst(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dstst' must be a constant integer}}
+  vec_dstst(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
+  vec_dststt(&vsi, index, index); //expected-error {{argument to '__builtin_altivec_dststt' must be a constant integer}}
+  vec_dststt(&vsi, index, 5); //expected-error {{argument value 5 is outside the valid range [0, 3]}}
+}
Index: clang/lib/Sema/SemaChecking.cpp
===
--- clang/lib/Sema/SemaChecking.cpp
+++ clang/lib/Sema/SemaChecking.cpp
@@ -3227,6 +3227,11 @@
   case PPC::BI__builtin_tabortdci:
 return SemaBuiltinConstantArgRange(TheCall, 0, 0, 31) ||
SemaBuiltinConstantArgRange(TheCall, 2, 0, 31);
+  ca

[PATCH] D67113: ICK_Function_Conversion and ICK_Qualification are third kind conversions

2019-09-03 Thread Aaron Puchert via Phabricator via cfe-commits
aaronpuchert created this revision.
aaronpuchert added a reviewer: rsmith.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Not sure if this has any effect, but it was inconsistent before.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67113

Files:
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaOverload.cpp


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5339,7 +5339,6 @@
   // conversions are fine.
   switch (SCS.Second) {
   case ICK_Identity:
-  case ICK_Function_Conversion:
   case ICK_Integral_Promotion:
   case ICK_Integral_Conversion: // Narrowing conversions are checked elsewhere.
   case ICK_Zero_Queue_Conversion:
@@ -5385,6 +5384,7 @@
   case ICK_Function_To_Pointer:
 llvm_unreachable("found a first conversion kind in Second");
 
+  case ICK_Function_Conversion:
   case ICK_Qualification:
 llvm_unreachable("found a third conversion kind in Second");
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4252,12 +4252,14 @@
   case ICK_Lvalue_To_Rvalue:
   case ICK_Array_To_Pointer:
   case ICK_Function_To_Pointer:
-  case ICK_Function_Conversion:
-  case ICK_Qualification:
   case ICK_Num_Conversion_Kinds:
   case ICK_C_Only_Conversion:
   case ICK_Incompatible_Pointer_Conversion:
 llvm_unreachable("Improper second standard conversion");
+
+  case ICK_Function_Conversion:
+  case ICK_Qualification:
+llvm_unreachable("Improper third standard conversion");
   }
 
   switch (SCS.Third) {


Index: clang/lib/Sema/SemaOverload.cpp
===
--- clang/lib/Sema/SemaOverload.cpp
+++ clang/lib/Sema/SemaOverload.cpp
@@ -5339,7 +5339,6 @@
   // conversions are fine.
   switch (SCS.Second) {
   case ICK_Identity:
-  case ICK_Function_Conversion:
   case ICK_Integral_Promotion:
   case ICK_Integral_Conversion: // Narrowing conversions are checked elsewhere.
   case ICK_Zero_Queue_Conversion:
@@ -5385,6 +5384,7 @@
   case ICK_Function_To_Pointer:
 llvm_unreachable("found a first conversion kind in Second");
 
+  case ICK_Function_Conversion:
   case ICK_Qualification:
 llvm_unreachable("found a third conversion kind in Second");
 
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4252,12 +4252,14 @@
   case ICK_Lvalue_To_Rvalue:
   case ICK_Array_To_Pointer:
   case ICK_Function_To_Pointer:
-  case ICK_Function_Conversion:
-  case ICK_Qualification:
   case ICK_Num_Conversion_Kinds:
   case ICK_C_Only_Conversion:
   case ICK_Incompatible_Pointer_Conversion:
 llvm_unreachable("Improper second standard conversion");
+
+  case ICK_Function_Conversion:
+  case ICK_Qualification:
+llvm_unreachable("Improper third standard conversion");
   }
 
   switch (SCS.Third) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r370795 - [www] Mark items complete in Clang 9 as 'Clang 9' rather than 'SVN'.

2019-09-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep  3 10:49:51 2019
New Revision: 370795

URL: http://llvm.org/viewvc/llvm-project?rev=370795&view=rev
Log:
[www] Mark items complete in Clang 9 as 'Clang 9' rather than 'SVN'.

Don't turn the boxes green yet, since Clang 9 hasn't been released.

Modified:
cfe/trunk/www/cxx_dr_status.html
cfe/trunk/www/cxx_status.html
cfe/trunk/www/make_cxx_dr_status

Modified: cfe/trunk/www/cxx_dr_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_dr_status.html?rev=370795&r1=370794&r2=370795&view=diff
==
--- cfe/trunk/www/cxx_dr_status.html (original)
+++ cfe/trunk/www/cxx_dr_status.html Tue Sep  3 10:49:51 2019
@@ -9955,19 +9955,19 @@ and POD class
 http://wg21.link/cwg1690";>1690
 C++14
 Associated namespace for local type
-SVN
+Clang 9
   
   
 http://wg21.link/cwg1691";>1691
 C++14
 Argument-dependent lookup and opaque enumerations
-SVN
+Clang 9
   
   
 http://wg21.link/cwg1692";>1692
 C++14
 Associated namespaces of doubly-nested classes
-SVN
+Clang 9
   
   
 http://wg21.link/cwg1693";>1693
@@ -10147,7 +10147,7 @@ and POD class
 http://wg21.link/cwg1722";>1722
 CD4
 Should lambda to function pointer conversion function be 
noexcept?
-SVN
+Clang 9
   
   
 http://wg21.link/cwg1723";>1723
@@ -10483,7 +10483,7 @@ and POD class
 http://wg21.link/cwg1778";>1778
 C++14
 exception-specification in explicitly-defaulted functions
-SVN
+Clang 9
   
   
 http://wg21.link/cwg1779";>1779
@@ -11047,7 +11047,7 @@ and POD class
 http://wg21.link/cwg1872";>1872
 CD4
 Instantiations of constexpr templates that cannot appear in 
constant expressions
-SVN
+Clang 9
   
   
 http://wg21.link/cwg1873";>1873
@@ -12655,7 +12655,7 @@ and POD class
 http://wg21.link/cwg2140";>2140
 CD4
 Lvalue-to-rvalue conversion of std::nullptr_t
-SVN
+Clang 9
   
   
 http://wg21.link/cwg2141";>2141
@@ -12835,7 +12835,7 @@ and POD class
 http://wg21.link/cwg2170";>2170
 DR
 Unclear definition of odr-use for arrays
-SVN
+Clang 9
   
   
 http://wg21.link/cwg2171";>2171
@@ -13567,7 +13567,7 @@ and POD class
 http://wg21.link/cwg2292";>2292
 DRWP
 simple-template-id is ambiguous between class-name and 
type-name
-SVN
+Clang 9
   
   
 http://wg21.link/cwg2293";>2293
@@ -13933,7 +13933,7 @@ and POD class
 http://wg21.link/cwg2353";>2353
 DR
 Potential results of a member access expression for a static data 
member
-SVN
+Clang 9
   
   
 http://wg21.link/cwg2354";>2354
@@ -14131,13 +14131,13 @@ and POD class
 http://wg21.link/cwg2386";>2386
 DR
 tuple_size requirements for structured binding
-Unknown
+Clang 9
   
   
 http://wg21.link/cwg2387";>2387
 DR
 Linkage of const-qualified variable template
-SVN
+Clang 9
   
   
 http://wg21.link/cwg2388";>2388

Modified: cfe/trunk/www/cxx_status.html
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/www/cxx_status.html?rev=370795&r1=370794&r2=370795&view=diff
==
--- cfe/trunk/www/cxx_status.html (original)
+++ cfe/trunk/www/cxx_status.html Tue Sep  3 10:49:51 2019
@@ -114,7 +114,7 @@ with http://libcxx.llvm.org/";>l
 

 http://wg21.link/p1009r2";>P1009R2 (DR)
-SVN
+Clang 9
   
 
   Static assertions
@@ -289,7 +289,7 @@ with http://libcxx.llvm.org/";>l
 

 http://wg21.link/p1286r2";>P1286R2 (DR)
-SVN
+Clang 9
   
 
   Deleted functions
@@ -664,7 +664,7 @@ version 3.7.
 

 http://wg21.link/p1771r1";>P1771R1 (DR)
-SVN
+Clang 9
   
 
   [[maybe_unused]] attribute
@@ -866,17 +866,17 @@ as the draft C++2a standard evolves.
 

 http://wg21.link/p1042r1";>P1042R1
-SVN
+Clang 9
   
 
   Designated initializers
   http://wg21.link/p0329r4";>P0329R4
-  SVN (Clang 10)
+  SVN
 
 
   template-parameter-list for generic lambdas
   http://wg21.link/p0428r2";>P0428R2
-  SVN
+  Clang 9
 
 
   Concepts
@@ -910,7 +910,7 @@ as the draft C++2a standard evolves.
 
   ADL and function templates that are not visible
   http://wg21.link/p0846r0";>P0846R0
-  SVN
+  Clang 9
 
 
   const mismatch with defaulted copy constructor
@@ -957,7 +957,7 @@ as the draft C++2a standard evolves.
 
   [[no_unique_address]] attribute
   http://wg21.link/p0840r2";>P0840R2
-  SVN
+  Clang 9
 
 
   [[likely]] and [[unlikely]] attributes
@@ -972,7 +972,7 @@ as the draft C++2a standard evolves.
 
   Pack expansion in lambda init-capture
   http://wg21.link/p0780r2";>P0780R2

r370798 - [analyzer] NonNullParamChecker and CStringChecker parameter number in checker message

2019-09-03 Thread Kristof Umann via cfe-commits
Author: szelethus
Date: Tue Sep  3 10:57:01 2019
New Revision: 370798

URL: http://llvm.org/viewvc/llvm-project?rev=370798&view=rev
Log:
[analyzer] NonNullParamChecker and CStringChecker parameter number in checker 
message

There are some functions which can't be given a null pointer as parameter either
because it has a nonnull attribute or it is declared to have undefined behavior
(e.g. strcmp()). Sometimes it is hard to determine from the checker message
which parameter is null at the invocation, so now this information is included
in the message.

This commit fixes https://bugs.llvm.org/show_bug.cgi?id=39358

Reviewed By: NoQ, Szelethus, whisperity

Patch by Tibor Brunner!

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

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
cfe/trunk/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
cfe/trunk/test/Analysis/Inputs/expected-plists/plist-output.m.plist
cfe/trunk/test/Analysis/misc-ps-region-store.m
cfe/trunk/test/Analysis/null-deref-ps.c

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp?rev=370798&r1=370797&r2=370798&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp Tue Sep  3 
10:57:01 2019
@@ -198,7 +198,8 @@ public:
   ProgramStateRef checkNonNull(CheckerContext &C,
ProgramStateRef state,
const Expr *S,
-   SVal l) const;
+   SVal l,
+   unsigned IdxOfArg) const;
   ProgramStateRef CheckLocation(CheckerContext &C,
 ProgramStateRef state,
 const Expr *S,
@@ -277,7 +278,8 @@ CStringChecker::assumeZero(CheckerContex
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C,
 ProgramStateRef state,
-const Expr *S, SVal l) const {
+const Expr *S, SVal l,
+unsigned IdxOfArg) const {
   // If a previous check has failed, propagate the failure.
   if (!state)
 return nullptr;
@@ -288,11 +290,13 @@ ProgramStateRef CStringChecker::checkNon
   if (stateNull && !stateNonNull) {
 if (Filter.CheckCStringNullArg) {
   SmallString<80> buf;
-  llvm::raw_svector_ostream os(buf);
+  llvm::raw_svector_ostream OS(buf);
   assert(CurrentFunctionDescription);
-  os << "Null pointer argument in call to " << CurrentFunctionDescription;
+  OS << "Null pointer argument in call to " << CurrentFunctionDescription
+ << ' ' << IdxOfArg << llvm::getOrdinalSuffix(IdxOfArg)
+ << " parameter";
 
-  emitNullArgBug(C, stateNull, S, os.str());
+  emitNullArgBug(C, stateNull, S, OS.str());
 }
 return nullptr;
   }
@@ -384,7 +388,7 @@ ProgramStateRef CStringChecker::CheckBuf
 
   // Check that the first buffer is non-null.
   SVal BufVal = C.getSVal(FirstBuf);
-  state = checkNonNull(C, state, FirstBuf, BufVal);
+  state = checkNonNull(C, state, FirstBuf, BufVal, 1);
   if (!state)
 return nullptr;
 
@@ -424,7 +428,7 @@ ProgramStateRef CStringChecker::CheckBuf
   // If there's a second buffer, check it as well.
   if (SecondBuf) {
 BufVal = state->getSVal(SecondBuf, LCtx);
-state = checkNonNull(C, state, SecondBuf, BufVal);
+state = checkNonNull(C, state, SecondBuf, BufVal, 2);
 if (!state)
   return nullptr;
 
@@ -1163,7 +1167,7 @@ void CStringChecker::evalCopyCommon(Chec
 
 // Ensure the destination is not null. If it is NULL there will be a
 // NULL pointer dereference.
-state = checkNonNull(C, state, Dest, destVal);
+state = checkNonNull(C, state, Dest, destVal, 1);
 if (!state)
   return;
 
@@ -1172,7 +1176,7 @@ void CStringChecker::evalCopyCommon(Chec
 
 // Ensure the source is not null. If it is NULL there will be a
 // NULL pointer dereference.
-state = checkNonNull(C, state, Source, srcVal);
+state = checkNonNull(C, state, Source, srcVal, 2);
 if (!state)
   return;
 
@@ -1383,7 +1387,7 @@ void CStringChecker::evalstrLengthCommon
   const Expr *Arg = CE->getArg(0);
   SVal ArgVal = state->getSVal(Arg, LCtx);
 
-  state = checkNonNull(C, state, Arg, ArgVal);
+  state = checkNonNull(C, state, Arg, ArgVal, 1);
 
   if (!state)
 return;
@@ -1541,14 +1545,14 @@ void CStringChecker::evalStrcpyCommon(Ch
   const Expr *Dst = CE->getArg(0);
   SVal DstVal = state->getSVal(Dst, LCtx);
 
-  state = checkNonNull(C, state, Dst, DstVal);
+  state = 

[PATCH] D66333: [analyzer] NonNullParamChecker and CStringChecker parameter number in checker message

2019-09-03 Thread Kristóf Umann via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370798: [analyzer] NonNullParamChecker and CStringChecker 
parameter number in checker… (authored by Szelethus, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D66333?vs=215754&id=218492#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66333/new/

https://reviews.llvm.org/D66333

Files:
  cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
  cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
  cfe/trunk/test/Analysis/Inputs/expected-plists/edges-new.mm.plist
  cfe/trunk/test/Analysis/Inputs/expected-plists/plist-output.m.plist
  cfe/trunk/test/Analysis/misc-ps-region-store.m
  cfe/trunk/test/Analysis/null-deref-ps.c

Index: cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
@@ -36,7 +36,9 @@
   void checkPreCall(const CallEvent &Call, CheckerContext &C) const;
 
   std::unique_ptr
-  genReportNullAttrNonNull(const ExplodedNode *ErrorN, const Expr *ArgE) const;
+  genReportNullAttrNonNull(const ExplodedNode *ErrorN,
+   const Expr *ArgE,
+   unsigned IdxOfArg) const;
   std::unique_ptr
   genReportReferenceToNullPointer(const ExplodedNode *ErrorN,
   const Expr *ArgE) const;
@@ -143,7 +145,7 @@
 
 std::unique_ptr R;
 if (haveAttrNonNull)
-  R = genReportNullAttrNonNull(errorNode, ArgE);
+  R = genReportNullAttrNonNull(errorNode, ArgE, idx + 1);
 else if (haveRefTypeParam)
   R = genReportReferenceToNullPointer(errorNode, ArgE);
 
@@ -179,7 +181,8 @@
 
 std::unique_ptr
 NonNullParamChecker::genReportNullAttrNonNull(const ExplodedNode *ErrorNode,
-  const Expr *ArgE) const {
+  const Expr *ArgE,
+  unsigned IdxOfArg) const {
   // Lazily allocate the BugType object if it hasn't already been
   // created. Ownership is transferred to the BugReporter object once
   // the BugReport is passed to 'EmitWarning'.
@@ -187,9 +190,13 @@
 BTAttrNonNull.reset(new BugType(
 this, "Argument with 'nonnull' attribute passed null", "API"));
 
-  auto R = std::make_unique(
-  *BTAttrNonNull,
-  "Null pointer passed as an argument to a 'nonnull' parameter", ErrorNode);
+  llvm::SmallString<256> SBuf;
+  llvm::raw_svector_ostream OS(SBuf);
+  OS << "Null pointer passed to "
+ << IdxOfArg << llvm::getOrdinalSuffix(IdxOfArg)
+ << " parameter expecting 'nonnull'";
+
+  auto R = llvm::make_unique(*BTAttrNonNull, SBuf, ErrorNode);
   if (ArgE)
 bugreporter::trackExpressionValue(ErrorNode, ArgE, *R);
 
Index: cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
===
--- cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/CStringChecker.cpp
@@ -198,7 +198,8 @@
   ProgramStateRef checkNonNull(CheckerContext &C,
ProgramStateRef state,
const Expr *S,
-   SVal l) const;
+   SVal l,
+   unsigned IdxOfArg) const;
   ProgramStateRef CheckLocation(CheckerContext &C,
 ProgramStateRef state,
 const Expr *S,
@@ -277,7 +278,8 @@
 
 ProgramStateRef CStringChecker::checkNonNull(CheckerContext &C,
 ProgramStateRef state,
-const Expr *S, SVal l) const {
+const Expr *S, SVal l,
+unsigned IdxOfArg) const {
   // If a previous check has failed, propagate the failure.
   if (!state)
 return nullptr;
@@ -288,11 +290,13 @@
   if (stateNull && !stateNonNull) {
 if (Filter.CheckCStringNullArg) {
   SmallString<80> buf;
-  llvm::raw_svector_ostream os(buf);
+  llvm::raw_svector_ostream OS(buf);
   assert(CurrentFunctionDescription);
-  os << "Null pointer argument in call to " << CurrentFunctionDescription;
+  OS << "Null pointer argument in call to " << CurrentFunctionDescription
+ << ' ' << IdxOfArg << llvm::getOrdinalSuffix(IdxOfArg)
+ << " parameter";
 
-  emitNullArgBug(C, stateNull, S, os.str());
+  emitNullArgBug(C, stateNull, S, OS.str());
 }
 return nullptr;
   }
@@ -384,7 +388,7 @@
 
   // Check that the first buffer is non-null.
   SVal BufVal

[PATCH] D67117: [clangd] Split Preamble.h out of ClangdUnit.h. NFC

2019-09-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall created this revision.
Herald added subscribers: cfe-commits, kadircet, arphaman, mgrang, jkorous, 
MaskRay, javed.absar, ilya-biryukov, mgorny.
Herald added a project: clang.

Add comment describing use of preamble in clangd.
Remove deps on ClangdUnit.h where possible.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67117

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdUnit.cpp
  clang-tools-extra/clangd/ClangdUnit.h
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/CodeComplete.h
  clang-tools-extra/clangd/Compiler.h
  clang-tools-extra/clangd/Preamble.cpp
  clang-tools-extra/clangd/Preamble.h
  clang-tools-extra/clangd/TUScheduler.cpp
  clang-tools-extra/clangd/TUScheduler.h
  clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp

Index: clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
===
--- clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
+++ clang-tools-extra/clangd/unittests/TUSchedulerTests.cpp
@@ -12,6 +12,7 @@
 #include "Diagnostics.h"
 #include "Matchers.h"
 #include "Path.h"
+#include "Preamble.h"
 #include "TUScheduler.h"
 #include "TestFS.h"
 #include "Threading.h"
Index: clang-tools-extra/clangd/TUScheduler.h
===
--- clang-tools-extra/clangd/TUScheduler.h
+++ clang-tools-extra/clangd/TUScheduler.h
@@ -9,7 +9,7 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H
 #define LLVM_CLANG_TOOLS_EXTRA_CLANGD_TUSCHEDULER_H
 
-#include "ClangdUnit.h"
+#include "Compiler.h"
 #include "Diagnostics.h"
 #include "Function.h"
 #include "GlobalCompilationDatabase.h"
@@ -24,6 +24,8 @@
 
 namespace clang {
 namespace clangd {
+class ParsedAST;
+struct PreambleData;
 
 /// Returns a number of a default async threads to use for TUScheduler.
 /// Returned value is always >= 1 (i.e. will not cause requests to be processed
Index: clang-tools-extra/clangd/TUScheduler.cpp
===
--- clang-tools-extra/clangd/TUScheduler.cpp
+++ clang-tools-extra/clangd/TUScheduler.cpp
@@ -43,10 +43,12 @@
 
 #include "TUScheduler.h"
 #include "Cancellation.h"
+#include "ClangdUnit.h"
 #include "Compiler.h"
 #include "Diagnostics.h"
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
+#include "Preamble.h"
 #include "Trace.h"
 #include "index/CanonicalIncludes.h"
 #include "clang/Frontend/CompilerInvocation.h"
Index: clang-tools-extra/clangd/Preamble.h
===
--- /dev/null
+++ clang-tools-extra/clangd/Preamble.h
@@ -0,0 +1,88 @@
+//===--- Preamble.h - Reusing expensive parts of the AST -*- C++-*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// The vast majority of code in a typical translation unit is in the headers
+// included at the top of the file.
+//
+// The preamble optimization says that we can parse this code once, and reuse
+// the result multiple times. The preamble is invalidated by changes to the
+// code in the preamble region, to the compile command, or to files on disk.
+//
+// This is the most important optimization in clangd: it allows operations like
+// code-completion to have sub-second latency. It is supported by the
+// PrecompiledPreamble functionality in clang, which wraps the techniques used
+// by PCH files, modules etc into a convenient interface.
+//
+//===--===//
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANGD_PREAMBLE_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANGD_PREAMBLE_H
+
+#include "Compiler.h"
+#include "Diagnostics.h"
+#include "FS.h"
+#include "Headers.h"
+#include "index/CanonicalIncludes.h"
+#include "clang/Frontend/PrecompiledPreamble.h"
+#include "clang/Tooling/CompilationDatabase.h"
+
+#include 
+#include 
+#include 
+
+namespace clang {
+namespace clangd {
+
+/// The parsed preamble and associated data.
+///
+/// As we must avoid re-parsing the preamble, any information that can only
+/// be obtained during parsing must be eagerly captured and stored here.
+struct PreambleData {
+  PreambleData(PrecompiledPreamble Preamble, std::vector Diags,
+   IncludeStructure Includes,
+   std::vector MainFileMacros,
+   std::unique_ptr StatCache,
+   CanonicalIncludes CanonIncludes);
+
+  tooling::CompileCommand CompileCommand;
+  PrecompiledPreamble Preamble;
+  std::vector Diags;
+  // Processes like code completions and go-to-definitions will need #include
+  // information, and their compile action skips preamble range.
+  IncludeStructur

r370801 - Disable stack exhaustion test on NetBSD, where either the detection or

2019-09-03 Thread Richard Smith via cfe-commits
Author: rsmith
Date: Tue Sep  3 11:00:44 2019
New Revision: 370801

URL: http://llvm.org/viewvc/llvm-project?rev=370801&view=rev
Log:
Disable stack exhaustion test on NetBSD, where either the detection or
recovery mechanism does not appear to work.

Modified:
cfe/trunk/test/SemaTemplate/stack-exhaustion.cpp

Modified: cfe/trunk/test/SemaTemplate/stack-exhaustion.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaTemplate/stack-exhaustion.cpp?rev=370801&r1=370800&r2=370801&view=diff
==
--- cfe/trunk/test/SemaTemplate/stack-exhaustion.cpp (original)
+++ cfe/trunk/test/SemaTemplate/stack-exhaustion.cpp Tue Sep  3 11:00:44 2019
@@ -1,6 +1,11 @@
 // RUN: %clang_cc1 -verify %s
 // REQUIRES: thread_support
 
+// FIXME: Detection of, or recovery from, stack exhaustion does not work on
+// NetBSD at the moment. Since this is a best-effort mitigation for exceeding
+// implementation limits, just disable the test.
+// UNSUPPORTED: system-netbsd
+
 // expected-warning@* 0-1{{stack nearly exhausted}}
 // expected-note@* 0+{{}}
 


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


[PATCH] D66361: Improve behavior in the case of stack exhaustion.

2019-09-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

In D66361#1655903 , @krytarowski wrote:

> This change broke on NetBSD.
>
> http://lab.llvm.org:8011/builders/netbsd-amd64/builds/22003/steps/run%20unit%20tests/logs/FAIL%3A%20Clang%3A%3Astack-exhaustion.cpp


Test disabled for NetBSD in r370801. If you're interested in investigating why 
this isn't working there, feel free, but this is only a best-effort mitigation 
for the case where things have already gone wrong, so there are limits to how 
much effort it makes sense to resolve this.

Does NetBSD set a hard stack rlimit of less than 8MB by any chance?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66361/new/

https://reviews.llvm.org/D66361



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


[PATCH] D67117: [clangd] Split Preamble.h out of ClangdUnit.h. NFC

2019-09-03 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov accepted this revision.
ilya-biryukov added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67117/new/

https://reviews.llvm.org/D67117



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


[PATCH] D46791: Make -gsplit-dwarf generally available

2019-09-03 Thread Ed Maste via Phabricator via cfe-commits
emaste added a comment.

Ping


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D46791/new/

https://reviews.llvm.org/D46791



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


[PATCH] D66988: [NewPM][Sancov] Make Sancov a Module Pass instead of 2 Passes

2019-09-03 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

*ping*


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66988/new/

https://reviews.llvm.org/D66988



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


[PATCH] D67119: On PowerPC, Secure-PLT by default for FreeBSD 13 and higher

2019-09-03 Thread Dimitry Andric via Phabricator via cfe-commits
dim created this revision.
dim added reviewers: emaste, jhibbits, hfinkel.
Herald added subscribers: steven.zhang, shchenz, jsji, MaskRay, kbarton, 
krytarowski, nemanjai.
Herald added a project: clang.

In https://svnweb.freebsd.org/changeset/base/349351, FreeBSD 13 and
higher transitioned to Secure-PLT for PowerPC.  This part contains the
changes in clang's PPC architecture defaults.


Repository:
  rC Clang

https://reviews.llvm.org/D67119

Files:
  lib/Driver/ToolChains/Arch/PPC.cpp


Index: lib/Driver/ToolChains/Arch/PPC.cpp
===
--- lib/Driver/ToolChains/Arch/PPC.cpp
+++ lib/Driver/ToolChains/Arch/PPC.cpp
@@ -115,7 +115,8 @@
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
+  if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) ||
+  Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;


Index: lib/Driver/ToolChains/Arch/PPC.cpp
===
--- lib/Driver/ToolChains/Arch/PPC.cpp
+++ lib/Driver/ToolChains/Arch/PPC.cpp
@@ -115,7 +115,8 @@
   const ArgList &Args) {
   if (Args.getLastArg(options::OPT_msecure_plt))
 return ppc::ReadGOTPtrMode::SecurePlt;
-  if (Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
+  if ((Triple.isOSFreeBSD() && Triple.getOSMajorVersion() >= 13) ||
+  Triple.isOSNetBSD() || Triple.isOSOpenBSD() || Triple.isMusl())
 return ppc::ReadGOTPtrMode::SecurePlt;
   else
 return ppc::ReadGOTPtrMode::Bss;
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r370807 - Unbreak the build after r370798

2019-09-03 Thread Benjamin Kramer via cfe-commits
Author: d0k
Date: Tue Sep  3 11:24:56 2019
New Revision: 370807

URL: http://llvm.org/viewvc/llvm-project?rev=370807&view=rev
Log:
Unbreak the build after r370798

Modified:
cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp

Modified: cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp?rev=370807&r1=370806&r2=370807&view=diff
==
--- cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp (original)
+++ cfe/trunk/lib/StaticAnalyzer/Checkers/NonNullParamChecker.cpp Tue Sep  3 
11:24:56 2019
@@ -196,7 +196,7 @@ NonNullParamChecker::genReportNullAttrNo
  << IdxOfArg << llvm::getOrdinalSuffix(IdxOfArg)
  << " parameter expecting 'nonnull'";
 
-  auto R = llvm::make_unique(*BTAttrNonNull, SBuf, ErrorNode);
+  auto R = std::make_unique(*BTAttrNonNull, SBuf, ErrorNode);
   if (ArgE)
 bugreporter::trackExpressionValue(ErrorNode, ArgE, *R);
 


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


[PATCH] D66983: [WebAssembly] Add wasm-specific vector shuffle builtin and intrinsic

2019-09-03 Thread Thomas Lively via Phabricator via cfe-commits
tlively abandoned this revision.
tlively added a comment.

Abandoning in favor of @sunfish's idea for introducing a cost mechanism for 
shuffle masks in DAGCombiner.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D66983/new/

https://reviews.llvm.org/D66983



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


r370808 - [AMDGPU] Set default flat work group size to (1, 256) for HIP

2019-09-03 Thread Yaxun Liu via cfe-commits
Author: yaxunl
Date: Tue Sep  3 11:50:24 2019
New Revision: 370808

URL: http://llvm.org/viewvc/llvm-project?rev=370808&view=rev
Log:
[AMDGPU] Set default flat work group size to (1,256) for HIP

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=370808&r1=370807&r2=370808&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Tue Sep  3 11:50:24 2019
@@ -7915,8 +7915,9 @@ void AMDGPUTargetCodeGenInfo::setTargetA
 
   const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
   FD->hasAttr();
-  if ((IsOpenCLKernel ||
-   (M.getLangOpts().HIP && FD->hasAttr())) &&
+  const bool IsHIPKernel = M.getLangOpts().HIP &&
+   FD->hasAttr();
+  if ((IsOpenCLKernel || IsHIPKernel) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
@@ -7942,7 +7943,7 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
 } else
   assert(Max == 0 && "Max must be zero");
-  } else if (IsOpenCLKernel) {
+  } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to 256.
 F->addFnAttr("amdgpu-flat-work-group-size", "1,256");
   }

Modified: cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu?rev=370808&r1=370807&r2=370808&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu Tue Sep  3 11:50:24 2019
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm -x hip %s -o - | 
FileCheck %s
 #include "Inputs/cuda.h"
 
 // CHECK: define amdgpu_kernel void @_ZN1A6kernelEv
@@ -25,7 +25,7 @@ struct Dummy {
   EmptyKernelPtr Empty() { return EmptyKernel; } 
 };
 
-// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_
+// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_{{.*}} 
#[[ATTR:[0-9][0-9]*]]
 template
 __global__ void template_kernel(T x) {}
 
@@ -39,3 +39,4 @@ int main() {
   launch((void*)D.Empty());
   return 0;
 }
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"


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


[PATCH] D64672: [X86] Prevent passing vectors of __int128 as in llvm IR

2019-09-03 Thread Craig Topper via Phabricator via cfe-commits
craig.topper updated this revision to Diff 218506.
craig.topper added a comment.

Change test name and adjust to the changes I think @rksimon was asking for. I 
haven't commited the test yet. I'd like to verify that the before version of 
the test is how you would like it pre-committed


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64672/new/

https://reviews.llvm.org/D64672

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/LangOptions.h
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/x86-vec-i128.c

Index: clang/test/CodeGen/x86-vec-i128.c
===
--- clang/test/CodeGen/x86-vec-i128.c
+++ clang/test/CodeGen/x86-vec-i128.c
@@ -3,24 +3,27 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,MEM256ALIGN16,MEM512ALIGN16
 // RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,MEM256ALIGN32,MEM512ALIGN64
 // RUN: %clang_cc1 -triple x86_64-unknown-freebsd10.0 %s -target-feature +sse2 -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,MEM256ALIGN32,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +sse2 -S -emit-llvm -o - -fclang-abi-compat=9 | FileCheck %s --check-prefixes=CLANG9ABI128,MEM256ALIGN32,MEM512ALIGN64
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG10ABI128,CLANG10ABI256,MEM512ALIGN64
 // RUN: %clang_cc1 -triple x86_64-netbsd %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG10ABI128,CLANG10ABI256,MEM512ALIGN64
 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,MEM512ALIGN32
 // RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,MEM512ALIGN64
 // RUN: %clang_cc1 -triple x86_64-unknown-freebsd10.0 %s -target-feature +avx -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,MEM512ALIGN64
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx -S -emit-llvm -o - -fclang-abi-compat=9 | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,MEM512ALIGN64
 
 // RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG10ABI128,CLANG10ABI256,CLANG10ABI512
 // RUN: %clang_cc1 -triple x86_64-netbsd %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG10ABI128,CLANG10ABI256,CLANG10ABI512
 // RUN: %clang_cc1 -triple x86_64-apple-darwin %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,CLANG9ABI512
 // RUN: %clang_cc1 -triple x86_64-scei-ps4 %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,CLANG9ABI512
 // RUN: %clang_cc1 -triple x86_64-unknown-freebsd10.0 %s -target-feature +avx512f -S -emit-llvm -o - | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,CLANG9ABI512
+// RUN: %clang_cc1 -triple x86_64-linux-gnu %s -target-feature +avx512f -S -emit-llvm -o - -fclang-abi-compat=9 | FileCheck %s --check-prefixes=CLANG9ABI128,CLANG9ABI256,CLANG9ABI512
 
 typedef unsigned long long v16u64 __attribute__((vector_size(16)));
 typedef unsigned __int128 v16u128 __attribute__((vector_size(16)));
 
 v16u64 test_v16u128(v16u64 a, v16u128 b) {
-// CLANG10ABI128: define <2 x i64> @test_v16u128(<2 x i64> %{{.*}}, <1 x i128> %{{.*}})
+// CLANG10ABI128: define <2 x i64> @test_v16u128(<2 x i64> %{{.*}}, <2 x i64> %{{.*}})
 // CLANG9ABI128: define <2 x i64> @test_v16u128(<2 x i64> %{{.*}}, <1 x i128> %{{.*}})
   return a + (v16u64)b;
 }
@@ -31,7 +34,7 @@
 v32u64 test_v32u128(v32u64 a, v32u128 b) {
 // MEM256ALIGN16: define <4 x i64> @test_v32u128(<4 x i64>* byval(<4 x i64>) align 16 %{{.*}}, <2 x i128>* byval(<2 x i128>) align 16 %{{.*}})
 // MEM256ALIGN32: define <4 x i64> @test_v32u128(<4 x i64>* byval(<4 x i64>) align 32 %{{.*}}, <2 x i128>* byval(<2 x i128>) align 32 %{{.*}})
-// CLANG10ABI256: define <4 x i64> @test_v32u128(<4 x i64> %{{.*}}, <2 x i128> %{{.*}})
+// CLANG10ABI256: define <4 x i64> @test_v32u128(<4 x i64> %{{.*}}, <2 x i128>* byval(<2 x i128>) align 32 %{{.*}})
 // CLANG9ABI256: define <4 x i64> @test_v32u128(<4 x i64> %{{.*}}, <2 x i128> %{{.*}})
   return a + (v32u64)b;
 }
@@ -43,7 +46,7 @@
 // MEM512ALIGN16: define <8 x i64> @test_v64u128(<8 x i64>* byval(<8 x i64>) align 16 %{{.*}}, <4 x i128>* byval(<4 x i128>) align 16 %{{.*}})
 // MEM512ALIGN32: define <8 x i64> @test_v64u128(<8 x i64>* byval(<8 x i64>) align 32 %{{.*}}, <4 x i128>* byval(<4 x i128>) align 32 %{{.*}})
 // MEM512ALIGN64: define <8 x i64> @test_v64u128(<8 x i64>* by

[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri updated this revision to Diff 218507.
lebedev.ri added a comment.

NFC, fixup docs.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67122/new/

https://reviews.llvm.org/D67122

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/include/clang/Basic/Sanitizers.def
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
  clang/test/CodeGen/catch-pointer-offsetting.c
  clang/test/CodeGen/catch-pointer-overflow.c
  clang/test/Driver/fsanitize.c
  compiler-rt/lib/ubsan/ubsan_checks.inc
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/index-overflow.cpp
  
compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-constants.cpp
  
compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-summary.cpp
  
compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-variable.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
  compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -54,6 +54,20 @@
   ``bcmp`` pattern, and convert it into a call to ``bcmp`` (or ``memcmp``)
   function.
 
+* As per :ref:`LLVM Language Reference Manual `,
+  ``getelementptr inbounds`` can not change the null status of a pointer,
+  meaning it can not produce non-null pointer given null base pointer, and
+  likewise given non-null base pointer it can not produce null pointer; if it
+  does, the result is a :ref:`poison value `.
+  Since `r369789 `_
+  (`D66608 `_ ``[InstCombine] icmp eq/ne (gep
+  inbounds P, Idx..), null -> icmp eq/ne P, null``) LLVM uses that for
+  transformations. If the original source violates these requirements this
+  may result in code being miscompiled. If you are using clang front-end,
+  Undefined Behaviour Sanitizer ``-fsanitize=nullptr-and-nonzero-offset`` check
+  will catch such cases.
+
+
 Changes to the LLVM IR
 --
 
Index: compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
===
--- /dev/null
+++ compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
@@ -0,0 +1,23 @@
+// RUN: %clang -fsanitize=nullptr-and-nonzero-offset %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+
+#include 
+
+int main(int argc, char *argv[]) {
+  char *base, *result;
+
+  // CHECK-NOT: pointer-overflow
+
+  base = (char *)0;
+  result = base + 1;
+  // CHECK: pointer-overflow
+
+  // CHECK-NOT: pointer-overflow
+
+  base = (char *)1;
+  result = base - 1;
+  // CHECK: pointer-overflow
+
+  // CHECK-NOT: pointer-overflow
+
+  return 0;
+}
Index: compiler-rt/test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
===
--- compiler-rt/test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
+++ compiler-rt/test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
@@ -12,7 +12,7 @@
   // CHECK: unsigned-index-expression.cpp:[[@LINE+1]]:16: runtime error: subtraction of unsigned offset from 0x{{.*}} overflowed to 0x{{.*}}
   char *q1 = p - neg_1;
 
-  // CHECK: unsigned-index-expression.cpp:[[@LINE+2]]:16: runtime error: pointer index expression with base 0x{{0*}} overflowed to 0x{{.*}}
+  // CHECK: unsigned-index-expression.cpp:[[@LINE+2]]:16: runtime error: applying non-zero offset {{.*}} to null pointer is undefined
   char *n = nullptr;
   char *q2 = n - 1ULL;
 
Index: compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-variable.cpp
===
--- /dev/null
+++ compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-variable.cpp
@@ -0,0 +1,52 @@
+// RUN: %clang -x c   -fsanitize=nullptr-and-nonzero-offset -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="error:" --check-prefix=CHECK-OK
+// RUN: %clang -x c   -fsanitize=nullptr-and-nonzero-offset -O1 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="error:" --check-prefix=CHECK-OK
+// RUN: %clang -x c   -fsanitize=nullptr-and-nonzero-offset -O2 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="error:" --check-prefix=CHECK-OK
+// RUN: %clang -x c   -fsanitize=nullptr-and-nonzero-offset -O3 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="error:" --check-prefix=CHECK-OK
+
+// RUN: %clang -x c++ -fsanitize=nullptr-and-nonzero-offset -O0 %s -o %t && %run %t 2>&1 | FileCheck %s --implicit-check-not="error:" --check-prefix=CHECK-OK
+// RUN: %clang -x c++ -fsani

[PATCH] D67048: [AMDGPU] Set default flat work group size to (1, 256) for HIP

2019-09-03 Thread Yaxun Liu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL370808: [AMDGPU] Set default flat work group size to (1,256) 
for HIP (authored by yaxunl, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D67048?vs=218261&id=218508#toc

Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67048/new/

https://reviews.llvm.org/D67048

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7915,8 +7915,9 @@
 
   const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
   FD->hasAttr();
-  if ((IsOpenCLKernel ||
-   (M.getLangOpts().HIP && FD->hasAttr())) &&
+  const bool IsHIPKernel = M.getLangOpts().HIP &&
+   FD->hasAttr();
+  if ((IsOpenCLKernel || IsHIPKernel) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
@@ -7942,7 +7943,7 @@
   F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
 } else
   assert(Max == 0 && "Max must be zero");
-  } else if (IsOpenCLKernel) {
+  } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to 256.
 F->addFnAttr("amdgpu-flat-work-group-size", "1,256");
   }
Index: cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu
===
--- cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu
+++ cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | 
FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm -x hip %s -o - | 
FileCheck %s
 #include "Inputs/cuda.h"
 
 // CHECK: define amdgpu_kernel void @_ZN1A6kernelEv
@@ -25,7 +25,7 @@
   EmptyKernelPtr Empty() { return EmptyKernel; } 
 };
 
-// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_
+// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_{{.*}} 
#[[ATTR:[0-9][0-9]*]]
 template
 __global__ void template_kernel(T x) {}
 
@@ -39,3 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"


Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -7915,8 +7915,9 @@
 
   const bool IsOpenCLKernel = M.getLangOpts().OpenCL &&
   FD->hasAttr();
-  if ((IsOpenCLKernel ||
-   (M.getLangOpts().HIP && FD->hasAttr())) &&
+  const bool IsHIPKernel = M.getLangOpts().HIP &&
+   FD->hasAttr();
+  if ((IsOpenCLKernel || IsHIPKernel) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
 F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
@@ -7942,7 +7943,7 @@
   F->addFnAttr("amdgpu-flat-work-group-size", AttrVal);
 } else
   assert(Max == 0 && "Max must be zero");
-  } else if (IsOpenCLKernel) {
+  } else if (IsOpenCLKernel || IsHIPKernel) {
 // By default, restrict the maximum size to 256.
 F->addFnAttr("amdgpu-flat-work-group-size", "1,256");
   }
Index: cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu
===
--- cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu
+++ cfe/trunk/test/CodeGenCUDA/kernel-amdgcn.cu
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm %s -o - | FileCheck %s
+// RUN: %clang_cc1 -triple amdgcn -fcuda-is-device -emit-llvm -x hip %s -o - | FileCheck %s
 #include "Inputs/cuda.h"
 
 // CHECK: define amdgpu_kernel void @_ZN1A6kernelEv
@@ -25,7 +25,7 @@
   EmptyKernelPtr Empty() { return EmptyKernel; } 
 };
 
-// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_
+// CHECK: define amdgpu_kernel void @_Z15template_kernelI1AEvT_{{.*}} #[[ATTR:[0-9][0-9]*]]
 template
 __global__ void template_kernel(T x) {}
 
@@ -39,3 +39,4 @@
   launch((void*)D.Empty());
   return 0;
 }
+// CHECK: attributes #[[ATTR]] = {{.*}}"amdgpu-flat-work-group-size"="1,256"
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri created this revision.
lebedev.ri added reviewers: vsk, filcab, rsmith, aaron.ballman, vitalybuka, 
rjmccall, Sanitizers.
lebedev.ri added projects: clang, Sanitizers.
Herald added subscribers: arphaman, dberris.
Herald added a project: LLVM.

Quote from http://eel.is/c++draft/expr.add#4:

  4 When an expression J that has integral type is added to or subtracted
from an expression P of pointer type, the result has the type of P.
  (4.1) If P evaluates to a null pointer value and J evaluates to 0,
the result is a null pointer value.
  (4.2) Otherwise, if P points to an array element i of an array object x with n
elements ([dcl.array]), the expressions P + J and J + P
(where J has the value j) point to the (possibly-hypothetical) array
element i+j of x if 0≤i+j≤n and the expression P - J points to the 
(possibly-hypothetical) array element i−j of x if 0≤i−j≤n.
  (4.3) Otherwise, the behavior is undefined.

Therefore, as per the standard, applying non-zero offset to `nullptr`
(or making non-`nullptr` a `nullptr`, by subtracting pointer's integral value
from the pointer itself) is undefined behavior. (*if* `nullptr` is not defined,
i.e. e.g. `-fno-delete-null-pointer-checks` was *not* specified.)

Since rL369789  (D66608 
 `[InstCombine] icmp eq/ne (gep inbounds P, 
Idx..), null -> icmp eq/ne P, null`)
LLVM middle-end uses those guarantees for transformations.
If the source contains such UB's, said code may now be miscompiled.
Such miscompilations were already observed:

- https://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190826/687838.html
- https://github.com/google/filament/pull/1566

Surprizingly, UBSan does not catch those issues
... until now. This diff teaches UBSan about these UB's.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D67122

Files:
  clang/docs/ReleaseNotes.rst
  clang/docs/UndefinedBehaviorSanitizer.rst
  clang/include/clang/Basic/Sanitizers.def
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset-blacklist.c
  clang/test/CodeGen/catch-nullptr-and-nonzero-offset.c
  clang/test/CodeGen/catch-pointer-offsetting.c
  clang/test/CodeGen/catch-pointer-overflow.c
  clang/test/Driver/fsanitize.c
  compiler-rt/lib/ubsan/ubsan_checks.inc
  compiler-rt/lib/ubsan/ubsan_handlers.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/index-overflow.cpp
  
compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-constants.cpp
  
compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-summary.cpp
  
compiler-rt/test/ubsan/TestCases/Pointer/nullptr-and-nonzero-offset-variable.cpp
  compiler-rt/test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
  compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
  llvm/docs/ReleaseNotes.rst

Index: llvm/docs/ReleaseNotes.rst
===
--- llvm/docs/ReleaseNotes.rst
+++ llvm/docs/ReleaseNotes.rst
@@ -54,6 +54,20 @@
   ``bcmp`` pattern, and convert it into a call to ``bcmp`` (or ``memcmp``)
   function.
 
+* As per :ref:`LLVM Language Reference Manual `,
+  ``getelementptr inbounds`` can not change the null status of a pointer,
+  meaning it can not produce non-null pointer given null base pointer, and
+  likewise given non-null base pointer it can not produce null pointer; if it
+  does, the result is a :ref:`poison value `.
+  Since `r369789 `_
+  (`D66608 `_ ``[InstCombine] icmp eq/ne (gep
+  inbounds P, Idx..), null -> icmp eq/ne P, null``) LLVM uses that for
+  transformations. If the original source violates these requirements this
+  may result in code being miscompiled. If you are using clang front-end,
+  Undefined Behaviour Sanitizer ``-fsanitize-trap=nullptr-and-nonzero-offset``
+  check will catch such cases.
+
+
 Changes to the LLVM IR
 --
 
Index: compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
===
--- /dev/null
+++ compiler-rt/test/ubsan_minimal/TestCases/nullptr-and-nonzero-offset.c
@@ -0,0 +1,23 @@
+// RUN: %clang -fsanitize=nullptr-and-nonzero-offset %s -o %t && %run %t 2>&1 | FileCheck %s --check-prefixes=CHECK
+
+#include 
+
+int main(int argc, char *argv[]) {
+  char *base, *result;
+
+  // CHECK-NOT: pointer-overflow
+
+  base = (char *)0;
+  result = base + 1;
+  // CHECK: pointer-overflow
+
+  // CHECK-NOT: pointer-overflow
+
+  base = (char *)1;
+  result = base - 1;
+  // CHECK: pointer-overflow
+
+  // CHECK-NOT: pointer-overflow
+
+  return 0;
+}
Index: compiler-rt/test/ubsan/TestCases/Pointer/unsigned-index-expression.cpp
===
--- compiler-rt/test/ubsan/TestCases/Pointer/unsigned-inde

[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

One fear I have with this is in expansions of the  `offsetof` macro, where it 
is a common implementation strategy to cast a null pointer to be of the correct 
type when calculating member offsets. Do you think you will be able to 
distinguish between null pointer additions that the user wrote directly (which 
is UB) as opposed to null pointer additions that come from the implementation 
(which is not UB)?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67122/new/

https://reviews.llvm.org/D67122



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


[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-03 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added a comment.

In D67122#1656189 , @aaron.ballman 
wrote:

> One fear I have with this is in expansions of the  `offsetof` macro, where it 
> is a common implementation strategy to cast a null pointer to be of the 
> correct type when calculating member offsets. Do you think you will be able 
> to distinguish between null pointer additions that the user wrote directly 
> (which is UB) as opposed to null pointer additions that come from the 
> implementation (which is not UB)?


Can you show a snippet on godbolt?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67122/new/

https://reviews.llvm.org/D67122



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


[PATCH] D59754: [Sema] Add c++2a designated initializer warnings

2019-09-03 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

Hi! We've noticed that for our arm bots, we're getting some flaky builds that 
sometimes fail with `error: array designators are a C99 extension 
[-Werror,-Wc99-designator]` and sometimes don't fail. 2 questions:

1. I can't see it off the patch immediately, but do you know why for arm 
specifically we can only get this warning sometimes?
2. I noticed that for the `test/SemaCXX/c99.cpp` test, this warning is also 
diagnosed for the `-std=c++17` case. Are C-style designated initializers only 
invalid in c++20, or are they also invalid in 17?

Thanks.


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D59754/new/

https://reviews.llvm.org/D59754



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


[PATCH] D64671: [clang-tidy] New check: misc-init-local-variables

2019-09-03 Thread Jussi Pakkanen via Phabricator via cfe-commits
jpakkane updated this revision to Diff 218511.
jpakkane added a comment.

Updated patch as per review comments.


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D64671/new/

https://reviews.llvm.org/D64671

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp
  clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp

Index: clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/cppcoreguidelines-init-variables.cpp
@@ -0,0 +1,98 @@
+// RUN: %check_clang_tidy %s cppcoreguidelines-init-variables %t
+
+#define DO_NOTHING(x) ((void)x)
+
+// Ensure that function declarations are not changed.
+void some_func(int x, double d, bool b, const char *p);
+
+// Ensure that function arguments are not changed
+int identity_function(int x) {
+  return x;
+}
+
+int do_not_modify_me;
+
+typedef struct {
+  int unaltered1;
+  int unaltered2;
+} UnusedStruct;
+
+typedef int my_int_type;
+#define MACRO_INT int
+#define FULL_DECLARATION() int macrodecl;
+
+template 
+void template_test_function() {
+  T t;
+  int uninitialized;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'uninitialized' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int uninitialized = 0;{{$}}
+
+  DO_NOTHING(t);
+  DO_NOTHING(uninitialized);
+}
+
+void init_unit_tests() {
+  int x;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'x' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int x = 0;{{$}}
+  my_int_type myint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'myint' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  my_int_type myint = 0;{{$}}
+
+  MACRO_INT macroint;
+  // CHECK-MESSAGES: :[[@LINE-1]]:13: warning: variable 'macroint' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  MACRO_INT macroint = 0;{{$}}
+  FULL_DECLARATION();
+
+  int x0 = 1, x1, x2 = 2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'x1' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int x0 = 1, x1 = 0, x2 = 2;{{$}}
+  int y0, y1 = 1, y2;
+  // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: variable 'y0' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-MESSAGES: :[[@LINE-2]]:19: warning: variable 'y2' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  int y0 = 0, y1 = 1, y2 = 0;{{$}}
+  int hasval = 42;
+
+  float f;
+  // CHECK-MESSAGES: :[[@LINE-1]]:9: warning: variable 'f' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  float f = NAN;{{$}}
+  float fval = 85.0;
+  double d;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: variable 'd' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  double d = NAN;{{$}}
+  double dval = 99.0;
+
+  bool b;
+  // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: variable 'b' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  bool b = 0;{{$}}
+  bool bval = true;
+
+  const char *ptr;
+  // CHECK-MESSAGES: :[[@LINE-1]]:15: warning: variable 'ptr' is not initialized [cppcoreguidelines-init-variables]
+  // CHECK-FIXES: {{^}}  const char *ptr = nullptr;{{$}}
+  const char *ptrval = "a string";
+
+  UnusedStruct u;
+
+  DO_NOTHING(x);
+  DO_NOTHING(myint);
+  DO_NOTHING(macroint);
+  DO_NOTHING(macrodecl);
+  DO_NOTHING(x0);
+  DO_NOTHING(x1);
+  DO_NOTHING(x2);
+  DO_NOTHING(y0);
+  DO_NOTHING(y1);
+  DO_NOTHING(y2);
+  DO_NOTHING(hasval);
+  DO_NOTHING(f);
+  DO_NOTHING(fval);
+  DO_NOTHING(d);
+  DO_NOTHING(dval);
+  DO_NOTHING(b);
+  DO_NOTHING(bval);
+  DO_NOTHING(ptr);
+  DO_NOTHING(ptrval);
+  DO_NOTHING(u);
+}
Index: clang-tools-extra/docs/clang-tidy/checks/list.rst
===
--- clang-tools-extra/docs/clang-tidy/checks/list.rst
+++ clang-tools-extra/docs/clang-tidy/checks/list.rst
@@ -193,6 +193,7 @@
cppcoreguidelines-avoid-magic-numbers (redirects to readability-magic-numbers) 
cppcoreguidelines-c-copy-assignment-signature (redirects to misc-unconventional-assign-operator) 
cppcoreguidelines-explicit-virtual-functions (redirects to modernize-use-override) 
+   cppcoreguidelines-init-variables
cppcoreguidelines-interfaces-global-init
cppcoreguidelines-macro-usage
cppcoreguidelines-narrowing-conversions
Index: clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines-init-variables.rst

[PATCH] D67122: [UBSan][clang][compiler-rt] Applying non-zero offset to nullptr is undefined behaviour

2019-09-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D67122#1656205 , @lebedev.ri wrote:

> In D67122#1656189 , @aaron.ballman 
> wrote:
>
> > One fear I have with this is in expansions of the  `offsetof` macro, where 
> > it is a common implementation strategy to cast a null pointer to be of the 
> > correct type when calculating member offsets. Do you think you will be able 
> > to distinguish between null pointer additions that the user wrote directly 
> > (which is UB) as opposed to null pointer additions that come from the 
> > implementation (which is not UB)?
>
>
> Can you show a snippet on godbolt?


https://godbolt.org/z/5DHL2E

This will show that Clang has a `__builtin_offsetof()` that gets used. I'm 
worried about situations where there is no `__builtin_offsetof()` but the 
canonical reference implementation is used instead (which looks identical to 
what initializes `bad` in my link).


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D67122/new/

https://reviews.llvm.org/D67122



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


  1   2   >