[PATCH] D63085: Provide a fix-it hint for -Wswitch, which adds missing cases. If there are >3 cases, the inserted text will contain newlines so it will not be shown in console output (but will be appl

2019-07-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

One major drawback that I see is the lack of indentation (and other format 
options) in the added code.
Should we have this fix at a higher level that can have formatting (either now 
or in the future)? E.g. in `clangd` directly?




Comment at: lib/Sema/SemaStmt.cpp:1208
+llvm::raw_string_ostream NewCasesOS(NewCases);
+// Include \n to separate new cases added if there are many.
+// This suppresses printing the (long) insert text.

Maybe always put each `case` on a new line?
From my experience, having multiple cases on the same line is not very common.


Repository:
  rC Clang

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

https://reviews.llvm.org/D63085



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


[PATCH] D61001: [clang-format][tests] Explicitly specify style in some tests

2019-07-10 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl added reviewers: MyDeveloperDay, krasimir.
r.stahl added a comment.

This should be trivial enough to just commit, but I'd just be more comfortable 
if someone looked at it before, because this is my first commit in this area of 
clang.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61001



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


[PATCH] D61001: [clang-format][tests] Explicitly specify style in some tests

2019-07-10 Thread Roman Lebedev via Phabricator via cfe-commits
lebedev.ri added inline comments.



Comment at: test/Format/language-detection.cpp:2
 // RUN: grep -Ev "// *[A-Z0-9_]+:" %s \
-// RUN:   | clang-format -style=llvm -assume-filename=foo.js \
 // RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s

What's wrong with `-style=llvm`?


Repository:
  rC Clang

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

https://reviews.llvm.org/D61001



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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-10 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added a comment.

In D64257#1577347 , @nridge wrote:

> @jvikstrom out of curiosity, are you testing these patches against a 
> client-side implementation of semantic highlighting? If so, which one?


Yes, I am testing against Theia. Just modified the Theia c++ language client to 
include the semantic highlighting service.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


[PATCH] D61001: [clang-format][tests] Explicitly specify style in some tests

2019-07-10 Thread Rafael Stahl via Phabricator via cfe-commits
r.stahl marked 2 inline comments as done.
r.stahl added inline comments.



Comment at: test/Format/language-detection.cpp:2
 // RUN: grep -Ev "// *[A-Z0-9_]+:" %s \
-// RUN:   | clang-format -style=llvm -assume-filename=foo.js \
 // RUN:   | FileCheck -strict-whitespace -check-prefix=CHECK1 %s

lebedev.ri wrote:
> What's wrong with `-style=llvm`?
I looked at all the tests in that folder and saw that LLVM is the more common 
usage and unified it.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61001



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


r365598 - [NFC][AArch64] Fix vector vqtb[lx][1-4]_s8 operand

2019-07-10 Thread Diogo N. Sampaio via cfe-commits
Author: dnsampaio
Date: Wed Jul 10 01:16:49 2019
New Revision: 365598

URL: http://llvm.org/viewvc/llvm-project?rev=365598&view=rev
Log:
[NFC][AArch64] Fix vector vqtb[lx][1-4]_s8 operand

Summary:
Change the vqtb[lx][1-4]_s8 instrinsics to have the last argument as vector of 
unsigned valuse, not
signed, accordingly to 
https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics

Reviewers: LukeCheeseman, DavidSpickett

Reviewed By: DavidSpickett

Subscribers: DavidSpickett, javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-tbl.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=365598&r1=365597&r2=365598&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Jul 10 01:16:49 2019
@@ -1070,16 +1070,16 @@ def VUZP2 : SOpInst<"vuzp2", "ddd",
 

 // Table lookup
 let InstName = "vtbl" in {
-def VQTBL1_A64 : WInst<"vqtbl1", "djt",  "UccPcQUcQcQPc">;
-def VQTBL2_A64 : WInst<"vqtbl2", "dBt",  "UccPcQUcQcQPc">;
-def VQTBL3_A64 : WInst<"vqtbl3", "dCt",  "UccPcQUcQcQPc">;
-def VQTBL4_A64 : WInst<"vqtbl4", "dDt",  "UccPcQUcQcQPc">;
+def VQTBL1_A64 : WInst<"vqtbl1", "dju",  "UccPcQUcQcQPc">;
+def VQTBL2_A64 : WInst<"vqtbl2", "dBu",  "UccPcQUcQcQPc">;
+def VQTBL3_A64 : WInst<"vqtbl3", "dCu",  "UccPcQUcQcQPc">;
+def VQTBL4_A64 : WInst<"vqtbl4", "dDu",  "UccPcQUcQcQPc">;
 }
 let InstName = "vtbx" in {
-def VQTBX1_A64 : WInst<"vqtbx1", "ddjt", "UccPcQUcQcQPc">;
-def VQTBX2_A64 : WInst<"vqtbx2", "ddBt", "UccPcQUcQcQPc">;
-def VQTBX3_A64 : WInst<"vqtbx3", "ddCt", "UccPcQUcQcQPc">;
-def VQTBX4_A64 : WInst<"vqtbx4", "ddDt", "UccPcQUcQcQPc">;
+def VQTBX1_A64 : WInst<"vqtbx1", "ddju", "UccPcQUcQcQPc">;
+def VQTBX2_A64 : WInst<"vqtbx2", "ddBu", "UccPcQUcQcQPc">;
+def VQTBX3_A64 : WInst<"vqtbx3", "ddCu", "UccPcQUcQcQPc">;
+def VQTBX4_A64 : WInst<"vqtbx4", "ddDu", "UccPcQUcQcQPc">;
 }
 
 


Modified: cfe/trunk/test/CodeGen/aarch64-neon-tbl.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-tbl.c?rev=365598&r1=365597&r2=365598&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-tbl.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-tbl.c Wed Jul 10 01:16:49 2019
@@ -16,7 +16,7 @@ int8x8_t test_vtbl1_s8(int8x8_t a, int8x
 // CHECK-LABEL: define <8 x i8> @test_vqtbl1_s8(<16 x i8> %a, <8 x i8> %b) #1 {
 // CHECK:   [[VTBL1_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl1.v8i8(<16 x 
i8> %a, <8 x i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL1_I]]
-int8x8_t test_vqtbl1_s8(int8x16_t a, int8x8_t b) {
+int8x8_t test_vqtbl1_s8(int8x16_t a, uint8x8_t b) {
   return vqtbl1_s8(a, b);
 }
 
@@ -59,7 +59,7 @@ int8x8_t test_vtbl2_s8(int8x8x2_t a, int
 // CHECK:   [[TMP2:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX2_I]], align 16
 // CHECK:   [[VTBL2_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl2.v8i8(<16 x 
i8> [[TMP1]], <16 x i8> [[TMP2]], <8 x i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL2_I]]
-int8x8_t test_vqtbl2_s8(int8x16x2_t a, int8x8_t b) {
+int8x8_t test_vqtbl2_s8(int8x16x2_t a, uint8x8_t b) {
   return vqtbl2_s8(a, b);
 }
 
@@ -109,7 +109,7 @@ int8x8_t test_vtbl3_s8(int8x8x3_t a, int
 // CHECK:   [[TMP3:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX4_I]], align 16
 // CHECK:   [[VTBL3_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl3.v8i8(<16 x 
i8> [[TMP1]], <16 x i8> [[TMP2]], <16 x i8> [[TMP3]], <8 x i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL3_I]]
-int8x8_t test_vqtbl3_s8(int8x16x3_t a, int8x8_t b) {
+int8x8_t test_vqtbl3_s8(int8x16x3_t a, uint8x8_t b) {
   return vqtbl3_s8(a, b);
 }
 
@@ -165,7 +165,7 @@ int8x8_t test_vtbl4_s8(int8x8x4_t a, int
 // CHECK:   [[TMP4:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX6_I]], align 16
 // CHECK:   [[VTBL4_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl4.v8i8(<16 x 
i8> [[TMP1]], <16 x i8> [[TMP2]], <16 x i8> [[TMP3]], <16 x i8> [[TMP4]], <8 x 
i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL4_I]]
-int8x8_t test_vqtbl4_s8(int8x16x4_t a, int8x8_t b) {
+int8x8_t test_vqtbl4_s8(int8x16x4_t a, uint8x8_t b) {
   return vqtbl4_s8(a, b);
 }
 
@@ -348,7 +348,7 @@ int8x8_t test_vtbx4_s8(int8x8_t a, int8x
 // CHECK-LABEL: define <8 x i8> @test_vqtbx1_s8(<8 x i8> %a, <16 x i8> %b, <8 
x i8> %c) #1 {
 // CHECK:   [[VTBX1_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbx1.v8i8(<8 x 
i8> %a, <16 x i8> %b, <8 x i8> %c) #3
 // CHECK:   ret <8 x i8> [[VTBX1_I]]
