[PATCH] D102614: [index] Add support for type of pointers to class members

2021-12-05 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added a comment.

ping

What do you think about this patch? Can it be landed now? Or I should debug the 
crash in the Windows version detected with the previous version of my patch.


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

https://reviews.llvm.org/D102614

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


[PATCH] D114583: [clang-format] Adjust braced list detection

2021-12-05 Thread Owen Pan via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc41b3b0fa0f4: [clang-format] Adjust braced list detection 
(authored by cpplearner, committed by owenpan).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114583

Files:
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/unittests/Format/FormatTest.cpp


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11773,6 +11773,27 @@
"  f(v);\n"
"}");
 
+  verifyFormat("void foo() {\n"
+   "  { // asdf\n"
+   "{ int a; }\n"
+   "  }\n"
+   "  {\n"
+   "{ int b; }\n"
+   "  }\n"
+   "}");
+  verifyFormat("namespace n {\n"
+   "void foo() {\n"
+   "  {\n"
+   "{\n"
+   "  statement();\n"
+   "  if (false) {\n"
+   "  }\n"
+   "}\n"
+   "  }\n"
+   "  {}\n"
+   "}\n"
+   "} // namespace n");
+
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,17 +578,14 @@
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
-  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
-  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
-   tok::r_paren, tok::r_square, tok::l_brace,
-   tok::ellipsis) ||
-  (NextTok->is(tok::identifier) &&
+   tok::r_paren, tok::r_square, tok::ellipsis) ||
+  (NextTok->isOneOf(tok::l_brace, tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
@@ -2856,7 +2853,7 @@
   // class Foo implements {bar: number} { }
   nextToken();
   if (FormatTok->is(tok::l_brace)) {
-tryToParseBracedList();
+parseBracedList();
 continue;
   }
 }


Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -11773,6 +11773,27 @@
"  f(v);\n"
"}");
 
