[PATCH] D92547: [c++2b] Add option -std=c++2b to enable support for potential C++2b features.

2020-12-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius created this revision.
curdeius added reviewers: rsmith, aaron.ballman, hubert.reinterpretcast, 
faisalv.
Herald added subscribers: cfe-commits, dexonsmith.
Herald added a project: clang.
curdeius requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92547

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Basic/LangStandards.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/std.cpp
  clang/test/Driver/unknown-std.cpp
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -9,6 +9,15 @@
 // BLOCKS:#define __block __attribute__((__blocks__(byref)))
 //
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s
+//
+// CXX2B:#define __GNUG__ 4
+// CXX2B:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX2B:#define __GXX_RTTI 1
+// CXX2B:#define __GXX_WEAK__ 1
+// CXX2B:#define __cplusplus 202101L
+// CXX2B:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
 //
@@ -122,6 +131,13 @@
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s
+//
+// GXX2B:#define __GNUG__ 4
+// GXX2B:#define __GXX_WEAK__ 1
+// GXX2B:#define __cplusplus 202101L
+// GXX2B:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
 //
Index: clang/test/Driver/unknown-std.cpp
===
--- clang/test/Driver/unknown-std.cpp
+++ clang/test/Driver/unknown-std.cpp
@@ -17,6 +17,8 @@
 // CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++20' for 'ISO C++ 2020 DIS' standard
 // CHECK-NEXT: note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++2b' for 'Working draft for ISO C++ 2023 DIS' standard
+// CHECK-NEXT: note: use 'gnu++2b' for 'Working draft for ISO C++ 2023 DIS with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
Index: clang/test/Driver/std.cpp
===
--- clang/test/Driver/std.cpp
+++ clang/test/Driver/std.cpp
@@ -11,7 +11,8 @@
 // RUN: not %clang -std=gnu++1z %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX1Z %s
 // RUN: not %clang -std=c++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX2A %s
 // RUN: not %clang -std=gnu++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX2A %s
-
+// RUN: not %clang -std=c++2b %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX2B %s
+// RUN: not %clang -std=gnu++2b %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX2B %s
 
 void f(int n) {
   typeof(n)();
@@ -48,3 +49,8 @@
 // GNUXX2A-NOT: undeclared identifier 'typeof'
 // GNUXX2A-NOT: undeclared identifier 'decltype'
 
+// CXX2B: undeclared identifier 'typeof'
+// CXX2B-NOT: undeclared identifier 'decltype'
+
+// GNUXX2B-NOT: undeclared identifier 'typeof'
+// GNUXX2B-NOT: undeclared identifier 'decltype'
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -376,8 +376,11 @@
   Builder.defineMacro("__STDC_VERSION__", "199409L");
   } else {
 //   -- __cplusplus
+// FIXME: Use correct value for C++23.
+if (LangOpts.CPlusPlus2b)
+  Builder.defineMacro("__cplusplus", "202101L");
 //  [C++20] The integer literal 202002L.
-if (LangOpts.CPlusPlus20)
+else if (LangOpts.CPlusPlus20)
   Builder.defineMacro("__cplusplus", "202002L");
 //  [C++17] The integer literal 201703L.
 else if (LangOpts.CPlusPlus17)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2388,6 +2388,7 @@
   Opts.CPlusPlus14 = Std.isCPlusPlus14();
   Opts.CPlusPlus17 

[PATCH] D92547: [c++2b] Add option -std=c++2b to enable support for potential C++2b features.

2020-12-03 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith added a comment.

There are some mechanical changes we should make to our documentation too, 
particularly www/cxx_status.html.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92547

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


[PATCH] D92547: [c++2b] Add option -std=c++2b to enable support for potential C++2b features.

2020-12-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

In D92547#2430428 , @rsmith wrote:

> There are some mechanical changes we should make to our documentation too, 
> particularly www/cxx_status.html.

Ok, I will soon send a patch to update cxx_status adding C++2b.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92547

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


[PATCH] D92078: [asan] Default to -asan-use-private-alias=1

2020-12-03 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

https://reviews.llvm.org/D55156
So with this patch no code increase but we lose ODR checks.
To preserve checks we need -fsanitize-address-use-odr-indicator but then binary 
size increase.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92078

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


[clang] 6627a3c - [c++2b] Add option -std=c++2b to enable support for potential C++2b features.

2020-12-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2020-12-03T10:27:47+01:00
New Revision: 6627a3c2873fdf7ccba1a1573371079be48b36e8

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

LOG: [c++2b] Add option -std=c++2b to enable support for potential C++2b 
features.

Reviewed By: rsmith

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

Added: 


Modified: 
clang/include/clang/Basic/LangOptions.def
clang/include/clang/Basic/LangStandard.h
clang/include/clang/Basic/LangStandards.def
clang/lib/Frontend/CompilerInvocation.cpp
clang/lib/Frontend/InitPreprocessor.cpp
clang/test/Driver/std.cpp
clang/test/Driver/unknown-std.cpp
clang/test/Preprocessor/init.c

Removed: 




diff  --git a/clang/include/clang/Basic/LangOptions.def 
b/clang/include/clang/Basic/LangOptions.def
index 071cc314b7d1..19fb4ae82b89 100644
--- a/clang/include/clang/Basic/LangOptions.def
+++ b/clang/include/clang/Basic/LangOptions.def
@@ -92,6 +92,7 @@ LANGOPT(CPlusPlus11   , 1, 0, "C++11")
 LANGOPT(CPlusPlus14   , 1, 0, "C++14")
 LANGOPT(CPlusPlus17   , 1, 0, "C++17")
 LANGOPT(CPlusPlus20   , 1, 0, "C++20")
+LANGOPT(CPlusPlus2b   , 1, 0, "C++2b")
 LANGOPT(ObjC  , 1, 0, "Objective-C")
 BENIGN_LANGOPT(ObjCDefaultSynthProperties , 1, 0,
"Objective-C auto-synthesized properties")

diff  --git a/clang/include/clang/Basic/LangStandard.h 
b/clang/include/clang/Basic/LangStandard.h
index ad7f7510b234..f82ce05a6369 100644
--- a/clang/include/clang/Basic/LangStandard.h
+++ b/clang/include/clang/Basic/LangStandard.h
@@ -49,11 +49,12 @@ enum LangFeatures {
   CPlusPlus14 = (1 << 7),
   CPlusPlus17 = (1 << 8),
   CPlusPlus20 = (1 << 9),
-  Digraphs = (1 << 10),
-  GNUMode = (1 << 11),
-  HexFloat = (1 << 12),
-  ImplicitInt = (1 << 13),
-  OpenCL = (1 << 14)
+  CPlusPlus2b = (1 << 10),
+  Digraphs = (1 << 11),
+  GNUMode = (1 << 12),
+  HexFloat = (1 << 13),
+  ImplicitInt = (1 << 14),
+  OpenCL = (1 << 15)
 };
 
 /// LangStandard - Information about the properties of a particular language
@@ -111,6 +112,9 @@ struct LangStandard {
   /// isCPlusPlus20 - Language is a C++20 variant (or later).
   bool isCPlusPlus20() const { return Flags & CPlusPlus20; }
 
+  /// isCPlusPlus2b - Language is a post-C++20 variant (or later).
+  bool isCPlusPlus2b() const { return Flags & CPlusPlus2b; }
+
   /// hasDigraphs - Language supports digraphs.
   bool hasDigraphs() const { return Flags & Digraphs; }
 

diff  --git a/clang/include/clang/Basic/LangStandards.def 
b/clang/include/clang/Basic/LangStandards.def
index 7b915c312746..f086d8a43ccb 100644
--- a/clang/include/clang/Basic/LangStandards.def
+++ b/clang/include/clang/Basic/LangStandards.def
@@ -152,6 +152,16 @@ LANGSTANDARD(gnucxx20, "gnu++20",
  CPlusPlus20 | Digraphs | HexFloat | GNUMode)
 LANGSTANDARD_ALIAS_DEPR(gnucxx20, "gnu++2a")
 
+LANGSTANDARD(cxx2b, "c++2b",
+ CXX, "Working draft for ISO C++ 2023 DIS",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 
|
+ CPlusPlus20 | CPlusPlus2b | Digraphs | HexFloat)
+
+LANGSTANDARD(gnucxx2b, "gnu++2b",
+ CXX, "Working draft for ISO C++ 2023 DIS with GNU extensions",
+ LineComment | CPlusPlus | CPlusPlus11 | CPlusPlus14 | CPlusPlus17 
|
+ CPlusPlus20 | CPlusPlus2b | Digraphs | HexFloat | GNUMode)
+
 // OpenCL
 LANGSTANDARD(opencl10, "cl1.0",
  OpenCL, "OpenCL 1.0",

diff  --git a/clang/lib/Frontend/CompilerInvocation.cpp 
b/clang/lib/Frontend/CompilerInvocation.cpp
index 1c63ce612be0..e31f6aa34b36 100644
--- a/clang/lib/Frontend/CompilerInvocation.cpp
+++ b/clang/lib/Frontend/CompilerInvocation.cpp
@@ -2388,6 +2388,7 @@ void CompilerInvocation::setLangDefaults(LangOptions 
&Opts, InputKind IK,
   Opts.CPlusPlus14 = Std.isCPlusPlus14();
   Opts.CPlusPlus17 = Std.isCPlusPlus17();
   Opts.CPlusPlus20 = Std.isCPlusPlus20();
+  Opts.CPlusPlus2b = Std.isCPlusPlus2b();
   Opts.Digraphs = Std.hasDigraphs();
   Opts.GNUMode = Std.isGNUMode();
   Opts.GNUInline = !Opts.C99 && !Opts.CPlusPlus;

diff  --git a/clang/lib/Frontend/InitPreprocessor.cpp 
b/clang/lib/Frontend/InitPreprocessor.cpp
index 86d5e61b7112..42eed9f6c7b5 100644
--- a/clang/lib/Frontend/InitPreprocessor.cpp
+++ b/clang/lib/Frontend/InitPreprocessor.cpp
@@ -376,8 +376,11 @@ static void InitializeStandardPredefinedMacros(const 
TargetInfo &TI,
   Builder.defineMacro("__STDC_VERSION__", "199409L");
   } else {
 //   -- __cplusplus
+// FIXME: Use correct value for C++23.
+if (LangOpts.CPlusPlus2b)
+  Builder.defineMacro("__cplusplus", "202101L");
 //  [C++20] The integer literal 202002L.
-if (LangOpts.CPlusPlus20)
+else if (LangOpts.CPlusPlus20)
   Builder.defineMacro("__cplusplu

[PATCH] D92547: [c++2b] Add option -std=c++2b to enable support for potential C++2b features.

2020-12-03 Thread Marek Kurdej via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG6627a3c2873f: [c++2b] Add option -std=c++2b to enable 
support for potential C++2b features. (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92547

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Basic/LangStandard.h
  clang/include/clang/Basic/LangStandards.def
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/lib/Frontend/InitPreprocessor.cpp
  clang/test/Driver/std.cpp
  clang/test/Driver/unknown-std.cpp
  clang/test/Preprocessor/init.c

Index: clang/test/Preprocessor/init.c
===
--- clang/test/Preprocessor/init.c
+++ clang/test/Preprocessor/init.c
@@ -9,6 +9,15 @@
 // BLOCKS:#define __block __attribute__((__blocks__(byref)))
 //
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2B %s
+//
+// CXX2B:#define __GNUG__ 4
+// CXX2B:#define __GXX_EXPERIMENTAL_CXX0X__ 1
+// CXX2B:#define __GXX_RTTI 1
+// CXX2B:#define __GXX_WEAK__ 1
+// CXX2B:#define __cplusplus 202101L
+// CXX2B:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=c++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix CXX2A %s
 //
@@ -122,6 +131,13 @@
 // RUN: %clang_cc1 -ffreestanding -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix FREESTANDING %s
 // FREESTANDING:#define __STDC_HOSTED__ 0
 //
+// RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2b -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2B %s
+//
+// GXX2B:#define __GNUG__ 4
+// GXX2B:#define __GXX_WEAK__ 1
+// GXX2B:#define __cplusplus 202101L
+// GXX2B:#define __private_extern__ extern
+//
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++20 -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
 // RUN: %clang_cc1 -x c++ -fgnuc-version=4.2.1 -std=gnu++2a -E -dM < /dev/null | FileCheck -match-full-lines -check-prefix GXX2A %s
 //
Index: clang/test/Driver/unknown-std.cpp
===
--- clang/test/Driver/unknown-std.cpp
+++ clang/test/Driver/unknown-std.cpp
@@ -17,6 +17,8 @@
 // CHECK-NEXT: note: use 'gnu++17' for 'ISO C++ 2017 with amendments and GNU extensions' standard
 // CHECK-NEXT: note: use 'c++20' for 'ISO C++ 2020 DIS' standard
 // CHECK-NEXT: note: use 'gnu++20' for 'ISO C++ 2020 DIS with GNU extensions' standard
+// CHECK-NEXT: note: use 'c++2b' for 'Working draft for ISO C++ 2023 DIS' standard
+// CHECK-NEXT: note: use 'gnu++2b' for 'Working draft for ISO C++ 2023 DIS with GNU extensions' standard
 // CUDA-NEXT: note: use 'cuda' for 'NVIDIA CUDA(tm)' standard
 
 // Make sure that no other output is present.
Index: clang/test/Driver/std.cpp
===
--- clang/test/Driver/std.cpp
+++ clang/test/Driver/std.cpp
@@ -11,7 +11,8 @@
 // RUN: not %clang -std=gnu++1z %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX1Z %s
 // RUN: not %clang -std=c++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX2A %s
 // RUN: not %clang -std=gnu++2a %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX2A %s
-
+// RUN: not %clang -std=c++2b %s -fsyntax-only 2>&1 | FileCheck -check-prefix=CXX2B %s
+// RUN: not %clang -std=gnu++2b %s -fsyntax-only 2>&1 | FileCheck -check-prefix=GNUXX2B %s
 
 void f(int n) {
   typeof(n)();
@@ -48,3 +49,8 @@
 // GNUXX2A-NOT: undeclared identifier 'typeof'
 // GNUXX2A-NOT: undeclared identifier 'decltype'
 
+// CXX2B: undeclared identifier 'typeof'
+// CXX2B-NOT: undeclared identifier 'decltype'
+
+// GNUXX2B-NOT: undeclared identifier 'typeof'
+// GNUXX2B-NOT: undeclared identifier 'decltype'
Index: clang/lib/Frontend/InitPreprocessor.cpp
===
--- clang/lib/Frontend/InitPreprocessor.cpp
+++ clang/lib/Frontend/InitPreprocessor.cpp
@@ -376,8 +376,11 @@
   Builder.defineMacro("__STDC_VERSION__", "199409L");
   } else {
 //   -- __cplusplus
+// FIXME: Use correct value for C++23.
+if (LangOpts.CPlusPlus2b)
+  Builder.defineMacro("__cplusplus", "202101L");
 //  [C++20] The integer literal 202002L.
-if (LangOpts.CPlusPlus20)
+else if (LangOpts.CPlusPlus20)
   Builder.defineMacro("__cplusplus", "202002L");
 //  [C++17] The integer literal 201703L.
 else if (LangOpts.CPlusPlus17)
Index: clang/lib/Frontend/CompilerInvocation.cpp
===
--- clang/lib/Frontend/CompilerInvocation.cpp
+++ clang/lib/Frontend/CompilerInvocation.cpp
@@ -2388,6 +2388,7 @@
   Opts.CPlusPlus14 = Std.is

[clang] fe21c86 - [clang-format] De-duplicate includes with leading or trailing whitespace.

2020-12-03 Thread Marek Kurdej via cfe-commits

Author: Marek Kurdej
Date: 2020-12-03T10:59:46+01:00
New Revision: fe21c86ee75f93bb0372660c004ac2325ac12cdc

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

LOG: [clang-format] De-duplicate includes with leading or trailing whitespace.

This fixes PR46555 (https://bugs.llvm.org/show_bug.cgi?id=46555).

Reviewed By: MyDeveloperDay

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

Added: 


Modified: 
clang/lib/Format/Format.cpp
clang/unittests/Format/SortIncludesTest.cpp

Removed: 




diff  --git a/clang/lib/Format/Format.cpp b/clang/lib/Format/Format.cpp
index 235621c4f9aa8..6f96395f608d2 100644
--- a/clang/lib/Format/Format.cpp
+++ b/clang/lib/Format/Format.cpp
@@ -2179,7 +2179,8 @@ static void sortCppIncludes(const FormatStyle &Style,
   // Deduplicate #includes.
   Indices.erase(std::unique(Indices.begin(), Indices.end(),
 [&](unsigned LHSI, unsigned RHSI) {
-  return Includes[LHSI].Text == 
Includes[RHSI].Text;
+  return Includes[LHSI].Text.trim() ==
+ Includes[RHSI].Text.trim();
 }),
 Indices.end());
 

diff  --git a/clang/unittests/Format/SortIncludesTest.cpp 
b/clang/unittests/Format/SortIncludesTest.cpp
index 279c4ee15a10c..cb2d2bd782fc8 100644
--- a/clang/unittests/Format/SortIncludesTest.cpp
+++ b/clang/unittests/Format/SortIncludesTest.cpp
@@ -289,6 +289,19 @@ TEST_F(SortIncludesTest, LeadingWhitespace) {
 sort("# include \"a.h\"\n"
  "#  include \"c.h\"\n"
  "#   include \"b.h\"\n"));
+  EXPECT_EQ("#include \"a.h\"\n", sort("#include \"a.h\"\n"
+   " #include \"a.h\"\n"));
+}
+
+TEST_F(SortIncludesTest, TrailingWhitespace) {
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\" \n"
+ "#include \"c.h\"  \n"
+ "#include \"b.h\"   \n"));
+  EXPECT_EQ("#include \"a.h\"\n", sort("#include \"a.h\"\n"
+   "#include \"a.h\" \n"));
 }
 
 TEST_F(SortIncludesTest, GreaterInComment) {



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


[PATCH] D88296: [clang-format] De-duplicate includes with leading or trailing whitespace.

2020-12-03 Thread Marek Kurdej 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 rGfe21c86ee75f: [clang-format] De-duplicate includes with 
leading or trailing whitespace. (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D88296

Files:
  clang/lib/Format/Format.cpp
  clang/unittests/Format/SortIncludesTest.cpp


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -289,6 +289,19 @@
 sort("# include \"a.h\"\n"
  "#  include \"c.h\"\n"
  "#   include \"b.h\"\n"));
+  EXPECT_EQ("#include \"a.h\"\n", sort("#include \"a.h\"\n"
+   " #include \"a.h\"\n"));
+}
+
+TEST_F(SortIncludesTest, TrailingWhitespace) {
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\" \n"
+ "#include \"c.h\"  \n"
+ "#include \"b.h\"   \n"));
+  EXPECT_EQ("#include \"a.h\"\n", sort("#include \"a.h\"\n"
+   "#include \"a.h\" \n"));
 }
 
 TEST_F(SortIncludesTest, GreaterInComment) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2179,7 +2179,8 @@
   // Deduplicate #includes.
   Indices.erase(std::unique(Indices.begin(), Indices.end(),
 [&](unsigned LHSI, unsigned RHSI) {
-  return Includes[LHSI].Text == 
Includes[RHSI].Text;
+  return Includes[LHSI].Text.trim() ==
+ Includes[RHSI].Text.trim();
 }),
 Indices.end());
 


Index: clang/unittests/Format/SortIncludesTest.cpp
===
--- clang/unittests/Format/SortIncludesTest.cpp
+++ clang/unittests/Format/SortIncludesTest.cpp
@@ -289,6 +289,19 @@
 sort("# include \"a.h\"\n"
  "#  include \"c.h\"\n"
  "#   include \"b.h\"\n"));
+  EXPECT_EQ("#include \"a.h\"\n", sort("#include \"a.h\"\n"
+   " #include \"a.h\"\n"));
+}
+
+TEST_F(SortIncludesTest, TrailingWhitespace) {
+  EXPECT_EQ("#include \"a.h\"\n"
+"#include \"b.h\"\n"
+"#include \"c.h\"\n",
+sort("#include \"a.h\" \n"
+ "#include \"c.h\"  \n"
+ "#include \"b.h\"   \n"));
+  EXPECT_EQ("#include \"a.h\"\n", sort("#include \"a.h\"\n"
+   "#include \"a.h\" \n"));
 }
 
 TEST_F(SortIncludesTest, GreaterInComment) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -2179,7 +2179,8 @@
   // Deduplicate #includes.
   Indices.erase(std::unique(Indices.begin(), Indices.end(),
 [&](unsigned LHSI, unsigned RHSI) {
-  return Includes[LHSI].Text == Includes[RHSI].Text;
+  return Includes[LHSI].Text.trim() ==
+ Includes[RHSI].Text.trim();
 }),
 Indices.end());
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 7ec6188 - [OpenCL] Add some more kernel argument tests

2020-12-03 Thread Sven van Haastregt via cfe-commits

Author: Sven van Haastregt
Date: 2020-12-03T10:21:29Z
New Revision: 7ec61889214d98f09eec7f18d0db66dcfdc68323

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

LOG: [OpenCL] Add some more kernel argument tests

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

Added: 


Modified: 
clang/test/SemaOpenCL/invalid-kernel-parameters.cl

Removed: 




diff  --git a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl 
b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
index 9fce92dbd6c3..96e6f7886b73 100644
--- a/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ b/clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -23,7 +23,12 @@ __kernel void no_privatearray(__private int i[]) { }
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_defaultarray(int i[]) { }
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_genericptr(generic int *ptr) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_private_ptr(private int * global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
@@ -32,6 +37,8 @@ kernel void no_ptr_private_ptr_ptr(global int * private * 
global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 #endif
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not 
be qualified with an address space}}
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptr
diff _t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them



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


[PATCH] D92406: [OpenCL] Add some more kernel argument tests

2020-12-03 Thread Sven van Haastregt 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 rG7ec61889214d: [OpenCL] Add some more kernel argument tests 
(authored by svenvh).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92406

Files:
  clang/test/SemaOpenCL/invalid-kernel-parameters.cl


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -23,7 +23,12 @@
 // expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+// expected-error@+1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
+__kernel void no_defaultarray(int i[]) { }
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_genericptr(generic int *ptr) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_private_ptr(private int * global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
@@ -32,6 +37,8 @@
 // expected-error@-1{{pointer arguments to kernel functions must reside in 
'__global', '__constant' or '__local' address space}}
 #endif
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not 
be qualified with an address space}}
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them


Index: clang/test/SemaOpenCL/invalid-kernel-parameters.cl
===
--- clang/test/SemaOpenCL/invalid-kernel-parameters.cl
+++ clang/test/SemaOpenCL/invalid-kernel-parameters.cl
@@ -23,7 +23,12 @@
 // expected-error@+1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 __kernel void no_addrsp_ptr(int *ptr) { }
 
+// expected-error@+1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
+__kernel void no_defaultarray(int i[]) { }
+
 #if __OPENCL_C_VERSION__ >= CL_VERSION_2_0
+kernel void no_genericptr(generic int *ptr) { }
+// expected-error@-1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 kernel void no_ptr_private_ptr(private int * global *i) { }
 // expected-error@-1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 kernel void no_ptr_ptr_private_ptr(private int * global * global *i) { }
@@ -32,6 +37,8 @@
 // expected-error@-1{{pointer arguments to kernel functions must reside in '__global', '__constant' or '__local' address space}}
 #endif
 