-int8x8_t test_vqtbx1_s8(int8x8_t a, int8x16_t b, int8x8_t c) {
+int8x8_t test_vqtbx1_s8(int8x8_t 

[PATCH] D64471: Loop pragma parsing. NFC.

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer created this revision.
SjoerdMeijer added reviewers: Meinersbur, dmgreen, samparker.

I would like to add some pragma handling here, but couldn't resist a little NFC 
and tidy up first.


https://reviews.llvm.org/D64471

Files:
  clang/lib/Sema/SemaStmtAttr.cpp


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -82,22 +82,17 @@
   IdentifierLoc *StateLoc = A.getArgAsIdent(2);
   Expr *ValueExpr = A.getArgAsExpr(3);
 
-  bool PragmaUnroll = PragmaNameLoc->Ident->getName() == "unroll";
-  bool PragmaNoUnroll = PragmaNameLoc->Ident->getName() == "nounroll";
-  bool PragmaUnrollAndJam = PragmaNameLoc->Ident->getName() == 
"unroll_and_jam";
-  bool PragmaNoUnrollAndJam =
-  PragmaNameLoc->Ident->getName() == "nounroll_and_jam";
+  StringRef PragmaName =
+  llvm::StringSwitch(PragmaNameLoc->Ident->getName())
+  .Cases("unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam",
+ PragmaNameLoc->Ident->getName())
+  .Default("clang loop");
+
   if (St->getStmtClass() != Stmt::DoStmtClass &&
   St->getStmtClass() != Stmt::ForStmtClass &&
   St->getStmtClass() != Stmt::CXXForRangeStmtClass &&
   St->getStmtClass() != Stmt::WhileStmtClass) {
-const char *Pragma =
-llvm::StringSwitch(PragmaNameLoc->Ident->getName())
-.Case("unroll", "#pragma unroll")
-.Case("nounroll", "#pragma nounroll")
-.Case("unroll_and_jam", "#pragma unroll_and_jam")
-.Case("nounroll_and_jam", "#pragma nounroll_and_jam")
-.Default("#pragma clang loop");
+std::string Pragma = "#pragma " + std::string(PragmaName);
 S.Diag(St->getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << 
Pragma;
 return nullptr;
   }
@@ -106,34 +101,29 @@
   LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
-  if (PragmaNoUnroll) {
-// #pragma nounroll
-Option = LoopHintAttr::Unroll;
-State = LoopHintAttr::Disable;
-  } else if (PragmaUnroll) {
-if (ValueExpr) {
-  // #pragma unroll N
-  Option = LoopHintAttr::UnrollCount;
-  State = LoopHintAttr::Numeric;
-} else {
-  // #pragma unroll
-  Option = LoopHintAttr::Unroll;
-  State = LoopHintAttr::Enable;
-}
-  } else if (PragmaNoUnrollAndJam) {
-// #pragma nounroll_and_jam
-Option = LoopHintAttr::UnrollAndJam;
-State = LoopHintAttr::Disable;
-  } else if (PragmaUnrollAndJam) {
-if (ValueExpr) {
-  // #pragma unroll_and_jam N
-  Option = LoopHintAttr::UnrollAndJamCount;
-  State = LoopHintAttr::Numeric;
-} else {
-  // #pragma unroll_and_jam
-  Option = LoopHintAttr::UnrollAndJam;
-  State = LoopHintAttr::Enable;
-}
+
+  auto SetHints = [&Option, &State](LoopHintAttr::OptionType O,
+LoopHintAttr::LoopHintState S) {
+Option = O;
+State = S;
+  };
+
+  if (PragmaName == "nounroll") {
+SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
+  } else if (PragmaName == "unroll") {
+// #pragma unroll N
+if (ValueExpr)
+  SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
+else
+  SetHints(LoopHintAttr::Unroll, LoopHintAttr::Enable);
+  } else if (PragmaName == "nounroll_and_jam") {
+SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Disable);
+  } else if (PragmaName == "unroll_and_jam") {
+// #pragma unroll_and_jam N
+if (ValueExpr)
+  SetHints(LoopHintAttr::UnrollAndJamCount, LoopHintAttr::Numeric);
+else
+  SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Enable);
   } else {
 // #pragma clang loop ...
 assert(OptionLoc && OptionLoc->Ident &&


Index: clang/lib/Sema/SemaStmtAttr.cpp
===
--- clang/lib/Sema/SemaStmtAttr.cpp
+++ clang/lib/Sema/SemaStmtAttr.cpp
@@ -82,22 +82,17 @@
   IdentifierLoc *StateLoc = A.getArgAsIdent(2);
   Expr *ValueExpr = A.getArgAsExpr(3);
 
-  bool PragmaUnroll = PragmaNameLoc->Ident->getName() == "unroll";
-  bool PragmaNoUnroll = PragmaNameLoc->Ident->getName() == "nounroll";
-  bool PragmaUnrollAndJam = PragmaNameLoc->Ident->getName() == "unroll_and_jam";
-  bool PragmaNoUnrollAndJam =
-  PragmaNameLoc->Ident->getName() == "nounroll_and_jam";
+  StringRef PragmaName =
+  llvm::StringSwitch(PragmaNameLoc->Ident->getName())
+  .Cases("unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam",
+ PragmaNameLoc->Ident->getName())
+  .Default("clang loop");
+
   if (St->getStmtClass() != Stmt::DoStmtClass &&
   St->getStmtClass() != Stmt::ForStmtClass &&
   St->getStmtClass() != Stmt::CXXForRangeStmtClass &&
   St->getStmtClass() != Stmt::WhileStmtClass) {
-const char *Pragma =
-llvm::StringSwitch(PragmaNameLoc-

[PATCH] D64243: [NFC][AArch64] Fix vector vqtb[lx][1-4]_s8 operand

2019-07-10 Thread Diogo N. Sampaio via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365598: [NFC][AArch64] Fix vector vqtb[lx][1-4]_s8 operand 
(authored by dnsampaio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64243

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/aarch64-neon-tbl.c

Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -1070,16 +1070,16 @@
 
 // Table lookup
 let InstName = "vtbl" in {
-def VQTBL1_A64 : WInst<"vqtbl1", "djt",  "UccPcQUcQcQPc">;
-def VQTBL2_A64 : WInst<"vqtbl2", "dBt",  "UccPcQUcQcQPc">;
-def VQTBL3_A64 : WInst<"vqtbl3", "dCt",  "UccPcQUcQcQPc">;
-def VQTBL4_A64 : WInst<"vqtbl4", "dDt",  "UccPcQUcQcQPc">;
+def VQTBL1_A64 : WInst<"vqtbl1", "dju",  "UccPcQUcQcQPc">;
+def VQTBL2_A64 : WInst<"vqtbl2", "dBu",  "UccPcQUcQcQPc">;
+def VQTBL3_A64 : WInst<"vqtbl3", "dCu",  "UccPcQUcQcQPc">;
+def VQTBL4_A64 : WInst<"vqtbl4", "dDu",  "UccPcQUcQcQPc">;
 }
 let InstName = "vtbx" in {
-def VQTBX1_A64 : WInst<"vqtbx1", "ddjt", "UccPcQUcQcQPc">;
-def VQTBX2_A64 : WInst<"vqtbx2", "ddBt", "UccPcQUcQcQPc">;
-def VQTBX3_A64 : WInst<"vqtbx3", "ddCt", "UccPcQUcQcQPc">;
-def VQTBX4_A64 : WInst<"vqtbx4", "ddDt", "UccPcQUcQcQPc">;
+def VQTBX1_A64 : WInst<"vqtbx1", "ddju", "UccPcQUcQcQPc">;
+def VQTBX2_A64 : WInst<"vqtbx2", "ddBu", "UccPcQUcQcQPc">;
+def VQTBX3_A64 : WInst<"vqtbx3", "ddCu", "UccPcQUcQcQPc">;
+def VQTBX4_A64 : WInst<"vqtbx4", "ddDu", "UccPcQUcQcQPc">;
 }
 
 
Index: cfe/trunk/test/CodeGen/aarch64-neon-tbl.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-tbl.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-tbl.c
@@ -16,7 +16,7 @@
 // CHECK-LABEL: define <8 x i8> @test_vqtbl1_s8(<16 x i8> %a, <8 x i8> %b) #1 {
 // CHECK:   [[VTBL1_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl1.v8i8(<16 x i8> %a, <8 x i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL1_I]]
-int8x8_t test_vqtbl1_s8(int8x16_t a, int8x8_t b) {
+int8x8_t test_vqtbl1_s8(int8x16_t a, uint8x8_t b) {
   return vqtbl1_s8(a, b);
 }
 
@@ -59,7 +59,7 @@
 // CHECK:   [[TMP2:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX2_I]], align 16
 // CHECK:   [[VTBL2_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl2.v8i8(<16 x i8> [[TMP1]], <16 x i8> [[TMP2]], <8 x i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL2_I]]
-int8x8_t test_vqtbl2_s8(int8x16x2_t a, int8x8_t b) {
+int8x8_t test_vqtbl2_s8(int8x16x2_t a, uint8x8_t b) {
   return vqtbl2_s8(a, b);
 }
 
@@ -109,7 +109,7 @@
 // CHECK:   [[TMP3:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX4_I]], align 16
 // CHECK:   [[VTBL3_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl3.v8i8(<16 x i8> [[TMP1]], <16 x i8> [[TMP2]], <16 x i8> [[TMP3]], <8 x i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL3_I]]
-int8x8_t test_vqtbl3_s8(int8x16x3_t a, int8x8_t b) {
+int8x8_t test_vqtbl3_s8(int8x16x3_t a, uint8x8_t b) {
   return vqtbl3_s8(a, b);
 }
 
@@ -165,7 +165,7 @@
 // CHECK:   [[TMP4:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX6_I]], align 16
 // CHECK:   [[VTBL4_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbl4.v8i8(<16 x i8> [[TMP1]], <16 x i8> [[TMP2]], <16 x i8> [[TMP3]], <16 x i8> [[TMP4]], <8 x i8> %b) #3
 // CHECK:   ret <8 x i8> [[VTBL4_I]]
-int8x8_t test_vqtbl4_s8(int8x16x4_t a, int8x8_t b) {
+int8x8_t test_vqtbl4_s8(int8x16x4_t a, uint8x8_t b) {
   return vqtbl4_s8(a, b);
 }
 
@@ -348,7 +348,7 @@
 // CHECK-LABEL: define <8 x i8> @test_vqtbx1_s8(<8 x i8> %a, <16 x i8> %b, <8 x i8> %c) #1 {
 // CHECK:   [[VTBX1_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbx1.v8i8(<8 x i8> %a, <16 x i8> %b, <8 x i8> %c) #3
 // CHECK:   ret <8 x i8> [[VTBX1_I]]
-int8x8_t test_vqtbx1_s8(int8x8_t a, int8x16_t b, int8x8_t c) {
+int8x8_t test_vqtbx1_s8(int8x8_t a, int8x16_t b, uint8x8_t c) {
   return vqtbx1_s8(a, b, c);
 }
 
@@ -369,7 +369,7 @@
 // CHECK:   [[TMP2:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX2_I]], align 16
 // CHECK:   [[VTBX2_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbx2.v8i8(<8 x i8> %a, <16 x i8> [[TMP1]], <16 x i8> [[TMP2]], <8 x i8> %c) #3
 // CHECK:   ret <8 x i8> [[VTBX2_I]]
-int8x8_t test_vqtbx2_s8(int8x8_t a, int8x16x2_t b, int8x8_t c) {
+int8x8_t test_vqtbx2_s8(int8x8_t a, int8x16x2_t b, uint8x8_t c) {
   return vqtbx2_s8(a, b, c);
 }
 
@@ -393,7 +393,7 @@
 // CHECK:   [[TMP3:%.*]] = load <16 x i8>, <16 x i8>* [[ARRAYIDX4_I]], align 16
 // CHECK:   [[VTBX3_I:%.*]] = call <8 x i8> @llvm.aarch64.neon.tbx3.v8i8(<8 x i8> %a, <16 x i8> [[TMP1]], <16 x i8> [[TMP2]], <16 x i8> [[TMP3]], <8 x i8> %c) #3
 // CHECK:   ret <8 x i8> [[VTBX3_I]]
-int8x8_t test_vqt

[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay marked an inline comment as done.
MaskRay added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:585
+  (A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ||
+  (!(A && A->getOption().matches(options::OPT_fomit_frame_pointer)) &&
+   (Args.hasArg(options::OPT_pg) ||

ychen wrote:
> It looks better if  `frame_pointer` is represented using tri-state. Something 
> like this?
> 
> It would be great to have comments for conditions that are not obvious such 
> as the overriding rules.
> 
> ```
>   // There are three states for frame_pointer.
>   enum class FpFlag {true, false, none};
>   FpFlag FPF = FpFlag::none;
>   if (Arg *A = Args.getLastArg(options::OPT_fomit_frame_pointer,
>options::OPT_fno_omit_frame_pointer))
> FPF = A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ?
>  FpFlag::true : FpFlag::false;
> 
>   if (!mustUseNonLeaf && FPF == FpFlag::false)
> return FramePointerKind::None;
> 
>   if (mustUseNonLeaf || FPF == FpFlag::true || Args.hasArg(options::OPT_pg) ||
>   useFramePointerForTargetByDefault(Args, Triple)) {
> if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
>  options::OPT_mno_omit_leaf_frame_pointer,
>  Triple.isPS4CPU()))
>   return FramePointerKind::NonLeaf;
> return FramePointerKind::All;
>   }
>   return FramePointerKind::None;
> ```
I actually think the current version is clearer.. The local `enum class FpFlag 
{true, false, none};` doesn't improve readability in my opinion.


I can define separate variables for:

* A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)
* A && A->getOption().matches(options::OPT_fomit_frame_pointer)

If reviewers think that makes the code easier to read.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein accepted this revision.
hokein added a comment.
This revision is now accepted and ready to land.

thanks, looks good.




Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:83
+// `Class` type. The destructor decls are handled in `VisitTypeLoc` (we 
will
+// visit a TypeLoc where the underlying Type is a CXXRecordDecl).
+if (D->getDeclName().isIdentifier() && D->getName().empty())

this comment doesn't belong to the if statement below, should move to Line 87.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


[PATCH] D64247: [clangd] Filter out non-governed files from broadcast

2019-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet updated this revision to Diff 208890.
kadircet marked 3 inline comments as done.
kadircet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64247

Files:
  clang-tools-extra/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/clangd/index/Background.cpp
  clang-tools-extra/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
  clang-tools-extra/clangd/unittests/TestFS.cpp
  clang-tools-extra/clangd/unittests/TestFS.h

Index: clang-tools-extra/clangd/unittests/TestFS.h
===
--- clang-tools-extra/clangd/unittests/TestFS.h
+++ clang-tools-extra/clangd/unittests/TestFS.h
@@ -12,6 +12,8 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #include "ClangdServer.h"
+#include "GlobalCompilationDatabase.h"
+#include "Path.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -48,7 +50,9 @@
   StringRef RelPathPrefix = StringRef());
 
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
+
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
   std::vector ExtraClangFlags;
 
Index: clang-tools-extra/clangd/unittests/TestFS.cpp
===
--- clang-tools-extra/clangd/unittests/TestFS.cpp
+++ clang-tools-extra/clangd/unittests/TestFS.cpp
@@ -6,7 +6,11 @@
 //
 //===--===//
 #include "TestFS.h"
+#include "GlobalCompilationDatabase.h"
+#include "Path.h"
 #include "URI.h"
+#include "llvm/ADT/None.h"
+#include "llvm/ADT/Optional.h"
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Errc.h"
 #include "llvm/Support/Path.h"
@@ -36,9 +40,13 @@
   // -ffreestanding avoids implicit stdc-predef.h.
 }
 
+llvm::Optional
+MockCompilationDatabase::getProjectInfo(PathRef File) const {
+  return ProjectInfo{Directory};
+};
+
 llvm::Optional
-MockCompilationDatabase::getCompileCommand(PathRef File,
-   ProjectInfo *Project) const {
+MockCompilationDatabase::getCompileCommand(PathRef File) const {
   if (ExtraClangFlags.empty())
 return None;
 
@@ -57,8 +65,6 @@
 CommandLine.push_back(RelativeFilePath.str());
   }
 
-  if (Project)
-Project->SourceRoot = Directory;
   return {tooling::CompileCommand(Directory != llvm::StringRef()
   ? Directory
   : llvm::sys::path::parent_path(File),
Index: clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
===
--- clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
+++ clang-tools-extra/clangd/unittests/GlobalCompilationDatabaseTests.cpp
@@ -8,10 +8,21 @@
 
 #include "GlobalCompilationDatabase.h"
 
+#include "Path.h"
 #include "TestFS.h"
+#include "llvm/ADT/Optional.h"
+#include "llvm/ADT/SmallString.h"
 #include "llvm/ADT/StringExtras.h"
+#include "llvm/ADT/StringRef.h"
+#include "llvm/Support/FileSystem.h"
+#include "llvm/Support/FormatVariadic.h"
+#include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
+#include "llvm/Support/raw_ostream.h"
 #include "gmock/gmock.h"
 #include "gtest/gtest.h"
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -20,8 +31,10 @@
 using ::testing::Contains;
 using ::testing::ElementsAre;
 using ::testing::EndsWith;
+using ::testing::IsEmpty;
 using ::testing::Not;
 using ::testing::StartsWith;
+using ::testing::UnorderedElementsAre;
 
 TEST(GlobalCompilationDatabaseTest, FallbackCommand) {
   DirectoryBasedGlobalCompilationDatabase DB(None);
@@ -50,13 +63,9 @@
   class BaseCDB : public GlobalCompilationDatabase {
   public:
 llvm::Optional
-getCompileCommand(llvm::StringRef File,
-  ProjectInfo *Project) const override {
-  if (File == testPath("foo.cc")) {
-if (Project)
-  Project->SourceRoot = testRoot();
+getCompileCommand(llvm::StringRef File) const override {
+  if (File == testPath("foo.cc"))
 return cmd(File, "-DA=1");
-  }
   return None;
 }
 
@@ -64,6 +73,10 @@
 getFallbackCommand(llvm::StringRef File) const override {
   return cmd(File, "-DA=2");
 }
+
+llvm::Optional getProjectInfo(PathRef File) const override {
+  return ProjectInfo{testRoot()};
+}
   };
 
 protected:
@@ -153,6 +166,109 @@
 Not(Contains("random-plugin";
 }
 
+TEST(GlobalCompilationDat

r365599 - [Syntax] Add assertion to catch invalid tokens early. NFC

2019-07-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jul 10 01:24:42 2019
New Revision: 365599

URL: http://llvm.org/viewvc/llvm-project?rev=365599&view=rev
Log:
[Syntax] Add assertion to catch invalid tokens early. NFC

To help with identifiying root cause of a crash we are seeing.

Modified:
cfe/trunk/include/clang/Tooling/Syntax/Tokens.h
cfe/trunk/lib/Tooling/Syntax/Tokens.cpp

Modified: cfe/trunk/include/clang/Tooling/Syntax/Tokens.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Syntax/Tokens.h?rev=365599&r1=365598&r2=365599&view=diff
==
--- cfe/trunk/include/clang/Tooling/Syntax/Tokens.h (original)
+++ cfe/trunk/include/clang/Tooling/Syntax/Tokens.h Wed Jul 10 01:24:42 2019
@@ -99,8 +99,7 @@ llvm::raw_ostream &operator<<(llvm::raw_
 /// Can represent both expanded and spelled tokens.
 class Token {
 public:
-  Token(SourceLocation Location, unsigned Length, tok::TokenKind Kind)
-  : Location(Location), Length(Length), Kind(Kind) {}
+  Token(SourceLocation Location, unsigned Length, tok::TokenKind Kind);
   /// EXPECTS: clang::Token is not an annotation token.
   explicit Token(const clang::Token &T);
 

Modified: cfe/trunk/lib/Tooling/Syntax/Tokens.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Syntax/Tokens.cpp?rev=365599&r1=365598&r2=365599&view=diff
==
--- cfe/trunk/lib/Tooling/Syntax/Tokens.cpp (original)
+++ cfe/trunk/lib/Tooling/Syntax/Tokens.cpp Wed Jul 10 01:24:42 2019
@@ -35,6 +35,12 @@
 using namespace clang;
 using namespace clang::syntax;
 
+syntax::Token::Token(SourceLocation Location, unsigned Length,
+ tok::TokenKind Kind)
+: Location(Location), Length(Length), Kind(Kind) {
+  assert(Location.isValid());
+}
+
 syntax::Token::Token(const clang::Token &T)
 : Token(T.getLocation(), T.getLength(), T.getKind()) {
   assert(!T.isAnnotation());


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


[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added a comment.

In D64257#1577347 , @nridge wrote:

> are you testing these patches against a client-side implementation of 
> semantic highlighting? If so, which one?


Looks like Theia is the only LSP client supporting the semantic highlighting 
proposal, we use it to verify the behavior.

And we also have a hidden tweak (run clangd with `-hidden-feature`) to annotate 
all the highlighting tokens, we use it to verify whether the token is being 
highlighted in a correct TextMate scope (it is triggered via the codeAction in 
VSCode).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64257



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


[PATCH] D64256: Teach some warnings to respect gsl::Pointer and gsl::Owner attributes

2019-07-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr accepted this revision.
gribozavr added a comment.
This revision is now accepted and ready to land.

I'm not an expert in SemaInit code, but this change LGTM.




Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:8
+
+struct OwnerWithConv;
+

Not needed anymore.



Comment at: clang/test/Sema/warn-lifetime-analysis-nocfg.cpp:25
+
+struct [[gsl::Owner(int)]] OwnerWithConv {
+  OwnerWithConv();

Would be nice if the second pair of types had clearly related names, like the 
first pair (MyOwner/MyPointer).


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

https://reviews.llvm.org/D64256



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


[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added a comment.

> Those are already there in clang/test/SemaCXX/attr-gsl-owner-pointer.cpp.

I see. Sorry, but that seems insufficient to me -- different libraries use 
different patterns. For example, libc++ wraps everything in std in an inline 
namespace. I don't know how various versions of libstdc++ differ.




Comment at: clang/include/clang/Basic/TokenKinds.def:486
+TYPE_TRAIT_1(__is_gsl_owner, IsGslOwner, KEYCXX)
+TYPE_TRAIT_1(__is_gsl_pointer, IsGslPointer, KEYCXX)
 KEYWORD(__underlying_type   , KEYCXX)

I'd suggest to split type trait implementations into a separate patch.

Are these type traits being exposed only for testing? I'm not sure it is a good 
idea to do that -- people will end up using them in production code -- is that 
a concern? If so, maybe it would be better to test through warnings.



Comment at: clang/test/AST/ast-dump-attr.cpp:222
+
+class [[gsl::Pointer]] PointerWithoutArgument{};
+// CHECK: CXXRecordDecl{{.*}} class PointerWithoutArgument

This test and related code changes could be split off into a separate patch.



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:86
+
+// Test builtin annotation for std types.
+namespace std {

I feel like these tests would be better off in a separate file.

It would be also good to explain which exact library we are trying to imitate 
in this test. Different libraries use different coding patterns.



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:103
+template 
+class set_iterator {};
+

Is it actually defined like that?



Comment at: clang/test/SemaCXX/attr-gsl-owner-pointer.cpp:140
+
+class thread;
+static_assert(!__is_gsl_pointer(thread), "");

Unclear what this test is testing.

If there's something special about thread (e.g., it looks very much like an 
owner or a pointer, and a buggy implementation can easily declare thread to be 
an owner or a pointer), please explain that in a comment.

If you're testing that some random name is not being picked up by inference 
rules, I'd suggest to use an obviously-fictional name ("class 
type_unknown_to_compiler;")


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64448



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


[clang-tools-extra] r365602 - [clangd] Added highlighting for class and enum types.

2019-07-10 Thread Johan Vikstrom via cfe-commits
Author: jvikstrom
Date: Wed Jul 10 01:41:25 2019
New Revision: 365602

URL: http://llvm.org/viewvc/llvm-project?rev=365602&view=rev
Log:
[clangd] Added highlighting for class and enum types.

Summary: Added highlighting for non-builtin types using VisitTypeLoc. Ignoring 
namespace qualifiers as for now.

Reviewers: hokein, sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
clang-tools-extra/trunk/clangd/SemanticHighlighting.h
clang-tools-extra/trunk/clangd/test/semantic-highlighting.test
clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp

Modified: clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp?rev=365602&r1=365601&r2=365602&view=diff
==
--- clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp (original)
+++ clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp Wed Jul 10 01:41:25 
2019
@@ -11,6 +11,8 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 
 namespace clang {
@@ -35,13 +37,18 @@ public:
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
-if (ND->getDeclName().getNameKind() != DeclarationName::Identifier)
+// Constructors' TypeLoc has a TypePtr that is a FunctionProtoType. It has
+// no tag decl and therefore constructors must be gotten as NamedDecls
+// instead.
+if (ND->getDeclName().getNameKind() ==
+DeclarationName::CXXConstructorName) {
+  addToken(ND->getLocation(), ND);
   return true;
+}
 
-if (ND->getDeclName().isEmpty())
-  // Don't add symbols that don't have any length.
+if (ND->getDeclName().getNameKind() != DeclarationName::Identifier)
   return true;
+
 addToken(ND->getLocation(), ND);
 return true;
   }
@@ -56,8 +63,39 @@ public:
 return true;
   }
 
+  bool VisitTypeLoc(TypeLoc &TL) {
+// This check is for not getting two entries when there are anonymous
+// structs. It also makes us not highlight namespace qualifiers. For
+// elaborated types the actual type is highlighted as an inner TypeLoc.
+if (TL.getTypeLocClass() == TypeLoc::TypeLocClass::Elaborated)
+  return true;
+
+if (const Type *TP = TL.getTypePtr())
+  if (const TagDecl *TD = TP->getAsTagDecl())
+  addToken(TL.getBeginLoc(), TD);
+return true;
+  }
+
 private:
-  void addToken(SourceLocation Loc, const Decl *D) {
+  void addToken(SourceLocation Loc, const NamedDecl *D) {
+if (D->getDeclName().isIdentifier() && D->getName().empty())
+  // Don't add symbols that don't have any length.
+  return;
+// We highlight class decls, constructor decls and destructor decls as
+// `Class` type. The destructor decls are handled in `VisitTypeLoc` (we 
will
+// visit a TypeLoc where the underlying Type is a CXXRecordDecl).
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);
+  return;
+}
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);
+  return;
+}
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Enum);
+  return;
+}
 if (isa(D)) {
   addToken(Loc, HighlightingKind::Variable);
   return;
@@ -176,6 +214,10 @@ llvm::StringRef toTextMateScope(Highligh
 return "entity.name.function.cpp";
   case HighlightingKind::Variable:
 return "variable.cpp";
+  case HighlightingKind::Class:
+return "entity.name.type.class.cpp";
+  case HighlightingKind::Enum:
+return "entity.name.type.enum.cpp";
   case HighlightingKind::NumKinds:
 llvm_unreachable("must not pass NumKinds to the function");
   }

Modified: clang-tools-extra/trunk/clangd/SemanticHighlighting.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/SemanticHighlighting.h?rev=365602&r1=365601&r2=365602&view=diff
==
--- clang-tools-extra/trunk/clangd/SemanticHighlighting.h (original)
+++ clang-tools-extra/trunk/clangd/SemanticHighlighting.h Wed Jul 10 01:41:25 
2019
@@ -26,6 +26,8 @@ namespace clangd {
 enum class HighlightingKind {
   Variable = 0,
   Function,
+  Class,
+  Enum,
 
   NumKinds,
 };

Modified: clang-tools-extra/trunk/clangd/test/semantic-highlighting.test
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/test/semantic-highlighting.test?rev=365602&r1=365601&r2=365602&view=diff
==
--- clang-tools-extra/trunk/clangd/test/semantic-highlighting.t

[PATCH] D64257: [clangd] Added highlighting for class and enum types

2019-07-10 Thread Johan Vikström via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365602: [clangd] Added highlighting for class and enum 
types. (authored by jvikstrom, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64257?vs=208708&id=208895#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64257

Files:
  clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
  clang-tools-extra/trunk/clangd/SemanticHighlighting.h
  clang-tools-extra/trunk/clangd/test/semantic-highlighting.test
  clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/trunk/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/trunk/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/trunk/clangd/test/semantic-highlighting.test
@@ -10,6 +10,12 @@
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
 # CHECK-NEXT:  ]
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.class.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
 ---
Index: clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/trunk/clangd/SemanticHighlighting.cpp
@@ -11,6 +11,8 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
+#include "clang/AST/Decl.h"
+#include "clang/AST/DeclarationName.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 
 namespace clang {
@@ -35,13 +37,18 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
-// FIXME: (De)Constructors/operator need to be highlighted some other way.
-if (ND->getDeclName().getNameKind() != DeclarationName::Identifier)
+// Constructors' TypeLoc has a TypePtr that is a FunctionProtoType. It has
+// no tag decl and therefore constructors must be gotten as NamedDecls
+// instead.
+if (ND->getDeclName().getNameKind() ==
+DeclarationName::CXXConstructorName) {
+  addToken(ND->getLocation(), ND);
   return true;
+}
 
-if (ND->getDeclName().isEmpty())
-  // Don't add symbols that don't have any length.
+if (ND->getDeclName().getNameKind() != DeclarationName::Identifier)
   return true;
+
 addToken(ND->getLocation(), ND);
 return true;
   }
@@ -56,8 +63,39 @@
 return true;
   }
 
+  bool VisitTypeLoc(TypeLoc &TL) {
+// This check is for not getting two entries when there are anonymous
+// structs. It also makes us not highlight namespace qualifiers. For
+// elaborated types the actual type is highlighted as an inner TypeLoc.
+if (TL.getTypeLocClass() == TypeLoc::TypeLocClass::Elaborated)
+  return true;
+
+if (const Type *TP = TL.getTypePtr())
+  if (const TagDecl *TD = TP->getAsTagDecl())
+  addToken(TL.getBeginLoc(), TD);
+return true;
+  }
+
 private:
-  void addToken(SourceLocation Loc, const Decl *D) {
+  void addToken(SourceLocation Loc, const NamedDecl *D) {
+if (D->getDeclName().isIdentifier() && D->getName().empty())
+  // Don't add symbols that don't have any length.
+  return;
+// We highlight class decls, constructor decls and destructor decls as
+// `Class` type. The destructor decls are handled in `VisitTypeLoc` (we will
+// visit a TypeLoc where the underlying Type is a CXXRecordDecl).
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);
+  return;
+}
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Class);
+  return;
+}
+if (isa(D)) {
+  addToken(Loc, HighlightingKind::Enum);
+  return;
+}
 if (isa(D)) {
   addToken(Loc, HighlightingKind::Variable);
   return;
@@ -176,6 +214,10 @@
 return "entity.name.function.cpp";
   case HighlightingKind::Variable:
 return "variable.cpp";
+  case HighlightingKind::Class:
+return "entity.name.type.class.cpp";
+  case HighlightingKind::Enum:
+return "entity.name.type.enum.cpp";
   case HighlightingKind::NumKinds:
 llvm_unreachable("must not pass NumKinds to the function");
   }
Index: clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/SemanticHighlightingTests.cpp
@@ -34,11 +34,13 @@
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
-  {HighlightingKind::Function, "Function"}};
+  {HighlightingKind::Functio

[PATCH] D63954: Add lifetime categories attributes

2019-07-10 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:4164
+  let Content = [{
+When annotating a class ``O`` with ``[[gsl::Owner(T)]]``, then each function
+that returns cv-qualified ``T&`` or ``T*`` is assumed to return a

Slightly better: "In a class annotated with ..., each function that returns ... 
is assumed to ..."

However, the "is assumed" part throws me off. There's no assumption here -- 
this is what this attribute means, intentionally, by design, no guessing 
involved.

So how about this?

The attribute `[[gsl::Owner(T)]]` applies to structs and classes that own an 
object of type `T`:

```
[[gsl::Owner(int)]] class IntOwner {
private:
  int value;
public:
  int *getInt() { return &value; }
  long *getLong();
};
```

In a class annotated like this each member function that returns `T&` or `T*` 
returns a pointer/reference to the data owned by the class instance:

```
IntOwner int_owner;
int *x = int_owner.getInt();
// `x` points to memory owned by `int_owner`.
```

Therefore, that the lifetime of that data ends when ... For example:

```
int *x = IntOwner().getInt();
// `x` points to memory owned by the temporary `IntOwner()`, which has been 
destroyed now.

long *y = IntOwner().getLong();
// Can't make any conclusion about validity of `y`.
```




Comment at: clang/include/clang/Basic/AttrDocs.td:4177
+  let Content = [{
+When annotating a class ``P`` with ``[[gsl::Pointer(T)]]``, it assumed to be a
+non-owning type whose objects can point to ``T`` type objects or dangle.

Ditto, "A class annotated with ... is assumed to be ..."

However, again, I feel like "assume" is the wrong word to use.

"The attribute `[[gsl::Pointer(T)]]` applies to structs and classes that behave 
like pointers to an object of type `T`:

```
class [[gsl::Pointer(int)]] IntPointer {
private:
  int *valuePointer;
public:
  // fill it in with appropriate APIs
};
```

Classes annotated like this behave like regular pointers: they can either point 
to objects of type `T`, or dangle (<<>>).

For example: ... sample code and a static analysis message...



Comment at: clang/lib/Sema/SemaDeclAttr.cpp:4546-4547
+
+  if (ParmType->isVoidType()) {
+S.Diag(AL.getLoc(), diag::err_attribute_invalid_argument) << "'void'" << 
AL;
+return;

xazax.hun wrote:
> aaron.ballman wrote:
> > Is `void` really the only problematic type? What about incomplete types, 
> > for instance?
> I think incomplete types are fine. The only information we actually need here 
> is the name the pointee types. E.g. for a `SomeOwner` which is 
> annotated `Owner(Incomplete)`, we will assume that a method returning 
> `Incomplete*`, `std::reference_wrapper` etc will return an object 
> pointing to the memory owned by `SomeOwner`.
What about array types? References?

gsl::Owner(int[])
gsl::Owner(int&)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63954



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


[clang-tools-extra] r365606 - [clangd] Consume error to avoid assertion failures

2019-07-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jul 10 02:18:09 2019
New Revision: 365606

URL: http://llvm.org/viewvc/llvm-project?rev=365606&view=rev
Log:
[clangd] Consume error to avoid assertion failures

When we fail to calculate #include insertion for a completion item.
Note that this change does not add a test, although that would be good.

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

Modified: clang-tools-extra/trunk/clangd/CodeComplete.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/CodeComplete.cpp?rev=365606&r1=365605&r2=365606&view=diff
==
--- clang-tools-extra/trunk/clangd/CodeComplete.cpp (original)
+++ clang-tools-extra/trunk/clangd/CodeComplete.cpp Wed Jul 10 02:18:09 2019
@@ -346,8 +346,9 @@ struct CodeCompletionBuilder {
 Completion.Includes.push_back(std::move(Include));
   } else
 log("Failed to generate include insertion edits for adding header "
-"(FileURI='{0}', IncludeHeader='{1}') into {2}",
-C.IndexResult->CanonicalDeclaration.FileURI, Inc, FileName);
+"(FileURI='{0}', IncludeHeader='{1}') into {2}: {3}",
+C.IndexResult->CanonicalDeclaration.FileURI, Inc, FileName,
+ToInclude.takeError());
 }
 // Prefer includes that do not need edits (i.e. already exist).
 std::stable_partition(Completion.Includes.begin(),


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


[clang-tools-extra] r365607 - [clangd] Stop recording tokens before running clang-tidy

2019-07-10 Thread Ilya Biryukov via cfe-commits
Author: ibiryukov
Date: Wed Jul 10 02:28:35 2019
New Revision: 365607

URL: http://llvm.org/viewvc/llvm-project?rev=365607&view=rev
Log:
[clangd] Stop recording tokens before running clang-tidy

modernize-trailing-return-type runs the preprocessor, breaking the token
collection logic.

This lead to a crash before, see the new test for a repro.

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

Modified: clang-tools-extra/trunk/clangd/ClangdUnit.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdUnit.cpp?rev=365607&r1=365606&r2=365607&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdUnit.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdUnit.cpp Wed Jul 10 02:28:35 2019
@@ -421,12 +421,16 @@ ParsedAST::build(std::unique_ptrgetPreprocessor().addCommentHandler(IWYUHandler.get());
 
   // Collect tokens of the main file.
-  syntax::TokenCollector Tokens(Clang->getPreprocessor());
+  syntax::TokenCollector CollectTokens(Clang->getPreprocessor());
 
   if (llvm::Error Err = Action->Execute())
 log("Execute() failed when building AST for {0}: {1}", MainInput.getFile(),
 toString(std::move(Err)));
 
+  // We have to consume the tokens before running clang-tidy to avoid 
collecting
+  // tokens from running the preprocessor inside the checks (only
+  // modernize-use-trailing-return-type does that today).
+  syntax::TokenBuffer Tokens = std::move(CollectTokens).consume();
   std::vector ParsedDecls = Action->takeTopLevelDecls();
   // AST traversals should exclude the preamble, to avoid performance cliffs.
   Clang->getASTContext().setTraversalScope(ParsedDecls);
@@ -452,9 +456,8 @@ ParsedAST::build(std::unique_ptrDiags.begin(), 
Preamble->Diags.end());
   return ParsedAST(std::move(Preamble), std::move(Clang), std::move(Action),
-   std::move(Tokens).consume(), std::move(ParsedDecls),
-   std::move(Diags), std::move(Includes),
-   std::move(CanonIncludes));
+   std::move(Tokens), std::move(ParsedDecls), std::move(Diags),
+   std::move(Includes), std::move(CanonIncludes));
 }
 
 ParsedAST::ParsedAST(ParsedAST &&Other) = default;

Modified: clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp?rev=365607&r1=365606&r2=365607&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/ClangdUnitTests.cpp Wed Jul 10 
02:28:35 2019
@@ -134,6 +134,27 @@ TEST(ClangdUnitTest, TokensAfterPreamble
   EXPECT_EQ(Spelled.back().text(SM), "last_token");
 }
 
+
+TEST(ClangdUnitTest, NoCrashOnTokensWithTidyCheck) {
+  TestTU TU;
+  // this check runs the preprocessor, we need to make sure it does not break
+  // our recording logic.
+  TU.ClangTidyChecks = "modernize-use-trailing-return-type";
+  TU.Code = "inline int foo() {}";
+
+  auto AST = TU.build();
+  const syntax::TokenBuffer &T = AST.getTokens();
+  const auto &SM = AST.getSourceManager();
+
+  ASSERT_GT(T.expandedTokens().size(), 7u);
+  // Check first token after the preamble.
+  EXPECT_EQ(T.expandedTokens().front().text(SM), "inline");
+  // Last token is always 'eof'.
+  EXPECT_EQ(T.expandedTokens().back().kind(), tok::eof);
+  // Check the token before 'eof'.
+  EXPECT_EQ(T.expandedTokens().drop_back().back().text(SM), "}");
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang


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


[PATCH] D64448: gsl::Owner/gsl::Pointer: Add implicit annotations for some std types

2019-07-10 Thread Jonas Toth via Phabricator via cfe-commits
JonasToth added a comment.

Just as Sidenote in case you were not aware: There is a check in clang-tidy for 
`gsl::owner` 
(https://clang.llvm.org/extra/clang-tidy/checks/cppcoreguidelines-owning-memory.html)
It will benefit from your annotation and can be simplified.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64448



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


Re: r365499 - [OpenCL][Sema] Fix builtin rewriting

2019-07-10 Thread Marco Antognini via cfe-commits
Hello Reid,

Thanks for reporting it. I filed a bug to fix that (http://llvm.org/PR42560). 
However, I'm not sure I'll have time this week to look at it, especially given 
that we have no Windows builder around here. If you are critically blocked by 
this, could you check that adding '// UNSUPPORTED: system-windows' properly 
disables the test? And if so, feel free to commit for now.

Marco

From: Reid Kleckner 
Sent: 09 July 2019 21:47
To: Marco Antognini
Cc: cfe-commits
Subject: Re: r365499 - [OpenCL][Sema] Fix builtin rewriting

FYI, your test seems to fail on Windows:
FAIL: Clang :: CodeGenOpenCL/pipe_builtin.cl (4679 of 
15176)
 TEST 'Clang :: 
CodeGenOpenCL/pipe_builtin.cl' FAILED 

Script:
--
: 'RUN: at line 1';   
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe -cc1 
-internal-isystem 
c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include 
-nostdsysteminc -emit-llvm -cl-ext=+cl_khr_subgroups -O0 -cl-std=c++ -o - 
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\CodeGenOpenCL\pipe_builtin.cl
 | c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\filecheck.exe 
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\CodeGenOpenCL\pipe_builtin.cl
--
Exit Code: 2

Command Output (stdout):
--
$ ":" "RUN: at line 1"
$ "c:\b\slave\clang-x64-windows-msvc\build\build\stage1\bin\clang.exe" "-cc1" 
"-internal-isystem" 
"c:\b\slave\clang-x64-windows-msvc\build\build\stage1\lib\clang\9.0.0\include" 
"-nostdsysteminc" "-emit-llvm" "-cl-ext=+cl_khr_subgroups" "-O0" "-cl-std=c++" 
"-o" "-" 
"C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\CodeGenOpenCL\pipe_builtin.cl"
# command stderr:
C:\b\slave\clang-x64-windows-msvc\build\llvm.src\tools\clang\test\CodeGenOpenCL\pipe_builtin.cl:9:1:
 error: cannot mangle this OpenCL pipe type yet

void test1(read_only pipe int p, global int *ptr) {

^~~

1 error generated.

On Tue, Jul 9, 2019 at 8:04 AM Marco Antognini via cfe-commits 
mailto:cfe-commits@lists.llvm.org>> wrote:
Author: mantognini
Date: Tue Jul  9 08:04:23 2019
New Revision: 365499

URL: http://llvm.org/viewvc/llvm-project?rev=365499&view=rev
Log:
[OpenCL][Sema] Fix builtin rewriting

This patch ensures built-in functions are rewritten using the proper
parent declaration.

Existing tests are modified to run in C++ mode to ensure the
functionality works also with C++ for OpenCL while not increasing the
testing runtime.

Modified:
cfe/trunk/include/clang/Basic/Builtins.def
cfe/trunk/lib/Sema/SemaExpr.cpp
cfe/trunk/test/CodeGenOpenCL/builtins.cl
cfe/trunk/test/CodeGenOpenCL/pipe_builtin.cl
cfe/trunk/test/CodeGenOpenCL/to_addr_builtin.cl

Modified: cfe/trunk/include/clang/Basic/Builtins.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Builtins.def?rev=365499&r1=365498&r2=365499&view=diff
==
--- cfe/trunk/include/clang/Basic/Builtins.def (original)
+++ cfe/trunk/include/clang/Basic/Builtins.def Tue Jul  9 08:04:23 2019
@@ -1478,6 +1478,7 @@ BUILTIN(__builtin_coro_begin, "v*v*", "n
 BUILTIN(__builtin_coro_end, "bv*Ib", "n")
 BUILTIN(__builtin_coro_suspend, "cIb", "n")
 BUILTIN(__builtin_coro_param, "bv*v*", "n")
+
 // OpenCL v2.0 s6.13.16, s9.17.3.5 - Pipe functions.
 // We need the generic prototype, since the packet type could be anything.
 LANGBUILTIN(read_pipe, "i.", "tn", OCLC20_LANG)
@@ -1513,6 +1514,8 @@ LANGBUILTIN(get_kernel_max_sub_group_siz
 LANGBUILTIN(get_kernel_sub_group_count_for_ndrange, "Ui.", "tn", OCLC20_LANG)

 // OpenCL v2.0 s6.13.9 - Address space qualifier functions.
+// FIXME: Pointer parameters of OpenCL builtins should have their address space
+// requirement defined.
 LANGBUILTIN(to_global, "v*v*", "tn", OCLC20_LANG)
 LANGBUILTIN(to_local, "v*v*", "tn", OCLC20_LANG)
 LANGBUILTIN(to_private, "v*v*", "tn", OCLC20_LANG)

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=365499&r1=365498&r2=365499&view=diff
==
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Tue Jul  9 08:04:23 2019
@@ -5360,7 +5360,7 @@ static bool checkArgsForPlaceholders(Sem
 ///  FunctionDecl is returned.
 /// TODO: Handle pointer return types.
 static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext 
&Context,
-const FunctionDecl *FDecl,
+FunctionDecl *FDecl,
   

r365608 - [NFC][AArch64] Fix vector vsqadd intrinsics operands

2019-07-10 Thread Diogo N. Sampaio via cfe-commits
Author: dnsampaio
Date: Wed Jul 10 02:58:03 2019
New Revision: 365608

URL: http://llvm.org/viewvc/llvm-project?rev=365608&view=rev
Log:
[NFC][AArch64] Fix vector vsqadd intrinsics operands

Summary:
Change the vsqadd vector instrinsics to have the second argument as signed 
values, not unsigned,
accordingly to 
https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics

Reviewers: LukeCheeseman, ostannard

Reviewed By: ostannard

Subscribers: javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=365608&r1=365607&r2=365608&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Jul 10 02:58:03 2019
@@ -707,7 +707,7 @@ def SUQADD : SInst<"vuqadd", "ddd", "csi
 
 

 // Unsigned Saturating Accumulated of Signed Value
-def USQADD : SInst<"vsqadd", "ddd", "UcUsUiUlQUcQUsQUiQUl">;
+def USQADD : SInst<"vsqadd", "ddx", "UcUsUiUlQUcQUsQUiQUl">;
 
 

 // Reciprocal/Sqrt


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


r365609 - [AArch64] Fix vector vuqadd intrinsics operands

2019-07-10 Thread Diogo N. Sampaio via cfe-commits
Author: dnsampaio
Date: Wed Jul 10 02:58:51 2019
New Revision: 365609

URL: http://llvm.org/viewvc/llvm-project?rev=365609&view=rev
Log:
[AArch64] Fix vector vuqadd intrinsics operands

Summary:
Change the vuqadd vector instrinsics to have the second argument as unsigned 
values, not signed,
accordingly to 
https://developer.arm.com/architectures/instruction-sets/simd-isas/neon/intrinsics

Reviewers: LukeCheeseman, ostannard

Reviewed By: ostannard

Subscribers: javed.absar, kristof.beyls, cfe-commits

Tags: #clang

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

Modified:
cfe/trunk/include/clang/Basic/arm_neon.td
cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c

Modified: cfe/trunk/include/clang/Basic/arm_neon.td
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/arm_neon.td?rev=365609&r1=365608&r2=365609&view=diff
==
--- cfe/trunk/include/clang/Basic/arm_neon.td (original)
+++ cfe/trunk/include/clang/Basic/arm_neon.td Wed Jul 10 02:58:51 2019
@@ -703,7 +703,7 @@ def QNEG   : SInst<"vqneg", "dd", "lQl">
 
 

 // Signed Saturating Accumulated of Unsigned Value
-def SUQADD : SInst<"vuqadd", "ddd", "csilQcQsQiQl">;
+def SUQADD : SInst<"vuqadd", "ddu", "csilQcQsQiQl">;
 
 

 // Unsigned Saturating Accumulated of Signed Value

Modified: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c?rev=365609&r1=365608&r2=365609&view=diff
==
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c (original)
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c Wed Jul 10 02:58:51 2019
@@ -17528,6 +17528,50 @@ float64_t test_vabdd_f64(float64_t a, fl
   return vabdd_f64(a, b);
 }
 
+// CHECK-LABEL: @test_vuqaddq_s8(
+// CHECK: entry:
+// CHECK-NEXT:  [[V:%.*]] = call <16 x i8> @llvm.aarch64.neon.suqadd.v16i8(<16 
x i8> %a, <16 x i8> %b)
+// CHECK-NEXT:  ret <16 x i8> [[V]]
+int8x16_t test_vuqaddq_s8(int8x16_t a, uint8x16_t b) {
+  return vuqaddq_s8(a, b);
+}
+
+// CHECK-LABEL: @test_vuqaddq_s32(
+// CHECK: [[V:%.*]] = call <4 x i32> @llvm.aarch64.neon.suqadd.v4i32(<4 x i32> 
%a, <4 x i32> %b)
+// CHECK-NEXT:  ret <4 x i32> [[V]]
+int32x4_t test_vuqaddq_s32(int32x4_t a, uint32x4_t b) {
+  return vuqaddq_s32(a, b);
+}
+
+// CHECK-LABEL: @test_vuqaddq_s64(
+// CHECK: [[V:%.*]] = call <2 x i64> @llvm.aarch64.neon.suqadd.v2i64(<2 x i64> 
%a, <2 x i64> %b)
+// CHECK-NEXT:  ret <2 x i64> [[V]]
+int64x2_t test_vuqaddq_s64(int64x2_t a, uint64x2_t b) {
+  return vuqaddq_s64(a, b);
+}
+
+// CHECK-LABEL: @test_vuqaddq_s16(
+// CHECK: [[V:%.*]] = call <8 x i16> @llvm.aarch64.neon.suqadd.v8i16(<8 x i16> 
%a, <8 x i16> %b)
+// CHECK-NEXT:  ret <8 x i16> [[V]]
+int16x8_t test_vuqaddq_s16(int16x8_t a, uint16x8_t b) {
+  return vuqaddq_s16(a, b);
+}
+
+// CHECK-LABEL: @test_vuqadd_s8(
+// CHECK: entry:
+// CHECK-NEXT: [[V:%.*]] = call <8 x i8> @llvm.aarch64.neon.suqadd.v8i8(<8 x 
i8> %a, <8 x i8> %b)
+// CHECK-NEXT: ret <8 x i8> [[V]]
+int8x8_t test_vuqadd_s8(int8x8_t a, uint8x8_t b) {
+  return vuqadd_s8(a, b);
+}
+
+// CHECK-LABEL: @test_vuqadd_s32(
+// CHECK: [[V:%.*]] = call <2 x i32> @llvm.aarch64.neon.suqadd.v2i32(<2 x i32> 
%a, <2 x i32> %b)
+// CHECK-NEXT:  ret <2 x i32> [[V]]
+int32x2_t test_vuqadd_s32(int32x2_t a, uint32x2_t b) {
+  return vuqadd_s32(a, b);
+}
+
 // CHECK-LABEL: @test_vuqadd_s64(
 // CHECK:   [[TMP0:%.*]] = bitcast <1 x i64> %a to <8 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <1 x i64> %b to <8 x i8>
@@ -17537,6 +17581,13 @@ int64x1_t test_vuqadd_s64(int64x1_t a, u
   return vuqadd_s64(a, b);
 }
 
+// CHECK-LABEL: @test_vuqadd_s16(
+// CHECK: [[V:%.*]] = call <4 x i16> @llvm.aarch64.neon.suqadd.v4i16(<4 x i16> 
%a, <4 x i16> %b)
+// CHECK-NEXT:  ret <4 x i16> [[V]]
+int16x4_t test_vuqadd_s16(int16x4_t a, uint16x4_t b) {
+  return vuqadd_s16(a, b);
+}
+
 // CHECK-LABEL: @test_vsqadd_u64(
 // CHECK:   [[TMP0:%.*]] = bitcast <1 x i64> %a to <8 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <1 x i64> %b to <8 x i8>


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


[PATCH] D64211: [AArch64] Fix vector vuqadd intrinsics operands

2019-07-10 Thread Diogo N. Sampaio via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365609: [AArch64] Fix vector vuqadd intrinsics operands 
(authored by dnsampaio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64211

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td
  cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -703,7 +703,7 @@
 
 

 // Signed Saturating Accumulated of Unsigned Value
-def SUQADD : SInst<"vuqadd", "ddd", "csilQcQsQiQl">;
+def SUQADD : SInst<"vuqadd", "ddu", "csilQcQsQiQl">;
 
 

 // Unsigned Saturating Accumulated of Signed Value
Index: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
@@ -17528,6 +17528,50 @@
   return vabdd_f64(a, b);
 }
 
+// CHECK-LABEL: @test_vuqaddq_s8(
+// CHECK: entry:
+// CHECK-NEXT:  [[V:%.*]] = call <16 x i8> @llvm.aarch64.neon.suqadd.v16i8(<16 
x i8> %a, <16 x i8> %b)
+// CHECK-NEXT:  ret <16 x i8> [[V]]
+int8x16_t test_vuqaddq_s8(int8x16_t a, uint8x16_t b) {
+  return vuqaddq_s8(a, b);
+}
+
+// CHECK-LABEL: @test_vuqaddq_s32(
+// CHECK: [[V:%.*]] = call <4 x i32> @llvm.aarch64.neon.suqadd.v4i32(<4 x i32> 
%a, <4 x i32> %b)
+// CHECK-NEXT:  ret <4 x i32> [[V]]
+int32x4_t test_vuqaddq_s32(int32x4_t a, uint32x4_t b) {
+  return vuqaddq_s32(a, b);
+}
+
+// CHECK-LABEL: @test_vuqaddq_s64(
+// CHECK: [[V:%.*]] = call <2 x i64> @llvm.aarch64.neon.suqadd.v2i64(<2 x i64> 
%a, <2 x i64> %b)
+// CHECK-NEXT:  ret <2 x i64> [[V]]
+int64x2_t test_vuqaddq_s64(int64x2_t a, uint64x2_t b) {
+  return vuqaddq_s64(a, b);
+}
+
+// CHECK-LABEL: @test_vuqaddq_s16(
+// CHECK: [[V:%.*]] = call <8 x i16> @llvm.aarch64.neon.suqadd.v8i16(<8 x i16> 
%a, <8 x i16> %b)
+// CHECK-NEXT:  ret <8 x i16> [[V]]
+int16x8_t test_vuqaddq_s16(int16x8_t a, uint16x8_t b) {
+  return vuqaddq_s16(a, b);
+}
+
+// CHECK-LABEL: @test_vuqadd_s8(
+// CHECK: entry:
+// CHECK-NEXT: [[V:%.*]] = call <8 x i8> @llvm.aarch64.neon.suqadd.v8i8(<8 x 
i8> %a, <8 x i8> %b)
+// CHECK-NEXT: ret <8 x i8> [[V]]
+int8x8_t test_vuqadd_s8(int8x8_t a, uint8x8_t b) {
+  return vuqadd_s8(a, b);
+}
+
+// CHECK-LABEL: @test_vuqadd_s32(
+// CHECK: [[V:%.*]] = call <2 x i32> @llvm.aarch64.neon.suqadd.v2i32(<2 x i32> 
%a, <2 x i32> %b)
+// CHECK-NEXT:  ret <2 x i32> [[V]]
+int32x2_t test_vuqadd_s32(int32x2_t a, uint32x2_t b) {
+  return vuqadd_s32(a, b);
+}
+
 // CHECK-LABEL: @test_vuqadd_s64(
 // CHECK:   [[TMP0:%.*]] = bitcast <1 x i64> %a to <8 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <1 x i64> %b to <8 x i8>
@@ -17537,6 +17581,13 @@
   return vuqadd_s64(a, b);
 }
 
+// CHECK-LABEL: @test_vuqadd_s16(
+// CHECK: [[V:%.*]] = call <4 x i16> @llvm.aarch64.neon.suqadd.v4i16(<4 x i16> 
%a, <4 x i16> %b)
+// CHECK-NEXT:  ret <4 x i16> [[V]]
+int16x4_t test_vuqadd_s16(int16x4_t a, uint16x4_t b) {
+  return vuqadd_s16(a, b);
+}
+
 // CHECK-LABEL: @test_vsqadd_u64(
 // CHECK:   [[TMP0:%.*]] = bitcast <1 x i64> %a to <8 x i8>
 // CHECK:   [[TMP1:%.*]] = bitcast <1 x i64> %b to <8 x i8>


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -703,7 +703,7 @@
 
 
 // Signed Saturating Accumulated of Unsigned Value
-def SUQADD : SInst<"vuqadd", "ddd", "csilQcQsQiQl">;
+def SUQADD : SInst<"vuqadd", "ddu", "csilQcQsQiQl">;
 
 
 // Unsigned Saturating Accumulated of Signed Value
Index: cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
===
--- cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
+++ cfe/trunk/test/CodeGen/aarch64-neon-intrinsics.c
@@ -17528,6 +17528,50 @@
   return vabdd_f64(a, b);
 }
 
+// CHECK-LABEL: @test_vuqaddq_s8(
+// CHECK: entry:
+// CHECK-NEXT:  [[V:%.*]] = call <16 x i8> @llvm.aarch64.neon.suqadd.v16i8(<16 x i8> %a, <16 x i8> %b)
+// CHECK-NEXT:  ret <16 x i8> [[V]]
+int8x16_t test_vuqaddq_s8(int8x16_t a, uint8x16_t b) {
+  return vuqaddq_s8(a, b);
+}
+
+// CHECK-LABEL: @test_vuqaddq_s32(
+// CHECK: [[V:%.*]] = call <4 x i32> @llvm.aarch64.neon.suqadd.v4i32(<4 x i32> %a, <4 x i32> %b)
+// CHECK-NEXT:  ret <4 x i32> [[V]]
+int32x4_t test_vuqaddq_s

[PATCH] D64210: [NFC][AArch64] Fix vector vsqadd intrinsics operands

2019-07-10 Thread Diogo N. Sampaio via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365608: [NFC][AArch64] Fix vector vsqadd intrinsics operands 
(authored by dnsampaio, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64210

Files:
  cfe/trunk/include/clang/Basic/arm_neon.td


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -707,7 +707,7 @@
 
 

 // Unsigned Saturating Accumulated of Signed Value
-def USQADD : SInst<"vsqadd", "ddd", "UcUsUiUlQUcQUsQUiQUl">;
+def USQADD : SInst<"vsqadd", "ddx", "UcUsUiUlQUcQUsQUiQUl">;
 
 

 // Reciprocal/Sqrt


Index: cfe/trunk/include/clang/Basic/arm_neon.td
===
--- cfe/trunk/include/clang/Basic/arm_neon.td
+++ cfe/trunk/include/clang/Basic/arm_neon.td
@@ -707,7 +707,7 @@
 
 
 // Unsigned Saturating Accumulated of Signed Value
-def USQADD : SInst<"vsqadd", "ddd", "UcUsUiUlQUcQUsQUiQUl">;
+def USQADD : SInst<"vsqadd", "ddx", "UcUsUiUlQUcQUsQUiQUl">;
 
 
 // Reciprocal/Sqrt
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64475: [clangd] Duplicate lines of semantic highlightings sent removed.

2019-07-10 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom created this revision.
jvikstrom added reviewers: hokein, sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, mgrang, jkorous, 
MaskRay.
Herald added a project: clang.

Added a class for diffing highlightings and removing duplicate lines. 
Integrated into the highlighting generation flow. Only works correctly if all 
tokens are on a single line. Also returns empty lines if the IDE should remove 
previous highlightings on a line.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64475

Files:
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -29,14 +29,17 @@
   return Tokens;
 }
 
-void checkHighlightings(llvm::StringRef Code) {
+std::tuple,
+   std::vector>
+getHighlightingsAnnotated(llvm::StringRef Code) {
   Annotations Test(Code);
   auto AST = TestTU::withCode(Test.code()).build();
   static const std::map KindToString{
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
   {HighlightingKind::Class, "Class"},
-  {HighlightingKind::Enum, "Enum"}};
+  {HighlightingKind::Enum, "Enum"},
+  {HighlightingKind::Empty, "Empty"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
 std::vector Toks = makeHighlightingTokens(
@@ -45,6 +48,14 @@
   }
 
   auto ActualTokens = getSemanticHighlightings(AST);
+  return {std::move(AST), ActualTokens, ExpectedTokens};
+}
+
+void checkHighlightings(llvm::StringRef Code) {
+  std::vector ActualTokens;
+  std::vector ExpectedTokens;
+  std::tie(std::ignore, ActualTokens, ExpectedTokens) =
+  getHighlightingsAnnotated(Code);
   EXPECT_THAT(ActualTokens, testing::UnorderedElementsAreArray(ExpectedTokens));
 }
 
@@ -161,6 +172,68 @@
   EXPECT_EQ(ActualResults, ExpectedResults);
 }
 
+TEST(SemanticHighlighting, HighlightingDiffer) {
+  std::vector> TestCases{{
+   R"cpp(
+struct $Class[[Alpha]] {
+  double SomeVariable = 9483.301;
+};
+struct $Class[[Beta]] {};
+int $Variable[[A]] = 121;
+$Class[[Alpha]] $Variable[[Var]];
+  )cpp",
+   R"cpp(
+struct Alpha {
+  double SomeVariable = 9483.301;
+};
+struct Beta   {}; // Some changes that don't change the tokens' position.
+intA$Empty[[]] = 121;
+$Class[[Beta]] $Variable[[Var]];
+  )cpp"},
+   {
+   R"cpp(
+  int $Variable[[A]] = 121; int $Variable[[B]];
+)cpp",
+   R"cpp(
+  intA = 121; int $Variable[[B]];
+)cpp"},
+   {
+   R"cpp(
+  int $Variable[[A]] = 213;
+)cpp",
+   R"cpp(
+  int C = 312;
+  int $Variable[[B]] = 213;
+)cpp",
+   R"cpp(
+  int C = 213;
+  int B = 412;
+)cpp"},
+   {
+   R"cpp(
+  int $Variable[[A]];
+)cpp",
+   R"cpp(
+  int $Variable[[A]]; int $Variable[[B]];
+)cpp"}};
+
+  for (auto Test : TestCases) {
+HighlightingDiffer Differ;
+for (const auto &Code : Test) {
+  ParsedAST AST =
+  TestTU::withCode("").build(); // Can't default construct a ParsedAST.
+  std::vector CompleteTokens;
+  std::vector ExpectedTokens;
+  std::tie(AST, CompleteTokens, ExpectedTokens) =
+  getHighlightingsAnnotated(Code);
+  std::vector DiffedTokens =
+  Differ.diffHighlightings(AST, CompleteTokens);
+  EXPECT_THAT(DiffedTokens,
+  testing::UnorderedElementsAreArray(ExpectedTokens));
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -34,6 +34,21 @@
 # CHECK-NEXT:  }
 # CHECK-NEXT:}
 ---
+{"jsonrpc":"2.0","method":"textDocument/didOpen","params":{"textDocument":{"uri":"test:///foo.cpp","languageId":"cpp","versio

[PATCH] D64471: Loop pragma parsing. NFC.

2019-07-10 Thread Sam Parker via Phabricator via cfe-commits
samparker accepted this revision.
samparker added a comment.
This revision is now accepted and ready to land.

LGTM


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

https://reviews.llvm.org/D64471



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


[PATCH] D62855: [clangd] Implementation of auto type expansion.

2019-07-10 Thread Christian Kühnel via Phabricator via cfe-commits
kuhnel updated this revision to Diff 208923.
kuhnel marked 13 inline comments as done.
kuhnel added a comment.

fixed parts of the 3rd round of review comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62855

Files:
  clang-tools-extra/clangd/AST.cpp
  clang-tools-extra/clangd/AST.h
  clang-tools-extra/clangd/Selection.cpp
  clang-tools-extra/clangd/Selection.h
  clang-tools-extra/clangd/XRefs.cpp
  clang-tools-extra/clangd/XRefs.h
  clang-tools-extra/clangd/refactor/tweaks/CMakeLists.txt
  clang-tools-extra/clangd/refactor/tweaks/ExpandAutoType.cpp
  clang-tools-extra/clangd/test/code-action-request.test
  clang-tools-extra/clangd/unittests/ASTTests.cpp
  clang-tools-extra/clangd/unittests/CMakeLists.txt
  clang-tools-extra/clangd/unittests/TweakTests.cpp
  clang-tools-extra/clangd/unittests/XRefsTests.cpp

Index: clang-tools-extra/clangd/unittests/XRefsTests.cpp
===
--- clang-tools-extra/clangd/unittests/XRefsTests.cpp
+++ clang-tools-extra/clangd/unittests/XRefsTests.cpp
@@ -2108,6 +2108,28 @@
   }
 }
 
+TEST(GetDeducedType, KwAutoExpansion) {
+  struct Test {
+StringRef AnnotatedCode;
+const char *DeducedType;
+  } Tests[] = {
+  {"^auto i = 0;", "int"},
+  {"^auto f(){ return 1;};", "int"}
+  };
+  for (Test T : Tests) {
+Annotations File(T.AnnotatedCode);
+auto AST = TestTU::withCode(File.code()).build();
+ASSERT_TRUE(AST.getDiagnostics().empty()) << AST.getDiagnostics().begin()->Message;
+SourceManagerForFile SM("foo.cpp", File.code());
+
+for (Position Pos : File.points()) {
+  auto Location = sourceLocationInMainFile(SM.get(), Pos);
+  auto DeducedType = getDeducedType(AST, *Location);
+  EXPECT_EQ(DeducedType->getAsString(), T.DeducedType);
+}
+  }
+}
+
 } // namespace
 } // namespace clangd
 } // namespace clang
Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -11,6 +11,7 @@
 #include "TestTU.h"
 #include "refactor/Tweak.h"
 #include "clang/AST/Expr.h"
+#include "clang/Basic/LLVM.h"
 #include "clang/Rewrite/Core/Rewriter.h"
 #include "clang/Tooling/Core/Replacement.h"
 #include "llvm/ADT/StringRef.h"
@@ -126,6 +127,19 @@
   EXPECT_EQ(Output, std::string(*Result)) << Input;
 }
 
+/// Check if apply returns an error and that the @ErrorMessage is contained
+/// in that error
+void checkApplyContainsError(llvm::StringRef ID, llvm::StringRef Input,
+ const std::string& ErrorMessage) {
+  auto Result = apply(ID, Input);
+  EXPECT_FALSE(Result) << "expected error message:\n   " << ErrorMessage <<
+   "\non input:" << Input;
+  EXPECT_NE(std::string::npos,
+llvm::toString(Result.takeError()).find(ErrorMessage))
+<< "Wrong error message:\n  " << llvm::toString(Result.takeError())
+<< "\nexpected:\n  " << ErrorMessage;
+}
+
 TEST(TweakTest, SwapIfBranches) {
   llvm::StringLiteral ID = "SwapIfBranches";
 
@@ -509,6 +523,132 @@
   )cpp");
 }
 
+TEST(TweakTest, ExpandAutoType) {
+  llvm::StringLiteral ID = "ExpandAutoType";
+
+  checkAvailable(ID, R"cpp(
+^a^u^t^o^ i = 0;
+  )cpp");
+
+  checkNotAvailable(ID, R"cpp(
+auto ^i^ ^=^ ^0^;^
+  )cpp");
+
+  llvm::StringLiteral Input = R"cpp(
+[[auto]] i = 0;
+  )cpp";
+  llvm::StringLiteral Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check primitive type
+  Input = R"cpp(
+au^to i = 0;
+  )cpp";
+  Output = R"cpp(
+int i = 0;
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check classes and namespaces
+  Input = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+^auto C = testns::TestClass::SubClass();
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+  class TestClass {
+class SubClass {};
+  };
+}
+testns::TestClass::SubClass C = testns::TestClass::SubClass();
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // check that namespaces are shortened
+  Input = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { ^auto C = TestClass(); }
+}
+  )cpp";
+  Output = R"cpp(
+namespace testns {
+class TestClass {
+};
+void func() { TestClass C = TestClass(); }
+}
+  )cpp";
+  checkTransform(ID, Input, Output);
+
+  // unknown types in a template should not be replaced
+  Input = R"cpp(
+template  void x() {
+^auto y =  T::z();
+}
+  )cpp";
+  checkApplyContainsError(ID, Input, "Could not deduce type for 'auto' type");
+
+  // undefined functions should not be replaced
+  Input = R"cpp(
+a^uto x = doesnt_exist();
+  )cpp";
+  checkApplyContainsError(ID, Input, "Could not d

[PATCH] D64083: [OpenCL][Sema] Improve address space support for blocks

2019-07-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added inline comments.



Comment at: cfe/trunk/lib/Sema/SemaExprCXX.cpp:4229
+LangAS AddrSpaceR =
+RHSType->getAs()->getPointeeType().getAddressSpace();
+CastKind Kind =

rjmccall wrote:
> All of this can be much simpler:
> 
> ```
> LangAS AddrSpaceL = 
> ToType->castAs()->getPointeeType().getAddressSpace();
> LangAS AddrSpaceR = 
> FromType->castAs()->getPointeeType().getAddressSpace();
> ```
> 
> Is there something actually checking the validity of this address-space cast 
> somewhere?
> Is there something actually checking the validity of this address-space cast 
> somewhere?

The address spaces for blocks are currently added by clang implicitly. It 
doesn't seem possible to write kernel code qualifying blocks with address 
spaces. Although I have to say the error is not given properly because the 
parser gets confused at least for the examples I have tried. The OpenCL spec 
doesn't detail much regarding this use case. Potentially this is the area for 
improvement.

So for now we can add an assert to check the cast validity if you think it 
makes sense and maybe a FIXME in the  code to explain that address spaces 
aren't working with blocks


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64083



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


[PATCH] D64477: [ASTImporter] Using Lang_CXX11 in ASTImporterVisibilityTest.

2019-07-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a project: clang.

These tests may work with language constructs in C++11 in the future.
To avoid warnings about language version C++ version constants in the tests
are updated.


Repository:
  rC Clang

https://reviews.llvm.org/D64477

Files:
  unittests/AST/ASTImporterVisibilityTest.cpp


Index: unittests/AST/ASTImporterVisibilityTest.cpp
===
--- unittests/AST/ASTImporterVisibilityTest.cpp
+++ unittests/AST/ASTImporterVisibilityTest.cpp
@@ -80,13 +80,13 @@
 std::string Code = getCode() + getCode();
 auto Pattern = getPattern();
 
-TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX, "input0.cc");
+TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX11, "input0.cc");
 
 auto *FromD0 = FirstDeclMatcher().match(FromTu, Pattern);
 auto *FromD1 = LastDeclMatcher().match(FromTu, Pattern);
 
-auto *ToD0 = Import(FromD0, Lang_CXX);
-auto *ToD1 = Import(FromD1, Lang_CXX);
+auto *ToD0 = Import(FromD0, Lang_CXX11);
+auto *ToD1 = Import(FromD1, Lang_CXX11);
 
 EXPECT_TRUE(ToD0);
 ASSERT_TRUE(ToD1);
@@ -157,13 +157,14 @@
   BindableMatcher getPattern() const { return PatternFactory()(); }
 
   void TypedTest_ImportAfter() {
-TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX);
-TranslationUnitDecl *FromTu = getTuDecl(getCode1(), Lang_CXX, "input1.cc");
+TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX11);
+TranslationUnitDecl *FromTu =
+getTuDecl(getCode1(), Lang_CXX11, "input1.cc");
 
 auto *ToD0 = FirstDeclMatcher().match(ToTu, getPattern());
 auto *FromD1 = FirstDeclMatcher().match(FromTu, getPattern());
 
-auto *ToD1 = Import(FromD1, Lang_CXX);
+auto *ToD1 = Import(FromD1, Lang_CXX11);
 
 ASSERT_TRUE(ToD0);
 ASSERT_TRUE(ToD1);
@@ -176,12 +177,14 @@
   }
 
   void TypedTest_ImportAfterImport() {
-TranslationUnitDecl *FromTu0 = getTuDecl(getCode0(), Lang_CXX, 
"input0.cc");
-TranslationUnitDecl *FromTu1 = getTuDecl(getCode1(), Lang_CXX, 
"input1.cc");
+TranslationUnitDecl *FromTu0 =
+getTuDecl(getCode0(), Lang_CXX11, "input0.cc");
+TranslationUnitDecl *FromTu1 =
+getTuDecl(getCode1(), Lang_CXX11, "input1.cc");
 auto *FromD0 = FirstDeclMatcher().match(FromTu0, getPattern());
 auto *FromD1 = FirstDeclMatcher().match(FromTu1, getPattern());
-auto *ToD0 = Import(FromD0, Lang_CXX);
-auto *ToD1 = Import(FromD1, Lang_CXX);
+auto *ToD0 = Import(FromD0, Lang_CXX11);
+auto *ToD1 = Import(FromD1, Lang_CXX11);
 ASSERT_TRUE(ToD0);
 ASSERT_TRUE(ToD1);
 EXPECT_NE(ToD0, ToD1);
@@ -192,13 +195,14 @@
   }
 
   void TypedTest_ImportAfterWithMerge() {
-TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX);
-TranslationUnitDecl *FromTu = getTuDecl(getCode1(), Lang_CXX, "input1.cc");
+TranslationUnitDecl *ToTu = getToTuDecl(getCode0(), Lang_CXX11);
+TranslationUnitDecl *FromTu =
+getTuDecl(getCode1(), Lang_CXX11, "input1.cc");
 
 auto *ToF0 = FirstDeclMatcher().match(ToTu, getPattern());
 auto *FromF1 = FirstDeclMatcher().match(FromTu, getPattern());
 
-auto *ToF1 = Import(FromF1, Lang_CXX);
+auto *ToF1 = Import(FromF1, Lang_CXX11);
 
 ASSERT_TRUE(ToF0);
 ASSERT_TRUE(ToF1);
@@ -213,12 +217,14 @@
   }
 
   void TypedTest_ImportAfterImportWithMerge() {
-TranslationUnitDecl *FromTu0 = getTuDecl(getCode0(), Lang_CXX, 
"input0.cc");
-TranslationUnitDecl *FromTu1 = getTuDecl(getCode1(), Lang_CXX, 
"input1.cc");
+TranslationUnitDecl *FromTu0 =
+getTuDecl(getCode0(), Lang_CXX11, "input0.cc");
+TranslationUnitDecl *FromTu1 =
+getTuDecl(getCode1(), Lang_CXX11, "input1.cc");
 auto *FromF0 = FirstDeclMatcher().match(FromTu0, getPattern());
 auto *FromF1 = FirstDeclMatcher().match(FromTu1, getPattern());
-auto *ToF0 = Import(FromF0, Lang_CXX);
-auto *ToF1 = Import(FromF1, Lang_CXX);
+auto *ToF0 = Import(FromF0, Lang_CXX11);
+auto *ToF1 = Import(FromF1, Lang_CXX11);
 ASSERT_TRUE(ToF0);
 ASSERT_TRUE(ToF1);
 if (shouldBeLinked())


Index: unittests/AST/ASTImporterVisibilityTest.cpp
===
--- unittests/AST/ASTImporterVisibilityTest.cpp
+++ unittests/AST/ASTImporterVisibilityTest.cpp
@@ -80,13 +80,13 @@
 std::string Code = getCode() + getCode();
 auto Pattern = getPattern();
 
-TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX, "input0.cc");
+TranslationUnitDecl *FromTu = getTuDecl(Code, Lang_CXX11, "input0.cc");
 
 auto *FromD0 = FirstDeclMatcher().match(FromTu, Pattern);
 auto *FromD1 = LastDeclMatcher().match(FromTu, Pattern);
 
-auto *ToD0 = Import(FromD0, Lang_CXX);
-auto *ToD1 = Import(FromD1, Lang_

[PATCH] D63954: Add lifetime categories attributes

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:2770
+def Owner : InheritableAttr {
+  let Spellings = [CXX11<"gsl", "Owner">];
+  let Subjects = SubjectList<[CXXRecord]>;

xazax.hun wrote:
> aaron.ballman wrote:
> > Has Microsoft already added support for this? We had an unfortunate problem 
> > with `gsl::suppress` where we introduced the attribute first and MSVC 
> > introduced it under a different, incompatible syntax. I would strongly like 
> > to avoid repeating that.
> I will double check this. Her Sutter's paper have this spelling and I believe 
> that the Microsoft implementation is following the same spelling. The main 
> difference is that the MSVC version does not have a type argument at this 
> point but they do plan to add it as an optional argument. (They want to infer 
> the pointee type when it is not provided.) The clang community do not want 
> the inference, hence we made the type argument required. Always providing the 
> type argument should be compatible with future versions of the MSVC 
> implementation.
I take this to mean that we're not implementing the same attribute as MSVC is, 
and that worries me.

> Always providing the type argument should be compatible with future versions 
> of the MSVC implementation.

The problem is that code written for MSVC (where the type argument is not 
required) will not compile with Clang (where the type argument is required), if 
I understand properly.

Generally speaking, when we implement an attribute from another vendor 
namespace, we expect the attribute to have the same semantics as whoever "owns" 
that vendor namespace. It's a bit trickier here because `gsl` isn't really a 
vendor so much as a collective, so I don't know who is the authority to turn to.

On a completely different note: would this attribute also make sense within C 
with a C2x spelling?



Comment at: clang/lib/Parse/ParseDecl.cpp:335-341
+  if (attributeIsTypeArgAttr(*AttrName)) {
+ParseAttributeWithTypeArg(*AttrName, AttrNameLoc, Attrs, EndLoc, ScopeName,
+  ScopeLoc, Syntax);
+// FIXME: when attributeIsTypeArgAttr() is true, assumes that the attribute
+// takes a single parameter.
+return 1;
+  }

I don't like how this short-circuits the remainder of the logic in this 
function. I'd rather see this one-off logic handled in 
`ParseClangAttributeArgs()` if we have to treat it as a one-off. A better 
approach would be to implement type arguments within 
`ParseAttributeArgsCommon()`.



Comment at: clang/lib/Sema/SemaDecl.cpp:2618-2619
+} else if (isa(NewAttribute) || isa(NewAttribute)) 
{
+  // gsl::Owner and gsl::Pointer are allowed to be added to a class after 
it
+  // is defined.
+  ++I;

I'd like to see some tests for this.

I'm a bit worried about whether this will do good things in practice or not. 
I'm concerned about situations like:
```
struct S;

void func(S *s) {
  // Interesting things happen here.
}

struct [[gsl::Pointer]] S {};
```
and whether the "interesting things" will be properly [un]diagnosed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63954



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


[PATCH] D64480: [ASTImporter] Added visibility context check for TypedefNameDecl.

2019-07-10 Thread Balázs Kéri via Phabricator via cfe-commits
balazske created this revision.
Herald added subscribers: cfe-commits, gamesh411, Szelethus, dkrupp.
Herald added a reviewer: martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a project: clang.
balazske added a parent revision: D64477: [ASTImporter] Using Lang_CXX11 in 
ASTImporterVisibilityTest..
Herald added a subscriber: rnkovacs.

ASTImporter makes now difference between typedefs and type aliases
with same name in different translation units
if these are not visible outside.


Repository:
  rC Clang

https://reviews.llvm.org/D64480

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

Index: unittests/AST/ASTImporterVisibilityTest.cpp
===
--- unittests/AST/ASTImporterVisibilityTest.cpp
+++ unittests/AST/ASTImporterVisibilityTest.cpp
@@ -39,6 +39,14 @@
   using DeclTy = EnumDecl;
   BindableMatcher operator()() { return enumDecl(hasName("E")); }
 };
+struct GetTypedefPattern {
+  using DeclTy = TypedefDecl;
+  BindableMatcher operator()() { return typedefDecl(hasName("T")); }
+};
+struct GetTypeAliasPattern {
+  using DeclTy = TypeAliasDecl;
+  BindableMatcher operator()() { return typeAliasDecl(hasName("T")); }
+};
 
 // Values for the value-parameterized test fixtures.
 // FunctionDecl:
@@ -55,6 +63,11 @@
 // EnumDecl:
 const auto *ExternE = "enum E {};";
 const auto *AnonE = "namespace { enum E {}; }";
+// TypedefNameDecl:
+auto *ExternTypedef = "typedef int T;";
+auto *AnonTypedef = "namespace { typedef int T; }";
+auto *ExternUsing = "using T = int;";
+auto *AnonUsing = "namespace { using T = int; }";
 
 // First value in tuple: Compile options.
 // Second value in tuple: Source code to be used in the test.
@@ -237,6 +250,8 @@
 using ImportVariablesVisibility = ImportVisibility;
 using ImportClassesVisibility = ImportVisibility;
 using ImportEnumsVisibility = ImportVisibility;
+using ImportTypedefVisibility = ImportVisibility;
+using ImportTypeAliasVisibility = ImportVisibility;
 
 // FunctionDecl.
 TEST_P(ImportFunctionsVisibility, ImportAfter) {
@@ -266,6 +281,19 @@
 TEST_P(ImportEnumsVisibility, ImportAfterImport) {
   TypedTest_ImportAfterImportWithMerge();
 }
+// TypedefNameDecl.
+TEST_P(ImportTypedefVisibility, ImportAfter) {
+  TypedTest_ImportAfterWithMerge();
+}
+TEST_P(ImportTypedefVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImportWithMerge();
+}
+TEST_P(ImportTypeAliasVisibility, ImportAfter) {
+  TypedTest_ImportAfterWithMerge();
+}
+TEST_P(ImportTypeAliasVisibility, ImportAfterImport) {
+  TypedTest_ImportAfterImportWithMerge();
+}
 
 const bool ExpectLink = true;
 const bool ExpectNotLink = false;
@@ -312,6 +340,24 @@
   std::make_tuple(ExternE, AnonE, ExpectNotLink),
   std::make_tuple(AnonE, ExternE, ExpectNotLink),
   std::make_tuple(AnonE, AnonE, ExpectNotLink))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportTypedefVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternTypedef, ExternTypedef, ExpectLink),
+std::make_tuple(ExternTypedef, AnonTypedef, ExpectNotLink),
+std::make_tuple(AnonTypedef, ExternTypedef, ExpectNotLink),
+std::make_tuple(AnonTypedef, AnonTypedef, ExpectNotLink))), );
+INSTANTIATE_TEST_CASE_P(
+ParameterizedTests, ImportTypeAliasVisibility,
+::testing::Combine(
+DefaultTestValuesForRunOptions,
+::testing::Values(
+std::make_tuple(ExternUsing, ExternUsing, ExpectLink),
+std::make_tuple(ExternUsing, AnonUsing, ExpectNotLink),
+std::make_tuple(AnonUsing, ExternUsing, ExpectNotLink),
+std::make_tuple(AnonUsing, AnonUsing, ExpectNotLink))), );
 
 } // end namespace ast_matchers
 } // end namespace clang