+  verifyFormat("void foo() {\n"
+   "  { // asdf\n"
+   "{ int a; }\n"
+   "  }\n"
+   "  {\n"
+   "{ int b; }\n"
+   "  }\n"
+   "}");
+  verifyFormat("namespace n {\n"
+   "void foo() {\n"
+   "  {\n"
+   "{\n"
+   "  statement();\n"
+   "  if (false) {\n"
+   "  }\n"
+   "}\n"
+   "  }\n"
+   "  {}\n"
+   "}\n"
+   "} // namespace n");
+
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"
Index: clang/lib/Format/UnwrappedLineParser.cpp
===
--- clang/lib/Format/UnwrappedLineParser.cpp
+++ clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,17 +578,14 @@
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
-  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
-  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
   (Style.isCpp() && 

[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-05 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie added inline comments.



Comment at: clang/lib/CrossTU/CrossTranslationUnit.cpp:154-172
+  // Find the length delimiter.
+  const size_t LengthDelimiter = LineRef.find(':');
+  if (StringRef::npos == LengthDelimiter)
+return false;
+
+  // Parse the length of LookupName as USRLength.
+  size_t USRLength = 0;

steakhal wrote:
> 
The source of lookup name of the function being imported is function 
`CrossTranslationUnitContext::getLookupName`. Keeping the length in the mapping 
can avoid parsing the lookup name during importing.


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

https://reviews.llvm.org/D102669

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


[clang] c41b3b0 - [clang-format] Adjust braced list detection

2021-12-05 Thread Owen Pan via cfe-commits

Author: Tan S. B
Date: 2021-12-05T22:39:29-08:00
New Revision: c41b3b0fa0f4f70aad8deaf48bcd42a04385066c

URL: 
https://github.com/llvm/llvm-project/commit/c41b3b0fa0f4f70aad8deaf48bcd42a04385066c
DIFF: 
https://github.com/llvm/llvm-project/commit/c41b3b0fa0f4f70aad8deaf48bcd42a04385066c.diff

LOG: [clang-format] Adjust braced list detection

This avoids mishandling nested compound statements that are followed by another 
compound statement.

Fixes https://llvm.org/PR38314 and https://llvm.org/PR48305.

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

Added: 


Modified: 
clang/lib/Format/UnwrappedLineParser.cpp
clang/unittests/Format/FormatTest.cpp

Removed: 




diff  --git a/clang/lib/Format/UnwrappedLineParser.cpp 
b/clang/lib/Format/UnwrappedLineParser.cpp
index 5b9fe267aae6..2f27bf912fa2 100644
--- a/clang/lib/Format/UnwrappedLineParser.cpp
+++ b/clang/lib/Format/UnwrappedLineParser.cpp
@@ -578,17 +578,14 @@ void UnwrappedLineParser::calculateBraceTypes(bool 
ExpectClassBody) {
   // BlockKind later if we parse a braced list (where all blocks
   // inside are by default braced lists), or when we explicitly detect
   // blocks (for example while parsing lambdas).
-  // FIXME: Some of these do not apply to JS, e.g. "} {" can never be a
-  // braced list in JS.
   ProbablyBracedList =
   (Style.Language == FormatStyle::LK_JavaScript &&
NextTok->isOneOf(Keywords.kw_of, Keywords.kw_in,
 Keywords.kw_as)) ||
   (Style.isCpp() && NextTok->is(tok::l_paren)) ||
   NextTok->isOneOf(tok::comma, tok::period, tok::colon,
-   tok::r_paren, tok::r_square, tok::l_brace,
-   tok::ellipsis) ||
-  (NextTok->is(tok::identifier) &&
+   tok::r_paren, tok::r_square, tok::ellipsis) ||
+  (NextTok->isOneOf(tok::l_brace, tok::identifier) &&
!PrevTok->isOneOf(tok::semi, tok::r_brace, tok::l_brace)) ||
   (NextTok->is(tok::semi) &&
(!ExpectClassBody || LBraceStack.size() != 1)) ||
@@ -2856,7 +2853,7 @@ void UnwrappedLineParser::parseRecord(bool ParseAsExpr) {
   // class Foo implements {bar: number} { }
   nextToken();
   if (FormatTok->is(tok::l_brace)) {
-tryToParseBracedList();
+parseBracedList();
 continue;
   }
 }

diff  --git a/clang/unittests/Format/FormatTest.cpp 
b/clang/unittests/Format/FormatTest.cpp
index bda5f7019416..cbd051f3a5e8 100644
--- a/clang/unittests/Format/FormatTest.cpp
+++ b/clang/unittests/Format/FormatTest.cpp
@@ -11773,6 +11773,27 @@ TEST_F(FormatTest, FormatsBracedListsInColumnLayout) {
"  f(v);\n"
"}");
 
+  verifyFormat("void foo() {\n"
+   "  { // asdf\n"
+   "{ int a; }\n"
+   "  }\n"
+   "  {\n"
+   "{ int b; }\n"
+   "  }\n"
+   "}");
+  verifyFormat("namespace n {\n"
+   "void foo() {\n"
+   "  {\n"
+   "{\n"
+   "  statement();\n"
+   "  if (false) {\n"
+   "  }\n"
+   "}\n"
+   "  }\n"
+   "  {}\n"
+   "}\n"
+   "} // namespace n");
+
   // Long lists should be formatted in columns even if they are nested.
   verifyFormat(
   "vector x = function({1, 22, 333, , 5, 66, 777,\n"



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


[PATCH] D102669: [analyzer][ctu] Fix wrong 'multiple definitions' errors caused by space characters in lookup names when parsing the ctu index file

2021-12-05 Thread Ella Ma via Phabricator via cfe-commits
OikawaKirie updated this revision to Diff 391968.
OikawaKirie added a comment.

1. Fix formatting bugs
2. Update lookup name format as `: ` in all 
comments and documents
3. Add the new test case as a part of 
`clang/test/Analysis/func-mapping-test.cpp` to verify the lookup name
4. Change the macros for asserting the lookup name format to an `NDEBUG` 
wrapped function


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

https://reviews.llvm.org/D102669

Files:
  clang/docs/analyzer/user-docs/CrossTranslationUnit.rst
  clang/include/clang/Basic/DiagnosticCrossTUKinds.td
  clang/include/clang/CrossTU/CrossTranslationUnit.h
  clang/lib/CrossTU/CrossTranslationUnit.cpp
  clang/test/Analysis/Inputs/ctu-import.c.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-lookup-name-with-space.cpp
  clang/test/Analysis/Inputs/ctu-other.c.externalDefMap.ast-dump.txt
  clang/test/Analysis/Inputs/ctu-other.cpp.externalDefMap.ast-dump.txt
  
clang/test/Analysis/Inputs/plist-macros-with-expansion-ctu.c.externalDefMap.txt
  clang/test/Analysis/ctu-inherited-default-ctor.cpp
  clang/test/Analysis/ctu-lookup-name-with-space.cpp
  clang/test/Analysis/func-mapping-test.cpp
  clang/unittests/CrossTU/CrossTranslationUnitTest.cpp

Index: clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
===
--- clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
+++ clang/unittests/CrossTU/CrossTranslationUnitTest.cpp
@@ -61,7 +61,7 @@
 ASSERT_FALSE(llvm::sys::fs::createTemporaryFile("index", "txt", IndexFD,
 IndexFileName));
 llvm::ToolOutputFile IndexFile(IndexFileName, IndexFD);
-IndexFile.os() << "c:@F@f#I# " << ASTFileName << "\n";
+IndexFile.os() << "9:c:@F@f#I# " << ASTFileName << "\n";
 IndexFile.os().flush();
 EXPECT_TRUE(llvm::sys::fs::exists(IndexFileName));
 
@@ -154,9 +154,9 @@
 
 TEST(CrossTranslationUnit, IndexFormatCanBeParsed) {
   llvm::StringMap Index;
-  Index["a"] = "/b/f1";
-  Index["c"] = "/d/f2";
-  Index["e"] = "/f/f3";
+  Index["1:a"] = "/b/f1";
+  Index["1:c"] = "/d/f2";
+  Index["1:e"] = "/f/f3";
   std::string IndexText = createCrossTUIndexString(Index);
 
   int IndexFD;
Index: clang/test/Analysis/func-mapping-test.cpp
===
--- clang/test/Analysis/func-mapping-test.cpp
+++ clang/test/Analysis/func-mapping-test.cpp
@@ -3,10 +3,10 @@
 int f(int) {
   return 0;
 }
-// CHECK-DAG: c:@F@f#I#
+// CHECK-DAG: 9:c:@F@f#I#
 
 extern const int x = 5;
-// CHECK-DAG: c:@x
+// CHECK-DAG: 4:c:@x
 
 // Non-const variables should not be collected.
 int y = 5;
@@ -18,29 +18,29 @@
   int a;
 };
 extern S const s = {.a = 2};
-// CHECK-DAG: c:@s
+// CHECK-DAG: 4:c:@s
 
 struct SF {
   const int a;
 };
 SF sf = {.a = 2};
-// CHECK-DAG: c:@sf
+// CHECK-DAG: 5:c:@sf
 
 struct SStatic {
   static const int a = 4;
 };
 const int SStatic::a;
-// CHECK-DAG: c:@S@SStatic@a
+// CHECK-DAG: 14:c:@S@SStatic@a
 
 extern int const arr[5] = { 0, 1 };
-// CHECK-DAG: c:@arr
+// CHECK-DAG: 6:c:@arr
 
 union U {
   const int a;
   const unsigned int b;
 };
 U u = {.a = 6};
-// CHECK-DAG: c:@u
+// CHECK-DAG: 4:c:@u
 
 // No USR can be generated for this.
 // Check for no crash in this case.
@@ -48,3 +48,15 @@
   float uf;
   const int ui;
 };
+
+void f(int (*)(char));
+void f(bool (*)(char));
+
+struct G {
+  G() {
+f([](char) -> int { return 42; });
+// CHECK-DAG: 41:c:@S@G@F@G#@Sa@F@operator int (*)(char)#1
+f([](char) -> bool { return true; });
+// CHECK-DAG: 42:c:@S@G@F@G#@Sa@F@operator bool (*)(char)#1
+  }
+};
Index: clang/test/Analysis/ctu-lookup-name-with-space.cpp
===
--- /dev/null
+++ clang/test/Analysis/ctu-lookup-name-with-space.cpp
@@ -0,0 +1,22 @@
+// RUN: rm -rf %t
+// RUN: mkdir %t
+
+// RUN: cp %s %t/trigger.cpp
+// RUN: cp %S/Inputs/ctu-lookup-name-with-space.cpp %t/importee.cpp
+// RUN: echo '"%t/importee.cpp" : ["g++", "-c", "%t/importee.cpp"]' > %t/invocations.yaml
+// RUN: echo '[{"directory": "%t", "command": "g++ -c %t/importee.cpp", "file": "%t/importee.cpp"}, {"directory": "%t", "command": "g++ -c %t/trigger.cpp", "file": "%t/trigger.cpp"}]' > %t/compile_commands.json
+
+// RUN: %clang_extdef_map -p %t %t/importee.cpp > %t/externalDefMap.txt
+
+// RUN: cd %t && %clang_cc1 -fsyntax-only -analyze \
+// RUN:   -analyzer-checker=core \
+// RUN:   -analyzer-config experimental-enable-naive-ctu-analysis=true \
+// RUN:   -analyzer-config ctu-dir=. \
+// RUN:   -analyzer-config ctu-invocation-list=invocations.yaml \
+// RUN:   -verify trigger.cpp 2>&1 | FileCheck --allow-empty importee.cpp
+
+int importee(int);
+
+void trigger() {
+  importee(0); // expected-warn...@importee.cpp:13 {{Division by zero}}
+}
Index: clang/test/Analysis/ctu-inherited-default-ctor.cpp
===
--- 

[PATCH] D115132: [C++20] [Modules] Namespace Declaration shouldn't have module linkage

2021-12-05 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu created this revision.
ChuanqiXu added reviewers: rsmith, aaron.ballman, urnathan, 
hubert.reinterpretcast, erichkeane.
ChuanqiXu added a project: clang.
ChuanqiXu requested review of this revision.
Herald added a subscriber: cfe-commits.

According to https://eel.is/c++draft/basic.namespace.general#2, a namespace 
declaration shouldn't have a module linkage.

Further more, without this patch, the compiler would crash for the test in 
assertion enabled build due to inconsistent linkage for redeclaration for 
namespaces.

Test Plan: check-all


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115132

Files:
  clang/lib/AST/Decl.cpp
  clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.cppm
  clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.h
  clang/test/CXX/basic/basic.namespace/basic.namespace.general/p2.cppm


Index: clang/test/CXX/basic/basic.namespace/basic.namespace.general/p2.cppm
===
--- /dev/null
+++ clang/test/CXX/basic/basic.namespace/basic.namespace.general/p2.cppm
@@ -0,0 +1,14 @@
+// Check that the compiler wouldn't crash due to inconsistent namesapce linkage
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: %clang -std=c++20 %S/Inputs/p2.cppm --precompile -o %t/Y.pcm
+// RUN: %clang -std=c++20 -fprebuilt-module-path=%t -I%S/Inputs %s -c -Xclang 
-verify
+// expected-no-diagnostics
+export module X;
+import Y;
+
+export namespace foo {
+namespace bar{
+void baz();
+}
+}
Index: clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.h
===
--- /dev/null
+++ clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.h
@@ -0,0 +1,7 @@
+#ifndef P2_H
+#define P2_H
+namespace foo {
+namespace bar {
+}
+} // namespace foo
+#endif
Index: 
clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.cppm
===
--- /dev/null
+++ clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.cppm
@@ -0,0 +1,7 @@
+module;
+#include "p2.h"
+export module Y;
+export namespace foo {
+// We need to export something at least
+void print();
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -604,8 +604,14 @@
   //   - A name declared at namespace scope that does not have internal linkage
   // by the previous rules and that is introduced by a non-exported
   // declaration has module linkage.
-  if (isInModulePurview(D) && !isExportedFromModuleInterfaceUnit(
-  cast(D->getCanonicalDecl(
+  //
+  // [basic.namespace.general]/p2
+  //   A namespace is never attached to a named module and never has a name 
with
+  //   module linkage.
+  if (isInModulePurview(D) &&
+  !isExportedFromModuleInterfaceUnit(
+  cast(D->getCanonicalDecl())) &&
+  !isa(D))
 return LinkageInfo(ModuleLinkage, DefaultVisibility, false);
 
   return LinkageInfo::external();


Index: clang/test/CXX/basic/basic.namespace/basic.namespace.general/p2.cppm
===
--- /dev/null
+++ clang/test/CXX/basic/basic.namespace/basic.namespace.general/p2.cppm
@@ -0,0 +1,14 @@
+// Check that the compiler wouldn't crash due to inconsistent namesapce linkage
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: %clang -std=c++20 %S/Inputs/p2.cppm --precompile -o %t/Y.pcm
+// RUN: %clang -std=c++20 -fprebuilt-module-path=%t -I%S/Inputs %s -c -Xclang -verify
+// expected-no-diagnostics
+export module X;
+import Y;
+
+export namespace foo {
+namespace bar{
+void baz();
+}
+}
Index: clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.h
===
--- /dev/null
+++ clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.h
@@ -0,0 +1,7 @@
+#ifndef P2_H
+#define P2_H
+namespace foo {
+namespace bar {
+}
+} // namespace foo
+#endif
Index: clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.cppm
===
--- /dev/null
+++ clang/test/CXX/basic/basic.namespace/basic.namespace.general/Inputs/p2.cppm
@@ -0,0 +1,7 @@
+module;
+#include "p2.h"
+export module Y;
+export namespace foo {
+// We need to export something at least
+void print();
+}
Index: clang/lib/AST/Decl.cpp
===
--- clang/lib/AST/Decl.cpp
+++ clang/lib/AST/Decl.cpp
@@ -604,8 +604,14 @@
   //   - A name declared at namespace scope that does not have internal linkage
   // by the previous rules and that is introduced by a non-exported
   // declaration has module linkage.
-  if (isInModulePurview(D) && !isExportedFromModuleInterfaceUnit(
-  

[PATCH] D102090: [CMake][ELF] Link libLLVM.so and libclang-cpp.so with -Bsymbolic-functions

2021-12-05 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

To add on rnk's comment (deduplication of vague linkage data which may be 
included in multiple shared objects), another big reason is -Bsymbolic data 
does not work with copy relocations. -fno-pic programs generally cannot avoid 
copy relocations (except mips; mips did this thing correctly). GCC 5 x86-64 has 
a regression  that -fpie 
code can have copy relocations, too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D102090

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


[PATCH] D113237: [RISCV] Support I extension version 2.1

2021-12-05 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence added a comment.

In D113237#3124232 , @luismarques 
wrote:

> In D113237#3124188 , @luismarques 
> wrote:
>
>> Should we also support `fence.i` with RVI 2.0, without zifencei?
>
> Here's a proposed path forwards:
>
> - Patch 1: Add support for RVI 2.1 and related changes. Keep RVI 2.0 as the 
> default.
> - Patch 2: Add warnings for uses of the removed `fence.i`, CSRs and counters 
> when using RVI 2.0 (at least when doing so by default; arguably this should 
> error out instead when explicitly specifying version 2.0.)
> - Patch 3: Start defaulting to RVI 2.1. IMO this should only be committed 
> after patch 2 being in effect for a while.

I tried to make I-ext imply `zifencei`, `zicsr`, and `zihintpause` 
automatically. BTW `zihintpause` is implemented in D93019 
.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113237

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


[PATCH] D113237: [RISCV] Support Zifencei extension

2021-12-05 Thread Shao-Ce SUN via Phabricator via cfe-commits
achieveartificialintelligence updated this revision to Diff 391951.
achieveartificialintelligence added a comment.
Herald added subscribers: cfe-commits, jdoerfert, rupprecht, emaste, qcolombet.
Herald added a reviewer: jhenderson.
Herald added a reviewer: MaskRay.
Herald added a project: clang.

Update I-ext to Version 2.1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113237

Files:
  clang/test/Driver/riscv-arch.c
  clang/test/Driver/riscv-cpus.c
  lld/test/ELF/riscv-attributes.s
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVInstrInfo.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/CodeGen/RISCV/rvv/access-fixed-objects-by-rvv.ll
  llvm/test/CodeGen/RISCV/rvv/allocate-lmul-2-4-8.ll
  llvm/test/CodeGen/RISCV/rvv/bitreverse-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/bswap-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/calling-conv-fastcc.ll
  llvm/test/CodeGen/RISCV/rvv/calling-conv.ll
  llvm/test/CodeGen/RISCV/rvv/extract-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-insert-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-store-fp.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-masked-store-int.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vwmul.ll
  llvm/test/CodeGen/RISCV/rvv/fixed-vectors-vwmulu.ll
  llvm/test/CodeGen/RISCV/rvv/insert-subvector.ll
  llvm/test/CodeGen/RISCV/rvv/interleave-crash.ll
  llvm/test/CodeGen/RISCV/rvv/large-rvv-stack-size.mir
  llvm/test/CodeGen/RISCV/rvv/legalize-load-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/legalize-store-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/localvar.ll
  llvm/test/CodeGen/RISCV/rvv/memory-args.ll
  llvm/test/CodeGen/RISCV/rvv/mgather-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/mscatter-sdnode.ll
  llvm/test/CodeGen/RISCV/rvv/named-vector-shuffle-reverse.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-vector.ll
  llvm/test/CodeGen/RISCV/rvv/rv32-spill-zvlsseg.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector-csr.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-vector.ll
  llvm/test/CodeGen/RISCV/rvv/rv64-spill-zvlsseg.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-framelayout.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-out-arguments.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-vscale.i32.ll
  llvm/test/CodeGen/RISCV/rvv/rvv-vscale.i64.ll
  llvm/test/CodeGen/RISCV/rvv/setcc-fp-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/setcc-fp-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/setcc-integer-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/setcc-integer-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/sink-splat-operands.ll
  llvm/test/CodeGen/RISCV/rvv/stepvector.ll
  llvm/test/CodeGen/RISCV/rvv/vadd-vp.ll
  llvm/test/CodeGen/RISCV/rvv/vleff-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vleff-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vlsegff-rv32-dead.ll
  llvm/test/CodeGen/RISCV/rvv/vlsegff-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vlsegff-rv64-dead.ll
  llvm/test/CodeGen/RISCV/rvv/vlsegff-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv32.ll
  llvm/test/CodeGen/RISCV/rvv/vselect-fp-rv64.ll
  llvm/test/CodeGen/RISCV/rvv/vsetvli-insert-crossbb.ll
  llvm/test/CodeGen/RISCV/rvv/wrong-stack-slot-rv32.mir
  llvm/test/CodeGen/RISCV/rvv/wrong-stack-slot-rv64.mir
  llvm/test/CodeGen/RISCV/rvv/zvlsseg-zero-vl.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/attribute-with-insts.s
  llvm/test/MC/RISCV/attribute-with-option.s
  llvm/test/MC/RISCV/attribute.s
  llvm/test/MC/RISCV/csr-aliases.s
  llvm/test/MC/RISCV/deprecated-csr-names.s
  llvm/test/MC/RISCV/invalid-attribute.s
  llvm/test/MC/RISCV/machine-csr-names.s
  llvm/test/MC/RISCV/rv32-machine-csr-names.s
  llvm/test/MC/RISCV/rv32-user-csr-names.s
  llvm/test/MC/RISCV/rv32e-valid.s
  llvm/test/MC/RISCV/rv32i-aliases-valid.s
  llvm/test/MC/RISCV/rv32i-invalid.s
  llvm/test/MC/RISCV/rv32i-valid.s
  llvm/test/MC/RISCV/rv32zicsr-invalid.s
  llvm/test/MC/RISCV/rv32zicsr-valid.s
  llvm/test/MC/RISCV/rv32zifencei-valid.s
  llvm/test/MC/RISCV/rv64-machine-csr-names.s
  llvm/test/MC/RISCV/rv64-user-csr-names.s
  llvm/test/MC/RISCV/rvf-aliases-valid.s
  llvm/test/MC/RISCV/rvf-user-csr-names.s
  llvm/test/MC/RISCV/rvi-aliases-valid.s
  llvm/test/MC/RISCV/rvv-user-csr-names.s
  llvm/test/MC/RISCV/rvzicsr-aliases-valid.s
  llvm/test/MC/RISCV/supervisor-csr-names.s
  llvm/test/MC/RISCV/user-csr-names.s
  llvm/test/tools/llvm-objdump/ELF/RISCV/unknown-arch-attr.test
  llvm/test/tools/llvm-readobj/ELF/RISCV/attribute.s

Index: llvm/test/tools/llvm-readobj/ELF/RISCV/attribute.s
===
--- llvm/test/tools/llvm-readobj/ELF/RISCV/attribute.s
+++ llvm/test/tools/llvm-readobj/ELF/RISCV/attribute.s
@@ -17,10 +17,10 @@
 # CHECK-OBJ-NEXT: TagName: stack_align
 # CHECK-OBJ-NEXT: Description: Stack alignment is 16-bytes
 
-.attribute  Tag_arch, "rv32i2p0_m2p0_a2p0_c2p0"
+.attribute  Tag_arch, 

[PATCH] D70401: [WIP][RISCV] Implement ilp32e ABI

2021-12-05 Thread Zixuan Wu via Phabricator via cfe-commits
zixuan-wu added a comment.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence.

Hi, all. Why is it not continued?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D70401

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


[PATCH] D111617: [RISCV] Lazily add RVV C intrinsics.

2021-12-05 Thread Hsiangkai Wang via Phabricator via cfe-commits
HsiangKai updated this revision to Diff 391948.
HsiangKai added a comment.

- Use unique_ptr.
- Avoid to create static global constructors.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111617

Files:
  clang/include/clang/Basic/CMakeLists.txt
  clang/include/clang/Basic/TokenKinds.def
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParsePragma.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/utils/TableGen/RISCVVEmitter.cpp
  clang/utils/TableGen/TableGen.cpp
  clang/utils/TableGen/TableGenBackends.h
  llvm/docs/CommandGuide/tblgen.rst

Index: llvm/docs/CommandGuide/tblgen.rst
===
--- llvm/docs/CommandGuide/tblgen.rst
+++ llvm/docs/CommandGuide/tblgen.rst
@@ -348,6 +348,10 @@
 
   Generate ``riscv_vector_builtin_cg.inc`` for Clang.
 
+.. option:: -gen-riscv-vector-builtin-sema
+
+  Generate ``riscv_vector_builtin_sema.inc`` for Clang.
+
 .. option:: -gen-attr-docs
 
   Generate attribute documentation.
Index: clang/utils/TableGen/TableGenBackends.h
===
--- clang/utils/TableGen/TableGenBackends.h
+++ clang/utils/TableGen/TableGenBackends.h
@@ -110,6 +110,7 @@
 void EmitRVVHeader(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitRVVBuiltins(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitRVVBuiltinCG(llvm::RecordKeeper , llvm::raw_ostream );
+void EmitRVVBuiltinSema(llvm::RecordKeeper , llvm::raw_ostream );
 
 void EmitCdeHeader(llvm::RecordKeeper , llvm::raw_ostream );
 void EmitCdeBuiltinDef(llvm::RecordKeeper , llvm::raw_ostream );
Index: clang/utils/TableGen/TableGen.cpp
===
--- clang/utils/TableGen/TableGen.cpp
+++ clang/utils/TableGen/TableGen.cpp
@@ -88,6 +88,7 @@
   GenRISCVVectorHeader,
   GenRISCVVectorBuiltins,
   GenRISCVVectorBuiltinCG,
+  GenRISCVVectorBuiltinSema,
   GenAttrDocs,
   GenDiagDocs,
   GenOptDocs,
@@ -243,6 +244,8 @@
"Generate riscv_vector_builtins.inc for clang"),
 clEnumValN(GenRISCVVectorBuiltinCG, "gen-riscv-vector-builtin-codegen",
"Generate riscv_vector_builtin_cg.inc for clang"),
+clEnumValN(GenRISCVVectorBuiltinSema, "gen-riscv-vector-builtin-sema",
+   "Generate riscv_vector_builtin_sema.inc for clang"),
 clEnumValN(GenAttrDocs, "gen-attr-docs",
"Generate attribute documentation"),
 clEnumValN(GenDiagDocs, "gen-diag-docs",
@@ -458,6 +461,9 @@
   case GenRISCVVectorBuiltinCG:
 EmitRVVBuiltinCG(Records, OS);
 break;
+  case GenRISCVVectorBuiltinSema:
+EmitRVVBuiltinSema(Records, OS);
+break;
   case GenAttrDocs:
 EmitClangAttrDocs(Records, OS);
 break;
Index: clang/utils/TableGen/RISCVVEmitter.cpp
===
--- clang/utils/TableGen/RISCVVEmitter.cpp
+++ clang/utils/TableGen/RISCVVEmitter.cpp
@@ -15,6 +15,7 @@
 //===--===//
 
 #include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/MapVector.h"
 #include "llvm/ADT/SmallSet.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringMap.h"
@@ -22,6 +23,8 @@
 #include "llvm/ADT/Twine.h"
 #include "llvm/TableGen/Error.h"
 #include "llvm/TableGen/Record.h"
+#include "llvm/TableGen/StringMatcher.h"
+#include "llvm/TableGen/TableGenBackend.h"
 #include 
 
 using namespace llvm;
@@ -55,7 +58,6 @@
 Float,
 Invalid,
   };
-  BasicType BT;
   ScalarTypeKind ScalarType = Invalid;
   LMULType LMUL;
   bool IsPointer = false;
@@ -71,11 +73,30 @@
   std::string ClangBuiltinStr;
   std::string Str;
   std::string ShortStr;
+  std::string QualExpr;
+  std::string MangledStr;
 
 public:
   RVVType() : RVVType(BasicType(), 0, StringRef()) {}
   RVVType(BasicType BT, int Log2LMUL, StringRef prototype);
 
+  StringRef getMangledStr() {
+if (MangledStr.empty()) {
+  if (!Valid)
+MangledStr = "invalid";
+  else {
+MangledStr =
+(Twine(ScalarType) + Twine(IsPointer) + Twine(IsImmediate) +
+ Twine(IsConstant) + Twine(ElementBitwidth))
+.str();
+if (!isScalar())
+  MangledStr += (Twine(Scale.getValue()) + LMUL.str()).str();
+  }
+}
+
+return MangledStr;
+  }
+
   // Return the string representation of a type, which is an encoded string for
   // passing to the BUILTIN() macro in Builtins.def.
   const std::string () const { return BuiltinStr; }
@@ -97,6 +118,8 @@
 return ShortStr;
   }
 
+  const std::string () { return QualExpr; }
+
   bool isValid() const { return Valid; }
   bool isScalar() const { return Scale.hasValue() && Scale.getValue() == 0; }
   bool isVector() const { return Scale.hasValue() && Scale.getValue() != 0; }
@@ -110,13 +133,15 @@
   bool isFloat(unsigned Width) const {
 return 

[PATCH] D115049: Fall back on Android triple w/o API level for runtimes search

2021-12-05 Thread Nico Weber via Phabricator via cfe-commits
thakis added a comment.

Looks like this breaks tests on Windows: 
https://buildkite.com/llvm-project/premerge-checks/builds/68330#746376c2-ce48-4ffc-b60f-515619dee28c

Failed Tests (2):

  Clang :: Driver/ve-toolchain.c
  Clang :: Driver/ve-toolchain.cpp
   


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115049

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


[PATCH] D25844: [Sema][ObjC] Warn about implicitly autoreleasing indirect parameters that are captured by blocks

2021-12-05 Thread John McCall via Phabricator via cfe-commits
rjmccall added a comment.

That's not an unreasonable idea, and we did consider it, and in fact it's still 
on the table as something we could do.  However, it's a significantly more 
complex change, and we're not committed to doing it, and so we wanted to at 
least put this warning in place to help people avoid a relatively common bug.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D25844

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


[PATCH] D115121: Add support for return values in bugprone-stringview-nullptr

2021-12-05 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp:94-95
+
+// TODO: Handle cases where types, such as Class and Struct below, are
+//   constructed with null arguments.
+class Class {

I attempted to address this TODO but it is quite the rabbit hole. If I just add 
a basic fallback matcher, `applyFirst(...)` does not have the behavior I 
desire. It was stomping on other, better fixes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115121

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


[PATCH] D115121: Add support for return values in bugprone-stringview-nullptr

2021-12-05 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp:735
 
 void function_invocation() /* f */ {
+  // Single Argument Function Invocation

This diff is also noisy, but it's about adding missing test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115121

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


[PATCH] D115121: Add support for return values in bugprone-stringview-nullptr

2021-12-05 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson updated this revision to Diff 391940.
CJ-Johnson added a comment.

Add missing tests for function arguments and fix incorrect warning message for 
static_cast cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115121

Files:
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -88,8 +88,21 @@
 
 } // namespace std
 
-void function(std::string_view);
-void function(std::string_view, std::string_view);
+void sv_function(std::string_view);
+void sv_function(std::string_view, std::string_view);
+
+// TODO: Handle cases where types, such as Class and Struct below, are
+//   constructed with null arguments.
+class Class {
+public:
+  Class(std::string_view);
+  Class(std::string_view, std::string_view);
+};
+struct Struct {
+  std::string_view first = {};
+  std::string_view second = {};
+};
+void type_function(Class, Struct);
 
 void temporary_construction() /* a */ {
   // Functional Cast
@@ -197,23 +210,54 @@
 // CHECK-FIXES: {{^}}(void)((const std::string_view){}) /* a24 */;
   }
 
+  // Return Value
+  {
+(void)([] -> std::string_view { return nullptr; }) /* a25 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* a25 */;
+
+(void)([] -> std::string_view { return (nullptr); }) /* a26 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* a26 */;
+
+(void)([] -> std::string_view { return {nullptr}; }) /* a27 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* a27 */;
+
+(void)([] -> std::string_view { return {(nullptr)}; }) /* a28 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* a28 */;
+
+(void)([] -> std::string_view { return {{nullptr}}; }) /* a29 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* a29 */;
+
+(void)([] -> std::string_view { return {{(nullptr)}}; }) /* a30 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* a30 */;
+
+(void)([] -> std::string_view { return {{}}; }) /* a31 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* a31 */;
+  }
+
   // Static Cast
   {
-(void)(static_cast(nullptr)) /* a25 */;
-// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: constructing{{.*}}default
-// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a25 */;
+(void)(static_cast(nullptr)) /* a32 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: constructing basic_string_view from null is undefined; replace with the empty string
+// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a32 */;
 
-(void)(static_cast((nullptr))) /* a26 */;
-// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: constructing{{.*}}default
-// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a26 */;
+(void)(static_cast((nullptr))) /* a33 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:42: warning: constructing{{.*}}empty string
+// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a33 */;
 
-(void)(static_cast(nullptr)) /* a27 */;
-// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default
-// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a27 */;
+(void)(static_cast(nullptr)) /* a34 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}empty string
+// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a34 */;
 
-(void)(static_cast((nullptr))) /* a28 */;
-// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default
-// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a28 */;
+(void)(static_cast((nullptr))) /* a35 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}empty string
+// CHECK-FIXES: {{^}}(void)(static_cast("")) /* a35 */;
   }
 }
 
@@ -689,55 +733,73 @@
 }
 
 void function_invocation() /* f */ {
-  // Single Argument
+  // Single Argument Function Invocation
   {
-function(nullptr) /* f1 */;
-// CHECK-MESSAGES: :[[@LINE-1]]:14: 

[PATCH] D115124: [clang-tidy] Fix `readability-container-size-empty` check for smart pointers

2021-12-05 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff created this revision.
fwolff added reviewers: mizvekov, compnerd.
fwolff added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes PR#51776 . If the object on 
which `size()` is called has an overloaded `operator->`, the span for `E` will 
include the `->`, and since the return type of `operator->` is a pointer, 
`readability-container-size-empty` will try to add another arrow, leading to 
the nonsensical `vp->->empty()` suggestion. This patch fixes this behavior.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115124

Files:
  clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
  
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
===
--- 
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
+++ 
clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
@@ -696,3 +696,17 @@
   instantiatedTemplateWithSizeCall();
   instantiatedTemplateWithSizeCall>();
 }
+
+namespace std {
+template 
+struct unique_ptr {
+  T *operator->() const;
+};
+} // namespace std
+
+bool call_through_unique_ptr(const std::unique_ptr> ) {
+  return ptr->size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be 
used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !ptr->empty();
+}
Index: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -194,7 +194,13 @@
   if (isBinaryOrTernary(E) || isa(E)) {
 ReplacementText = "(" + ReplacementText + ")";
   }
-  if (E->getType()->isPointerType())
+  const auto *OpCallExpr = dyn_cast(E);
+  if (OpCallExpr &&
+  OpCallExpr->getOperator() == OverloadedOperatorKind::OO_Arrow) {
+// This can happen if the object is a smart pointer. Don't add anything
+// because a '->' is already there (PR#51776), just call the method.
+ReplacementText += "empty()";
+  } else if (E->getType()->isPointerType())
 ReplacementText += "->empty()";
   else
 ReplacementText += ".empty()";


Index: clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/readability-container-size-empty.cpp
@@ -696,3 +696,17 @@
   instantiatedTemplateWithSizeCall();
   instantiatedTemplateWithSizeCall>();
 }
+
+namespace std {
+template 
+struct unique_ptr {
+  T *operator->() const;
+};
+} // namespace std
+
+bool call_through_unique_ptr(const std::unique_ptr> ) {
+  return ptr->size() > 0;
+  // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: the 'empty' method should be used
+  // CHECK-MESSAGES: :9:8: note: method 'vector'::empty() defined here
+  // CHECK-FIXES: {{^  }}return !ptr->empty();
+}
Index: clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
===
--- clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
+++ clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.cpp
@@ -194,7 +194,13 @@
   if (isBinaryOrTernary(E) || isa(E)) {
 ReplacementText = "(" + ReplacementText + ")";
   }
-  if (E->getType()->isPointerType())
+  const auto *OpCallExpr = dyn_cast(E);
+  if (OpCallExpr &&
+  OpCallExpr->getOperator() == OverloadedOperatorKind::OO_Arrow) {
+// This can happen if the object is a smart pointer. Don't add anything
+// because a '->' is already there (PR#51776), just call the method.
+ReplacementText += "empty()";
+  } else if (E->getType()->isPointerType())
 ReplacementText += "->empty()";
   else
 ReplacementText += ".empty()";
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D104830: AST: Create __va_list in the std namespace even in C.

2021-12-05 Thread Jessica Clarke via Phabricator via cfe-commits
jrtc27 added a comment.

Any luck with this?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D104830

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


[PATCH] D114565: [InstrProf] Attach debug info to counters

2021-12-05 Thread Kyungwoo Lee via Phabricator via cfe-commits
kyulee added inline comments.



Comment at: compiler-rt/lib/profile/InstrProfilingWriter.c:299
 
+  if (DebugInfoCorrelate) {
+ProfDataIOVec IOVecData[] = {

Should it be down after `__llvm_write_binary_ids` below although it doesn't do 
anything in general?
I saw D114566 seems to parse this to compute the other addresses. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114565

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


[clang] 296ebeb - Test commit to check access.

2021-12-05 Thread Jack Andersen via cfe-commits

Author: Jack Andersen
Date: 2021-12-05T14:35:33-05:00
New Revision: 296ebeb808a71e44a64e0f805cffc6e3a3bf6182

URL: 
https://github.com/llvm/llvm-project/commit/296ebeb808a71e44a64e0f805cffc6e3a3bf6182
DIFF: 
https://github.com/llvm/llvm-project/commit/296ebeb808a71e44a64e0f805cffc6e3a3bf6182.diff

LOG: Test commit to check access.

Added: 


Modified: 
clang/lib/Driver/Driver.cpp

Removed: 




diff  --git a/clang/lib/Driver/Driver.cpp b/clang/lib/Driver/Driver.cpp
index d501bd0262199..3b71fb8d7a876 100644
--- a/clang/lib/Driver/Driver.cpp
+++ b/clang/lib/Driver/Driver.cpp
@@ -1545,7 +1545,7 @@ int Driver::ExecuteCompilation(
   if (Diags.hasErrorOccurred())
 return 1;
 
-  // Set up response file names for each command, if necessary
+  // Set up response file names for each command, if necessary.
   for (auto  : C.getJobs())
 setUpResponseFiles(C, Job);
 



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


[PATCH] D115121: Add support for return values in bugprone-stringview-nullptr

2021-12-05 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp:174-194
   return applyFirst(
   {HandleTemporaryCXXFunctionalCastExpr,
HandleTemporaryCXXTemporaryObjectExprAndCompoundLiteralExpr,
-   HandleTemporaryCStyleCastExpr, HandleTemporaryCXXStaticCastExpr,
-   HandleStackCopyInitialization, HandleStackDirectInitialization,
+   HandleTemporaryCStyleCastExpr,
+   HandleTemporaryCXXStaticCastExpr,
+   HandleTemporaryReturnValue,
+   HandleStackCopyInitialization,

The diff isn't great here, but these weren't actually changed. I just inserted 
the new one, `HandleTemporaryReturnValue`, and it caused a reflow.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115121

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


[PATCH] D115121: Add support for return values in bugprone-stringview-nullptr

2021-12-05 Thread CJ Johnson via Phabricator via cfe-commits
CJ-Johnson created this revision.
CJ-Johnson added a reviewer: ymandel.
Herald added a subscriber: carlosgalvezp.
CJ-Johnson requested review of this revision.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

bugprone-stringview-nullptr was not initially written with tests for return 
statements. After landing the check, the thought crossed my mind to add such 
tests. After writing them, I realized they needed additional handling in the 
matchers.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115121

Files:
  clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp


Index: 
clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-stringview-nullptr.cpp
@@ -215,6 +215,37 @@
 // CHECK-MESSAGES: :[[@LINE-1]]:48: warning: constructing{{.*}}default
 // CHECK-FIXES: {{^}}(void)(static_cast("")) 
/* a28 */;
   }
+
+  // Return Value
+  {
+(void)([] -> std::string_view { return nullptr; }) /* a29 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* 
a29 */;
+
+(void)([] -> std::string_view { return (nullptr); }) /* a30 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* 
a30 */;
+
+(void)([] -> std::string_view { return {nullptr}; }) /* a31 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* 
a31 */;
+
+(void)([] -> std::string_view { return {(nullptr)}; }) /* a32 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* 
a32 */;
+
+(void)([] -> std::string_view { return {{nullptr}}; }) /* a33 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* 
a33 */;
+
+(void)([] -> std::string_view { return {{(nullptr)}}; }) /* a34 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* 
a34 */;
+
+(void)([] -> std::string_view { return {{}}; }) /* a35 */;
+// CHECK-MESSAGES: :[[@LINE-1]]:44: warning: constructing{{.*}}default
+// CHECK-FIXES: {{^}}(void)([] -> std::string_view { return {}; }) /* 
a35 */;
+  }
 }
 
 void stack_construction() /* b */ {
Index: clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
===
--- clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
+++ clang-tools-extra/clang-tidy/bugprone/StringviewNullptrCheck.cpp
@@ -74,6 +74,11 @@
   hasSourceExpression(StringViewConstructingFromNullExpr)),
   changeTo(node("null_argument_expr"), cat("\"\"")), construction_warning);
 
+  auto HandleTemporaryReturnValue = makeRule(
+  returnStmt(
+  
hasReturnValue(ignoringImpCasts(StringViewConstructingFromNullExpr))),
+  changeTo(node("construct_expr"), cat("{}")), construction_warning);
+
   auto HandleStackCopyInitialization = makeRule(
   varDecl(hasInitializer(implicitCastExpr(
   ignoringImpCasts(StringViewConstructingFromNullExpr,
@@ -169,15 +174,23 @@
   return applyFirst(
   {HandleTemporaryCXXFunctionalCastExpr,
HandleTemporaryCXXTemporaryObjectExprAndCompoundLiteralExpr,
-   HandleTemporaryCStyleCastExpr, HandleTemporaryCXXStaticCastExpr,
-   HandleStackCopyInitialization, HandleStackDirectInitialization,
+   HandleTemporaryCStyleCastExpr,
+   HandleTemporaryCXXStaticCastExpr,
+   HandleTemporaryReturnValue,
+   HandleStackCopyInitialization,
+   HandleStackDirectInitialization,
HandleStackDirectListAndCopyListInitialization,
-   HandleFieldCopyInitialization, HandleFieldOtherInitialization,
-   HandleConstructorInitialization, HandleDefaultArgumentInitialization,
-   HandleDefaultArgumentListInitialization, HandleHeapInitialization,
+   HandleFieldCopyInitialization,
+   HandleFieldOtherInitialization,
+   HandleConstructorInitialization,
+   HandleDefaultArgumentInitialization,
+   HandleDefaultArgumentListInitialization,
+   HandleHeapInitialization,
HandleFunctionArgumentInitialization,
-   HandleFunctionArgumentListInitialization, HandleAssignment,
-   HandleRelativeComparison, HandleEmptyEqualityComparison,
+   

[PATCH] D115118: [clang-tidy] Assume that `noexcept` functions won't throw anything in `bugprone-exception-escape` check

2021-12-05 Thread Fabian Wolff via Phabricator via cfe-commits
fwolff created this revision.
fwolff added reviewers: aaron.ballman, JonasToth, lebedev.ri.
fwolff added a project: clang-tools-extra.
Herald added subscribers: carlosgalvezp, xazax.hun.
fwolff requested review of this revision.
Herald added a subscriber: cfe-commits.

Fixes PR#52254 . The 
`ExceptionAnalyzer` currently recursively checks called functions, but this 
does not make sense if the called function is marked as `noexcept`. If it does 
throw, there should be a warning //for that function,// but not for every 
caller. In particular, this can lead to false positives if the called 
`noexcept` function calls other, potentially throwing, functions, in a way that 
ensures they will never actually throw.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D115118

Files:
  clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
  clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
@@ -288,6 +288,29 @@
   return recursion_helper(n);
 }
 
+// The following functions all incorrectly throw exceptions, *but* calling them
+// should not yield a warning because they are marked as noexcept (or similar).
+void est_dynamic_none() throw() { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'est_dynamic_none' which should not throw exceptions
+void est_basic_noexcept() noexcept { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'est_basic_noexcept' which should not throw exceptions
+void est_noexcept_true() noexcept(true) { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'est_noexcept_true' which should not throw exceptions
+template 
+void est_dependent_noexcept() noexcept(T::should_throw) { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in 
function 'est_dependent_noexcept>' which should not throw 
exceptions
+template 
+struct ShouldThrow {
+  static const bool should_throw = B;
+};
+
+void only_calls_non_throwing() noexcept {
+  est_dynamic_none();
+  est_basic_noexcept();
+  est_noexcept_true();
+  est_dependent_noexcept>();
+}
+
 int main() {
   // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: an exception may be thrown in 
function 'main' which should not throw exceptions
   throw 1;
Index: clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
===
--- clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
+++ clang-tools-extra/clang-tidy/utils/ExceptionAnalyzer.cpp
@@ -192,8 +192,27 @@
 Results.merge(Uncaught);
   } else if (const auto *Call = dyn_cast(St)) {
 if (const FunctionDecl *Func = Call->getDirectCallee()) {
-  ExceptionInfo Excs = throwsException(Func, CallStack);
-  Results.merge(Excs);
+  bool MightThrow;
+
+  switch (Func->getExceptionSpecType()) {
+  case EST_DynamicNone:
+  case EST_NoThrow:
+  case EST_BasicNoexcept:
+  case EST_DependentNoexcept: // Let's be optimistic here (necessary e.g.
+  // for variant assignment; see PR#52254)
+  case EST_NoexceptTrue:
+MightThrow = false;
+break;
+
+  default:
+MightThrow = true;
+break;
+  }
+
+  if (MightThrow) {
+ExceptionInfo Excs = throwsException(Func, CallStack);
+Results.merge(Excs);
+  }
 }
   } else {
 for (const Stmt *Child : St->children()) {


Index: clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
===
--- clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone-exception-escape.cpp
@@ -288,6 +288,29 @@
   return recursion_helper(n);
 }
 
+// The following functions all incorrectly throw exceptions, *but* calling them
+// should not yield a warning because they are marked as noexcept (or similar).
+void est_dynamic_none() throw() { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'est_dynamic_none' which should not throw exceptions
+void est_basic_noexcept() noexcept { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'est_basic_noexcept' which should not throw exceptions
+void est_noexcept_true() noexcept(true) { throw 42; }
+// CHECK-MESSAGES: :[[@LINE-1]]:6: warning: an exception may be thrown in function 'est_noexcept_true' which should not throw exceptions
+template 
+void est_dependent_noexcept() noexcept(T::should_throw) 

[PATCH] D114583: [clang-format] Adjust braced list detection

2021-12-05 Thread S. B. Tam via Phabricator via cfe-commits
cpplearner added a comment.

Yes, I need someone to commit it on my behalf. My name and email address: `Tan 
S. B. `


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

https://reviews.llvm.org/D114583

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


[PATCH] D114601: Read path to CUDA from env. variable CUDA_PATH on Windows

2021-12-05 Thread Mojca Miklavec via Phabricator via cfe-commits
mojca added a comment.

What can/should I do next in order to proceed with this?


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

https://reviews.llvm.org/D114601

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


[PATCH] D114865: [AMDGPU][OpenMP] Use -amdgpu-fixed-function-abi

2021-12-05 Thread Jon Chesterfield via Phabricator via cfe-commits
JonChesterfield added a comment.

Probably obsoleted by 729bf9b26b657df8 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114865

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


[PATCH] D115050: [clang-format] PR48916 PointerAlignment not working when using C++20 init-statement in for loop

2021-12-05 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 391915.
MyDeveloperDay marked 2 inline comments as done.
MyDeveloperDay added a comment.

Address review comments


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

https://reviews.llvm.org/D115050

Files:
  clang/lib/Format/FormatToken.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -1924,6 +1924,9 @@
   verifyFormat("int *a = f1();", Style);
   verifyFormat("int  = f2();", Style);
   verifyFormat("int & = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const auto  : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const int  : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo  : {1, 2, 3})", Style);
 
   Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   verifyFormat("Const unsigned int *c;\n"
@@ -1943,6 +1946,9 @@
   verifyFormat("int* a = f1();", Style);
   verifyFormat("int& b = f2();", Style);
   verifyFormat("int&& c = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const auto& c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const int& c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo& c : {1, 2, 3})", Style);
 
   Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   verifyFormat("Const unsigned int* c;\n"
@@ -1979,6 +1985,9 @@
   verifyFormat("int* a = f1();", Style);
   verifyFormat("int & b = f2();", Style);
   verifyFormat("int && c = f3();", Style);
+  verifyFormat("for (auto a = 0, b = 0; const auto & c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const int & c : {1, 2, 3})", Style);
+  verifyFormat("for (auto a = 0, b = 0; const Foo & c : {1, 2, 3})", Style);
 
   Style.AlignConsecutiveDeclarations = FormatStyle::ACS_Consecutive;
   verifyFormat("Const unsigned int*  c;\n"
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3024,8 +3024,12 @@
  Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
 (Left.is(TT_AttributeParen) || Left.canBePointerOrReferenceQualifier()))
   return true;
+if (Left.Tok.isLiteral())
+  return true;
+if (Left.isTypeOrIdentifier())
+  return getTokenPointerOrReferenceAlignment(Right) !=
+ FormatStyle::PAS_Left;
 return (
-Left.Tok.isLiteral() ||
 (!Left.isOneOf(TT_PointerOrReference, tok::l_paren) &&
  (getTokenPointerOrReferenceAlignment(Right) != FormatStyle::PAS_Left ||
   (Line.IsMultiVariableDeclStmt &&
@@ -3044,18 +3048,33 @@
  Style.SpaceAroundPointerQualifiers == FormatStyle::SAPQ_Both) &&
 Right.canBePointerOrReferenceQualifier())
   return true;
-return Right.Tok.isLiteral() || Right.is(TT_BlockComment) ||
-   (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) &&
-!Right.is(TT_StartOfName)) ||
-   (Right.is(tok::l_brace) && Right.is(BK_Block)) ||
-   (!Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,
-   tok::l_paren) &&
-(getTokenPointerOrReferenceAlignment(Left) !=
- FormatStyle::PAS_Right &&
- !Line.IsMultiVariableDeclStmt) &&
-Left.Previous &&
-!Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
-tok::l_square));
+// & 1
+if (Right.Tok.isLiteral())
+  return true;
+// & /* comment
+if (Right.is(TT_BlockComment))
+  return true;
+// foo() -> const Bar * override/final
+if (Right.isOneOf(Keywords.kw_override, Keywords.kw_final) &&
+!Right.is(TT_StartOfName))
+  return true;
+// & {
+if (Right.is(tok::l_brace) && Right.is(BK_Block))
+  return true;
+// for (auto a = 0, b = 0; const auto& c : {1, 2, 3})
+if (Left.Previous && Left.Previous->isTypeOrIdentifier() &&
+Right.is(tok::identifier))
+  return getTokenPointerOrReferenceAlignment(Left) !=
+ FormatStyle::PAS_Right;
+
+return !Right.isOneOf(TT_PointerOrReference, TT_ArraySubscriptLSquare,
+  tok::l_paren) &&
+   (getTokenPointerOrReferenceAlignment(Left) !=
+FormatStyle::PAS_Right &&
+!Line.IsMultiVariableDeclStmt) &&
+   Left.Previous &&
+   !Left.Previous->isOneOf(tok::l_paren, tok::coloncolon,
+   tok::l_square);
   }
   // Ensure right pointer alignment with ellipsis e.g. int *...P
   if (Left.is(tok::ellipsis) && Left.Previous &&
Index: clang/lib/Format/FormatToken.h

[PATCH] D113096: [X86][MS-InlineAsm] Add constraint *m for memory access w/ global var

2021-12-05 Thread Phoebe Wang via Phabricator via cfe-commits
pengfei added a comment.

@skan This change seems don't work for -fpic, see 
https://godbolt.org/z/h3nWoerPe
I don't have any idea to handle these cases, I suggest we should revert this 
patch first.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113096

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


[PATCH] D112730: [clang-tidy] Add AUTOSAR module

2021-12-05 Thread Carlos Galvez via Phabricator via cfe-commits
carlosgalvezp added a comment.

@tstellar Do you have any updates on the topic? What approximate time frame 
should I expect? Thanks!


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

https://reviews.llvm.org/D112730

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


[PATCH] D111400: [Clang] Implement P2242R3

2021-12-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

Regression compared to the status quo:
This code no longer warns (as noted by Hubert above)

  auto f = [](bool b) {
if (b) return 42;
static int x = 0;
return x;
  };
  constexpr int x = f(true);
  const int *p = 

GCC doesn't warn and... if we wanted to produce a warning there, I have no idea 
how to go about it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

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


[PATCH] D111400: [Clang] Implement P2242R3

2021-12-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 391906.
cor3ntin added a comment.

Treat non-literals in constexpr as an error before C++23


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/test/CXX/basic/basic.types/p10.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/dtor.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3-2b.cpp
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
  clang/test/Lexer/cxx-features.cpp
  clang/test/SemaCXX/constant-expression-cxx14.cpp
  clang/test/SemaCXX/constant-expression-cxx2b.cpp
  clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -1352,7 +1352,7 @@
 
   Non-literal variables (and labels and gotos) in constexpr functions
   https://wg21.link/P2242R3;>P2242R3
-  No
+  Clang 14
 
 
   Character encoding of diagnostic text
Index: clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
===
--- clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
+++ clang/test/SemaCXX/cxx1z-constexpr-lambdas.cpp
@@ -115,11 +115,6 @@
 constexpr const char *Str = "abc";
 static_assert(fp4(Str) == Str);
 
-auto NCL = [](int i) { static int j; return j; }; //expected-note{{declared here}}
-constexpr int (*fp5)(int) = NCL;
-constexpr int I =  //expected-error{{must be initialized by a constant expression}}
-  fp5(5); //expected-note{{non-constexpr function}} 
-
 namespace test_dont_always_instantiate_constexpr_templates {
 
 auto explicit_return_type = [](auto x) -> int { return x.get(); };
Index: clang/test/SemaCXX/constant-expression-cxx2b.cpp
===
--- /dev/null
+++ clang/test/SemaCXX/constant-expression-cxx2b.cpp
@@ -0,0 +1,23 @@
+// RUN: %clang_cc1 -std=c++2b -fsyntax-only -verify %s -fcxx-exceptions -triple=x86_64-linux-gnu
+
+constexpr int f(int n) {  // expected-error {{constexpr function never produces a constant expression}}
+  static const int m = n; //  expected-note {{declared here}}
+  return m;   //  expected-note {{initializer of 'm' is not a constant expression}}
+}
+constexpr int g(int n) {// expected-error {{constexpr function never produces a constant expression}}
+  thread_local const int m = n; //  expected-note {{declared here}}
+  return m; //  expected-note {{initializer of 'm' is not a constant expression}}
+}
+
+constexpr int h(int n) {
+  if (!n)
+return 0;
+  static const int m = n;
+  return m;
+}
+constexpr int i(int n) {
+  if (!n)
+return 0;
+  thread_local const int m = n;
+  return m;
+}
Index: clang/test/SemaCXX/constant-expression-cxx14.cpp
===
--- clang/test/SemaCXX/constant-expression-cxx14.cpp
+++ clang/test/SemaCXX/constant-expression-cxx14.cpp
@@ -44,14 +44,6 @@
   return 3 * k3 + 5 * k2 + n * k - 20;
 }
 static_assert(g(2) == 42, "");
-constexpr int h(int n) {
-  static const int m = n; // expected-error {{static variable not permitted in a constexpr function}}
-  return m;
-}
-constexpr int i(int n) {
-  thread_local const int m = n; // expected-error {{thread_local variable not permitted in a constexpr function}}
-  return m;
-}
 
 // if-statements can be used in constexpr functions.
 constexpr int j(int k) {
@@ -65,7 +57,9 @@
   return 2;
 }
   }
-} // expected-note 2{{control reached end of constexpr function}}
+} // expected-warning {{non-void}} \
+  //expected-note 2{{control reached end of constexpr function}}
+
 static_assert(j(0) == -3, "");
 static_assert(j(1) == 5, "");
 static_assert(j(2), ""); // expected-error {{constant expression}} expected-note {{in call to 'j(2)'}}
Index: clang/test/Lexer/cxx-features.cpp
===
--- clang/test/Lexer/cxx-features.cpp
+++ clang/test/Lexer/cxx-features.cpp
@@ -277,7 +277,7 @@
 #error "wrong value for __cpp_lambdas"
 #endif
 
-#if check(constexpr, 0, 200704, 201304, 201603, 201907, 201907)
+#if check(constexpr, 0, 200704, 201304, 201603, 201907, 202110)
 #error "wrong value for __cpp_constexpr"
 #endif
 
Index: clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
===
--- clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
+++ clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p3.cpp
@@ -1,6 +1,7 @@
-// RUN: %clang_cc1 -verify -fcxx-exceptions -triple=x86_64-linux-gnu -std=c++11 -Werror=c++14-extensions -Werror=c++20-extensions %s
-// RUN: %clang_cc1 -verify 

[PATCH] D115061: [clang-format][NFC] Prefer pass by reference

2021-12-05 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks reopened this revision.
HazardyKnusperkeks added a comment.
This revision is now accepted and ready to land.

I will revert.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115061

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


[PATCH] D115064: [clang-format][NFC] Replace deque with vector

2021-12-05 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added a comment.

In D115064#3171950 , @owenpan wrote:

> In D115064#3170615 , @curdeius 
> wrote:
>
>> Maybe using `llvm::SmallVector` with some well-thought (data-based) static 
>> number of elements would be better here, WDYT?
>
> I tend to agree as LLVM style 
> 
>  prefers `SmallVector` to `vector`.

Okay, didn't know I can use it without a number. Will update.


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

https://reviews.llvm.org/D115064

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


[PATCH] D111400: [Clang] Implement P2242R3

2021-12-05 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D111400#3165668 , 
@hubert.reinterpretcast wrote:

> In D111400#3164301 , @cor3ntin 
> wrote:
>
>> If the issue is regarding the support and extension warning in C++20 and 
>> older modes, it's something I can address by conserving the status quo in 
>> older versions.
>
> I think preserving the status quo in older modes is fine.
>
>> If the ask is a more involved modification of how clang does SFINAE in 
>> general, i don't think that i can take that on.
>
> As long as this patch isn't making a change to the older modes, then there's 
> nothing it's doing that requires special attention of the "disable if 
> checking for SFINAE purposes" variety.

Somehow I missed that message, oups

I will make non literal ill-formed in 20.
I think labels can be left as is.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D111400

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