+void no_addrspace_param(global int x) { } // expected-error{{parameter may not be qualified with an address space}}
+
 // Disallowed: parameters with type
 // bool, half, size_t, ptrdiff_t, intptr_t, and uintptr_t
 // or a struct / union with any of these types in them
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 1e14588 - [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-12-03 Thread Gabor Marton via cfe-commits

Author: Gabor Marton
Date: 2020-12-03T11:35:47+01:00
New Revision: 1e14588d0f6845976e774c87a18a84a0f7b61015

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

LOG: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

http://lists.llvm.org/pipermail/cfe-dev/2020-November/067252.html

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

Added: 


Modified: 
clang/lib/Sema/SemaTemplate.cpp
clang/unittests/AST/ASTImporterTest.cpp

Removed: 




diff  --git a/clang/lib/Sema/SemaTemplate.cpp b/clang/lib/Sema/SemaTemplate.cpp
index 5b321bb74400..5710f9e3daad 100644
--- a/clang/lib/Sema/SemaTemplate.cpp
+++ b/clang/lib/Sema/SemaTemplate.cpp
@@ -2077,27 +2077,28 @@ class ExtractTypeForDeductionGuide
   QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) {
 ASTContext &Context = SemaRef.getASTContext();
 TypedefNameDecl *OrigDecl = TL.getTypedefNameDecl();
-TypeLocBuilder InnerTLB;
-QualType Transformed =
-TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
-TypeSourceInfo *TSI =
-TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));
-
-TypedefNameDecl *Decl = nullptr;
-
-if (isa(OrigDecl))
-  Decl = TypeAliasDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
-else {
-  assert(isa(OrigDecl) && "Not a Type alias or typedef");
-  Decl = TypedefDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+TypedefNameDecl *Decl = OrigDecl;
+// Transform the underlying type of the typedef and clone the Decl only if
+// the typedef has a dependent context.
+if (OrigDecl->getDeclContext()->isDependentContext()) {
+  TypeLocBuilder InnerTLB;
+  QualType Transformed =
+  TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
+  TypeSourceInfo *TSI =
+  TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));
+  if (isa(OrigDecl))
+Decl = TypeAliasDecl::Create(
+Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+  else {
+assert(isa(OrigDecl) && "Not a Type alias or typedef");
+Decl = TypedefDecl::Create(
+Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
+OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+  }
+  MaterializedTypedefs.push_back(Decl);
 }
 
-MaterializedTypedefs.push_back(Decl);
-
 QualType TDTy = Context.getTypedefType(Decl);
 TypedefTypeLoc TypedefTL = TLB.push(TDTy);
 TypedefTL.setNameLoc(TL.getNameLoc());

diff  --git a/clang/unittests/AST/ASTImporterTest.cpp 
b/clang/unittests/AST/ASTImporterTest.cpp
index 7e56b3ed501f..e4c73a832a14 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -5998,6 +5998,77 @@ TEST_P(ImportFunctions, CTADUserDefinedExplicit) {
   EXPECT_TRUE(ToD->isExplicit());
 }
 
+// FIXME Move these tests out of ASTImporterTest. For that we need to factor
+// out the ASTImporter specific pars from ASTImporterOptionSpecificTestBase
+// into a new test Fixture. Then we should lift up this Fixture to its own
+// implementation file and only then could we reuse the Fixture in other AST
+// unitttests.
+struct CTAD : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  // The type of the first param (which is a typedef) should match the typedef
+  // in the global scope.
+  EXPECT_EQ(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedefInParamPtr) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U*, T);
+  };
+  A a{(int*)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_EQ(Param->getType()
+->getAs()
+

[PATCH] D92101: [Clang][Sema] Attempt to fix CTAD faulty copy of non-local typedefs

2020-12-03 Thread Gabor Marton via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
martong marked an inline comment as done.
Closed by commit rG1e14588d0f68: [Clang][Sema] Attempt to fix CTAD faulty copy 
of non-local typedefs (authored by martong).

Changed prior to commit:
  https://reviews.llvm.org/D92101?vs=308922&id=309199#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92101

Files:
  clang/lib/Sema/SemaTemplate.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -5998,6 +5998,77 @@
   EXPECT_TRUE(ToD->isExplicit());
 }
 
+// FIXME Move these tests out of ASTImporterTest. For that we need to factor
+// out the ASTImporter specific pars from ASTImporterOptionSpecificTestBase
+// into a new test Fixture. Then we should lift up this Fixture to its own
+// implementation file and only then could we reuse the Fixture in other AST
+// unitttests.
+struct CTAD : ASTImporterOptionSpecificTestBase {};
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  // The type of the first param (which is a typedef) should match the typedef
+  // in the global scope.
+  EXPECT_EQ(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldReferToANonLocalTypedefInParamPtr) {
+  Decl *TU = getTuDecl(
+  R"(
+  typedef int U;
+  template  struct A {
+A(U*, T);
+  };
+  A a{(int*)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_EQ(Param->getType()
+->getAs()
+->getPointeeType()
+->getAs()
+->getDecl(),
+Typedef);
+}
+
+TEST_P(CTAD, DeductionGuideShouldCopyALocalTypedef) {
+  Decl *TU = getTuDecl(
+  R"(
+  template  struct A {
+typedef T U;
+A(U, T);
+  };
+  A a{(int)0, (int)0};
+  )",
+  Lang_CXX17, "input.cc");
+  auto *Guide = FirstDeclMatcher().match(
+  TU, cxxDeductionGuideDecl());
+  auto *Typedef = FirstDeclMatcher().match(
+  TU, typedefNameDecl(hasName("U")));
+  ParmVarDecl *Param = Guide->getParamDecl(0);
+  EXPECT_NE(Param->getType()->getAs()->getDecl(), Typedef);
+}
+
+INSTANTIATE_TEST_CASE_P(ParameterizedTests, CTAD,
+DefaultTestValuesForRunOptions, );
+
 INSTANTIATE_TEST_CASE_P(ParameterizedTests, ASTImporterLookupTableTest,
 DefaultTestValuesForRunOptions, );
 
Index: clang/lib/Sema/SemaTemplate.cpp
===
--- clang/lib/Sema/SemaTemplate.cpp
+++ clang/lib/Sema/SemaTemplate.cpp
@@ -2077,27 +2077,28 @@
   QualType TransformTypedefType(TypeLocBuilder &TLB, TypedefTypeLoc TL) {
 ASTContext &Context = SemaRef.getASTContext();
 TypedefNameDecl *OrigDecl = TL.getTypedefNameDecl();
-TypeLocBuilder InnerTLB;
-QualType Transformed =
-TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
-TypeSourceInfo *TSI =
-TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));
-
-TypedefNameDecl *Decl = nullptr;
-
-if (isa(OrigDecl))
-  Decl = TypeAliasDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
-else {
-  assert(isa(OrigDecl) && "Not a Type alias or typedef");
-  Decl = TypedefDecl::Create(
-  Context, Context.getTranslationUnitDecl(), OrigDecl->getBeginLoc(),
-  OrigDecl->getLocation(), OrigDecl->getIdentifier(), TSI);
+TypedefNameDecl *Decl = OrigDecl;
+// Transform the underlying type of the typedef and clone the Decl only if
+// the typedef has a dependent context.
+if (OrigDecl->getDeclContext()->isDependentContext()) {
+  TypeLocBuilder InnerTLB;
+  QualType Transformed =
+  TransformType(InnerTLB, OrigDecl->getTypeSourceInfo()->getTypeLoc());
+  TypeSourceInfo *TSI =
+  TransformType(InnerTLB.getTypeSourceInfo(Context, Transformed));
+  if (isa(OrigDecl))
+Decl = TypeAliasDecl::Create(
+Contex

[clang] 152df3a - arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame pointers

2020-12-03 Thread Tim Northover via cfe-commits

Author: Tim Northover
Date: 2020-12-03T11:09:44Z
New Revision: 152df3add156b68aca7bfb06b62ea85fa127f3b1

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

LOG: arm64: count Triple::aarch64_32 as an aarch64 target and enable leaf frame 
pointers

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/frame-pointer-elim.c
llvm/include/llvm/ADT/Triple.h
llvm/lib/BinaryFormat/MachO.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 0330afdcec48..85ab05cb7021 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -1075,9 +1075,9 @@ SanitizerMask ToolChain::getSupportedSanitizers() const {
   getTriple().isAArch64())
 Res |= SanitizerKind::CFIICall;
   if (getTriple().getArch() == llvm::Triple::x86_64 ||
-  getTriple().isAArch64() || getTriple().isRISCV())
+  getTriple().isAArch64(64) || getTriple().isRISCV())
 Res |= SanitizerKind::ShadowCallStack;
-  if (getTriple().isAArch64())
+  if (getTriple().isAArch64(64))
 Res |= SanitizerKind::MemTag;
   return Res;
 }

diff  --git a/clang/test/Driver/frame-pointer-elim.c 
b/clang/test/Driver/frame-pointer-elim.c
index fd74da7768eb..83dbf3816b68 100644
--- a/clang/test/Driver/frame-pointer-elim.c
+++ b/clang/test/Driver/frame-pointer-elim.c
@@ -97,6 +97,8 @@
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 // RUN: %clang -### -target x86_64-scei-ps4 -S -O2 %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
+// RUN: %clang -### -target aarch64-apple-darwin -arch arm64_32 -S %s 2>&1 | \
+// RUN:   FileCheck --check-prefix=KEEP-NON-LEAF %s
 
 // RUN: %clang -### -target powerpc64 -S %s 2>&1 | \
 // RUN:   FileCheck --check-prefix=KEEP-ALL %s

diff  --git a/llvm/include/llvm/ADT/Triple.h b/llvm/include/llvm/ADT/Triple.h
index 6bfdfe691c2e..4e1a9499bf81 100644
--- a/llvm/include/llvm/ADT/Triple.h
+++ b/llvm/include/llvm/ADT/Triple.h
@@ -714,7 +714,17 @@ class Triple {
 
   /// Tests whether the target is AArch64 (little and big endian).
   bool isAArch64() const {
-return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be;
+return getArch() == Triple::aarch64 || getArch() == Triple::aarch64_be ||
+   getArch() == Triple::aarch64_32;
+  }
+
+  /// Tests whether the target is AArch64 and pointers are the size specified 
by
+  /// \p PointerWidth.
+  bool isAArch64(int PointerWidth) const {
+assert(PointerWidth == 64 || PointerWidth == 32);
+if (!isAArch64())
+  return false;
+return isArch64Bit() ? PointerWidth == 64 : PointerWidth == 32;
   }
 
   /// Tests whether the target is MIPS 32-bit (little and big endian).

diff  --git a/llvm/lib/BinaryFormat/MachO.cpp b/llvm/lib/BinaryFormat/MachO.cpp
index 2b9eb8025521..0901022a6141 100644
--- a/llvm/lib/BinaryFormat/MachO.cpp
+++ b/llvm/lib/BinaryFormat/MachO.cpp
@@ -55,7 +55,7 @@ static MachO::CPUSubTypeARM getARMSubType(const Triple &T) {
 }
 
 static MachO::CPUSubTypeARM64 getARM64SubType(const Triple &T) {
-  assert(T.isAArch64() || T.getArch() == Triple::aarch64_32);
+  assert(T.isAArch64());
   if (T.isArch32Bit())
 return (MachO::CPUSubTypeARM64)MachO::CPU_SUBTYPE_ARM64_32_V8;
   if (T.getArchName() == "arm64e")
@@ -84,9 +84,7 @@ Expected MachO::getCPUType(const Triple &T) {
   if (T.isARM() || T.isThumb())
 return MachO::CPU_TYPE_ARM;
   if (T.isAArch64())
-return MachO::CPU_TYPE_ARM64;
-  if (T.getArch() == Triple::aarch64_32)
-return MachO::CPU_TYPE_ARM64_32;
+return T.isArch32Bit() ? MachO::CPU_TYPE_ARM64_32 : MachO::CPU_TYPE_ARM64;
   if (T.getArch() == Triple::ppc)
 return MachO::CPU_TYPE_POWERPC;
   if (T.getArch() == Triple::ppc64)



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


[PATCH] D91147: AArch64: classify Triple::aarch64_32 as AArch64

2020-12-03 Thread Tim Northover via Phabricator via cfe-commits
t.p.northover closed this revision.
t.p.northover added a comment.

Thanks Gerolf. Committed:

To github.com:llvm/llvm-project.git

  ae9d96a656a1..152df3add156  master -> master


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

https://reviews.llvm.org/D91147

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


[clang-tools-extra] a59e504 - [clangd] Fix a nullptr-access crash in canonicalRenameDecl.

2020-12-03 Thread Haojian Wu via cfe-commits

Author: Haojian Wu
Date: 2020-12-03T12:59:00+01:00
New Revision: a59e504a61a580e7b7d9af0b0380b573cee21a1c

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

LOG: [clangd] Fix a nullptr-access crash in canonicalRenameDecl.

Added: 


Modified: 
clang-tools-extra/clangd/refactor/Rename.cpp
clang-tools-extra/clangd/unittests/RenameTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/Rename.cpp 
b/clang-tools-extra/clangd/refactor/Rename.cpp
index 946daaf6d158..0af8a98427c7 100644
--- a/clang-tools-extra/clangd/refactor/Rename.cpp
+++ b/clang-tools-extra/clangd/refactor/Rename.cpp
@@ -129,7 +129,8 @@ const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
 // CXXMethodDecl::getInstantiatedFromMemberFunction for the field because
 // Clang AST does not store relevant information about the field that is
 // instantiated.
-const auto *FieldParent = dyn_cast(Field->getParent());
+const auto *FieldParent =
+dyn_cast_or_null(Field->getParent());
 if (!FieldParent)
   return Field->getCanonicalDecl();
 FieldParent = FieldParent->getTemplateInstantiationPattern();

diff  --git a/clang-tools-extra/clangd/unittests/RenameTests.cpp 
b/clang-tools-extra/clangd/unittests/RenameTests.cpp
index 2382dba19659..306909892509 100644
--- a/clang-tools-extra/clangd/unittests/RenameTests.cpp
+++ b/clang-tools-extra/clangd/unittests/RenameTests.cpp
@@ -816,6 +816,13 @@ TEST(RenameTest, WithinFileRename) {
   [[F^oo]] foo = static_cast<[[F^oo]]>(boo);
 }
   )cpp",
+
+  // ObjC, should not crash.
+  R"cpp(
+@interface ObjC {
+  char [[da^ta]];
+} @end
+  )cpp",
   };
   llvm::StringRef NewName = "NewName";
   for (llvm::StringRef T : Tests) {
@@ -823,6 +830,7 @@ TEST(RenameTest, WithinFileRename) {
 Annotations Code(T);
 auto TU = TestTU::withCode(Code.code());
 TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+TU.ExtraArgs.push_back("-xobjective-c++");
 auto AST = TU.build();
 for (const auto &RenamePos : Code.points()) {
   auto RenameResult =



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


[PATCH] D92484: [clangd] Relation slabs should not be accounted when computing backing storage size

2020-12-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall added a comment.

Can you give a little context? Why not?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92484

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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-12-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added a comment.

It would be maybe possible to:

- address @klimek 's comment and do any other necessary cleanup
- create a bug ticket for what @JohelEGP found with ctors
- mark clang-format's support of concept as experimental?

This patch is getting big IMO and I really think that something is better than 
nothing in this case.
And at least we could parallelise the efforts on the remaining (edge) cases 
when this gets landed.
WDYT?


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

https://reviews.llvm.org/D79773

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


[PATCH] D92484: [clangd] Relation slabs should not be accounted when computing backing storage size

2020-12-03 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

In D92484#2430851 , @sammccall wrote:

> Can you give a little context? Why not?

It seems `Relations` should be not taken into account because they don't 
reference a backing storage.
Only `SymStorage` and `RefsStorage` are passed to the respective index in the 
`Payload` argument.

  cpp
  return std::make_unique(
  llvm::make_pointee_range(AllSymbols), std::move(AllRefs),
  std::move(AllRelations),
  std::make_tuple(std::move(SymbolSlabs), std::move(RefSlabs),
  std::move(RefsStorage), std::move(SymsStorage)),
  StorageSize);

Also, there is a comment regarding `Rels` slab in `Dex.cpp`:

  cpp
  std::unique_ptr Dex::build(SymbolSlab Symbols, RefSlab Refs, 
RelationSlab Rels) {
auto Size = Symbols.bytes() + Refs.bytes();
// There is no need to include "Rels" in Data because the relations are 
self-  <
// contained, without references into a backing store.  
   <
auto Data = std::make_pair(std::move(Symbols), std::move(Refs));
return std::make_unique(Data.first, Data.second, Rels, std::move(Data),
  Size);
  }

MemIndex also uses only `Symbols` and `Refs` slabs to compute backing storage 
size.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92484

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


[PATCH] D92570: [clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in _mm_free

2020-12-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo created this revision.
mstorsjo added reviewers: amccarth, rnk, chapuni.
Herald added a project: clang.
mstorsjo requested review of this revision.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92570

Files:
  clang/lib/Headers/mm_malloc.h


Index: clang/lib/Headers/mm_malloc.h
===
--- clang/lib/Headers/mm_malloc.h
+++ clang/lib/Headers/mm_malloc.h
@@ -54,7 +54,13 @@
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
 _mm_free(void *__p)
 {
+#if defined(__MINGW32__)
+  __mingw_aligned_free(__p);
+#elif defined(_WIN32)
+  _aligned_free(__p);
+#else
   free(__p);
+#endif
 }
 #endif
 


Index: clang/lib/Headers/mm_malloc.h
===
--- clang/lib/Headers/mm_malloc.h
+++ clang/lib/Headers/mm_malloc.h
@@ -54,7 +54,13 @@
 static __inline__ void __attribute__((__always_inline__, __nodebug__))
 _mm_free(void *__p)
 {
+#if defined(__MINGW32__)
+  __mingw_aligned_free(__p);
+#elif defined(_WIN32)
+  _aligned_free(__p);
+#else
   free(__p);
+#endif
 }
 #endif
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92573: [clang] Add a C++17 deduction guide testcase.

2020-12-03 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: adamcz.
Herald added a project: clang.
hokein requested review of this revision.

>From https://bugs.llvm.org/show_bug.cgi?id=47219.

It was crashing before the commit 1e14588d0f68 
.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92573

Files:
  clang/test/PCH/cxx17-deduction-guide-decl.cpp


Index: clang/test/PCH/cxx17-deduction-guide-decl.cpp
===
--- /dev/null
+++ clang/test/PCH/cxx17-deduction-guide-decl.cpp
@@ -0,0 +1,28 @@
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -std=c++17  -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -std=c++17 -o - %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace RP47219 {
+typedef int MyInt;
+template 
+class Some {
+ public:
+  explicit Some(T, MyInt) {}
+};
+
+// Class template argument deduction
+template 
+Some(T) -> Some;
+
+struct Foo {};
+void ParseNatural() {
+  Some(Foo(), 1);
+}
+}
+
+#else
+
+#endif


Index: clang/test/PCH/cxx17-deduction-guide-decl.cpp
===
--- /dev/null
+++ clang/test/PCH/cxx17-deduction-guide-decl.cpp
@@ -0,0 +1,28 @@
+// Test with pch.
+// RUN: %clang_cc1 -emit-pch -std=c++17  -o %t %s
+// RUN: %clang_cc1 -include-pch %t -emit-llvm -std=c++17 -o - %s
+
+#ifndef HEADER
+#define HEADER
+
+namespace RP47219 {
+typedef int MyInt;
+template 
+class Some {
+ public:
+  explicit Some(T, MyInt) {}
+};
+
+// Class template argument deduction
+template 
+Some(T) -> Some;
+
+struct Foo {};
+void ParseNatural() {
+  Some(Foo(), 1);
+}
+}
+
+#else
+
+#endif
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92386: [VE] Add standard include path and library path for C++

2020-12-03 Thread Kazushi Marukawa via Phabricator via cfe-commits
kaz7 updated this revision to Diff 309231.
kaz7 added a comment.

Add environment variable test as suggested.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92386

Files:
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- /dev/null
+++ clang/test/Driver/ve-toolchain.cpp
@@ -0,0 +1,132 @@
+/// Check the behavior of toolchain for NEC Aurora VE
+/// REQUIRES: ve-registered-target
+
+///-
+/// Checking dwarf-version
+
+// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// DWARF_VER: "-dwarf-version=4"
+
+///-
+/// Checking dynamic-linker
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DYNLINKER %s
+// DYNLINKER: nld{{.*}} "-dynamic-linker" "/opt/nec/ve/lib/ld-linux-ve.so.1"
+
+///-
+/// Checking VE specific option
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=VENLDOPT %s
+// VENLDOPT: nld{{.*}} "-z" "max-page-size=0x400"
+
+///-
+/// Checking include-path
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINC %s
+// DEFINC: clang{{.*}} "-cc1"
+// DEFINC: "-nostdsysteminc"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdlibinc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDLIBINC %s
+// NOSTDLIBINC: clang{{.*}} "-cc1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDLIBINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDLIBINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nobuiltininc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOBUILTININC %s
+// NOBUILTININC: clang{{.*}} "-cc1"
+// NOBUILTININC: "-nobuiltininc"
+// NOBUILTININC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOBUILTININC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOBUILTININC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDINC %s
+// NOSTDINC: clang{{.*}} "-cc1"
+// NOSTDINC: "-nobuiltininc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc++ 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDINCXX %s
+// NOSTDINCXX: clang{{.*}} "-cc1"
+// NOSTDINCXX: "-nostdinc++"
+// NOSTDINCXX-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINCXX: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINCXX: "-internal-isystem" "/opt/nec/ve/include"
+
+///-
+/// Checking environment variable NCC_CPLUS_INCLUDE_PATH
+
+// RUN: env NCC_CPLUS_INCLUDE_PATH=/test/test %clangxx -### -target ve %s \
+// RUN:2>&1 | FileCheck -check-prefix=DEFINCENV %s
+
+// DEFINCENV: clang{{.*}} "-cc1"
+// DEFINCENV: "-nostdsysteminc"
+// DEFINCENV: "-internal-isystem" "/test/test"
+// DEFINCENV: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINCENV: "-internal-isystem" "/opt/nec/ve/include"
+
+///-
+/// Checking -fuse-init-array
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINITARRAY %s
+// DEFINITARRAY: clang{{.*}} "-cc1"
+// DEFINITARRAY-NOT: "-fuse-init-array"
+
+// RUN: %clangxx -### -target ve %s -fno-use-init-array 2>&1 | \
+// RUN: FileCheck -check-prefix=NOTINITARRAY %s
+// NOTINITARRAY: clang{{.*}} "-cc1"
+// NOTINITARRAY: "-fno-use-init-array"
+
+///-
+/// Checking -faddrsig
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFADDESIG %s
+// DEFADDESIG: clang{{.*}} "-cc1"
+// DEFADDESIG-NOT: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -faddrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=ADDRSIG %s
+// ADDRSIG: clang{{.*}} "-cc1"
+// ADDRSIG: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -fno-addrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=NOADDRSIG %s
+// NOADDRSIG: clang{{.*}} "-cc1"
+// NOADDRSIG-NOT: "-faddrsig"
+
+

[PATCH] D92386: [VE] Add standard include path and library path for C++

2020-12-03 Thread Simon Moll via Phabricator via cfe-commits
simoll accepted this revision.
simoll added a comment.
This revision is now accepted and ready to land.

Thx!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92386

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


[PATCH] D71726: Let clang atomic builtins fetch add/sub support floating point types

2020-12-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

ping


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

https://reviews.llvm.org/D71726

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


[PATCH] D92484: [clangd] Relation slabs should not be accounted when computing backing storage size

2020-12-03 Thread Sam McCall via Phabricator via cfe-commits
sammccall accepted this revision.
sammccall added a comment.
This revision is now accepted and ready to land.

Thanks, you're right. There's no "payload" memory here, and 
MemIndex::estimateMemoryUsage should already be accounting for all the memory 
used.

(Sorry, it's been a while since I looked at this code)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92484

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


[clang] 7d30df7 - [VE] Add standard include path and library path for C++

2020-12-03 Thread Kazushi Marukawa via cfe-commits

Author: Kazushi (Jam) Marukawa
Date: 2020-12-03T22:22:56+09:00
New Revision: 7d30df7b59973a42a93c86cb501bd3d0fbb07404

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

LOG: [VE] Add standard include path and library path for C++

We have a plan to add libcxx and libcxxabi for VE.  In order to do so,
we need to compile cxx source code with bootstarapped header files.
This patch adds such expected path to make clang++ work, at least
not crash at the startup.  Add regression test for that, also.

Reviewed By: simoll

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

Added: 
clang/test/Driver/ve-toolchain.cpp

Modified: 
clang/lib/Driver/ToolChains/VEToolchain.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/VEToolchain.cpp 
b/clang/lib/Driver/ToolChains/VEToolchain.cpp
index 6ea405c0269c..e28f340f9aad 100644
--- a/clang/lib/Driver/ToolChains/VEToolchain.cpp
+++ b/clang/lib/Driver/ToolChains/VEToolchain.cpp
@@ -102,14 +102,37 @@ void VEToolChain::addClangTargetOptions(const ArgList 
&DriverArgs,
 
 void VEToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
ArgStringList &CC1Args) const {
-  // TODO upstream VE libc++ patches
-  llvm_unreachable("The VE target has no C++ stdlib for Clang yet");
+  if (DriverArgs.hasArg(clang::driver::options::OPT_nostdinc) ||
+  DriverArgs.hasArg(options::OPT_nostdlibinc) ||
+  DriverArgs.hasArg(options::OPT_nostdincxx))
+return;
+  if (const char *cl_include_dir = getenv("NCC_CPLUS_INCLUDE_PATH")) {
+SmallVector Dirs;
+const char EnvPathSeparatorStr[] = {llvm::sys::EnvPathSeparator, '\0'};
+StringRef(cl_include_dir).split(Dirs, StringRef(EnvPathSeparatorStr));
+ArrayRef DirVec(Dirs);
+addSystemIncludes(DriverArgs, CC1Args, DirVec);
+  } else {
+SmallString<128> P(getDriver().ResourceDir);
+llvm::sys::path::append(P, "include/c++/v1");
+addSystemInclude(DriverArgs, CC1Args, P);
+  }
 }
 
 void VEToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
   ArgStringList &CmdArgs) const {
-  // TODO upstream VE libc++ patches
-  llvm_unreachable("The VE target has no C++ stdlib for Clang yet");
+  assert((GetCXXStdlibType(Args) == ToolChain::CST_Libcxx) &&
+ "Only -lc++ (aka libxx) is supported in this toolchain.");
+
+  tools::addArchSpecificRPath(*this, Args, CmdArgs);
+
+  CmdArgs.push_back("-lc++");
+  CmdArgs.push_back("-lc++abi");
+  CmdArgs.push_back("-lunwind");
+  // libc++ requires -lpthread under glibc environment
+  CmdArgs.push_back("-lpthread");
+  // libunwind requires -ldl under glibc environment
+  CmdArgs.push_back("-ldl");
 }
 
 llvm::ExceptionHandling

diff  --git a/clang/test/Driver/ve-toolchain.cpp 
b/clang/test/Driver/ve-toolchain.cpp
new file mode 100644
index ..e056c04456ae
--- /dev/null
+++ b/clang/test/Driver/ve-toolchain.cpp
@@ -0,0 +1,132 @@
+/// Check the behavior of toolchain for NEC Aurora VE
+/// REQUIRES: ve-registered-target
+
+///-
+/// Checking dwarf-version
+
+// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck 
-check-prefix=DWARF_VER %s
+// DWARF_VER: "-dwarf-version=4"
+
+///-
+/// Checking dynamic-linker
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DYNLINKER %s
+// DYNLINKER: nld{{.*}} "-dynamic-linker" "/opt/nec/ve/lib/ld-linux-ve.so.1"
+
+///-
+/// Checking VE specific option
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=VENLDOPT %s
+// VENLDOPT: nld{{.*}} "-z" "max-page-size=0x400"
+
+///-
+/// Checking include-path
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINC %s
+// DEFINC: clang{{.*}} "-cc1"
+// DEFINC: "-nostdsysteminc"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdlibinc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDLIBINC %s
+// NOSTDLIBINC: clang{{.*}} "-cc1"
+// NOSTDLIBINC-NOT: "-internal-isystem" 
"{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDLIBINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDLIBINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nobuiltininc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOBUILTININC %s
+// NOBUILTININC: clang{{.*}} "-cc1"
+// NOBUILTI

[PATCH] D92386: [VE] Add standard include path and library path for C++

2020-12-03 Thread Kazushi Marukawa 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 rG7d30df7b5997: [VE] Add standard include path and library 
path for C++ (authored by kaz7).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92386

Files:
  clang/lib/Driver/ToolChains/VEToolchain.cpp
  clang/test/Driver/ve-toolchain.cpp

Index: clang/test/Driver/ve-toolchain.cpp
===
--- /dev/null
+++ clang/test/Driver/ve-toolchain.cpp
@@ -0,0 +1,132 @@
+/// Check the behavior of toolchain for NEC Aurora VE
+/// REQUIRES: ve-registered-target
+
+///-
+/// Checking dwarf-version
+
+// RUN: %clangxx -### -g -target ve %s 2>&1 | FileCheck -check-prefix=DWARF_VER %s
+// DWARF_VER: "-dwarf-version=4"
+
+///-
+/// Checking dynamic-linker
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DYNLINKER %s
+// DYNLINKER: nld{{.*}} "-dynamic-linker" "/opt/nec/ve/lib/ld-linux-ve.so.1"
+
+///-
+/// Checking VE specific option
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=VENLDOPT %s
+// VENLDOPT: nld{{.*}} "-z" "max-page-size=0x400"
+
+///-
+/// Checking include-path
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINC %s
+// DEFINC: clang{{.*}} "-cc1"
+// DEFINC: "-nostdsysteminc"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// DEFINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdlibinc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDLIBINC %s
+// NOSTDLIBINC: clang{{.*}} "-cc1"
+// NOSTDLIBINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDLIBINC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDLIBINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nobuiltininc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOBUILTININC %s
+// NOBUILTININC: clang{{.*}} "-cc1"
+// NOBUILTININC: "-nobuiltininc"
+// NOBUILTININC: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOBUILTININC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOBUILTININC: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDINC %s
+// NOSTDINC: clang{{.*}} "-cc1"
+// NOSTDINC: "-nobuiltininc"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINC-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINC-NOT: "-internal-isystem" "/opt/nec/ve/include"
+
+// RUN: %clangxx -### -target ve %s -nostdinc++ 2>&1 | \
+// RUN:FileCheck -check-prefix=NOSTDINCXX %s
+// NOSTDINCXX: clang{{.*}} "-cc1"
+// NOSTDINCXX: "-nostdinc++"
+// NOSTDINCXX-NOT: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include/c++/v1"
+// NOSTDINCXX: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// NOSTDINCXX: "-internal-isystem" "/opt/nec/ve/include"
+
+///-
+/// Checking environment variable NCC_CPLUS_INCLUDE_PATH
+
+// RUN: env NCC_CPLUS_INCLUDE_PATH=/test/test %clangxx -### -target ve %s \
+// RUN:2>&1 | FileCheck -check-prefix=DEFINCENV %s
+
+// DEFINCENV: clang{{.*}} "-cc1"
+// DEFINCENV: "-nostdsysteminc"
+// DEFINCENV: "-internal-isystem" "/test/test"
+// DEFINCENV: "-internal-isystem" "{{.*}}/lib/clang/{{[0-9.]*}}/include"
+// DEFINCENV: "-internal-isystem" "/opt/nec/ve/include"
+
+///-
+/// Checking -fuse-init-array
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFINITARRAY %s
+// DEFINITARRAY: clang{{.*}} "-cc1"
+// DEFINITARRAY-NOT: "-fuse-init-array"
+
+// RUN: %clangxx -### -target ve %s -fno-use-init-array 2>&1 | \
+// RUN: FileCheck -check-prefix=NOTINITARRAY %s
+// NOTINITARRAY: clang{{.*}} "-cc1"
+// NOTINITARRAY: "-fno-use-init-array"
+
+///-
+/// Checking -faddrsig
+
+// RUN: %clangxx -### -target ve %s 2>&1 | FileCheck -check-prefix=DEFADDESIG %s
+// DEFADDESIG: clang{{.*}} "-cc1"
+// DEFADDESIG-NOT: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -faddrsig 2>&1 | \
+// RUN: FileCheck -check-prefix=ADDRSIG %s
+// ADDRSIG: clang{{.*}} "-cc1"
+// ADDRSIG: "-faddrsig"
+
+// RUN: %clangxx -### -target ve %s -fno-addrsi

[PATCH] D92484: [clangd] Relation slabs should not be accounted when computing backing storage size

2020-12-03 Thread Ilya Golovenko via Phabricator via cfe-commits
ilya-golovenko added a comment.

In D92484#2430985 , @sammccall wrote:

> Thanks, you're right. There's no "payload" memory here, and 
> MemIndex::estimateMemoryUsage should already be accounting for all the memory 
> used.
>
> (Sorry, it's been a while since I looked at this code)

Thank you for review!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92484

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


[clang-tools-extra] 2d539d7 - [clangd] Relation slabs should not be accounted when computing backing storage size

2020-12-03 Thread Ilya Golovenko via cfe-commits

Author: Ilya Golovenko
Date: 2020-12-03T16:56:53+03:00
New Revision: 2d539d78549fbe26144d5ff491de338413bd99d3

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

LOG: [clangd] Relation slabs should not be accounted when computing backing 
storage size

Reviewed By: sammccall

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

Added: 


Modified: 
clang-tools-extra/clangd/index/FileIndex.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/index/FileIndex.cpp 
b/clang-tools-extra/clangd/index/FileIndex.cpp
index 9a376df8dfec..1ccfb4485638 100644
--- a/clang-tools-extra/clangd/index/FileIndex.cpp
+++ b/clang-tools-extra/clangd/index/FileIndex.cpp
@@ -366,8 +366,6 @@ FileSymbols::buildIndex(IndexType Type, DuplicateHandling 
DuplicateHandle,
 StorageSize += Slab->bytes();
   for (const auto &RefSlab : RefSlabs)
 StorageSize += RefSlab->bytes();
-  for (const auto &RelationSlab : RelationSlabs)
-StorageSize += RelationSlab->bytes();
 
   // Index must keep the slabs and contiguous ranges alive.
   switch (Type) {



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


[PATCH] D92484: [clangd] Relation slabs should not be accounted when computing backing storage size

2020-12-03 Thread walrus via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG2d539d78549f: [clangd] Relation slabs should not be 
accounted when computing backing storage… (authored by walrus).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92484

Files:
  clang-tools-extra/clangd/index/FileIndex.cpp


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -366,8 +366,6 @@
 StorageSize += Slab->bytes();
   for (const auto &RefSlab : RefSlabs)
 StorageSize += RefSlab->bytes();
-  for (const auto &RelationSlab : RelationSlabs)
-StorageSize += RelationSlab->bytes();
 
   // Index must keep the slabs and contiguous ranges alive.
   switch (Type) {


Index: clang-tools-extra/clangd/index/FileIndex.cpp
===
--- clang-tools-extra/clangd/index/FileIndex.cpp
+++ clang-tools-extra/clangd/index/FileIndex.cpp
@@ -366,8 +366,6 @@
 StorageSize += Slab->bytes();
   for (const auto &RefSlab : RefSlabs)
 StorageSize += RefSlab->bytes();
-  for (const auto &RelationSlab : RelationSlabs)
-StorageSize += RelationSlab->bytes();
 
   // Index must keep the slabs and contiguous ranges alive.
   switch (Type) {
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] 68f2ff5 - clang/darwin: Don't use response files with ld64

2020-12-03 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-12-03T09:00:10-05:00
New Revision: 68f2ff59d114a5511e197472d2d4f23fea7ff0f5

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

LOG: clang/darwin: Don't use response files with ld64

This morally reverts D82777 -- turns out that ld64 crashes with many
response files, so we must stop passing them to it until the crash is
fixed.

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

Added: 


Modified: 
clang/lib/Driver/ToolChains/Darwin.cpp

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index f1846a573914..9f8560356405 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -698,7 +698,10 @@ void darwin::Linker::ConstructJob(Compilation &C, const 
JobAction &JA,
   }
 
   ResponseFileSupport ResponseSupport;
-  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+  if (LinkerIsLLDDarwinNew) {
+// Xcode12's ld64 added support for @response files, but it's crashy:
+// https://openradar.appspot.com/radar?id=4933317065441280
+// FIXME: Pass this for ld64 once it no longer crashes.
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method 
instead.



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


[PATCH] D92357: clang/darwin: Don't use response files with ld64

2020-12-03 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG68f2ff59d114: clang/darwin: Don't use response files 
with ld64 (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92357

Files:
  clang/lib/Driver/ToolChains/Darwin.cpp


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -698,7 +698,10 @@
   }
 
   ResponseFileSupport ResponseSupport;
-  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+  if (LinkerIsLLDDarwinNew) {
+// Xcode12's ld64 added support for @response files, but it's crashy:
+// https://openradar.appspot.com/radar?id=4933317065441280
+// FIXME: Pass this for ld64 once it no longer crashes.
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method 
instead.


Index: clang/lib/Driver/ToolChains/Darwin.cpp
===
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -698,7 +698,10 @@
   }
 
   ResponseFileSupport ResponseSupport;
-  if (Version[0] >= 607 || LinkerIsLLDDarwinNew) {
+  if (LinkerIsLLDDarwinNew) {
+// Xcode12's ld64 added support for @response files, but it's crashy:
+// https://openradar.appspot.com/radar?id=4933317065441280
+// FIXME: Pass this for ld64 once it no longer crashes.
 ResponseSupport = ResponseFileSupport::AtFileUTF8();
   } else {
 // For older versions of the linker, use the legacy filelist method instead.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91904: [mac/arm] Fix rtti codegen tests when running on an arm mac

2020-12-03 Thread Hans Wennborg via Phabricator via cfe-commits
hans accepted this revision.
hans added a comment.
This revision is now accepted and ready to land.

lgtm


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

https://reviews.llvm.org/D91904

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


[PATCH] D91904: [mac/arm] Fix rtti codegen tests when running on an arm mac

2020-12-03 Thread Nico Weber via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0cbf61be8be5: [mac/arm] Fix rtti codegen tests when running 
on an arm mac (authored by thakis).
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91904

Files:
  clang/include/clang/Basic/TargetCXXABI.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
  clang/test/SemaCXX/typeid-ref.cpp

Index: clang/test/SemaCXX/typeid-ref.cpp
===
--- clang/test/SemaCXX/typeid-ref.cpp
+++ clang/test/SemaCXX/typeid-ref.cpp
@@ -6,7 +6,7 @@
 struct X { };
 
 void f() {
-  // CHECK: @_ZTS1X = linkonce_odr {{(dso_local )?}}constant
-  // CHECK: @_ZTI1X = linkonce_odr {{(dso_local )?}}constant 
+  // CHECK: @_ZTS1X = linkonce_odr {{(dso_local|hidden )?}}constant
+  // CHECK: @_ZTI1X = linkonce_odr {{(dso_local|hidden )?}}constant
   (void)typeid(X&);
 }
Index: clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
===
--- clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
+++ clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
@@ -31,17 +31,17 @@
 void V1::foo() { }
 void V2::foo() { }
 
-// CHECK: @_ZTS1A = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTI1A = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTS1B = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTI1B = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTS1C = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTS2T1 = linkonce_odr {{(dso_local )?}}constant
-// CHECK: @_ZTI2T1 = linkonce_odr {{(dso_local )?}}constant
-// CHECK: @_ZTS1T = linkonce_odr {{(dso_local )?}}constant
-// CHECK: @_ZTI1T = linkonce_odr {{(dso_local )?}}constant
-// CHECK: @_ZTI1C = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTS2V1 = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTI2V1 = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTS2V2 = weak_odr {{(dso_local )?}}constant
-// CHECK: @_ZTI2V2 = weak_odr {{(dso_local )?}}constant
+// CHECK: @_ZTS1A = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTI1A = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTS1B = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTI1B = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTS1C = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTS2T1 = linkonce_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTI2T1 = linkonce_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTS1T = linkonce_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTI1T = linkonce_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTI1C = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTS2V1 = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTI2V1 = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTS2V2 = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTI2V2 = weak_odr {{(dso_local|hidden )?}}constant
Index: clang/lib/CodeGen/ItaniumCXXABI.cpp
===
--- clang/lib/CodeGen/ItaniumCXXABI.cpp
+++ clang/lib/CodeGen/ItaniumCXXABI.cpp
@@ -486,9 +486,9 @@
CharUnits cookieSize) override;
 };
 
-class iOS64CXXABI : public ARMCXXABI {
+class AppleARM64CXXABI : public ARMCXXABI {
 public:
-  iOS64CXXABI(CodeGen::CodeGenModule &CGM) : ARMCXXABI(CGM) {
+  AppleARM64CXXABI(CodeGen::CodeGenModule &CGM) : ARMCXXABI(CGM) {
 Use32BitVTableOffsetABI = true;
   }
 
@@ -551,8 +551,8 @@
   case TargetCXXABI::WatchOS:
 return new ARMCXXABI(CGM);
 
-  case TargetCXXABI::iOS64:
-return new iOS64CXXABI(CGM);
+  case TargetCXXABI::AppleARM64:
+return new AppleARM64CXXABI(CGM);
 
   case TargetCXXABI::Fuchsia:
 return new FuchsiaCXXABI(CGM);
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -76,11 +76,11 @@
 
 static CGCXXABI *createCXXABI(CodeGenModule &CGM) {
   switch (CGM.getTarget().getCXXABI().getKind()) {
+  case TargetCXXABI::AppleARM64:
   case TargetCXXABI::Fuchsia:
   case TargetCXXABI::GenericAArch64:
   case TargetCXXABI::GenericARM:
   case TargetCXXABI::iOS:
-  case TargetCXXABI::iOS64:
   case TargetCXXABI::WatchOS:
   case TargetCXXABI::GenericMIPS:
   case TargetCXXABI::GenericItanium:
Index: clang/lib/Basic/Targets/AArch64.cpp
===
--- clang/lib/Basic/Targets/AArch64.cpp
+++ clang/lib/Basic/Targets/AArch64.cpp
@@ -857,7 +857,7 @@
 UseZeroLengthBitfieldAlignment = true;
 TheCXXABI.set(TargetCXXABI::WatchOS);
   } else
-TheCXXABI.set(TargetCXXABI::iOS64);
+TheCXXABI.set(TargetCXXABI::Appl

[clang] 0cbf61b - [mac/arm] Fix rtti codegen tests when running on an arm mac

2020-12-03 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-12-03T09:11:03-05:00
New Revision: 0cbf61be8be546257854d1a2e5d6c675f5838a63

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

LOG: [mac/arm] Fix rtti codegen tests when running on an arm mac

shouldRTTIBeUnique() returns false for iOS64CXXABI, which causes
RTTI objects to be emitted hidden. Update two tests that didn't
expect this to happen for the default triple.

Also rename iOS64CXXABI to AppleARM64CXXABI, since it's used for
arm64-apple-macos triples too.

Part of PR46644.

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

Added: 


Modified: 
clang/include/clang/Basic/TargetCXXABI.h
clang/lib/AST/ASTContext.cpp
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/CodeGen/CodeGenModule.cpp
clang/lib/CodeGen/ItaniumCXXABI.cpp
clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
clang/test/SemaCXX/typeid-ref.cpp

Removed: 




diff  --git a/clang/include/clang/Basic/TargetCXXABI.h 
b/clang/include/clang/Basic/TargetCXXABI.h
index 30145ac69138..2d267f43f92b 100644
--- a/clang/include/clang/Basic/TargetCXXABI.h
+++ b/clang/include/clang/Basic/TargetCXXABI.h
@@ -62,17 +62,17 @@ class TargetCXXABI {
 ///   - constructor/destructor signatures.
 iOS,
 
-/// The iOS 64-bit ABI is follows ARM's published 64-bit ABI more
-/// closely, but we don't guarantee to follow it perfectly.
+/// The iOS 64-bit and macOS 64-bit ARM ABI follows ARM's published 64-bit
+/// ABI more closely, but we don't guarantee to follow it perfectly.
 ///
 /// It is documented here:
 ///http://infocenter.arm.com
 ///  /help/topic/com.arm.doc.ihi0059a/IHI0059A_cppabi64.pdf
-iOS64,
+AppleARM64,
 
 /// WatchOS is a modernisation of the iOS ABI, which roughly means it's
-/// the iOS64 ABI ported to 32-bits. The primary 
diff erence from iOS64 is
-/// that RTTI objects must still be unique at the moment.
+/// the AppleARM64 ABI ported to 32-bits. The primary 
diff erence from
+/// AppleARM64 is that RTTI objects must still be unique at the moment.
 WatchOS,
 
 /// The generic AArch64 ABI is also a modified version of the Itanium ABI,
@@ -98,7 +98,7 @@ class TargetCXXABI {
 ///   - guard variables are 32-bit on wasm32, as in ARM;
 ///   - unused bits of guard variables are reserved, as in ARM;
 ///   - inline functions are never key functions, as in ARM;
-///   - C++11 POD rules are used for tail padding, as in iOS64.
+///   - C++11 POD rules are used for tail padding, as in AppleARM64.
 ///
 /// TODO: At present the WebAssembly ABI is not considered stable, so none
 /// of these details is necessarily final yet.
@@ -147,12 +147,12 @@ class TargetCXXABI {
   /// Does this ABI generally fall into the Itanium family of ABIs?
   bool isItaniumFamily() const {
 switch (getKind()) {
+case AppleARM64:
 case Fuchsia:
 case GenericAArch64:
 case GenericItanium:
 case GenericARM:
 case iOS:
-case iOS64:
 case WatchOS:
 case GenericMIPS:
 case WebAssembly:
@@ -168,12 +168,12 @@ class TargetCXXABI {
   /// Is this ABI an MSVC-compatible ABI?
   bool isMicrosoft() const {
 switch (getKind()) {
+case AppleARM64:
 case Fuchsia:
 case GenericAArch64:
 case GenericItanium:
 case GenericARM:
 case iOS:
-case iOS64:
 case WatchOS:
 case GenericMIPS:
 case WebAssembly:
@@ -200,6 +200,7 @@ class TargetCXXABI {
 case WebAssembly:
   // WebAssembly doesn't require any special alignment for member 
functions.
   return false;
+case AppleARM64:
 case Fuchsia:
 case GenericARM:
 case GenericAArch64:
@@ -209,7 +210,6 @@ class TargetCXXABI {
   //   special alignment and could therefore also return false.
 case GenericItanium:
 case iOS:
-case iOS64:
 case WatchOS:
 case Microsoft:
 case XL:
@@ -277,9 +277,9 @@ class TargetCXXABI {
   /// done on a generic Itanium platform.
   bool canKeyFunctionBeInline() const {
 switch (getKind()) {
+case AppleARM64:
 case Fuchsia:
 case GenericARM:
-case iOS64:
 case WebAssembly:
 case WatchOS:
   return false;
@@ -330,10 +330,10 @@ class TargetCXXABI {
 case XL:
   return UseTailPaddingUnlessPOD03;
 
-// iOS on ARM64 and WebAssembly use the C++11 POD rules.  They do not honor
+// AppleARM64 and WebAssembly use the C++11 POD rules.  They do not honor
 // the Itanium exception about classes with over-large bitfields.
+case AppleARM64:
 case Fuchsia:
-case iOS64:
 case WebAssembly:
 case WatchOS:
   return UseTailPaddingUnlessPOD11;

diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 67ee

[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-03 Thread Jamie Schmeiser via Phabricator via cfe-commits
jamieschmeiser accepted this revision.
jamieschmeiser added a comment.
This revision is now accepted and ready to land.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87216

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


[PATCH] D92269: [TableGen] Eliminate the 'code' type

2020-12-03 Thread Paul C. Anagnostopoulos via Phabricator via cfe-commits
Paul-C-Anagnostopoulos added a comment.

I'm about to push this revision. I will be surprised if it does not break the 
build.


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

https://reviews.llvm.org/D92269

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


[clang] 415fab6 - [TableGen] Eliminate the 'code' type

2020-12-03 Thread Paul C. Anagnostopoulos via cfe-commits

Author: Paul C. Anagnostopoulos
Date: 2020-12-03T10:19:11-05:00
New Revision: 415fab6f67b4db59abe533130272d55b4efbf0cb

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

LOG: [TableGen] Eliminate the 'code' type

Update the documentation.

Rework various backends that relied on the code type.

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

Added: 


Modified: 
clang/utils/TableGen/ClangOptionDocEmitter.cpp
llvm/docs/TableGen/BackEnds.rst
llvm/docs/TableGen/BackGuide.rst
llvm/docs/TableGen/ProgRef.rst
llvm/include/llvm/TableGen/Error.h
llvm/include/llvm/TableGen/Record.h
llvm/include/llvm/TableGen/SearchableTable.td
llvm/lib/TableGen/Error.cpp
llvm/lib/TableGen/JSONBackend.cpp
llvm/lib/TableGen/Record.cpp
llvm/lib/TableGen/TGLexer.cpp
llvm/lib/TableGen/TGLexer.h
llvm/lib/TableGen/TGParser.cpp
llvm/lib/Target/AMDGPU/MIMGInstructions.td
llvm/test/TableGen/code.td
llvm/test/TableGen/generic-tables.td
llvm/test/TableGen/interleave.td
llvm/test/TableGen/unterminated-code-block.td
llvm/utils/TableGen/AsmWriterEmitter.cpp
llvm/utils/TableGen/DFAEmitter.cpp
llvm/utils/TableGen/GICombinerEmitter.cpp
llvm/utils/TableGen/RISCVCompressInstEmitter.cpp
llvm/utils/TableGen/SearchableTableEmitter.cpp
mlir/include/mlir/TableGen/Operator.h
mlir/lib/TableGen/Attribute.cpp
mlir/lib/TableGen/Dialect.cpp
mlir/lib/TableGen/Operator.cpp
mlir/lib/TableGen/Pattern.cpp
mlir/lib/TableGen/Type.cpp
mlir/lib/TableGen/TypeDef.cpp
mlir/tools/mlir-tblgen/OpDefinitionsGen.cpp

Removed: 




diff  --git a/clang/utils/TableGen/ClangOptionDocEmitter.cpp 
b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
index 23aa31cc732f..0e079b6b505a 100644
--- a/clang/utils/TableGen/ClangOptionDocEmitter.cpp
+++ b/clang/utils/TableGen/ClangOptionDocEmitter.cpp
@@ -217,8 +217,6 @@ std::string getRSTStringWithTextFallback(const Record *R, 
StringRef Primary,
   StringRef Value;
   if (auto *SV = dyn_cast_or_null(V->getValue()))
 Value = SV->getValue();
-  else if (auto *CV = dyn_cast_or_null(V->getValue()))
-Value = CV->getValue();
   if (!Value.empty())
 return Field == Primary ? Value.str() : escapeRST(Value);
 }

diff  --git a/llvm/docs/TableGen/BackEnds.rst b/llvm/docs/TableGen/BackEnds.rst
index b4ccdf95485e..1e1a4e71a1fd 100644
--- a/llvm/docs/TableGen/BackEnds.rst
+++ b/llvm/docs/TableGen/BackEnds.rst
@@ -693,8 +693,8 @@ This class provides six fields.
   table that holds the entries. If unspecified, the ``FilterClass`` name is
   used.
 
-* ``list Fields``. A list of the names of the fields in the
-  collected records that contain the data for the table entries. The order of
+* ``list Fields``. A list of the names of the fields *in the
+  collected records* that contain the data for the table entries. The order of
   this list determines the order of the values in the C++ initializers. See
   below for information about the types of these fields.
 
@@ -706,13 +706,26 @@ This class provides six fields.
 
 * ``bit PrimaryKeyEarlyOut``. See the third example below.
 
-TableGen attempts to deduce the type of each of the table fields. It can
-deduce ``bit``, ``bits``, ``string``, ``Intrinsic``, and ``Instruction``.
-These can be used in the primary key. TableGen also deduces ``code``, but it
-cannot be used in the primary key. Any other field types must be specified
+TableGen attempts to deduce the type of each of the table fields so that it
+can format the C++ initializers in the emitted table. It can deduce ``bit``,
+``bits``, ``string``, ``Intrinsic``, and ``Instruction``.  These can be
+used in the primary key. Any other field types must be specified
 explicitly; this is done as shown in the second example below. Such fields
 cannot be used in the primary key.
 
+One special case of the field type has to do with code. Arbitrary code is
+represented by a string, but has to be emitted as a C++ initializer without
+quotes. If the code field was defined using a code literal (``[{...}]``),
+then TableGen will know to emit it without quotes. However, if it was
+defined using a string literal or complex string expression, then TableGen
+will not know. In this case, you can force TableGen to treat the field as
+code by including the following line in the ``GenericTable`` record, where
+*xxx* is the code field name.
+
+.. code-block:: text
+
+  string TypeOf_xxx = "code";
+
 Here is an example where TableGen can deduce the field types. Note that the
 table entry records are anonymous; the names of entry records are
 irrelevant.
@@ -793,7 +806,7 @@ pointer if no entry is found.
 
 This example includes a field whose type TableGen cannot deduce. The ``Kind``
 field us

[PATCH] D92573: [clang] Add a C++17 deduction guide testcase.

2020-12-03 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz accepted this revision.
adamcz added a comment.
This revision is now accepted and ready to land.

Thanks, adding this test is a very good idea.




Comment at: clang/test/PCH/cxx17-deduction-guide-decl.cpp:16
+
+// Class template argument deduction
+template 

You can drop these 3 lines, they're not needed for the crash repro. Also, c-tor 
doesn't have to be explicit. Probably best to keep the code as short as 
possible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92573

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2020-12-03 Thread Alex Orlov via Phabricator via cfe-commits
aorlov updated this revision to Diff 309252.
aorlov added a comment.

Fixed typos. Made minor changes in test cases.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

Files:
  clang/include/clang/Parse/Parser.h
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/ParseDeclCXX.cpp
  clang/lib/Parse/ParseTemplate.cpp
  clang/test/CXX/drs/dr1xx.cpp
  clang/test/CXX/temp/temp.spec/func.spec.cpp
  clang/test/CXX/temp/temp.spec/part.spec.cpp

Index: clang/test/CXX/temp/temp.spec/part.spec.cpp
===
--- /dev/null
+++ clang/test/CXX/temp/temp.spec/part.spec.cpp
@@ -0,0 +1,565 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+// C++20 [temp.class.spec] 17.6.5/10:
+//   The usual access checking rules do not apply to non-dependent names used
+//   to specify template arguments of the simple-template-id of the partial
+//   specialization.
+
+// TODO: add test cases for `enum`
+
+// class for tests
+class TestClass {
+public:
+  class PublicClass {};
+  template  class TemplatePublicClass {};
+
+  using AliasPublicClass = unsigned char;
+
+  void publicFunc();
+  void publicFuncOverloaded();
+  void publicFuncOverloaded(int);
+
+  static void publicStaticFunc();
+  static void publicStaticFuncOverloaded();
+  static void publicStaticFuncOverloaded(int);
+
+  static constexpr int publicStaticInt = 42;
+
+protected:
+  // expected-note@+1 8{{declared protected here}}
+  class ProtectedClass {};
+  template  class TemplateProtectedClass {};
+
+  // expected-note@+1 2{{declared protected here}}
+  using AliasProtectedClass = const char;
+
+  // expected-note@+1 3{{declared protected here}}
+  void protectedFunc();
+  void protectedFuncOverloaded();
+  void protectedFuncOverloaded(int);
+
+  // expected-note@+1 2{{declared protected here}}
+  static void protectedStaticFunc();
+  // expected-note@+1 2{{declared protected here}}
+  static void protectedStaticFuncOverloaded();
+  static void protectedStaticFuncOverloaded(int);
+
+  // expected-note@+1 2{{declared protected here}}
+  static constexpr int protectedStaticInt = 43;
+
+private:
+  // expected-note@+1 10{{declared private here}}
+  class PrivateClass {};
+  // expected-note@+1 {{declared private here}}
+  template  class TemplatePrivateClass {};
+
+  using AliasPrivateClass = char *;
+
+  void privateFunc();
+  void privateFuncOverloaded();
+  void privateFuncOverloaded(int);
+
+  static void privateStaticFunc();
+  static void privateStaticFuncOverloaded();
+  static void privateStaticFuncOverloaded(int);
+
+  static constexpr int privateStaticInt = 44;
+};
+
+void globalFunction() {}
+
+//--//
+
+// template declarations for full specializations
+template  class CT1 {};
+template  class CT2 {};
+template  class CT3 {};
+template  class CT4 {};
+template  class CT5 {};
+template  class CT6 {
+  template  class NCT1 {};
+  template  class NCT2; // forward declaration
+};
+
+// full specializations
+
+// public
+template <> class CT1;
+template  class CT1>; // not full but let it be here
+template <> struct CT1>;
+template <> class CT1;
+template <> struct CT2;
+template <> class CT3;
+template <> struct CT4<&TestClass::publicFunc>;
+template <> class CT4<&TestClass::publicFuncOverloaded>;
+template <> struct CT5<&TestClass::publicStaticFunc>;
+template <> class CT5<&TestClass::publicStaticFuncOverloaded>;
+template <> class CT5<&globalFunction>;
+template <> template <> class CT6::NCT1;
+
+template <> class CT1 {};
+template  class CT1> {};
+template <> class CT1> {};
+template <> class CT1 {};
+template <> class CT2 {};
+template <> class CT3 {};
+template <> class CT4<&TestClass::publicFunc> {};
+template <> class CT4<&TestClass::publicFuncOverloaded> {};
+template <> class CT5<&TestClass::publicStaticFunc> {};
+template <> class CT5<&TestClass::publicStaticFuncOverloaded> {};
+template <> class CT5<&globalFunction> {};
+template <> template <> class CT6::NCT1 {};
+template <> template  class CT6::NCT2 {}; // declaration
+
+// protected
+template <> class CT1;
+template  class CT1>; // not full but let it be here
+template <> class CT1>;
+template <> struct CT1;
+template <> class CT2;
+template <> struct CT3;
+template <> class CT4<&TestClass::protectedFunc>;
+template <> struct CT4<&TestClass::protectedFuncOverloaded>;
+template <> class CT5<&TestClass::protectedStaticFunc>;
+template <> class CT5<&TestClass::protectedStaticFuncOverloaded>;
+template <> template <> class CT6::NCT1;
+
+template <> class CT1 {};
+template  class CT1> {}; // not full but let it be here
+template <> class CT1> {};
+template <> class CT1 {};
+template <> class CT2 {};
+template <> class CT3 {};
+template <> class CT4<&TestClass::protectedFunc> {};
+template <> class CT4<&TestClass::protectedFuncOverloaded> {};
+template <> class CT5<&TestClass::protectedStaticFunc> {};
+template

[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-12-03 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:9357
+
+  if (Lo) {
+SplatNode =

Braces can be omitted here and on 9364 if it's just a single statement.



Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:9366
+SplatNode = DAG.getNode(
+PPCISD::XXSPLTI32DX, SDLoc(SplatNode), MVT::v2i64, SplatNode,
+DAG.getTargetConstant(isLE ? 1 : 0, SplatNode, MVT::i32),

I think I'm still a little confused by this. Do we not need `dl` when we do 
`getNode()` here?



Comment at: llvm/lib/Target/PowerPC/PPCInstrPrefix.td:2385
+
+  def : Pat <(v2i64 (PPCxxsplti32dx v2i64:$XT, i32:$XI, i32:$IMM32)),
+ (v2i64 (XXSPLTI32DX v2i64:$XT, i32:$XI, i32:$IMM32))>;

It would be good to put this under the "Anonymous Patterns" section.


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

https://reviews.llvm.org/D90173

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


[PATCH] D92577: Don't reject tag declarations in for loop clause-1

2020-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman created this revision.
aaron.ballman added reviewers: rsmith, rjmccall.
aaron.ballman requested review of this revision.

We currently reject this valid C construct by claiming it declares a non-local 
variable: `for (struct { int i; } s={0}; s.i != 0; s.i--) ;`

The problem is that we expect all declaration in the clause-1 declaration 
statement to be `VarDecl`s of local variables, but there can be other 
declarations involved such as a tag declaration. We now ignore tag declarations 
when deciding whether the clause-1 declarations are valid or not. This fixes 
PR35757.


https://reviews.llvm.org/D92577

Files:
  clang/lib/Sema/SemaStmt.cpp
  clang/test/Sema/for.c


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -5,3 +5,5 @@
 void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of 
non-local variable}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of 
non-local variable}}
 void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of 
non-local variable}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1826,7 +1826,10 @@
 VarDecl *VD = dyn_cast(DI);
 if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage())
   VD = nullptr;
-if (!VD) {
+// It is possible to declare non-variable declarations as part of the
+// declaration part of a 'for' statement, such as defining a structure
+// or enum type: for (enum { zero, ten } i = zero; i < ten; ++i);
+if (!VD && !isa(DI)) {
   Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
   DI->setInvalidDecl();
 }


Index: clang/test/Sema/for.c
===
--- clang/test/Sema/for.c
+++ clang/test/Sema/for.c
@@ -5,3 +5,5 @@
 void b2 (void) { for (void f (void);;); }   // expected-error {{declaration of non-local variable}}
 void b3 (void) { for (static int f;;); }// expected-error {{declaration of non-local variable}}
 void b4 (void) { for (typedef int f;;); }   // expected-error {{declaration of non-local variable}}
+void b5 (void) { for (struct { int i; } s;;); }
+void b6 (void) { for (enum { zero, ten = 10 } i;;); }
Index: clang/lib/Sema/SemaStmt.cpp
===
--- clang/lib/Sema/SemaStmt.cpp
+++ clang/lib/Sema/SemaStmt.cpp
@@ -1826,7 +1826,10 @@
 VarDecl *VD = dyn_cast(DI);
 if (VD && VD->isLocalVarDecl() && !VD->hasLocalStorage())
   VD = nullptr;
-if (!VD) {
+// It is possible to declare non-variable declarations as part of the
+// declaration part of a 'for' statement, such as defining a structure
+// or enum type: for (enum { zero, ten } i = zero; i < ten; ++i);
+if (!VD && !isa(DI)) {
   Diag(DI->getLocation(), diag::err_non_local_variable_decl_in_for);
   DI->setInvalidDecl();
 }
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang-tools-extra] 517828a - [clangd] Bundle code completion items when the include paths differ, but resolve to the same file.

2020-12-03 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2020-12-03T16:33:15+01:00
New Revision: 517828a31b0d1b7cfd1fd261046746bd8778420a

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

LOG: [clangd] Bundle code completion items when the include paths differ, but 
resolve to the same file.

This can happen when, for example, merging results from an external
index that generates IncludeHeaders with full URI rather than just
literal include.

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

Added: 


Modified: 
clang-tools-extra/clangd/CodeComplete.cpp
clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/CodeComplete.cpp 
b/clang-tools-extra/clangd/CodeComplete.cpp
index 1d85439f53af..cc6b5dbc9904 100644
--- a/clang-tools-extra/clangd/CodeComplete.cpp
+++ b/clang-tools-extra/clangd/CodeComplete.cpp
@@ -173,9 +173,22 @@ struct CompletionCandidate {
 
   // Returns a token identifying the overload set this is part of.
   // 0 indicates it's not part of any overload set.
-  size_t overloadSet(const CodeCompleteOptions &Opts) const {
+  size_t overloadSet(const CodeCompleteOptions &Opts, llvm::StringRef FileName,
+ IncludeInserter *Inserter) const {
 if (!Opts.BundleOverloads.getValueOr(false))
   return 0;
+
+// Depending on the index implementation, we can see 
diff erent header
+// strings (literal or URI) mapping to the same file. We still want to
+// bundle those, so we must resolve the header to be included here.
+std::string HeaderForHash;
+if (Inserter)
+  if (auto Header = headerToInsertIfAllowed(Opts))
+if (auto HeaderFile = toHeaderFile(*Header, FileName))
+  if (auto Spelled =
+  Inserter->calculateIncludePath(*HeaderFile, FileName))
+HeaderForHash = *Spelled;
+
 llvm::SmallString<256> Scratch;
 if (IndexResult) {
   switch (IndexResult->SymInfo.Kind) {
@@ -192,7 +205,7 @@ struct CompletionCandidate {
 // This could break #include insertion.
 return llvm::hash_combine(
 (IndexResult->Scope + IndexResult->Name).toStringRef(Scratch),
-headerToInsertIfAllowed(Opts).getValueOr(""));
+HeaderForHash);
   default:
 return 0;
   }
@@ -206,8 +219,7 @@ struct CompletionCandidate {
 llvm::raw_svector_ostream OS(Scratch);
 D->printQualifiedName(OS);
   }
-  return llvm::hash_combine(Scratch,
-headerToInsertIfAllowed(Opts).getValueOr(""));
+  return llvm::hash_combine(Scratch, HeaderForHash);
 }
 assert(IdentifierResult);
 return 0;
@@ -1570,7 +1582,8 @@ class CodeCompleteFlow {
 assert(IdentifierResult);
 C.Name = IdentifierResult->Name;
   }
-  if (auto OverloadSet = C.overloadSet(Opts)) {
+  if (auto OverloadSet = C.overloadSet(
+  Opts, FileName, Inserter ? Inserter.getPointer() : nullptr)) {
 auto Ret = BundleLookup.try_emplace(OverloadSet, Bundles.size());
 if (Ret.second)
   Bundles.emplace_back();

diff  --git a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp 
b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
index a7e1c6c48143..a19c6a83e954 100644
--- a/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ b/clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1628,6 +1628,29 @@ TEST(CompletionTest, OverloadBundling) {
   EXPECT_EQ(A.SnippetSuffix, "($0)");
 }
 
+TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
+  Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::create(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI.c_str();
+  SymY.CanonicalDeclaration.FileURI = BarURI.c_str();
+  // The include header is 
diff erent, but really it's the same file.
+  SymX.IncludeHeaders.emplace_back("\"bar.h\"", 1);
+  SymY.IncludeHeaders.emplace_back(BarURI.c_str(), 1);
+
+  auto Results = completions("void f() { ::ns::^ }", {SymX, SymY}, Opts);
+  // Expect both results are bundled, despite the 
diff erent-but-same
+  // IncludeHeader.
+  ASSERT_EQ(1u, Results.Completions.size());
+  const auto &R = Results.Completions.front();
+  EXPECT_EQ("X", R.Name);
+  EXPECT_EQ(2u, R.BundleSize);
+}
+
 TEST(CompletionTest, DocumentationFromChangedFileCrash) {
   MockFS FS;
   auto FooH = testPath("foo.h");



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

[PATCH] D92494: [clangd] Bundle code completion items when the include paths differ, but resolve to the same file.

2020-12-03 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG517828a31b0d: [clangd] Bundle code completion items when the 
include paths differ, but… (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92494

Files:
  clang-tools-extra/clangd/CodeComplete.cpp
  clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1628,6 +1628,29 @@
   EXPECT_EQ(A.SnippetSuffix, "($0)");
 }
 
+TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
+  Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::create(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI.c_str();
+  SymY.CanonicalDeclaration.FileURI = BarURI.c_str();
+  // The include header is different, but really it's the same file.
+  SymX.IncludeHeaders.emplace_back("\"bar.h\"", 1);
+  SymY.IncludeHeaders.emplace_back(BarURI.c_str(), 1);
+
+  auto Results = completions("void f() { ::ns::^ }", {SymX, SymY}, Opts);
+  // Expect both results are bundled, despite the different-but-same
+  // IncludeHeader.
+  ASSERT_EQ(1u, Results.Completions.size());
+  const auto &R = Results.Completions.front();
+  EXPECT_EQ("X", R.Name);
+  EXPECT_EQ(2u, R.BundleSize);
+}
+
 TEST(CompletionTest, DocumentationFromChangedFileCrash) {
   MockFS FS;
   auto FooH = testPath("foo.h");
Index: clang-tools-extra/clangd/CodeComplete.cpp
===
--- clang-tools-extra/clangd/CodeComplete.cpp
+++ clang-tools-extra/clangd/CodeComplete.cpp
@@ -173,9 +173,22 @@
 
   // Returns a token identifying the overload set this is part of.
   // 0 indicates it's not part of any overload set.
-  size_t overloadSet(const CodeCompleteOptions &Opts) const {
+  size_t overloadSet(const CodeCompleteOptions &Opts, llvm::StringRef FileName,
+ IncludeInserter *Inserter) const {
 if (!Opts.BundleOverloads.getValueOr(false))
   return 0;
+
+// Depending on the index implementation, we can see different header
+// strings (literal or URI) mapping to the same file. We still want to
+// bundle those, so we must resolve the header to be included here.
+std::string HeaderForHash;
+if (Inserter)
+  if (auto Header = headerToInsertIfAllowed(Opts))
+if (auto HeaderFile = toHeaderFile(*Header, FileName))
+  if (auto Spelled =
+  Inserter->calculateIncludePath(*HeaderFile, FileName))
+HeaderForHash = *Spelled;
+
 llvm::SmallString<256> Scratch;
 if (IndexResult) {
   switch (IndexResult->SymInfo.Kind) {
@@ -192,7 +205,7 @@
 // This could break #include insertion.
 return llvm::hash_combine(
 (IndexResult->Scope + IndexResult->Name).toStringRef(Scratch),
-headerToInsertIfAllowed(Opts).getValueOr(""));
+HeaderForHash);
   default:
 return 0;
   }
@@ -206,8 +219,7 @@
 llvm::raw_svector_ostream OS(Scratch);
 D->printQualifiedName(OS);
   }
-  return llvm::hash_combine(Scratch,
-headerToInsertIfAllowed(Opts).getValueOr(""));
+  return llvm::hash_combine(Scratch, HeaderForHash);
 }
 assert(IdentifierResult);
 return 0;
@@ -1570,7 +1582,8 @@
 assert(IdentifierResult);
 C.Name = IdentifierResult->Name;
   }
-  if (auto OverloadSet = C.overloadSet(Opts)) {
+  if (auto OverloadSet = C.overloadSet(
+  Opts, FileName, Inserter ? Inserter.getPointer() : nullptr)) {
 auto Ret = BundleLookup.try_emplace(OverloadSet, Bundles.size());
 if (Ret.second)
   Bundles.emplace_back();


Index: clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
===
--- clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
+++ clang-tools-extra/clangd/unittests/CodeCompleteTests.cpp
@@ -1628,6 +1628,29 @@
   EXPECT_EQ(A.SnippetSuffix, "($0)");
 }
 
+TEST(CompletionTest, OverloadBundlingSameFileDifferentURI) {
+  clangd::CodeCompleteOptions Opts;
+  Opts.BundleOverloads = true;
+
+  Symbol SymX = sym("ns::X", index::SymbolKind::Function, "@F@\\0#");
+  Symbol SymY = sym("ns::X", index::SymbolKind::Function, "@F@\\0#I#");
+  std::string BarHeader = testPath("bar.h");
+  auto BarURI = URI::create(BarHeader).toString();
+  SymX.CanonicalDeclaration.FileURI = BarURI.c_str();
+  SymY.CanonicalDeclarati

[PATCH] D72184: [BPF] support atomic instructions

2020-12-03 Thread Yonghong Song 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 rG286daafd6512: [BPF] support atomic instructions (authored by 
yonghong-song).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D72184

Files:
  llvm/lib/Target/BPF/BPFInstrFormats.td
  llvm/lib/Target/BPF/BPFInstrInfo.td
  llvm/lib/Target/BPF/BPFMIChecking.cpp
  llvm/lib/Target/BPF/Disassembler/BPFDisassembler.cpp
  llvm/lib/Target/BPF/MCTargetDesc/BPFMCCodeEmitter.cpp
  llvm/test/CodeGen/BPF/atomics.ll
  llvm/test/CodeGen/BPF/atomics_2.ll
  llvm/test/CodeGen/BPF/xadd.ll

Index: llvm/test/CodeGen/BPF/xadd.ll
===
--- llvm/test/CodeGen/BPF/xadd.ll
+++ llvm/test/CodeGen/BPF/xadd.ll
@@ -1,7 +1,5 @@
 ; RUN: not --crash llc -march=bpfel < %s 2>&1 | FileCheck %s
 ; RUN: not --crash llc -march=bpfeb < %s 2>&1 | FileCheck %s
-; RUN: not --crash llc -march=bpfel -mattr=+alu32 < %s 2>&1 | FileCheck %s
-; RUN: not --crash llc -march=bpfeb -mattr=+alu32 < %s 2>&1 | FileCheck %s
 
 ; This file is generated with the source command and source
 ; $ clang -target bpf -O2 -g -S -emit-llvm t.c
Index: llvm/test/CodeGen/BPF/atomics_2.ll
===
--- /dev/null
+++ llvm/test/CodeGen/BPF/atomics_2.ll
@@ -0,0 +1,254 @@
+; RUN: llc < %s -march=bpfel -mcpu=v3 -verify-machineinstrs -show-mc-encoding | FileCheck %s
+;
+; Source:
+;   int test_load_add_32(int *p, int v) {
+; return __sync_fetch_and_add(p, v);
+;   }
+;   int test_load_add_64(long *p, long v) {
+; return __sync_fetch_and_add(p, v);
+;   }
+;   int test_load_sub_32(int *p, int v) {
+; return __sync_fetch_and_sub(p, v);
+;   }
+;   int test_load_sub_64(long *p, long v) {
+; return __sync_fetch_and_sub(p, v);
+;   }
+;   // from https://gcc.gnu.org/onlinedocs/gcc-4.1.1/gcc/Atomic-Builtins.html
+;   // __sync_lock_test_and_set() actually does atomic xchg and returns
+;   // old contents.
+;   int test_xchg_32(int *p, int v) {
+; return __sync_lock_test_and_set(p, v);
+;   }
+;   int test_xchg_64(long *p, long v) {
+; return __sync_lock_test_and_set(p, v);
+;   }
+;   int test_cas_32(int *p, int old, int new) {
+; return __sync_val_compare_and_swap(p, old, new);
+;   }
+;   long test_cas_64(long *p, long old, long new) {
+; return __sync_val_compare_and_swap(p, old, new);
+;   }
+;   int test_load_and_32(int *p, int v) {
+; return __sync_fetch_and_and(p, v);
+;   }
+;   int test_load_and_64(long *p, long v) {
+; return __sync_fetch_and_and(p, v);
+;   }
+;   int test_load_or_32(int *p, int v) {
+; return __sync_fetch_and_or(p, v);
+;   }
+;   int test_load_or_64(long *p, long v) {
+; return __sync_fetch_and_or(p, v);
+;   }
+;   int test_load_xor_32(int *p, int v) {
+; return __sync_fetch_and_xor(p, v);
+;   }
+;   int test_load_xor_64(long *p, long v) {
+; return __sync_fetch_and_xor(p, v);
+;   }
+;   int test_atomic_xor_32(int *p, int v) {
+; __sync_fetch_and_xor(p, v);
+; return 0;
+;   }
+;   int test_atomic_xor_64(long *p, long v) {
+; __sync_fetch_and_xor(p, v);
+; return 0;
+;   }
+;   int test_atomic_and_64(long *p, long v) {
+; __sync_fetch_and_and(p, v);
+; return 0;
+;   }
+;   int test_atomic_or_64(long *p, long v) {
+; __sync_fetch_and_or(p, v);
+; return 0;
+;   }
+
+; CHECK-LABEL: test_load_add_32
+; CHECK: w0 = w2
+; CHECK: w0 = atomic_fetch_add((u32 *)(r1 + 0), w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_add_32(i32* nocapture %p, i32 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw add i32* %p, i32 %v seq_cst
+  ret i32 %0
+}
+
+; CHECK-LABEL: test_load_add_64
+; CHECK: r0 = r2
+; CHECK: r0 = atomic_fetch_add((u64 *)(r1 + 0), r0)
+; CHECK: encoding: [0xdb,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_add_64(i64* nocapture %p, i64 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw add i64* %p, i64 %v seq_cst
+  %conv = trunc i64 %0 to i32
+  ret i32 %conv
+}
+
+; CHECK-LABEL: test_load_sub_32
+; CHECK: w0 = w2
+; CHECK: w0 = -w0
+; CHECK: w0 = atomic_fetch_add((u32 *)(r1 + 0), w0)
+; CHECK: encoding: [0xc3,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_sub_32(i32* nocapture %p, i32 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw sub i32* %p, i32 %v seq_cst
+  ret i32 %0
+}
+
+; CHECK-LABEL: test_load_sub_64
+; CHECK: r0 = r2
+; CHECK: r0 = -r0
+; CHECK: r0 = atomic_fetch_add((u64 *)(r1 + 0), r0)
+; CHECK: encoding: [0xdb,0x01,0x00,0x00,0x01,0x00,0x00,0x00]
+define dso_local i32 @test_load_sub_64(i64* nocapture %p, i64 %v) local_unnamed_addr {
+entry:
+  %0 = atomicrmw sub i64* %p, i64 %v seq_cst
+  %conv = trunc i64 %0 to i32
+  ret i32 %conv
+}
+
+; CHECK-LABEL: test_xchg_32
+; CHECK: w0 = w2
+; CHECK: w0 = xchg32_32(r1 +

[clang] aa11556 - [ASTMatchers][NFC] Made variadic operator funcs static

2020-12-03 Thread Nathan James via cfe-commits

Author: Nathan James
Date: 2020-12-03T15:47:54Z
New Revision: aa1155634fe41a53988a277ca7668a8d69f59f94

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

LOG: [ASTMatchers][NFC] Made variadic operator funcs static

Fix naming style while were here too.

Added: 


Modified: 
clang/lib/ASTMatchers/ASTMatchersInternal.cpp

Removed: 




diff  --git a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp 
b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
index 215afcd29b64..257a893ccaa6 100644
--- a/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ b/clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -49,26 +49,30 @@ AST_MATCHER_P(ObjCMessageExpr, hasAnySelectorMatcher, 
std::vector,
 
 namespace internal {
 
-bool NotUnaryOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
-  BoundNodesTreeBuilder *Builder,
-  ArrayRef InnerMatchers);
-
-bool AllOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
-   BoundNodesTreeBuilder *Builder,
-   ArrayRef InnerMatchers);
-
-bool EachOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder 
*Finder,
-BoundNodesTreeBuilder *Builder,
-ArrayRef InnerMatchers);
-
-bool AnyOfVariadicOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
-   BoundNodesTreeBuilder *Builder,
-   ArrayRef InnerMatchers);
-
-bool OptionallyVariadicOperator(const DynTypedNode &DynNode,
-ASTMatchFinder *Finder,
-BoundNodesTreeBuilder *Builder,
-ArrayRef InnerMatchers);
+static bool notUnaryOperator(const DynTypedNode &DynNode,
+ ASTMatchFinder *Finder,
+ BoundNodesTreeBuilder *Builder,
+ ArrayRef InnerMatchers);
+
+static bool allOfVariadicOperator(const DynTypedNode &DynNode,
+  ASTMatchFinder *Finder,
+  BoundNodesTreeBuilder *Builder,
+  ArrayRef InnerMatchers);
+
+static bool eachOfVariadicOperator(const DynTypedNode &DynNode,
+   ASTMatchFinder *Finder,
+   BoundNodesTreeBuilder *Builder,
+   ArrayRef InnerMatchers);
+
+static bool anyOfVariadicOperator(const DynTypedNode &DynNode,
+  ASTMatchFinder *Finder,
+  BoundNodesTreeBuilder *Builder,
+  ArrayRef InnerMatchers);
+
+static bool optionallyVariadicOperator(const DynTypedNode &DynNode,
+   ASTMatchFinder *Finder,
+   BoundNodesTreeBuilder *Builder,
+   ArrayRef 
InnerMatchers);
 
 bool matchesAnyBase(const CXXRecordDecl &Node,
 const Matcher &BaseSpecMatcher,
@@ -225,21 +229,21 @@ 
DynTypedMatcher::constructVariadic(DynTypedMatcher::VariadicOperator Op,
 }
 return DynTypedMatcher(
 SupportedKind, RestrictKind,
-new VariadicMatcher(std::move(InnerMatchers)));
+new VariadicMatcher(std::move(InnerMatchers)));
 
   case VO_AnyOf:
 return DynTypedMatcher(
 SupportedKind, RestrictKind,
-new VariadicMatcher(std::move(InnerMatchers)));
+new VariadicMatcher(std::move(InnerMatchers)));
 
   case VO_EachOf:
 return DynTypedMatcher(
 SupportedKind, RestrictKind,
-new VariadicMatcher(std::move(InnerMatchers)));
+new VariadicMatcher(std::move(InnerMatchers)));
 
   case VO_Optionally:
 return DynTypedMatcher(SupportedKind, RestrictKind,
-   new VariadicMatcher(
+   new VariadicMatcher(
std::move(InnerMatchers)));
 
   case VO_UnaryNot:
@@ -247,7 +251,7 @@ 
DynTypedMatcher::constructVariadic(DynTypedMatcher::VariadicOperator Op,
 // vector.
 return DynTypedMatcher(
 SupportedKind, RestrictKind,
-new VariadicMatcher(std::move(InnerMatchers)));
+new VariadicMatcher(std::move(InnerMatchers)));
   }
   llvm_unreachable("Invalid Op value.");
 }
@@ -354,9 +358,10 @@ void BoundNodesTreeBuilder::addMatch(const 
BoundNodesTreeBuilder &Other) {
   Bindings.append(Other.Bindings.begin(), Other.Bindings.end());
 }
 
-bool NotUnaryOperator(const DynTypedNode &DynNode, ASTMatchFinder *Finder,
-  BoundNodesTreeBuilder *Builder,
-  ArrayRef InnerMatchers) {
+static bool notUnaryOperator(const DynTyped

[clang] f77c948 - [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.

2020-12-03 Thread Ahmed Bougacha via cfe-commits

Author: Ahmed Bougacha
Date: 2020-12-03T07:53:59-08:00
New Revision: f77c948d56b09b839262e258af5c6ad701e5b168

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

LOG: [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.

This also teaches MachO writers/readers about the MachO cpu subtype,
beyond the minimal subtype reader support present at the moment.

This also defines a preprocessor macro to allow users to distinguish
__arm64__ from __arm64e__.

arm64e defaults to an "apple-a12" CPU, which supports v8.3a, allowing
pointer-authentication codegen.
It also currently defaults to ios14 and macos11.

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

Added: 
clang/test/Preprocessor/arm64e.c
llvm/test/MC/AArch64/arm64e-subtype.s
llvm/test/MC/AArch64/arm64e.s
llvm/test/tools/llvm-dwarfdump/AArch64/arm64e.ll
llvm/test/tools/llvm-readobj/macho-arm64e.test

Modified: 
clang/lib/Basic/Targets/AArch64.cpp
clang/lib/Driver/ToolChain.cpp
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/aarch64-cpus.c
clang/test/Driver/arclite-link.c
clang/test/Driver/target-triple-deployment.c
llvm/include/llvm/ADT/Triple.h
llvm/lib/BinaryFormat/MachO.cpp
llvm/lib/LTO/LTOCodeGenerator.cpp
llvm/lib/LTO/LTOModule.cpp
llvm/lib/Object/MachOObjectFile.cpp
llvm/lib/Support/ARMTargetParser.cpp
llvm/lib/Support/Triple.cpp
llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
llvm/test/MC/MachO/AArch64/arm-darwin-version-min-load-command.s
llvm/test/tools/llvm-objdump/MachO/universal-arm64.test
llvm/unittests/ADT/TripleTest.cpp
llvm/utils/UpdateTestChecks/asm.py

Removed: 




diff  --git a/clang/lib/Basic/Targets/AArch64.cpp 
b/clang/lib/Basic/Targets/AArch64.cpp
index abdd424ea048..c8162dd55220 100644
--- a/clang/lib/Basic/Targets/AArch64.cpp
+++ b/clang/lib/Basic/Targets/AArch64.cpp
@@ -874,6 +874,9 @@ void DarwinAArch64TargetInfo::getOSDefines(const 
LangOptions &Opts,
   Builder.defineMacro("__arm64", "1");
   Builder.defineMacro("__arm64__", "1");
 
+  if (Triple.isArm64e())
+Builder.defineMacro("__arm64e__", "1");
+
   getDarwinDefines(Builder, Opts, Triple, PlatformName, PlatformMinVersion);
 }
 

diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 85ab05cb7021..11b78a14fe47 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -232,8 +232,11 @@ StringRef ToolChain::getDefaultUniversalArchName() const {
   // the same as the ones that appear in the triple. Roughly speaking, this is
   // an inverse of the darwin::getArchTypeForDarwinArchName() function.
   switch (Triple.getArch()) {
-  case llvm::Triple::aarch64:
+  case llvm::Triple::aarch64: {
+if (getTriple().isArm64e())
+  return "arm64e";
 return "arm64";
+  }
   case llvm::Triple::aarch64_32:
 return "arm64_32";
   case llvm::Triple::ppc:
@@ -706,6 +709,9 @@ std::string ToolChain::ComputeLLVMTriple(const ArgList 
&Args,
 if (!Triple.isOSBinFormatMachO())
   return getTripleString();
 
+if (Triple.isArm64e())
+  return getTripleString();
+
 // FIXME: older versions of ld64 expect the "arm64" component in the actual
 // triple string and query it to determine whether an LTO file can be
 // handled. Remove this when we don't care any more.

diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index 06bb705a3721..0fc531b8c3a0 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -40,7 +40,12 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
   // Handle CPU name is 'native'.
   if (CPU == "native")
 return std::string(llvm::sys::getHostCPUName());
-  else if (CPU.size())
+
+  // arm64e requires v8.3a and only runs on apple-a12 and later CPUs.
+  if (Triple.isArm64e())
+return "apple-a12";
+
+  if (CPU.size())
 return CPU;
 
   if (Triple.isTargetMachineMac() &&

diff  --git a/clang/lib/Driver/ToolChains/Darwin.cpp 
b/clang/lib/Driver/ToolChains/Darwin.cpp
index 9f8560356405..eb7bd4aec898 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -7,6 +7,7 @@
 
//===--===//
 
 #include "Darwin.h"
+#include "Arch/AArch64.h"
 #include "Arch/ARM.h"
 #include "CommonArgs.h"
 #include "clang/Basic/AlignedAllocation.h"
@@ -58,7 +59,7 @@ llvm::Triple::ArchType 
darwin::getArchTypeForMachOArchName(StringRef Str) {
   .Cases("arm", "armv4t", "armv5", "armv6", "armv6m", llvm::Triple::arm)

[PATCH] D87095: [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.

2020-12-03 Thread Ahmed Bougacha via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rGf77c948d56b0: [Triple][MachO] Define "arm64e", an 
AArch64 subarch for Pointer Auth. (authored by ab).

Changed prior to commit:
  https://reviews.llvm.org/D87095?vs=292557&id=309261#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87095

Files:
  clang/lib/Basic/Targets/AArch64.cpp
  clang/lib/Driver/ToolChain.cpp
  clang/lib/Driver/ToolChains/Arch/AArch64.cpp
  clang/lib/Driver/ToolChains/Darwin.cpp
  clang/test/Driver/aarch64-cpus.c
  clang/test/Driver/arclite-link.c
  clang/test/Driver/target-triple-deployment.c
  clang/test/Preprocessor/arm64e.c
  llvm/include/llvm/ADT/Triple.h
  llvm/lib/BinaryFormat/MachO.cpp
  llvm/lib/LTO/LTOCodeGenerator.cpp
  llvm/lib/LTO/LTOModule.cpp
  llvm/lib/Object/MachOObjectFile.cpp
  llvm/lib/Support/ARMTargetParser.cpp
  llvm/lib/Support/Triple.cpp
  llvm/lib/Target/AArch64/AArch64TargetMachine.cpp
  llvm/lib/Target/AArch64/MCTargetDesc/AArch64MCTargetDesc.cpp
  llvm/test/MC/AArch64/arm64e-subtype.s
  llvm/test/MC/AArch64/arm64e.s
  llvm/test/MC/MachO/AArch64/arm-darwin-version-min-load-command.s
  llvm/test/tools/llvm-dwarfdump/AArch64/arm64e.ll
  llvm/test/tools/llvm-objdump/MachO/universal-arm64.test
  llvm/test/tools/llvm-readobj/macho-arm64e.test
  llvm/unittests/ADT/TripleTest.cpp
  llvm/utils/UpdateTestChecks/asm.py

Index: llvm/utils/UpdateTestChecks/asm.py
===
--- llvm/utils/UpdateTestChecks/asm.py
+++ llvm/utils/UpdateTestChecks/asm.py
@@ -336,6 +336,7 @@
   'amdgcn': (scrub_asm_amdgpu, ASM_FUNCTION_AMDGPU_RE),
   'arm': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_RE),
   'arm64': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_RE),
+  'arm64e': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_DARWIN_RE),
   'arm64-apple-ios': (scrub_asm_arm_eabi, ASM_FUNCTION_AARCH64_DARWIN_RE),
   'armv7-apple-ios' : (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_IOS_RE),
   'armv7-apple-darwin': (scrub_asm_arm_eabi, ASM_FUNCTION_ARM_DARWIN_RE),
Index: llvm/unittests/ADT/TripleTest.cpp
===
--- llvm/unittests/ADT/TripleTest.cpp
+++ llvm/unittests/ADT/TripleTest.cpp
@@ -1590,5 +1590,10 @@
 Triple T = Triple("aarch64_be");
 EXPECT_EQ(Triple::aarch64_be, T.getArch());
   }
+  {
+Triple T = Triple("arm64e");
+EXPECT_EQ(Triple::aarch64, T.getArch());
+EXPECT_EQ(Triple::AArch64SubArch_arm64e, T.getSubArch());
+  }
 }
 } // end anonymous namespace
Index: llvm/test/tools/llvm-readobj/macho-arm64e.test
===
--- /dev/null
+++ llvm/test/tools/llvm-readobj/macho-arm64e.test
@@ -0,0 +1,17 @@
+# RUN: yaml2obj %s -o %t.o
+# RUN: llvm-readobj -h %t.o | FileCheck %s
+
+# CHECK: Magic: Magic64 (0xFEEDFACF)
+# CHECK: CpuType: Arm64 (0x10C)
+# CHECK: CpuSubType: CPU_SUBTYPE_ARM64E (0x2)
+
+--- !mach-o
+FileHeader:
+  magic:   0xFEEDFACF
+  cputype: 0x010C
+  cpusubtype:  0x0002
+  filetype:0x0001
+  ncmds:   0
+  sizeofcmds:  0
+  flags:   0x
+  reserved:0x
Index: llvm/test/tools/llvm-objdump/MachO/universal-arm64.test
===
--- llvm/test/tools/llvm-objdump/MachO/universal-arm64.test
+++ llvm/test/tools/llvm-objdump/MachO/universal-arm64.test
@@ -22,7 +22,7 @@
 # CHECK-NEXT: offset 16384
 # CHECK-NEXT: size 384
 # CHECK-NEXT: align 2^14 (16384)
-# CHECK-NEXT: architecture
+# CHECK-NEXT: architecture arm64e
 # CHECK-NEXT: cputype CPU_TYPE_ARM64
 # CHECK-NEXT: cpusubtype CPU_SUBTYPE_ARM64E
 # CHECK-NEXT: capabilities 0x0
Index: llvm/test/tools/llvm-dwarfdump/AArch64/arm64e.ll
===
--- /dev/null
+++ llvm/test/tools/llvm-dwarfdump/AArch64/arm64e.ll
@@ -0,0 +1,17 @@
+; RUN: llc -O0 %s -filetype=obj -o - \
+; RUN:   | llvm-dwarfdump -arch arm64e - | FileCheck %s
+; CHECK: file format Mach-O arm64
+
+source_filename = "/tmp/empty.c"
+target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
+target triple = "arm64e-apple-ios"
+
+!llvm.module.flags = !{!1, !2, !3, !4}
+!llvm.dbg.cu = !{!5}
+
+!1 = !{i32 2, !"Dwarf Version", i32 4}
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = !{i32 1, !"wchar_size", i32 4}
+!4 = !{i32 7, !"PIC Level", i32 2}
+!5 = distinct !DICompileUnit(language: DW_LANG_C99, file: !6, producer: "Apple clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug)
+!6 = !DIFile(filename: "/tmp/empty.c", directory: "/Volumes/Data/llvm-project")
Index: llvm/test/MC/MachO/AArch64/arm-darwin-version-min-load-command.s
===

[PATCH] D87095: [Triple][MachO] Define "arm64e", an AArch64 subarch for Pointer Auth.

2020-12-03 Thread Ahmed Bougacha via Phabricator via cfe-commits
ab added a comment.

Thanks Tim!  f77c948d56b 



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87095

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


[clang] c00516d - Try to fix tests on Windows after 0cbf61be8be

2020-12-03 Thread Nico Weber via cfe-commits

Author: Nico Weber
Date: 2020-12-03T10:55:05-05:00
New Revision: c00516d52054e31179ce921a35a3815032feed0f

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

LOG: Try to fix tests on Windows after 0cbf61be8be

Added: 


Modified: 
clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
clang/test/SemaCXX/typeid-ref.cpp

Removed: 




diff  --git a/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp 
b/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
index 7f93c7297227..db94aed9c8c8 100644
--- a/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
+++ b/clang/test/CodeGenCXX/weak-extern-typeinfo.cpp
@@ -31,17 +31,17 @@ class V2 : public virtual V1 {
 void V1::foo() { }
 void V2::foo() { }
 
-// CHECK: @_ZTS1A = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTI1A = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTS1B = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTI1B = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTS1C = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTS2T1 = linkonce_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTI2T1 = linkonce_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTS1T = linkonce_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTI1T = linkonce_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTI1C = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTS2V1 = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTI2V1 = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTS2V2 = weak_odr {{(dso_local|hidden )?}}constant
-// CHECK: @_ZTI2V2 = weak_odr {{(dso_local|hidden )?}}constant
+// CHECK: @_ZTS1A = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI1A = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS1B = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI1B = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS1C = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS2T1 = linkonce_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI2T1 = linkonce_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS1T = linkonce_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI1T = linkonce_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI1C = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS2V1 = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI2V1 = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTS2V2 = weak_odr {{(dso_local |hidden )?}}constant
+// CHECK: @_ZTI2V2 = weak_odr {{(dso_local |hidden )?}}constant

diff  --git a/clang/test/SemaCXX/typeid-ref.cpp 
b/clang/test/SemaCXX/typeid-ref.cpp
index 5a917df8ecf9..f788b04077ec 100644
--- a/clang/test/SemaCXX/typeid-ref.cpp
+++ b/clang/test/SemaCXX/typeid-ref.cpp
@@ -6,7 +6,7 @@ namespace std {
 struct X { };
 
 void f() {
-  // CHECK: @_ZTS1X = linkonce_odr {{(dso_local|hidden )?}}constant
-  // CHECK: @_ZTI1X = linkonce_odr {{(dso_local|hidden )?}}constant
+  // CHECK: @_ZTS1X = linkonce_odr {{(dso_local |hidden )?}}constant
+  // CHECK: @_ZTI1X = linkonce_odr {{(dso_local |hidden )?}}constant
   (void)typeid(X&);
 }



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


[PATCH] D92432: [analyzer] Add a thin abstraction layer between libCrossTU and libAnalysis.

2020-12-03 Thread Valeriy Savchenko via Phabricator via cfe-commits
vsavchenko accepted this revision.
vsavchenko added a comment.

LGTM!


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

https://reviews.llvm.org/D92432

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


[PATCH] D92439: [CLANG] Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D92439#2429815 , @jyu2 wrote:

> In D92439#2429511 , @jdoerfert wrote:
>
>> Still unsure if we should also error out for NVPTX but that is a different 
>> story. Looks OK from my side, assuming you address the earlier comment.
>
> With this change if NVPTX need diagnostic for  use of 128-bit integer, adding 
> "bool hasInt128Type() const override { return false; }" in NVPTX.h is all 
> needed.
>
>> Maybe someone else should accept though.
>
> Do you have suggestion whom I may contact for acceptance?  We have customer 
> needs for this...   Thank you in advance. :-)

You have the right people as reviewers, it sometimes need a few days. You can 
ping it after a week without progress.


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

https://reviews.llvm.org/D92439

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


[PATCH] D92439: [CLANG] Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.

In D92439#2431256 , @jdoerfert wrote:

> In D92439#2429815 , @jyu2 wrote:
>
>> In D92439#2429511 , @jdoerfert 
>> wrote:
>>
>>> Still unsure if we should also error out for NVPTX but that is a different 
>>> story. Looks OK from my side, assuming you address the earlier comment.
>>
>> With this change if NVPTX need diagnostic for  use of 128-bit integer, 
>> adding "bool hasInt128Type() const override { return false; }" in NVPTX.h is 
>> all needed.
>>
>>> Maybe someone else should accept though.
>>
>> Do you have suggestion whom I may contact for acceptance?  We have customer 
>> needs for this...   Thank you in advance. :-)
>
> You have the right people as reviewers, it sometimes need a few days. You can 
> ping it after a week without progress.

FWIW, the changes LGTM but I don't know enough about the domain to know the 
answer for NVPTX. That said, this is still good incremental progress as-is.


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

https://reviews.llvm.org/D92439

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


[PATCH] D91944: OpenMP 5.0 metadirective

2020-12-03 Thread Alok Mishra via Phabricator via cfe-commits
alokmishra.besu updated this revision to Diff 309268.
alokmishra.besu added a comment.

Updated version of metadirective supporting OpenMP 5.0 features


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

Files:
  clang/include/clang-c/Index.h
  clang/include/clang/AST/RecursiveASTVisitor.h
  clang/include/clang/AST/StmtOpenMP.h
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Basic/StmtNodes.td
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/lib/AST/OpenMPClause.cpp
  clang/lib/AST/StmtOpenMP.cpp
  clang/lib/AST/StmtPrinter.cpp
  clang/lib/AST/StmtProfile.cpp
  clang/lib/Basic/OpenMPKinds.cpp
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  clang/lib/CodeGen/CGStmt.cpp
  clang/lib/CodeGen/CGStmtOpenMP.cpp
  clang/lib/CodeGen/CodeGenFunction.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaExceptionSpec.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderStmt.cpp
  clang/lib/Serialization/ASTWriterStmt.cpp
  clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
  clang/test/OpenMP/metadirective_ast_print.c
  clang/test/OpenMP/metadirective_ast_print.cpp
  clang/test/OpenMP/metadirective_device_kind_codegen.c
  clang/test/OpenMP/metadirective_device_kind_codegen.cpp
  clang/test/OpenMP/metadirective_empty.cpp
  clang/test/OpenMP/metadirective_implementation_codegen.c
  clang/test/OpenMP/metadirective_implementation_codegen.cpp
  clang/test/OpenMP/metadirective_messages.cpp
  clang/tools/libclang/CIndex.cpp
  clang/tools/libclang/CXCursor.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPContext.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPContext.cpp

Index: llvm/lib/Frontend/OpenMP/OMPContext.cpp
===
--- llvm/lib/Frontend/OpenMP/OMPContext.cpp
+++ llvm/lib/Frontend/OpenMP/OMPContext.cpp
@@ -332,6 +332,16 @@
   return Score;
 }
 
+int llvm::omp::getBestWhenMatchForContext(
+const SmallVectorImpl &VMIs, const OMPContext &Ctx,
+SmallVectorImpl *OrderedMatch) {
+
+  // TODO: This will become invalid in OpenMP 5.1
+  // In OpenMP 5.1 we need to analyze and get all variant which can be resolved
+  // during runtime, and set their position in OrderedMatch.
+  return getBestVariantMatchForContext(VMIs, Ctx);
+}
+
 int llvm::omp::getBestVariantMatchForContext(
 const SmallVectorImpl &VMIs, const OMPContext &Ctx) {
 
Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -115,6 +115,7 @@
 __OMP_CLAUSE_NO_CLASS(uniform)
 __OMP_CLAUSE_NO_CLASS(device_type)
 __OMP_CLAUSE_NO_CLASS(match)
+__OMP_CLAUSE_NO_CLASS(when)
 
 __OMP_IMPLICIT_CLAUSE_CLASS(depobj, "depobj", OMPDepobjClause)
 __OMP_IMPLICIT_CLAUSE_CLASS(flush, "flush", OMPFlushClause)
Index: llvm/include/llvm/Frontend/OpenMP/OMPContext.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPContext.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPContext.h
@@ -184,6 +184,13 @@
   const OMPContext &Ctx,
   bool DeviceSetOnly = false);
 
+/// Return the index (into \p VMIs) of the When clause with the highest score
+/// from the ones applicble in \p Ctx.
+/// In OpenMP 5.1 set OrderedMatch to those conditions which need runtime
+/// resolution.
+int getBestWhenMatchForContext(
+const SmallVectorImpl &VMIs, const OMPContext &Ctx,
+SmallVectorImpl *OrderedMatch = nullptr);
 /// Return the index (into \p VMIs) of the variant with the highest score
 /// from the ones applicble in \p Ctx. See llvm::isVariantApplicableInContext.
 int getBestVariantMatchForContext(const SmallVectorImpl &VMIs,
Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -59,6 +59,7 @@
   let clangClass = "OMPCollapseClause";
   let flangClassValue = "ScalarIntConstantExpr";
 }
+def OMPC_When: Clause<"when"> {}
 def OMPC_Default : Clause<"default"> {
   let clangClass = "OMPDefaultClause";
   let flangClass = "OmpDefaultClause";
@@ -295,6 +296,14 @@
 // Definition of OpenMP directives
 //===--===//
 
+def OMP_Metadirective : Directive<"metadirective"> {
+  let allowedClauses = [
+VersionedClause
+  ];
+  let allowedOnceClauses = [
+VersionedClause
+  ];
+}
 def OMP_ThreadPrivate : Directive<"threadprivate"> {}
 def OMP_Parallel : Directive<"parallel"> {
   let allowedClauses = [
Index: clang/tools/lib

[PATCH] D91944: OpenMP 5.0 metadirective

2020-12-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:373
+///
+class OMPMetaDirective final : public OMPExecutableDirective {
+  friend class ASTStmtReader;

I think, metadirective should be a kind of a container for different 
sub-directives. The problem is that that subdirectives could be completely 
different, they may capture different variables, using different capture kind 
(by value or by reference) etc.So, you need to generate each possible 
sub-directive independently and store them in the meta directive node. 
Otherwise you won't be able to generate the code correctly.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91789: [clang-tidy] find/fix unneeded trailing semicolons in macros

2020-12-03 Thread Tom Rix via Phabricator via cfe-commits
trixirt updated this revision to Diff 309270.
trixirt added a comment.

move enum


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91789

Files:
  clang-tools-extra/clang-tidy/linuxkernel/CMakeLists.txt
  clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.cpp
  clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.h
  clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
  clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
  clang-tools-extra/test/clang-tidy/checkers/linuxkernel-switch-semi.c

Index: clang-tools-extra/test/clang-tidy/checkers/linuxkernel-switch-semi.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/linuxkernel-switch-semi.c
@@ -0,0 +1,41 @@
+// RUN: %check_clang_tidy %s linuxkernel-extra-semi %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: linuxkernel-extra-semi.Fixer, \
+// RUN:   value: 'Switch'}, \
+// RUN: ]}"
+
+int f(int a) {
+  switch (a) {
+  case 1:
+return 0;
+  default:
+break;
+  };
+  // CHECK-MESSAGES: :[[@LINE-1]]:4: warning: unneeded semicolon
+  // CHECK-FIXES:   }{{$}}
+  return 0;
+}
+
+// A normal switch, should not produce a warning
+int p1(int a) {
+  switch (a) {
+  case 1:
+return 0;
+  default:
+break;
+  }
+  return 0;
+}
+
+#define EMPTY_MACRO()
+// A corner case, do not fix an empty macro
+int p2(int a) {
+  switch (a) {
+  case 1:
+return 0;
+  default:
+break;
+  }
+  EMPTY_MACRO();
+  return 0;
+}
Index: clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/linuxkernel-macro-trailing-semi.c
@@ -0,0 +1,32 @@
+// RUN: %check_clang_tidy %s linuxkernel-extra-semi %t -- \
+// RUN:   -config="{CheckOptions: \
+// RUN: [{key: linuxkernel-extra-semi.Fixer, \
+// RUN:   value: 'TrailingMacro'}, \
+// RUN: ]}"
+
+#define M(a) a++;
+// CHECK-MESSAGES: :[[@LINE-1]]:17: warning: unneeded semicolon
+// CHECK-FIXES: #define M(a) a++{{$}}
+
+int f() {
+  int v = 0;
+  M(v);
+  return v;
+}
+
+// A corner case
+// An empty macro could conditionally contain another path so
+// do not warn or fix.
+#ifdef UNSET_CONDITION
+#define E() ;
+#else
+#define E()
+#endif
+#define N(a) a++;
+
+int g() {
+  int v = 0;
+  N(v)
+  E();
+  return v;
+}
Index: clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
===
--- clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
+++ clang-tools-extra/clang-tidy/linuxkernel/LinuxKernelTidyModule.cpp
@@ -9,6 +9,7 @@
 #include "../ClangTidy.h"
 #include "../ClangTidyModule.h"
 #include "../ClangTidyModuleRegistry.h"
+#include "ExtraSemiCheck.h"
 #include "MustCheckErrsCheck.h"
 
 namespace clang {
@@ -19,6 +20,7 @@
 class LinuxKernelModule : public ClangTidyModule {
 public:
   void addCheckFactories(ClangTidyCheckFactories &CheckFactories) override {
+CheckFactories.registerCheck("linuxkernel-extra-semi");
 CheckFactories.registerCheck(
 "linuxkernel-must-check-errs");
   }
Index: clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.h
===
--- /dev/null
+++ clang-tools-extra/clang-tidy/linuxkernel/ExtraSemiCheck.h
@@ -0,0 +1,45 @@
+//===--- ExtraSemiCheck.h - clang-tidy --*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+
+#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LINUXKERNEL_EXTRASEMICHECK_H
+#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_LINUXKERNEL_EXTRASEMICHECK_H
+
+#include "../ClangTidyCheck.h"
+#include "clang/Lex/MacroInfo.h"
+#include 
+
+namespace clang {
+namespace tidy {
+namespace linuxkernel {
+
+class ExtraSemiCheck : public ClangTidyCheck {
+
+  enum ExtraSemiFixerKind { ESFK_None, ESFK_Switch, ESFK_TrailingMacro };
+
+public:
+  ExtraSemiCheck(StringRef Name, ClangTidyContext *Context);
+  void registerMatchers(ast_matchers::MatchFinder *Finder) override;
+  void registerPPCallbacks(const SourceManager &SM, Preprocessor *PP,
+   Preprocessor *ModuleExpanderPP) override final;
+
+  void check(const ast_matchers::MatchFinder::MatchResult &Result) override;
+  void checkMacro(SourceManager &SM, const Token &MacroNameTok,
+  const MacroInfo *MI);
+  void storeOptions(ClangTidyOptions::OptionMap &Opts) override;
+
+private:
+  std::vector SuspectMacros;
+  enum ExtraSemiFixerKind FixerKind;
+  const std::string ExtraSemiFixerKindName;
+}

[PATCH] D91789: [clang-tidy] find/fix unneeded trailing semicolons in macros

2020-12-03 Thread Tom Rix via Phabricator via cfe-commits
trixirt added a comment.

How this is run in the kernel is a wip so adding it to the commit log is not 
very helpful.
Here is the lkml rfc
https://lkml.org/lkml/2020/11/21/190
This calling in the kernel needs needs to change because of the refactor.

The auto suggestions fail to build, so they are not helpful.

Yes eventually the first review should be dropped, i'll do that when this one 
lands.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91789

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


[PATCH] D92579: [clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.

2020-12-03 Thread Adam Czachorowski via Phabricator via cfe-commits
adamcz created this revision.
Herald added subscribers: cfe-commits, usaxena95, kadircet, arphaman.
Herald added a project: clang.
adamcz requested review of this revision.
Herald added subscribers: MaskRay, ilya-biryukov.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92579

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2523,6 +2523,9 @@
   // Do not offer code action on typo-corrections.
   EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
 
+  // NestedNameSpecifier, but no namespace.
+  EXPECT_UNAVAILABLE(Header + "class Foo {}; class F^oo foo;");
+
   // Check that we do not trigger in header files.
   FileName = "test.h";
   ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -274,6 +274,8 @@
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
   QualifierToRemove = E.getQualifierLoc();
+  if (!QualifierToRemove)
+return false;
 
   auto SpelledTokens =
   TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2523,6 +2523,9 @@
   // Do not offer code action on typo-corrections.
   EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
 
+  // NestedNameSpecifier, but no namespace.
+  EXPECT_UNAVAILABLE(Header + "class Foo {}; class F^oo foo;");
+
   // Check that we do not trigger in header files.
   FileName = "test.h";
   ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -274,6 +274,8 @@
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
   QualifierToRemove = E.getQualifierLoc();
+  if (!QualifierToRemove)
+return false;
 
   auto SpelledTokens =
   TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D91311: Add new 'preferred_name' attribute.

2020-12-03 Thread Louis Dionne via Phabricator via cfe-commits
ldionne added a comment.

In D91311#2423809 , @rsmith wrote:

> In D91311#2418881 , @ldionne wrote:
>
>> In D91311#2417293 , @rsmith wrote:
>>
>>> In D91311#2416940 , @ldionne wrote:
>>>
 LGTM from the libc++ point of view. The CI is passing -- those failures 
 are flaky modules tests that we need to fix.
>>>
>>> Perhaps we need to specify `-fmodules-validate-system-headers` in the test 
>>> so Clang doesn't assume that system headers are unchanged?
>>
>> Oh, would that be it? We're not including libc++ headers as system headers 
>> when running the tests, though (and we're disabling the system header 
>> pragma). Do you think that might still be the issue?
>
> The module map lists `std` as being `[system]` module, so I think the headers 
> will still end up being treated as system headers. So yes, I think there's a 
> possibility that is still the issue.
>
>> I tried a dumb workaround with D92131 , but 
>> it's arguably not great. I'd love to have your thoughts on that.
>
> I'm not sure that'll make any difference: at least in my setup, `%t` expands 
> to the same path on subsequent invocations of the same test, so you'll still 
> reuse module caches from one test run to the next. In Clang tests for this 
> sort of thing, we have explicit `RUN: rm -rf %t/ModuleCache` lines to clean 
> up any stale module cache before running a test... but that shouldn't really 
> be necessary; Clang should be able to detect when the files are out of date.

Ok, thanks for the info. I'll use `-fmodules-validate-system-headers` instead. 
Anyway, this patch LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91311

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


[PATCH] D92439: [CLANG] Fix missing error for use of 128-bit integer inside SPIR64 device code.

2020-12-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added a comment.

In D92439#2431270 , @aaron.ballman 
wrote:

> In D92439#2431256 , @jdoerfert wrote:
>
>> In D92439#2429815 , @jyu2 wrote:
>>
>>> In D92439#2429511 , @jdoerfert 
>>> wrote:
>>>
 Still unsure if we should also error out for NVPTX but that is a different 
 story. Looks OK from my side, assuming you address the earlier comment.
>>>
>>> With this change if NVPTX need diagnostic for  use of 128-bit integer, 
>>> adding "bool hasInt128Type() const override { return false; }" in NVPTX.h 
>>> is all needed.
>>>
 Maybe someone else should accept though.
>>>
>>> Do you have suggestion whom I may contact for acceptance?  We have customer 
>>> needs for this...   Thank you in advance. :-)
>>
>> You have the right people as reviewers, it sometimes need a few days. You 
>> can ping it after a week without progress.
>
> FWIW, the changes LGTM but I don't know enough about the domain to know the 
> answer for NVPTX. That said, this is still good incremental progress as-is.

Leave NVPTX out for now. As I said, it looks like the backend does the right 
thing so it is "legal" to have i128.


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

https://reviews.llvm.org/D92439

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


[PATCH] D92209: [ASTImporter] Support CXXDeductionGuideDecl with local typedef

2020-12-03 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added inline comments.



Comment at: clang/lib/AST/ASTImporter.cpp:2522
+  // Add to the lookupTable because we could not do that in MapImported.
+  Importer.AddToLookupTable(ToTypedef);
+

shafik wrote:
> I am not super excited about this solution, I feel like several bugs we have 
> had can be attributed to these exception control flow cases that we have in 
> the ASTImporter. I don't have any immediate better solution.
> 
> 
Before uploading this patch I had been thinking about several other solutions
but all of them had some problems:

1) 
Detect the loop in the AST and return with UnsupportedConstruct. We could do
the detection with the help of ImportPath. However, I realized this approach is
way too defensive and removes the support for an important AST node which is
against our goals.

2) 
Try to eliminate the looping contruct from the AST. I could do that for some
cases (D92101) but there are still cases when the Sema must create such a loop
deliberately (the test case in this patch shows that).

It is essential to add a newly created Decl to the lookupTable ASAP because it
makes it possible for subsequent imports to find the existing Decl and this way
avoiding the creation of duplicated Decls. This is why AddToLookupTable is
called in MapImported. But the lookuptable operates on the DeclContext of the
Decl, and in this patch we must not import the DeclContext before.
Consequently, we have to add to the loopkuptable once the DeclContext is
imported. Perhaps, we could provide an optional lambda function to
GetImportedOrCreateDecl which would be called before MapImported (and that
lambda would do the DC import), but this seems even more clumsy.

BTW, the lookuptable is not used in LLDB, there you use the traditional lookup
implemented in DeclContext (addDeclInternal and noload_lookup). One problem
with noload_lookup is that it does not find some Decls because it obeys to C++
visibility rules, thus new duplicated Decls are created. The ASTImporter must
be able to lookup e.g. template specialization Decls too, in order to avoid
creating a redundant duplicated clone and this is the task of the lookupTable.
I hope one day LLDB would be able to switch to ASTImporterLookupTable from
noload_lookup. The other problem is with addDeclInternal: we call this later,
not in MapImported. The only responsibility attached to the use of 
addDeclInternal 
should be to clone the visibility as it is in the source context (and not 
managing 
the do-not-create-duplicate-decls issue).

So yes, there are many exceptional control flow cases, but most of them stems
from the complexity of trying to support two different needs: noload_lookup and
minimal import are needed exceptionally for LLDB. I was thinking about to
create a separate ASTImporter implementation specifically for CTU and LLDB
could have it's own implementation. For that we just need to create an
interface class with virtual functions. Having two different implementations
could save us from braking each others tests and this could be a big gain, WDYT?
(On the other hand, we'd loose updates and fixes from the other team.)



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92209

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


[PATCH] D92495: [clang] Add a new nullability annotation for swift async: _Nullable_result

2020-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/include/clang/Basic/AttrDocs.td:3516
+``_Nullable_result`` pointer can be ``nil``, just like ``_Nullable``. Where 
this
+attribute differs from ``_Nullable`` is when its used on a parameter to a
+completion handler in a Swift async method. For instance, here:

its -> it's



Comment at: clang/include/clang/Basic/AttrDocs.td:3526
+available, or calls it with an error. ``_Nullable_result`` indicates to the
+Swift imported that this is the uncommon case where ``result`` can get ``nil``
+even if no error has occured, and will therefore import it as a Swift optional

Swift imported -> Swift importer



Comment at: clang/lib/Basic/IdentifierTable.cpp:718-719
+  case NullabilityKind::NullableResult:
+assert(!isContextSensitive &&
+   "_Nullable_result isn't supported as context-sensitive keyword");
+return "_Nullable_result";

Can you explain why it differs from `_Nullable` in this case?



Comment at: clang/lib/Sema/SemaExprObjC.cpp:1566
   unsigned receiverNullabilityIdx = 0;
-  if (auto nullability = ReceiverType->getNullability(Context))
+  if (auto nullability = ReceiverType->getNullability(Context)) {
+if (*nullability == NullabilityKind::NullableResult)

Should that be `auto *`?



Comment at: clang/lib/Sema/SemaExprObjC.cpp:1573
   unsigned resultNullabilityIdx = 0;
-  if (auto nullability = resultType->getNullability(Context))
+  if (auto nullability = resultType->getNullability(Context)) {
+if (*nullability == NullabilityKind::NullableResult)

Same here.


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

https://reviews.llvm.org/D92495

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


[PATCH] D92024: [clang] Implement P0692R1 from C++20 (access checking on specializations and instantiations)

2020-12-03 Thread Arthur O'Dwyer via Phabricator via cfe-commits
Quuxplusone added a comment.

The subject line says "access checking on specializations and instantiations," 
but I don't see any tests for explicit instantiations here — just 
specializations. In particular, I'm very interested to know if P0692 is 
intended to have any effect on the legality of https://godbolt.org/z/fqfo8q

  template struct T {};
  template struct T<&S::private_static_data>;

It would also be good to document which of the two proposed wordings from 
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2017/p0692r1.html is 
actually being adopted in this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92024

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


[PATCH] D92570: [clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in _mm_free

2020-12-03 Thread Reid Kleckner via Phabricator via cfe-commits
rnk accepted this revision.
rnk added a comment.
This revision is now accepted and ready to land.

lgtm




Comment at: clang/lib/Headers/mm_malloc.h:42
   void *__mallocedMemory;
 #if defined(__MINGW32__)
   __mallocedMemory = __mingw_aligned_malloc(__size, __align);

This has been here since 2011, and somehow nobody complained that we didn't use 
the corresponding `__mingw_aligned_free` API...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92570

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


[PATCH] D91885: [clang-tidy] Add support for diagnostics with no location

2020-12-03 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang-tools-extra/clang-tidy/ClangTidyCheck.h:183
+
+  /// Adds a diagnostic to report errors in the checks configuration.
+  DiagnosticBuilder

checks -> check's



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:276
+  // Never ignore these.
+} else if (!Context.isCheckEnabled(Error.DiagnosticName) &&
+   Error.DiagLevel != ClangTidyError::Error) {

Perhaps this is a bad idea, but would it make sense to have `isCheckEnabled()` 
report `true` for `clang-tidy-config`? It's not really a check, so that's a bit 
odd, but it seems like anywhere we're testing this property we wouldn't want to 
ignore config issues?



Comment at: clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h:102
+
+  /// Report any errors to do with reading configuration using this method
+  DiagnosticBuilder

with reading configuration -> with reading the configuration

and add a full stop to the end of the comment.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91885

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


[PATCH] D91944: OpenMP 5.0 metadirective

2020-12-03 Thread Alok Mishra via Phabricator via cfe-commits
alokmishra.besu added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:373
+///
+class OMPMetaDirective final : public OMPExecutableDirective {
+  friend class ASTStmtReader;

ABataev wrote:
> I think, metadirective should be a kind of a container for different 
> sub-directives. The problem is that that subdirectives could be completely 
> different, they may capture different variables, using different capture kind 
> (by value or by reference) etc.So, you need to generate each possible 
> sub-directive independently and store them in the meta directive node. 
> Otherwise you won't be able to generate the code correctly.
In OpenMP 5.0, we do not need to generate every sub-directive. Rather we need 
to select one (or none) directive and replace metadirective with it. So this is 
not needed.
Yes with future specifications we will need to include a list of all valid 
directives which need to be resolved at runtime. That is when we will need to 
generate and store multiple sub-directives inside the OMPMetaDirective class.  


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D92427: [OPENMP51] Add present modifier in defaultmap clause

2020-12-03 Thread Chi Chun Chen via Phabricator via cfe-commits
cchen updated this revision to Diff 309292.
cchen added a comment.

Update based on comment


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92427

Files:
  clang/include/clang/Basic/OpenMPKinds.def
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/target_ast_print.cpp
  clang/test/OpenMP/target_defaultmap_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_defaultmap_codegen_02.cpp
  clang/test/OpenMP/target_defaultmap_messages.cpp

Index: clang/test/OpenMP/target_defaultmap_messages.cpp
===
--- clang/test/OpenMP/target_defaultmap_messages.cpp
+++ clang/test/OpenMP/target_defaultmap_messages.cpp
@@ -1,3 +1,6 @@
+// RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=51 %s -verify=expected,omp51 -Wuninitialized -DOMP51
+// RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=51 %s -verify=expected,omp51 -Wuninitialized -DOMP51
+
 // RUN: %clang_cc1 -verify -fopenmp -fopenmp-version=50 %s -verify=expected,omp5 -Wuninitialized -DOMP5
 // RUN: %clang_cc1 -verify -fopenmp-simd -fopenmp-version=50 %s -verify=expected,omp5 -Wuninitialized -DOMP5
 
@@ -27,23 +30,24 @@
 T tmain(T argc, S **argv) {
   #pragma omp target defaultmap // expected-error {{expected '(' after 'defaultmap'}}
   foo();
-#pragma omp target defaultmap( // omp5-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp45-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+#pragma omp target defaultmap( // omp51-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default', 'present' in OpenMP clause 'defaultmap'}} omp5-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} expected-note {{to match this '('}} omp45-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
   foo();
-#pragma omp target defaultmap() // omp5-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default' in OpenMP clause 'defaultmap'}} omp45-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+#pragma omp target defaultmap() // omp51-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default', 'present' in OpenMP clause 'defaultmap'}} omp5-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default' in OpenMP clause 'defaultmap'}} omp45-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
   foo();
 #pragma omp target defaultmap(tofrom // expected-error {{expected ')'}} expected-note {{to match this '('}} omp45-warning {{missing ':' after defaultmap modifier - ignoring}} omp45-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
   foo();
-  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} omp5-error {{expected 'scalar', 'aggregate', 'pointer' in OpenMP clause 'defaultmap'}} omp45-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
+  #pragma omp target defaultmap (tofrom: // expected-error {{expected ')'}} expected-note {{to match this '('}} omp51-error {{expected 'scalar', 'aggregate', 'pointer' in OpenMP clause 'defaultmap'}} omp5-error {{expected 'scalar', 'aggregate', 'pointer' in OpenMP clause 'defaultmap'}} omp45-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
   foo();
 #pragma omp target defaultmap(tofrom) // omp45-warning {{missing ':' after defaultmap modifier - ignoring}} omp45-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
   foo();
 #pragma omp target defaultmap(tofrom, // expected-error {{expected ')'}} omp45-warning {{missing ':' after defaultmap modifier - ignoring}} expected-note {{to match this '('}} omp45-error {{expected 'scalar' in OpenMP clause 'defaultmap'}}
   foo();
-  #pragma omp target defaultmap (scalar: // omp5-error {{expected 'scalar', 'aggregate', 'pointer' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} omp5-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} omp45-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}
+  #pragma omp target defaultmap (scalar: // omp51-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default', 'present' in OpenMP clause 'defaultmap'}} omp51-error {{expected 'scalar', 'aggregate', 'pointer' in OpenMP clause 'defaultmap'}} omp5-error {{expected 'scalar', 'aggregate', 'pointer' in OpenMP clause 'defaultmap'}} expected-error {{expected ')'}} omp5-error {{expected 'alloc', 'from', 'to', 'tofrom', 'firstprivate', 'none', 'default' in OpenMP clause 'defaultmap'}} expected-note {{to match this '('}} omp45-error {{expected 'tofrom' in OpenMP clause 'defaultmap'}}

[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.

It is very unfortunate that we have to manage and translate between two sets of 
names (one pass name and one type name). This makes me wonder if we just keep 
the pass name as the return value of PassInfoMixin::name and get rid of class 
name everywhere. Right now I couldn't think of anything is blocking us from 
doing that. WDYT?  @asbirlea ?




Comment at: llvm/include/llvm/Passes/StandardInstrumentations.h:24
 #include "llvm/IR/ValueHandle.h"
+#include "llvm/Passes/PassBuilder.h"
 #include "llvm/Support/CommandLine.h"

It is better if forward declaring PassInstrumentationCallbacks could remove 
this include.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87216

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


[PATCH] D91944: OpenMP 5.0 metadirective

2020-12-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/include/clang/AST/StmtOpenMP.h:373
+///
+class OMPMetaDirective final : public OMPExecutableDirective {
+  friend class ASTStmtReader;

alokmishra.besu wrote:
> ABataev wrote:
> > I think, metadirective should be a kind of a container for different 
> > sub-directives. The problem is that that subdirectives could be completely 
> > different, they may capture different variables, using different capture 
> > kind (by value or by reference) etc.So, you need to generate each possible 
> > sub-directive independently and store them in the meta directive node. 
> > Otherwise you won't be able to generate the code correctly.
> In OpenMP 5.0, we do not need to generate every sub-directive. Rather we need 
> to select one (or none) directive and replace metadirective with it. So this 
> is not needed.
> Yes with future specifications we will need to include a list of all valid 
> directives which need to be resolved at runtime. That is when we will need to 
> generate and store multiple sub-directives inside the OMPMetaDirective class. 
>  
I think you still need to do it even for 5.0. I don't mean y need to emit the 
code for every sub-directive, but to generate them in the AST. Even in the 
example above, `when(user={condition(N>10)}` is used in the template and `N` is 
a template argument, the chosen directive can be selected on the instantiation 
and, thus, the original templated directive has to contain all possible 
sub-directives.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D91944: OpenMP 5.0 metadirective

2020-12-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/include/clang/Serialization/ASTBitCodes.h:1952
-  STMT_MS_DEPENDENT_EXISTS,   // MSDependentExistsStmt
-  EXPR_LAMBDA,// LambdaExpr
   STMT_COROUTINE_BODY,

alokmishra.besu wrote:
> jdoerfert wrote:
> > Unrelated.
> Only STMT_OMP_META_DIRECTIVE was added. Rest was formatted by git clang-format
> Rest was formatted by git clang-format

Please don't format unrelated code. 



Comment at: clang/lib/Parse/ParseOpenMP.cpp:2264
+  Actions.StartOpenMPDSABlock(DirKind, DirName, Actions.getCurScope(),
+  Loc);
+  int paren = 0;

alokmishra.besu wrote:
> jdoerfert wrote:
> > Should we not go back to the original code handling "directives" instead? 
> > This looks like it is copied here.
> Unfortunately we cannot go to the original code handling since the original 
> code handling assumes that the directive always ends with 
> annot_pragma_openmp_end, while here it will always end with ')'.
> In specification 5.0, since we are choosing only 1 directive, the body of the 
> while block remains the same as the original code. Only the condition of the 
> while block changes. In specification 5.1, we will need to generate code for 
> dynamic handling and even the body will differ as we might need to generate 
> AST node for multiple directives. It is best if we handle this code here for 
> easier handling of 5.1 code, than in the original code space.
> I will add a TODO comment here.
> Unfortunately we cannot go to the original code handling since the original 
> code handling assumes that the directive always ends with 
> annot_pragma_openmp_end, while here it will always end with ')'.

Let's add a flag to the original handling to make this possible then. Copying 
it is going to create more long term problems.



Comment at: llvm/lib/Frontend/OpenMP/OMPContext.cpp:337
+const SmallVectorImpl &VMIs, const OMPContext &Ctx,
+SmallVectorImpl *OrderedMatch) {
+

alokmishra.besu wrote:
> jdoerfert wrote:
> > This looks like a clone of `getBestVariantMatchForContext` with an extra 
> > unused argument.
> I intended to keep it similar for 5.0 to be updated in 5.1 code. But anyways 
> it seems to be giving wrong result. Will go through this again.
Use the `getBestVariantMatchForContext` interface now and for the 5.1 semantics 
we introduce the `OrderedMatch`. That can also be used in the call site declare 
variant handling which currently calls `getBestVariantMatchForContext` multiple 
times.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91944

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


[PATCH] D92427: [OPENMP51] Add present modifier in defaultmap clause

2020-12-03 Thread Alexey Bataev via Phabricator via cfe-commits
ABataev added inline comments.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3490
+OMPC_MAP_MODIFIER_present);
+ImplicitMapModifierLoc[ClauseKind].push_back(SourceLocation());
+  }

cchen wrote:
> ABataev wrote:
> > Why need to add an empty `SourceLocation`?
> I'm doing this since there is no actual location for present modifier. Maybe 
> I should just pass llvm::None to ActOnOpenMPMapClause.
Could you store the original location of the `present` modifier and add a real 
source location rather. Better to use correct locations when possible, it may 
help with the debug info emission


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92427

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


[PATCH] D92209: [ASTImporter] Support CXXDeductionGuideDecl with local typedef

2020-12-03 Thread Gabor Marton via Phabricator via cfe-commits
martong marked an inline comment as done.
martong added a comment.

> I was thinking about to create a separate ASTImporter implementation 
> specifically for CTU and LLDB could have it's own implementation. For that we 
> just need to create an interface class with virtual functions.

One implementation could reside in libCrossTU and the other in LLDB. At least, 
that's what I thought. Unfortunately there is an obstacle which renders this 
whole idea practically unfeasible: Currently ASTImporter and ASTNodeImporter 
are `friend`s of almost all AST classes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92209

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


[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-03 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added a comment.

In D87216#2431508 , @ychen wrote:

> It is very unfortunate that we have to manage and translate between two sets 
> of names (one pass name and one type name). This makes me wonder if we just 
> keep the pass name as the return value of PassInfoMixin::name and get rid of 
> class name everywhere. Right now I couldn't think of anything is blocking us 
> from doing that. WDYT?  @asbirlea ?

We'd have to move the names from PassRegistry.def to every pass class 
definition which would be a lot of work but definitely feasible.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87216

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


[PATCH] D92231: [OpenCL] Implement extended subgroups fully in headers

2020-12-03 Thread Anastasia Stulova via Phabricator via cfe-commits
Anastasia added a comment.

In D92231#2425323 , @Anastasia wrote:

> In D92231#2425305 , @PiotrFusik 
> wrote:
>
>> The specification for these extensions was edited by Ben Ashbaugh @Intel. 
>> I've asked him about this change.
>
> Sure. Thanks! Happy to hold off committing for a few days to see if Ben has 
> any feedback.

FYI, I have discussed this with Ben offline and he doesn't seem to have any 
objections on the approach. I will keep this open for another week to see if 
there is any detailed feedback from anyone.


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

https://reviews.llvm.org/D92231

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


[PATCH] D90173: [PowerPC] Exploit splat instruction xxsplti32dx in Power10

2020-12-03 Thread Albion Fung via Phabricator via cfe-commits
Conanap added a comment.

addressed a comment




Comment at: llvm/lib/Target/PowerPC/PPCISelLowering.cpp:9366
+SplatNode = DAG.getNode(
+PPCISD::XXSPLTI32DX, SDLoc(SplatNode), MVT::v2i64, SplatNode,
+DAG.getTargetConstant(isLE ? 1 : 0, SplatNode, MVT::i32),

amyk wrote:
> I think I'm still a little confused by this. Do we not need `dl` when we do 
> `getNode()` here?
Hey so the DL is supplied from `SplatNode`'s definition, and then we pass in 
`SDLoc(SplatNode)` here as the proper SDLoc after new instr def.


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

https://reviews.llvm.org/D90173

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


[PATCH] D92570: [clang] [Headers] Use the corresponding _aligned_free or __mingw_aligned_free in _mm_free

2020-12-03 Thread Martin Storsjö via Phabricator via cfe-commits
mstorsjo added inline comments.



Comment at: clang/lib/Headers/mm_malloc.h:42
   void *__mallocedMemory;
 #if defined(__MINGW32__)
   __mallocedMemory = __mingw_aligned_malloc(__size, __align);

rnk wrote:
> This has been here since 2011, and somehow nobody complained that we didn't 
> use the corresponding `__mingw_aligned_free` API...
Due to 
https://github.com/mingw-w64/mingw-w64/blob/master/mingw-w64-headers/crt/malloc.h#L72
 (which is included implicitly from stdlib.h), it hasn't been used much at all- 
maybe only when using the older mingw.org headers. But I'm considering 
suggesting to change that bit in the mingw-w64 headers (it's a bit of a mess 
when used with gcc's mm_malloc.h).

For msvc based configs it would have been noticable though. But I don't know 
how much `_mm_malloc` really is used...


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92570

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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-03 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith added inline comments.



Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-76
   RefCountedBase() = default;
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}

njames93 wrote:
> njames93 wrote:
> > dexonsmith wrote:
> > > dblaikie wrote:
> > > > I can't quite understand this comment - perhaps you could try 
> > > > rephrasing it?
> > > I'm not quite following why you needed to add these special members; it 
> > > seems like just the destructor would be enough for the assertion; but if 
> > > you do need them, can/should they be `= default`?
> > They can't be defaulted as we don't want to copy the RefCount.
> I understand it in my head, just can't think of the best way to write it down.
Maybe something like this would work:
```
/// Do not copy or move RefCount when constructing or assigning from
/// a derived type. These operations don't imply anything about the
/// number of IntrusiveRefCntPtr instances.
```
WDYT?



Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-80
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }

dexonsmith wrote:
> njames93 wrote:
> > njames93 wrote:
> > > dexonsmith wrote:
> > > > dblaikie wrote:
> > > > > I can't quite understand this comment - perhaps you could try 
> > > > > rephrasing it?
> > > > I'm not quite following why you needed to add these special members; it 
> > > > seems like just the destructor would be enough for the assertion; but 
> > > > if you do need them, can/should they be `= default`?
> > > They can't be defaulted as we don't want to copy the RefCount.
> > I understand it in my head, just can't think of the best way to write it 
> > down.
> Maybe something like this would work:
> ```
> /// Do not copy or move RefCount when constructing or assigning from
> /// a derived type. These operations don't imply anything about the
> /// number of IntrusiveRefCntPtr instances.
> ```
> WDYT?
Ah, I get it, thanks for explaining.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92480

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


[PATCH] D92363: [HIP] Warn no --offload-arch option

2020-12-03 Thread Yaxun Liu via Phabricator via cfe-commits
yaxunl added a comment.

In D92363#2426401 , @tra wrote:

> While I agree that the default GPU choice is not likely to be correct, or 
> usable, for everyone, but the warning seems to be a half-measure.
> If the default is not usable, then it should not be the default. If it's 
> usable, then we don't need a warning.
>
> Having a warning would make sense if it were a part of the plan to transition 
> towards making GPU arch a mandatory option. Is that the case here?
> Just a warning is not very useful, IMO. The users would need to specify the 
> GPU in order to silence it, so why not just require it.

There are still valid use cases for not providing GPU arch. For example, users 
would like to test syntax of a HIP program for which GPU arch does not matter, 
or users would like to get PCH file where GPU arch does not matter. Another 
example is cmake may test whether a compiler can compile HIP program without 
options. Make it a warning allows such uses cases.


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

https://reviews.llvm.org/D92363

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


[clang-tools-extra] c282b7d - [clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.

2020-12-03 Thread Adam Czachorowski via cfe-commits

Author: Adam Czachorowski
Date: 2020-12-03T20:25:38+01:00
New Revision: c282b7de5a5de8151a19228702867e2299f1d3fe

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

LOG: [clangd] AddUsing: Fix a crash on ElaboratedTypes without 
NestedNameSpecfiiers.

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

Added: 


Modified: 
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
clang-tools-extra/clangd/unittests/TweakTests.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp 
b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
index b00c2716005c7..d6a57efeeef13 100644
--- a/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ b/clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -274,6 +274,8 @@ bool AddUsing::prepare(const Selection &Inputs) {
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
   QualifierToRemove = E.getQualifierLoc();
+  if (!QualifierToRemove)
+return false;
 
   auto SpelledTokens =
   TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));

diff  --git a/clang-tools-extra/clangd/unittests/TweakTests.cpp 
b/clang-tools-extra/clangd/unittests/TweakTests.cpp
index eefc50d754e2a..07f061b3f2e39 100644
--- a/clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ b/clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2523,6 +2523,9 @@ class cc {
   // Do not offer code action on typo-corrections.
   EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
 
+  // NestedNameSpecifier, but no namespace.
+  EXPECT_UNAVAILABLE(Header + "class Foo {}; class F^oo foo;");
+
   // Check that we do not trigger in header files.
   FileName = "test.h";
   ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.



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


[PATCH] D92579: [clangd] AddUsing: Fix a crash on ElaboratedTypes without NestedNameSpecfiiers.

2020-12-03 Thread Adam Czachorowski via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGc282b7de5a5d: [clangd] AddUsing: Fix a crash on 
ElaboratedTypes without NestedNameSpecfiiers. (authored by adamcz).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92579

Files:
  clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
  clang-tools-extra/clangd/unittests/TweakTests.cpp


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2523,6 +2523,9 @@
   // Do not offer code action on typo-corrections.
   EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
 
+  // NestedNameSpecifier, but no namespace.
+  EXPECT_UNAVAILABLE(Header + "class Foo {}; class F^oo foo;");
+
   // Check that we do not trigger in header files.
   FileName = "test.h";
   ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -274,6 +274,8 @@
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
   QualifierToRemove = E.getQualifierLoc();
+  if (!QualifierToRemove)
+return false;
 
   auto SpelledTokens =
   TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));


Index: clang-tools-extra/clangd/unittests/TweakTests.cpp
===
--- clang-tools-extra/clangd/unittests/TweakTests.cpp
+++ clang-tools-extra/clangd/unittests/TweakTests.cpp
@@ -2523,6 +2523,9 @@
   // Do not offer code action on typo-corrections.
   EXPECT_UNAVAILABLE(Header + "/*error-ok*/c^c C;");
 
+  // NestedNameSpecifier, but no namespace.
+  EXPECT_UNAVAILABLE(Header + "class Foo {}; class F^oo foo;");
+
   // Check that we do not trigger in header files.
   FileName = "test.h";
   ExtraArgs.push_back("-xc++-header"); // .h file is treated a C by default.
Index: clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
===
--- clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
+++ clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
@@ -274,6 +274,8 @@
   } else if (auto *T = Node->ASTNode.get()) {
 if (auto E = T->getAs()) {
   QualifierToRemove = E.getQualifierLoc();
+  if (!QualifierToRemove)
+return false;
 
   auto SpelledTokens =
   TB.spelledForExpanded(TB.expandedTokens(E.getSourceRange()));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-03 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D87216#2431626 , @aeubanks wrote:

> In D87216#2431508 , @ychen wrote:
>
>> It is very unfortunate that we have to manage and translate between two sets 
>> of names (one pass name and one type name). This makes me wonder if we just 
>> keep the pass name as the return value of PassInfoMixin::name and get rid of 
>> class name everywhere. Right now I couldn't think of anything is blocking us 
>> from doing that. WDYT?  @asbirlea ?
>
> We'd have to move the names from PassRegistry.def to every pass class 
> definition which would be a lot of work but definitely feasible.

That's true. The issue of translation also happens for codegen using NPM where 
both target-dependent and target-independent passes need the translation. 
Looking at my prototype, there is a lot of boilerplate for that. I think the 
one-time cost of moving names around should be worthwhile.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87216

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay accepted this revision.
MyDeveloperDay added a comment.
This revision is now accepted and ready to land.

This LGTM, I'm not sure if others have any comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D92596: [FPEnv] Correct constrained metadata in fp16-ops-strict.c

2020-12-03 Thread Kevin P. Neal via Phabricator via cfe-commits
kpn created this revision.
kpn added reviewers: sepavloff, mibintc.
kpn added a project: clang.
kpn requested review of this revision.
Herald added a subscriber: cfe-commits.

This test shows we're in some cases not getting strictfp information from the 
AST. Correct that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92596

Files:
  clang/lib/CodeGen/CGExprScalar.cpp
  clang/test/CodeGen/fp16-ops-strictfp.c

Index: clang/test/CodeGen/fp16-ops-strictfp.c
===
--- clang/test/CodeGen/fp16-ops-strictfp.c
+++ clang/test/CodeGen/fp16-ops-strictfp.c
@@ -11,7 +11,6 @@
 //
 // Test that the constrained intrinsics are picking up the exception
 // metadata from the AST instead of the global default from the command line.
-// FIXME: All cases of "fpexcept.maytrap" in this test are wrong.
 
 #pragma float_control(except, on)
 
@@ -62,31 +61,31 @@
   // NOTNATIVE: store {{.*}} half {{.*}}, half*
   h1 = +h1;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half %{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half %{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half %{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half %{{.*}}, metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: store {{.*}} half {{.*}}, half*
   h1++;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half %{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half %{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half %{{.*}}, half 0xH3C00, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half %{{.*}}, metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: store {{.*}} half {{.*}}, half*
   ++h1;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half %{{.*}}, half 0xHBC00, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half %{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
+  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half %{{.*}}, half 0xHBC00, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half %{{.*}}, metadata !"fpexcept.strict")
+  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
+  // NOTNATIVE: call half @llvm.experimental.constrained.fptrunc.f16.f32(float %{{.*}}, metadata !"round.tonearest", metadata !"fpexcept.strict")
   // CHECK: store {{.*}} half {{.*}}, half*
   --h1;
 
-  // NATIVE-HALF: call half @llvm.experimental.constrained.fadd.f16(half %{{.*}}, half 0xHBC00, metadata !"round.tonearest", metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fpext.f32.f16(half %{{.*}}, metadata !"fpexcept.maytrap")
-  // NOTNATIVE: call float @llvm.experimental.constrained.fadd.f32(float %{{.*}}, float {{.*}}, metadata !"round

[PATCH] D92597: ARCMigrate: Initialize fields in EditEntry inline, NFC

2020-12-03 Thread Duncan P. N. Exon Smith via Phabricator via cfe-commits
dexonsmith created this revision.
dexonsmith added reviewers: jansvoboda11, JDevlieghere, akyrtzi.
Herald added a subscriber: ributzka.
dexonsmith requested review of this revision.
Herald added a project: clang.

Initialize the fields inline instead of having to manually write out a
default constructor.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92597

Files:
  clang/lib/ARCMigrate/ObjCMT.cpp


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -2034,12 +2034,10 @@
 
 namespace {
 struct EditEntry {
-  const FileEntry *File;
-  unsigned Offset;
-  unsigned RemoveLen;
+  const FileEntry *File = nullptr;
+  unsigned Offset = 0;
+  unsigned RemoveLen = 0;
   std::string Text;
-
-  EditEntry() : File(), Offset(), RemoveLen() {}
 };
 } // end anonymous namespace
 


Index: clang/lib/ARCMigrate/ObjCMT.cpp
===
--- clang/lib/ARCMigrate/ObjCMT.cpp
+++ clang/lib/ARCMigrate/ObjCMT.cpp
@@ -2034,12 +2034,10 @@
 
 namespace {
 struct EditEntry {
-  const FileEntry *File;
-  unsigned Offset;
-  unsigned RemoveLen;
+  const FileEntry *File = nullptr;
+  unsigned Offset = 0;
+  unsigned RemoveLen = 0;
   std::string Text;
-
-  EditEntry() : File(), Offset(), RemoveLen() {}
 };
 } // end anonymous namespace
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D92363: [HIP] Warn no --offload-arch option

2020-12-03 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D92363#2431812 , @yaxunl wrote:

> 



> There are still valid use cases for not providing GPU arch. For example, 
> users would like to test syntax of a HIP program for which GPU arch does not 
> matter, or users would like to get PCH file where GPU arch does not matter. 
> Another example is cmake may test whether a compiler can compile HIP program 
> without options. Make it a warning allows such uses cases.

Issuing no warning allows such use cases even better. :-)

Also, how do I silence that warning, if I'm compiling with -Werror? 
If we provide a knob to silence the warning, how would that be better than 
asking the user to specify a GPU arch? 
If we do ask users to specify GPU arch in order to silence the warning => we 
effectively make the GPU arch a mandatory option.

I believe that no warning or a mandatory GPU arch would be a more principled 
way. With the warning we effectively flag the default value as 'it's not a very 
useful default'. If it's not useful by default, then it should not be the 
default. If it is useful, there should be no warning.

In this case, I think making GPU arch mandatory would have a stronger case, as 
the default we use right now is indeed quite often wrong. However, we probably 
have existing users who have valid use cases that work without the explicitly 
specified GPU arch, so requiring the GPU arch would break them. That constrains 
us to the no-warning scenario in practice.

Introducing a warning would break existing users, too -- compiling with 
`-Werror` is not that uncommon. If we're willing to break users, we may as well 
break them by requiring a GPU arch.
I just don't see a compelling argument where adding a warning would provide a 
net benefit over no-warning or a mandatory-GPU-arch scenarios.


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

https://reviews.llvm.org/D92363

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-12-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius added inline comments.



Comment at: clang/lib/Format/Format.cpp:963
   LLVMStyle.SpacesInCStyleCastParentheses = false;
+  LLVMStyle.SpacesInLineComments = {/*Minimum=*/1, /*Maximum=*/-1u};
   LLVMStyle.SpaceAfterCStyleCast = false;

I don't know precisely the LLVM style but does it allow more than one space (as 
Maximum would suggest)?
Are there any tests covering that?
And what about other styles, no need to set min/max for them?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-12-03 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/Format.cpp:963
   LLVMStyle.SpacesInCStyleCastParentheses = false;
+  LLVMStyle.SpacesInLineComments = {/*Minimum=*/1, /*Maximum=*/-1u};
   LLVMStyle.SpaceAfterCStyleCast = false;

curdeius wrote:
> I don't know precisely the LLVM style but does it allow more than one space 
> (as Maximum would suggest)?
> Are there any tests covering that?
> And what about other styles, no need to set min/max for them?
The part with the LLVM Style from my test case did run exactly so without any 
modification, so yes it allows more than one space.

Since there was no option before (that I'm aware of) all other styles behaved 
exactly like that. I did not check the style guides if they say anything about 
that, I just preserved the old behavior when nothing is configured.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 309335.
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

rebase before making any further changes


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

https://reviews.llvm.org/D79773

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14104,6 +14104,7 @@
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
@@ -14115,6 +14116,7 @@
   CHECK_PARSE_BOOL(IndentCaseLabels);
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
+  CHECK_PARSE_BOOL(IndentRequires);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
@@ -17288,6 +17290,277 @@
"}",
Style);
 }
+
+TEST_F(FormatTest, ConceptsAndRequires) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+
+  verifyFormat("template \n"
+   "requires Iterator\n"
+   "void sort(It begin, It end) {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "concept Large = sizeof(T) > 10;",
+   Style);
+
+  verifyFormat("template \n"
+   "concept FooableWith = requires(T t, U u) {\n"
+   "  typename T::foo_type;\n"
+   "  { t.foo(u) } -> typename T::foo_type;\n"
+   "  t++;\n"
+   "};\n"
+   "void doFoo(FooableWith auto t) {\n"
+   "  t.foo(3);\n"
+   "}",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = sizeof(T) == 1;",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = is_specialization_of_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Node = std::is_object_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Tree = true;",
+   Style);
+
+  verifyFormat("template  int g(T i) requires Concept1 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 || "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 && "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "requires Foo() && Bar {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   

[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-03 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder created this revision.
tmroeder added reviewers: aaron.ballman, klimek.
Herald added subscribers: teemperor, martong.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
tmroeder requested review of this revision.
Herald added a project: clang.

This allows ASTs to be merged when they contain GenericSelectionExpr
nodes (this is _Generic from C11). This is needed, for example, for
cross-CTU analysis of C code that makes use of _Generic, like the Linux
kernel.

The node is already supported in the AST, but it didn't have a matcher
in ASTMatchers. So, this change adds the matcher and adds support to
ASTImporter.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92600

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
  clang/test/ASTMerge/generic-selection-expr/test.c
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -985,6 +985,11 @@
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
 
+TEST_P(ASTMatchersTest, GenericSelectionExpr) {
+  EXPECT_TRUE(matches("void f() { (void)_Generic(1, int: 1, float: 2.0); }",
+  genericSelectionExpr()));
+}
+
 TEST_P(ASTMatchersTest, AtomicExpr) {
   EXPECT_TRUE(matches("void foo() { int *ptr; __atomic_load_n(ptr, 1); }",
   atomicExpr()));
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -279,6 +279,15 @@
  functionDecl(hasDescendant(gnuNullExpr(hasType(isInteger());
 }
 
+TEST_P(ImportExpr, ImportGenericSelectionExpr) {
+  MatchVerifier Verifier;
+
+  testImport(
+  "void declToImport() { int x; (void)_Generic(x, int: 0, float: 1); }",
+  Lang_C99, "", Lang_C99, Verifier,
+  functionDecl(hasDescendant(genericSelectionExpr(;
+}
+
 TEST_P(ImportExpr, ImportCXXNullPtrLiteralExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1088,6 +1097,36 @@
 ToChooseExpr->isConditionDependent());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportGenericSelectionExpr) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"(
+  int declToImport() {
+int x;
+return _Generic(x, int: 0, default: 1);
+  }
+  )",
+  Lang_C99, "", Lang_C99);
+
+  auto ToResults =
+  match(genericSelectionExpr().bind("expr"), To->getASTContext());
+  auto FromResults =
+  match(genericSelectionExpr().bind("expr"), From->getASTContext());
+
+  const GenericSelectionExpr *FromGenericSelectionExpr =
+  selectFirst("expr", FromResults);
+  ASSERT_TRUE(FromGenericSelectionExpr);
+
+  const GenericSelectionExpr *ToGenericSelectionExpr =
+  selectFirst("expr", ToResults);
+  ASSERT_TRUE(ToGenericSelectionExpr);
+
+  EXPECT_EQ(FromGenericSelectionExpr->isResultDependent(),
+ToGenericSelectionExpr->isResultDependent());
+  EXPECT_EQ(FromGenericSelectionExpr->getResultIndex(),
+ToGenericSelectionExpr->getResultIndex());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/generic-selection-expr/test.c
===
--- /dev/null
+++ clang/test/ASTMerge/generic-selection-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/generic.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
===
--- /dev/null
+++ clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
@@ -0,0 +1,7 @@
+void f() {
+  int x;
+  float y;
+  _Static_assert(_Generic(x, float: 0, int: 1), "Incorrect semantics of _Generic");
+  _Static_assert(_Generic(y, float: 1, int: 0), "Incorrect semantics of _Generic");
+}
+
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -95,10 +95,6 @@
   return Node.isPotentiallyEvaluated();
 }
 
-const ast_matchers::internal::VariadicDynCastAllOfMatcher
-genericSelectionExpr;
-
 AST_MATCHER_P(GenericSelectionExpr, hasControllingExpr,
   ast_matcher

[PATCH] D87216: [NewPM] Support --print-before/after in NPM

2020-12-03 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 309338.
aeubanks added a comment.

forward declare class


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D87216

Files:
  llvm/include/llvm/IR/IRPrintingPasses.h
  llvm/include/llvm/IR/PassInstrumentation.h
  llvm/include/llvm/IR/PrintPasses.h
  llvm/include/llvm/Passes/StandardInstrumentations.h
  llvm/lib/Analysis/CallGraphSCCPass.cpp
  llvm/lib/Analysis/LoopInfo.cpp
  llvm/lib/Analysis/LoopPass.cpp
  llvm/lib/CodeGen/MachineFunctionPrinterPass.cpp
  llvm/lib/IR/CMakeLists.txt
  llvm/lib/IR/IRPrintingPasses.cpp
  llvm/lib/IR/LegacyPassManager.cpp
  llvm/lib/IR/PassInstrumentation.cpp
  llvm/lib/IR/PrintPasses.cpp
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/StandardInstrumentations.cpp
  llvm/test/CodeGen/Generic/print-after.ll
  llvm/test/Other/loop-pass-printer.ll
  llvm/test/Other/print-before-after.ll
  llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn

Index: llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
===
--- llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
+++ llvm/utils/gn/secondary/llvm/lib/IR/BUILD.gn
@@ -59,6 +59,7 @@
 "PassManager.cpp",
 "PassRegistry.cpp",
 "PassTimingInfo.cpp",
+"PrintPasses.cpp",
 "ProfileSummary.cpp",
 "SafepointIRVerifier.cpp",
 "Statepoint.cpp",
Index: llvm/test/Other/print-before-after.ll
===
--- /dev/null
+++ llvm/test/Other/print-before-after.ll
@@ -0,0 +1,33 @@
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-before=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: not --crash opt < %s -disable-output -passes='no-op-module' -print-after=bleh 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=NONE --allow-empty
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-module 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-before=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-function' -print-after=no-op-function 2>&1 | FileCheck %s --check-prefix=ONCE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-before=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+; RUN: opt < %s -disable-output -passes='no-op-module,no-op-function' -print-after=no-op-function --print-module-scope 2>&1 | FileCheck %s --check-prefix=TWICE
+
+; NONE-NOT: @foo
+; NONE-NOT: @bar
+
+; ONCE: @foo
+; ONCE: @bar
+; ONCE-NOT: @foo
+; ONCE-NOT: @bar
+
+; TWICE: @foo
+; TWICE: @bar
+; TWICE: @foo
+; TWICE: @bar
+; TWICE-NOT: @foo
+; TWICE-NOT: @bar
+
+define void @foo() {
+  ret void
+}
+
+define void @bar() {
+  ret void
+}
Index: llvm/test/Other/loop-pass-printer.ll
===
--- llvm/test/Other/loop-pass-printer.ll
+++ llvm/test/Other/loop-pass-printer.ll
@@ -1,23 +1,23 @@
 ; This test checks -print-after/before on loop passes
 ; Besides of the loop itself it should be dumping loop pre-header and exits.
 ;
-; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
+; RUN: opt < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-deletion -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='loop(loop-deletion)' -print-before-all \
+; RUN: 	   -passes='loop(loop-deletion)' -print-before=loop-deletion \
 ; RUN:	   | FileCheck %s -check-prefix=DEL
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR -check-prefix=BAR-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=bar \
+; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after=loop-unroll-full -filter-print-funcs=bar \
 ; RUN:	   | FileCheck %s -check-prefix=BAR
 ; RUN: opt -enable-new-pm=0 < %s 2>&1 -disable-output \
 ; RUN: 	   -loop-unroll -print-after=loop-unroll -filter-print-funcs=foo -print-module-scope \
 ; RUN:	   | FileCheck %s -check-prefix=FOO-MODULE -check-prefix=FOO-MODULE-OLD
 ; RUN: opt < %s 2>&1 -disable-output \
-; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after-all -filter-print-funcs=foo -print-module-scope \
+; RUN: 	   -passes='require,loop(loop-unroll-full)' -print-after=

[PATCH] D92257: [clang-format] Add option to control the space at the front of a line comment

2020-12-03 Thread Marek Kurdej via Phabricator via cfe-commits
curdeius accepted this revision.
curdeius added a comment.

LGTM




Comment at: clang/lib/Format/Format.cpp:963
   LLVMStyle.SpacesInCStyleCastParentheses = false;
+  LLVMStyle.SpacesInLineComments = {/*Minimum=*/1, /*Maximum=*/-1u};
   LLVMStyle.SpaceAfterCStyleCast = false;

HazardyKnusperkeks wrote:
> curdeius wrote:
> > I don't know precisely the LLVM style but does it allow more than one space 
> > (as Maximum would suggest)?
> > Are there any tests covering that?
> > And what about other styles, no need to set min/max for them?
> The part with the LLVM Style from my test case did run exactly so without any 
> modification, so yes it allows more than one space.
> 
> Since there was no option before (that I'm aware of) all other styles behaved 
> exactly like that. I did not check the style guides if they say anything 
> about that, I just preserved the old behavior when nothing is configured.
Ok. Great


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92257

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


[PATCH] D91949: [clang-format] Add BeforeStructInitialization option in BraceWrapping configuration

2020-12-03 Thread Anastasiia Lukianenko via Phabricator via cfe-commits
anastasiia_lukianenko updated this revision to Diff 309336.
anastasiia_lukianenko retitled this revision from "[clang-format] Add 
BreakBeforeStructInitialization configuration" to "[clang-format] Add 
BeforeStructInitialization option in BraceWrapping configuration".
anastasiia_lukianenko added reviewers: djasper, klimek, alexfh, mprobst.
anastasiia_lukianenko added a comment.

1. Configuration became BraceWrapping option
2. Added CHECK_PARSE_NESTED_BOOL test
3. Fixed bugs with unwanted formatting




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

https://reviews.llvm.org/D91949

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/ContinuationIndenter.cpp
  clang/lib/Format/Format.cpp
  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
@@ -5046,6 +5046,25 @@
 format(Input, Style));
 }
 
+TEST_F(FormatTest, BreakBeforeStructInitialization) {
+  FormatStyle Style = getLLVMStyle();
+  Style.ColumnLimit = 80;
+  Style.BreakBeforeBraces = FormatStyle::BS_Custom;
+  Style.BraceWrapping.BeforeStructInitialization = true;
+  verifyFormat("struct new_struct struct_name =\n"
+   "{\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+  Style.BraceWrapping.BeforeStructInitialization = false;
+  verifyFormat("struct new_struct struct_name = {\n"
+   "a = 1,\n"
+   "b = 2,\n"
+   "};",
+   Style);
+}
+
 TEST_F(FormatTest, BreakConstructorInitializersAfterColon) {
   FormatStyle Style = getLLVMStyle();
   Style.BreakConstructorInitializers = FormatStyle::BCIS_AfterColon;
@@ -14154,6 +14173,7 @@
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeCatch);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeElse);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeLambdaBody);
+  CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeStructInitialization);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, BeforeWhile);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, IndentBraces);
   CHECK_PARSE_NESTED_BOOL(BraceWrapping, SplitEmptyFunction);
Index: clang/lib/Format/TokenAnnotator.cpp
===
--- clang/lib/Format/TokenAnnotator.cpp
+++ clang/lib/Format/TokenAnnotator.cpp
@@ -3489,6 +3489,10 @@
 bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
  const FormatToken &Right) {
   const FormatToken &Left = *Right.Previous;
+  if (Style.BraceWrapping.BeforeStructInitialization &&
+  Line.First->is(tok::kw_struct) && Right.is(tok::l_brace) &&
+  (Right.is(BK_BracedInit) || Left.is(tok::equal)))
+return true;
   if (Right.NewlinesBefore > 1 && Style.MaxEmptyLinesToKeep > 0)
 return true;
 
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -657,6 +657,8 @@
 IO.mapOptional("BeforeCatch", Wrapping.BeforeCatch);
 IO.mapOptional("BeforeElse", Wrapping.BeforeElse);
 IO.mapOptional("BeforeLambdaBody", Wrapping.BeforeLambdaBody);
+IO.mapOptional("BeforeStructInitialization",
+   Wrapping.BeforeStructInitialization);
 IO.mapOptional("BeforeWhile", Wrapping.BeforeWhile);
 IO.mapOptional("IndentBraces", Wrapping.IndentBraces);
 IO.mapOptional("SplitEmptyFunction", Wrapping.SplitEmptyFunction);
@@ -754,6 +756,7 @@
 /*BeforeCatch=*/false,
 /*BeforeElse=*/false,
 /*BeforeLambdaBody=*/false,
+/*BeforeStructInitialization=*/false,
 /*BeforeWhile=*/false,
 /*IndentBraces=*/false,
 /*SplitEmptyFunction=*/true,
@@ -887,6 +890,7 @@
  /*BeforeCatch=*/false,
  /*BeforeElse=*/false,
  /*BeforeLambdaBody=*/false,
+ /*BeforeStructInitialization=*/false,
  /*BeforeWhile=*/false,
  /*IndentBraces=*/false,
  /*SplitEmptyFunction=*/true,
Index: clang/lib/Format/ContinuationIndenter.cpp
===
--- clang/lib/Format/ContinuationIndenter.cpp
+++ clang/lib/Format/ContinuationIndenter.cpp
@@ -972,8 +972,10 @@
   const FormatToken &Previous = *Current.Previous;
   // If we are continuing an expression, we want to use the continuation indent.
   unsigned ContinuationIndent =
-  std::max(State.Stack.back().LastSpace, State.Stack.back().Indent

[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-12-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert updated this revision to Diff 309340.
jdoerfert marked 4 inline comments as done.
jdoerfert added a comment.

Addressed comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

Files:
  clang/include/clang/Basic/DiagnosticParseKinds.td
  clang/include/clang/Parse/Parser.h
  clang/include/clang/Sema/Sema.h
  clang/lib/Parse/ParseOpenMP.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaLambda.cpp
  clang/lib/Sema/SemaOpenMP.cpp
  clang/test/OpenMP/assumes_codegen.cpp
  clang/test/OpenMP/assumes_include_nvptx.cpp
  clang/test/OpenMP/assumes_messages.c
  clang/test/OpenMP/assumes_print.cpp
  clang/test/OpenMP/assumes_template_print.cpp
  llvm/include/llvm/Frontend/OpenMP/OMP.td
  llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def

Index: llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
===
--- llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
+++ llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
@@ -1224,3 +1224,27 @@
 #undef __OMP_REQUIRES_TRAIT
 #undef OMP_REQUIRES_TRAIT
 ///}
+
+
+/// Assumption clauses
+///
+///{
+
+#ifdef OMP_ASSUME_CLAUSE
+#define __OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression) \
+OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList, HasExpression)
+#else
+#define __OMP_ASSUME_CLAUSE(...)
+#endif
+
+__OMP_ASSUME_CLAUSE("ext_", true, false, false)
+__OMP_ASSUME_CLAUSE("absent", false, true, false)
+__OMP_ASSUME_CLAUSE("contains", false, true, false)
+__OMP_ASSUME_CLAUSE("holds", false, false, true)
+__OMP_ASSUME_CLAUSE("no_openmp", false, false, false)
+__OMP_ASSUME_CLAUSE("no_openmp_routines", false, false, false)
+__OMP_ASSUME_CLAUSE("no_parallelism", false, false, false)
+
+#undef __OMP_ASSUME_CLAUSE
+#undef OMP_ASSUME_CLAUSE
+///}
Index: llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
===
--- llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
+++ llvm/include/llvm/Frontend/OpenMP/OMPConstants.h
@@ -16,6 +16,7 @@
 
 #include "llvm/ADT/BitmaskEnum.h"
 
+#include "llvm/ADT/StringRef.h"
 #include "llvm/Frontend/OpenMP/OMP.h.inc"
 
 namespace llvm {
@@ -79,6 +80,33 @@
 #define OMP_IDENT_FLAG(Enum, ...) constexpr auto Enum = omp::IdentFlag::Enum;
 #include "llvm/Frontend/OpenMP/OMPKinds.def"
 
+/// Helper to describe assume clauses.
+struct AssumptionClauseMappingInfo {
+  /// The identifier describing the (beginning of the) clause.
+  llvm::StringLiteral Identifier;
+  /// Flag to determine if the identifier is a full name or the start of a name.
+  bool StartsWith;
+  /// Flag to determine if a directive lists follows.
+  bool HasDirectiveList;
+  /// Flag to determine if an expression follows.
+  bool HasExpression;
+};
+
+/// All known assume clauses.
+static constexpr AssumptionClauseMappingInfo AssumptionClauseMappings[] = {
+#define OMP_ASSUME_CLAUSE(Identifier, StartsWith, HasDirectiveList,\
+  HasExpression)   \
+  {Identifier, StartsWith, HasDirectiveList, HasExpression},
+#include "llvm/Frontend/OpenMP/OMPKinds.def"
+};
+
+inline std::string getAllAssumeClauseOptions() {
+  std::string S;
+  for (const AssumptionClauseMappingInfo &ACMI : AssumptionClauseMappings)
+S += (S.empty() ? "'" : "', '") + ACMI.Identifier.str();
+  return S + "'";
+}
+
 } // end namespace omp
 
 } // end namespace llvm
Index: llvm/include/llvm/Frontend/OpenMP/OMP.td
===
--- llvm/include/llvm/Frontend/OpenMP/OMP.td
+++ llvm/include/llvm/Frontend/OpenMP/OMP.td
@@ -1590,6 +1590,9 @@
 VersionedClause
   ];
 }
+def OMP_Assumes : Directive<"assumes"> {}
+def OMP_BeginAssumes : Directive<"begin assumes"> {}
+def OMP_EndAssumes : Directive<"end assumes"> {}
 def OMP_BeginDeclareVariant : Directive<"begin declare variant"> {}
 def OMP_EndDeclareVariant : Directive<"end declare variant"> {}
 def OMP_ParallelWorkshare : Directive<"parallel workshare"> {
Index: clang/test/OpenMP/assumes_template_print.cpp
===
--- /dev/null
+++ clang/test/OpenMP/assumes_template_print.cpp
@@ -0,0 +1,91 @@
+// RUN: %clang_cc1 -verify -fopenmp -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+
+// RUN: %clang_cc1 -verify -fopenmp-simd -ast-print %s | FileCheck %s
+// RUN: %clang_cc1 -fopenmp-simd -x c++ -std=c++11 -emit-pch -o %t %s
+// RUN: %clang_cc1 -fopenmp-simd -std=c++11 -include-pch %t -fsyntax-only -verify %s -ast-print | FileCheck %s
+// expected-no-diagnostics
+
+// It is unclear if we want to annotate the template instantiations, e.g., S::foo, or not in the two
+// situ

[PATCH] D91980: [OpenMP] Add initial support for `omp [begin/end] assumes`

2020-12-03 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert added inline comments.



Comment at: clang/lib/Sema/SemaLambda.cpp:999-1002
+  // OpenMP lambdas might get assumumption attributes.
+  if (LangOpts.OpenMP)
+ActOnFinishedFunctionDefinitionInOpenMPAssumeScope(Method);
+

ABataev wrote:
> Are there any other function-like constructs that also should have markings? 
> Coroutines maybe? 
Hm, can we postpone coroutines for now?



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3203
+  auto *AA = AssumptionAttr::Create(Context, llvm::join(Assumptions, ","), 
Loc);
+  // Disable assumes in OpenMP simd mode.
+  if (DKind == llvm::omp::Directive::OMPD_begin_assumes) {

ABataev wrote:
> How this comment relates to the code?
Leftover.



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3207
+  } else {
+assert(DKind == llvm::omp::Directive::OMPD_assumes && "");
+OMPAssumeGlobal.push_back(AA);

ABataev wrote:
> Add a message in for the assertion
Good catch!



Comment at: clang/lib/Sema/SemaOpenMP.cpp:3217
+while (Ctx->getParent())
+  Ctx = Ctx->getParent();
+DeclContexts.push_back(Ctx);

ABataev wrote:
> Maybe, better to use `getLexicalParent`? `getParent` returns semantic parent, 
> while `getLexicalParent` - the lexical parent. Do you need to mark the 
> declarations in the lexical context or in the semantic context?
I go to the top, should not matter. I want all declarations so I start at the 
top most scope, then traverse everything. I go with lexical now.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91980

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


[PATCH] D92600: [ASTImporter] Add support for importing GenericSelectionExpr AST nodes.

2020-12-03 Thread Tom Roeder via Phabricator via cfe-commits
tmroeder updated this revision to Diff 309344.
tmroeder edited the summary of this revision.
tmroeder added a comment.

Fix a typo in the summary.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92600

Files:
  clang/docs/LibASTMatchersReference.html
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/lib/Analysis/ExprMutationAnalyzer.cpp
  clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
  clang/test/ASTMerge/generic-selection-expr/test.c
  clang/unittests/AST/ASTImporterTest.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp

Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -985,6 +985,11 @@
   EXPECT_TRUE(matches("int* i = __null;", gnuNullExpr()));
 }
 
+TEST_P(ASTMatchersTest, GenericSelectionExpr) {
+  EXPECT_TRUE(matches("void f() { (void)_Generic(1, int: 1, float: 2.0); }",
+  genericSelectionExpr()));
+}
+
 TEST_P(ASTMatchersTest, AtomicExpr) {
   EXPECT_TRUE(matches("void foo() { int *ptr; __atomic_load_n(ptr, 1); }",
   atomicExpr()));
Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -279,6 +279,15 @@
  functionDecl(hasDescendant(gnuNullExpr(hasType(isInteger());
 }
 
+TEST_P(ImportExpr, ImportGenericSelectionExpr) {
+  MatchVerifier Verifier;
+
+  testImport(
+  "void declToImport() { int x; (void)_Generic(x, int: 0, float: 1); }",
+  Lang_C99, "", Lang_C99, Verifier,
+  functionDecl(hasDescendant(genericSelectionExpr(;
+}
+
 TEST_P(ImportExpr, ImportCXXNullPtrLiteralExpr) {
   MatchVerifier Verifier;
   testImport(
@@ -1088,6 +1097,36 @@
 ToChooseExpr->isConditionDependent());
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, ImportGenericSelectionExpr) {
+  Decl *From, *To;
+  std::tie(From, To) = getImportedDecl(
+  R"(
+  int declToImport() {
+int x;
+return _Generic(x, int: 0, default: 1);
+  }
+  )",
+  Lang_C99, "", Lang_C99);
+
+  auto ToResults =
+  match(genericSelectionExpr().bind("expr"), To->getASTContext());
+  auto FromResults =
+  match(genericSelectionExpr().bind("expr"), From->getASTContext());
+
+  const GenericSelectionExpr *FromGenericSelectionExpr =
+  selectFirst("expr", FromResults);
+  ASSERT_TRUE(FromGenericSelectionExpr);
+
+  const GenericSelectionExpr *ToGenericSelectionExpr =
+  selectFirst("expr", ToResults);
+  ASSERT_TRUE(ToGenericSelectionExpr);
+
+  EXPECT_EQ(FromGenericSelectionExpr->isResultDependent(),
+ToGenericSelectionExpr->isResultDependent());
+  EXPECT_EQ(FromGenericSelectionExpr->getResultIndex(),
+ToGenericSelectionExpr->getResultIndex());
+}
+
 TEST_P(ASTImporterOptionSpecificTestBase,
ImportFunctionWithBackReferringParameter) {
   Decl *From, *To;
Index: clang/test/ASTMerge/generic-selection-expr/test.c
===
--- /dev/null
+++ clang/test/ASTMerge/generic-selection-expr/test.c
@@ -0,0 +1,4 @@
+// RUN: %clang_cc1 -std=c11 -emit-pch -o %t.ast %S/Inputs/generic.c
+// RUN: %clang_cc1 -std=c11 -ast-merge %t.ast -fsyntax-only -verify %s
+// expected-no-diagnostics
+
Index: clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
===
--- /dev/null
+++ clang/test/ASTMerge/generic-selection-expr/Inputs/generic.c
@@ -0,0 +1,7 @@
+void f() {
+  int x;
+  float y;
+  _Static_assert(_Generic(x, float: 0, int: 1), "Incorrect semantics of _Generic");
+  _Static_assert(_Generic(y, float: 1, int: 0), "Incorrect semantics of _Generic");
+}
+
Index: clang/lib/Analysis/ExprMutationAnalyzer.cpp
===
--- clang/lib/Analysis/ExprMutationAnalyzer.cpp
+++ clang/lib/Analysis/ExprMutationAnalyzer.cpp
@@ -95,10 +95,6 @@
   return Node.isPotentiallyEvaluated();
 }
 
-const ast_matchers::internal::VariadicDynCastAllOfMatcher
-genericSelectionExpr;
-
 AST_MATCHER_P(GenericSelectionExpr, hasControllingExpr,
   ast_matchers::internal::Matcher, InnerMatcher) {
   return InnerMatcher.matches(*Node.getControllingExpr(), Finder, Builder);
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -241,6 +241,7 @@
   REGISTER_MATCHER(functionProtoType);
   REGISTER_MATCHER(functionTemplateDecl);

[PATCH] D92602: [objc] diagnose protocol conformance in categories with direct members in their corresponding class interfaces

2020-12-03 Thread Alex Lorenz via Phabricator via cfe-commits
arphaman created this revision.
arphaman added reviewers: erik.pilkington, MadCoder.
Herald added subscribers: ributzka, jfb, jkorous.
arphaman requested review of this revision.
Herald added a project: clang.

Categories that add protocol conformances to classes with direct members should 
prohibit protocol conformances when the methods/properties that the protocol 
expects are actually declared as 'direct' in the class.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D92602

Files:
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaDeclObjC.cpp
  clang/test/SemaObjC/category-direct-members-protocol-conformance.m

Index: clang/test/SemaObjC/category-direct-members-protocol-conformance.m
===
--- /dev/null
+++ clang/test/SemaObjC/category-direct-members-protocol-conformance.m
@@ -0,0 +1,98 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s
+
+__attribute__((objc_root_class))
+@interface RootClass
+
+- (void)baseMethod;
+
+@end
+
+__attribute__((objc_direct_members))
+@interface I : RootClass
+
+- (void)direct; // expected-note {{direct member declared here}}
+
+@end
+
+@protocol P
+- (void)direct;
+@end
+
+@interface I (Cat1)  // expected-error {{category 'Cat1' cannot conform to protocol 'P' because of direct members declared in interface 'I'}}
+@end
+
+@protocol BaseP
+- (void)baseMethod;
+@end
+
+@interface I (CatBase)  // OK
+@end
+
+@protocol P2
+- (void)indirect;
+@end
+
+@interface I (Cat2)  // OK
+- (void)indirect;
+@end
+
+@protocol P3
+- (void)indirect3;
+@end
+
+@interface I (Cat3)  // OK
+@end
+
+@interface ExpDirect : RootClass
+
+- (void)direct __attribute__((objc_direct)); // expected-note {{direct member declared here}}
+
+- (void)directRecursive __attribute__((objc_direct)); // expected-note {{direct member declared here}}
+
+@end
+
+@interface ExpDirect (CatExpDirect)  // expected-error {{category 'CatExpDirect' cannot conform to protocol 'P' because of direct members declared in interface 'ExpDirect'}}
+@end
+
+@protocol PRecursive1
+- (void)directRecursive;
+@end
+
+@protocol PRecursiveTop 
+@end
+
+@interface ExpDirect ()  // expected-error {{class extension cannot conform to protocol 'PRecursive1' because of direct members declared in interface 'ExpDirect'}}
+@end
+
+
+@protocol PProp
+
+@property (nonatomic, readonly) I *name;
+
+@end
+
+__attribute__((objc_direct_members))
+@interface IProp1 : RootClass
+
+@property (nonatomic, readonly) I *name; // expected-note {{direct member declared here}}
+
+@end
+
+@interface IProp1 ()  // expected-error {{class extension cannot conform to protocol 'PProp' because of direct members declared in interface 'IProp1'}}
+@end
+
+
+@protocol PProp2
+
+@property (nonatomic, readonly, class) I *name;
+
+@end
+
+@interface IProp2 : RootClass
+
+@property (nonatomic, readonly, class, direct) I *name; // expected-note {{direct member declared here}}
+
+@end
+
+@interface IProp2 ()  // expected-error {{class extension cannot conform to protocol 'PProp2' because of direct members declared in interface 'IProp2'}}
+@end
Index: clang/lib/Sema/SemaDeclObjC.cpp
===
--- clang/lib/Sema/SemaDeclObjC.cpp
+++ clang/lib/Sema/SemaDeclObjC.cpp
@@ -3912,6 +3912,55 @@
   }
 }
 
+static void DiagnoseCategoryDirectMembersProtocolConformance(
+Sema &S, ObjCProtocolDecl *PDecl, ObjCCategoryDecl *CDecl);
+
+static void DiagnoseCategoryDirectMembersProtocolConformance(
+Sema &S, ObjCCategoryDecl *CDecl,
+const llvm::iterator_range &Protocols) {
+  for (auto *PI : Protocols)
+DiagnoseCategoryDirectMembersProtocolConformance(S, PI, CDecl);
+}
+
+static void DiagnoseCategoryDirectMembersProtocolConformance(
+Sema &S, ObjCProtocolDecl *PDecl, ObjCCategoryDecl *CDecl) {
+  if (!PDecl->isThisDeclarationADefinition() && PDecl->getDefinition())
+PDecl = PDecl->getDefinition();
+
+  llvm::SmallVector DirectMembers;
+  const auto *IDecl = CDecl->getClassInterface();
+  for (auto *MD : PDecl->methods()) {
+if (!MD->isPropertyAccessor()) {
+  if (const auto *CMD =
+  IDecl->getMethod(MD->getSelector(), MD->isInstanceMethod())) {
+if (CMD->isDirectMethod())
+  DirectMembers.push_back(CMD);
+  }
+}
+  }
+  for (auto *PD : PDecl->properties()) {
+if (const auto *CPD = IDecl->FindPropertyVisibleInPrimaryClass(
+PD->getIdentifier(),
+PD->isClassProperty()
+? ObjCPropertyQueryKind::OBJC_PR_query_class
+: ObjCPropertyQueryKind::OBJC_PR_query_instance)) {
+  if (CPD->isDirectProperty())
+DirectMembers.push_back(CPD);
+}
+  }
+  if (!DirectMembers.empty()) {
+S.Diag(CDecl->getLocation(), diag::err_objc_direct_protocol_conformance)
+<< CDecl->IsClassExtension() << CDecl << PDecl << IDecl;
+for (const auto *MD : DirectMembers)
+  S.Diag(MD->getLocation(), diag::note_direct_membe

[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:2314
+  nextToken();
+  if (FormatTok->Tok.is(tok::less)) {
+while (!FormatTok->Tok.is(tok::greater)) {

klimek wrote:
> MyDeveloperDay wrote:
> > miscco wrote:
> > > miscco wrote:
> > > > I guess you could use `parseBracedList(/*ContinueOnSemicolons=*/false, 
> > > > /*IsEnum=*/false,/*ClosingBraceKind=*/tok::greater);` here?
> > > To be more specific, I am concerned what happens if you have multiple 
> > > template arguments where a linebreak should occur. Is this still 
> > > happening here?
> > > 
> > > 
> > > ```
> > > template 
> > > concept someVeryLongConceptName = 
> > > someVeryLongConstraintName1;
> > > ```
> > This is formatted as
> > 
> > ```
> > template 
> > concept someVeryLongConceptName =
> > someVeryLongConstraintName1;
> > ```
> This seems like a very detailed way to parse them; generally, we try to only 
> parse rough structure here.
So whilst I tend to agree, and I've tried to write this loop to be less and it 
just didn't seem to catch the cases that had already been given in the unit 
tests,

This ended up being a lot likes its own parseStructuralElement, I think the 
difference here is that I've written it as a series of if's rather than a 
switch statement.

I feel I'd be happier to push the patch through then address individual 
specific cases



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

https://reviews.llvm.org/D79773

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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay updated this revision to Diff 309350.
MyDeveloperDay marked an inline comment as done.
MyDeveloperDay added a comment.

Address the issue with still munching the semi
mark as experimental in the release notes


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

https://reviews.llvm.org/D79773

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatToken.h
  clang/lib/Format/TokenAnnotator.cpp
  clang/lib/Format/UnwrappedLineParser.cpp
  clang/lib/Format/UnwrappedLineParser.h
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -14104,6 +14104,7 @@
   CHECK_PARSE_BOOL(BinPackArguments);
   CHECK_PARSE_BOOL(BinPackParameters);
   CHECK_PARSE_BOOL(BreakAfterJavaFieldAnnotations);
+  CHECK_PARSE_BOOL(BreakBeforeConceptDeclarations);
   CHECK_PARSE_BOOL(BreakBeforeTernaryOperators);
   CHECK_PARSE_BOOL(BreakStringLiterals);
   CHECK_PARSE_BOOL(CompactNamespaces);
@@ -14115,6 +14116,7 @@
   CHECK_PARSE_BOOL(IndentCaseLabels);
   CHECK_PARSE_BOOL(IndentCaseBlocks);
   CHECK_PARSE_BOOL(IndentGotoLabels);
+  CHECK_PARSE_BOOL(IndentRequires);
   CHECK_PARSE_BOOL(IndentWrappedFunctionNames);
   CHECK_PARSE_BOOL(KeepEmptyLinesAtTheStartOfBlocks);
   CHECK_PARSE_BOOL(ObjCSpaceAfterProperty);
@@ -17288,6 +17290,277 @@
"}",
Style);
 }
+
+TEST_F(FormatTest, ConceptsAndRequires) {
+  FormatStyle Style = getLLVMStyle();
+  Style.AllowShortFunctionsOnASingleLine = FormatStyle::SFS_None;
+
+  verifyFormat("template \n"
+   "concept Hashable = requires(T a) {\n"
+   "  { std::hash{}(a) } -> std::convertible_to;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+  verifyFormat("template \n"
+   "concept EqualityComparable = requires(T a, T b) {\n"
+   "  { a == b } -> bool;\n"
+   "  { a != b } -> bool;\n"
+   "};",
+   Style);
+
+  verifyFormat("template \n"
+   "requires Iterator\n"
+   "void sort(It begin, It end) {\n"
+   "  //\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "concept Large = sizeof(T) > 10;",
+   Style);
+
+  verifyFormat("template \n"
+   "concept FooableWith = requires(T t, U u) {\n"
+   "  typename T::foo_type;\n"
+   "  { t.foo(u) } -> typename T::foo_type;\n"
+   "  t++;\n"
+   "};\n"
+   "void doFoo(FooableWith auto t) {\n"
+   "  t.foo(3);\n"
+   "}",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = sizeof(T) == 1;",
+   Style);
+  verifyFormat("template \n"
+   "concept Context = is_specialization_of_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Node = std::is_object_v;",
+   Style);
+  verifyFormat("template \n"
+   "concept Tree = true;",
+   Style);
+
+  verifyFormat("template  int g(T i) requires Concept1 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template  int g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 || "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat("template \n"
+   "veryveryvery_long_return_type g(T i) requires Concept1 && "
+   "Concept2 {\n"
+   "  //...\n"
+   "}",
+   Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 && Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat(
+  "template \n"
+  "veryveryvery_long_return_type g(T i) requires Concept1 || Concept2 {\n"
+  "  //...\n"
+  "}",
+  Style);
+
+  verifyFormat("template \n"
+   "requires Foo() && Bar {\n"
+   "  //\n"
+   "}",
+   

[PATCH] D92597: ARCMigrate: Initialize fields in EditEntry inline, NFC

2020-12-03 Thread Jonas Devlieghere via Phabricator via cfe-commits
JDevlieghere added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92597

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


[PATCH] D79773: [clang-format] Improve clang-formats handling of concepts

2020-12-03 Thread MyDeveloperDay via Phabricator via cfe-commits
MyDeveloperDay added a comment.

Having reviewed the current status I'm going to leave this patch with just 
minor changes from where its been for some time, if others feel it has merits 
in landing as experimental support I'd be happy with that. I would rather build 
from a base than try and keep rebuilding the same tower.

The concepts support in clang-format is currently poor, actually, it's 
downright destructive, I've tried to cover the basic concept usage and I'm 
happy to support this feature against individual bug report where I can.


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

https://reviews.llvm.org/D79773

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


[PATCH] D92480: [llvm] Unify interface of (ThreadSafe)?RefCountedBase

2020-12-03 Thread David Blaikie via Phabricator via cfe-commits
dblaikie added inline comments.



Comment at: clang/lib/ASTMatchers/ASTMatchersInternal.cpp:190-196
+// Use a custom deleter for the TrueMatcherInstance ManagedStatic. This 
prevents
+// an assert firing when the refcount is nonzero while running its destructor.
+struct DynMatcherInterfaceDeleter {
+  static void call(void *Ptr) {
+static_cast(Ptr)->Release();
+  }
+};

I think probably the right solution is to have TrueMatcherImpl's dtor Release 
the same way its ctor Retains. Symmetry is nice/helps avoid splitting this 
quirk into two different places.



Comment at: llvm/include/llvm/ADT/IntrusiveRefCntPtr.h:75-80
+  // Copy and move constructors/assignments are no-ops as the RefCount isn't
+  // dictated by the class directly.
   RefCountedBase(const RefCountedBase &) {}
+  RefCountedBase(RefCountedBase &&) {}
+  RefCountedBase &operator=(const RefCountedBase &) { return *this; }
+  RefCountedBase &operator=(RefCountedBase &&) { return *this; }

dexonsmith wrote:
> dexonsmith wrote:
> > njames93 wrote:
> > > njames93 wrote:
> > > > dexonsmith wrote:
> > > > > dblaikie wrote:
> > > > > > I can't quite understand this comment - perhaps you could try 
> > > > > > rephrasing it?
> > > > > I'm not quite following why you needed to add these special members; 
> > > > > it seems like just the destructor would be enough for the assertion; 
> > > > > but if you do need them, can/should they be `= default`?
> > > > They can't be defaulted as we don't want to copy the RefCount.
> > > I understand it in my head, just can't think of the best way to write it 
> > > down.
> > Maybe something like this would work:
> > ```
> > /// Do not copy or move RefCount when constructing or assigning from
> > /// a derived type. These operations don't imply anything about the
> > /// number of IntrusiveRefCntPtr instances.
> > ```
> > WDYT?
> Ah, I get it, thanks for explaining.
Do we need them at all, though?

The code prior to this patch has a copy ctor that "does the right thing" by 
producing a ref count of 0 for the new copy (same as a newly constructed 
object). No move operations will be provided - nor probably should there be 
any, the copy semantics are cheap/correct & not sure there's a more optimized 
implementation for move.

The copy assignment operaotr currently is probably broken (the implicit copy 
assignment is deprecated in the presence of a user-declared copy ctor - so we 
could probably delete that rather than adding it if it's not used (& at least, 
currently if it is used it'd be pretty broken).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D92480

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


  1   2   >