Index: lib/AST/ASTImporter.cpp
===
--- lib/AST/ASTImporter.cpp
+++ lib/AST/ASTImporter.cpp
@@ -927,6 +927,28 @@
   EllipsisLoc);
 }
 
+template 
+bool ASTNodeImporter::hasSameVisibilityContext(T *Found, T *From) {
+  if (From->hasExternalFormalLinkage())
+return Found->hasExternalFormalLinkage();
+  else if (Importer.GetFromTU(Found) == From->getTranslationUnitDecl()) {
+if (From->isInAnonymousNamespace())
+  return Found->isInAnonymousNamespace();
+else
+  return !Found->isInAnonymousNamespace() &&
+ !Found->hasExternalFormalLinkage();
+  }
+  return false;
+}
+
+template <>
+bool ASTNodeImporter::hasSameVisibilityContext(TypedefNameDecl *Found,
+   TypedefNameDecl *From) {
+  if (From->isInAnonymousNamespace() && Found->isInAnonymousNamespace())
+return Importer.GetFromTU(Found) == From->getTranslationUnitDecl();
+  return From->isInAnonymousNamespace() == Found->isInAnonymousNamespace();
+}
+
 } // na

[PATCH] D64481: [clangd] Add a flag to clangdServer rename function to control whether we want format the replacements.

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

This would allow clangd embedders to use the ClangdServer::rename for other
purposes (highlighting all the occurrences of the symbol in prepare
stage).


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64481

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/SyncAPI.cpp


Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -102,7 +102,7 @@
 PathRef File, Position Pos,
 llvm::StringRef NewName) {
   llvm::Optional>> Result;
-  Server.rename(File, Pos, NewName, capture(Result));
+  Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -241,7 +241,7 @@
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
   void rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB);
+  bool WantFormat, Callback> CB);
 
   struct TweakRef {
 std::string ID;/// ID to pass for applyTweak.
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -283,23 +283,25 @@
 }
 
 void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB) {
-  auto Action = [Pos, this](Path File, std::string NewName,
-Callback> CB,
-llvm::Expected InpAST) {
+  bool WantFormat, Callback> CB) 
{
+  auto Action = [Pos, WantFormat, this](Path File, std::string NewName,
+Callback> CB,
+llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName, Index);
 if (!Changes)
   return CB(Changes.takeError());
 
-auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
-   InpAST->Inputs.FS.get());
-if (auto Formatted =
-cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
-  *Changes = std::move(*Formatted);
-else
-  elog("Failed to format replacements: {0}", Formatted.takeError());
+if (WantFormat) {
+  auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+ InpAST->Inputs.FS.get());
+  if (auto Formatted =
+  cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+*Changes = std::move(*Formatted);
+  else
+elog("Failed to format replacements: {0}", Formatted.takeError());
+}
 
 std::vector Edits;
 for (const auto &Rep : *Changes)
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -577,7 +577,7 @@
 "onRename called for non-added file", ErrorCode::InvalidParams));
 
   Server->rename(
-  File, Params.position, Params.newName,
+  File, Params.position, Params.newName, /*WantFormat=*/true,
   Bind(
   [File, Code, Params](decltype(Reply) Reply,
llvm::Expected> Edits) {


Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -102,7 +102,7 @@
 PathRef File, Position Pos,
 llvm::StringRef NewName) {
   llvm::Optional>> Result;
-  Server.rename(File, Pos, NewName, capture(Result));
+  Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -241,7 +241,7 @@
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
   

[PATCH] D61749: [clang-tidy] initial version of readability-const-method

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/readability/ReadabilityTidyModule.cpp:96
+CheckFactories.registerCheck(
+"readability-static-method");
 CheckFactories.registerCheck(

mgehre wrote:
> aaron.ballman wrote:
> > I'm not super keen on the check name. It's not very descriptive -- does 
> > this operate on static methods, does it make methods static, does it turn 
> > global dynamic initialization into static method initialization?
> > 
> > How about: `readability-convert-functions-to-static` or something more 
> > descriptive of the functionality?
> I agree that we should find a better name. With 
> `readability-convert-functions-to-static`, I miss the difference between 
> adding `static` linkage to a free function versus making a member function 
> static.
> How about `readability-convert-member-functions-to-static` or 
> `readability-convert-method-to-static`?
I think `readability-convert-member-functions-to-static` would be a good name.



Comment at: 
clang-tools-extra/clang-tidy/readability/StaticMethodCheck.cpp:136-149
+  if (Definition->isConst()) {
+// Make sure that we either remove 'const' on both declaration and
+// definition or emit no fix-it at all.
+SourceRange DefConst = getLocationOfConst(Definition->getTypeSourceInfo(),
+   *Result.SourceManager,
+   Result.Context->getLangOpts());
+

mgehre wrote:
> aaron.ballman wrote:
> > `const` isn't the only thing to worry about though, no? You need to handle 
> > things like:
> > ```
> > struct S {
> >   void f() volatile;
> >   void g() &;
> >   void h() &&;
> > };
> > ```
> > Another one I am curious about are computed noexcept specifications and 
> > whether those are handled properly. e.g.,
> > ```
> > struct S {
> >   int i;
> >   void foo(SomeClass C) noexcept(noexcept(C + i));
> > };
> > ```
> I added tests for those cases and disabled fix-it generation for them to keep 
> the code simple (for now).
There's an obscure edge case missing:
```
struct S {
  void f() __restrict;
};
```



Comment at: clang-tools-extra/clang-tidy/readability/StaticMethodCheck.cpp:35-45
+AST_MATCHER(CXXMethodDecl, isConstructor) {
+  return isa(Node);
+}
+
+AST_MATCHER(CXXMethodDecl, isDestructor) {
+  return isa(Node);
+}

Is there a reason we can't use `cxxConstructorDecl()`, `cxxDestructorDecl()`, 
and `cxxConversionDecl()` instead?



Comment at: clang-tools-extra/clang-tidy/readability/StaticMethodCheck.cpp:130
+  StringRef Text = getStringFromRange(SourceMgr, LangOpts, Range);
+  size_t Offset = Text.find("const");
+  if (Offset == StringRef::npos)

What does this do for code like:
```
#define constantly_annoying volatile

struct S {
  void func() constantly_annoying {}
};
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D61749



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


[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-07-10 Thread Oliver Stannard (Linaro) via Phabricator via cfe-commits
ostannard added a comment.

Ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63932



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


[PATCH] D64481: [clangd] Add a flag to clangdServer rename function to control whether we want format the replacements.

2019-07-10 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 with a small NIT.

Was also thinking about adding a test for this, but the amount of work required 
to do so seems to outweigh the usefulness. Therefore seems ok to land without 
the test too.
But up to you.




Comment at: clang-tools-extra/clangd/ClangdServer.h:244
   void rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB);
+  bool WantFormat, Callback> CB);
 

Could you add a short comment mentioning the highlight use-case? (the review 
description seems to be a good fit)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64481



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


[PATCH] D63835: [Syntax] Add nodes for most common statements

2019-07-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 208937.
ilya-biryukov marked 5 inline comments as done.
ilya-biryukov added a comment.

- Rebase
- Address comments
- Restructure the roles
- Remove the role from tree dumps for now With too many roles it is annoying to 
update the test outputs on incremental changes. I tried using the symbolic role 
names there, but they end up being too verbose.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63835

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -136,19 +136,326 @@
 | |-(
 | |-)
 | `-CompoundStatement
-|   |-2: {
-|   `-3: }
+|   |-{
+|   `-}
 |-TopLevelDeclaration
 | |-void
 | |-foo
 | |-(
 | |-)
 | `-CompoundStatement
-|   |-2: {
-|   `-3: }
+|   |-{
+|   `-}
 `-
 )txt"},
-  };
+  // if.
+  {
+  R"cpp(
+int main() {
+  if (true) {}
+  if (true) {} else if (false) {}
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-int
+| |-main
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-IfStatement
+|   | |-if
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   `-}
+|   |-IfStatement
+|   | |-if
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | |-CompoundStatement
+|   | | |-{
+|   | | `-}
+|   | |-else
+|   | `-IfStatement
+|   |   |-if
+|   |   |-(
+|   |   |-UnknownExpression
+|   |   | `-false
+|   |   |-)
+|   |   `-CompoundStatement
+|   | |-{
+|   | `-}
+|   `-}
+`-
+)txt"},
+  // for.
+  {R"cpp(
+void test() {
+  for (;;)  {}
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-ForStatement
+|   | |-for
+|   | |-(
+|   | |-;
+|   | |-;
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // declaration statement.
+  {"void test() { int a = 10; }",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-DeclarationStatement
+|   | |-int
+|   | |-a
+|   | |-=
+|   | |-10
+|   | `-;
+|   `-}
+`-
+)txt"},
+  {"void test() { ; }", R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-EmptyStatement
+|   | `-;
+|   `-}
+`-
+)txt"},
+  // switch, case and default.
+  {R"cpp(
+void test() {
+  switch (true) {
+case 0:
+default:;
+  }
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-SwitchStatement
+|   | |-switch
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   |-CaseStatement
+|   |   | |-case
+|   |   | |-UnknownExpression
+|   |   | | `-0
+|   |   | |-:
+|   |   | `-DefaultStatement
+|   |   |   |-default
+|   |   |   |-:
+|   |   |   `-EmptyStatement
+|   |   | `-;
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // while.
+  {R"cpp(
+void test() {
+  while (true) { continue; break; }
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-WhileStatement
+|   | |-while
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   |-ContinueStatement
+|   |   | |-continue
+|   |   | `-;
+|   |   |-BreakStatement
+|   |   | |-break
+|   |   | `-;
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // return.
+  {R"cpp(
+int test() { return 1; }
+  )cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-int
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-ReturnStatement
+|   | |-return
+|   | |-UnknownExpression
+|   | | `-1
+|   | `-;
+|   `-}
+`-
+   )txt"},
+  // Range-based for.
+  {R"cpp(
+void test() {
+  int a[3];
+  for (int x : a) ;
+}
+  )cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-DeclarationStatement
+|   | |-int
+|   | |-a
+|   | |-[
+|   | |-3
+|   | |-]
+|   | `-;
+|   |-RangeBasedForStatement
+|   | |-for
+|   | |-(
+|   | |-int
+|   | |-x
+|   | |-:
+|   | |-UnknownExpression
+|   | | `-a
+|   | |-)
+|   | `-EmptyStatement
+|   |   `-;
+|   `-}
+`-
+   )txt"},
+  // Unhandled statements should end up as 'unknown statement'.
+  // This example uses a 'label statement', which does not yet have a sy

[PATCH] D63835: [Syntax] Add nodes for most common statements

2019-07-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added inline comments.



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:185
+/// if (cond)  else 
+class IfStatement final : public Statement {
+public:

sammccall wrote:
> I guess the missing cond here (and similar below) are due to complexities 
> around the variable declaring variants?
> 
> Warrants a FIXME I think
Yes. Added a FIXME



Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:265
+/// return ;
+class ReturnStatement final : public Statement {
+public:

sammccall wrote:
> (any reason we can't already have the expr here?)
Added a getter for it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63835



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


[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: fedor.sergeev, rsmith.
ro added a project: clang.

`make check-all` currently fails on `x86_64-pc-solaris2.11` when building with 
GCC 9:

  Undefined   first referenced
   symbol in file
  _ZN11__sanitizer14internal_lseekEimi 
SANITIZER_TEST_OBJECTS.sanitizer_libc_test.cc.i386.o
  _ZN11__sanitizer23MapWritableFileToMemoryEPvmim 
SANITIZER_TEST_OBJECTS.sanitizer_libc_test.cc.i386.o
  ld: fatal: symbol referencing errors
  clang-9: error: linker command failed with exit code 1 (use -v to see 
invocation)
  make[3]: *** 
[projects/compiler-rt/lib/sanitizer_common/tests/CMakeFiles/TSanitizer-i386-Test.dir/build.make:92:
 projects/compiler-rt/lib/sanitizer_common/tests/Sanitizer-i386-Test] Error 1

While e.g. `__sanitizer::internal_lseek` is defined in `sanitizer_solaris.cc`, 
g++ 9
predefines `_FILE_OFFSET_BITS=64` while clang++ currently does not.

This patch resolves this inconsistency by following the gcc lead, which allows
`make check-all` to finish successfully.

There's one caveat: gcc defines `_LARGEFILE_SOURCE` and `_LARGEFILE64_SOURCE` 
for C++ only, while clang has long been doing it for
all languages.  I'd like to keep it this way because those macros do is to make
declarations of `fseek`/`ftello` (`_LARGEFILE_SOURCE`) resp. the 64-bit versions
of largefile functions (`*64` with `_LARGEFILE64_SOURCE`) visible additionally.
However, `_FILE_OFFSET_BITS=64` changes all affected functions to be 
largefile-aware.
I'd like to restrict this to C++, just like gcc does.

To avoid a similar inconsistence with host compilers that don't predefine 
`_FILE_OFFSET_BITS=64`
(e.g. clang < 9, gcc < 9), this needs a compantion patch to be submitted 
shortly.

Tested on `x86_64-pc-solaris2.11`.  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64482

Files:
  lib/Basic/Targets/OSTargets.h


Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -618,8 +618,11 @@
   Builder.defineMacro("_XOPEN_SOURCE", "600");
 else
   Builder.defineMacro("_XOPEN_SOURCE", "500");
-if (Opts.CPlusPlus)
+if (Opts.CPlusPlus) {
   Builder.defineMacro("__C99FEATURES__");
+  Builder.defineMacro("_FILE_OFFSET_BITS", "64");
+}
+// GCC restricts the next two to C++.
 Builder.defineMacro("_LARGEFILE_SOURCE");
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");


Index: lib/Basic/Targets/OSTargets.h
===
--- lib/Basic/Targets/OSTargets.h
+++ lib/Basic/Targets/OSTargets.h
@@ -618,8 +618,11 @@
   Builder.defineMacro("_XOPEN_SOURCE", "600");
 else
   Builder.defineMacro("_XOPEN_SOURCE", "500");
-if (Opts.CPlusPlus)
+if (Opts.CPlusPlus) {
   Builder.defineMacro("__C99FEATURES__");
+  Builder.defineMacro("_FILE_OFFSET_BITS", "64");
+}
+// GCC restricts the next two to C++.
 Builder.defineMacro("_LARGEFILE_SOURCE");
 Builder.defineMacro("_LARGEFILE64_SOURCE");
 Builder.defineMacro("__EXTENSIONS__");
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


r365629 - Loop pragma parsing. NFC.

2019-07-10 Thread Sjoerd Meijer via cfe-commits
Author: sjoerdmeijer
Date: Wed Jul 10 06:34:57 2019
New Revision: 365629

URL: http://llvm.org/viewvc/llvm-project?rev=365629&view=rev
Log:
Loop pragma parsing. NFC.

I would like to add some pragma handling here, but couldn't resist a little NFC
and tidy up first.

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

Modified:
cfe/trunk/lib/Sema/SemaStmtAttr.cpp

Modified: cfe/trunk/lib/Sema/SemaStmtAttr.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaStmtAttr.cpp?rev=365629&r1=365628&r2=365629&view=diff
==
--- cfe/trunk/lib/Sema/SemaStmtAttr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp Wed Jul 10 06:34:57 2019
@@ -82,22 +82,17 @@ static Attr *handleLoopHintAttr(Sema &S,
   IdentifierLoc *StateLoc = A.getArgAsIdent(2);
   Expr *ValueExpr = A.getArgAsExpr(3);
 
-  bool PragmaUnroll = PragmaNameLoc->Ident->getName() == "unroll";
-  bool PragmaNoUnroll = PragmaNameLoc->Ident->getName() == "nounroll";
-  bool PragmaUnrollAndJam = PragmaNameLoc->Ident->getName() == 
"unroll_and_jam";
-  bool PragmaNoUnrollAndJam =
-  PragmaNameLoc->Ident->getName() == "nounroll_and_jam";
+  StringRef PragmaName =
+  llvm::StringSwitch(PragmaNameLoc->Ident->getName())
+  .Cases("unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam",
+ PragmaNameLoc->Ident->getName())
+  .Default("clang loop");
+
   if (St->getStmtClass() != Stmt::DoStmtClass &&
   St->getStmtClass() != Stmt::ForStmtClass &&
   St->getStmtClass() != Stmt::CXXForRangeStmtClass &&
   St->getStmtClass() != Stmt::WhileStmtClass) {
-const char *Pragma =
-llvm::StringSwitch(PragmaNameLoc->Ident->getName())
-.Case("unroll", "#pragma unroll")
-.Case("nounroll", "#pragma nounroll")
-.Case("unroll_and_jam", "#pragma unroll_and_jam")
-.Case("nounroll_and_jam", "#pragma nounroll_and_jam")
-.Default("#pragma clang loop");
+std::string Pragma = "#pragma " + std::string(PragmaName);
 S.Diag(St->getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << 
Pragma;
 return nullptr;
   }
@@ -106,34 +101,29 @@ static Attr *handleLoopHintAttr(Sema &S,
   LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
-  if (PragmaNoUnroll) {
-// #pragma nounroll
-Option = LoopHintAttr::Unroll;
-State = LoopHintAttr::Disable;
-  } else if (PragmaUnroll) {
-if (ValueExpr) {
-  // #pragma unroll N
-  Option = LoopHintAttr::UnrollCount;
-  State = LoopHintAttr::Numeric;
-} else {
-  // #pragma unroll
-  Option = LoopHintAttr::Unroll;
-  State = LoopHintAttr::Enable;
-}
-  } else if (PragmaNoUnrollAndJam) {
-// #pragma nounroll_and_jam
-Option = LoopHintAttr::UnrollAndJam;
-State = LoopHintAttr::Disable;
-  } else if (PragmaUnrollAndJam) {
-if (ValueExpr) {
-  // #pragma unroll_and_jam N
-  Option = LoopHintAttr::UnrollAndJamCount;
-  State = LoopHintAttr::Numeric;
-} else {
-  // #pragma unroll_and_jam
-  Option = LoopHintAttr::UnrollAndJam;
-  State = LoopHintAttr::Enable;
-}
+
+  auto SetHints = [&Option, &State](LoopHintAttr::OptionType O,
+LoopHintAttr::LoopHintState S) {
+Option = O;
+State = S;
+  };
+
+  if (PragmaName == "nounroll") {
+SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
+  } else if (PragmaName == "unroll") {
+// #pragma unroll N
+if (ValueExpr)
+  SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
+else
+  SetHints(LoopHintAttr::Unroll, LoopHintAttr::Enable);
+  } else if (PragmaName == "nounroll_and_jam") {
+SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Disable);
+  } else if (PragmaName == "unroll_and_jam") {
+// #pragma unroll_and_jam N
+if (ValueExpr)
+  SetHints(LoopHintAttr::UnrollAndJamCount, LoopHintAttr::Numeric);
+else
+  SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Enable);
   } else {
 // #pragma clang loop ...
 assert(OptionLoc && OptionLoc->Ident &&


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


[PATCH] D64471: Loop pragma parsing. NFC.

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365629: Loop pragma parsing. NFC. (authored by SjoerdMeijer, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64471?vs=20&id=208939#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64471

Files:
  cfe/trunk/lib/Sema/SemaStmtAttr.cpp


Index: cfe/trunk/lib/Sema/SemaStmtAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAttr.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp
@@ -82,22 +82,17 @@
   IdentifierLoc *StateLoc = A.getArgAsIdent(2);
   Expr *ValueExpr = A.getArgAsExpr(3);
 
-  bool PragmaUnroll = PragmaNameLoc->Ident->getName() == "unroll";
-  bool PragmaNoUnroll = PragmaNameLoc->Ident->getName() == "nounroll";
-  bool PragmaUnrollAndJam = PragmaNameLoc->Ident->getName() == 
"unroll_and_jam";
-  bool PragmaNoUnrollAndJam =
-  PragmaNameLoc->Ident->getName() == "nounroll_and_jam";
+  StringRef PragmaName =
+  llvm::StringSwitch(PragmaNameLoc->Ident->getName())
+  .Cases("unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam",
+ PragmaNameLoc->Ident->getName())
+  .Default("clang loop");
+
   if (St->getStmtClass() != Stmt::DoStmtClass &&
   St->getStmtClass() != Stmt::ForStmtClass &&
   St->getStmtClass() != Stmt::CXXForRangeStmtClass &&
   St->getStmtClass() != Stmt::WhileStmtClass) {
-const char *Pragma =
-llvm::StringSwitch(PragmaNameLoc->Ident->getName())
-.Case("unroll", "#pragma unroll")
-.Case("nounroll", "#pragma nounroll")
-.Case("unroll_and_jam", "#pragma unroll_and_jam")
-.Case("nounroll_and_jam", "#pragma nounroll_and_jam")
-.Default("#pragma clang loop");
+std::string Pragma = "#pragma " + std::string(PragmaName);
 S.Diag(St->getBeginLoc(), diag::err_pragma_loop_precedes_nonloop) << 
Pragma;
 return nullptr;
   }
@@ -106,34 +101,29 @@
   LoopHintAttr::Spelling(A.getAttributeSpellingListIndex());
   LoopHintAttr::OptionType Option;
   LoopHintAttr::LoopHintState State;
-  if (PragmaNoUnroll) {
-// #pragma nounroll
-Option = LoopHintAttr::Unroll;
-State = LoopHintAttr::Disable;
-  } else if (PragmaUnroll) {
-if (ValueExpr) {
-  // #pragma unroll N
-  Option = LoopHintAttr::UnrollCount;
-  State = LoopHintAttr::Numeric;
-} else {
-  // #pragma unroll
-  Option = LoopHintAttr::Unroll;
-  State = LoopHintAttr::Enable;
-}
-  } else if (PragmaNoUnrollAndJam) {
-// #pragma nounroll_and_jam
-Option = LoopHintAttr::UnrollAndJam;
-State = LoopHintAttr::Disable;
-  } else if (PragmaUnrollAndJam) {
-if (ValueExpr) {
-  // #pragma unroll_and_jam N
-  Option = LoopHintAttr::UnrollAndJamCount;
-  State = LoopHintAttr::Numeric;
-} else {
-  // #pragma unroll_and_jam
-  Option = LoopHintAttr::UnrollAndJam;
-  State = LoopHintAttr::Enable;
-}
+
+  auto SetHints = [&Option, &State](LoopHintAttr::OptionType O,
+LoopHintAttr::LoopHintState S) {
+Option = O;
+State = S;
+  };
+
+  if (PragmaName == "nounroll") {
+SetHints(LoopHintAttr::Unroll, LoopHintAttr::Disable);
+  } else if (PragmaName == "unroll") {
+// #pragma unroll N
+if (ValueExpr)
+  SetHints(LoopHintAttr::UnrollCount, LoopHintAttr::Numeric);
+else
+  SetHints(LoopHintAttr::Unroll, LoopHintAttr::Enable);
+  } else if (PragmaName == "nounroll_and_jam") {
+SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Disable);
+  } else if (PragmaName == "unroll_and_jam") {
+// #pragma unroll_and_jam N
+if (ValueExpr)
+  SetHints(LoopHintAttr::UnrollAndJamCount, LoopHintAttr::Numeric);
+else
+  SetHints(LoopHintAttr::UnrollAndJam, LoopHintAttr::Enable);
   } else {
 // #pragma clang loop ...
 assert(OptionLoc && OptionLoc->Ident &&


Index: cfe/trunk/lib/Sema/SemaStmtAttr.cpp
===
--- cfe/trunk/lib/Sema/SemaStmtAttr.cpp
+++ cfe/trunk/lib/Sema/SemaStmtAttr.cpp
@@ -82,22 +82,17 @@
   IdentifierLoc *StateLoc = A.getArgAsIdent(2);
   Expr *ValueExpr = A.getArgAsExpr(3);
 
-  bool PragmaUnroll = PragmaNameLoc->Ident->getName() == "unroll";
-  bool PragmaNoUnroll = PragmaNameLoc->Ident->getName() == "nounroll";
-  bool PragmaUnrollAndJam = PragmaNameLoc->Ident->getName() == "unroll_and_jam";
-  bool PragmaNoUnrollAndJam =
-  PragmaNameLoc->Ident->getName() == "nounroll_and_jam";
+  StringRef PragmaName =
+  llvm::StringSwitch(PragmaNameLoc->Ident->getName())
+  .Cases("unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam",
+ PragmaNameLoc->Ident->getName())
+  .Default("clang loop");
+
   if (St->getStmtClass() != Stmt::DoS

[PATCH] D64481: [clangd] Add a flag to clangdServer rename function to control whether we want format the replacements.

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

Address review comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64481

Files:
  clang-tools-extra/clangd/ClangdLSPServer.cpp
  clang-tools-extra/clangd/ClangdServer.cpp
  clang-tools-extra/clangd/ClangdServer.h
  clang-tools-extra/clangd/unittests/SyncAPI.cpp


Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -102,7 +102,7 @@
 PathRef File, Position Pos,
 llvm::StringRef NewName) {
   llvm::Optional>> Result;
-  Server.rename(File, Pos, NewName, capture(Result));
+  Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -240,8 +240,11 @@
 
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
+  /// If WantFormat is false, the final TextEdit will be not formatted,
+  /// embedders could use this method to get all occurrences of the symbol 
(e.g.
+  /// highlighting them in prepare stage).
   void rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB);
+  bool WantFormat, Callback> CB);
 
   struct TweakRef {
 std::string ID;/// ID to pass for applyTweak.
Index: clang-tools-extra/clangd/ClangdServer.cpp
===
--- clang-tools-extra/clangd/ClangdServer.cpp
+++ clang-tools-extra/clangd/ClangdServer.cpp
@@ -283,23 +283,25 @@
 }
 
 void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB) {
-  auto Action = [Pos, this](Path File, std::string NewName,
-Callback> CB,
-llvm::Expected InpAST) {
+  bool WantFormat, Callback> CB) 
{
+  auto Action = [Pos, WantFormat, this](Path File, std::string NewName,
+Callback> CB,
+llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName, Index);
 if (!Changes)
   return CB(Changes.takeError());
 
-auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
-   InpAST->Inputs.FS.get());
-if (auto Formatted =
-cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
-  *Changes = std::move(*Formatted);
-else
-  elog("Failed to format replacements: {0}", Formatted.takeError());
+if (WantFormat) {
+  auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+ InpAST->Inputs.FS.get());
+  if (auto Formatted =
+  cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+*Changes = std::move(*Formatted);
+  else
+elog("Failed to format replacements: {0}", Formatted.takeError());
+}
 
 std::vector Edits;
 for (const auto &Rep : *Changes)
Index: clang-tools-extra/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/clangd/ClangdLSPServer.cpp
@@ -577,7 +577,7 @@
 "onRename called for non-added file", ErrorCode::InvalidParams));
 
   Server->rename(
-  File, Params.position, Params.newName,
+  File, Params.position, Params.newName, /*WantFormat=*/true,
   Bind(
   [File, Code, Params](decltype(Reply) Reply,
llvm::Expected> Edits) {


Index: clang-tools-extra/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/clangd/unittests/SyncAPI.cpp
@@ -102,7 +102,7 @@
 PathRef File, Position Pos,
 llvm::StringRef NewName) {
   llvm::Optional>> Result;
-  Server.rename(File, Pos, NewName, capture(Result));
+  Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
   return std::move(*Result);
 }
 
Index: clang-tools-extra/clangd/ClangdServer.h
===
--- clang-tools-extra/clangd/ClangdServer.h
+++ clang-tools-extra/clangd/ClangdServer.h
@@ -240,8 +240,11 @@
 
   /// Rename a

[clang-tools-extra] r365631 - [clangd] Add a flag to clangdServer rename function to control whether we want format the replacements.

2019-07-10 Thread Haojian Wu via cfe-commits
Author: hokein
Date: Wed Jul 10 06:44:22 2019
New Revision: 365631

URL: http://llvm.org/viewvc/llvm-project?rev=365631&view=rev
Log:
[clangd] Add a flag to clangdServer rename function to control whether we want 
format the replacements.

Summary:
This would allow clangd embedders to use the ClangdServer::rename for other
purposes (highlighting all the occurrences of the symbol in prepare
stage).

Reviewers: sammccall, ilya-biryukov

Subscribers: MaskRay, jkorous, arphaman, kadircet, cfe-commits

Tags: #clang

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

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

Modified: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp?rev=365631&r1=365630&r2=365631&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp Wed Jul 10 06:44:22 2019
@@ -577,7 +577,7 @@ void ClangdLSPServer::onRename(const Ren
 "onRename called for non-added file", ErrorCode::InvalidParams));
 
   Server->rename(
-  File, Params.position, Params.newName,
+  File, Params.position, Params.newName, /*WantFormat=*/true,
   Bind(
   [File, Code, Params](decltype(Reply) Reply,
llvm::Expected> Edits) {

Modified: clang-tools-extra/trunk/clangd/ClangdServer.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.cpp?rev=365631&r1=365630&r2=365631&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp Wed Jul 10 06:44:22 2019
@@ -283,23 +283,25 @@ ClangdServer::formatOnType(llvm::StringR
 }
 
 void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB) {
-  auto Action = [Pos, this](Path File, std::string NewName,
-Callback> CB,
-llvm::Expected InpAST) {
+  bool WantFormat, Callback> CB) 
{
+  auto Action = [Pos, WantFormat, this](Path File, std::string NewName,
+Callback> CB,
+llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName, Index);
 if (!Changes)
   return CB(Changes.takeError());
 
-auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
-   InpAST->Inputs.FS.get());
-if (auto Formatted =
-cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
-  *Changes = std::move(*Formatted);
-else
-  elog("Failed to format replacements: {0}", Formatted.takeError());
+if (WantFormat) {
+  auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+ InpAST->Inputs.FS.get());
+  if (auto Formatted =
+  cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+*Changes = std::move(*Formatted);
+  else
+elog("Failed to format replacements: {0}", Formatted.takeError());
+}
 
 std::vector Edits;
 for (const auto &Rep : *Changes)

Modified: clang-tools-extra/trunk/clangd/ClangdServer.h
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/ClangdServer.h?rev=365631&r1=365630&r2=365631&view=diff
==
--- clang-tools-extra/trunk/clangd/ClangdServer.h (original)
+++ clang-tools-extra/trunk/clangd/ClangdServer.h Wed Jul 10 06:44:22 2019
@@ -240,8 +240,11 @@ public:
 
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
+  /// If WantFormat is false, the final TextEdit will be not formatted,
+  /// embedders could use this method to get all occurrences of the symbol 
(e.g.
+  /// highlighting them in prepare stage).
   void rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB);
+  bool WantFormat, Callback> CB);
 
   struct TweakRef {
 std::string ID;/// ID to pass for applyTweak.

Modified: clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp?rev=365631&r1=365630&r2=365631&view=diff
==
--- clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp (original)
+++ clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp

[PATCH] D64481: [clangd] Add a flag to clangdServer rename function to control whether we want format the replacements.

2019-07-10 Thread Haojian Wu via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365631: [clangd] Add a flag to clangdServer rename function 
to control whether we want… (authored by hokein, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64481?vs=208940&id=208943#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64481

Files:
  clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.cpp
  clang-tools-extra/trunk/clangd/ClangdServer.h
  clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp


Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -283,23 +283,25 @@
 }
 
 void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB) {
-  auto Action = [Pos, this](Path File, std::string NewName,
-Callback> CB,
-llvm::Expected InpAST) {
+  bool WantFormat, Callback> CB) 
{
+  auto Action = [Pos, WantFormat, this](Path File, std::string NewName,
+Callback> CB,
+llvm::Expected InpAST) {
 if (!InpAST)
   return CB(InpAST.takeError());
 auto Changes = renameWithinFile(InpAST->AST, File, Pos, NewName, Index);
 if (!Changes)
   return CB(Changes.takeError());
 
-auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
-   InpAST->Inputs.FS.get());
-if (auto Formatted =
-cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
-  *Changes = std::move(*Formatted);
-else
-  elog("Failed to format replacements: {0}", Formatted.takeError());
+if (WantFormat) {
+  auto Style = getFormatStyleForFile(File, InpAST->Inputs.Contents,
+ InpAST->Inputs.FS.get());
+  if (auto Formatted =
+  cleanupAndFormat(InpAST->Inputs.Contents, *Changes, Style))
+*Changes = std::move(*Formatted);
+  else
+elog("Failed to format replacements: {0}", Formatted.takeError());
+}
 
 std::vector Edits;
 for (const auto &Rep : *Changes)
Index: clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdLSPServer.cpp
@@ -577,7 +577,7 @@
 "onRename called for non-added file", ErrorCode::InvalidParams));
 
   Server->rename(
-  File, Params.position, Params.newName,
+  File, Params.position, Params.newName, /*WantFormat=*/true,
   Bind(
   [File, Code, Params](decltype(Reply) Reply,
llvm::Expected> Edits) {
Index: clang-tools-extra/trunk/clangd/ClangdServer.h
===
--- clang-tools-extra/trunk/clangd/ClangdServer.h
+++ clang-tools-extra/trunk/clangd/ClangdServer.h
@@ -240,8 +240,11 @@
 
   /// Rename all occurrences of the symbol at the \p Pos in \p File to
   /// \p NewName.
+  /// If WantFormat is false, the final TextEdit will be not formatted,
+  /// embedders could use this method to get all occurrences of the symbol 
(e.g.
+  /// highlighting them in prepare stage).
   void rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB);
+  bool WantFormat, Callback> CB);
 
   struct TweakRef {
 std::string ID;/// ID to pass for applyTweak.
Index: clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
+++ clang-tools-extra/trunk/clangd/unittests/SyncAPI.cpp
@@ -102,7 +102,7 @@
 PathRef File, Position Pos,
 llvm::StringRef NewName) {
   llvm::Optional>> Result;
-  Server.rename(File, Pos, NewName, capture(Result));
+  Server.rename(File, Pos, NewName, /*WantFormat=*/true, capture(Result));
   return std::move(*Result);
 }
 


Index: clang-tools-extra/trunk/clangd/ClangdServer.cpp
===
--- clang-tools-extra/trunk/clangd/ClangdServer.cpp
+++ clang-tools-extra/trunk/clangd/ClangdServer.cpp
@@ -283,23 +283,25 @@
 }
 
 void ClangdServer::rename(PathRef File, Position Pos, llvm::StringRef NewName,
-  Callback> CB) {
-  auto Action = [Pos, this](Path File, std::string NewName,
-Callback> CB,
-llvm

[PATCH] D64487: [clang, test] Fix Clang :: Headers/max_align.c on 64-bit SPARC

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: venkatra, fedor.sergeev.
Herald added subscribers: jrtc27, jyknight.
Herald added a project: clang.

`Clang :: Headers/max_align.c` currently FAILs on 64-bit SPARC:

  error: 'error' diagnostics seen but not expected: 
File /vol/llvm/src/clang/dist/test/Headers/max_align.c Line 12: 
static_assert failed due to requirement '8 == _Alignof(max_align_t)' ""
  1 error generated.

This happens because `SuitableAlign` isn't defined for SPARCv9 unlike SPARCv8
(which uses the default of 64 bits).  gcc's `sparc/sparc.h` has

  #define BIGGEST_ALIGNMENT (TARGET_ARCH64 ? 128 : 64)

This patch sets `SuitableAlign` to match and updates the corresponding testcase.

Tested on `sparcv9-sun-solaris2.11` .  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64487

Files:
  lib/Basic/Targets/Sparc.h
  test/Preprocessor/init.c


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9599,6 +9599,7 @@
 // X86-64-DECLSPEC: #define __declspec{{.*}}
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null 
| FileCheck -match-full-lines -check-prefix SPARCV9 %s
+// SPARCV9:#define __BIGGEST_ALIGNMENT__ 16
 // SPARCV9:#define __INT64_TYPE__ long int
 // SPARCV9:#define __INTMAX_C_SUFFIX__ L
 // SPARCV9:#define __INTMAX_TYPE__ long int
Index: lib/Basic/Targets/Sparc.h
===
--- lib/Basic/Targets/Sparc.h
+++ lib/Basic/Targets/Sparc.h
@@ -208,6 +208,7 @@
 // aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned.
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
+SuitableAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }


Index: test/Preprocessor/init.c
===
--- test/Preprocessor/init.c
+++ test/Preprocessor/init.c
@@ -9599,6 +9599,7 @@
 // X86-64-DECLSPEC: #define __declspec{{.*}}
 //
 // RUN: %clang_cc1 -E -dM -ffreestanding -triple=sparc64-none-none < /dev/null | FileCheck -match-full-lines -check-prefix SPARCV9 %s
+// SPARCV9:#define __BIGGEST_ALIGNMENT__ 16
 // SPARCV9:#define __INT64_TYPE__ long int
 // SPARCV9:#define __INTMAX_C_SUFFIX__ L
 // SPARCV9:#define __INTMAX_TYPE__ long int
Index: lib/Basic/Targets/Sparc.h
===
--- lib/Basic/Targets/Sparc.h
+++ lib/Basic/Targets/Sparc.h
@@ -208,6 +208,7 @@
 // aligned. The SPARCv9 SCD 2.4.1 says 16-byte aligned.
 LongDoubleWidth = 128;
 LongDoubleAlign = 128;
+SuitableAlign = 128;
 LongDoubleFormat = &llvm::APFloat::IEEEquad();
 MaxAtomicPromoteWidth = MaxAtomicInlineWidth = 64;
   }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] r365632 - [clangd] Trim spaces around parsed include in include extractor

2019-07-10 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Jul 10 06:59:13 2019
New Revision: 365632

URL: http://llvm.org/viewvc/llvm-project?rev=365632&view=rev
Log:
[clangd] Trim spaces around parsed include in include extractor

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

Modified: clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp?rev=365632&r1=365631&r2=365632&view=diff
==
--- clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp Wed Jul 10 06:59:13 
2019
@@ -76,7 +76,7 @@ std::vector parseDriverOutp
   }
 
   for (llvm::StringRef Line : llvm::make_range(StartIt, EndIt)) {
-SystemIncludes.push_back(Line.str());
+SystemIncludes.push_back(Line.trim().str());
 vlog("System include extraction: adding {0}", Line);
   }
   return SystemIncludes;


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


[PATCH] D64488: [Driver] Support -fsanitize=function on Solaris/x86

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added a reviewer: kcc.
ro added a project: Sanitizers.
Herald added a subscriber: fedor.sergeev.
Herald added a project: clang.

`UBSan-Standalone-x86_64 :: TestCases/TypeCheck/Function/function.cpp` currently
FAILs on Solaris/x86_64:

  clang-9: error: unsupported option '-fsanitize=function' for target 
'x86_64-pc-solaris2.11'

AFAICS, there's nothing more to do then enable that sanitizer in the driver 
(for x86 only),
which is what this patch does, together with updating another testcase.

Tested on `x86_64-pc-solaris2.11`.  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64488

Files:
  lib/Driver/ToolChains/Solaris.cpp
  test/Driver/fsanitize.c


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -717,6 +717,9 @@
 // RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | 
FileCheck %s -check-prefix=SCUDO-NETBSD
 // SCUDO-NETBSD: "-fsanitize=scudo"
 
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | 
FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// FUNCTION-SOLARIS: "-fsanitize=function"
 
 
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function 
-fsanitize=undefined %s -### 2>&1 | FileCheck %s 
--check-prefix=CHECK-FSAN-UBSAN-PS4
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -181,6 +181,7 @@
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   const bool IsSparc = getTriple().getArch() == llvm::Triple::sparc;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   // FIXME: Omit X86_64 and SPARCv9 until 64-bit support is figured out.
@@ -189,6 +190,8 @@
 Res |= SanitizerKind::PointerCompare;
 Res |= SanitizerKind::PointerSubtract;
   }
+  if (IsX86 || IsX86_64)
+Res |= SanitizerKind::Function;
   Res |= SanitizerKind::Vptr;
   return Res;
 }


Index: test/Driver/fsanitize.c
===
--- test/Driver/fsanitize.c
+++ test/Driver/fsanitize.c
@@ -717,6 +717,9 @@
 // RUN: %clang -target x86_64--netbsd -fsanitize=scudo %s -### 2>&1 | FileCheck %s -check-prefix=SCUDO-NETBSD
 // SCUDO-NETBSD: "-fsanitize=scudo"
 
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// RUN: %clang -target x86_64--solaris -fsanitize=function %s -### 2>&1 | FileCheck %s -check-prefix=FUNCTION-SOLARIS
+// FUNCTION-SOLARIS: "-fsanitize=function"
 
 
 // RUN: %clang -target x86_64-scei-ps4 -fsanitize=function -fsanitize=undefined %s -### 2>&1 | FileCheck %s --check-prefix=CHECK-FSAN-UBSAN-PS4
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -181,6 +181,7 @@
 
 SanitizerMask Solaris::getSupportedSanitizers() const {
   const bool IsX86 = getTriple().getArch() == llvm::Triple::x86;
+  const bool IsX86_64 = getTriple().getArch() == llvm::Triple::x86_64;
   const bool IsSparc = getTriple().getArch() == llvm::Triple::sparc;
   SanitizerMask Res = ToolChain::getSupportedSanitizers();
   // FIXME: Omit X86_64 and SPARCv9 until 64-bit support is figured out.
@@ -189,6 +190,8 @@
 Res |= SanitizerKind::PointerCompare;
 Res |= SanitizerKind::PointerSubtract;
   }
+  if (IsX86 || IsX86_64)
+Res |= SanitizerKind::Function;
   Res |= SanitizerKind::Vptr;
   return Res;
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-10 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

> There's one caveat: gcc defines _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE for 
> C++ only, while clang has long been doing it for all languages

Can you explain more about the hack 
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0f97ccfdccc033f543ccbcb220697e62e84bf01f


Repository:
  rC Clang

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

https://reviews.llvm.org/D64482



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


[PATCH] D64489: [clangd][QueryDriver] Use language from underlying database if possible

2019-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, arphaman, jkorous, MaskRay, 
ilya-biryukov.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64489

Files:
  clang-tools-extra/clangd/QueryDriverDatabase.cpp


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -83,11 +83,11 @@
 }
 
 std::vector extractSystemIncludes(PathRef Driver,
-   llvm::StringRef Ext,
+   llvm::StringRef Lang,
llvm::Regex &QueryDriverRegex) {
   trace::Span Tracer("Extract system includes");
   SPAN_ATTACH(Tracer, "driver", Driver);
-  SPAN_ATTACH(Tracer, "ext", Ext);
+  SPAN_ATTACH(Tracer, "lang", Lang);
 
   if (!QueryDriverRegex.match(Driver)) {
 vlog("System include extraction: not whitelisted driver {0}", Driver);
@@ -117,14 +117,8 @@
   llvm::Optional Redirects[] = {
   {""}, {""}, llvm::StringRef(StdErrPath)};
 
-  auto Type = driver::types::lookupTypeForExtension(Ext);
-  if (Type == driver::types::TY_INVALID) {
-elog("System include extraction: invalid file type for {0}", Ext);
-return {};
-  }
   // Should we also preserve flags like "-sysroot", "-nostdinc" ?
-  const llvm::StringRef Args[] = {
-  Driver, "-E", "-x", driver::types::getTypeName(Type), "-", "-v"};
+  const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};
 
   if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
  Redirects)) {
@@ -220,10 +214,27 @@
 if (!Cmd || Cmd->CommandLine.empty())
   return Cmd;
 
+llvm::StringRef Lang;
+for (size_t I = 0, E = Cmd->CommandLine.size(); I < E; ++I) {
+  llvm::StringRef Arg = Cmd->CommandLine[I];
+  if (Arg == "-x" && I + 1 < E)
+Lang = Cmd->CommandLine[I + 1];
+  else if (Arg.startswith("-x"))
+Lang = Arg.drop_front(2).trim();
+}
+if (Lang.empty()) {
+  llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.');
+  auto Type = driver::types::lookupTypeForExtension(Ext);
+  if (Type == driver::types::TY_INVALID) {
+elog("System include extraction: invalid file type for {0}", Ext);
+return {};
+  }
+  Lang = driver::types::getTypeName(Type);
+}
+
 llvm::SmallString<128> Driver(Cmd->CommandLine.front());
 llvm::sys::fs::make_absolute(Cmd->Directory, Driver);
-llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.');
-auto Key = std::make_pair(Driver.str(), Ext);
+auto Key = std::make_pair(Driver.str(), Lang);
 
 std::vector SystemIncludes;
 {


Index: clang-tools-extra/clangd/QueryDriverDatabase.cpp
===
--- clang-tools-extra/clangd/QueryDriverDatabase.cpp
+++ clang-tools-extra/clangd/QueryDriverDatabase.cpp
@@ -83,11 +83,11 @@
 }
 
 std::vector extractSystemIncludes(PathRef Driver,
-   llvm::StringRef Ext,
+   llvm::StringRef Lang,
llvm::Regex &QueryDriverRegex) {
   trace::Span Tracer("Extract system includes");
   SPAN_ATTACH(Tracer, "driver", Driver);
-  SPAN_ATTACH(Tracer, "ext", Ext);
+  SPAN_ATTACH(Tracer, "lang", Lang);
 
   if (!QueryDriverRegex.match(Driver)) {
 vlog("System include extraction: not whitelisted driver {0}", Driver);
@@ -117,14 +117,8 @@
   llvm::Optional Redirects[] = {
   {""}, {""}, llvm::StringRef(StdErrPath)};
 
-  auto Type = driver::types::lookupTypeForExtension(Ext);
-  if (Type == driver::types::TY_INVALID) {
-elog("System include extraction: invalid file type for {0}", Ext);
-return {};
-  }
   // Should we also preserve flags like "-sysroot", "-nostdinc" ?
-  const llvm::StringRef Args[] = {
-  Driver, "-E", "-x", driver::types::getTypeName(Type), "-", "-v"};
+  const llvm::StringRef Args[] = {Driver, "-E", "-x", Lang, "-", "-v"};
 
   if (int RC = llvm::sys::ExecuteAndWait(Driver, Args, /*Env=*/llvm::None,
  Redirects)) {
@@ -220,10 +214,27 @@
 if (!Cmd || Cmd->CommandLine.empty())
   return Cmd;
 
+llvm::StringRef Lang;
+for (size_t I = 0, E = Cmd->CommandLine.size(); I < E; ++I) {
+  llvm::StringRef Arg = Cmd->CommandLine[I];
+  if (Arg == "-x" && I + 1 < E)
+Lang = Cmd->CommandLine[I + 1];
+  else if (Arg.startswith("-x"))
+Lang = Arg.drop_front(2).trim();
+}
+if (Lang.empty()) {
+  llvm::StringRef Ext = llvm::sys::path::extension(File).trim('.');
+  auto Type = driver::types::lookupTypeForExtension(Ext);
+  if (Type == driver::

[PATCH] D64491: [Driver] Enable __cxa_atexit on Solaris

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: fedor.sergeev, rsmith.
Herald added subscribers: dexonsmith, mehdi_amini, jyknight.
Herald added a project: clang.

Starting with Solaris 11.4 (which is now the required minimal version), Solaris 
does
support `__cxa_atexit`.  This patch reflects that.

One might consider removing the affected tests altogether instead of inverting 
them,
as is done on other targets.

Besides, this lets two ASan tests PASS:

  AddressSanitizer-i386-sunos :: TestCases/init-order-atexit.cc
  AddressSanitizer-i386-sunos-dynamic :: TestCases/init-order-atexit.cc

Tested on `x86_64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64491

Files:
  lib/Driver/ToolChains/Clang.cpp
  test/Driver/cxa-atexit.cpp
  test/Driver/solaris-opts.c


Index: test/Driver/solaris-opts.c
===
--- test/Driver/solaris-opts.c
+++ test/Driver/solaris-opts.c
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck 
%s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 
Index: test/Driver/cxa-atexit.cpp
===
--- test/Driver/cxa-atexit.cpp
+++ test/Driver/cxa-atexit.cpp
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | 
FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4750,7 +4750,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||


Index: test/Driver/solaris-opts.c
===
--- test/Driver/solaris-opts.c
+++ test/Driver/solaris-opts.c
@@ -1,4 +1,4 @@
 // RUN: %clang %s --target=sparc-sun-solaris2.11 -### -o %t.o 2>&1 | FileCheck %s
 
-// CHECK: "-fno-use-cxa-atexit"
+// CHECK-NOT: "-fno-use-cxa-atexit"
 
Index: test/Driver/cxa-atexit.cpp
===
--- test/Driver/cxa-atexit.cpp
+++ test/Driver/cxa-atexit.cpp
@@ -19,7 +19,7 @@
 // RUN: %clang -### -target sparc-sun-solaris -c %s -o /dev/null 2>&1 | FileCheck %s -check-prefix CHECK-SOLARIS
 
 // CHECK-WINDOWS: "-fno-use-cxa-atexit"
-// CHECK-SOLARIS: "-fno-use-cxa-atexit"
+// CHECK-SOLARIS-NOT: "-fno-use-cxa-atexit"
 // CHECK-HEXAGON-NOT: "-fno-use-cxa-atexit"
 // CHECK-XCORE: "-fno-use-cxa-atexit"
 // CHECK-MTI: "-fno-use-cxa-atexit"
Index: lib/Driver/ToolChains/Clang.cpp
===
--- lib/Driver/ToolChains/Clang.cpp
+++ lib/Driver/ToolChains/Clang.cpp
@@ -4750,7 +4750,6 @@
   if (!Args.hasFlag(
   options::OPT_fuse_cxa_atexit, options::OPT_fno_use_cxa_atexit,
   !RawTriple.isOSWindows() &&
-  RawTriple.getOS() != llvm::Triple::Solaris &&
   TC.getArch() != llvm::Triple::xcore &&
   ((RawTriple.getVendor() != llvm::Triple::MipsTechnologies) ||
RawTriple.hasEnvironment())) ||
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

2019-07-10 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom created this revision.
jvikstrom added reviewers: hokein, sammccall, ilya-biryukov.
Herald added subscribers: cfe-commits, kadircet, arphaman, jkorous, MaskRay.
Herald added a project: clang.

Added highlightings for namespace specifiers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64492

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -36,7 +36,8 @@
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
   {HighlightingKind::Class, "Class"},
-  {HighlightingKind::Enum, "Enum"}};
+  {HighlightingKind::Enum, "Enum"},
+  {HighlightingKind::Namespace, "Namespace"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
 std::vector Toks = makeHighlightingTokens(
@@ -75,18 +76,18 @@
   };
 )cpp",
 R"cpp(
-  namespace abc {
+  namespace $Namespace[[abc]] {
 template
 struct $Class[[A]] {
   T t;
 };
   }
   template
-  struct $Class[[C]] : abc::A {
+  struct $Class[[C]] : $Namespace[[abc]]::A {
 typename T::A* D;
   };
-  abc::$Class[[A]] $Variable[[AA]];
-  typedef abc::$Class[[A]] AAA;
+  $Namespace[[abc]]::$Class[[A]] $Variable[[AA]];
+  typedef $Namespace[[abc]]::$Class[[A]] AAA;
   struct $Class[[B]] {
 $Class[[B]]();
 ~$Class[[B]]();
@@ -108,6 +109,26 @@
 $Enum[[E]] EEE;
 $Enum[[EE]] ;
   };
+)cpp",
+R"cpp(
+  namespace $Namespace[[abc]] {
+namespace $Namespace[[bcd]] {
+  struct $Class[[A]] {};
+  namespace $Namespace[[cde]] {
+struct $Class[[A]] {
+  static enum class $Enum[[B]] {
+Hi,
+  };
+};
+  }
+}
+  }
+  using namespace $Namespace[[abc]]::$Namespace[[bcd]];
+  namespace $Namespace[[vwz]] =
+$Namespace[[abc]]::$Namespace[[bcd]]::$Namespace[[cde]];
+  $Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[AA]];
+  $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]] $Variable[[AAA]] =
+$Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::Hi;
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -9,12 +9,15 @@
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
-# CHECK-NEXT:  ]
+# CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.type.class.cpp"
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.namespace.cpp"
 # CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -28,6 +28,7 @@
   Function,
   Class,
   Enum,
+  Namespace,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,8 +11,6 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 
 namespace clang {
@@ -37,6 +35,13 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
+// UsingDirectiveDecl's namespaces do not show up anywhere else in the
+// Visit/Traverse mehods. But they should also be highlighted as a
+// namespace.
+if (const auto UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
+}
+
 // Constructors' TypeLoc has a TypePtr that is a FunctionProtoType. It has
 // no tag decl and therefore constructors must be gotten as NamedDecls
 // instead.
@@ -76,6 +81,16 @@
 return true;
   }
 
+  bool TraverseNestedNameSpecifierLoc(NestedNameSpecifierLoc NNSLoc) {
+if (NestedNameSpecif

[clang-tools-extra] r365634 - [clangd] Filter out non-governed files from broadcast

2019-07-10 Thread Kadir Cetinkaya via cfe-commits
Author: kadircet
Date: Wed Jul 10 07:11:46 2019
New Revision: 365634

URL: http://llvm.org/viewvc/llvm-project?rev=365634&view=rev
Log:
[clangd] Filter out non-governed files from broadcast

Summary:
This also turns off implicit discovery of additional compilation
databases.

Reviewers: sammccall

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, cfe-commits

Tags: #clang

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

Modified:
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
clang-tools-extra/trunk/clangd/index/Background.cpp
clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp
clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
clang-tools-extra/trunk/clangd/unittests/TestFS.cpp
clang-tools-extra/trunk/clangd/unittests/TestFS.h

Modified: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
URL: 
http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp?rev=365634&r1=365633&r2=365634&view=diff
==
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp (original)
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp Wed Jul 10 
07:11:46 2019
@@ -8,12 +8,18 @@
 
 #include "GlobalCompilationDatabase.h"
 #include "Logger.h"
+#include "Path.h"
 #include "clang/Frontend/CompilerInvocation.h"
 #include "clang/Tooling/ArgumentsAdjusters.h"
 #include "clang/Tooling/CompilationDatabase.h"
+#include "llvm/ADT/None.h"
 #include "llvm/ADT/Optional.h"
+#include "llvm/ADT/STLExtras.h"
 #include "llvm/Support/FileSystem.h"
 #include "llvm/Support/Path.h"
+#include 
+#include 
+#include 
 
 namespace clang {
 namespace clangd {
@@ -43,6 +49,16 @@ std::string getStandardResourceDir() {
   return CompilerInvocation::GetResourcesPath("clangd", (void *)&Dummy);
 }
 
+// Runs the given action on all parent directories of filename, starting from
+// deepest directory and going up to root. Stops whenever action succeeds.
+void actOnAllParentDirectories(PathRef FileName,
+   llvm::function_ref Action) {
+  for (auto Path = llvm::sys::path::parent_path(FileName);
+   !Path.empty() && !Action(Path);
+   Path = llvm::sys::path::parent_path(Path))
+;
+}
+
 } // namespace
 
 static std::string getFallbackClangPath() {
@@ -81,60 +97,138 @@ DirectoryBasedGlobalCompilationDatabase:
 ~DirectoryBasedGlobalCompilationDatabase() = default;
 
 llvm::Optional
-DirectoryBasedGlobalCompilationDatabase::getCompileCommand(
-PathRef File, ProjectInfo *Project) const {
-  if (auto CDB = getCDBForFile(File, Project)) {
-auto Candidates = CDB->getCompileCommands(File);
-if (!Candidates.empty()) {
-  return std::move(Candidates.front());
-}
-  } else {
+DirectoryBasedGlobalCompilationDatabase::getCompileCommand(PathRef File) const 
{
+  CDBLookupRequest Req;
+  Req.FileName = File;
+  Req.ShouldBroadcast = true;
+
+  auto Res = lookupCDB(Req);
+  if (!Res) {
 log("Failed to find compilation database for {0}", File);
+return llvm::None;
   }
+
+  auto Candidates = Res->CDB->getCompileCommands(File);
+  if (!Candidates.empty())
+return std::move(Candidates.front());
+
   return None;
 }
 
-std::pair
+std::pair
 DirectoryBasedGlobalCompilationDatabase::getCDBInDirLocked(PathRef Dir) const {
   // FIXME(ibiryukov): Invalidate cached compilation databases on changes
   auto CachedIt = CompilationDatabases.find(Dir);
   if (CachedIt != CompilationDatabases.end())
-return {CachedIt->second.get(), true};
+return {CachedIt->second.CDB.get(), CachedIt->second.SentBroadcast};
   std::string Error = "";
-  auto CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
-  auto Result = CDB.get();
-  CompilationDatabases.insert(std::make_pair(Dir, std::move(CDB)));
+
+  CachedCDB Entry;
+  Entry.CDB = tooling::CompilationDatabase::loadFromDirectory(Dir, Error);
+  auto Result = Entry.CDB.get();
+  CompilationDatabases[Dir] = std::move(Entry);
+
   return {Result, false};
 }
 
-tooling::CompilationDatabase *
-DirectoryBasedGlobalCompilationDatabase::getCDBForFile(
-PathRef File, ProjectInfo *Project) const {
-  namespace path = llvm::sys::path;
-  assert((path::is_absolute(File, path::Style::posix) ||
-  path::is_absolute(File, path::Style::windows)) &&
+llvm::Optional
+DirectoryBasedGlobalCompilationDatabase::lookupCDB(
+CDBLookupRequest Request) const {
+  assert(llvm::sys::path::is_absolute(Request.FileName) &&
  "path must be absolute");
 
-  tooling::CompilationDatabase *CDB = nullptr;
-  bool Cached = false;
-  std::lock_guard Lock(Mutex);
+  CDBLookupResult Result;
+  bool SentBroadcast = false;
+
+  {
+std::lock_guard Lock(Mutex);
+if (CompileCommandsDir) {
+  std::tie(Result.CDB, SentBroadcas

[PATCH] D64247: [clangd] Filter out non-governed files from broadcast

2019-07-10 Thread Kadir Cetinkaya via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365634: [clangd] Filter out non-governed files from 
broadcast (authored by kadircet, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64247?vs=208890&id=208957#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64247

Files:
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.cpp
  clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
  clang-tools-extra/trunk/clangd/QueryDriverDatabase.cpp
  clang-tools-extra/trunk/clangd/index/Background.cpp
  clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp
  clang-tools-extra/trunk/clangd/unittests/GlobalCompilationDatabaseTests.cpp
  clang-tools-extra/trunk/clangd/unittests/TestFS.cpp
  clang-tools-extra/trunk/clangd/unittests/TestFS.h

Index: clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
===
--- clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
+++ clang-tools-extra/trunk/clangd/GlobalCompilationDatabase.h
@@ -40,9 +40,13 @@
   virtual ~GlobalCompilationDatabase() = default;
 
   /// If there are any known-good commands for building this file, returns one.
-  /// If the ProjectInfo pointer is set, it will also be populated.
   virtual llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const = 0;
+  getCompileCommand(PathRef File) const = 0;
+
+  /// Finds the closest project to \p File.
+  virtual llvm::Optional getProjectInfo(PathRef File) const {
+return llvm::None;
+  }
 
   /// Makes a guess at how to build a file.
   /// The default implementation just runs clang on the file.
@@ -71,20 +75,40 @@
 
   /// Scans File's parents looking for compilation databases.
   /// Any extra flags will be added.
+  /// Might trigger OnCommandChanged, if CDB wasn't broadcasted yet.
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
+
+  /// Returns the path to first directory containing a compilation database in
+  /// \p File's parents.
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
 private:
-  tooling::CompilationDatabase *getCDBForFile(PathRef File,
-  ProjectInfo *) const;
-  std::pair
+  std::pair
   getCDBInDirLocked(PathRef File) const;
 
+  struct CDBLookupRequest {
+PathRef FileName;
+// Whether this lookup should trigger discovery of the CDB found.
+bool ShouldBroadcast = false;
+  };
+  struct CDBLookupResult {
+tooling::CompilationDatabase *CDB = nullptr;
+ProjectInfo PI;
+  };
+  llvm::Optional lookupCDB(CDBLookupRequest Request) const;
+
+  // Performs broadcast on governed files.
+  void broadcastCDB(CDBLookupResult Res) const;
+
   mutable std::mutex Mutex;
   /// Caches compilation databases loaded from directories(keys are
   /// directories).
-  mutable llvm::StringMap>
-  CompilationDatabases;
+  struct CachedCDB {
+std::unique_ptr CDB = nullptr;
+bool SentBroadcast = false;
+  };
+  mutable llvm::StringMap CompilationDatabases;
 
   /// Used for command argument pointing to folder where compile_commands.json
   /// is located.
@@ -109,8 +133,9 @@
  llvm::Optional ResourceDir = llvm::None);
 
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
   tooling::CompileCommand getFallbackCommand(PathRef File) const override;
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
   /// Sets or clears the compilation command for a particular file.
   void
Index: clang-tools-extra/trunk/clangd/unittests/TestFS.h
===
--- clang-tools-extra/trunk/clangd/unittests/TestFS.h
+++ clang-tools-extra/trunk/clangd/unittests/TestFS.h
@@ -12,6 +12,8 @@
 #ifndef LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #define LLVM_CLANG_TOOLS_EXTRA_UNITTESTS_CLANGD_TESTFS_H
 #include "ClangdServer.h"
+#include "GlobalCompilationDatabase.h"
+#include "Path.h"
 #include "llvm/ADT/IntrusiveRefCntPtr.h"
 #include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
@@ -48,7 +50,9 @@
   StringRef RelPathPrefix = StringRef());
 
   llvm::Optional
-  getCompileCommand(PathRef File, ProjectInfo * = nullptr) const override;
+  getCompileCommand(PathRef File) const override;
+
+  llvm::Optional getProjectInfo(PathRef File) const override;
 
   std::vector ExtraClangFlags;
 
Index: clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp
===
--- clang-tools-extra/trunk/clangd/unittests/ClangdTests.cpp
+++ clang-tools-extra/trunk/clangd/unittests/ClangdTests

[PATCH] D64493: [Driver] Don't pass --dynamic-linker to ld on Solaris

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro created this revision.
ro added reviewers: fedor.sergeev, rsmith, theraven.
Herald added subscribers: jrtc27, jyknight.
Herald added a project: clang.

I noticed that clang currenly passes `--dynamic-linker` to `ld`.  This has been 
the case
since Solaris 11 support was added initially back in 2012 by David Chisnall 
(r150580).
I couldn't find any patch submission, let alone a justification, for this, and 
it seems
completely useless: `--dynamic-linker` is a gld compatibility form of the 
option, the
native option being `-I`.  First of all, however, the dynamic linker passed is 
simply the
default, so there's no reason at all to specify it in the first place.

This patch removes passing the option and adjusts the affected testcase 
accordingly.

Tested on `x86_64-pc-solaris2.11` and `sparcv9-sun-solaris2.11`.  Ok for trunk?


Repository:
  rC Clang

https://reviews.llvm.org/D64493

Files:
  lib/Driver/ToolChains/Solaris.cpp
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/ld.so.1
  test/Driver/Inputs/solaris_sparc_tree/usr/lib/sparcv9/ld.so.1
  test/Driver/Inputs/solaris_x86_tree/usr/lib/amd64/ld.so.1
  test/Driver/Inputs/solaris_x86_tree/usr/lib/ld.so.1
  test/Driver/solaris-ld.c


Index: test/Driver/solaris-ld.c
===
--- test/Driver/solaris-ld.c
+++ test/Driver/solaris-ld.c
@@ -11,7 +11,6 @@
 // CHECK-LD-SPARC32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"sparc-sun-solaris2.11"
 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC32-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib{{/|}}ld.so.1"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crt1.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD-SPARC32-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtbegin.o"
@@ -35,7 +34,6 @@
 // CHECK-LD-SPARC64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"sparcv9-sun-solaris2.11"
 // CHECK-LD-SPARC64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC64-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib/sparcv9{{/|}}ld.so.1"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crt1.o"
 // CHECK-LD-SPARC64-SAME: "[[SYSROOT]]/usr/lib/sparcv9{{/|}}crti.o"
 // CHECK-LD-SPARC64-SAME: 
"[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2/sparcv9{{/|}}crtbegin.o"
@@ -59,7 +57,6 @@
 // CHECK-LD-X32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "i386-pc-solaris2.11"
 // CHECK-LD-X32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-X32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-X32-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib{{/|}}ld.so.1"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crt1.o"
 // CHECK-LD-X32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD-X32-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4{{/|}}crtbegin.o"
@@ -83,7 +80,6 @@
 // CHECK-LD-X64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" 
"x86_64-pc-solaris2.11"
 // CHECK-LD-X64-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-X64: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-X64-SAME: "--dynamic-linker" 
"[[SYSROOT]]/usr/lib/amd64{{/|}}ld.so.1"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crt1.o"
 // CHECK-LD-X64-SAME: "[[SYSROOT]]/usr/lib/amd64{{/|}}crti.o"
 // CHECK-LD-X64-SAME: 
"[[SYSROOT]]/usr/gcc/4.9/lib/gcc/i386-pc-solaris2.11/4.9.4/amd64{{/|}}crtbegin.o"
Index: lib/Driver/ToolChains/Solaris.cpp
===
--- lib/Driver/ToolChains/Solaris.cpp
+++ lib/Driver/ToolChains/Solaris.cpp
@@ -65,10 +65,6 @@
 CmdArgs.push_back("-Bdynamic");
 if (Args.hasArg(options::OPT_shared)) {
   CmdArgs.push_back("-shared");
-} else {
-  CmdArgs.push_back("--dynamic-linker");
-  CmdArgs.push_back(
-  Args.MakeArgString(getToolChain().GetFilePath("ld.so.1")));
 }
 
 // libpthread has been folded into libc since Solaris 10, no need to do


Index: test/Driver/solaris-ld.c
===
--- test/Driver/solaris-ld.c
+++ test/Driver/solaris-ld.c
@@ -11,7 +11,6 @@
 // CHECK-LD-SPARC32: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "sparc-sun-solaris2.11"
 // CHECK-LD-SPARC32-SAME: "-isysroot" "[[SYSROOT:[^"]+]]"
 // CHECK-LD-SPARC32: "{{.*}}ld{{(.exe)?}}"
-// CHECK-LD-SPARC32-SAME: "--dynamic-linker" "[[SYSROOT]]/usr/lib{{/|}}ld.so.1"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crt1.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/lib{{/|}}crti.o"
 // CHECK-LD-SPARC32-SAME: "[[SYSROOT]]/usr/gcc/4.8/lib/gcc/sparc-sun-solaris2.11/4.8.2{{/|}}crtbegin.o"
@@ -35,7 +34,6 @@
 // CHECK-LD-SPARC64: {{.*}}clang{{(.exe)?}}" "-cc1" "-triple" "sparcv9-sun-solaris2.11"
 // CHECK-LD-SPA

[PATCH] D64380: Add 'require_designated_init' and 'required' attribute to clang

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/Attr.td:1947
 
+def RequireDesignatedInit : InheritableAttr {
+  let Spellings = [CXX11<"clang", "require_designated_init">];

This should be `RequiresDesignator`.



Comment at: clang/include/clang/Basic/Attr.td:1948
+def RequireDesignatedInit : InheritableAttr {
+  let Spellings = [CXX11<"clang", "require_designated_init">];
+  let Subjects = SubjectList<[Type]>;

I'd prefer this be named `requires_designator`.



Comment at: clang/include/clang/Basic/Attr.td:1949
+  let Spellings = [CXX11<"clang", "require_designated_init">];
+  let Subjects = SubjectList<[Type]>;
+  let Documentation = [RequireDesignatedInitDocs];

I'm a bit confused by this subject -- it's a declaration attribute that 
appertains to types? Why is this not `RecordDecl` instead?



Comment at: clang/include/clang/Basic/Attr.td:1953
+
+def Required : InheritableAttr {
+  let Spellings = [CXX11<"clang", "designated_init_required">];

This should be `RequiresInit`



Comment at: clang/include/clang/Basic/Attr.td:1954
+def Required : InheritableAttr {
+  let Spellings = [CXX11<"clang", "designated_init_required">];
+  let Subjects = SubjectList<[Field]>;

This should also use the `Clang` spelling. Also, I'd prefer this be named 
`requires_init`.

As it stands, these two attribute names are *way* too similar.



Comment at: clang/include/clang/Basic/Attr.td:1948
+def RequireDesignatedInit : InheritableAttr {
+  let Spellings = [GNU<"require_designated_init">];
+  let Subjects = SubjectList<[Type]>;

compnerd wrote:
> This seems like an extension?  I think that we want to explicitly mark this 
> as an extension, as this is not available in GCC AFAIK.
This should use the `Clang` attribute spelling rather than `CXX11`.



Comment at: clang/include/clang/Basic/AttrDocs.td:1448
 
+def RequireDesignatedInitDocs : Documentation {
+  let Category = DocCatType;

The behavior should be documented as to what happens when you apply these 
attributes to unions.



Comment at: clang/include/clang/Basic/AttrDocs.td:1451
+  let Content = [{
+This attribute can be applied to a struct definition to require that anytime a
+variable of that struct's type is declared, the declaration uses designated

anytime -> any time



Comment at: clang/include/clang/Basic/AttrDocs.td:1452
+This attribute can be applied to a struct definition to require that anytime a
+variable of that struct's type is declared, the declaration uses designated
+initializer syntax ([dcl.init.aggr]p3.1).

struct's -> structure's



Comment at: clang/include/clang/Basic/AttrDocs.td:1484
+This attribute can be applied to a field definition within a struct or a class
+to require that anytime a variable of the struct/class's type is declared, that
+field must be initialized using designated initializer syntax 
([dcl.init.aggr]p3.1).

anytime -> any time
struct/class -> struct



Comment at: clang/include/clang/Basic/DiagnosticSemaKinds.td:3533-3541
+def err_require_designated_init_failed : Error<
+  "variable declaration does not use designated initializer syntax">;
+def note_declared_required_designated_init_here : Note<
+  "required by 'require_designated_init' attribute here">;
+
+def err_required_failed : Error<
+  "initializer for variable %0 must explicitly initialize field %1">;

I'm a little uncomfortable with these being errors rather than warnings. I 
think of these attributes as being preferences rather than requirements; the 
code isn't *wrong* if it fails to use the designated initializer (it's 
conforming to C or C++, does not have UB, etc) and other implementations are 
free to ignore those attributes and the end result will be identical to what's 
produced by Clang.

What do you think about turning these into warnings? Users can always use 
`-Werror` to strengthen their own requirements.



Comment at: clang/lib/Sema/SemaDecl.cpp:11214
 
+  if (auto *TD = VDecl->getType().getTypePtr()->getAsTagDecl()) {
+// If the type of the declaration is a struct/class and that type has the

Any reason this shouldn't be `const auto *`? (Propagated elsewhere.)



Comment at: clang/lib/Sema/SemaDecl.cpp:11220-11221
+  if (auto *ILE = dyn_cast(Init)) {
+for (unsigned i = 0; i < ILE->getNumInits(); i++) {
+  Expr *init = ILE->getInit(i);
+  if (auto *DIE = dyn_cast(init))

You can use a range-based for loop over `inits()`, I believe. Also, the 
variable should be named `Init` to meet the coding style.



Comment at: clang/lib/Sema/SemaDecl.cpp:11228
+  << 

[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added reviewers: NoQ, Szelethus.
aaron.ballman added a subscriber: NoQ.
aaron.ballman added a comment.

I'm worried that this will continue to drift out of sync with the static 
analyzer checks unless we find some way to automate it. I wonder if we could 
write a script to generate these .rst files and somehow fit it into the 
workflow for adding new static analyzer checks to re-run the script to produce 
new files (or modified files) as needed? @NoQ and @Szelethus may have ideas.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via Phabricator via cfe-commits
martong created this revision.
martong added a reviewer: dkrupp.
Herald added subscribers: cfe-commits, Charusso, gamesh411, donat.nagy, 
Szelethus, mikhail.ramalho, a.sidorin, rnkovacs, szepet, baloghadamsoftware, 
xazax.hun, whisperity.
Herald added a project: clang.

Add user documentation page. This is an empty page atm, later patches will add
the specific user documentatoins.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64494

Files:
  clang/docs/ClangStaticAnalyzer.rst
  clang/docs/analyzer/user-docs.rst


Index: clang/docs/analyzer/user-docs.rst
===
--- /dev/null
+++ clang/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: clang/docs/ClangStaticAnalyzer.rst
===
--- clang/docs/ClangStaticAnalyzer.rst
+++ clang/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, 
C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic 
execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 


Index: clang/docs/analyzer/user-docs.rst
===
--- /dev/null
+++ clang/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: clang/docs/ClangStaticAnalyzer.rst
===
--- clang/docs/ClangStaticAnalyzer.rst
+++ clang/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Daniel Krupp via Phabricator via cfe-commits
dkrupp accepted this revision.
dkrupp added a comment.
This revision is now accepted and ready to land.

I guess this is a placeholder for the subpages of "User Manual" @ 
https://clang-analyzer.llvm.org, which will be ported in follow-up patches.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64494



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


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Kyrill Tkachov via Phabricator via cfe-commits
ktkachov created this revision.
ktkachov added reviewers: t.p.northover, SjoerdMeijer, pbarrio, momchil.velikov.
ktkachov added projects: LLVM, clang.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya, kristof.beyls, 
javed.absar.

The __jcvt intrinsic defined in ACLE [1] is available when __ARM_FEATURE_JCVT 
is defined.

  

This change introduces the AArch64 intrinsic, wires it up to the instruction 
and a new clang builtin function.
The __ARM_FEATURE_JCVT macro is now defined when an Armv8.3-A or higher target 
is used.
I've implemented the target detection logic in Clang so that this feature is 
enabled for architectures from armv8.3-a onwards (so -march=armv8.4-a also 
enables this, for example).

make check-all didn't show any new failures.

[1] https://developer.arm.com/docs/101028/latest/data-processing-intrinsics

N.B. This is my first patch to LLVM. Apologies if some code looks weird. If 
this is okay can somebody please apply it for me?


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D64495

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/fjcvtzs.ll

Index: llvm/test/CodeGen/AArch64/fjcvtzs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/fjcvtzs.ll
@@ -0,0 +1,10 @@
+; RUN: llc -mtriple=arm64-eabi -mattr=+jsconv -o - %s | FileCheck %s
+
+define i32 @test_jcvt(double %v) {
+; CHECK-LABEL: test_jcvt:
+; CHECK: fjcvtzs w0, d0
+  %val = call i32 @llvm.aarch64.fjcvtzs(double %v)
+  ret i32 %val
+}
+
+declare i32 @llvm.aarch64.fjcvtzs(double)
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -717,7 +717,7 @@
 // v8.3a floating point conversion for javascript
 let Predicates = [HasJS, HasFPARMv8] in
 def FJCVTZS  : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
-  "fjcvtzs", []> {
+  "fjcvtzs", [(set GPR32:$Rd, (int_aarch64_fjcvtzs FPR64:$Rn))]> {
   let Inst{31} = 0;
 } // HasJS, HasFPARMv8
 
Index: llvm/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -31,6 +31,8 @@
 def int_aarch64_udiv : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>,
 LLVMMatchType<0>], [IntrNoMem]>;
 
+def int_aarch64_fjcvtzs : Intrinsic<[llvm_i32_ty], [llvm_double_ty], [IntrNoMem]>;
+
 //===--===//
 // HINT
 
Index: clang/test/CodeGen/builtins-arm64.c
===
--- clang/test/CodeGen/builtins-arm64.c
+++ clang/test/CodeGen/builtins-arm64.c
@@ -58,6 +58,11 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
 }
 
+int32_t jcvt(double v) {
+  //CHECK: call i32 @llvm.aarch64.fjcvtzs
+  return __builtin_arm_jcvt(v);
+}
+
 __typeof__(__builtin_arm_rsr("1:2:3:4:5")) rsr(void);
 
 uint32_t rsr() {
Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -2,6 +2,7 @@
 // RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 -O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM -check-prefix=AArch32-NEWPM
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY -check-prefix=AArch64-LEGACY
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM -check-prefix=AArch64-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s --check-prefix=AArch64-v8_3
 
 #include 
 
@@ -823,3 +824,11 @@
 
 // AArch64: ![[M0]] = !{!"1:2:3:4:5"}
 // AArch64: ![[M1]] = !{!"sysreg"}
+
+
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs
+#ifdef __ARM_64BIT_STATE
+int32_t test_jc

[PATCH] D64482: [Driver] Define _FILE_OFFSET_BITS=64 on Solaris

2019-07-10 Thread Rainer Orth via Phabricator via cfe-commits
ro added a comment.

In D64482#1578245 , @MaskRay wrote:

> > There's one caveat: gcc defines _LARGEFILE_SOURCE and _LARGEFILE64_SOURCE 
> > for C++ only, while clang has long been doing it for all languages
>
> Can you explain more about the hack 
> https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=0f97ccfdccc033f543ccbcb220697e62e84bf01f


No hack at all ;-)  See the patch submission 
https://gcc.gnu.org/ml/gcc-patches/2018-06/msg01320.html for details.  Apart 
from that,
this is the direction libstdc++/g++ mean to take in general.


Repository:
  rC Clang

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

https://reviews.llvm.org/D64482



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


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:237
+break;
+  case llvm::AArch64::ArchKind::ARMV8_4A:
+getTargetDefinesARMV84A(Opts, Builder);

It is a good change, but I think you should either add tests for these cases, 
or remove this (temporarily) because it is not adding much at the moment.



Comment at: clang/test/CodeGen/arm_acle.c:829
+
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs
+#ifdef __ARM_64BIT_STATE

Same comment, better is to do a CHECK-LABEL first



Comment at: clang/test/CodeGen/builtins-arm64.c:61
 
+int32_t jcvt(double v) {
+  //CHECK: call i32 @llvm.aarch64.fjcvtzs

Although this file doesn't seem to do this, better is check the function name 
first, e.g.:

  // CHECK-LABEL: @jcvt(

followed by what you want to check:
  
  //CHECK: call i32 @llvm.aarch64.fjcvtzs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64495



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


[PATCH] D63139: [Diagnostics] Implement -Wswitch-unreachable

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D63139#1561891 , @rjmccall wrote:

> Are the `CaseStmt`s being dropped in C++ because the expression overflows?  I 
> agree that that's bad AST behavior; we should strive to generate AST whenever 
> we can, even if it's not valid.


We do strive to generate an AST whenever we can (like recovering as though 
fix-its were applied, or keeping declarations and marking them as invalid), but 
I don't think we want to generate *invalid* AST nodes. I believe that way leads 
to more cascading, insensible errors and worse behavior for tooling than 
dropping the invalid AST node does (depending on the scenario). I have a hazy 
recollection that we wanted to consider adding AST nodes to represent erroneous 
constructs that attempt to hold onto as much valid state as we can capture to 
help with these situations, but I'm not certain that idea went anywhere.

It would be nice if we could suppress the unreachable warning in this case, but 
I'm not certain it's strictly required for this patch to proceed, either. 
@rsmith, do you have opinions?


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

https://reviews.llvm.org/D63139



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


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via Phabricator via cfe-commits
martong added a comment.

In D64494#1578373 , @dkrupp wrote:

> I guess this is a placeholder for the subpages of "User Manual" @ 
> https://clang-analyzer.llvm.org, which will be ported in follow-up patches.


Yes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64494



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


r365639 - [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via cfe-commits
Author: martong
Date: Wed Jul 10 07:49:53 2019
New Revision: 365639

URL: http://llvm.org/viewvc/llvm-project?rev=365639&view=rev
Log:
[analyzer]Add user docs rst

Summary:
Add user documentation page. This is an empty page atm, later patches will add
the specific user documentatoins.

Reviewers: dkrupp

Subscribers: whisperity, xazax.hun, baloghadamsoftware, szepet, rnkovacs, 
a.sidorin, mikhail.ramalho, Szelethus, donat.nagy, gamesh411, Charusso, 
cfe-commits

Tags: #clang

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

Added:
cfe/trunk/docs/analyzer/user-docs.rst
Modified:
cfe/trunk/docs/ClangStaticAnalyzer.rst

Modified: cfe/trunk/docs/ClangStaticAnalyzer.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/ClangStaticAnalyzer.rst?rev=365639&r1=365638&r2=365639&view=diff
==
--- cfe/trunk/docs/ClangStaticAnalyzer.rst (original)
+++ cfe/trunk/docs/ClangStaticAnalyzer.rst Wed Jul 10 07:49:53 2019
@@ -5,15 +5,16 @@ Clang Static Analyzer
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, 
C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic 
execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 

Added: cfe/trunk/docs/analyzer/user-docs.rst
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/docs/analyzer/user-docs.rst?rev=365639&view=auto
==
--- cfe/trunk/docs/analyzer/user-docs.rst (added)
+++ cfe/trunk/docs/analyzer/user-docs.rst Wed Jul 10 07:49:53 2019
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:


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


r365638 - Remove two unused member variables.

2019-07-10 Thread Nico Weber via cfe-commits
Author: nico
Date: Wed Jul 10 07:49:36 2019
New Revision: 365638

URL: http://llvm.org/viewvc/llvm-project?rev=365638&view=rev
Log:
Remove two unused member variables.

They were added over 10 years ago in r66575 and have never been used as
far as I can tell.

(r67087 added similar fields to Compilation, and those are used.)

Modified:
cfe/trunk/include/clang/Driver/Driver.h

Modified: cfe/trunk/include/clang/Driver/Driver.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Driver/Driver.h?rev=365638&r1=365637&r2=365638&view=diff
==
--- cfe/trunk/include/clang/Driver/Driver.h (original)
+++ cfe/trunk/include/clang/Driver/Driver.h Wed Jul 10 07:49:36 2019
@@ -235,9 +235,6 @@ private:
   /// Certain options suppress the 'no input files' warning.
   unsigned SuppressMissingInputWarning : 1;
 
-  std::list TempFiles;
-  std::list ResultFiles;
-
   /// Cache of all the ToolChains in use by the driver.
   ///
   /// This maps from the string representation of a triple to a ToolChain


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


[PATCH] D64494: [analyzer]Add user docs rst

2019-07-10 Thread Gabor Marton via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365639: [analyzer]Add user docs rst (authored by martong, 
committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D64494?vs=208958&id=208966#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D64494

Files:
  cfe/trunk/docs/ClangStaticAnalyzer.rst
  cfe/trunk/docs/analyzer/user-docs.rst


Index: cfe/trunk/docs/analyzer/user-docs.rst
===
--- cfe/trunk/docs/analyzer/user-docs.rst
+++ cfe/trunk/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: cfe/trunk/docs/ClangStaticAnalyzer.rst
===
--- cfe/trunk/docs/ClangStaticAnalyzer.rst
+++ cfe/trunk/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, 
C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic 
execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 


Index: cfe/trunk/docs/analyzer/user-docs.rst
===
--- cfe/trunk/docs/analyzer/user-docs.rst
+++ cfe/trunk/docs/analyzer/user-docs.rst
@@ -0,0 +1,4 @@
+User Docs
+=
+
+Contents:
Index: cfe/trunk/docs/ClangStaticAnalyzer.rst
===
--- cfe/trunk/docs/ClangStaticAnalyzer.rst
+++ cfe/trunk/docs/ClangStaticAnalyzer.rst
@@ -5,15 +5,16 @@
 The Clang Static Analyzer is a source code analysis tool that finds bugs in C, C++, and Objective-C programs.
 It implements *path-sensitive*, *inter-procedural analysis* based on *symbolic execution* technique.
 
-This is the Static Analyzer documentation page. 
+This is the Static Analyzer documentation page.
 
 See the `Official Tool Page `_.
 
 .. toctree::
:caption: Table of Contents
:numbered:
-   :maxdepth: 2  
- 
+   :maxdepth: 2
+
analyzer/checkers
+   analyzer/user-docs
analyzer/developer-docs
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: clang/lib/Basic/Targets/AArch64.cpp:237
+break;
+  case llvm::AArch64::ArchKind::ARMV8_4A:
+getTargetDefinesARMV84A(Opts, Builder);

SjoerdMeijer wrote:
> It is a good change, but I think you should either add tests for these cases, 
> or remove this (temporarily) because it is not adding much at the moment.
Ah, sorry: "-march=armv8.4-a also enables this"
probably good to add some tests for v8.4 and v8.5 too then.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64495



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


[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

2019-07-10 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:41
+// namespace.
+if (const auto UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);

nit: const auto *



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:42
+if (const auto UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
+}

nit: you miss a `return`



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
 // This check is for not getting two entries when there are anonymous
 // structs. It also makes us not highlight namespace qualifiers. For
 // elaborated types the actual type is highlighted as an inner TypeLoc.

this comment is stale with this patch, now we are highlighting namespace, it 
seems more natural to do it here, we can get a NestedNameSpecifierLoc from an 
`ElaboratedTypeLoc ` (so that we don't need the 
`TraverseNestedNameSpecifierLoc`).



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:247
+  case HighlightingKind::Namespace:
+return "entity.name.type.namespace.cpp";
   case HighlightingKind::NumKinds:

I think here should be `entity.name.namespace.cpp`, vscode uses this TX scope 
for namespace.



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:114
+R"cpp(
+  namespace $Namespace[[abc]] {
+namespace $Namespace[[bcd]] {

could you add a testcase for anonymous namespace?

`namespace {}`



Comment at: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp:119
+struct $Class[[A]] {
+  static enum class $Enum[[B]] {
+Hi,

nit: the `static` is not needed for a type.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492



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


[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer added inline comments.



Comment at: llvm/lib/Target/AArch64/AArch64InstrInfo.td:720
 def FJCVTZS  : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
-  "fjcvtzs", []> {
+  "fjcvtzs", [(set GPR32:$Rd, 
(int_aarch64_fjcvtzs FPR64:$Rn))]> {
   let Inst{31} = 0;

and a last nit: this needs some reformatting (exceeding the max column width)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64495



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


[PATCH] D63756: [AMDGPU] Increased the number of implicit argument bytes for both OpenCL and HIP (CLANG).

2019-07-10 Thread Christudasan Devadasan via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365643: [AMDGPU] Increased the number of implicit argument 
bytes for both OpenCL and… (authored by cdevadas, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63756?vs=206377&id=208969#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63756

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
  cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl


Index: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
===
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
@@ -158,30 +158,30 @@
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
-
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_SGPR_32]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_NUM_VGPR_64]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-sgpr"="32" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-implicitarg-num-bytes"="48" 
"amdgpu-num-vgpr"="64" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32_NUM_VGPR_64]] = { convergent noinline 
nounwind optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-num-vgpr"="64" 
-
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
"amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_SGPR_32]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
"amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes 
[[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2_4_NUM_VGPR_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
"amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-

r365643 - [AMDGPU] Increased the number of implicit argument bytes for both OpenCL and HIP (CLANG).

2019-07-10 Thread Christudasan Devadasan via cfe-commits
Author: cdevadas
Date: Wed Jul 10 08:10:08 2019
New Revision: 365643

URL: http://llvm.org/viewvc/llvm-project?rev=365643&view=rev
Log:
[AMDGPU] Increased the number of implicit argument bytes for both OpenCL and 
HIP (CLANG).

To enable a new implicit kernel argument,
increased the number of argument bytes from 48 to 56.

Reviewed By: yaxunl

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=365643&r1=365642&r2=365643&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 10 08:10:08 2019
@@ -7910,7 +7910,7 @@ void AMDGPUTargetCodeGenInfo::setTargetA
   if (((M.getLangOpts().OpenCL && FD->hasAttr()) ||
   (M.getLangOpts().HIP && FD->hasAttr())) &&
   (M.getTriple().getOS() == llvm::Triple::AMDHSA))
-F->addFnAttr("amdgpu-implicitarg-num-bytes", "48");
+F->addFnAttr("amdgpu-implicitarg-num-bytes", "56");
 
   const auto *FlatWGS = FD->getAttr();
   if (ReqdWGS || FlatWGS) {

Modified: cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu?rev=365643&r1=365642&r2=365643&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/amdgpu-hip-implicit-kernarg.cu Wed Jul 10 
08:10:08 2019
@@ -5,4 +5,4 @@
 __global__ void hip_kernel_temp() {
 }
 
-// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="48"
+// CHECK: attributes {{.*}} = {{.*}} "amdgpu-implicitarg-num-bytes"="56"

Modified: cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl?rev=365643&r1=365642&r2=365643&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/amdgpu-attrs.cl Wed Jul 10 08:10:08 2019
@@ -158,30 +158,30 @@ void a_function() {
 // CHECK-NOT: "amdgpu-num-sgpr"="0"
 // CHECK-NOT: "amdgpu-num-vgpr"="0"
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="48" 
-// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2,4"
-// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-sgpr"="32" 
-// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="48" "amdgpu-num-vgpr"="64" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="56" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_64_64]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="64,64" 
"amdgpu-implicitarg-num-bytes"="56" 
+// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_16_128]] = { convergent 
noinline nounwind optnone "amdgpu-flat-work-group-size"="16,128" 
"amdgpu-implicitarg-num-bytes"="56" 
+// CHECK-DAG: attributes [[WAVES_PER_EU_2]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2"
+// CHECK-DAG: attributes [[WAVES_PER_EU_2_4]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-waves-per-eu"="2,4"
+// CHECK-DAG: attributes [[NUM_SGPR_32]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-sgpr"="32" 
+// CHECK-DAG: attributes [[NUM_VGPR_64]] = { convergent noinline nounwind 
optnone "amdgpu-implicitarg-num-bytes"="56" "amdgpu-num-vgpr"="64" 
 
-// CHECK-DAG: attributes [[FLAT_WORK_GROUP_SIZE_32_64_WAVES_PER_EU_2]] = { 
convergent noinline nounwind optnone "amdgpu-flat-work-group-size"="32,64" 
"amdgpu-implicitarg-num-bytes"="48" "amdgpu-waves-per-eu"="2"
-// CHECK-DAG: attributes [[FLAT_WORK_GRO

[PATCH] D63932: [GlobalDCE] Dead Virtual Function Elimination

2019-07-10 Thread Peter Collingbourne via Phabricator via cfe-commits
pcc added a comment.

Hi Oliver, thanks for working on this. This is something that I've always 
wanted to do with the type metadata but never had time to work on. I'll try to 
take a more in depth look later this week.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63932



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


[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 208974.
xbolva00 added a comment.

Rebased, improved.


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

https://reviews.llvm.org/D63192

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaStmt.cpp
  test/SemaCXX/switch_default.cpp
  test/SemaCXX/uninitialized.cpp

Index: test/SemaCXX/uninitialized.cpp
===
--- test/SemaCXX/uninitialized.cpp
+++ test/SemaCXX/uninitialized.cpp
@@ -1444,8 +1444,8 @@
   if (int n = 0; (n == k || k > 5)) {}
 
   if (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n = 0; (n == k || k > 5)) {} // expected-warning {{boolean}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}} expected-warning {{boolean}}
 }
Index: test/SemaCXX/switch_default.cpp
===
--- test/SemaCXX/switch_default.cpp
+++ test/SemaCXX/switch_default.cpp
@@ -0,0 +1,41 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wall %s
+
+void test(int x) {
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+break;
+  }
+
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+x++;
+  }
+
+  switch (x) {
+  default:; // expected-warning {{switch contains only default label}}
+  }
+
+  switch (x)
+  default: // expected-warning {{switch contains only default label}}
+break;
+
+  switch (x) {
+  default:
+return;
+  case 1:
+break;
+  }
+
+  switch (x) {
+  case 1:
+break;
+  default:
+return;
+  }
+
+  switch (x) { // expected-warning {{switch has no default and case labels}}
+  }
+}
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -865,8 +865,13 @@
 
   bool CaseListIsErroneous = false;
 
-  for (SwitchCase *SC = SS->getSwitchCaseList(); SC && !HasDependentValue;
-   SC = SC->getNextSwitchCase()) {
+  SwitchCase *SC = SS->getSwitchCaseList();
+  if (!SC)
+Diag(SS->getBeginLoc(), diag::warn_no_cases_in_switch);
+  else if (isa(SC) && !SC->getNextSwitchCase())
+Diag(SC->getBeginLoc(), diag::warn_default_only_in_switch);
+
+  for (; SC && !HasDependentValue; SC = SC->getNextSwitchCase()) {
 
 if (DefaultStmt *DS = dyn_cast(SC)) {
   if (TheDefaultStmt) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8201,6 +8201,10 @@
 def warn_break_binds_to_switch : Warning<
   "'break' is bound to loop, GCC binds it to switch">,
   InGroup;
+def warn_no_cases_in_switch : Warning<
+  "switch has no default and case labels">, InGroup, DefaultIgnore;
+def warn_default_only_in_switch : Warning<
+  "switch contains only default label">, InGroup, DefaultIgnore;
 def err_default_not_in_switch : Error<
   "'default' statement not in switch statement">;
 def err_case_not_in_switch : Error<"'case' statement not in switch statement">;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -458,7 +458,6 @@
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
 def : DiagGroup<"stack-protector">;
-def : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
@@ -537,6 +536,7 @@
 def ObjCCStringFormat : DiagGroup<"cstring-format-directive">;
 def CoveredSwitchDefault : DiagGroup<"covered-switch-default">;
 def SwitchBool : DiagGroup<"switch-bool">;
+def SwitchDefault  : DiagGroup<"switch-default">;
 def SwitchEnum : DiagGroup<"switch-enum">;
 def Switch : DiagGroup<"switch">;
 def EnumCompareSwitch : DiagGroup<"enum-compare-switch">;
@@ -842,7 +842,7 @@
 // Note that putting warnings in -Wall will not disable them by default. If a
 // warning should be active _only_ when -Wall is passed in, mark it as
 // DefaultIgnore in addition to putting it here.
-def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool]>;
+def All : DiagGroup<"all", [Most, Parentheses, Switch, SwitchBool, SwitchDefault]>;
 
 // Warnings that should be in clang-cl /w4.
 def : DiagGroup<"CL4", [All, Extra]>;

[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

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

In D63192#1539605 , @xbolva00 wrote:

> I will work on this after we land https://reviews.llvm.org/D63139.


^ not yet landed, but please @aaron.ballman  take a look, this patch is ready 
for review.


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

https://reviews.llvm.org/D63192



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


[PATCH] D64504: Various minor tweaks to CLCompatOptions.td

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

- Add back indentation I accidentally removed in r364901
- Wrap two lines to 80 cols
- Slightly tighten up help text for several flags
- Consistently use "Do not" instead of "Don't"
- Make every option description start with a verb
- Use "Set" instead of "Specify"
- Mark default values of options more consistently
- Remove text about "/Zi" not producing PDBs since it's confusing for people 
not intimately familiar with the implementation of the normal PDB pipeline. /Zi 
lets the linker produce PDBs, which is what most users want.
- Consistently use "file" over "filename" in meta var names, consistently use 
"file name" over "filename" in text
- Make all output setting options have consistent language

Hopefully makes help output a bit easier to read.
Also makes help for most flags in the "CL COMPAT FLAGS" section fit in an 80 
column terminal.


https://reviews.llvm.org/D64504

Files:
  clang/include/clang/Driver/CLCompatOptions.td

Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -52,21 +52,21 @@
 // already in the right group.)
 
 def _SLASH_Brepro : CLFlag<"Brepro">,
-  HelpText<"Emit an object file which can be reproduced over time">,
+  HelpText<"Do not write current time into COFF output (breaks link.exe /incremental)">,
   Alias;
 def _SLASH_Brepro_ : CLFlag<"Brepro-">,
-  HelpText<"Emit an object file which cannot be reproduced over time">,
+  HelpText<"Write current time into COFF output (default)">,
   Alias;
 def _SLASH_C : CLFlag<"C">,
-  HelpText<"Don't discard comments when preprocessing">, Alias;
+  HelpText<"Do not discard comments when preprocessing">, Alias;
 def _SLASH_c : CLFlag<"c">, HelpText<"Compile only">, Alias;
 def _SLASH_d1PP : CLFlag<"d1PP">,
   HelpText<"Retain macro definitions in /E mode">, Alias;
 def _SLASH_d1reportAllClassLayout : CLFlag<"d1reportAllClassLayout">,
   HelpText<"Dump record layout information">,
-Alias, AliasArgs<["-fdump-record-layouts"]>;
+  Alias, AliasArgs<["-fdump-record-layouts"]>;
 def _SLASH_diagnostics_caret : CLFlag<"diagnostics:caret">,
-  HelpText<"Enable caret and column diagnostics (on by default)">;
+  HelpText<"Enable caret and column diagnostics (default)">;
 def _SLASH_diagnostics_column : CLFlag<"diagnostics:column">,
   HelpText<"Disable caret diagnostics but keep column info">;
 def _SLASH_diagnostics_classic : CLFlag<"diagnostics:classic">,
@@ -83,12 +83,14 @@
 def _SLASH_fp_strict : CLFlag<"fp:strict">, HelpText<"">, Alias;
 def _SLASH_GA : CLFlag<"GA">, Alias, AliasArgs<["local-exec"]>,
   HelpText<"Assume thread-local variables are defined in the executable">;
-def _SLASH_GR : CLFlag<"GR">, HelpText<"Enable emission of RTTI data">;
-def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Disable emission of RTTI data">;
-def _SLASH_GF : CLIgnoredFlag<"GF">, HelpText<"Enable string pooling (default)">;
+def _SLASH_GR : CLFlag<"GR">, HelpText<"Emit RTTI data (default)">;
+def _SLASH_GR_ : CLFlag<"GR-">, HelpText<"Do not emit RTTI data">;
+def _SLASH_GF : CLIgnoredFlag<"GF">,
+  HelpText<"Enable string pooling (default)">;
 def _SLASH_GF_ : CLFlag<"GF-">, HelpText<"Disable string pooling">,
   Alias;
-def _SLASH_GS : CLFlag<"GS">, HelpText<"Enable buffer security check (default)">;
+def _SLASH_GS : CLFlag<"GS">,
+  HelpText<"Enable buffer security check (default)">;
 def _SLASH_GS_ : CLFlag<"GS-">, HelpText<"Disable buffer security check">;
 def : CLFlag<"Gs">, HelpText<"Use stack probes (default)">,
   Alias, AliasArgs<["4096"]>;
@@ -102,7 +104,7 @@
 def _SLASH_Gw : CLFlag<"Gw">, HelpText<"Put each data item in its own section">,
   Alias;
 def _SLASH_Gw_ : CLFlag<"Gw-">,
-  HelpText<"Don't put each data item in its own section">,
+  HelpText<"Don't put each data item in its own section (default)">,
   Alias;
 def _SLASH_help : CLFlag<"help">, Alias,
   HelpText<"Display available options">;
@@ -121,13 +123,13 @@
 // FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
 def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
-  HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for size  (like /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,
-  HelpText<"Optimize for speed (same as /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
+  HelpText<"Optimize for speed (like /Og /Oi /Ot /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"Ob0">, Alias<_SLASH_O>, AliasArgs<["b0"]>,
   HelpText<"Disable function inlining">;
 def : CLFlag<"Ob1">, Alias<_SLASH_O>, AliasArgs<["b1"]>,
-  HelpText<"Only inline functions which are (explicitly or implicitly) marked inline">;
+  HelpText<"Only inline functions explicitly or implicitly marked inline">;
 def : CLFlag<"Ob2">, Alias<_SLASH_O>, AliasArgs<["b2"]>,
   Hel

[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Kyrill Tkachov via Phabricator via cfe-commits
ktkachov updated this revision to Diff 208980.
ktkachov added a comment.

Add more CHECK-LABEL tests, test v8.4a and v8.5a features. Fix formatting in 
pattern.


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

https://reviews.llvm.org/D64495

Files:
  clang/include/clang/Basic/BuiltinsAArch64.def
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Basic/Targets/AArch64.h
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Headers/arm_acle.h
  clang/test/CodeGen/arm_acle.c
  clang/test/CodeGen/builtins-arm64.c
  llvm/include/llvm/IR/IntrinsicsAArch64.td
  llvm/lib/Target/AArch64/AArch64InstrInfo.td
  llvm/test/CodeGen/AArch64/fjcvtzs.ll

Index: llvm/test/CodeGen/AArch64/fjcvtzs.ll
===
--- /dev/null
+++ llvm/test/CodeGen/AArch64/fjcvtzs.ll
@@ -0,0 +1,10 @@
+; RUN: llc -mtriple=arm64-eabi -mattr=+jsconv -o - %s | FileCheck %s
+
+define i32 @test_jcvt(double %v) {
+; CHECK-LABEL: test_jcvt:
+; CHECK: fjcvtzs w0, d0
+  %val = call i32 @llvm.aarch64.fjcvtzs(double %v)
+  ret i32 %val
+}
+
+declare i32 @llvm.aarch64.fjcvtzs(double)
Index: llvm/lib/Target/AArch64/AArch64InstrInfo.td
===
--- llvm/lib/Target/AArch64/AArch64InstrInfo.td
+++ llvm/lib/Target/AArch64/AArch64InstrInfo.td
@@ -717,7 +717,9 @@
 // v8.3a floating point conversion for javascript
 let Predicates = [HasJS, HasFPARMv8] in
 def FJCVTZS  : BaseFPToIntegerUnscaled<0b01, 0b11, 0b110, FPR64, GPR32,
-  "fjcvtzs", []> {
+  "fjcvtzs",
+  [(set GPR32:$Rd,
+ (int_aarch64_fjcvtzs FPR64:$Rn))]> {
   let Inst{31} = 0;
 } // HasJS, HasFPARMv8
 
Index: llvm/include/llvm/IR/IntrinsicsAArch64.td
===
--- llvm/include/llvm/IR/IntrinsicsAArch64.td
+++ llvm/include/llvm/IR/IntrinsicsAArch64.td
@@ -31,6 +31,8 @@
 def int_aarch64_udiv : Intrinsic<[llvm_anyint_ty], [LLVMMatchType<0>,
 LLVMMatchType<0>], [IntrNoMem]>;
 
+def int_aarch64_fjcvtzs : Intrinsic<[llvm_i32_ty], [llvm_double_ty], [IntrNoMem]>;
+
 //===--===//
 // HINT
 
Index: clang/test/CodeGen/builtins-arm64.c
===
--- clang/test/CodeGen/builtins-arm64.c
+++ clang/test/CodeGen/builtins-arm64.c
@@ -58,6 +58,12 @@
 // CHECK: call {{.*}} @llvm.prefetch(i8* null, i32 0, i32 3, i32 0)
 }
 
+int32_t jcvt(double v) {
+  //CHECK-LABEL: @jcvt(
+  //CHECK: call i32 @llvm.aarch64.fjcvtzs
+  return __builtin_arm_jcvt(v);
+}
+
 __typeof__(__builtin_arm_rsr("1:2:3:4:5")) rsr(void);
 
 uint32_t rsr() {
Index: clang/test/CodeGen/arm_acle.c
===
--- clang/test/CodeGen/arm_acle.c
+++ clang/test/CodeGen/arm_acle.c
@@ -2,6 +2,9 @@
 // RUN: %clang_cc1 -ffreestanding -triple armv8-eabi -target-cpu cortex-a57 -O2  -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch32 -check-prefix=ARM-NEWPM -check-prefix=AArch32-NEWPM
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fno-experimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-LEGACY -check-prefix=AArch64-LEGACY
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +neon -target-feature +crc -target-feature +crypto -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM -check-prefix=AArch64-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 -target-feature +v8.5a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
 
 #include 
 
@@ -823,3 +826,11 @@
 
 // AArch64: ![[M0]] = !{!"1:2:3:4:5"}
 // AArch64: ![[M1]] = !{!"sysreg"}
+
+// CHECK-LABEL: @test_jcvt(
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs
+#ifdef __ARM_64BIT_STATE
+int32_t test_jcvt(double v) {
+  return __jcvt(v);
+}
+#endif
Index: clang/lib/Headers/arm_acle.h
===
--- clang/lib/Headers/arm_acle

[PATCH] D64506: clang-cl: Remove -O0 option

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis created this revision.
thakis added a reviewer: rnk.

cl.exe doesn't understand it; there's /Od instead. See also the review
thread for r229575.


https://reviews.llvm.org/D64506

Files:
  clang/include/clang/Driver/CLCompatOptions.td


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -118,8 +118,6 @@
 def _SLASH_O : CLJoined<"O">,
   HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
   MetaVarName<"">;
-// FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
-def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
   HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,


Index: clang/include/clang/Driver/CLCompatOptions.td
===
--- clang/include/clang/Driver/CLCompatOptions.td
+++ clang/include/clang/Driver/CLCompatOptions.td
@@ -118,8 +118,6 @@
 def _SLASH_O : CLJoined<"O">,
   HelpText<"Set multiple /O flags at once; e.g. '/O2y-' for '/O2 /Oy-'">,
   MetaVarName<"">;
-// FIXME: Not sure why we have -O0 here; MSVC doesn't support that.
-def : CLFlag<"O0">, Alias, HelpText<"Disable optimization">;
 def : CLFlag<"O1">, Alias<_SLASH_O>, AliasArgs<["1"]>,
   HelpText<"Optimize for size  (same as /Og /Os /Oy /Ob2 /GF /Gy)">;
 def : CLFlag<"O2">, Alias<_SLASH_O>, AliasArgs<["2"]>,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D64506: clang-cl: Remove -O0 option

2019-07-10 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

I did check that we now warn, like you had requested:

  $ out/gn/bin/clang-cl test.cc /O0 /c
  clang: warning: argument unused during compilation: '/O0' 
[-Wunused-command-line-argument]

Adding a test for that felt weird though, so I didn't.


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

https://reviews.llvm.org/D64506



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


[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Dávid Bolvanský via Phabricator via cfe-commits
xbolva00 updated this revision to Diff 208984.

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

https://reviews.llvm.org/D63192

Files:
  include/clang/Basic/DiagnosticGroups.td
  include/clang/Basic/DiagnosticSemaKinds.td
  lib/Sema/SemaStmt.cpp
  test/Sema/switch-availability.c
  test/SemaCXX/switch_default.cpp
  test/SemaCXX/uninitialized.cpp

Index: test/SemaCXX/uninitialized.cpp
===
--- test/SemaCXX/uninitialized.cpp
+++ test/SemaCXX/uninitialized.cpp
@@ -1444,8 +1444,8 @@
   if (int n = 0; (n == k || k > 5)) {}
 
   if (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n = 0; (n == k || k > 5)) {} // expected-warning {{boolean}}
-
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (int n; (n == k || k > 5)) {} // expected-warning {{uninitialized}} expected-note {{initialize}} expected-warning {{boolean}}
 }
Index: test/SemaCXX/switch_default.cpp
===
--- test/SemaCXX/switch_default.cpp
+++ test/SemaCXX/switch_default.cpp
@@ -0,0 +1,38 @@
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wswitch-default %s
+// RUN: %clang_cc1 -x c -fsyntax-only -verify -Wall %s
+// RUN: %clang_cc1 -x c++ -fsyntax-only -verify -Wall %s
+
+void test(int x) {
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+break;
+  }
+
+  switch (x) {
+  default: // expected-warning {{switch contains only default label}}
+x++;
+  }
+
+  switch (x) {
+  default:; // expected-warning {{switch contains only default label}}
+  }
+
+  switch (x)
+  default: // expected-warning {{switch contains only default label}}
+break;
+
+  switch (x) {
+  default:
+return;
+  case 1:
+break;
+  }
+
+  switch (x) {
+  case 1:
+break;
+  default:
+return;
+  }
+}
Index: test/Sema/switch-availability.c
===
--- test/Sema/switch-availability.c
+++ test/Sema/switch-availability.c
@@ -5,7 +5,7 @@
 };
 
 void testSwitchOne(enum SwitchOne so) {
-  switch (so) {} // no warning
+  switch (so) {} // expected-warning {{switch has no default and case labels}}
 }
 
 enum SwitchTwo {
@@ -15,6 +15,7 @@
 };
 
 void testSwitchTwo(enum SwitchTwo st) {
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (st) {} // expected-warning{{enumeration values 'Vim' and 'Emacs' not handled in switch}}
 }
 
@@ -23,5 +24,6 @@
 };
 
 void testSwitchThree(enum SwitchThree st) {
+  // expected-warning@+1 {{switch has no default and case labels}}
   switch (st) {} // expected-warning{{enumeration value 'New' not handled in switch}}
 }
Index: lib/Sema/SemaStmt.cpp
===
--- lib/Sema/SemaStmt.cpp
+++ lib/Sema/SemaStmt.cpp
@@ -865,8 +865,13 @@
 
   bool CaseListIsErroneous = false;
 
-  for (SwitchCase *SC = SS->getSwitchCaseList(); SC && !HasDependentValue;
-   SC = SC->getNextSwitchCase()) {
+  SwitchCase *SC = SS->getSwitchCaseList();
+  if (!SC)
+Diag(SS->getBeginLoc(), diag::warn_no_cases_in_switch);
+  else if (isa(SC) && !SC->getNextSwitchCase())
+Diag(SC->getBeginLoc(), diag::warn_default_only_in_switch);
+
+  for (; SC && !HasDependentValue; SC = SC->getNextSwitchCase()) {
 
 if (DefaultStmt *DS = dyn_cast(SC)) {
   if (TheDefaultStmt) {
Index: include/clang/Basic/DiagnosticSemaKinds.td
===
--- include/clang/Basic/DiagnosticSemaKinds.td
+++ include/clang/Basic/DiagnosticSemaKinds.td
@@ -8201,6 +8201,10 @@
 def warn_break_binds_to_switch : Warning<
   "'break' is bound to loop, GCC binds it to switch">,
   InGroup;
+def warn_no_cases_in_switch : Warning<
+  "switch has no default and case labels">, InGroup, DefaultIgnore;
+def warn_default_only_in_switch : Warning<
+  "switch contains only default label">, InGroup, DefaultIgnore;
 def err_default_not_in_switch : Error<
   "'default' statement not in switch statement">;
 def err_case_not_in_switch : Error<"'case' statement not in switch statement">;
Index: include/clang/Basic/DiagnosticGroups.td
===
--- include/clang/Basic/DiagnosticGroups.td
+++ include/clang/Basic/DiagnosticGroups.td
@@ -458,7 +458,6 @@
 def : DiagGroup<"sign-promo">;
 def SignCompare : DiagGroup<"sign-compare">;
 def : DiagGroup<"stack-protector">;
-def : DiagGroup<"switch-default">;
 def : DiagGroup<"synth">;
 def SizeofArrayArgument : DiagGroup<"sizeof-array-argument">;
 def SizeofArrayDecay : DiagGroup<"sizeof-array-decay">;
@@ -537,6 +536,7 @@
 def ObjCCStringFormat : DiagGroup<"cstring-format-directive">;
 def CoveredSwitchDefault : Diag

[PATCH] D64495: [AArch64] Implement __jcvt intrinsic from Armv8.3-A

2019-07-10 Thread Sjoerd Meijer via Phabricator via cfe-commits
SjoerdMeijer accepted this revision.
SjoerdMeijer added a comment.
This revision is now accepted and ready to land.

Looks like a good change to me, some nits inlined.

It shouldn't be difficult to request an account and commit it yourself, which 
might be useful if you maybe intend to submit more patches. 
But I can of course easily commit this on your behalf, just let me know. If you 
want me to commit this, it is easiest if you do upload a new diff with the nits 
fixed.




Comment at: clang/test/CodeGen/arm_acle.c:5
 // RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +neon -target-feature +crc -target-feature +crypto -O2 
-fexperimental-new-pass-manager -S -emit-llvm -o - %s | FileCheck %s 
-check-prefix=ARM -check-prefix=AArch64 -check-prefix=ARM-NEWPM 
-check-prefix=AArch64-NEWPM
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.3a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL
+// RUN: %clang_cc1 -ffreestanding -triple aarch64-eabi -target-cpu cortex-a57 
-target-feature +v8.4a -O2 -fexperimental-new-pass-manager -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix=AArch64-v8_3 -check-prefix=CHECK-LABEL

Some nits that you can fix before committing; no need for another review I 
think.

You can remove: 

  -check-prefix=CHECK-LABEL

in all these 3 lines below.



Comment at: clang/test/CodeGen/arm_acle.c:830
+
+// CHECK-LABEL: @test_jcvt(
+// AArch64-v8_3: call i32 @llvm.aarch64.fjcvtzs

and change 

  // CHECK-LABEL: @test_jcvt(

into 

   // AArch64-v8_3-LABEL: @test_jcvt(


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

https://reviews.llvm.org/D64495



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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

In D64454#1578352 , @aaron.ballman 
wrote:

> I'm worried that this will continue to drift out of sync with the static 
> analyzer checks unless we find some way to automate it. I wonder if we could 
> write a script to generate these .rst files and somehow fit it into the 
> workflow for adding new static analyzer checks to re-run the script to 
> produce new files (or modified files) as needed? @NoQ and @Szelethus may have 
> ideas.


I totally agree. The list of checkers changes fairly often.

The checkers are listed in a machine-readable tablegen file, 
`include/clang/StaticAnalyzer/Checkers/Checkers.td`.

Note that some of the checkers in the list don't emit any warnings (which is 
fine in the Static Analyzer as checkers can interact with each other and the 
only purpose of these checkers is to make other checkers be more correct). 
There's a related set of checkers that are "hidden" (marked as Hidden in 
`Checkers.td`) - those checkers that we don't support enabling/disabling 
manually, so you should probably not list them either. I think currently all or 
most of the non-warning checkers are also hidden.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64400: [OpenCL][PR42390] Deduce addr space for templ specialization

2019-07-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia updated this revision to Diff 208993.
Anastasia marked 2 inline comments as done.
Anastasia added a comment.

- Added handling of similar test case with `InjectedClassNameType`


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

https://reviews.llvm.org/D64400

Files:
  include/clang/AST/Type.h
  lib/Sema/SemaType.cpp
  test/SemaOpenCLCXX/address-space-deduction.cl


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -38,3 +38,41 @@
   int foo[10];
   xxx(&foo[0]);
 }
+
+// Deducing addr spaces for template specialization is fine
+// addr space of template arg can't affecting the addr space
+// of specialization
+
+template 
+struct x1 {
+//CHECK: -CXXMethodDecl {{.*}} operator= '__generic x1 &(const __generic 
x1 &) __generic'
+  x1& operator=(const x1& xx) {
+y = xx.y;
+return *this;
+  }
+  int y;
+};
+
+template 
+struct x2 {
+//CHECK: -CXXMethodDecl {{.*}} foo 'void (__generic x1 *) __generic'
+  void foo(x1* xx) {
+m[0] = *xx;
+  }
+//CHECK: -FieldDecl {{.*}}  m 'x1 [2]'
+  x1 m[2];
+};
+
+void bar(__global x1 *xx, __global x2 *bar) {
+  bar->foo(xx);
+}
+
+template 
+class x3 : public T {
+public:
+  //CHECK: -CXXConstructorDecl {{.*}} x3 'void (const __generic x3 &) 
__generic'
+  x3(const x3 &t);
+};
+//CHECK: -CXXConstructorDecl {{.*}} 'void (const __generic x3 &) __generic'
+template 
+x3::x3(const x3 &t) {}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7414,9 +7414,14 @@
   (T->isVoidType() && !IsPointee) ||
   // Do not deduce addr spaces for dependent types because they might end
   // up instantiating to a type with an explicit address space qualifier.
-  // Expect for pointer or reference types because the addr space in
-  // template argument can only belong to a pointee.
-  (T->isDependentType() && !T->isPointerType() && !T->isReferenceType()) ||
+  // Except for:
+  // - pointer or reference types because the addr space in template
+  //   argument can only belong to a pointee.
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() &&
+   (!T->isPointerType() && !T->isReferenceType() &&
+!T->isTemplateSpecializationType() && !T->isInjectedClassNameType())) 
||
   // Do not deduce addr space of decltype because it will be taken from
   // its argument.
   T->isDecltypeType() ||
Index: include/clang/AST/Type.h
===
--- include/clang/AST/Type.h
+++ include/clang/AST/Type.h
@@ -1981,6 +1981,8 @@
   bool isObjCBoxableRecordType() const;
   bool isInterfaceType() const;
   bool isStructureOrClassType() const;
+  bool isTemplateSpecializationType() const;
+  bool isInjectedClassNameType() const;
   bool isUnionType() const;
   bool isComplexIntegerType() const;// GCC _Complex integer type.
   bool isVectorType() const;// GCC vector type.
@@ -6507,6 +6509,14 @@
   return isa(this);
 }
 
+inline bool Type::isTemplateSpecializationType() const {
+  return isa(this);
+}
+
+inline bool Type::isInjectedClassNameType() const {
+  return isa(this);
+}
+
 #define IMAGE_TYPE(ImgType, Id, SingletonId, Access, Suffix) \
   inline bool Type::is##Id##Type() const { \
 return isSpecificBuiltinType(BuiltinType::Id); \


Index: test/SemaOpenCLCXX/address-space-deduction.cl
===
--- test/SemaOpenCLCXX/address-space-deduction.cl
+++ test/SemaOpenCLCXX/address-space-deduction.cl
@@ -38,3 +38,41 @@
   int foo[10];
   xxx(&foo[0]);
 }
+
+// Deducing addr spaces for template specialization is fine
+// addr space of template arg can't affecting the addr space
+// of specialization
+
+template 
+struct x1 {
+//CHECK: -CXXMethodDecl {{.*}} operator= '__generic x1 &(const __generic x1 &) __generic'
+  x1& operator=(const x1& xx) {
+y = xx.y;
+return *this;
+  }
+  int y;
+};
+
+template 
+struct x2 {
+//CHECK: -CXXMethodDecl {{.*}} foo 'void (__generic x1 *) __generic'
+  void foo(x1* xx) {
+m[0] = *xx;
+  }
+//CHECK: -FieldDecl {{.*}}  m 'x1 [2]'
+  x1 m[2];
+};
+
+void bar(__global x1 *xx, __global x2 *bar) {
+  bar->foo(xx);
+}
+
+template 
+class x3 : public T {
+public:
+  //CHECK: -CXXConstructorDecl {{.*}} x3 'void (const __generic x3 &) __generic'
+  x3(const x3 &t);
+};
+//CHECK: -CXXConstructorDecl {{.*}} 'void (const __generic x3 &) __generic'
+template 
+x3::x3(const x3 &t) {}
Index: lib/Sema/SemaType.cpp
===
--- lib/Sema/SemaType.cpp
+++ lib/Sema/SemaType.cpp
@@ -7414,9 +7414,14 @@
   (T->isVoidType() && !IsPointe

[PATCH] D64400: [OpenCL][PR42390] Deduce addr space for templ specialization

2019-07-10 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia marked 2 inline comments as done and 2 inline comments as done.
Anastasia added inline comments.



Comment at: include/clang/AST/Type.h:6512
+inline bool Type::isTemplateSpecializationType() const {
+  return isa(this);
+}

rjmccall wrote:
> This is a sugar type.  What are you trying to do?
I just need a helper function to identify this type in the addr space deduction 
logic below. Do you think we shouldn't expose it as interface? 

In fact I am now adding `isInjectedClassNameType` for the same reason to cover 
another similar test case.



Comment at: lib/Sema/SemaType.cpp:7421
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() && (!T->isPointerType() && !T->isReferenceType() &&

rjmccall wrote:
> I don't understand what you're saying here.  Why does inference depend on 
> whether the type is a template specialization?  And what does this have to do 
> with template arguments?  Also, address spaces in template arguments are 
> definitely part of the template argument and affect which specialization 
> you're naming.
What I am trying to say here is that an address space of a template argument 
isn't used as an address space of a template specialization and therefore we 
can deduce the address space of a template specialization since it's not going 
to be provided during the template instantiation.

Let's say we have specialization `MyClass`. The address space of `T` has 
nothing to do with the address space of `MyClass`. They are different. 
Therefore if the address space of `MyClass` is not provided explicitly it is 
ok to deduce it.

Does it make sense?



Comment at: lib/Sema/SemaType.cpp:7421
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() &&

If you think it's reasonable the same would apply to `InjectedClassNameType`.


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

https://reviews.llvm.org/D64400



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


[PATCH] D63835: [Syntax] Add nodes for most common statements

2019-07-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov updated this revision to Diff 208995.
ilya-biryukov added a comment.

- Mark groups of kinds for statements and expressions


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63835

Files:
  clang/include/clang/Tooling/Syntax/Nodes.h
  clang/lib/Tooling/Syntax/BuildTree.cpp
  clang/lib/Tooling/Syntax/Nodes.cpp
  clang/lib/Tooling/Syntax/Tree.cpp
  clang/unittests/Tooling/Syntax/TreeTest.cpp

Index: clang/unittests/Tooling/Syntax/TreeTest.cpp
===
--- clang/unittests/Tooling/Syntax/TreeTest.cpp
+++ clang/unittests/Tooling/Syntax/TreeTest.cpp
@@ -136,19 +136,326 @@
 | |-(
 | |-)
 | `-CompoundStatement
-|   |-2: {
-|   `-3: }
+|   |-{
+|   `-}
 |-TopLevelDeclaration
 | |-void
 | |-foo
 | |-(
 | |-)
 | `-CompoundStatement
-|   |-2: {
-|   `-3: }
+|   |-{
+|   `-}
 `-
 )txt"},
-  };
+  // if.
+  {
+  R"cpp(
+int main() {
+  if (true) {}
+  if (true) {} else if (false) {}
+}
+)cpp",
+  R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-int
+| |-main
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-IfStatement
+|   | |-if
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   `-}
+|   |-IfStatement
+|   | |-if
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | |-CompoundStatement
+|   | | |-{
+|   | | `-}
+|   | |-else
+|   | `-IfStatement
+|   |   |-if
+|   |   |-(
+|   |   |-UnknownExpression
+|   |   | `-false
+|   |   |-)
+|   |   `-CompoundStatement
+|   | |-{
+|   | `-}
+|   `-}
+`-
+)txt"},
+  // for.
+  {R"cpp(
+void test() {
+  for (;;)  {}
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-ForStatement
+|   | |-for
+|   | |-(
+|   | |-;
+|   | |-;
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // declaration statement.
+  {"void test() { int a = 10; }",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-DeclarationStatement
+|   | |-int
+|   | |-a
+|   | |-=
+|   | |-10
+|   | `-;
+|   `-}
+`-
+)txt"},
+  {"void test() { ; }", R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-EmptyStatement
+|   | `-;
+|   `-}
+`-
+)txt"},
+  // switch, case and default.
+  {R"cpp(
+void test() {
+  switch (true) {
+case 0:
+default:;
+  }
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-SwitchStatement
+|   | |-switch
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   |-CaseStatement
+|   |   | |-case
+|   |   | |-UnknownExpression
+|   |   | | `-0
+|   |   | |-:
+|   |   | `-DefaultStatement
+|   |   |   |-default
+|   |   |   |-:
+|   |   |   `-EmptyStatement
+|   |   | `-;
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // while.
+  {R"cpp(
+void test() {
+  while (true) { continue; break; }
+}
+)cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-WhileStatement
+|   | |-while
+|   | |-(
+|   | |-UnknownExpression
+|   | | `-true
+|   | |-)
+|   | `-CompoundStatement
+|   |   |-{
+|   |   |-ContinueStatement
+|   |   | |-continue
+|   |   | `-;
+|   |   |-BreakStatement
+|   |   | |-break
+|   |   | `-;
+|   |   `-}
+|   `-}
+`-
+)txt"},
+  // return.
+  {R"cpp(
+int test() { return 1; }
+  )cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-int
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-ReturnStatement
+|   | |-return
+|   | |-UnknownExpression
+|   | | `-1
+|   | `-;
+|   `-}
+`-
+   )txt"},
+  // Range-based for.
+  {R"cpp(
+void test() {
+  int a[3];
+  for (int x : a) ;
+}
+  )cpp",
+   R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-test
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-DeclarationStatement
+|   | |-int
+|   | |-a
+|   | |-[
+|   | |-3
+|   | |-]
+|   | `-;
+|   |-RangeBasedForStatement
+|   | |-for
+|   | |-(
+|   | |-int
+|   | |-x
+|   | |-:
+|   | |-UnknownExpression
+|   | | `-a
+|   | |-)
+|   | `-EmptyStatement
+|   |   `-;
+|   `-}
+`-
+   )txt"},
+  // Unhandled statements should end up as 'unknown statement'.
+  // This example uses a 'label statement', which does not yet have a syntax
+  // counterpart.
+  {"void main() { foo: return 100; }", R"txt(
+*: TranslationUnit
+|-TopLevelDeclaration
+| |-void
+| |-main
+| |-(
+| |-)
+| `-CompoundStatement
+|   |-{
+|   |-UnknownStatement
+|   | |-foo
+|   | |-:
+|   | `-ReturnState

[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

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

Just thinking aloud!

We were tinkering with the idea of a checker creator script similar to what 
clang-tidy has, that could help on this potentially.

Is generating the rst code with Tblgen a feasable approach? At first glance, it 
sounds like a nightmare to implement, and I wonder whether the maintainers of 
sphinx buildbots would need to adjust to that.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D63835: [Syntax] Add nodes for most common statements

2019-07-10 Thread Ilya Biryukov via Phabricator via cfe-commits
ilya-biryukov added a comment.

This is ready for another round




Comment at: clang/include/clang/Tooling/Syntax/Nodes.h:25
 /// A kind of a syntax node, used for implementing casts.
 enum class NodeKind : uint16_t {
   Leaf,

sammccall wrote:
> there are going to be many of these. I'd suggest either sorting them all, or 
> breaking them into blocks (e.g. statements vs declarations vs leaf/tu/etc) 
> and sorting those blocks.
I've added two blocks now - statements and expressions.
Did not sort, though, I find the semantic grouping (loop statements close to 
each other) more useful, but hard to keep consistent.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D63835



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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

In D64454#1578704 , @Szelethus wrote:

> Just thinking aloud!
>
> We were tinkering with the idea of a checker creator script similar to what 
> clang-tidy has, that could help on this potentially.
>
> Is generating the rst code with Tblgen a feasable approach? At first glance, 
> it sounds like a nightmare to implement, and I wonder whether the maintainers 
> of sphinx buildbots would need to adjust to that.


clang-tidy doesn't currently rely on tablegen for producing docs like we do for 
attributes or command line arguments in Clang itself, but I don't think we need 
that for an initial offering anyway. I'd be happy with a simple python script 
that we execute as-needed (like we do for AST matchers, for instance) to 
generate docs that are committed. I figured that python script could execute a 
tablegen command to offload some of that work. Eventually, we might get to a 
point where that script can then be run on a server like we do elsewhere.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64454: [clang-tidy] Adding static analyzer check to list of clang-tidy checks

2019-07-10 Thread Nathan Huckleberry via Phabricator via cfe-commits
Nathan-Huckleberry added a comment.

In D64454#1578352 , @aaron.ballman 
wrote:

> I'm worried that this will continue to drift out of sync with the static 
> analyzer checks unless we find some way to automate it. I wonder if we could 
> write a script to generate these .rst files and somehow fit it into the 
> workflow for adding new static analyzer checks to re-run the script to 
> produce new files (or modified files) as needed? @NoQ and @Szelethus may have 
> ideas.


I wrote a script to generate these. I can clean it up a bit more and add it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64454



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


[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

2019-07-10 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom updated this revision to Diff 208998.
jvikstrom marked 6 inline comments as done.
jvikstrom added a comment.

Addressed comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492

Files:
  clang-tools-extra/clangd/SemanticHighlighting.cpp
  clang-tools-extra/clangd/SemanticHighlighting.h
  clang-tools-extra/clangd/test/semantic-highlighting.test
  clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp

Index: clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
===
--- clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
+++ clang-tools-extra/clangd/unittests/SemanticHighlightingTests.cpp
@@ -36,7 +36,8 @@
   {HighlightingKind::Variable, "Variable"},
   {HighlightingKind::Function, "Function"},
   {HighlightingKind::Class, "Class"},
-  {HighlightingKind::Enum, "Enum"}};
+  {HighlightingKind::Enum, "Enum"},
+  {HighlightingKind::Namespace, "Namespace"}};
   std::vector ExpectedTokens;
   for (const auto &KindString : KindToString) {
 std::vector Toks = makeHighlightingTokens(
@@ -75,18 +76,18 @@
   };
 )cpp",
 R"cpp(
-  namespace abc {
+  namespace $Namespace[[abc]] {
 template
 struct $Class[[A]] {
   T t;
 };
   }
   template
-  struct $Class[[C]] : abc::A {
+  struct $Class[[C]] : $Namespace[[abc]]::A {
 typename T::A* D;
   };
-  abc::$Class[[A]] $Variable[[AA]];
-  typedef abc::$Class[[A]] AAA;
+  $Namespace[[abc]]::$Class[[A]] $Variable[[AA]];
+  typedef $Namespace[[abc]]::$Class[[A]] AAA;
   struct $Class[[B]] {
 $Class[[B]]();
 ~$Class[[B]]();
@@ -108,6 +109,27 @@
 $Enum[[E]] EEE;
 $Enum[[EE]] ;
   };
+)cpp",
+R"cpp(
+  namespace $Namespace[[abc]] {
+namespace {}
+namespace $Namespace[[bcd]] {
+  struct $Class[[A]] {};
+  namespace $Namespace[[cde]] {
+struct $Class[[A]] {
+  enum class $Enum[[B]] {
+Hi,
+  };
+};
+  }
+}
+  }
+  using namespace $Namespace[[abc]]::$Namespace[[bcd]];
+  namespace $Namespace[[vwz]] =
+$Namespace[[abc]]::$Namespace[[bcd]]::$Namespace[[cde]];
+  $Namespace[[abc]]::$Namespace[[bcd]]::$Class[[A]] $Variable[[AA]];
+  $Namespace[[vwz]]::$Class[[A]]::$Enum[[B]] $Variable[[AAA]] =
+$Namespace[[vwz]]::$Class[[A]]::$Enum[[B]]::Hi;
 )cpp"};
   for (const auto &TestCase : TestCases) {
 checkHighlightings(TestCase);
Index: clang-tools-extra/clangd/test/semantic-highlighting.test
===
--- clang-tools-extra/clangd/test/semantic-highlighting.test
+++ clang-tools-extra/clangd/test/semantic-highlighting.test
@@ -9,12 +9,15 @@
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.function.cpp"
-# CHECK-NEXT:  ]
+# CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.type.class.cpp"
 # CHECK-NEXT:  ],
 # CHECK-NEXT:  [
 # CHECK-NEXT:"entity.name.type.enum.cpp"
+# CHECK-NEXT:  ],
+# CHECK-NEXT:  [
+# CHECK-NEXT:"entity.name.type.namespace.cpp"
 # CHECK-NEXT:  ]
 # CHECK-NEXT:]
 # CHECK-NEXT:  },
Index: clang-tools-extra/clangd/SemanticHighlighting.h
===
--- clang-tools-extra/clangd/SemanticHighlighting.h
+++ clang-tools-extra/clangd/SemanticHighlighting.h
@@ -28,6 +28,7 @@
   Function,
   Class,
   Enum,
+  Namespace,
 
   NumKinds,
 };
Index: clang-tools-extra/clangd/SemanticHighlighting.cpp
===
--- clang-tools-extra/clangd/SemanticHighlighting.cpp
+++ clang-tools-extra/clangd/SemanticHighlighting.cpp
@@ -11,8 +11,6 @@
 #include "Protocol.h"
 #include "SourceCode.h"
 #include "clang/AST/ASTContext.h"
-#include "clang/AST/Decl.h"
-#include "clang/AST/DeclarationName.h"
 #include "clang/AST/RecursiveASTVisitor.h"
 
 namespace clang {
@@ -37,6 +35,14 @@
   }
 
   bool VisitNamedDecl(NamedDecl *ND) {
+// UsingDirectiveDecl's namespaces do not show up anywhere else in the
+// Visit/Traverse mehods. But they should also be highlighted as a
+// namespace.
+if (const auto *UD = dyn_cast(ND)) {
+  addToken(UD->getIdentLocation(), HighlightingKind::Namespace);
+  return true;
+}
+
 // Constructors' TypeLoc has a TypePtr that is a FunctionProtoType. It has
 // no tag decl and therefore constructors must be gotten as NamedDecls
 // instead.
@@ -65,17 +71,28 @@
 
   bool VisitTypeLoc(TypeLoc &TL) {
 // This check is for not getting two entries when there are anonymous
-// structs

[PATCH] D64492: [clangd] Added highlightings for namespace specifiers.

2019-07-10 Thread Johan Vikström via Phabricator via cfe-commits
jvikstrom added inline comments.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:73
 // This check is for not getting two entries when there are anonymous
 // structs. It also makes us not highlight namespace qualifiers. For
 // elaborated types the actual type is highlighted as an inner TypeLoc.

hokein wrote:
> this comment is stale with this patch, now we are highlighting namespace, it 
> seems more natural to do it here, we can get a NestedNameSpecifierLoc from an 
> `ElaboratedTypeLoc ` (so that we don't need the 
> `TraverseNestedNameSpecifierLoc`).
Doing it in VisitTypeLoc means that we fail on this testcase:

```
  namespace $Namespace[[aa]] {
namespace $Namespace[[bb]] {
  struct $Class[[A]] {};
}
  }
  $Namespace[[aa]]::$Namespace[[bb]]::$Class[[A]] $Variable[[a]];
```

It can't detect the `bb` namespace qualifier in `aa::bb::A a;`.

Maybe there is some way of solving this without 
`TraverseNestedNameSpecifierLoc` that I am not aware of?
Also don't know how I'd get a `NestedNameSpecifierLoc` from an 
`ElaboratedTypeLoc`.



Comment at: clang-tools-extra/clangd/SemanticHighlighting.cpp:247
+  case HighlightingKind::Namespace:
+return "entity.name.type.namespace.cpp";
   case HighlightingKind::NumKinds:

hokein wrote:
> I think here should be `entity.name.namespace.cpp`, vscode uses this TX scope 
> for namespace.
Really? Because I see `entity.name.type.namespace.cpp` when I inspect the TM 
scopes for namespaces.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D64492



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


[PATCH] D64274: [analyzer] VirtualCallChecker overhaul.

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

Please know that I'm currently out of town, so it'll be a while before I can 
formally accept. Its on top of my list when I get home though! :^)


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

https://reviews.llvm.org/D64274



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


r365669 - [X86] Change the IR sequence for _mm_storeh_pi and _mm_storel_pi to perform the store as a <2 x float> instead of i64.

2019-07-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jul 10 10:11:29 2019
New Revision: 365669

URL: http://llvm.org/viewvc/llvm-project?rev=365669&view=rev
Log:
[X86] Change the IR sequence for _mm_storeh_pi and _mm_storel_pi to perform the 
store as a <2 x float> instead of i64.

This is similar to what we do for loadl_pi and loadh_pi.

Modified:
cfe/trunk/include/clang/Basic/BuiltinsX86.def
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/Headers/xmmintrin.h
cfe/trunk/test/CodeGen/builtins-x86.c
cfe/trunk/test/CodeGen/sse-builtins.c

Modified: cfe/trunk/include/clang/Basic/BuiltinsX86.def
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/BuiltinsX86.def?rev=365669&r1=365668&r2=365669&view=diff
==
--- cfe/trunk/include/clang/Basic/BuiltinsX86.def (original)
+++ cfe/trunk/include/clang/Basic/BuiltinsX86.def Wed Jul 10 10:11:29 2019
@@ -306,8 +306,6 @@ TARGET_BUILTIN(__builtin_ia32_stmxcsr, "
 TARGET_HEADER_BUILTIN(_mm_getcsr, "Ui", "nh", "xmmintrin.h", ALL_LANGUAGES, 
"sse")
 TARGET_BUILTIN(__builtin_ia32_cvtss2si, "iV4f", "ncV:128:", "sse")
 TARGET_BUILTIN(__builtin_ia32_cvttss2si, "iV4f", "ncV:128:", "sse")
-TARGET_BUILTIN(__builtin_ia32_storehps, "vV2i*V4f", "nV:128:", "sse")
-TARGET_BUILTIN(__builtin_ia32_storelps, "vV2i*V4f", "nV:128:", "sse")
 TARGET_BUILTIN(__builtin_ia32_movmskps, "iV4f", "nV:128:", "sse")
 TARGET_BUILTIN(__builtin_ia32_sfence, "v", "n", "sse")
 TARGET_HEADER_BUILTIN(_mm_sfence, "v", "nh", "xmmintrin.h", ALL_LANGUAGES, 
"sse")

Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=365669&r1=365668&r2=365669&view=diff
==
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Jul 10 10:11:29 2019
@@ -10651,22 +10651,6 @@ Value *CodeGenFunction::EmitX86BuiltinEx
 return Builder.CreateCall(Intr, Ops);
   }
 
-  case X86::BI__builtin_ia32_storehps:
-  case X86::BI__builtin_ia32_storelps: {
-llvm::Type *PtrTy = llvm::PointerType::getUnqual(Int64Ty);
-llvm::Type *VecTy = llvm::VectorType::get(Int64Ty, 2);
-
-// cast val v2i64
-Ops[1] = Builder.CreateBitCast(Ops[1], VecTy, "cast");
-
-// extract (0, 1)
-unsigned Index = BuiltinID == X86::BI__builtin_ia32_storelps ? 0 : 1;
-Ops[1] = Builder.CreateExtractElement(Ops[1], Index, "extract");
-
-// cast pointer to i64 & store
-Ops[0] = Builder.CreateBitCast(Ops[0], PtrTy);
-return Builder.CreateDefaultAlignedStore(Ops[1], Ops[0]);
-  }
   case X86::BI__builtin_ia32_vextractf128_pd256:
   case X86::BI__builtin_ia32_vextractf128_ps256:
   case X86::BI__builtin_ia32_vextractf128_si256:

Modified: cfe/trunk/lib/Headers/xmmintrin.h
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Headers/xmmintrin.h?rev=365669&r1=365668&r2=365669&view=diff
==
--- cfe/trunk/lib/Headers/xmmintrin.h (original)
+++ cfe/trunk/lib/Headers/xmmintrin.h Wed Jul 10 10:11:29 2019
@@ -1919,7 +1919,11 @@ _mm_setzero_ps(void)
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_storeh_pi(__m64 *__p, __m128 __a)
 {
-  __builtin_ia32_storehps((__v2si *)__p, (__v4sf)__a);
+  typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8)));
+  struct __mm_storeh_pi_struct {
+__mm_storeh_pi_v2f32 __u;
+  } __attribute__((__packed__, __may_alias__));
+  ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, 
__a, 2, 3);
 }
 
 /// Stores the lower 64 bits of a 128-bit vector of [4 x float] to a
@@ -1936,7 +1940,11 @@ _mm_storeh_pi(__m64 *__p, __m128 __a)
 static __inline__ void __DEFAULT_FN_ATTRS
 _mm_storel_pi(__m64 *__p, __m128 __a)
 {
-  __builtin_ia32_storelps((__v2si *)__p, (__v4sf)__a);
+  typedef float __mm_storeh_pi_v2f32 __attribute__((__vector_size__(8)));
+  struct __mm_storeh_pi_struct {
+__mm_storeh_pi_v2f32 __u;
+  } __attribute__((__packed__, __may_alias__));
+  ((struct __mm_storeh_pi_struct*)__p)->__u = __builtin_shufflevector(__a, 
__a, 0, 1);
 }
 
 /// Stores the lower 32 bits of a 128-bit vector of [4 x float] to a

Modified: cfe/trunk/test/CodeGen/builtins-x86.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/builtins-x86.c?rev=365669&r1=365668&r2=365669&view=diff
==
--- cfe/trunk/test/CodeGen/builtins-x86.c (original)
+++ cfe/trunk/test/CodeGen/builtins-x86.c Wed Jul 10 10:11:29 2019
@@ -341,8 +341,6 @@ void f0() {
 #endif
   tmp_V2i = __builtin_ia32_cvttps2pi(tmp_V4f);
   (void) __builtin_ia32_maskmovq(tmp_V8c, tmp_V8c, tmp_cp);
-  (void) __builtin_ia32_storehps(tmp_V2ip, tmp_V4f);
-  (void) __builtin_ia32_storelps(tmp_V2ip, tmp_V4f);
   tmp_i = __builtin_ia32_movmskps(tmp_V4f);
   tmp_i = __builtin_ia32_pmovmskb(tmp_V8c);
   (void) __builtin_ia

[PATCH] D63846: [clang] Preserve names of addrspacecast'ed values.

2019-07-10 Thread Vyacheslav Zakharin via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL365666: [clang] Preserve names of addrspacecast'ed 
values. (authored by vzakhari, committed by ).
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Changed prior to commit:
  https://reviews.llvm.org/D63846?vs=208564&id=209006#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D63846

Files:
  cfe/trunk/lib/CodeGen/TargetInfo.cpp
  cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
  cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
  cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl
  cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
  cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
  cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl
  cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl

Index: cfe/trunk/lib/CodeGen/TargetInfo.cpp
===
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp
@@ -449,7 +449,9 @@
   // space, an address space conversion may end up as a bitcast.
   if (auto *C = dyn_cast(Src))
 return performAddrSpaceCast(CGF.CGM, C, SrcAddr, DestAddr, DestTy);
-  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DestTy);
+  // Try to preserve the source's name to make IR more readable.
+  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Src, DestTy, Src->hasName() ? Src->getName() + ".ascast" : "");
 }
 
 llvm::Constant *
Index: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
===
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
@@ -13,7 +13,7 @@
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_gen = &var_priv; // implicit cast with obtaining adr, private -> generic
-  // CHECK: %{{[0-9]+}} = addrspacecast i32* %var_priv to i32 addrspace(4)*
+  // CHECK: %{{[._a-z0-9]+}} = addrspacecast i32* %{{[._a-z0-9]+}} to i32 addrspace(4)*
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_glob = (global int *)arg_gen; // explicit cast
Index: cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
===
--- cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
+++ cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
@@ -2,15 +2,15 @@
 #include "Inputs/cuda.h"
 
 // CHECK-LABEL: @_Z16use_dispatch_ptrPi(
-// CHECK: %2 = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
-// CHECK: %3 = addrspacecast i8 addrspace(4)* %2 to i8 addrspace(4)**
+// CHECK: %[[PTR:.*]] = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
+// CHECK: %{{.*}} = addrspacecast i8 addrspace(4)* %[[PTR]] to i8 addrspace(4)**
 __global__ void use_dispatch_ptr(int* out) {
   const int* dispatch_ptr = (const int*)__builtin_amdgcn_dispatch_ptr();
   *out = *dispatch_ptr;
 }
 
 // CHECK-LABEL: @_Z12test_ds_fmaxf(
-// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* @_ZZ12test_ds_fmaxfE6shared, float %2, i32 0, i32 0, i1 false)
+// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* @_ZZ12test_ds_fmaxfE6shared, float %{{[^,]*}}, i32 0, i32 0, i1 false)
 __global__
 void test_ds_fmax(float src) {
   __shared__ float shared;
Index: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
===
--- cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
+++ cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
@@ -19,11 +19,11 @@
 //CHECK-LABEL: define spir_func void @_Z3barv()
 void bar() {
   C c;
-  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
-  //CHECK: call void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0)
+  //CHECK: [[A1:%[.a-z0-9]+]] = addrspacecast %class.C* [[C:%[a-z0-9]+]] to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C6AssignE1E(%class.C addrspace(4)* [[A1]], i32 0)
   c.Assign(a);
-  //CHECK: addrspacecast %class.C* %c to %class.C addrspace(4)*
-  //CHECK: call void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* %{{[0-9]+}}, i32 0)
+  //CHECK: [[A2:%[.a-z0-9]+]] = addrspacecast %class.C* [[C]] to %class.C addrspace(4)*
+  //CHECK: call void @_ZNU3AS41C8OrAssignE1E(%class.C addrspace(4)* [[A2]], i32 0)
   c.OrAssign(a);
 
   E e;
@@ -35,19 +35,33 @@
   globI |= b;
   //CHECK: store i32 %add, i32 addrspace(1)* @globI
   globI += a;
-  //CHECK: store volatile i32 %and, i32 addrspace(1)* @globVI
+  //CHECK: [[GVIV1:%[0-9]+]] = load volatile i32, i32 addrspace(1)* @globVI
+  //CHECK: [[AND:%[a-z0-9]+]] = and i32 [[GVIV1]], 1
+  //CHECK: store volatile i32 [[AND]], i32 addrspace(1)* @globVI
   globVI &= b;
-  //CHECK: store volatile i32 %sub, i32 addrspace(1)* @globVI
+  //CHECK: [[GVIV2:%[0-9]+]] = load volatile i32, i32 addrspace(1)* @globVI
+  //CHECK: [[SUB:%[a-z0-9]+]] = sub nsw i32 [[GVIV2]], 0
+  /

r365668 - [X86] Add guards to some of the x86 intrinsic tests to skip 64-bit mode only intrinsics when compiled for 32-bit mode.

2019-07-10 Thread Craig Topper via cfe-commits
Author: ctopper
Date: Wed Jul 10 10:11:23 2019
New Revision: 365668

URL: http://llvm.org/viewvc/llvm-project?rev=365668&view=rev
Log:
[X86] Add guards to some of the x86 intrinsic tests to skip 64-bit mode only 
intrinsics when compiled for 32-bit mode.

All the command lines are for 64-bit mode, but sometimes I compile
the tests in 32-bit mode to see what assembly we get and we need
to skip these to do that.

Modified:
cfe/trunk/test/CodeGen/avx-builtins.c
cfe/trunk/test/CodeGen/bmi-builtins.c
cfe/trunk/test/CodeGen/bmi2-builtins.c
cfe/trunk/test/CodeGen/popcnt-builtins.c
cfe/trunk/test/CodeGen/rdrand-builtins.c
cfe/trunk/test/CodeGen/sse-builtins.c
cfe/trunk/test/CodeGen/sse2-builtins.c
cfe/trunk/test/CodeGen/sse41-builtins.c
cfe/trunk/test/CodeGen/sse42-builtins.c
cfe/trunk/test/CodeGen/tbm-builtins.c

Modified: cfe/trunk/test/CodeGen/avx-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/avx-builtins.c?rev=365668&r1=365667&r2=365668&view=diff
==
--- cfe/trunk/test/CodeGen/avx-builtins.c (original)
+++ cfe/trunk/test/CodeGen/avx-builtins.c Wed Jul 10 10:11:23 2019
@@ -1079,11 +1079,13 @@ int test_mm256_extract_epi32(__m256i A)
   return _mm256_extract_epi32(A, 7);
 }
 
+#if __x86_64__
 long long test_mm256_extract_epi64(__m256i A) {
   // CHECK-LABEL: test_mm256_extract_epi64
   // CHECK: extractelement <4 x i64> %{{.*}}, {{i32|i64}} 3
   return _mm256_extract_epi64(A, 3);
 }
+#endif
 
 __m128d test_mm256_extractf128_pd(__m256d A) {
   // CHECK-LABEL: test_mm256_extractf128_pd
@@ -1157,11 +1159,13 @@ __m256i test_mm256_insert_epi32(__m256i
   return _mm256_insert_epi32(x, b, 5);
 }
 
+#if __x86_64__
 __m256i test_mm256_insert_epi64(__m256i x, long long b) {
   // CHECK-LABEL: test_mm256_insert_epi64
   // CHECK: insertelement <4 x i64> %{{.*}}, i64 %{{.*}}, {{i32|i64}} 2
   return _mm256_insert_epi64(x, b, 2);
 }
+#endif
 
 __m256d test_mm256_insertf128_pd(__m256d A, __m128d B) {
   // CHECK-LABEL: test_mm256_insertf128_pd

Modified: cfe/trunk/test/CodeGen/bmi-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bmi-builtins.c?rev=365668&r1=365667&r2=365668&view=diff
==
--- cfe/trunk/test/CodeGen/bmi-builtins.c (original)
+++ cfe/trunk/test/CodeGen/bmi-builtins.c Wed Jul 10 10:11:23 2019
@@ -65,6 +65,7 @@ int test_mm_tzcnt_32(unsigned int __X) {
   return _mm_tzcnt_32(__X);
 }
 
+#ifdef __x86_64__
 unsigned long long test__andn_u64(unsigned long __X, unsigned long __Y) {
   // CHECK-LABEL: test__andn_u64
   // CHECK: xor i64 %{{.*}}, -1
@@ -110,6 +111,7 @@ long long test_mm_tzcnt_64(unsigned long
   // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _mm_tzcnt_64(__X);
 }
+#endif
 
 // Intel intrinsics
 
@@ -164,6 +166,7 @@ unsigned int test_tzcnt_u32(unsigned int
   return _tzcnt_u32(__X);
 }
 
+#ifdef __x86_64__
 unsigned long long test_andn_u64(unsigned long __X, unsigned long __Y) {
   // CHECK-LABEL: test_andn_u64
   // CHECK: xor i64 %{{.*}}, -1
@@ -209,3 +212,4 @@ unsigned long long test_tzcnt_u64(unsign
   // CHECK: i64 @llvm.cttz.i64(i64 %{{.*}}, i1 false)
   return _tzcnt_u64(__X);
 }
+#endif

Modified: cfe/trunk/test/CodeGen/bmi2-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/bmi2-builtins.c?rev=365668&r1=365667&r2=365668&view=diff
==
--- cfe/trunk/test/CodeGen/bmi2-builtins.c (original)
+++ cfe/trunk/test/CodeGen/bmi2-builtins.c Wed Jul 10 10:11:23 2019
@@ -28,6 +28,7 @@ unsigned int test_mulx_u32(unsigned int
   return _mulx_u32(__X, __Y, __P);
 }
 
+#ifdef __x86_64__
 unsigned long long test_bzhi_u64(unsigned long long __X, unsigned long long 
__Y) {
   // CHECK: @llvm.x86.bmi.bzhi.64
   return _bzhi_u64(__X, __Y);
@@ -49,3 +50,4 @@ unsigned long long test_mulx_u64(unsigne
   // CHECK: mul i128
   return _mulx_u64(__X, __Y, __P);
 }
+#endif

Modified: cfe/trunk/test/CodeGen/popcnt-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/popcnt-builtins.c?rev=365668&r1=365667&r2=365668&view=diff
==
--- cfe/trunk/test/CodeGen/popcnt-builtins.c (original)
+++ cfe/trunk/test/CodeGen/popcnt-builtins.c Wed Jul 10 10:11:23 2019
@@ -21,6 +21,7 @@ int test__popcntd(unsigned int __X) {
   return __popcntd(__X);
 }
 
+#ifdef __x86_64__
 #ifdef __POPCNT__
 long long test_mm_popcnt_u64(unsigned long long __X) {
   //CHECK-POPCNT: call i64 @llvm.ctpop.i64
@@ -37,3 +38,4 @@ long long test__popcntq(unsigned long lo
   //CHECK: call i64 @llvm.ctpop.i64
   return __popcntq(__X);
 }
+#endif

Modified: cfe/trunk/test/CodeGen/rdrand-builtins.c
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdrand-builtins.c?rev=365668&r1=365667&r2=365668&view=diff
==

r365666 - [clang] Preserve names of addrspacecast'ed values.

2019-07-10 Thread Vyacheslav Zakharin via cfe-commits
Author: vzakhari
Date: Wed Jul 10 10:10:05 2019
New Revision: 365666

URL: http://llvm.org/viewvc/llvm-project?rev=365666&view=rev
Log:
[clang] Preserve names of addrspacecast'ed values.

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

Modified:
cfe/trunk/lib/CodeGen/TargetInfo.cpp
cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-operators.cl
cfe/trunk/test/CodeGenOpenCLCXX/addrspace-references.cl
cfe/trunk/test/CodeGenOpenCLCXX/template-address-spaces.cl

Modified: cfe/trunk/lib/CodeGen/TargetInfo.cpp
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/TargetInfo.cpp?rev=365666&r1=365665&r2=365666&view=diff
==
--- cfe/trunk/lib/CodeGen/TargetInfo.cpp (original)
+++ cfe/trunk/lib/CodeGen/TargetInfo.cpp Wed Jul 10 10:10:05 2019
@@ -449,7 +449,9 @@ llvm::Value *TargetCodeGenInfo::performA
   // space, an address space conversion may end up as a bitcast.
   if (auto *C = dyn_cast(Src))
 return performAddrSpaceCast(CGF.CGM, C, SrcAddr, DestAddr, DestTy);
-  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(Src, DestTy);
+  // Try to preserve the source's name to make IR more readable.
+  return CGF.Builder.CreatePointerBitCastOrAddrSpaceCast(
+  Src, DestTy, Src->hasName() ? Src->getName() + ".ascast" : "");
 }
 
 llvm::Constant *

Modified: cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu?rev=365666&r1=365665&r2=365666&view=diff
==
--- cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu (original)
+++ cfe/trunk/test/CodeGenCUDA/builtins-amdgcn.cu Wed Jul 10 10:10:05 2019
@@ -2,15 +2,15 @@
 #include "Inputs/cuda.h"
 
 // CHECK-LABEL: @_Z16use_dispatch_ptrPi(
-// CHECK: %2 = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
-// CHECK: %3 = addrspacecast i8 addrspace(4)* %2 to i8 addrspace(4)**
+// CHECK: %[[PTR:.*]] = call i8 addrspace(4)* @llvm.amdgcn.dispatch.ptr()
+// CHECK: %{{.*}} = addrspacecast i8 addrspace(4)* %[[PTR]] to i8 
addrspace(4)**
 __global__ void use_dispatch_ptr(int* out) {
   const int* dispatch_ptr = (const int*)__builtin_amdgcn_dispatch_ptr();
   *out = *dispatch_ptr;
 }
 
 // CHECK-LABEL: @_Z12test_ds_fmaxf(
-// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* 
@_ZZ12test_ds_fmaxfE6shared, float %2, i32 0, i32 0, i1 false)
+// CHECK: call float @llvm.amdgcn.ds.fmax(float addrspace(3)* 
@_ZZ12test_ds_fmaxfE6shared, float %{{[^,]*}}, i32 0, i32 0, i1 false)
 __global__
 void test_ds_fmax(float src) {
   __shared__ float shared;

Modified: cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl?rev=365666&r1=365665&r2=365666&view=diff
==
--- cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl (original)
+++ cfe/trunk/test/CodeGenOpenCL/address-spaces-conversions.cl Wed Jul 10 
10:10:05 2019
@@ -13,7 +13,7 @@ void test(global int *arg_glob, generic
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_gen = &var_priv; // implicit cast with obtaining adr, private -> generic
-  // CHECK: %{{[0-9]+}} = addrspacecast i32* %var_priv to i32 addrspace(4)*
+  // CHECK: %{{[._a-z0-9]+}} = addrspacecast i32* %{{[._a-z0-9]+}} to i32 
addrspace(4)*
   // CHECK-NOFAKE-NOT: addrspacecast
 
   arg_glob = (global int *)arg_gen; // explicit cast

Modified: cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl?rev=365666&r1=365665&r2=365666&view=diff
==
--- cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl (original)
+++ cfe/trunk/test/CodeGenOpenCLCXX/address-space-deduction.cl Wed Jul 10 
10:10:05 2019
@@ -29,7 +29,7 @@ int foo(int par, int PTR par_p){
   int loc;
   //COMMON: %loc_p = alloca i32 addrspace(4)*
   //COMMON: %loc_p_const = alloca i32*
-  //COMMON: [[GAS:%[0-9]+]] = addrspacecast i32* %loc to i32 addrspace(4)*
+  //COMMON: [[GAS:%[._a-z0-9]*]] = addrspacecast i32* %loc to i32 addrspace(4)*
   //COMMON: store i32 addrspace(4)* [[GAS]], i32 addrspace(4)** %loc_p
   int PTR loc_p = ADR(loc);
   //COMMON: store i32* %loc, i32** %loc_p_const

Modified: cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl
URL: 
http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenOpenCLCXX/addrspace-of-this.cl?rev=365666&r1=365665&r2=365666&view=diff
==
--- cfe/trunk

[PATCH] D64083: [OpenCL][Sema] Improve address space support for blocks

2019-07-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: cfe/trunk/lib/Sema/SemaExprCXX.cpp:4229
+LangAS AddrSpaceR =
+RHSType->getAs()->getPointeeType().getAddressSpace();
+CastKind Kind =

Anastasia wrote:
> rjmccall wrote:
> > All of this can be much simpler:
> > 
> > ```
> > LangAS AddrSpaceL = 
> > ToType->castAs()->getPointeeType().getAddressSpace();
> > LangAS AddrSpaceR = 
> > FromType->castAs()->getPointeeType().getAddressSpace();
> > ```
> > 
> > Is there something actually checking the validity of this address-space 
> > cast somewhere?
> > Is there something actually checking the validity of this address-space 
> > cast somewhere?
> 
> The address spaces for blocks are currently added by clang implicitly. It 
> doesn't seem possible to write kernel code qualifying blocks with address 
> spaces. Although I have to say the error is not given properly because the 
> parser gets confused at least for the examples I have tried. The OpenCL spec 
> doesn't detail much regarding this use case. Potentially this is the area for 
> improvement.
> 
> So for now we can add an assert to check the cast validity if you think it 
> makes sense and maybe a FIXME in the  code to explain that address spaces 
> aren't working with blocks
> The address spaces for blocks are currently added by clang implicitly. It 
> doesn't seem possible to write kernel code qualifying blocks with address 
> spaces.

There's no way that just fell out from the existing implementation; it was a 
change someone must have made for OpenCL.  Unless you care about blocks 
existing in multiple address spaces — which, given that you depend on 
eliminating them, I'm pretty sure you don't — the compiler just shouldn't do 
that if it's causing you problems.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D64083



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


[PATCH] D64294: [Driver] Consolidate shouldUseFramePointer() and shouldUseLeafFramePointer()

2019-07-10 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added inline comments.



Comment at: lib/Driver/ToolChains/Clang.cpp:585
+  (A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ||
+  (!(A && A->getOption().matches(options::OPT_fomit_frame_pointer)) &&
+   (Args.hasArg(options::OPT_pg) ||

MaskRay wrote:
> ychen wrote:
> > It looks better if  `frame_pointer` is represented using tri-state. 
> > Something like this?
> > 
> > It would be great to have comments for conditions that are not obvious such 
> > as the overriding rules.
> > 
> > ```
> >   // There are three states for frame_pointer.
> >   enum class FpFlag {true, false, none};
> >   FpFlag FPF = FpFlag::none;
> >   if (Arg *A = Args.getLastArg(options::OPT_fomit_frame_pointer,
> >options::OPT_fno_omit_frame_pointer))
> > FPF = A->getOption().matches(options::OPT_fno_omit_frame_pointer)) ?
> >  FpFlag::true : FpFlag::false;
> > 
> >   if (!mustUseNonLeaf && FPF == FpFlag::false)
> > return FramePointerKind::None;
> > 
> >   if (mustUseNonLeaf || FPF == FpFlag::true || Args.hasArg(options::OPT_pg) 
> > ||
> >   useFramePointerForTargetByDefault(Args, Triple)) {
> > if (Args.hasFlag(options::OPT_momit_leaf_frame_pointer,
> >  options::OPT_mno_omit_leaf_frame_pointer,
> >  Triple.isPS4CPU()))
> >   return FramePointerKind::NonLeaf;
> > return FramePointerKind::All;
> >   }
> >   return FramePointerKind::None;
> > ```
> I actually think the current version is clearer.. The local `enum class 
> FpFlag {true, false, none};` doesn't improve readability in my opinion.
> 
> 
> I can define separate variables for:
> 
> * A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)
> * A && A->getOption().matches(options::OPT_fomit_frame_pointer)
> 
> If reviewers think that makes the code easier to read.
I think local enum may be optional.

Say 
  - `Fp  = A && A->getOption().matches(options::OPT_fno_omit_frame_pointer)`
  - `NoFp = A && A->getOption().matches(options::OPT_fomit_frame_pointer)`

The `!(A && A->getOption().matches(options::OPT_fomit_frame_pointer))` in the 
current revision could be `!A`. The implicit logic is `NoFp`  could only be 
overriden by `mustUseNonLeaf`.

This block helps to make the implicit logic explicit and simplify the rest of 
the code.

```
if (!mustUseNonLeaf && NoFp)
  return FramePointerKind::None;
}
```




Repository:
  rC Clang

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

https://reviews.llvm.org/D64294



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


[PATCH] D64400: [OpenCL][PR42390] Deduce addr space for templ specialization

2019-07-10 Thread John McCall via Phabricator via cfe-commits
rjmccall added inline comments.



Comment at: lib/Sema/SemaType.cpp:7421
+  // - template specialization as addr space in template argument doesn't
+  //   affect specialization.
+  (T->isDependentType() && (!T->isPointerType() && !T->isReferenceType() &&

Anastasia wrote:
> rjmccall wrote:
> > I don't understand what you're saying here.  Why does inference depend on 
> > whether the type is a template specialization?  And what does this have to 
> > do with template arguments?  Also, address spaces in template arguments are 
> > definitely part of the template argument and affect which specialization 
> > you're naming.
> What I am trying to say here is that an address space of a template argument 
> isn't used as an address space of a template specialization and therefore we 
> can deduce the address space of a template specialization since it's not 
> going to be provided during the template instantiation.
> 
> Let's say we have specialization `MyClass`. The address space of `T` has 
> nothing to do with the address space of `MyClass`. They are different. 
> Therefore if the address space of `MyClass` is not provided explicitly it 
> is ok to deduce it.
> 
> Does it make sense?
Of course the address space of `T` has nothing to do with the address space of 
`MyClass`, but that's true of literally every type, and you don't need to 
add special cases checking for specific type spellings.

Why don't you just never infer address spaces on dependent types and then infer 
them as necessary during instantiation?  Why is it important to infer address 
spaces on any dependent type in the template pattern?


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

https://reviews.llvm.org/D64400



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


[PATCH] D63192: [Diagnostics] Implement -Wswitch-default

2019-07-10 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added a comment.

I'm wary of adding this as an on-by-default warning, despite its presence in 
MSVC (and despite submitting a similar patch years ago to implement the same 
functionality). Machine-generated code runs into this one frequently (we've 
been bitten by it numerous times with our tablegen code, especially in the 
backends), but it does not seem likely to occur in hand-written code very often.

While it's pretty easy to implement this in the frontend, I sort of feel like 
this is a better candidate for clang-tidy's `readability` module.


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

https://reviews.llvm.org/D63192



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


  1   2   3   >