[clang] 5c9013e - Use std::optional instead of llvm::Optional (NFC)

2023-01-28 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-28T00:45:19-08:00
New Revision: 5c9013e2664141d3b4071c37b3cbb8cd09a008d8

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

LOG: Use std::optional instead of llvm::Optional (NFC)

Added: 


Modified: 
clang/lib/Analysis/UnsafeBufferUsage.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
mlir/lib/Dialect/Index/IR/InferIntRangeInterfaceImpls.cpp
mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp

Removed: 




diff  --git a/clang/lib/Analysis/UnsafeBufferUsage.cpp 
b/clang/lib/Analysis/UnsafeBufferUsage.cpp
index 2f1417487967d..54e3fb17efe45 100644
--- a/clang/lib/Analysis/UnsafeBufferUsage.cpp
+++ b/clang/lib/Analysis/UnsafeBufferUsage.cpp
@@ -615,7 +615,7 @@ getFixIts(FixableGadgetSets &FixablesForUnsafeVars, const 
Strategy &S) {
 bool ImpossibleToFix = false;
 llvm::SmallVector FixItsForVD;
 for (const auto &F : Fixables) {
-  llvm::Optional Fixits = F->getFixits(S);
+  std::optional Fixits = F->getFixits(S);
   if (!Fixits) {
 ImpossibleToFix = true;
 break;

diff  --git a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h 
b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
index b40bcbf76ad06..bc089f141850a 100644
--- a/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
+++ b/clang/unittests/Analysis/FlowSensitive/TestingSupport.h
@@ -262,7 +262,7 @@ checkDataflow(AnalysisInputs AI,
 
 // If successful, the dataflow analysis returns a mapping from block IDs to
 // the post-analysis states for the CFG blocks that have been evaluated.
-
llvm::Expected>>
+llvm::Expected>>
 MaybeBlockStates = runTypeErasedDataflowAnalysis(
 CFCtx, Analysis, InitEnv, TypeErasedPostVisitCFG);
 if (!MaybeBlockStates) return MaybeBlockStates.takeError();

diff  --git a/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h 
b/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
index 7ee059cf342ce..97c97c23ba82a 100644
--- a/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
+++ b/mlir/include/mlir/Interfaces/Utils/InferIntRangeCommon.h
@@ -16,6 +16,7 @@
 
 #include "mlir/Interfaces/InferIntRangeInterface.h"
 #include "llvm/ADT/ArrayRef.h"
+#include 
 
 namespace mlir {
 namespace intrange {
@@ -117,8 +118,9 @@ enum class CmpPredicate : uint64_t {
 /// Returns a boolean value if `pred` is statically true or false for
 /// anypossible inputs falling within `lhs` and `rhs`, and std::nullopt if the
 /// value of the predicate cannot be determined.
-Optional evaluatePred(CmpPredicate pred, const ConstantIntRanges &lhs,
-const ConstantIntRanges &rhs);
+std::optional evaluatePred(CmpPredicate pred,
+ const ConstantIntRanges &lhs,
+ const ConstantIntRanges &rhs);
 
 } // namespace intrange
 } // namespace mlir

diff  --git a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp 
b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
index a80c024ceb248..08ea2cae4cd7c 100644
--- a/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
+++ b/mlir/lib/Conversion/GPUToNVVM/LowerGpuOpsToNVVMOps.cpp
@@ -33,6 +33,7 @@
 #include "../GPUCommon/GPUOpsLowering.h"
 #include "../GPUCommon/IndexIntrinsicsOpLowering.h"
 #include "../GPUCommon/OpToFuncCallLowering.h"
+#include 
 
 namespace mlir {
 #define GEN_PASS_DEF_CONVERTGPUOPSTONVVMOPS
@@ -58,7 +59,7 @@ static NVVM::ShflKind convertShflKind(gpu::ShuffleMode mode) {
   llvm_unreachable("unknown shuffle mode");
 }
 
-static Optional
+static std::optional
 convertReduxKind(gpu::AllReduceOperation mode) {
   switch (mode) {
   case gpu::AllReduceOperation::ADD:
@@ -95,7 +96,7 @@ struct GPUSubgroupReduceOpLowering
 if (!op.getValue().getType().isInteger(32))
   return rewriter.notifyMatchFailure(op, "unsupported data type");
 
-Optional mode = convertReduxKind(op.getOp());
+std::optional mode = convertReduxKind(op.getOp());
 if (!mode.has_value())
   return rewriter.notifyMatchFailure(
   op, "unsupported reduction mode for redux");

diff  --git a/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp 
b/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
index 971477fa94cb9..179d0883f691d 100644
--- a/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
+++ b/mlir/lib/Dialect/Arith/IR/InferIntRangeInterfaceImpls.cpp
@@ -269,7 +269,7 @@ void 
arith::CmpIOp::inferResultRanges(ArrayRef argRanges,
   APInt min = APInt::getZero(1);
   APInt max = APInt::getAllOnesValue(1);
 
-  Optional truth

[PATCH] D142800: [Clang][Diagnostic] Add `-Wcomparison-op-parentheses` to warn on chained comparisons

2023-01-28 Thread Takuya Shimizu via Phabricator via cfe-commits
hazohelet updated this revision to Diff 492986.
hazohelet added a comment.

Fix the new warning issued against libcxx test code.


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

https://reviews.llvm.org/D142800

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticGroups.td
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Sema/SemaExpr.cpp
  clang/test/Misc/warning-wall.c
  clang/test/Sema/comparison-op-parentheses.c
  libcxx/test/support/test_comparisons.h

Index: libcxx/test/support/test_comparisons.h
===
--- libcxx/test/support/test_comparisons.h
+++ libcxx/test/support/test_comparisons.h
@@ -162,7 +162,7 @@
 bool less= order == Order::less;
 bool greater = order == Order::greater;
 
-return (t1 <=> t2 == order) && testComparisonsComplete(t1, t2, equal, less, greater);
+return ((t1 <=> t2) == order) && testComparisonsComplete(t1, t2, equal, less, greater);
 }
 
 template 
Index: clang/test/Sema/comparison-op-parentheses.c
===
--- /dev/null
+++ clang/test/Sema/comparison-op-parentheses.c
@@ -0,0 +1,94 @@
+// RUN: %clang_cc1 -fsyntax-only -verify %s -DSILENCE
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wcomparison-op-parentheses
+// RUN: %clang_cc1 -fsyntax-only -verify %s -Wparentheses
+// RUN: %clang_cc1 -fsyntax-only -fdiagnostics-parseable-fixits %s -Wcomparison-op-parentheses 2>&1 | FileCheck %s
+
+#ifdef SILENCE
+// expected-no-diagnostics
+#endif
+
+void comparison_op_parentheses(int a, int b, int c) {
+  (void)(a ==
+ b > c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>' within '=='}}
+  // expected-note@-3 {{place parentheses around the '>' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
+
+  (void)(a ==b == c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'==' within '=='}}
+  // expected-note@-3 {{place parentheses around the '==' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"
+
+  (void)(a !=b == c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'!=' within '=='}}
+  // expected-note@-3 {{place parentheses around the '!=' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:15-[[@LINE-6]]:15}:")"
+
+  (void)(a !=
+ b < c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'<' within '!='}}
+  // expected-note@-3 {{place parentheses around the '<' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:14-[[@LINE-5]]:14}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:19-[[@LINE-6]]:19}:")"
+
+  (void)(a>=b >= c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>=' within '>='}}
+  // expected-note@-3 {{place parentheses around the '>=' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:14-[[@LINE-6]]:14}:")"
+
+  (void)(a >b >= c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>' within '>='}}
+  // expected-note@-3 {{place parentheses around the '>' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:14-[[@LINE-6]]:14}:")"
+
+  (void)(a >b > c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'>' within '>'}}
+  // expected-note@-3 {{place parentheses around the '>' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:14-[[@LINE-6]]:14}:")"
+
+
+
+  (void)(a c);
+#ifndef SILENCE
+  // expected-warning@-2 {{'<' within '>'}}
+  // expected-note@-3 {{place parentheses around the '<' expression to silence this warning}}
+#endif
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-5]]:10-[[@LINE-5]]:10}:"("
+  // CHECK: fix-it:"{{.*}}":{[[@LINE-6]]:13-[[@LINE-6]]:13}:")"
+
+  (void)(a != (b > c));
+  (void)(a == (b > c));
+  (void)((a>b) >= c);
+  (void)((a c);
+  (void)(a != b && a > c);
+  (void)((a c);
+}
Index: clang/test/Misc/warning-wall.c
===
--- clang/test/Misc/warning-wall.c
+++ clang/test/Misc/warning-wall.c
@@ -92,6 +92,7 @@
 CHECK-NEXT:-Wlogical-not-parentheses
 CHECK-NEXT:-Wbitwise-conditional-parentheses
 CHECK-NEXT:-Wbitwise-op-parentheses
+CHECK-NEXT:-Wcomparison-op-parentheses
 CHECK-NEXT:-Wshift-op-parentheses
 CHECK-NEXT:-Woverloaded-shift-op-parentheses
 CHECK-NEXT:-Wparentheses-equality
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExp

[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2023-01-28 Thread Hantao Pan via Phabricator via cfe-commits
HantaoPan added a comment.

In D14484#4087827 , @owenpan wrote:

> In D14484#4079711 , @HantaoPan wrote:
>
>> Hi,
>> I am interesting in this feature too. You know, consistency is crucial to a 
>> large program...
>>
>> regards,
>
> As mentioned above, it has been added in D108752 
> . See also 
> https://clang.llvm.org/docs/ClangFormatStyleOptions.html#packconstructorinitializers.

Thank you! Is there a similar flag with respect to function parameter?


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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


[PATCH] D14484: [clang-format] Formatting constructor initializer lists by putting them always on different lines

2023-01-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added a comment.

In D14484#4087879 , @HantaoPan wrote:

> Thank you! Is there a similar flag wrt function parameter? (say a "Never" 
> other than "false", which can always put each function parameter on its own 
> line.)

Nope.


Repository:
  rL LLVM

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

https://reviews.llvm.org/D14484

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


[PATCH] D142804: [clang-format] Support clang-format on/off line comments as prefixes

2023-01-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan created this revision.
owenpan added reviewers: MyDeveloperDay, HazardyKnusperkeks, rymiel.
owenpan added a project: clang-format.
Herald added a project: All.
owenpan requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Closes https://github.com/llvm/llvm-project/issues/60264.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142804

Files:
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22619,6 +22619,28 @@
"/* clang-format off */\n"
"/* long long long long long long line */\n",
getLLVMStyleWithColumns(20)));
+
+  verifyFormat("int *i;\n"
+   "// clang-format off 0\n"
+   "int* j;\n"
+   "// clang-format on 1\n"
+   "int *k;",
+   "int* i;\n"
+   "// clang-format off 0\n"
+   "int* j;\n"
+   "// clang-format on 1\n"
+   "int* k;");
+
+  verifyFormat("int *i;\n"
+   "// clang-format off\t0\n"
+   "int* j;\n"
+   "// clang-format on1\n"
+   "int* k;",
+   "int* i;\n"
+   "// clang-format off\t0\n"
+   "int* j;\n"
+   "// clang-format on1\n"
+   "int* k;");
 }
 
 TEST_F(FormatTest, DoNotCrashOnInvalidInput) {
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -195,8 +195,7 @@
 // Separate references from the main code body of the file.
 if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2 &&
 !(FirstNonImportLine->First->is(tok::comment) &&
-  FirstNonImportLine->First->TokenText.trim() ==
-  "// clang-format on")) {
+  isClangFormatOn(FirstNonImportLine->First->TokenText.trim( {
   ReferencesText += "\n";
 }
 
@@ -376,9 +375,9 @@
   // This is tracked in FormattingOff here and on JsModuleReference.
   while (Current && Current->is(tok::comment)) {
 StringRef CommentText = Current->TokenText.trim();
-if (CommentText == "// clang-format off") {
+if (isClangFormatOff(CommentText)) {
   FormattingOff = true;
-} else if (CommentText == "// clang-format on") {
+} else if (isClangFormatOn(CommentText)) {
   FormattingOff = false;
   // Special case: consider a trailing "clang-format on" line to be part
   // of the module reference, so that it gets moved around together with
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -87,9 +87,9 @@
 auto Location = Tok.getLocation();
 auto Text = StringRef(SourceMgr.getCharacterData(Location), Length);
 if (Tok.is(tok::comment)) {
-  if (Text == "// clang-format off" || Text == "/* clang-format off */")
+  if (isClangFormatOff(Text))
 Skip = true;
-  else if (Text == "// clang-format on" || Text == "/* clang-format on */")
+  else if (isClangFormatOn(Text))
 Skip = false;
   continue;
 }
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -1286,17 +1286,13 @@
 Tok.Tok.setKind(tok::string_literal);
   }
 
-  if (Tok.is(tok::comment) && (Tok.TokenText == "// clang-format on" ||
-   Tok.TokenText == "/* clang-format on */")) {
+  if (Tok.is(tok::comment) && isClangFormatOn(Tok.TokenText))
 FormattingDisabled = false;
-  }
 
   Tok.Finalized = FormattingDisabled;
 
-  if (Tok.is(tok::comment) && (Tok.TokenText == "// clang-format off" ||
-   Tok.TokenText == "/* clang-format off */")) {
+  if (Tok.is(tok::comment) && isClangFormatOff(Tok.TokenText))
 FormattingDisabled = true;
-  }
 }
 
 void FormatTokenLexer::resetLexer(unsigned Offset) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3002,13 +3002,10 @@
 if (Trimmed.contains(RawStringTermination))
   FormattingOff = false;
 
-if (Trimmed == "// clang-format off" ||
-Trimmed == "/* clang

[PATCH] D142804: [clang-format] Support clang-format on/off line comments as prefixes

2023-01-28 Thread Emilia Dreamer via Phabricator via cfe-commits
rymiel added inline comments.



Comment at: clang/lib/Format/Format.cpp:3901
+  return Comment.startswith(Prefix) &&
+ (Comment.size() == Size || isblank(Comment[Size]));
+}

Should the space be required? What about `// clang-format off: reasoning` or 
similar?

Also, should this be documented?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142804

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


[PATCH] D142016: [Clang][RISCV] Simplify RVV intrinsic policy suffix

2023-01-28 Thread Yueh-Ting (eop) Chen 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 rGd94a315ee3ec: [Clang][RISCV] Simplify RVV intrinsic policy 
suffix (authored by eopXD).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142016

Files:
  clang/include/clang/Support/RISCVVIntrinsicUtils.h
  clang/lib/Sema/SemaRISCVVectorLookup.cpp
  clang/lib/Support/RISCVVIntrinsicUtils.cpp
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vaaddu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vadc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vand.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vasubu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vcompress.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vdivu.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfabs.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfclass.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmerge.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfmv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfncvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfneg.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfnmsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrdiv.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrec7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredmax.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredmin.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredosum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfredusum.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrsqrt7.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfrsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsgnj.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsgnjn.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsgnjx.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfslide1down.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfslide1up.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsqrt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfsub.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwadd.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwcvt.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmacc.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmsac.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/policy/non-overloaded/vfwmul.c
  
clang/test/CodeGen/RISCV/rvv-intrinsics-autogenerated/pol

[PATCH] D134351: AArch64: add definitions for recent Apple CPUs

2023-01-28 Thread Valerii Zapodovnikov via Phabricator via cfe-commits
ValZapod added a comment.

What do you mean by we do not have SM4? Apple CPU or clang?


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

https://reviews.llvm.org/D134351

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


[PATCH] D142804: [clang-format] Support clang-format on/off line comments as prefixes

2023-01-28 Thread Björn Schäpers via Phabricator via cfe-commits
HazardyKnusperkeks added inline comments.



Comment at: clang/lib/Format/Format.cpp:3901
+  return Comment.startswith(Prefix) &&
+ (Comment.size() == Size || isblank(Comment[Size]));
+}

rymiel wrote:
> Should the space be required? What about `// clang-format off: reasoning` or 
> similar?
> 
> Also, should this be documented?
> Should the space be required? What about `// clang-format off: reasoning` or 
> similar?
> 
> Also, should this be documented?

+1


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142804

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


[PATCH] D136886: [clang] ASTImporter: Fix importing of va_list types and declarations

2023-01-28 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers added a comment.

@mizvekov, will you be picking this change up and finishing this, or do you 
mind if I have a go at finishing this patch? Thanks


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D136886

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


[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:452-454
+
 - Now diagnoses use of a member access expression or array subscript expression
   within ``__builtin_offsetof`` and ``offsetof`` as being a Clang extension.

aaron.ballman wrote:
> Assuming https://github.com/llvm/llvm-project/issues/60337 gets ported to the 
> 16.0 branch, this bullet can be removed entirely.
and that did land in 84f3164c1d9ce024f59221dcfbc8ab050de73748


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-28 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

I am not the only who has a different background. If the introduction says this 
is the introduction of the release notes, I am not super motivated to read on. 
I would prefer to see some highlights to motivate the readers to continue 
reading.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[PATCH] D142609: [Clang] Fix -Wconstant-logical-operand when LHS is a constant

2023-01-28 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta updated this revision to Diff 492995.
xgupta added a comment.

update test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142609

Files:
  clang/lib/Sema/SemaExpr.cpp
  clang/test/C/drs/dr4xx.c
  clang/test/CXX/dcl.dcl/dcl.spec/dcl.constexpr/p5.cpp
  clang/test/Parser/cxx2a-concept-declaration.cpp
  clang/test/Sema/exprs.c
  clang/test/SemaCXX/expressions.cpp
  clang/test/SemaCXX/warn-unsequenced.cpp
  clang/test/SemaTemplate/dependent-expr.cpp

Index: clang/test/SemaTemplate/dependent-expr.cpp
===
--- clang/test/SemaTemplate/dependent-expr.cpp
+++ clang/test/SemaTemplate/dependent-expr.cpp
@@ -43,7 +43,9 @@
 
 namespace PR7724 {
   template int myMethod()
-  { return 2 && sizeof(OT); }
+  { return 2 && sizeof(OT); } // expected-warning {{use of logical '&&' with constant operand}} \
+  // expected-note {{use '&' for a bitwise operation}} \
+  // expected-note {{remove constant to silence this warning}}
 }
 
 namespace test4 {
Index: clang/test/SemaCXX/warn-unsequenced.cpp
===
--- clang/test/SemaCXX/warn-unsequenced.cpp
+++ clang/test/SemaCXX/warn-unsequenced.cpp
@@ -76,15 +76,37 @@
 
   (xs[2] && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (0 && (a = 0)) + a; // ok
+
+  (0 && (a = 0)) + a; // cxx11-warning {{use of logical '&&' with constant operand}}
+  // cxx11-note@-1 {{use '&' for a bitwise operation}}
+  // cxx11-note@-2 {{remove constant to silence this warning}}
+  // cxx17-warning@-3 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-4 {{use '&' for a bitwise operation}}
+  // cxx17-note@-5 {{remove constant to silence this warning}}
+
   (1 && (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
+  // cxx11-warning@-2 {{use of logical '&&' with constant operand}}
+  // cxx11-note@-3 {{use '&' for a bitwise operation}}
+  // cxx11-note@-4 {{remove constant to silence this warning}}
+  // cxx17-warning@-5 {{use of logical '&&' with constant operand}}
+  // cxx17-note@-6 {{use '&' for a bitwise operation}}
+  // cxx17-note@-7 {{remove constant to silence this warning}}
+
 
   (xs[3] || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
   (0 || (a = 0)) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
   // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
-  (1 || (a = 0)) + a; // ok
+  // cxx11-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx11-note@-3 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-4 {{use of logical '||' with constant operand}}
+  // cxx17-note@-5 {{use '|' for a bitwise operation}}
+  (1 || (a = 0)) + a; // cxx11-warning {{use of logical '||' with constant operand}}
+  // cxx11-note@-1 {{use '|' for a bitwise operation}}
+  // cxx17-warning@-2 {{use of logical '||' with constant operand}}
+  // cxx17-note@-3 {{use '|' for a bitwise operation}}
+
 
   (xs[4] ? a : ++a) + a; // cxx11-warning {{unsequenced modification and access to 'a'}}
  // cxx17-warning@-1 {{unsequenced modification and access to 'a'}}
Index: clang/test/SemaCXX/expressions.cpp
===
--- clang/test/SemaCXX/expressions.cpp
+++ clang/test/SemaCXX/expressions.cpp
@@ -44,6 +44,9 @@
   return x && 4; // expected-warning {{use of logical '&&' with constant operand}} \
// expected-note {{use '&' for a bitwise operation}} \
// expected-note {{remove constant to silence this warning}}
+  return 4 && x; // expected-warning {{use of logical '&&' with constant operand}} \
+   // expected-note {{use '&' for a bitwise operation}} \
+   // expected-note {{remove constant to silence this warning}}
 
   return x && sizeof(int) == 4;  // no warning, RHS is logical op.
   return x && true;
@@ -66,6 +69,8 @@
// expected-note {{use '|' for a bitwise operation}}
   return x || 5; // expected-warning {{use of logical '||' with constant operand}} \
// expec

[PATCH] D138675: [flang] Add -ffast-math and -Ofast

2023-01-28 Thread Tom Eccles via Phabricator via cfe-commits
tblah marked an inline comment as done.
tblah added inline comments.



Comment at: flang/test/Driver/fast_math.f90:59-62
+! Check that -ffast-math causes us to link to crtfastmath.o
+! UNSUPPORTED: system-windows
+! RUN: %flang -ffast-math -### %s -o %t 2>&1 \
+! RUN: | FileCheck --check-prefix=CHECK-CRT %s

mnadeem wrote:
> I think this test should use an explicit sysroot like the clang test does. It 
> fails on my system (x86 linux, llvm built for arm target) because it cant 
> find the crtfastmath.o library.
> 
> 
> > // file linux-ld.c
> >
> > // RUN:--sysroot=%S/Inputs/basic_linux_tree 2>&1 \
> > // RUN:   | FileCheck --check-prefix=CHECK-CRTFASTMATH %s
> 
Thanks for the suggestion https://reviews.llvm.org/D142807


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D138675

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


[clang] 3821391 - Fix Clang sphinx build

2023-01-28 Thread Aaron Ballman via cfe-commits

Author: Aaron Ballman
Date: 2023-01-28T08:56:22-05:00
New Revision: 3821391847c4613d21295a53dcab30e6f92fe94c

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

LOG: Fix Clang sphinx build

This addresses the issue found in:
https://lab.llvm.org/buildbot/#/builders/92/builds/39306

Added: 


Modified: 
clang/docs/SourceBasedCodeCoverage.rst

Removed: 




diff  --git a/clang/docs/SourceBasedCodeCoverage.rst 
b/clang/docs/SourceBasedCodeCoverage.rst
index 3a5d1cefb7e5..d1d819bf0b69 100644
--- a/clang/docs/SourceBasedCodeCoverage.rst
+++ b/clang/docs/SourceBasedCodeCoverage.rst
@@ -127,11 +127,11 @@ copy that's mapped into memory). This implementation can 
be also enabled for
 other platforms by passing the ``-runtime-counter-relocation`` option to the
 backend during compilation.
 
-For a program such as the :doc:`Lit ` testing tool which
-invokes other programs, it may be necessary to set ``LLVM_PROFILE_FILE`` for
-each invocation. The pattern strings "%p" or "%Nm" may help to avoid
-corruption due to concurrency. Note that "%p" is also a Lit token and needs
-to be escaped as "%%p".
+For a program such as the `Lit `_
+testing tool which invokes other programs, it may be necessary to set
+``LLVM_PROFILE_FILE`` for each invocation. The pattern strings "%p" or "%Nm"
+may help to avoid corruption due to concurrency. Note that "%p" is also a Lit
+token and needs to be escaped as "%%p".
 
 .. code-block:: console
 



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


[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-28 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson added a comment.

In D142578#4087974 , @tschuett wrote:

> I am not the only one who has a different background. If the introduction 
> says this is the introduction of the release notes, I am not super motivated 
> to read on. I would prefer to see some highlights to motivate the readers to 
> continue reading.

You've mentioned what I think are separate issues - that this document is 
difficult to read for readers from different backgrounds and that the 
introduction might be too long or unengaging.

I mostly agree about the first point - I've tried to do what I could to make it 
more accessible but I don't think it's enough.

About the second point - I'm not really sure what to change. I think the 
'potentially breaking changes' section is more important than the 'what's new' 
section, but the 'what's new' section IS the second section (and there's a 
table of contents). Are there specific topics you think we should remove from 
the introduction or move into the intro from the 'what's new' section? I'd like 
to avoid duplicating information if we can.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-28 Thread Thorsten via Phabricator via cfe-commits
tschuett added a comment.

IDK. Clang 16 is fully is a fully conformant C++20 except for some DRs. Or 
beginning with Clang 16, we start a long-term project to overhaul the 
diagnostics.

I agree that breaking changes are important.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[PATCH] D142690: [DRAFT][libc++] Fixes the Clang modular build.

2023-01-28 Thread Mark de Wever via Phabricator via cfe-commits
Mordante updated this revision to Diff 492999.
Mordante added a comment.

Undo CI changes.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142690

Files:
  libcxx/include/module.modulemap.in


Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header 
"__concepts/derived_from.h" }
   module destructible   { private header 
"__concepts/destructible.h" }
   module different_from { private header 
"__concepts/different_from.h" }
-  module equality_comparable{ private header 
"__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header 
"__concepts/invocable.h" }
   module movable{ private header 
"__concepts/movable.h" }
   module predicate  { private header 
"__concepts/predicate.h" }
   module regular{ private header 
"__concepts/regular.h" }
   module relation   { private header 
"__concepts/relation.h" }
-  module same_as{ private header 
"__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ private header 
"__concepts/semiregular.h" }
   module swappable  { private header 
"__concepts/swappable.h" }
   module totally_ordered{ private header 
"__concepts/totally_ordered.h" }
@@ -979,7 +985,11 @@
   module back_insert_iterator  { private header 
"__iterator/back_insert_iterator.h" }
   module bounded_iter  { private header 
"__iterator/bounded_iter.h" }
   module common_iterator   { private header 
"__iterator/common_iterator.h" }
-  module concepts  { private header "__iterator/concepts.h" }
+  module concepts {
+private header "__iterator/concepts.h"
+export concepts.equality_comparable
+export type_traits.common_reference
+  }
   module counted_iterator  { private header 
"__iterator/counted_iterator.h" }
   module data  { private header "__iterator/data.h" }
   module default_sentinel  { private header 
"__iterator/default_sentinel.h" }


Index: libcxx/include/module.modulemap.in
===
--- libcxx/include/module.modulemap.in
+++ libcxx/include/module.modulemap.in
@@ -755,13 +755,19 @@
   module derived_from   { private header "__concepts/derived_from.h" }
   module destructible   { private header "__concepts/destructible.h" }
   module different_from { private header "__concepts/different_from.h" }
-  module equality_comparable{ private header "__concepts/equality_comparable.h" }
+  module equality_comparable {
+private header "__concepts/equality_comparable.h"
+export type_traits.common_reference
+  }
   module invocable  { private header "__concepts/invocable.h" }
   module movable{ private header "__concepts/movable.h" }
   module predicate  { private header "__concepts/predicate.h" }
   module regular{ private header "__concepts/regular.h" }
   module relation   { private header "__concepts/relation.h" }
-  module same_as{ private header "__concepts/same_as.h" }
+  module same_as {
+private header "__concepts/same_as.h"
+export type_traits.is_same
+  }
   module semiregular{ private header "__concepts/semiregular.h" }
   module swappable  { private header "__concepts/swappable.h" }
   module totally_ordered{ private header "__concepts/totally_ordered.h" }
@@ -979,7 +985,11 @@
   module back_insert_iterator  { private header "__iterator/back_insert_iterator.h" }
   module bounded_iter  { private header "__iterator/bounded_iter.h" }
   module common_iterator   { private header "__iterator/common_iterator.h" }
-  module concepts  { private header "__iterator/concepts.h" }
+  module concepts {
+private header "__iterator/concepts.h"
+export concepts.equality_comparable
+export type_traits.common_reference
+  }
   module counted_iterator  { private header "__iterator/counted_iterator.h" }
   module data  { private header "__iterator/data.h" }
   module default

[PATCH] D142690: [libc++] Fixes the Clang modular build.

2023-01-28 Thread Mark de Wever via Phabricator via cfe-commits
Mordante added a comment.

https://buildkite.com/llvm-project/libcxx-ci/builds/18148 shows this patch 
fixes the Clang modular build.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142690

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-28 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 493004.
ccotter marked an inline comment as done.
ccotter added a comment.

rebase


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/CMakeLists.txt
  clang-tools-extra/clang-tidy/cppcoreguidelines/CppCoreGuidelinesTidyModule.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.cpp
  
clang-tools-extra/clang-tidy/cppcoreguidelines/RvalueReferenceParamNotMovedCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  
clang-tools-extra/docs/clang-tidy/checks/cppcoreguidelines/rvalue-reference-param-not-moved.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  
clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines/rvalue-reference-param-not-moved.cpp
@@ -0,0 +1,293 @@
+// RUN: %check_clang_tidy -std=c++11 %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+// RUN: %check_clang_tidy -check-suffix=,CXX14 -std=c++14-or-later %s cppcoreguidelines-rvalue-reference-param-not-moved %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template 
+struct remove_reference;
+
+template 
+struct remove_reference {
+  typedef _Tp type;
+};
+
+template 
+constexpr typename std::remove_reference<_Tp>::type &&move(_Tp &&__t) noexcept;
+
+template 
+constexpr _Tp &&
+forward(typename remove_reference<_Tp>::type &__t) noexcept;
+
+}
+// NOLINTEND
+
+struct Obj {
+  Obj();
+  Obj(const Obj&);
+  Obj& operator=(const Obj&);
+  Obj(Obj&&);
+  Obj& operator=(Obj&&);
+  void member() const;
+};
+
+void consumes_object(Obj);
+
+void never_moves_param(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:30: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void copies_object(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:26: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  Obj copy = o;
+}
+
+template 
+void never_moves_param_template(Obj&& o, T t) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:39: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  o.member();
+}
+
+void never_moves_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  // CHECK-MESSAGES: :[[@LINE-2]]:41: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void never_moves_some_params(Obj&& o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:36: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+  Obj other{std::move(o2)};
+}
+
+void never_moves_mixed(Obj o1, Obj&& o2) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:38: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value(Obj&& o) {
+  auto f = [o]() {
+consumes_object(std::move(o));
+  };
+  // CHECK-MESSAGES: :[[@LINE-4]]:47: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+}
+
+void lambda_captures_parameter_as_value_nested(Obj&& o) {
+  // CHECK-MESSAGES: :[[@LINE-1]]:54: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+  auto f = [&o]() {
+auto f_nested = [o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f2 = [o]() {
+auto f_nested = [&o]() {
+  consumes_object(std::move(o));
+};
+  };
+  auto f3 = [o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [&o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+  auto f4 = [&o]() {
+auto f_nested = [&o]() {
+  auto f_nested_inner = [o]() {
+consumes_object(std::move(o));
+  };
+};
+  };
+}
+
+void misc_lambda_checks() {
+  auto never_moves = [](Obj&& o1) {
+Obj other{o1};
+  };
+  // CHECK-MESSAGES: :[[@LINE-3]]:31: warning: rvalue reference parameter is never moved from inside the function body [cppcoreguidelines-rvalue-reference-param-not-moved]
+
+#if __cplusplus >= 201402L
+  auto never_moves_with_auto_param = [](Obj&& o1, auto& v) {
+Obj o

[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-28 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson updated this revision to Diff 493008.
royjacobson added a comment.

- Remove redundant paragraph from the intro
- Remove outdated bug fix bullet


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

Files:
  clang/docs/ReleaseNotes.rst

Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -13,7 +13,7 @@
   .. warning::
  These are in-progress notes for the upcoming Clang |version| release.
  Release notes for previous releases can be found on
- `the Download Page `_.
+ `the Releases Page `_.
 
 Introduction
 
@@ -23,43 +23,32 @@
 describe the status of Clang in some detail, including major
 improvements from the previous release and new feature work. For the
 general LLVM release notes, see `the LLVM
-documentation `_. All LLVM
-releases may be downloaded from the `LLVM releases web
-site `_.
+documentation `_. For the libc++ release notes,
+see `this page `_. All LLVM releases
+may be downloaded from the `LLVM releases web site `_.
 
 For more information about Clang or LLVM, including information about the
 latest release, please see the `Clang Web Site `_ or the
 `LLVM Web Site `_.
 
-Note that if you are reading this file from a Git checkout or the
-main Clang web page, this document applies to the *next* release, not
-the current one. To see the release notes for a specific release, please
-see the `releases page `_.
-
 Potentially Breaking Changes
 
 These changes are ones which we think may surprise users when upgrading to
 Clang |release| because of the opportunity they pose for disruption to existing
 code bases.
 
-- Clang will now correctly diagnose as ill-formed a constant expression where an
-  enum without a fixed underlying type is set to a value outside the range of
-  the enumeration's values.
-
-  .. code-block:: c++
+- Clang's default C++/ObjC++ standard is now ``gnu++17`` instead of ``gnu++14``.
+  This means Clang will by default accept code using features from C++17 and
+  conforming GNU extensions. Projects incompatible with C++17 can add
+  ``-std=gnu++14`` to their build settings to restore the previous behaviour.
 
-enum E { Zero, One, Two, Three, Four };
-constexpr E Val1 = (E)3;  // Ok
-constexpr E Val2 = (E)7;  // Ok
-constexpr E Val3 = (E)8;  // Now diagnosed as out of the range [0, 7]
-constexpr E Val4 = (E)-1; // Now diagnosed as out of the range [0, 7]
+- The ``-fexperimental-new-pass-manager`` and ``-fno-legacy-pass-manager``
+  flags have been removed. These flags have been silently ignored since 15.
 
-  Due to the extended period of time this bug was present in major C++
-  implementations (including Clang), this error has the ability to be
-  downgraded into a warning (via: ``-Wno-error=enum-constexpr-conversion``) to
-  provide a transition period for users. This diagnostic is expected to turn
-  into an error-only diagnostic in the next Clang release. Fixes
-  `Issue 50055 `_.
+- Clang's resource directory path previously included the full clang version.
+  It now includes only the major version. The new resource directory is
+  ``$prefix/lib/clang/$CLANG_MAJOR_VERSION`` and can be queried using
+  ``clang -print-resource-dir``, just like before.
 
 - The ``-Wimplicit-function-declaration`` and ``-Wimplicit-int`` warnings
   now default to an error in C99, C11, and C17. As of C2x,
@@ -89,17 +78,26 @@
   void (*fp)(int *) = func; // Previously a warning, now a downgradable error.
 }
 
+- To match GCC, ``__ppc64__`` is no longer defined on PowerPC64 targets. Use
+  ``__powerpc64__`` instead.
+
+- ``-p`` is rejected for all targets which are not AIX or OpenBSD. ``-p`` led
+  to an ``-Wunused-command-line-argument`` warning in previous releases.
+
+C/C++ Language Potentially Breaking Changes
+---
+
 - Clang now disallows types whose sizes aren't a multiple of their alignments
   to be used as the element type of arrays.
 
   .. code-block:: c
 
-  typedef char int8_a16 __attribute__((aligned(16)));
-  int8_a16 array[4]; // Now diagnosed as the element size not being a multiple of the array alignment.
+typedef char int8_a16 __attribute__((aligned(16)));
+int8_a16 array[4]; // Now diagnosed as the element size not being a multiple of the array alignment.
 
 - When compiling for Windows in MSVC compatibility mode (for example by using
   clang-cl), the compiler will no

[PATCH] D142578: [Clang][Doc] Edit the Clang release notes

2023-01-28 Thread Roy Jacobson via Phabricator via cfe-commits
royjacobson marked 5 inline comments as done.
royjacobson added inline comments.



Comment at: clang/docs/ReleaseNotes.rst:452-454
+
 - Now diagnoses use of a member access expression or array subscript expression
   within ``__builtin_offsetof`` and ``offsetof`` as being a Clang extension.

aaron.ballman wrote:
> aaron.ballman wrote:
> > Assuming https://github.com/llvm/llvm-project/issues/60337 gets ported to 
> > the 16.0 branch, this bullet can be removed entirely.
> and that did land in 84f3164c1d9ce024f59221dcfbc8ab050de73748
done.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142578

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


[PATCH] D141569: [clang-tidy] Implement CppCoreGuideline F.18

2023-01-28 Thread Chris Cotter via Phabricator via cfe-commits
ccotter added a comment.

In https://github.com/isocpp/CppCoreGuidelines/issues/2026, it looks like the 
core guideline will not permit exceptions for code that accepts an rvalue ref 
parameter, and the function body `moves` members of the parameter. So, my 
`moves_member_of_parameter` test case would be flagged. In theory, we could add 
a tool option to allow someone to live more "dangerously" and have the tool 
accept code like `moves_member_of_parameter`, with the caveat that the tool (as 
I have written it so far) would not be smart enough to detect that all static 
paths move every data member of the object. In any case, I'll update my test 
and the tool to align exactly with the guideline.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141569

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


[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-28 Thread Iain Sandoe via Phabricator via cfe-commits
iains updated this revision to Diff 493014.
iains added a comment.

rebased, and revised to handle variable templates and instantiations.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142704

Files:
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CXX/module/module.import/p6.cpp


Index: clang/test/CXX/module/module.import/p6.cpp
===
--- clang/test/CXX/module/module.import/p6.cpp
+++ clang/test/CXX/module/module.import/p6.cpp
@@ -22,6 +22,8 @@
 
 int bad_var_definition = 3;  // expected-error {{non-inline external 
definitions are not permitted in C++ header units}}
 
+/* The cases below should compile without diagnostics.  */
+
 class A {
 public:
 // This is a declaration instead of definition.
@@ -36,3 +38,26 @@
   S(S&);
 };
 S::S(S&) = default;
+
+template 
+_X tmpl_var_ok_0 = static_cast<_X>(-1);
+
+template 
+constexpr _T tmpl_var_ok_1 = static_cast<_T>(42);
+
+template  class _T>
+constexpr int tmpl_var_ok_2 = _T<_Tp>::value ? 42 : 6174 ;
+
+template
+int tmpl_OK (_Ep) { return 0; }
+
+template 
+bool
+operator==(_T1& , _T1& ) { return false; }
+
+constexpr long one_k = 1000L;
+
+template 
+void* tmpl_fn_ok
+(_Args ...__args) { return nullptr; }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13088,9 +13088,10 @@
   // C++ [module.import/6] external definitions are not permitted in header
   // units.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
-  VDecl->isThisDeclarationADefinition() &&
+  !VDecl->isInvalidDecl() && VDecl->isThisDeclarationADefinition() &&
   VDecl->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !VDecl->isInline()) {
+  !VDecl->isInline() && !VDecl->isTemplated() &&
+  !isa(VDecl)) {
 Diag(VDecl->getLocation(), diag::err_extern_def_in_header_unit);
 VDecl->setInvalidDecl();
   }
@@ -15259,9 +15260,10 @@
   // FIXME: Consider an alternate location for the test where the inlined()
   // state is complete.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
+  !FD->isInvalidDecl() && !FD->isInlined() &&
+  BodyKind != FnBodyKind::Delete && BodyKind != FnBodyKind::Default &&
   FD->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
-  BodyKind != FnBodyKind::Default && !FD->isInlined()) {
+  !FD->isTemplated() && !FD->isTemplateInstantiation()) {
 assert(FD->isThisDeclarationADefinition());
 Diag(FD->getLocation(), diag::err_extern_def_in_header_unit);
 FD->setInvalidDecl();


Index: clang/test/CXX/module/module.import/p6.cpp
===
--- clang/test/CXX/module/module.import/p6.cpp
+++ clang/test/CXX/module/module.import/p6.cpp
@@ -22,6 +22,8 @@
 
 int bad_var_definition = 3;  // expected-error {{non-inline external definitions are not permitted in C++ header units}}
 
+/* The cases below should compile without diagnostics.  */
+
 class A {
 public:
 // This is a declaration instead of definition.
@@ -36,3 +38,26 @@
   S(S&);
 };
 S::S(S&) = default;
+
+template 
+_X tmpl_var_ok_0 = static_cast<_X>(-1);
+
+template 
+constexpr _T tmpl_var_ok_1 = static_cast<_T>(42);
+
+template  class _T>
+constexpr int tmpl_var_ok_2 = _T<_Tp>::value ? 42 : 6174 ;
+
+template
+int tmpl_OK (_Ep) { return 0; }
+
+template 
+bool
+operator==(_T1& , _T1& ) { return false; }
+
+constexpr long one_k = 1000L;
+
+template 
+void* tmpl_fn_ok
+(_Args ...__args) { return nullptr; }
Index: clang/lib/Sema/SemaDecl.cpp
===
--- clang/lib/Sema/SemaDecl.cpp
+++ clang/lib/Sema/SemaDecl.cpp
@@ -13088,9 +13088,10 @@
   // C++ [module.import/6] external definitions are not permitted in header
   // units.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
-  VDecl->isThisDeclarationADefinition() &&
+  !VDecl->isInvalidDecl() && VDecl->isThisDeclarationADefinition() &&
   VDecl->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !VDecl->isInline()) {
+  !VDecl->isInline() && !VDecl->isTemplated() &&
+  !isa(VDecl)) {
 Diag(VDecl->getLocation(), diag::err_extern_def_in_header_unit);
 VDecl->setInvalidDecl();
   }
@@ -15259,9 +15260,10 @@
   // FIXME: Consider an alternate location for the test where the inlined()
   // state is complete.
   if (getLangOpts().CPlusPlusModules && currentModuleIsHeaderUnit() &&
+  !FD->isInvalidDecl() && !FD->isInlined() &&
+  BodyKind != FnBodyKind::Delete && BodyKind != FnBodyKind::Default &&
   FD->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
-  BodyKind != FnBodyKind::Default && !F

[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-28 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked an inline comment as done.
iains added a comment.

in my local testing, I was able to consume all libc++ headers individually.




Comment at: clang/lib/Sema/SemaDecl.cpp:15265
   FD->getFormalLinkage() == Linkage::ExternalLinkage &&
-  !FD->isInvalidDecl() && BodyKind != FnBodyKind::Delete &&
+  !FD->isInvalidDecl() && !IsFnTemplate && BodyKind != FnBodyKind::Delete 
&&
   BodyKind != FnBodyKind::Default && !FD->isInlined()) {

rsmith wrote:
> Would it make sense to use `!isa(D)` here instead of 
> adding `IsFnTemplate`?
> Would it make sense to use `!isa(D)` here instead of 
> adding `IsFnTemplate`?

I have changed this to use FD->isTemplated() to match the changes for VarDecls 
- where the template decl is not available.  Would it be better to use the 
isa<>() ?



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142704

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


[PATCH] D142569: [WIP][OpenMP] Introduce kernel argument

2023-01-28 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 493019.
tianshilei1992 added a comment.

rebase and fix bugs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  openmp/libomptarget/DeviceRTL/CMakeLists.txt
  openmp/libomptarget/DeviceRTL/include/Debug.h
  openmp/libomptarget/DeviceRTL/include/Interface.h
  openmp/libomptarget/DeviceRTL/include/State.h
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/Debug.cpp
  openmp/libomptarget/DeviceRTL/src/Kernel.cpp
  openmp/libomptarget/DeviceRTL/src/State.cpp
  openmp/libomptarget/include/DeviceEnvironment.h
  openmp/libomptarget/include/Environment.h
  openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins/cuda/src/rtl.cpp

Index: openmp/libomptarget/plugins/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -23,7 +23,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "omptarget.h"
 #include "omptargetplugin.h"
 
Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -37,7 +37,7 @@
 #include "internal.h"
 #include "rt.h"
 
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "get_elf_mach_gfx_name.h"
 #include "omptargetplugin.h"
 #include "print_tracing.h"
Index: openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
@@ -17,7 +17,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "GlobalHandler.h"
 #include "PluginInterface.h"
 #include "omptarget.h"
Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -17,7 +17,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "GlobalHandler.h"
 #include "PluginInterface.h"
 
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
@@ -19,7 +19,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "GlobalHandler.h"
 #include "JIT.h"
 #include "MemoryManager.h"
@@ -627,6 +627,11 @@
 
   /// Map of host pinned allocations used for optimize device transfers.
   PinnedAllocationMapTy PinnedAllocs;
+
+private:
+  /// Return the kernel environment object for kernel \p Name.
+  Expected
+  getKernelEnvironmentForKernel(StringRef Name, DeviceImageTy &Image);
 };
 
 /// Class implementing common functionalities of offload plugins. Each plugin
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -554,32 +554,43 @@
   return Plugin::success();
 }
 
-Expected
-GenericDeviceTy::getExecutionModeForKernel(StringRef Name,
-   DeviceImageTy &Image) {
-  // Create a metadata object for the exec mode global (auto-generated).
-  StaticGlobalTy ExecModeGlobal(Name.data(),
-"_exec_mode");
+Expected
+GenericDeviceTy::getKernelEnvironmentForKernel(StringRef Name,
+   DeviceImageTy &Image) {
+  // Create a metadata object for the kernel environment object.
+  StaticGlobalTy KernelEnv(Name.data(), "_kernel_info");
 
-  // Retrieve execution mode fo

[PATCH] D141144: [clang-tidy][doc] Improve clang-tidy documentation

2023-01-28 Thread Piotr Zegar via Phabricator via cfe-commits
ClockMan added inline comments.



Comment at: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp:34
 
+static StringRef TrimFirstChar(StringRef x) { return x.substr(1); }
+

Looks like usecase of this is more like rtrim, then probably rtrim should be 
used instead of substr.
And probably better would be to replace entire cl::desc. instead of adding new 
additional wrap.

more like: 
static auto desc(llvm::StringRef description) { return 
cl::desc(description.rtrim()); }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141144

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


[PATCH] D142816: [clang-tidy] Add --list-unique-checks command

2023-01-28 Thread Piotr Zegar via Phabricator via cfe-commits
ClockMan created this revision.
Herald added subscribers: carlosgalvezp, arphaman, xazax.hun.
Herald added a reviewer: njames93.
Herald added a project: All.
ClockMan updated this revision to Diff 493024.
ClockMan added a comment.
ClockMan published this revision for review.
Herald added a project: clang-tools-extra.
Herald added a subscriber: cfe-commits.

clang-format


ClockMan added a comment.

Read for review.


Currently in clang-tidy 48 checks are registred more
than once under diffrent names. This causes issues
for end user, who by mistake could enable same check
multiple times. This commit provides command that
can be used by user to troubleshot this issue.

Read more: https://github.com/llvm/llvm-project/issues/49960


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142816

Files:
  clang-tools-extra/clang-tidy/ClangTidy.cpp
  clang-tools-extra/clang-tidy/ClangTidy.h
  clang-tools-extra/clang-tidy/ClangTidyModule.cpp
  clang-tools-extra/clang-tidy/ClangTidyModule.h
  clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
  clang-tools-extra/docs/clang-tidy/index.rst
  clang-tools-extra/test/clang-tidy/infrastructure/list-unique-checks.cpp

Index: clang-tools-extra/test/clang-tidy/infrastructure/list-unique-checks.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/infrastructure/list-unique-checks.cpp
@@ -0,0 +1,4 @@
+// RUN: mkdir -p %T/clang-tidy/list-unique-checks/
+// RUN: echo '{Checks: "-*,google-readability-braces-around-statements,hicpp-braces-around-statements,readability-braces-around-statements"}' > %T/clang-tidy/.clang-tidy
+// RUN: cd %T/clang-tidy/list-unique-checks
+// RUN: clang-tidy -list-unique-checks | grep "^ *google-readability-braces-around-statements, hicpp-braces-around-statements, readability-braces-around-statements"
Index: clang-tools-extra/docs/clang-tidy/index.rst
===
--- clang-tools-extra/docs/clang-tidy/index.rst
+++ clang-tools-extra/docs/clang-tidy/index.rst
@@ -139,7 +139,7 @@
  When the value is empty, clang-tidy will
  attempt to find a file named .clang-tidy for
  each source file in its parent directories.
---config-file= - 
+--config-file= -
 Specify the path of .clang-tidy or custom config file:
   e.g. --config-file=/some/path/myTidyConfigFile
 This option internally works exactly the same way as
@@ -217,6 +217,10 @@
 --list-checks  -
  List all enabled checks and exit. Use with
  -checks=* to list all available checks.
+--list-unique-checks   -
+ List all enabled checks and exit. Check
+ aliases are listed in the same line. Use
+ with -checks=* to list all available checks.
 -load= -
  Load the dynamic object ``plugin``. This
  object should register new static analyzer
@@ -237,7 +241,7 @@
  format to stderr. When this option is passed,
  these per-TU profiles are instead stored as JSON.
 --system-headers   - Display the errors from system headers.
---use-color- 
+--use-color-
 Use colors in diagnostics. If not set, colors
 will be used if the terminal connected to
 standard output supports colors.
Index: clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
===
--- clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
+++ clang-tools-extra/clang-tidy/tool/ClangTidyMain.cpp
@@ -130,10 +130,10 @@
cl::init(false), cl::cat(ClangTidyCategory));
 
 static cl::opt FixNotes("fix-notes", cl::desc(R"(
-If a warning has no fix, but a single fix can 
-be found through an associated diagnostic note, 
-apply the fix. 
-Specifying this flag will implicitly enable the 
+If a warning has no fix, but a single fix can
+be found through an associated diagnostic note,
+apply the fix.
+Specifying this flag will implicitly enable the
 '--fix' flag.
 )"),
   cl::init(false), cl::cat(ClangTidyCategory));
@@ -152,8 +152,8 @@
 This option overrides the 'FormatStyle` option in
 .clang-tidy file, if any.
 )"),
-   cl::init("none"),
-   cl::cat(ClangTidyCategory));
+ 

[clang] e67f849 - [CMake] Replace clang binary if using clang-bolt target

2023-01-28 Thread Amir Aupov via cfe-commits

Author: Amir Ayupov
Date: 2023-01-28T11:54:09-08:00
New Revision: e67f849001bb890f86831ab31c1bb25e0882e711

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

LOG: [CMake] Replace clang binary if using clang-bolt target

Instead of creating an extra clang-bolt binary and clang++-bolt symlink,
replace the original clang binary with BOLT-optimized one.

This fixes the issue with installing optimized binary as `install-clang`
target now copies the new version.

Reviewed By: phosek

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

Added: 


Modified: 
clang/CMakeLists.txt
clang/cmake/caches/BOLT-PGO.cmake
llvm/docs/AdvancedBuilds.rst

Removed: 




diff  --git a/clang/CMakeLists.txt b/clang/CMakeLists.txt
index 090cfa3520789..b2cd30b9c7884 100644
--- a/clang/CMakeLists.txt
+++ b/clang/CMakeLists.txt
@@ -856,8 +856,6 @@ if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   set(CLANGXX_PATH ${CLANG_PATH}++)
   set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst)
   set(CLANGXX_INSTRUMENTED ${CLANGXX_PATH}-bolt.inst)
-  set(CLANG_OPTIMIZED ${CLANG_PATH}-bolt)
-  set(CLANGXX_OPTIMIZED ${CLANGXX_PATH}-bolt)
 
   # Instrument clang with BOLT
   add_custom_target(clang-instrumented
@@ -935,6 +933,7 @@ if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   )
 
   # Optimize original (pre-bolt) Clang using the collected profile
+  set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt)
   add_custom_target(clang-bolt
 DEPENDS ${CLANG_OPTIMIZED}
   )
@@ -945,22 +944,10 @@ if (CLANG_BOLT_INSTRUMENT AND NOT LLVM_BUILD_INSTRUMENTED)
   -data ${CMAKE_CURRENT_BINARY_DIR}/prof.fdata
   -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions
   -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
+COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} $
 COMMENT "Optimizing Clang with BOLT"
 VERBATIM
   )
-
-  # Make a symlink from clang-bolt to clang++-bolt
-  add_custom_target(clang++-bolt
-DEPENDS ${CLANGXX_OPTIMIZED}
-  )
-  add_custom_command(OUTPUT ${CLANGXX_OPTIMIZED}
-DEPENDS clang-bolt
-COMMAND ${CMAKE_COMMAND} -E create_symlink
-  ${CLANG_OPTIMIZED}
-  ${CLANGXX_OPTIMIZED}
-COMMENT "Creating symlink from BOLT optimized clang to clang++"
-VERBATIM
-  )
 endif()
 
 if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)

diff  --git a/clang/cmake/caches/BOLT-PGO.cmake 
b/clang/cmake/caches/BOLT-PGO.cmake
index c329415465c94..616e632d1531b 100644
--- a/clang/cmake/caches/BOLT-PGO.cmake
+++ b/clang/cmake/caches/BOLT-PGO.cmake
@@ -2,11 +2,9 @@ set(LLVM_ENABLE_PROJECTS "bolt;clang;lld" CACHE STRING "")
 
 set(CLANG_BOOTSTRAP_TARGETS
   stage2-clang-bolt
-  stage2-clang++-bolt
   CACHE STRING "")
 set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
   clang-bolt
-  clang++-bolt
   CACHE STRING "")
 
 set(PGO_BUILD_CONFIGURATION ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake CACHE STRING 
"")

diff  --git a/llvm/docs/AdvancedBuilds.rst b/llvm/docs/AdvancedBuilds.rst
index b3e9f85d7fe95..ba3f3c3e498f4 100644
--- a/llvm/docs/AdvancedBuilds.rst
+++ b/llvm/docs/AdvancedBuilds.rst
@@ -224,7 +224,7 @@ Then, build the BOLT-optimized binary by running the 
following ninja command:
 
 .. code-block:: console
 
-  $ ninja clang++-bolt
+  $ ninja clang-bolt
 
 If you're seeing errors in the build process, try building with a recent
 version of Clang/LLVM by setting the CMAKE_C_COMPILER and
@@ -243,12 +243,11 @@ configuration command:
   -DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
   -DPGO_INSTRUMENT_LTO=Thin
 
-Then, to build the final optimized binary, build the stage2-clang++-bolt
-target:
+Then, to build the final optimized binary, build the stage2-clang-bolt target:
 
 .. code-block:: console
 
-  $ ninja stage2-clang++-bolt
+  $ ninja stage2-clang-bolt
 
 3-Stage Non-Determinism
 ===



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


[PATCH] D139454: [CMake] Replace clang binary if using clang-bolt target

2023-01-28 Thread Amir Ayupov via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe67f849001bb: [CMake] Replace clang binary if using 
clang-bolt target (authored by Amir).

Changed prior to commit:
  https://reviews.llvm.org/D139454?vs=492638&id=493025#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D139454

Files:
  clang/CMakeLists.txt
  clang/cmake/caches/BOLT-PGO.cmake
  llvm/docs/AdvancedBuilds.rst


Index: llvm/docs/AdvancedBuilds.rst
===
--- llvm/docs/AdvancedBuilds.rst
+++ llvm/docs/AdvancedBuilds.rst
@@ -224,7 +224,7 @@
 
 .. code-block:: console
 
-  $ ninja clang++-bolt
+  $ ninja clang-bolt
 
 If you're seeing errors in the build process, try building with a recent
 version of Clang/LLVM by setting the CMAKE_C_COMPILER and
@@ -243,12 +243,11 @@
   -DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
   -DPGO_INSTRUMENT_LTO=Thin
 
-Then, to build the final optimized binary, build the stage2-clang++-bolt
-target:
+Then, to build the final optimized binary, build the stage2-clang-bolt target:
 
 .. code-block:: console
 
-  $ ninja stage2-clang++-bolt
+  $ ninja stage2-clang-bolt
 
 3-Stage Non-Determinism
 ===
Index: clang/cmake/caches/BOLT-PGO.cmake
===
--- clang/cmake/caches/BOLT-PGO.cmake
+++ clang/cmake/caches/BOLT-PGO.cmake
@@ -2,11 +2,9 @@
 
 set(CLANG_BOOTSTRAP_TARGETS
   stage2-clang-bolt
-  stage2-clang++-bolt
   CACHE STRING "")
 set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
   clang-bolt
-  clang++-bolt
   CACHE STRING "")
 
 set(PGO_BUILD_CONFIGURATION ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake CACHE STRING 
"")
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -856,8 +856,6 @@
   set(CLANGXX_PATH ${CLANG_PATH}++)
   set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst)
   set(CLANGXX_INSTRUMENTED ${CLANGXX_PATH}-bolt.inst)
-  set(CLANG_OPTIMIZED ${CLANG_PATH}-bolt)
-  set(CLANGXX_OPTIMIZED ${CLANGXX_PATH}-bolt)
 
   # Instrument clang with BOLT
   add_custom_target(clang-instrumented
@@ -935,6 +933,7 @@
   )
 
   # Optimize original (pre-bolt) Clang using the collected profile
+  set(CLANG_OPTIMIZED ${CMAKE_CURRENT_BINARY_DIR}/clang.bolt)
   add_custom_target(clang-bolt
 DEPENDS ${CLANG_OPTIMIZED}
   )
@@ -945,22 +944,10 @@
   -data ${CMAKE_CURRENT_BINARY_DIR}/prof.fdata
   -reorder-blocks=ext-tsp -reorder-functions=hfsort+ -split-functions
   -split-all-cold -split-eh -dyno-stats -icf=1 -use-gnu-stack
+COMMAND ${CMAKE_COMMAND} -E rename ${CLANG_OPTIMIZED} $
 COMMENT "Optimizing Clang with BOLT"
 VERBATIM
   )
-
-  # Make a symlink from clang-bolt to clang++-bolt
-  add_custom_target(clang++-bolt
-DEPENDS ${CLANGXX_OPTIMIZED}
-  )
-  add_custom_command(OUTPUT ${CLANGXX_OPTIMIZED}
-DEPENDS clang-bolt
-COMMAND ${CMAKE_COMMAND} -E create_symlink
-  ${CLANG_OPTIMIZED}
-  ${CLANGXX_OPTIMIZED}
-COMMENT "Creating symlink from BOLT optimized clang to clang++"
-VERBATIM
-  )
 endif()
 
 if (LLVM_ADD_NATIVE_VISUALIZERS_TO_SOLUTION)


Index: llvm/docs/AdvancedBuilds.rst
===
--- llvm/docs/AdvancedBuilds.rst
+++ llvm/docs/AdvancedBuilds.rst
@@ -224,7 +224,7 @@
 
 .. code-block:: console
 
-  $ ninja clang++-bolt
+  $ ninja clang-bolt
 
 If you're seeing errors in the build process, try building with a recent
 version of Clang/LLVM by setting the CMAKE_C_COMPILER and
@@ -243,12 +243,11 @@
   -DBOOTSTRAP_BOOTSTRAP_LLVM_ENABLE_LLD=ON \
   -DPGO_INSTRUMENT_LTO=Thin
 
-Then, to build the final optimized binary, build the stage2-clang++-bolt
-target:
+Then, to build the final optimized binary, build the stage2-clang-bolt target:
 
 .. code-block:: console
 
-  $ ninja stage2-clang++-bolt
+  $ ninja stage2-clang-bolt
 
 3-Stage Non-Determinism
 ===
Index: clang/cmake/caches/BOLT-PGO.cmake
===
--- clang/cmake/caches/BOLT-PGO.cmake
+++ clang/cmake/caches/BOLT-PGO.cmake
@@ -2,11 +2,9 @@
 
 set(CLANG_BOOTSTRAP_TARGETS
   stage2-clang-bolt
-  stage2-clang++-bolt
   CACHE STRING "")
 set(BOOTSTRAP_CLANG_BOOTSTRAP_TARGETS
   clang-bolt
-  clang++-bolt
   CACHE STRING "")
 
 set(PGO_BUILD_CONFIGURATION ${CMAKE_CURRENT_LIST_DIR}/BOLT.cmake CACHE STRING "")
Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -856,8 +856,6 @@
   set(CLANGXX_PATH ${CLANG_PATH}++)
   set(CLANG_INSTRUMENTED ${CLANG_PATH}-bolt.inst)
   set(CLANGXX_INSTRUMENTED ${CLANGXX_PATH}-bolt.inst)
-  set(CLANG_OPTIMIZED ${CLANG_PATH}-bolt)
-  set(CLANGXX_OPTIMIZED ${CLANGXX_PATH}-bolt)
 
   # Instrument clang with BOLT
   a

[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-28 Thread Arthur Laurent via Phabricator via cfe-commits
Arthapz added a comment.

tried the patch and it seems to work with libstdc++ but not with libc++

  > rm -rf .xmake build; xmake f --toolchain=clang; xmake b
  checking for platform ... linux
  checking for architecture ... x86_64
  [  0%]: generating.module.deps src/main.cpp
  [  4%]: compiling.headerunit.release iostream
  [  4%]: compiling.headerunit.release utility
  [  4%]: compiling.headerunit.release cstdio
  [  4%]: compiling.headerunit.release vector
  [  4%]: compiling.headerunit.release fstream
  [  4%]: compiling.headerunit.release memory
  [  4%]: compiling.headerunit.release queue
  [  4%]: compiling.headerunit.release string
  [  4%]: compiling.headerunit.release map
  [  4%]: compiling.headerunit.release complex
  [  4%]: compiling.headerunit.release deque
  [  4%]: compiling.headerunit.release iomanip
  [  4%]: compiling.headerunit.release cstdlib
  [  4%]: compiling.headerunit.release set
  [  4%]: compiling.headerunit.release algorithm
  [  4%]: compiling.headerunit.release exception
  [  4%]: compiling.headerunit.release stack
  [  4%]: compiling.headerunit.release list
  [ 88%]: compiling.release src/main.cpp
  [ 92%]: linking.release stl_headerunit_cpp_only
  [100%]: build ok!
  
  > rm -rf .xmake build; xmake f --toolchain=clang --cxxflags="-stdlib=libc++"; 
xmake b 
  
  checking for platform ... linux
  checking for architecture ... x86_64
  [  0%]: generating.module.deps src/main.cpp
  [  4%]: compiling.headerunit.release memory
  [  4%]: compiling.headerunit.release exception
  [  4%]: compiling.headerunit.release queue
  [  4%]: compiling.headerunit.release iomanip
  [  4%]: compiling.headerunit.release vector
  [  4%]: compiling.headerunit.release utility
  [  4%]: compiling.headerunit.release deque
  [  4%]: compiling.headerunit.release set
  [  4%]: compiling.headerunit.release map
  [  4%]: compiling.headerunit.release fstream
  [  4%]: compiling.headerunit.release cstdio
  [  4%]: compiling.headerunit.release complex
  [  4%]: compiling.headerunit.release cstdlib
  [  4%]: compiling.headerunit.release iostream
  [  4%]: compiling.headerunit.release list
  [  4%]: compiling.headerunit.release string
  [  4%]: compiling.headerunit.release stack
  [  4%]: compiling.headerunit.release algorithm
  [ 88%]: compiling.release src/main.cpp
  error: /usr/bin/../include/c++/v1/ostream:254:20: error: 
'std::basic_ostream::operator<<' from module 
'/usr/bin/../include/c++/v1/complex' is not present in definition of 
'std::ostream' in module '/usr/bin/../include/c++/v1/iostream'
  basic_ostream& operator<<(basic_streambuf* __sb);
 ^
  /usr/bin/../include/c++/v1/ostream:221:20: note: declaration of 'operator<<' 
does not match
  basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
 ^
  /usr/bin/../include/c++/v1/ostream:225:20: note: declaration of 'operator<<' 
does not match
  basic_ostream& operator<<(basic_ios&
 ^
  /usr/bin/../include/c++/v1/ostream:230:20: note: declaration of 'operator<<' 
does not match
  basic_ostream& operator<<(ios_base& (*__pf)(ios_base&))
 ^
  /usr/bin/../include/c++/v1/ostream:233:20: note: declaration of 'operator<<' 
does not match
  basic_ostream& operator<<(bool __n);
 ^
  /usr/bin/../include/c++/v1/ostream:234:20: note: declaration of 'operator<<' 
does not match
  basic_ostream& operator<<(short __n);
> in src/main.cpp

  > cat src/main.cpp
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  import ;
  
  using namespace std;
  
  int main(int argc, char** argv)
  {
  cout << "hello world!" << endl;
  return 0;
  }


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142704

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


[PATCH] D142704: [C++20][Modules] Handle template declarations in header units.

2023-01-28 Thread Iain Sandoe via Phabricator via cfe-commits
iains marked an inline comment as done.
iains added a comment.

In D142704#4088217 , @Arthapz wrote:

> tried the patch and it seems to work with libstdc++ but not with libc++
>
>   
>   > rm -rf .xmake build; xmake f --toolchain=clang 
> --cxxflags="-stdlib=libc++"; xmake b  
>  
>   checking for platform ... linux
>   checking for architecture ... x86_64
>   
>   [ 88%]: compiling.release src/main.cpp
>   error: /usr/bin/../include/c++/v1/ostream:254:20: error: 
> 'std::basic_ostream::operator<<' from module 
> '/usr/bin/../include/c++/v1/complex' is not present in definition of 
> 'std::ostream' in module '/usr/bin/../include/c++/v1/iostream'
>   basic_ostream& operator<<(basic_streambuf* 
> __sb);
>  ^
>   /usr/bin/../include/c++/v1/ostream:221:20: note: declaration of 
> 'operator<<' does not match
>   basic_ostream& operator<<(basic_ostream& (*__pf)(basic_ostream&))
>  ^
>   
>   
>   using namespace std;
>   
>   int main(int argc, char** argv)
>   {
>   cout << "hello world!" << endl;
>   return 0;
>   }

These seem to be a different diagnostic, do you find that is in some way 
related to the changes in D140261  + follow 
on patches?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142704

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


[clang] 55e2cd1 - Use llvm::count{lr}_{zero,one} (NFC)

2023-01-28 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-28T12:41:20-08:00
New Revision: 55e2cd16095d64e9afca6e109e40ed95d735dc7f

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

LOG: Use llvm::count{lr}_{zero,one} (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/SourceCode.cpp
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/CodeGen/CGFunctionInfo.h
clang/lib/AST/Interp/Integral.h
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
clang/utils/TableGen/SveEmitter.cpp
lld/ELF/Arch/ARM.cpp
lld/ELF/InputFiles.cpp
lld/ELF/SyntheticSections.cpp
lld/ELF/SyntheticSections.h
lld/ELF/Writer.cpp
lld/MachO/SyntheticSections.cpp
lld/MachO/UnwindInfoSection.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Symbol/CompactUnwindInfo.cpp
llvm/include/llvm/ADT/APInt.h
llvm/include/llvm/ADT/BitVector.h
llvm/include/llvm/ADT/SmallBitVector.h
llvm/include/llvm/ADT/SparseBitVector.h
llvm/include/llvm/CodeGen/ExecutionDomainFix.h
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/include/llvm/Support/ScaledNumber.h
llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Analysis/VectorUtils.cpp
llvm/lib/CodeGen/ExecutionDomainFix.cpp
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/TargetRegisterInfo.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/Object/MachOUniversalWriter.cpp
llvm/lib/Support/APInt.cpp
llvm/lib/Support/ScaledNumber.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp
llvm/tools/llvm-mca/Views/ResourcePressureView.cpp
llvm/tools/llvm-objdump/ELFDump.cpp
mlir/lib/Bytecode/Reader/BytecodeReader.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index b53e9adeef6aa..d0140a7e0d01b 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -72,7 +72,7 @@ static bool iterateCodepoints(llvm::StringRef U8, const 
Callback &CB) {
   continue;
 }
 // This convenient property of UTF-8 holds for all non-ASCII characters.
-size_t UTF8Length = llvm::countLeadingOnes(C);
+size_t UTF8Length = llvm::countl_one(C);
 // 0xxx is ASCII, handled above. 10xxx is a trailing byte, invalid here.
 // 1xxx is not valid UTF-8 at all, maybe some ISO-8859-*.
 if (LLVM_UNLIKELY(UTF8Length < 2 || UTF8Length > 4)) {

diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 2f94e839768cd..9adbec14b33a0 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -243,10 +243,10 @@ namespace clang {
 };
 
 SVETypeFlags(uint64_t F) : Flags(F) {
-  EltTypeShift = llvm::countTrailingZeros(EltTypeMask);
-  MemEltTypeShift = llvm::countTrailingZeros(MemEltTypeMask);
-  MergeTypeShift = llvm::countTrailingZeros(MergeTypeMask);
-  SplatOperandMaskShift = llvm::countTrailingZeros(SplatOperandMask);
+  EltTypeShift = llvm::countr_zero(EltTypeMask);
+  MemEltTypeShift = llvm::countr_zero(MemEltTypeMask);
+  MergeTypeShift = llvm::countr_zero(MergeTypeMask);
+  SplatOperandMaskShift = llvm::countr_zero(SplatOperandMask);
 }
 
 EltType getEltType() const {

diff  --git a/clang/include/clang/CodeGen/CGFunctionInfo.h 
b/clang/include/clang/CodeGen/CGFunctionInfo.h
index c042bcd9fc5f3..39c7a578c8c4e 100644
--- a/clang/include/clang/CodeGen/CGFunctionInfo.h
+++ b/clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -742,7 +742,7 @@ class CGFunctionInfo final
   /// Set the maximum vector width in the arguments.
   void setMaxVectorWidth(unsigned Width) {
 assert(llvm::isPowerOf2_32(Width) && "Expected power of 2 vector");
-MaxVectorWidth = llvm::countTrailingZeros(Width) + 1;
+MaxVectorWidth = llvm::countr_zero(Width) + 1;
   }
 
   void Profile(llvm::FoldingSetNodeID &ID) {

diff

[clang-tools-extra] 55e2cd1 - Use llvm::count{lr}_{zero,one} (NFC)

2023-01-28 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-28T12:41:20-08:00
New Revision: 55e2cd16095d64e9afca6e109e40ed95d735dc7f

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

LOG: Use llvm::count{lr}_{zero,one} (NFC)

Added: 


Modified: 
clang-tools-extra/clangd/SourceCode.cpp
clang/include/clang/Basic/TargetBuiltins.h
clang/include/clang/CodeGen/CGFunctionInfo.h
clang/lib/AST/Interp/Integral.h
clang/lib/Basic/SourceManager.cpp
clang/lib/Lex/Lexer.cpp
clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
clang/utils/TableGen/SveEmitter.cpp
lld/ELF/Arch/ARM.cpp
lld/ELF/InputFiles.cpp
lld/ELF/SyntheticSections.cpp
lld/ELF/SyntheticSections.h
lld/ELF/Writer.cpp
lld/MachO/SyntheticSections.cpp
lld/MachO/UnwindInfoSection.cpp
lldb/source/Plugins/Instruction/ARM/EmulateInstructionARM.cpp
lldb/source/Symbol/CompactUnwindInfo.cpp
llvm/include/llvm/ADT/APInt.h
llvm/include/llvm/ADT/BitVector.h
llvm/include/llvm/ADT/SmallBitVector.h
llvm/include/llvm/ADT/SparseBitVector.h
llvm/include/llvm/CodeGen/ExecutionDomainFix.h
llvm/include/llvm/CodeGen/TargetRegisterInfo.h
llvm/include/llvm/ExecutionEngine/JITLink/JITLink.h
llvm/include/llvm/Support/ScaledNumber.h
llvm/lib/Analysis/BlockFrequencyInfoImpl.cpp
llvm/lib/Analysis/ValueTracking.cpp
llvm/lib/Analysis/VectorUtils.cpp
llvm/lib/CodeGen/ExecutionDomainFix.cpp
llvm/lib/CodeGen/GlobalISel/CombinerHelper.cpp
llvm/lib/CodeGen/GlobalISel/IRTranslator.cpp
llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
llvm/lib/CodeGen/TargetRegisterInfo.cpp
llvm/lib/DebugInfo/DWARF/DWARFDie.cpp
llvm/lib/Object/ELFObjectFile.cpp
llvm/lib/Object/MachOUniversalWriter.cpp
llvm/lib/Support/APInt.cpp
llvm/lib/Support/ScaledNumber.cpp
llvm/lib/Transforms/IPO/LowerTypeTests.cpp
llvm/lib/Transforms/IPO/WholeProgramDevirt.cpp
llvm/lib/Transforms/InstCombine/InstCombineCompares.cpp
llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp
llvm/lib/Transforms/Scalar/LoopStrengthReduce.cpp
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/tools/llvm-mca/Views/BottleneckAnalysis.cpp
llvm/tools/llvm-mca/Views/ResourcePressureView.cpp
llvm/tools/llvm-objdump/ELFDump.cpp
mlir/lib/Bytecode/Reader/BytecodeReader.cpp

Removed: 




diff  --git a/clang-tools-extra/clangd/SourceCode.cpp 
b/clang-tools-extra/clangd/SourceCode.cpp
index b53e9adeef6aa..d0140a7e0d01b 100644
--- a/clang-tools-extra/clangd/SourceCode.cpp
+++ b/clang-tools-extra/clangd/SourceCode.cpp
@@ -72,7 +72,7 @@ static bool iterateCodepoints(llvm::StringRef U8, const 
Callback &CB) {
   continue;
 }
 // This convenient property of UTF-8 holds for all non-ASCII characters.
-size_t UTF8Length = llvm::countLeadingOnes(C);
+size_t UTF8Length = llvm::countl_one(C);
 // 0xxx is ASCII, handled above. 10xxx is a trailing byte, invalid here.
 // 1xxx is not valid UTF-8 at all, maybe some ISO-8859-*.
 if (LLVM_UNLIKELY(UTF8Length < 2 || UTF8Length > 4)) {

diff  --git a/clang/include/clang/Basic/TargetBuiltins.h 
b/clang/include/clang/Basic/TargetBuiltins.h
index 2f94e839768cd..9adbec14b33a0 100644
--- a/clang/include/clang/Basic/TargetBuiltins.h
+++ b/clang/include/clang/Basic/TargetBuiltins.h
@@ -243,10 +243,10 @@ namespace clang {
 };
 
 SVETypeFlags(uint64_t F) : Flags(F) {
-  EltTypeShift = llvm::countTrailingZeros(EltTypeMask);
-  MemEltTypeShift = llvm::countTrailingZeros(MemEltTypeMask);
-  MergeTypeShift = llvm::countTrailingZeros(MergeTypeMask);
-  SplatOperandMaskShift = llvm::countTrailingZeros(SplatOperandMask);
+  EltTypeShift = llvm::countr_zero(EltTypeMask);
+  MemEltTypeShift = llvm::countr_zero(MemEltTypeMask);
+  MergeTypeShift = llvm::countr_zero(MergeTypeMask);
+  SplatOperandMaskShift = llvm::countr_zero(SplatOperandMask);
 }
 
 EltType getEltType() const {

diff  --git a/clang/include/clang/CodeGen/CGFunctionInfo.h 
b/clang/include/clang/CodeGen/CGFunctionInfo.h
index c042bcd9fc5f3..39c7a578c8c4e 100644
--- a/clang/include/clang/CodeGen/CGFunctionInfo.h
+++ b/clang/include/clang/CodeGen/CGFunctionInfo.h
@@ -742,7 +742,7 @@ class CGFunctionInfo final
   /// Set the maximum vector width in the arguments.
   void setMaxVectorWidth(unsigned Width) {
 assert(llvm::isPowerOf2_32(Width) && "Expected power of 2 vector");
-MaxVectorWidth = llvm::countTrailingZeros(Width) + 1;
+MaxVectorWidth = llvm::countr_zero(Width) + 1;
   }
 
   void Profile(llvm::FoldingSetNodeID &ID) {

diff

[PATCH] D142804: [clang-format] Support clang-format on/off line comments as prefixes

2023-01-28 Thread Alex via Phabricator via cfe-commits
alexolog added inline comments.



Comment at: clang/lib/Format/Format.cpp:3893
 
+bool isClangFormatOn(StringRef Comment) {
+  if (Comment == "/* clang-format on */")

Here's my attempt at something flexible:
Disclaimer: this is my first time looking at the LLVM codebase, so don't expect 
production quality.

```


// Implementation detail, hide in a namespace and/or take out of the header
bool isClangFormatMarked(StringRef Comment, StringRef Mark) {
  // Quick heuristics: minimum length and starts with a slash (comment)
  // Shortest tag: "//clang-format on", 17 characters
  static constexpr StringLiteral clangFormatStr("clang-format ");
  if (Comment.size() < clangFormatStr.size() + 4 || Comment[0] != '/')
return false;

  // check if it's a comment starting with "//" or "/*"
  bool CloseNeeded = false;
  if (Comment[1] == '*')
CloseNeeded = true;
  else if (Comment[1] != '/')
return false;

  // Remove the comment start and all following whitespace
  Comment = Comment.substr(2).ltrim();

  // Check for the actual command, a piece at a time
  if (!Comment.consume_front(clangFormatStr) || !Comment.consume_front(Mark))
return false;

  // Are we there yet?
  if (!CloseNeeded && Comment.empty() ||
  CloseNeeded && Comment.starts_with("*/"))
return true;

  // For a trailer, restrict the next character
  // (currently spaces and tabs, but can include a colon, etc.)
  static constexpr StringLiteral Separator(" \t");
  if (!Separator.contains(Comment[0]))
return false;
  
  // Verify comment is properly terminated
  if (!CloseNeeded || Comment.contains("*/"))
return true;

  return false; // Everything else
}



bool isClangFormatOn(StringRef Comment) {
  return isClangFormatMarked(Comment, "on");
}

bool isClangFormatOff(StringRef Comment) {
  return isClangFormatMarked(Comment, "off");
}



  EXPECT_TRUE(isClangFormatOn("//clang-format on"));
  EXPECT_TRUE(isClangFormatOn("// clang-format on"));
  EXPECT_TRUE(isClangFormatOn("//clang-format on "));
  EXPECT_TRUE(isClangFormatOn("//clang-format on and off"));
  EXPECT_TRUE(isClangFormatOn("/*clang-format on*/"));
  EXPECT_TRUE(isClangFormatOn("/* clang-format on*/"));
  EXPECT_TRUE(isClangFormatOn("/*clang-format on */"));
  EXPECT_TRUE(isClangFormatOn("/*clang-format on*/int i{0};"));

  EXPECT_FALSE(isClangFormatOn("//clang-format  on"));
  EXPECT_FALSE(isClangFormatOn("//clang-format o"));
  EXPECT_FALSE(isClangFormatOn("// clang-format o"));
  EXPECT_FALSE(isClangFormatOn("//clang-format ontario"));
  EXPECT_FALSE(isClangFormatOn("//clang-format off"));
  EXPECT_FALSE(isClangFormatOn("/*clang-format onwards*/"));


```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142804

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


[PATCH] D142804: [clang-format] Support clang-format on/off line comments as prefixes

2023-01-28 Thread Alex via Phabricator via cfe-commits
alexolog added inline comments.



Comment at: clang/lib/Format/Format.cpp:3893
 
+bool isClangFormatOn(StringRef Comment) {
+  if (Comment == "/* clang-format on */")

alexolog wrote:
> Here's my attempt at something flexible:
> Disclaimer: this is my first time looking at the LLVM codebase, so don't 
> expect production quality.
> 
> ```
> 
> 
> // Implementation detail, hide in a namespace and/or take out of the header
> bool isClangFormatMarked(StringRef Comment, StringRef Mark) {
>   // Quick heuristics: minimum length and starts with a slash (comment)
>   // Shortest tag: "//clang-format on", 17 characters
>   static constexpr StringLiteral clangFormatStr("clang-format ");
>   if (Comment.size() < clangFormatStr.size() + 4 || Comment[0] != '/')
> return false;
> 
>   // check if it's a comment starting with "//" or "/*"
>   bool CloseNeeded = false;
>   if (Comment[1] == '*')
> CloseNeeded = true;
>   else if (Comment[1] != '/')
> return false;
> 
>   // Remove the comment start and all following whitespace
>   Comment = Comment.substr(2).ltrim();
> 
>   // Check for the actual command, a piece at a time
>   if (!Comment.consume_front(clangFormatStr) || !Comment.consume_front(Mark))
> return false;
> 
>   // Are we there yet?
>   if (!CloseNeeded && Comment.empty() ||
>   CloseNeeded && Comment.starts_with("*/"))
> return true;
> 
>   // For a trailer, restrict the next character
>   // (currently spaces and tabs, but can include a colon, etc.)
>   static constexpr StringLiteral Separator(" \t");
>   if (!Separator.contains(Comment[0]))
> return false;
>   
>   // Verify comment is properly terminated
>   if (!CloseNeeded || Comment.contains("*/"))
> return true;
> 
>   return false; // Everything else
> }
> 
> 
> 
> bool isClangFormatOn(StringRef Comment) {
>   return isClangFormatMarked(Comment, "on");
> }
> 
> bool isClangFormatOff(StringRef Comment) {
>   return isClangFormatMarked(Comment, "off");
> }
> 
> 
> 
>   EXPECT_TRUE(isClangFormatOn("//clang-format on"));
>   EXPECT_TRUE(isClangFormatOn("// clang-format on"));
>   EXPECT_TRUE(isClangFormatOn("//clang-format on "));
>   EXPECT_TRUE(isClangFormatOn("//clang-format on and off"));
>   EXPECT_TRUE(isClangFormatOn("/*clang-format on*/"));
>   EXPECT_TRUE(isClangFormatOn("/* clang-format on*/"));
>   EXPECT_TRUE(isClangFormatOn("/*clang-format on */"));
>   EXPECT_TRUE(isClangFormatOn("/*clang-format on*/int i{0};"));
> 
>   EXPECT_FALSE(isClangFormatOn("//clang-format  on"));
>   EXPECT_FALSE(isClangFormatOn("//clang-format o"));
>   EXPECT_FALSE(isClangFormatOn("// clang-format o"));
>   EXPECT_FALSE(isClangFormatOn("//clang-format ontario"));
>   EXPECT_FALSE(isClangFormatOn("//clang-format off"));
>   EXPECT_FALSE(isClangFormatOn("/*clang-format onwards*/"));
> 
> 
> ```
Sorry about the "done".  My misunderstanding


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142804

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


[clang] f6b8f05 - Use llvm::byteswap instead of ByteSwap_{16, 32, 64} (NFC)

2023-01-28 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-28T15:22:37-08:00
New Revision: f6b8f05bb399e8f5fd176b2c9dd383cd029467f1

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

LOG: Use llvm::byteswap instead of ByteSwap_{16,32,64} (NFC)

Added: 


Modified: 
clang/lib/Lex/HeaderMap.cpp
lld/COFF/DebugTypes.cpp
lldb/include/lldb/Core/Opcode.h
lldb/source/Core/Opcode.cpp

lldb/source/Plugins/DynamicLoader/Darwin-Kernel/DynamicLoaderDarwinKernel.cpp
lldb/source/Plugins/Instruction/ARM/EmulationStateARM.cpp
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
lldb/source/Symbol/ArmUnwindInfo.cpp
lldb/source/Utility/DataExtractor.cpp
llvm/lib/ExecutionEngine/JITLink/MachO.cpp
llvm/lib/Support/APInt.cpp
llvm/lib/Support/ConvertUTFWrapper.cpp

Removed: 




diff  --git a/clang/lib/Lex/HeaderMap.cpp b/clang/lib/Lex/HeaderMap.cpp
index bb50a4eef65c1..da0b8898f6900 100644
--- a/clang/lib/Lex/HeaderMap.cpp
+++ b/clang/lib/Lex/HeaderMap.cpp
@@ -77,8 +77,8 @@ bool HeaderMapImpl::checkHeader(const llvm::MemoryBuffer 
&File,
   if (Header->Magic == HMAP_HeaderMagicNumber &&
   Header->Version == HMAP_HeaderVersion)
 NeedsByteSwap = false;
-  else if (Header->Magic == llvm::ByteSwap_32(HMAP_HeaderMagicNumber) &&
-   Header->Version == llvm::ByteSwap_16(HMAP_HeaderVersion))
+  else if (Header->Magic == llvm::byteswap(HMAP_HeaderMagicNumber) &&
+   Header->Version == llvm::byteswap(HMAP_HeaderVersion))
 NeedsByteSwap = true;  // Mixed endianness headermap.
   else
 return false;  // Not a header map.
@@ -113,7 +113,7 @@ StringRef HeaderMapImpl::getFileName() const {
 
 unsigned HeaderMapImpl::getEndianAdjustedWord(unsigned X) const {
   if (!NeedsBSwap) return X;
-  return llvm::ByteSwap_32(X);
+  return llvm::byteswap(X);
 }
 
 /// getHeader - Return a reference to the file header, in unbyte-swapped form.

diff  --git a/lld/COFF/DebugTypes.cpp b/lld/COFF/DebugTypes.cpp
index 7bbce84b2d548..95d4e53bb7707 100644
--- a/lld/COFF/DebugTypes.cpp
+++ b/lld/COFF/DebugTypes.cpp
@@ -1021,7 +1021,8 @@ uint32_t GHashTable::insert(COFFLinkerContext &ctx, 
GloballyHashedType ghash,
   // type records are. Swap the byte order for better entropy. A better ghash
   // won't need this.
   uint32_t startIdx =
-  ByteSwap_64(*reinterpret_cast(&ghash)) % tableSize;
+  llvm::byteswap(*reinterpret_cast(&ghash)) %
+  tableSize;
 
   // Do a linear probe starting at startIdx.
   uint32_t idx = startIdx;

diff  --git a/lldb/include/lldb/Core/Opcode.h b/lldb/include/lldb/Core/Opcode.h
index 70f2dbdf639f4..f72f2687b54fe 100644
--- a/lldb/include/lldb/Core/Opcode.h
+++ b/lldb/include/lldb/Core/Opcode.h
@@ -99,7 +99,8 @@ class Opcode {
 case Opcode::eType8:
   return m_data.inst8;
 case Opcode::eType16:
-  return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : 
m_data.inst16;
+  return GetEndianSwap() ? llvm::byteswap(m_data.inst16)
+ : m_data.inst16;
 case Opcode::eType16_2:
   break;
 case Opcode::eType32:
@@ -119,10 +120,12 @@ class Opcode {
 case Opcode::eType8:
   return m_data.inst8;
 case Opcode::eType16:
-  return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : 
m_data.inst16;
+  return GetEndianSwap() ? llvm::byteswap(m_data.inst16)
+ : m_data.inst16;
 case Opcode::eType16_2: // passthrough
 case Opcode::eType32:
-  return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : 
m_data.inst32;
+  return GetEndianSwap() ? llvm::byteswap(m_data.inst32)
+ : m_data.inst32;
 case Opcode::eType64:
   break;
 case Opcode::eTypeBytes:
@@ -138,12 +141,15 @@ class Opcode {
 case Opcode::eType8:
   return m_data.inst8;
 case Opcode::eType16:
-  return GetEndianSwap() ? llvm::ByteSwap_16(m_data.inst16) : 
m_data.inst16;
+  return GetEndianSwap() ? llvm::byteswap(m_data.inst16)
+ : m_data.inst16;
 case Opcode::eType16_2: // passthrough
 case Opcode::eType32:
-  return GetEndianSwap() ? llvm::ByteSwap_32(m_data.inst32) : 
m_data.inst32;
+  return GetEndianSwap() ? llvm::byteswap(m_data.inst32)
+ : m_data.inst32;
 case Opcode::eType64:
-  return GetEndianSwap() ? llvm::ByteSwap_64(m_data.inst64) : 
m_data.inst64;
+  return GetEndianSwap() ? llvm::byteswap(m_data.inst64)
+ : m_data.inst64;
 case Opcode::eTypeBytes:
   break;
 }

diff  --git a/lldb/source/Core/Opcode.cpp b/lldb/source/Core/Opcode.cpp
index a3fc97f95266d..3e30d98975d8a 100644
--- a/lldb/source/Core/Opcode.cpp
+++ b/lldb/source/Core/Opcode.cpp
@@ -103,7 +103,7 @@ uint32_t Opcode::GetDat

[clang] 526966d - Use llvm::bit_ceil (NFC)

2023-01-28 Thread Kazu Hirata via cfe-commits

Author: Kazu Hirata
Date: 2023-01-28T16:13:09-08:00
New Revision: 526966d07dc89ad69940259020d97d25f26b1306

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

LOG: Use llvm::bit_ceil (NFC)

Note that:

  std::has_single_bit(X) ? X : llvm::NextPowerOf2(X);

is equivalent to:

  std::bit_ceil(X)

even for input 0.

Added: 


Modified: 
clang/lib/AST/ASTContext.cpp
clang/lib/CodeGen/TargetInfo.cpp
llvm/lib/Analysis/IVDescriptors.cpp
llvm/lib/Analysis/VectorUtils.cpp
llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
llvm/lib/CodeGen/TargetLoweringBase.cpp
llvm/lib/Transforms/Utils/VNCoercion.cpp
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp

Removed: 




diff  --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 06807ffc4826..9ff1216548c1 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -2502,8 +2502,7 @@ TypeInfo ASTContext::getTypeInfoImpl(const Type *T) const 
{
   // favorable to atomic operations:
 
   // Round the size up to a power of 2.
-  if (!llvm::isPowerOf2_64(Width))
-Width = llvm::NextPowerOf2(Width);
+  Width = llvm::bit_ceil(Width);
 
   // Set the alignment equal to the size.
   Align = static_cast(Width);

diff  --git a/clang/lib/CodeGen/TargetInfo.cpp 
b/clang/lib/CodeGen/TargetInfo.cpp
index a9119abad81d..77db1153e1dd 100644
--- a/clang/lib/CodeGen/TargetInfo.cpp
+++ b/clang/lib/CodeGen/TargetInfo.cpp
@@ -8761,8 +8761,7 @@ ABIArgInfo HexagonABIInfo::classifyArgumentType(QualType 
Ty,
 Align = Size <= 32 ? 32 : 64;
   if (Size <= Align) {
 // Pass in the smallest viable integer type.
-if (!llvm::isPowerOf2_64(Size))
-  Size = llvm::NextPowerOf2(Size);
+Size = llvm::bit_ceil(Size);
 return ABIArgInfo::getDirect(llvm::Type::getIntNTy(getVMContext(), Size));
   }
   return DefaultABIInfo::classifyArgumentType(Ty);
@@ -8807,8 +8806,7 @@ ABIArgInfo HexagonABIInfo::classifyReturnType(QualType 
RetTy) const {
   // are returned indirectly.
   if (Size <= 64) {
 // Return in the smallest viable integer type.
-if (!llvm::isPowerOf2_64(Size))
-  Size = llvm::NextPowerOf2(Size);
+Size = llvm::bit_ceil(Size);
 return ABIArgInfo::getDirect(llvm::Type::getIntNTy(getVMContext(), Size));
   }
   return getNaturalAlignIndirect(RetTy, /*ByVal=*/true);

diff  --git a/llvm/lib/Analysis/IVDescriptors.cpp 
b/llvm/lib/Analysis/IVDescriptors.cpp
index 950541ace9d7..8b9e5c6f56f7 100644
--- a/llvm/lib/Analysis/IVDescriptors.cpp
+++ b/llvm/lib/Analysis/IVDescriptors.cpp
@@ -128,8 +128,7 @@ static std::pair 
computeRecurrenceType(Instruction *Exit,
   ++MaxBitWidth;
 }
   }
-  if (!isPowerOf2_64(MaxBitWidth))
-MaxBitWidth = NextPowerOf2(MaxBitWidth);
+  MaxBitWidth = llvm::bit_ceil(MaxBitWidth);
 
   return std::make_pair(Type::getIntNTy(Exit->getContext(), MaxBitWidth),
 IsSigned);

diff  --git a/llvm/lib/Analysis/VectorUtils.cpp 
b/llvm/lib/Analysis/VectorUtils.cpp
index c96e320fa78a..31c2de15d602 100644
--- a/llvm/lib/Analysis/VectorUtils.cpp
+++ b/llvm/lib/Analysis/VectorUtils.cpp
@@ -772,8 +772,7 @@ llvm::computeMinimumValueSizes(ArrayRef 
Blocks, DemandedBits &DB,
 
 uint64_t MinBW = llvm::bit_width(LeaderDemandedBits);
 // Round up to a power of 2
-if (!isPowerOf2_64((uint64_t)MinBW))
-  MinBW = NextPowerOf2(MinBW);
+MinBW = llvm::bit_ceil(MinBW);
 
 // We don't modify the types of PHIs. Reductions will already have been
 // truncated if possible, and inductions' sizes will have been chosen by

diff  --git a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp 
b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
index 208de4b73d91..429184d64ffb 100644
--- a/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -576,8 +576,7 @@ bool TargetLowering::ShrinkDemandedOp(SDValue Op, unsigned 
BitWidth,
   const TargetLowering &TLI = DAG.getTargetLoweringInfo();
   unsigned DemandedSize = Demanded.getActiveBits();
   unsigned SmallVTBits = DemandedSize;
-  if (!isPowerOf2_32(SmallVTBits))
-SmallVTBits = NextPowerOf2(SmallVTBits);
+  SmallVTBits = llvm::bit_ceil(SmallVTBits);
   for (; SmallVTBits < BitWidth; SmallVTBits = NextPowerOf2(SmallVTBits)) {
 EVT SmallVT = EVT::getIntegerVT(*DAG.getContext(), SmallVTBits);
 if (TLI.isTruncateFree(Op.getValueType(), SmallVT) &&

diff  --git a/llvm/lib/CodeGen/TargetLoweringBase.cpp 
b/llvm/lib/CodeGen/TargetLoweringBase.cpp
index da8b87babc2d..ee621c32f906 100644
--- a/llvm/lib/CodeGen/TargetLoweringBase.cpp
+++ b/llvm/lib/CodeGen/TargetLoweringBase.cpp
@@ -1137,8 +1137,7 @@ static unsigned getVectorTypeBreakdownMVT(MVT VT, MVT 
&IntermediateVT,
   unsigned LaneSizeInBits = N

[clang] 0fd9c37 - [Clang] Treat `std::forward_like` as builtin

2023-01-28 Thread Alexander Shaposhnikov via cfe-commits

Author: Alexander Shaposhnikov
Date: 2023-01-29T00:13:46Z
New Revision: 0fd9c37d8cf20d1ee42263872ab2135265c3ac3d

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

LOG: [Clang] Treat `std::forward_like` as builtin

This diff extends D123345 by adding support for std::forward_like.

Test plan: ninja check-clang check-clang-tools check-llvm

Differential revision: https://reviews.llvm.org/D142430

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/Builtins.def
clang/lib/AST/ExprConstant.cpp
clang/lib/Analysis/BodyFarm.cpp
clang/lib/CodeGen/CGBuiltin.cpp
clang/lib/Sema/SemaChecking.cpp
clang/lib/Sema/SemaDecl.cpp
clang/test/CodeGenCXX/builtin-std-move.cpp
clang/test/SemaCXX/attr-lifetimebound.cpp
clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
clang/test/SemaCXX/builtin-std-move.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 28345f144fd33..4c72ec64f6e19 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -97,6 +97,9 @@ C2x Feature Support
 
 C++ Language Changes in Clang
 -
+- Improved ``-O0`` code generation for calls to ``std::forward_like``. 
Similarly to
+  ``std::move, std::forward`` et al. it is now treated as a compiler builtin 
and implemented
+  directly rather than instantiating the definition from the standard library.
 
 C++20 Feature Support
 ^

diff  --git a/clang/include/clang/Basic/Builtins.def 
b/clang/include/clang/Basic/Builtins.def
index 41f1245564465..6b54ff7c40e82 100644
--- a/clang/include/clang/Basic/Builtins.def
+++ b/clang/include/clang/Basic/Builtins.def
@@ -1565,6 +1565,7 @@ LIBBUILTIN(addressof, "v*v&", "zfncThE", MEMORY, CXX_LANG)
 LANGBUILTIN(__addressof, "v*v&", "zfncTE", CXX_LANG)
 LIBBUILTIN(as_const, "v&v&", "zfncThE", UTILITY, CXX_LANG)
 LIBBUILTIN(forward, "v&v&", "zfncThE", UTILITY, CXX_LANG)
+LIBBUILTIN(forward_like, "v&v&", "zfncThE", UTILITY, CXX_LANG)
 LIBBUILTIN(move, "v&v&", "zfncThE", UTILITY, CXX_LANG)
 LIBBUILTIN(move_if_noexcept, "v&v&", "zfncThE", UTILITY, CXX_LANG)
 

diff  --git a/clang/lib/AST/ExprConstant.cpp b/clang/lib/AST/ExprConstant.cpp
index 912a210fd2545..2a5b5c3520b4d 100644
--- a/clang/lib/AST/ExprConstant.cpp
+++ b/clang/lib/AST/ExprConstant.cpp
@@ -8339,6 +8339,7 @@ bool LValueExprEvaluator::VisitCallExpr(const CallExpr 
*E) {
 return false;
   case Builtin::BIas_const:
   case Builtin::BIforward:
+  case Builtin::BIforward_like:
   case Builtin::BImove:
   case Builtin::BImove_if_noexcept:
 if (cast(E->getCalleeDecl())->isConstexpr())

diff  --git a/clang/lib/Analysis/BodyFarm.cpp b/clang/lib/Analysis/BodyFarm.cpp
index c05534886cb50..b989b8422cfc8 100644
--- a/clang/lib/Analysis/BodyFarm.cpp
+++ b/clang/lib/Analysis/BodyFarm.cpp
@@ -717,6 +717,7 @@ Stmt *BodyFarm::getBody(const FunctionDecl *D) {
 switch (BuiltinID) {
 case Builtin::BIas_const:
 case Builtin::BIforward:
+case Builtin::BIforward_like:
 case Builtin::BImove:
 case Builtin::BImove_if_noexcept:
   FF = create_std_move_forward;

diff  --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index f72e04a425d9f..bf23774c3fe12 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -4674,6 +4674,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl 
GD, unsigned BuiltinID,
   case Builtin::BImove:
   case Builtin::BImove_if_noexcept:
   case Builtin::BIforward:
+  case Builtin::BIforward_like:
   case Builtin::BIas_const:
 return RValue::get(EmitLValue(E->getArg(0)).getPointer(*this));
   case Builtin::BI__GetExceptionInfo: {

diff  --git a/clang/lib/Sema/SemaChecking.cpp b/clang/lib/Sema/SemaChecking.cpp
index ea21171aaac62..d414dcf549f38 100644
--- a/clang/lib/Sema/SemaChecking.cpp
+++ b/clang/lib/Sema/SemaChecking.cpp
@@ -2471,6 +2471,7 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, 
unsigned BuiltinID,
   case Builtin::BIaddressof:
   case Builtin::BI__addressof:
   case Builtin::BIforward:
+  case Builtin::BIforward_like:
   case Builtin::BImove:
   case Builtin::BImove_if_noexcept:
   case Builtin::BIas_const: {

diff  --git a/clang/lib/Sema/SemaDecl.cpp b/clang/lib/Sema/SemaDecl.cpp
index b2ac4173410a8..6740a495a8a27 100644
--- a/clang/lib/Sema/SemaDecl.cpp
+++ b/clang/lib/Sema/SemaDecl.cpp
@@ -9556,6 +9556,7 @@ static bool isStdBuiltin(ASTContext &Ctx, FunctionDecl 
*FD,
   case Builtin::BIaddressof:
   case Builtin::BI__addressof:
   case Builtin::BIforward:
+  case Builtin::BIforward_like:
   case Builtin::BImove:
   case Builtin::BImove_if_noexcept:
   case Builtin::BIas_const: {
@@ -16196,6 +16197,7 @@ void Sema::AddKnownFunctionAttributes(FunctionDecl *FD) 

[PATCH] D142430: [Clang] Treat `std::forward_like` as builtin

2023-01-28 Thread Alexander Shaposhnikov 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 rG0fd9c37d8cf2: [Clang] Treat `std::forward_like` as builtin 
(authored by alexander-shaposhnikov).

Changed prior to commit:
  https://reviews.llvm.org/D142430?vs=491598&id=493042#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142430

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/Builtins.def
  clang/lib/AST/ExprConstant.cpp
  clang/lib/Analysis/BodyFarm.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/test/CodeGenCXX/builtin-std-move.cpp
  clang/test/SemaCXX/attr-lifetimebound.cpp
  clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
  clang/test/SemaCXX/builtin-std-move.cpp

Index: clang/test/SemaCXX/builtin-std-move.cpp
===
--- clang/test/SemaCXX/builtin-std-move.cpp
+++ clang/test/SemaCXX/builtin-std-move.cpp
@@ -43,6 +43,33 @@
 return static_cast(x);
   }
 
+  template  struct is_const { static constexpr bool value = false; };
+  template  struct is_const { static constexpr bool value = true; };
+
+  template  struct conditional { using type = T; };
+  template  struct conditional { using type = F; };
+
+  template 
+  using CopyConst = typename conditional<
+  is_const>::value,
+  const T, T>::type;
+
+  template 
+  using OverrideRef = typename conditional<
+  is_lvalue_reference::value,
+  typename remove_reference::type &,
+  typename remove_reference::type &&>::type;
+
+  template 
+  using ForwardLikeRetType = OverrideRef>;
+
+  template 
+  CONSTEXPR auto forward_like(T &&t) -> ForwardLikeRetType {
+using TT = typename remove_reference::type;
+static_assert(TT::moveable, "instantiated as_const"); // expected-error {{no member named 'moveable' in 'B'}}
+return static_cast>(t);
+  }
+
   template CONSTEXPR const T &as_const(T &x) {
 static_assert(T::moveable, "instantiated as_const"); // expected-error {{no member named 'moveable' in 'B'}}
 return x;
@@ -92,14 +119,15 @@
 B &&(*pMove)(B&) = std::move; // #1 expected-note {{instantiation of}}
 B &&(*pMoveIfNoexcept)(B&) = &std::move_if_noexcept; // #2 expected-note {{instantiation of}}
 B &&(*pForward)(B&) = &std::forward; // #3 expected-note {{instantiation of}}
-const B &(*pAsConst)(B&) = &std::as_const; // #4 expected-note {{instantiation of}}
-B *(*pAddressof)(B&) = &std::addressof; // #5 expected-note {{instantiation of}}
-B *(*pUnderUnderAddressof)(B&) = &std::__addressof; // #6 expected-note {{instantiation of}}
+B &&(*pForwardLike)(B&) = &std::forward_like; // #4 expected-note {{instantiation of}}
+const B &(*pAsConst)(B&) = &std::as_const; // #5 expected-note {{instantiation of}}
+B *(*pAddressof)(B&) = &std::addressof; // #6 expected-note {{instantiation of}}
+B *(*pUnderUnderAddressof)(B&) = &std::__addressof; // #7 expected-note {{instantiation of}}
 int (*pUnrelatedMove)(B, B) = std::move;
 
 struct C {};
-C &&(&rMove)(C&) = std::move; // #7 expected-note {{instantiation of}}
-C &&(&rForward)(C&) = std::forward; // #8 expected-note {{instantiation of}}
+C &&(&rMove)(C&) = std::move; // #8 expected-note {{instantiation of}}
+C &&(&rForward)(C&) = std::forward; // #9 expected-note {{instantiation of}}
 int (&rUnrelatedMove)(B, B) = std::move;
 
 #if __cplusplus <= 201703L
@@ -111,6 +139,7 @@
 // expected-warning@#6 {{non-addressable}}
 // expected-warning@#7 {{non-addressable}}
 // expected-warning@#8 {{non-addressable}}
+// expected-warning@#9 {{non-addressable}}
 #else
 // expected-error@#1 {{non-addressable}}
 // expected-error@#2 {{non-addressable}}
@@ -120,6 +149,7 @@
 // expected-error@#6 {{non-addressable}}
 // expected-error@#7 {{non-addressable}}
 // expected-error@#8 {{non-addressable}}
+// expected-error@#9 {{non-addressable}}
 #endif
 
 void attribute_const() {
@@ -127,6 +157,7 @@
   std::move(n); // expected-warning {{ignoring return value}}
   std::move_if_noexcept(n); // expected-warning {{ignoring return value}}
   std::forward(n); // expected-warning {{ignoring return value}}
+  std::forward_like(n); // expected-warning {{ignoring return value}}
   std::addressof(n); // expected-warning {{ignoring return value}}
   std::__addressof(n); // expected-warning {{ignoring return value}}
   std::as_const(n); // expected-warning {{ignoring return value}}
Index: clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
===
--- clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
+++ clang/test/SemaCXX/builtin-std-move-nobuiltin.cpp
@@ -1,6 +1,6 @@
 // RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=builtin
 // RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=nobuiltin -fno-builtin
-// RUN: %clang_cc1 -std=c++20 -verify %s -DBUILTIN=nobuiltin 

[PATCH] D142569: [WIP][OpenMP] Introduce kernel argument

2023-01-28 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 updated this revision to Diff 493043.
tianshilei1992 added a comment.

rebase and fix bugs


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

Files:
  clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
  llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
  llvm/include/llvm/Frontend/OpenMP/OMPKinds.def
  llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
  llvm/lib/Transforms/IPO/OpenMPOpt.cpp
  openmp/libomptarget/DeviceRTL/CMakeLists.txt
  openmp/libomptarget/DeviceRTL/include/Debug.h
  openmp/libomptarget/DeviceRTL/include/Interface.h
  openmp/libomptarget/DeviceRTL/include/State.h
  openmp/libomptarget/DeviceRTL/src/Configuration.cpp
  openmp/libomptarget/DeviceRTL/src/Debug.cpp
  openmp/libomptarget/DeviceRTL/src/Kernel.cpp
  openmp/libomptarget/DeviceRTL/src/State.cpp
  openmp/libomptarget/include/DeviceEnvironment.h
  openmp/libomptarget/include/Environment.h
  openmp/libomptarget/plugins-nextgen/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
  openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
  openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
  openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
  openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
  openmp/libomptarget/plugins/cuda/src/rtl.cpp

Index: openmp/libomptarget/plugins/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins/cuda/src/rtl.cpp
@@ -23,7 +23,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "omptarget.h"
 #include "omptargetplugin.h"
 
Index: openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
===
--- openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
+++ openmp/libomptarget/plugins/amdgpu/src/rtl.cpp
@@ -37,7 +37,7 @@
 #include "internal.h"
 #include "rt.h"
 
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "get_elf_mach_gfx_name.h"
 #include "omptargetplugin.h"
 #include "print_tracing.h"
Index: openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/generic-elf-64bit/src/rtl.cpp
@@ -17,7 +17,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "GlobalHandler.h"
 #include "PluginInterface.h"
 #include "omptarget.h"
Index: openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
===
--- openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
+++ openmp/libomptarget/plugins-nextgen/cuda/src/rtl.cpp
@@ -17,7 +17,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "GlobalHandler.h"
 #include "PluginInterface.h"
 
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.h
@@ -19,7 +19,7 @@
 #include 
 
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "GlobalHandler.h"
 #include "JIT.h"
 #include "MemoryManager.h"
@@ -627,6 +627,11 @@
 
   /// Map of host pinned allocations used for optimize device transfers.
   PinnedAllocationMapTy PinnedAllocs;
+
+private:
+  /// Return the kernel environment object for kernel \p Name.
+  Expected
+  getKernelEnvironmentForKernel(StringRef Name, DeviceImageTy &Image);
 };
 
 /// Class implementing common functionalities of offload plugins. Each plugin
Index: openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
===
--- openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
+++ openmp/libomptarget/plugins-nextgen/common/PluginInterface/PluginInterface.cpp
@@ -554,32 +554,43 @@
   return Plugin::success();
 }
 
-Expected
-GenericDeviceTy::getExecutionModeForKernel(StringRef Name,
-   DeviceImageTy &Image) {
-  // Create a metadata object for the exec mode global (auto-generated).
-  StaticGlobalTy ExecModeGlobal(Name.data(),
-"_exec_mode");
+Expected
+GenericDeviceTy::getKernelEnvironmentForKernel(StringRef Name,
+   DeviceImageTy &Image) {
+  // Create a metadata object for the kernel environment object.
+  StaticGlobalTy KernelEnv(Name.data(), "_kernel_info");
 
-  // Retrieve execution mode fo

[PATCH] D142569: [WIP][OpenMP] Introduce kernel argument

2023-01-28 Thread Shilei Tian via Phabricator via cfe-commits
tianshilei1992 added inline comments.



Comment at: openmp/libomptarget/plugins/cuda/src/rtl.cpp:26
 #include "Debug.h"
-#include "DeviceEnvironment.h"
+#include "Environment.h"
 #include "omptarget.h"

These changes in old plugins will be gone because the old plugins will be 
removed.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142569

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


[PATCH] D142822: [clang] ASTImporter: Fix importing of va_list types and declarations

2023-01-28 Thread Vince Bridgers via Phabricator via cfe-commits
vabridgers created this revision.
vabridgers added reviewers: aaron.ballman, mizvekov.
Herald added subscribers: carlosgalvezp, martong, kristof.beyls.
Herald added a reviewer: a.sidorin.
Herald added a reviewer: shafik.
Herald added a reviewer: njames93.
Herald added a project: All.
vabridgers requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added projects: clang, clang-tools-extra.

This patch was originally submitted by @mizvekov, then reverted because
it caused crashes on arm and aarch64. This has since been debugged as a
problem in the DontModifyStdNamespaceCheck.cpp tidy checker exposed by
arm and aarch64 architectures defining va_list in the std namespace. The
tidy checker was fixed by excluding the implicit cases. See D136886 
 for
original patch and notes. This patch takes changes from D136886 
, adds
the fix and LIT cases to cover the fix.

Original description from @mizvekov for the base portion of this fix.

This fixes a problem where __va_list_tag was not correctly imported,
possibly leading to multiple definitions with different types.

This adds __va_list_tag to it's proper scope, so that the ASTImporter
can find it.

Crash seen in original fix, addressed by improvements.

$ clang-tidy crash.cpp -checks="cert-dcl58-cpp" --  -target arm
clang-tidy: 
/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:178:

  clang::DiagnosticBuilder clang::tidy::ClangTidyContext::diag(llvm::StringRef,
  clang::SourceLocation, llvm::StringRef, clang::DiagnosticIDs::Level):
  Assertion `Loc.isValid()' failed.

Stack dump:
0.Program arguments: clang-tidy crash.cpp -checks=cert-dcl58-cpp -- -target 
arm
1. parser at end of file
2.ASTMatcher: Processing 'cert-dcl58-cpp' against:
  CXXRecordDecl std::__va_list : <>

- Bound Nodes Begin --- decl - { CXXRecordDecl std::__va_list : <> } nmspc - { NamespaceDecl std : <> }
- Bound Nodes End --- #0 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) 
/llvm/lib/Support/Unix/Signals.inc:567:22 #1 
PrintStackTraceSignalHandler(void*) 
/llvm/lib/Support/Unix/Signals.inc:641:1 ... #9 
clang::tidy::ClangTidyContext::diag(llvm::StringRef, clang::SourceLocation, 
llvm::StringRef, clang::DiagnosticIDs::Level) 
/clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp:179:17 
clang::DiagnosticIDs::Level) 
/clang-tools-extra/clang-tidy/ClangTidyCheck.cpp:27:54 
clang::ast_matchers::MatchFinder::MatchResultconst&) 
/clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp:121:10


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142822

Files:
  clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
  clang-tools-extra/clang-tidy/cert/DontModifyStdNamespaceCheck.cpp
  clang-tools-extra/clang-tidy/utils/RenamerClangTidyCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/cert/dcl58-cpp.cpp
  clang/docs/ReleaseNotes.rst
  clang/lib/Frontend/ASTMerge.cpp
  clang/lib/Sema/Sema.cpp
  clang/test/AST/ast-dump-file-line-json.c
  clang/test/AST/ast-dump-overloaded-operators.cpp
  clang/test/AST/ast-dump-record-definition-data-json.cpp
  clang/test/AST/ast-dump-records-json.cpp
  clang/test/AST/ast-dump-records.cpp
  clang/test/AST/ast-dump-template-decls-json.cpp
  clang/test/AST/ast-dump-traits.cpp
  clang/test/AST/fixed_point.c
  clang/test/AST/float16.cpp
  clang/test/PCH/stmt-openmp_structured_block-bit.cpp
  clang/unittests/AST/ASTImporterTest.cpp

Index: clang/unittests/AST/ASTImporterTest.cpp
===
--- clang/unittests/AST/ASTImporterTest.cpp
+++ clang/unittests/AST/ASTImporterTest.cpp
@@ -7528,7 +7528,14 @@
   }
   )",
   Lang_CXX14);
-  auto *FromFD = FirstDeclMatcher().match(FromTU, fieldDecl());
+
+  auto *FromF = FirstDeclMatcher().match(
+  FromTU, functionDecl(hasName("declToImport")));
+  CXXRecordDecl *FromLambda =
+  cast((cast(FromF->getBody())->body_back()))
+  ->getLambdaClass();
+
+  auto *FromFD = *FromLambda->field_begin();
   ASSERT_TRUE(FromFD);
   ASSERT_TRUE(FromFD->hasCapturedVLAType());
 
@@ -8104,6 +8111,24 @@
   EXPECT_FALSE(SharedStatePtr->isNewDecl(ToBar));
 }
 
+TEST_P(ASTImporterOptionSpecificTestBase, VaList) {
+  Decl *FromTU = getTuDecl(R"(typedef __builtin_va_list va_list;)", Lang_C99);
+
+  auto *FromVaList = FirstDeclMatcher().match(
+  FromTU, typedefDecl(hasName("va_list")));
+  ASSERT_TRUE(FromVaList);
+
+  auto *ToVaList = Import(FromVaList, Lang_C99);
+  ASSERT_TRUE(ToVaList);
+
+  auto *ToBuiltinVaList = FirstDeclMatcher().match(
+  ToAST->getASTContext().getTranslationUnitDecl(),
+  typedefDecl(hasName("__builtin_va_list")));
+
+  ASSERT_TRUE(ToAST->getASTContext().hasSameType(
+  ToVaList->getUnderlyingType(), ToBuiltinVaList->getUnderlyingType()));
+}
+
 INSTANTIATE_TEST_SUITE_P(ParameterizedTests, ASTImporterLookupTableTest,

[PATCH] D142757: [clang][driver] Do not warn about position of `/clang:-xc` in cl mode

2023-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

See https://github.com/llvm/llvm-project/issues/59307#issuecomment-1407529807 I 
think we should just report an error for `/clang:-xc`




Comment at: clang/lib/Driver/Driver.cpp:2571
 // No driver mode exposes -x and /TC or /TP; we don't support mixing them.
 assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed");
   }

```
-assert(!Args.hasArg(options::OPT_x) && "-x and /TC or /TP is not allowed");
+if (auto *A = Args.getLastArg(options::OPT_x))
+  Diag(diag::err_drv_unsupported_opt_with_suggestion)
+  << A->getAsString(Args) << "/TC' or '/TP";
```



Comment at: clang/test/Driver/x-args.c:8
 // CHECK: '-x c++' after last input file has no effect
+//
+// RUN: %clang_cl /WX /clang:-xc /clang:-E /clang:-dM %s 2>&1 | FileCheck 
-check-prefix=CL %s

Delete `//`



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142757

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


[PATCH] D142595: [Driver][AVR] Don't emit default '-Tdata' when a linker script is specified

2023-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay requested changes to this revision.
MaskRay added a comment.
This revision now requires changes to proceed.

This is probably not a good idea. See 
https://github.com/llvm/llvm-project/issues/60203#issuecomment-1407532083


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142595

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


[PATCH] D142823: Intrinsics: Allow tablegen to mark parameters with dereferenceable

2023-01-28 Thread Matt Arsenault via Phabricator via cfe-commits
arsenm created this revision.
arsenm added reviewers: sstefan1, jdoerfert, yaxunl, AMDGPU, nikic, 
alexander-shaposhnikov.
Herald added subscribers: kosarev, StephenFan, kerbowa, jvesely.
Herald added a project: All.
arsenm requested review of this revision.
Herald added a subscriber: wdng.
Herald added a project: LLVM.

Also increases the alignment of llvm.amdgcn.implicitarg.ptr to 8 to
match clang.


https://reviews.llvm.org/D142823

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/test/CodeGenCUDA/amdgpu-workgroup-size.cu
  clang/test/CodeGenCUDA/builtins-amdgcn.cu
  clang/test/CodeGenOpenCL/builtins-amdgcn.cl
  llvm/include/llvm/IR/Intrinsics.td
  llvm/include/llvm/IR/IntrinsicsAMDGPU.td
  llvm/utils/TableGen/CodeGenIntrinsics.h
  llvm/utils/TableGen/CodeGenTarget.cpp
  llvm/utils/TableGen/IntrinsicEmitter.cpp

Index: llvm/utils/TableGen/IntrinsicEmitter.cpp
===
--- llvm/utils/TableGen/IntrinsicEmitter.cpp
+++ llvm/utils/TableGen/IntrinsicEmitter.cpp
@@ -726,6 +726,10 @@
   OS << "  Attribute::get(C, Attribute::Alignment, "
  << Attr.Value << "),\n";
   break;
+case CodeGenIntrinsic::Dereferenceable:
+  OS << "  Attribute::get(C, Attribute::Dereferenceable, "
+ << Attr.Value << "),\n";
+  break;
 }
   }
   OS << "});\n";
Index: llvm/utils/TableGen/CodeGenTarget.cpp
===
--- llvm/utils/TableGen/CodeGenTarget.cpp
+++ llvm/utils/TableGen/CodeGenTarget.cpp
@@ -923,6 +923,10 @@
 unsigned ArgNo = R->getValueAsInt("ArgNo");
 uint64_t Align = R->getValueAsInt("Align");
 addArgAttribute(ArgNo, Alignment, Align);
+  } else if (R->isSubClassOf("Dereferenceable")) {
+unsigned ArgNo = R->getValueAsInt("ArgNo");
+uint64_t Bytes = R->getValueAsInt("Bytes");
+addArgAttribute(ArgNo, Dereferenceable, Bytes);
   } else
 llvm_unreachable("Unknown property!");
 }
Index: llvm/utils/TableGen/CodeGenIntrinsics.h
===
--- llvm/utils/TableGen/CodeGenIntrinsics.h
+++ llvm/utils/TableGen/CodeGenIntrinsics.h
@@ -119,7 +119,8 @@
 WriteOnly,
 ReadNone,
 ImmArg,
-Alignment
+Alignment,
+Dereferenceable
   };
 
   struct ArgAttribute {
Index: llvm/include/llvm/IR/IntrinsicsAMDGPU.td
===
--- llvm/include/llvm/IR/IntrinsicsAMDGPU.td
+++ llvm/include/llvm/IR/IntrinsicsAMDGPU.td
@@ -141,8 +141,10 @@
<"__builtin_amdgcn_workgroup_id">;
 
 def int_amdgcn_dispatch_ptr :
+  ClangBuiltin<"__builtin_amdgcn_dispatch_ptr">,
   DefaultAttrsIntrinsic<[LLVMQualPointerType], [],
-  [Align, IntrNoMem, IntrSpeculatable]>;
+  [Align, Dereferenceable, IntrNoMem,
+   IntrSpeculatable]>;
 
 def int_amdgcn_queue_ptr :
   ClangBuiltin<"__builtin_amdgcn_queue_ptr">,
@@ -157,7 +159,8 @@
 def int_amdgcn_implicitarg_ptr :
   ClangBuiltin<"__builtin_amdgcn_implicitarg_ptr">,
   DefaultAttrsIntrinsic<[LLVMQualPointerType], [],
-  [Align, IntrNoMem, IntrSpeculatable]>;
+  [Align, Dereferenceable,
+   IntrNoMem, IntrSpeculatable]>;
 
 def int_amdgcn_groupstaticsize :
   ClangBuiltin<"__builtin_amdgcn_groupstaticsize">,
Index: llvm/include/llvm/IR/Intrinsics.td
===
--- llvm/include/llvm/IR/Intrinsics.td
+++ llvm/include/llvm/IR/Intrinsics.td
@@ -94,6 +94,11 @@
   int Align = align;
 }
 
+class Dereferenceable : IntrinsicProperty {
+  int ArgNo = idx.Value;
+  int Bytes = bytes;
+}
+
 // Returned - The specified argument is always the return value of the
 // intrinsic.
 class Returned : IntrinsicProperty {
Index: clang/test/CodeGenOpenCL/builtins-amdgcn.cl
===
--- clang/test/CodeGenOpenCL/builtins-amdgcn.cl
+++ clang/test/CodeGenOpenCL/builtins-amdgcn.cl
@@ -516,12 +516,15 @@
 }
 
 // CHECK-LABEL: @test_dispatch_ptr
-// CHECK: call align 4 dereferenceable(64) ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
+// CHECK: call ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
 void test_dispatch_ptr(__constant unsigned char ** out)
 {
   *out = __builtin_amdgcn_dispatch_ptr();
 }
 
+// CHECK: declare align 4 dereferenceable(64) ptr addrspace(4) @llvm.amdgcn.dispatch.ptr()
+
+
 // CHECK-LABEL: @test_queue_ptr
 // CHECK: call ptr addrspace(4) @llvm.amdgcn.queue.ptr()
 void test_queue_ptr(__constant unsigned char ** out)
@@ -543,6 +546,9 @@
   *out = __builtin_amdgcn_implicitarg_ptr();
 }
 
+// CHECK: declare align 8 dereferenceable(256) ptr addrspace(4) @llvm.amdgcn.implicitarg.ptr()
+
+
 // CHECK-LABEL: @test_get_group_id(
 // CHECK: tail call i32 @llvm.amdgcn.workgroup.id.x()
 // CHECK: tail call i32 @llvm.amdgcn.workgroup.id.y()
@@ -583,7 +589,7 @@
 }
 
 // CHECK-LABEL: @test_get_workgroup_size(
-// CHECK: call align 4 dereferenceable

[PATCH] D142688: [Clang][Driver] Handle LoongArch multiarch tuples

2023-01-28 Thread Lu Weining via Phabricator via cfe-commits
SixWeining added inline comments.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:41
 /// so we provide a rough mapping here.
 std::string Linux::getMultiarchTriple(const Driver &D,
   const llvm::Triple &TargetTriple,

Missing test. Perhaps add some in `clang/test/Driver/linux-ld.c` and 
`clang/test/Driver/linux-header-search.cpp`? Or postpone this change until 
loongarch is upstreamed to Debian?



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:93
+
+if (TargetTriple.isGNUEnvironment()) {
+  Libc = "gnu";

Should only check `{GNU|GNUF32|GNUF64}`?



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:95
+  Libc = "gnu";
+} else if (TargetTriple.isMusl()) {
+  Libc = "musl";

Should only check `Triple::Musl`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142688

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


[PATCH] D141892: Implement modernize-use-constraints

2023-01-28 Thread Chris Cotter via Phabricator via cfe-commits
ccotter updated this revision to Diff 493050.
ccotter added a comment.

Rebase + Simplify match logic


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141892

Files:
  clang-tools-extra/clang-tidy/modernize/CMakeLists.txt
  clang-tools-extra/clang-tidy/modernize/ModernizeTidyModule.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.cpp
  clang-tools-extra/clang-tidy/modernize/UseConstraintsCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/docs/clang-tidy/checks/modernize/use-constraints.rst
  
clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints-first-greatergreater.cpp
  clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/modernize/use-constraints.cpp
@@ -0,0 +1,693 @@
+// RUN: %check_clang_tidy -std=c++20 %s modernize-use-constraints %t -- -- -fno-delayed-template-parsing
+
+// NOLINTBEGIN
+namespace std {
+template  struct enable_if { };
+
+template  struct enable_if { typedef T type; };
+
+template 
+using enable_if_t = typename enable_if::type;
+
+} // namespace std
+// NOLINTEND
+
+template 
+struct ConsumeVariadic;
+
+struct Obj {
+};
+
+namespace enable_if_in_return_type {
+
+
+// Section 1: enable_if in return type of function
+
+
+
+// General tests
+
+
+template 
+typename std::enable_if::type basic() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t basic_t() {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}Obj basic_t() requires T::some_value {{{$}}
+
+template 
+auto basic_trailing() -> typename std::enable_if::type {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:26: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}auto basic_trailing() -> Obj requires T::some_value {{{$}}
+
+template 
+typename std::enable_if::type existing_constraint() requires (T::another_value) {
+  return Obj{};
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}typename std::enable_if::type existing_constraint() requires (T::another_value) {{{$}}
+
+template 
+typename std::enable_if::type decl_without_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def();
+
+template 
+typename std::enable_if::type decl_with_separate_def() {
+  return Obj{};
+}
+// FIXME - Support definitions with separate decls
+
+template 
+std::enable_if_t no_dependent_type(U) {
+  return Obj{};
+}
+// FIXME - Support non-dependent enable_ifs. Low priority though...
+
+template 
+typename std::enable_if::type* pointer_of_enable_if() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t* pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int* pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+const std::enable_if_t* const_pointer_of_enable_if_t() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:7: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}const int* const_pointer_of_enable_if_t() requires T::some_value {{{$}}
+
+template 
+std::enable_if_t const * const_pointer_of_enable_if_t2() {
+  return nullptr;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int const * const_pointer_of_enable_if_t2() requires T::some_value {{{$}}
+
+
+template 
+std::enable_if_t& reference_of_enable_if_t() {
+  static int x; return x;
+}
+// CHECK-MESSAGES: :[[@LINE-3]]:1: warning: use C++20 requires constraints instead of enable_if [modernize-use-constraints]
+// CHECK-FIXES: {{^}}template {{$}}
+// CHECK-FIXES-NEXT: {{^}}int& reference_of_enable_

[PATCH] D142595: [Driver][AVR] Don't emit default '-Tdata' when a linker script is specified

2023-01-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added a comment.

In D142595#4088364 , @MaskRay wrote:

> This is probably not a good idea. See 
> https://github.com/llvm/llvm-project/issues/60203#issuecomment-1407532083

I agree with your comment in 
`https://github.com/llvm/llvm-project/issues/60203#issuecomment-1407532083`, 
But I still think my patch is worth to be applied.

Since you mentioned `It's not a problem to have multiple -Tdata=. The last 
wins.` But what will happen if both a linker script and a `-Wl,-Tdata` are 
specified? ASFAIK, the command line option will win.

But the default "-Tdata" is added according to each specific AVR device SRAM 
layout 
(https://github.com/llvm/llvm-project/blob/main/clang/lib/Driver/ToolChains/AVR.cpp#L35).

My opinion is:

1. We should add a default SRAM address to the linker, if user does not specify 
any link options. This is current behaviour of clang's main branch.
2. If the user explictly specifies a linker scrpit, we should follow the user's 
willing, and do not decide the SRAM address for him.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142595

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


[PATCH] D142595: [Driver][AVR] Don't emit default '-Tdata' when a linker script is specified

2023-01-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 updated this revision to Diff 493053.
benshi001 edited the summary of this revision.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142595

Files:
  clang/lib/Driver/ToolChains/AVR.cpp
  clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/avr35.lds
  clang/test/Driver/Inputs/basic_avr_tree/usr/lib/avr/lib/avr51.lds
  clang/test/Driver/avr-ld.c


Index: clang/test/Driver/avr-ld.c
===
--- clang/test/Driver/avr-ld.c
+++ clang/test/Driver/avr-ld.c
@@ -42,3 +42,11 @@
 
 // RUN: %clang -### --target=avr -mmcu=atxmega128a1 --rtlib=libgcc --sysroot 
%S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKO %s
 // LINKO: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega7"}} {{.*}} "-Tdata=0x802000" 
"--start-group" {{.*}} "-latxmega128a1" {{.*}} "--end-group" "-mavrxmega7"
+
+// RUN: %clang -### --target=avr -mmcu=atmega8u2 --sysroot 
%S/Inputs/basic_avr_tree %s -T 
%S/Inputs/basic_avr_tree/usr/lib/avr/lib/avr35.lds 2>&1 | FileCheck 
-check-prefix LINKP %s
+// LINKP: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "--start-group" {{.*}} 
"-latmega8u2" {{.*}} "--end-group" "-T" {{".*avr35.lds"}} "-mavr35"
+// LINKP-NOT: "-Tdata"
+
+// RUN: %clang -### --target=avr --sysroot %S/Inputs/basic_avr_tree %s -T 
%S/Inputs/basic_avr_tree/usr/lib/avr/lib/avr51.lds 2>&1 | FileCheck 
-check-prefix LINKQ %s
+// LINKQ-NOT: "-Tdata"
+// LINKQ-NOT: "warning:" {{.*}} "section address"
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -497,12 +497,17 @@
   D.Diag(diag::warn_drv_avr_stdlib_not_linked);
   }
 
-  if (SectionAddressData) {
-CmdArgs.push_back(Args.MakeArgString(
-"-Tdata=0x" + Twine::utohexstr(*SectionAddressData)));
-  } else {
-// We do not have an entry for this CPU in the address mapping table yet.
-D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) << CPU;
+  // If user explicitly specifies a linker script, we should follow that.
+  // Otherwise we must add a default '-Tdata' option to the linker, according
+  // to each AVR device's specific memory layout.
+  if (!Args.hasArg(options::OPT_T)) {
+if (SectionAddressData) {
+  CmdArgs.push_back(Args.MakeArgString(
+  "-Tdata=0x" + Twine::utohexstr(*SectionAddressData)));
+} else {
+  // We do not have an entry for this CPU in the address mapping table yet.
+  D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) << 
CPU;
+}
   }
 
   // If the family name is known, we can link with the device-specific libgcc.


Index: clang/test/Driver/avr-ld.c
===
--- clang/test/Driver/avr-ld.c
+++ clang/test/Driver/avr-ld.c
@@ -42,3 +42,11 @@
 
 // RUN: %clang -### --target=avr -mmcu=atxmega128a1 --rtlib=libgcc --sysroot %S/Inputs/basic_avr_tree %s 2>&1 | FileCheck -check-prefix LINKO %s
 // LINKO: {{".*ld.*"}} {{.*}} {{"-L.*avrxmega7"}} {{.*}} "-Tdata=0x802000" "--start-group" {{.*}} "-latxmega128a1" {{.*}} "--end-group" "-mavrxmega7"
+
+// RUN: %clang -### --target=avr -mmcu=atmega8u2 --sysroot %S/Inputs/basic_avr_tree %s -T %S/Inputs/basic_avr_tree/usr/lib/avr/lib/avr35.lds 2>&1 | FileCheck -check-prefix LINKP %s
+// LINKP: {{".*ld.*"}} {{.*}} {{"-L.*avr35"}} {{.*}} "--start-group" {{.*}} "-latmega8u2" {{.*}} "--end-group" "-T" {{".*avr35.lds"}} "-mavr35"
+// LINKP-NOT: "-Tdata"
+
+// RUN: %clang -### --target=avr --sysroot %S/Inputs/basic_avr_tree %s -T %S/Inputs/basic_avr_tree/usr/lib/avr/lib/avr51.lds 2>&1 | FileCheck -check-prefix LINKQ %s
+// LINKQ-NOT: "-Tdata"
+// LINKQ-NOT: "warning:" {{.*}} "section address"
Index: clang/lib/Driver/ToolChains/AVR.cpp
===
--- clang/lib/Driver/ToolChains/AVR.cpp
+++ clang/lib/Driver/ToolChains/AVR.cpp
@@ -497,12 +497,17 @@
   D.Diag(diag::warn_drv_avr_stdlib_not_linked);
   }
 
-  if (SectionAddressData) {
-CmdArgs.push_back(Args.MakeArgString(
-"-Tdata=0x" + Twine::utohexstr(*SectionAddressData)));
-  } else {
-// We do not have an entry for this CPU in the address mapping table yet.
-D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) << CPU;
+  // If user explicitly specifies a linker script, we should follow that.
+  // Otherwise we must add a default '-Tdata' option to the linker, according
+  // to each AVR device's specific memory layout.
+  if (!Args.hasArg(options::OPT_T)) {
+if (SectionAddressData) {
+  CmdArgs.push_back(Args.MakeArgString(
+  "-Tdata=0x" + Twine::utohexstr(*SectionAddressData)));
+} else {
+  // We do not have an entry for this CPU in the address mapping table yet.
+  D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) << CPU;

[PATCH] D142595: [Driver][AVR] Don't emit default '-Tdata' when a linker script is specified

2023-01-28 Thread Ben Shi via Phabricator via cfe-commits
benshi001 added inline comments.



Comment at: clang/lib/Driver/ToolChains/AVR.cpp:500
 
-  if (SectionAddressData) {
-CmdArgs.push_back(Args.MakeArgString(
-"-Tdata=0x" + Twine::utohexstr(*SectionAddressData)));
-  } else {
-// We do not have an entry for this CPU in the address mapping table yet.
-D.Diag(diag::warn_drv_avr_linker_section_addresses_not_implemented) << CPU;
+  // If user explicitly specifies a linker script, we should follow that.
+  // Otherwise we must add a default '-Tdata' option to the linker, according

I have added comment about why we need this change, it has nothing to do with 
https://github.com/llvm/llvm-project/issues/60203.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142595

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


[PATCH] D137753: [Clang][AIX][p]Enable -p Functionality

2023-01-28 Thread Michael Francis via Phabricator via cfe-commits
francii updated this revision to Diff 493054.
francii added a comment.

Update based on review


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D137753

Files:
  clang/include/clang/Driver/Options.td
  clang/lib/Driver/ToolChains/AIX.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/test/Driver/aix-ld.c


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6284,7 +6284,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+if (TC.getTriple().isOSAIX()) {
+  CmdArgs.push_back("-pg");
+} else if (!TC.getTriple().isOSOpenBSD()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(options::OPT_pg)) {
+if (Args.hasArg(options::OPT_p, options::OPT_pg)) {
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
"/lib/profiled"));
   CmdArgs.push_back(Args.MakeArgString((llvm::Twine("-L") + D.SysRoot) +
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -4138,6 +4138,7 @@
   MarshallingInfoFlag>;
 def pedantic : Flag<["-", "--"], "pedantic">, Group, 
Flags<[CC1Option,FlangOption,FC1Option]>,
   HelpText<"Warn on language extensions">, 
MarshallingInfoFlag>;
+def p : Flag<["-"], "p">, HelpText<"Enable mcount instrumentation with prof">;
 def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">, 
Flags<[CC1Option]>,
   MarshallingInfoFlag>;
 def pipe : Flag<["-", "--"], "pipe">,
@@ -4184,7 +4185,6 @@
   LangOpts<"POSIXThreads">, DefaultFalse,
   PosFlag,
   NegFlag, BothFlags<[CC1Option]>>;
-def p : Flag<["-"], "p">;
 def pie : Flag<["-"], "pie">, Group;
 def static_pie : Flag<["-"], "static-pie">, Group;
 def read__only__relocs : Separate<["-"], "read_only_relocs">;


Index: clang/test/Driver/aix-ld.c
===
--- clang/test/Driver/aix-ld.c
+++ clang/test/Driver/aix-ld.c
@@ -135,6 +135,8 @@
 // CHECK-LD32-PROF-NOT: "--no-as-needed"
 // CHECK-LD32-PROF-NOT: "-lm"
 // CHECK-LD32-PROF: "-lc"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD32-PROF: "-L[[SYSROOT]]/usr/lib/profiled"
 
 // Check powerpc64-ibm-aix7.1.0.0, 64-bit. Enable profiling.
 // RUN: %clang %s -### 2>&1 \
@@ -162,6 +164,8 @@
 // CHECK-LD64-PROF-NOT: "--no-as-needed"
 // CHECK-LD64-PROF-NOT: "-lm"
 // CHECK-LD64-PROF: "-lc"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/lib/profiled"
+// CHECK-LD64-PROF: "-L[[SYSROOT]]/usr/lib/profiled
 
 // Check powerpc-ibm-aix7.1.0.0, 32-bit. Enable g-profiling.
 // RUN: %clang %s -### 2>&1 \
Index: clang/lib/Driver/ToolChains/Clang.cpp
===
--- clang/lib/Driver/ToolChains/Clang.cpp
+++ clang/lib/Driver/ToolChains/Clang.cpp
@@ -6284,7 +6284,9 @@
 }
   }
   if (Arg *A = Args.getLastArgNoClaim(options::OPT_p)) {
-if (!TC.getTriple().isOSAIX() && !TC.getTriple().isOSOpenBSD()) {
+if (TC.getTriple().isOSAIX()) {
+  CmdArgs.push_back("-pg");
+} else if (!TC.getTriple().isOSOpenBSD()) {
   D.Diag(diag::err_drv_unsupported_opt_for_target)
   << A->getAsString(Args) << TripleStr;
 }
Index: clang/lib/Driver/ToolChains/AIX.cpp
===
--- clang/lib/Driver/ToolChains/AIX.cpp
+++ clang/lib/Driver/ToolChains/AIX.cpp
@@ -271,7 +271,7 @@
 
 CmdArgs.push_back("-lc");
 
-if (Args.hasArg(opt

[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-28 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 493055.

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

https://reviews.llvm.org/D142437

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,36 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember =
+ ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class,
+  /*LookupIndependent=*/true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths) const {
+  CXXBasePaths &Paths,
+  bool LookupIndependent) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -80,9 +82,10 @@
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
-return FindBaseClass(Specifier, Path, BaseDecl);
+return Specifier->getType()->getAsRecordDecl() &&
+   FindBaseClass(Specifier, Path, BaseDecl);
   },
-  Paths);
+  Paths, LookupIndependent);
 }
 
 bool CXXRecord

[PATCH] D142596: [RISCV] Bump Zca, Zcb, Zcd, Zcf version to 1.0.

2023-01-28 Thread Xinlong Wu via Phabricator via cfe-commits
VincentWu added a comment.

LGTM for now )


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142596

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


[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-28 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 493057.

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

https://reviews.llvm.org/D142437

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,36 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember =
+ ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class,
+  /*LookupIndependent=*/true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths) const {
+  CXXBasePaths &Paths,
+  bool LookupIndependent) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -80,9 +82,10 @@
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
-return FindBaseClass(Specifier, Path, BaseDecl);
+return Specifier->getType()->getAsRecordDecl() &&
+   FindBaseClass(Specifier, Path, BaseDecl);
   },
-  Paths);
+  Paths, LookupIndependent);
 }
 
 bool CXXRecord

[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-28 Thread Liming Liu via Phabricator via cfe-commits
lime updated this revision to Diff 493058.

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

https://reviews.llvm.org/D142437

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,36 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember =
+ ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class,
+  /*LookupIndependent=*/true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths) const {
+  CXXBasePaths &Paths,
+  bool LookupIndependent) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -80,9 +82,10 @@
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
-return FindBaseClass(Specifier, Path, BaseDecl);
+return Specifier->getType()->getAsRecordDecl() &&
+   FindBaseClass(Specifier, Path, BaseDecl);
   },
-  Paths);
+  Paths, LookupIndependent);
 }
 
 bool CXXRecord

[PATCH] D142826: [Clang] Add -Wtype-limits to -Wextra for GCC compatibility

2023-01-28 Thread Shivam Gupta via Phabricator via cfe-commits
xgupta created this revision.
xgupta added reviewers: aaron.ballman, dblaikie.
Herald added a project: All.
xgupta requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

GCC added the -Wtype-limits warning group to -Wextra around
GCC 4.4 and the group has some very helpful extra warnings
like tautological comparison type limit warnings
(comparingan unsigned int to see if it's positive, etc).

Fix https://github.com/llvm/llvm-project/issues/58375


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D142826

Files:
  clang/include/clang/Basic/DiagnosticGroups.td


Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [


Index: clang/include/clang/Basic/DiagnosticGroups.td
===
--- clang/include/clang/Basic/DiagnosticGroups.td
+++ clang/include/clang/Basic/DiagnosticGroups.td
@@ -992,6 +992,7 @@
 EmptyInitStatement,
 StringConcatation,
 FUseLdPath,
+TypeLimits,
   ]>;
 
 def Most : DiagGroup<"most", [
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D142688: [Clang][Driver] Handle LoongArch multiarch tuples

2023-01-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/lib/Driver/ToolChains/Linux.cpp:116
+
+return std::string("loongarch64-linux-") + Libc + FPFlavor;
+  }

`return (... + ...).str();` if an operand of `+` is a `Twine`


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142688

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


[PATCH] D142804: [clang-format] Support clang-format on/off line comments as prefixes

2023-01-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/Format.cpp:3893
 
+bool isClangFormatOn(StringRef Comment) {
+  if (Comment == "/* clang-format on */")

alexolog wrote:
> alexolog wrote:
> > Here's my attempt at something flexible:
> > Disclaimer: this is my first time looking at the LLVM codebase, so don't 
> > expect production quality.
> > 
> > ```
> > 
> > 
> > // Implementation detail, hide in a namespace and/or take out of the header
> > bool isClangFormatMarked(StringRef Comment, StringRef Mark) {
> >   // Quick heuristics: minimum length and starts with a slash (comment)
> >   // Shortest tag: "//clang-format on", 17 characters
> >   static constexpr StringLiteral clangFormatStr("clang-format ");
> >   if (Comment.size() < clangFormatStr.size() + 4 || Comment[0] != '/')
> > return false;
> > 
> >   // check if it's a comment starting with "//" or "/*"
> >   bool CloseNeeded = false;
> >   if (Comment[1] == '*')
> > CloseNeeded = true;
> >   else if (Comment[1] != '/')
> > return false;
> > 
> >   // Remove the comment start and all following whitespace
> >   Comment = Comment.substr(2).ltrim();
> > 
> >   // Check for the actual command, a piece at a time
> >   if (!Comment.consume_front(clangFormatStr) || 
> > !Comment.consume_front(Mark))
> > return false;
> > 
> >   // Are we there yet?
> >   if (!CloseNeeded && Comment.empty() ||
> >   CloseNeeded && Comment.starts_with("*/"))
> > return true;
> > 
> >   // For a trailer, restrict the next character
> >   // (currently spaces and tabs, but can include a colon, etc.)
> >   static constexpr StringLiteral Separator(" \t");
> >   if (!Separator.contains(Comment[0]))
> > return false;
> >   
> >   // Verify comment is properly terminated
> >   if (!CloseNeeded || Comment.contains("*/"))
> > return true;
> > 
> >   return false; // Everything else
> > }
> > 
> > 
> > 
> > bool isClangFormatOn(StringRef Comment) {
> >   return isClangFormatMarked(Comment, "on");
> > }
> > 
> > bool isClangFormatOff(StringRef Comment) {
> >   return isClangFormatMarked(Comment, "off");
> > }
> > 
> > 
> > 
> >   EXPECT_TRUE(isClangFormatOn("//clang-format on"));
> >   EXPECT_TRUE(isClangFormatOn("// clang-format on"));
> >   EXPECT_TRUE(isClangFormatOn("//clang-format on "));
> >   EXPECT_TRUE(isClangFormatOn("//clang-format on and off"));
> >   EXPECT_TRUE(isClangFormatOn("/*clang-format on*/"));
> >   EXPECT_TRUE(isClangFormatOn("/* clang-format on*/"));
> >   EXPECT_TRUE(isClangFormatOn("/*clang-format on */"));
> >   EXPECT_TRUE(isClangFormatOn("/*clang-format on*/int i{0};"));
> > 
> >   EXPECT_FALSE(isClangFormatOn("//clang-format  on"));
> >   EXPECT_FALSE(isClangFormatOn("//clang-format o"));
> >   EXPECT_FALSE(isClangFormatOn("// clang-format o"));
> >   EXPECT_FALSE(isClangFormatOn("//clang-format ontario"));
> >   EXPECT_FALSE(isClangFormatOn("//clang-format off"));
> >   EXPECT_FALSE(isClangFormatOn("/*clang-format onwards*/"));
> > 
> > 
> > ```
> Sorry about the "done".  My misunderstanding
> Here's my attempt at something flexible:
> Disclaimer: this is my first time looking at the LLVM codebase, so don't 
> expect production quality.

Thanks! If we didn't have to worry about regressions, we might want to do 
something like what you suggested above.



Comment at: clang/lib/Format/Format.cpp:3901
+  return Comment.startswith(Prefix) &&
+ (Comment.size() == Size || isblank(Comment[Size]));
+}

HazardyKnusperkeks wrote:
> rymiel wrote:
> > Should the space be required? What about `// clang-format off: reasoning` 
> > or similar?
> > 
> > Also, should this be documented?
> > Should the space be required? What about `// clang-format off: reasoning` 
> > or similar?
> > 
> > Also, should this be documented?
> 
> +1
> Should the space be required? What about `// clang-format off: reasoning` or 
> similar?

On second thought, we should make it more restrictive to avoid regressions. How 
about //requiring// a colon, i.e. `// clang-format off:` (but not `// 
clang-format off :`)?
 
> Also, should this be documented?

Yep.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142804

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


[clang] 01adf96 - [clang] Add the check of membership in decltype for the issue #58674

2023-01-28 Thread Liming Liu via cfe-commits

Author: Liming Liu
Date: 2023-01-29T13:44:19+08:00
New Revision: 01adf96ebc8608bcdda0cacc303035b2e60ccb46

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

LOG: [clang] Add the check of membership in decltype for the issue #58674

D137531 had once fixed the issue. However, it caused a crash during compiling
llvm/unittests/IR/PatternMatch.cpp in stage-2. The reason is the predicator
isDerivedFrom does not consider independent types if the derived type is
dependent.

This patch improves D137531 by adding an option to make isDerivedFrom consider
independent types.

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/CXXInheritance.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/decltype.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 4c72ec64f6e19..a73a750cbe305 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -57,6 +57,9 @@ Bug Fixes
 - Fix crash on invalid code when looking up a destructor in a templated class
   inside a namespace. This fixes
   `Issue 59446 `_.
+- Fix an issue about ``decltype`` in the members of class templates derived 
from
+  templates with related parameters. This fixes
+  `Issue 58674 `_.
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 11276c77490ce..30200a1785a3f 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1547,7 +1547,8 @@ class CXXRecordDecl : public RecordDecl {
   /// \param Base the base class we are searching for.
   ///
   /// \returns true if this class is derived from Base, false otherwise.
-  bool isDerivedFrom(const CXXRecordDecl *Base) const;
+  bool isDerivedFrom(const CXXRecordDecl *Base,
+ bool LookupIndependent = false) const;
 
   /// Determine whether this class is derived from the type \p Base.
   ///
@@ -1565,7 +1566,8 @@ class CXXRecordDecl : public RecordDecl {
   ///
   /// \todo add a separate parameter to configure IsDerivedFrom, rather than
   /// tangling input and output in \p Paths
-  bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const;
+  bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths,
+ bool LookupIndependent = false) const;
 
   /// Determine whether this class is virtually derived from
   /// the class \p Base.

diff  --git a/clang/lib/AST/CXXInheritance.cpp 
b/clang/lib/AST/CXXInheritance.cpp
index 1abbe8139ae99..175e461787fdf 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@ void CXXBasePaths::swap(CXXBasePaths &Other) {
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths) const {
+  CXXBasePaths &Paths,
+  bool LookupIndependent) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -80,9 +82,10 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
-return FindBaseClass(Specifier, Path, BaseDecl);
+return Specifier->getType()->getAsRecordDecl() &&
+   FindBaseClass(Specifier, Path, BaseDecl);
   },
-  Paths);
+  Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index 2842add2cc4af..b7c62f5375e42 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,36 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in a

[PATCH] D142437: [clang] Add the check of membership in decltype for the issue #58674

2023-01-28 Thread Liming Liu 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 rG01adf96ebc86: [clang] Add the check of membership in 
decltype for the issue #58674 (authored by lime).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142437

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/DeclCXX.h
  clang/lib/AST/CXXInheritance.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/test/SemaCXX/decltype.cpp

Index: clang/test/SemaCXX/decltype.cpp
===
--- clang/test/SemaCXX/decltype.cpp
+++ clang/test/SemaCXX/decltype.cpp
@@ -101,6 +101,44 @@
   template void foo(decltype(T(LP1{ .p1 = g1, .p1.x[1] = 'x' }))) {}
 }
 
+namespace GH58674 {
+  struct Foo {
+float value_;
+struct nested {
+  float value_;
+};
+  };
+
+  template 
+  struct TemplateFoo {
+float value_;
+  };
+
+  float bar;
+
+  template 
+  struct Animal{};
+
+  template 
+  class Cat : Animal {
+using okay = decltype(Foo::value_);
+using also_okay = decltype(bar);
+using okay2 = decltype(Foo::nested::value_);
+using okay3 = decltype(TemplateFoo::value_);
+  public:
+void meow() {
+  using okay = decltype(Foo::value_);
+  using also_okay = decltype(bar);
+  using okay2 = decltype(Foo::nested::value_);
+  using okay3 = decltype(TemplateFoo::value_);
+}
+  };
+
+  void baz() {
+  Cat{}.meow();
+  }
+}
+
 template
 class conditional {
 };
Index: clang/lib/Sema/SemaExpr.cpp
===
--- clang/lib/Sema/SemaExpr.cpp
+++ clang/lib/Sema/SemaExpr.cpp
@@ -2693,20 +2693,36 @@
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
+  //
+  // We also don't need to do this if R resolved to a member in another
+  // class, which can happen in an unevaluated operand:
+  //
+  // C++ [expr.prim.id]p3.3:
+  //   If that id-expression denotes a non-static data member and it
+  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember;
-if (!IsAddressOfOperand)
-  MightBeImplicitMember = true;
-else if (!SS.isEmpty())
-  MightBeImplicitMember = false;
-else if (R.isOverloadedResult())
-  MightBeImplicitMember = false;
-else if (R.isUnresolvableResult())
-  MightBeImplicitMember = true;
-else
-  MightBeImplicitMember = isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl()) ||
-  isa(R.getFoundDecl());
+bool MightBeImplicitMember = true, CheckField = true;
+if (IsAddressOfOperand) {
+  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
+  CheckField = !R.isUnresolvableResult();
+}
+if (MightBeImplicitMember && CheckField) {
+  if (R.isSingleResult() &&
+  isa(R.getFoundDecl())) {
+auto Class = cast((*R.begin())->getDeclContext());
+for (auto Curr = S->getLookupEntity(); Curr && !Curr->isFileContext();
+ Curr = Curr->getParent()) {
+  if (auto ThisClass = dyn_cast_if_present(Curr)) {
+if ((MightBeImplicitMember =
+ ThisClass->Equals(Class) ||
+ ThisClass->isDerivedFrom(Class,
+  /*LookupIndependent=*/true)))
+  break;
+  }
+}
+  } else if (IsAddressOfOperand)
+MightBeImplicitMember = false;
+}
 
 if (MightBeImplicitMember)
   return BuildPossibleImplicitMemberExpr(SS, TemplateKWLoc,
Index: clang/lib/AST/CXXInheritance.cpp
===
--- clang/lib/AST/CXXInheritance.cpp
+++ clang/lib/AST/CXXInheritance.cpp
@@ -64,14 +64,16 @@
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
+  bool LookupIndependent) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths);
+  return isDerivedFrom(Base, Paths, LookupIndependent);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths) const {
+  CXXBasePaths &Paths,
+  bool LookupIndependent) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -80,9 +82,10 @@
   const CXXRecordDecl *BaseDecl = Base->getCanonicalDecl();
   return lookupInBases(
   [BaseDecl](const CXXBaseSpecifier *Specifier, CXXBasePath &Path) {
-

[clang] 3d7a59b - [RISCV] Bump Zca, Zcb, Zcd, Zcf version to 1.0.

2023-01-28 Thread Craig Topper via cfe-commits

Author: Craig Topper
Date: 2023-01-28T22:04:34-08:00
New Revision: 3d7a59bdc0850fee0ad31686f038ae5abf88b7f2

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

LOG: [RISCV] Bump Zca, Zcb, Zcd, Zcf version to 1.0.

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

Added: 


Modified: 
clang/test/Driver/riscv-arch.c
clang/test/Preprocessor/riscv-target-features.c
llvm/docs/RISCVUsage.rst
llvm/docs/ReleaseNotes.rst
llvm/lib/Support/RISCVISAInfo.cpp
llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
llvm/test/CodeGen/RISCV/attributes.ll
llvm/test/MC/RISCV/attribute-arch.s

Removed: 




diff  --git a/clang/test/Driver/riscv-arch.c b/clang/test/Driver/riscv-arch.c
index cf38a3c07051a..26a58418fe457 100644
--- a/clang/test/Driver/riscv-arch.c
+++ b/clang/test/Driver/riscv-arch.c
@@ -430,9 +430,9 @@
 // RUN: %clang --target=riscv32-unknown-elf -march=rv32izca0p1 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck -check-prefix=RV32-EXPERIMENTAL-BADVERS 
%s
 // RV32-EXPERIMENTAL-BADVERS: error: invalid arch name 'rv32izca0p1'
-// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension 'zca' (this compiler supports 0.70)
+// RV32-EXPERIMENTAL-BADVERS: unsupported version number 0.1 for experimental 
extension 'zca' (this compiler supports 1.0)
 
-// RUN: %clang --target=riscv32-unknown-elf -march=rv32izca0p70 
-menable-experimental-extensions -### %s \
+// RUN: %clang --target=riscv32-unknown-elf -march=rv32izca1p0 
-menable-experimental-extensions -### %s \
 // RUN: -fsyntax-only 2>&1 | FileCheck 
-check-prefix=RV32-EXPERIMENTAL-GOODVERS %s
 // RV32-EXPERIMENTAL-GOODVERS: "-target-feature" "+experimental-zca"
 

diff  --git a/clang/test/Preprocessor/riscv-target-features.c 
b/clang/test/Preprocessor/riscv-target-features.c
index 2e264369e1bff..e312ea0781911 100644
--- a/clang/test/Preprocessor/riscv-target-features.c
+++ b/clang/test/Preprocessor/riscv-target-features.c
@@ -466,25 +466,25 @@
 // RUN: -o - | FileCheck --check-prefix=CHECK-XTHEADVDOT-EXT %s
 // CHECK-XTHEADVDOT-EXT: __riscv_xtheadvdot 100{{$}}
 
-// RUN: %clang -target riscv32 -march=rv32izca0p70 
-menable-experimental-extensions \
+// RUN: %clang -target riscv32 -march=rv32izca1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCA-EXT %s
-// RUN: %clang -target riscv64 -march=rv64izca0p70 
-menable-experimental-extensions \
+// RUN: %clang -target riscv64 -march=rv64izca1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCA-EXT %s
-// CHECK-ZCA-EXT: __riscv_zca 7{{$}}
+// CHECK-ZCA-EXT: __riscv_zca 100{{$}}
 
-// RUN: %clang -target riscv32 -march=rv32izcb0p70 
-menable-experimental-extensions \
+// RUN: %clang -target riscv32 -march=rv32izcb1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCB-EXT %s
-// RUN: %clang -target riscv64 -march=rv64izcb0p70 
-menable-experimental-extensions \
+// RUN: %clang -target riscv64 -march=rv64izcb1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCB-EXT %s
-// CHECK-ZCB-EXT: __riscv_zca 7{{$}}
-// CHECK-ZCB-EXT: __riscv_zcb 7{{$}}
+// CHECK-ZCB-EXT: __riscv_zca 100{{$}}
+// CHECK-ZCB-EXT: __riscv_zcb 100{{$}}
 
-// RUN: %clang -target riscv32 -march=rv32izcd0p70 
-menable-experimental-extensions \
+// RUN: %clang -target riscv32 -march=rv32izcd1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCD-EXT %s
-// RUN: %clang -target riscv64 -march=rv64izcd0p70 
-menable-experimental-extensions \
+// RUN: %clang -target riscv64 -march=rv64izcd1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCD-EXT %s
-// CHECK-ZCD-EXT: __riscv_zcd 7{{$}}
+// CHECK-ZCD-EXT: __riscv_zcd 100{{$}}
 
-// RUN: %clang -target riscv32 -march=rv32izcf0p70 
-menable-experimental-extensions \
+// RUN: %clang -target riscv32 -march=rv32izcf1p0 
-menable-experimental-extensions \
 // RUN: -x c -E -dM %s -o - | FileCheck --check-prefix=CHECK-ZCF-EXT %s
-// CHECK-ZCF-EXT: __riscv_zcf 7{{$}}
+// CHECK-ZCF-EXT: __riscv_zcf 100{{$}}

diff  --git a/llvm/docs/RISCVUsage.rst b/llvm/docs/RISCVUsage.rst
index 18d848a174358..58a24cea30885 100644
--- a/llvm/docs/RISCVUsage.rst
+++ b/llvm/docs/RISCVUsage.rst
@@ -136,13 +136,13 @@ The primary goal of experimental support is to assist in 
the process of ratifica
   LLVM implements the `1.0-rc3 draft specification 
`_.  
Note that have been backwards incompatible changes made b

[PATCH] D142596: [RISCV] Bump Zca, Zcb, Zcd, Zcf version to 1.0.

2023-01-28 Thread Craig Topper via Phabricator via cfe-commits
This revision was not accepted when it landed; it landed in state "Needs 
Review".
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3d7a59bdc085: [RISCV] Bump Zca, Zcb, Zcd, Zcf version to 
1.0. (authored by craig.topper).

Changed prior to commit:
  https://reviews.llvm.org/D142596?vs=492810&id=493067#toc

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D142596

Files:
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/docs/RISCVUsage.rst
  llvm/docs/ReleaseNotes.rst
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/MC/RISCV/attribute-arch.s

Index: llvm/test/MC/RISCV/attribute-arch.s
===
--- llvm/test/MC/RISCV/attribute-arch.s
+++ llvm/test/MC/RISCV/attribute-arch.s
@@ -176,11 +176,17 @@
 .attribute arch, "rv32if_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
 # CHECK: attribute  5, "rv32i2p0_f2p0_zkt1p0_zve32f1p0_zve32x1p0_zvl32b1p0"
 
-.attribute arch, "rv32izca0p70"
-# CHECK: attribute  5, "rv32i2p0_zca0p70"
+.attribute arch, "rv32izca1p0"
+# CHECK: attribute  5, "rv32i2p0_zca1p0"
 
-.attribute arch, "rv32izcb0p70"
-# CHECK: attribute  5, "rv32i2p0_zca0p70_zcb0p70"
+.attribute arch, "rv32izcd1p0"
+# CHECK: attribute  5, "rv32i2p0_zcd1p0"
+
+.attribute arch, "rv32izcf1p0"
+# CHECK: attribute  5, "rv32i2p0_zcf1p0"
+
+.attribute arch, "rv32izcb1p0"
+# CHECK: attribute  5, "rv32i2p0_zca1p0_zcb1p0"
 
 .attribute arch, "rv32izawrs1p0"
 # CHECK: attribute  5, "rv32i2p0_zawrs1p0"
Index: llvm/test/CodeGen/RISCV/attributes.ll
===
--- llvm/test/CodeGen/RISCV/attributes.ll
+++ llvm/test/CodeGen/RISCV/attributes.ll
@@ -42,6 +42,8 @@
 ; RUN: llc -mtriple=riscv32 -mattr=+svinval %s -o - | FileCheck --check-prefix=RV32SVINVAL %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zca %s -o - | FileCheck --check-prefix=RV32ZCA %s
 ; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefix=RV32ZCB %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefix=RV32ZCD %s
+; RUN: llc -mtriple=riscv32 -mattr=+experimental-zcf %s -o - | FileCheck --check-prefix=RV32ZCF %s
 
 ; RUN: llc -mtriple=riscv64 -mattr=+m %s -o - | FileCheck --check-prefix=RV64M %s
 ; RUN: llc -mtriple=riscv64 -mattr=+zmmul %s -o - | FileCheck --check-prefix=RV64ZMMUL %s
@@ -89,6 +91,7 @@
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-ztso %s -o - | FileCheck --check-prefix=RV64ZTSO %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zca %s -o - | FileCheck --check-prefix=RV64ZCA %s
 ; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcb %s -o - | FileCheck --check-prefix=RV64ZCB %s
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-zcd %s -o - | FileCheck --check-prefix=RV64ZCD %s
 
 ; RV32M: .attribute 5, "rv32i2p0_m2p0"
 ; RV32ZMMUL: .attribute 5, "rv32i2p0_zmmul1p0"
@@ -130,8 +133,10 @@
 ; RV32SVNAPOT: .attribute 5, "rv32i2p0_svnapot1p0"
 ; RV32SVPBMT: .attribute 5, "rv32i2p0_svpbmt1p0"
 ; RV32SVINVAL: .attribute 5, "rv32i2p0_svinval1p0"
-; RV32ZCA: .attribute 5, "rv32i2p0_zca0p70"
-; RV32ZCB: .attribute 5, "rv32i2p0_zca0p70_zcb0p70"
+; RV32ZCA: .attribute 5, "rv32i2p0_zca1p0"
+; RV32ZCB: .attribute 5, "rv32i2p0_zca1p0_zcb1p0"
+; RV32ZCD: .attribute 5, "rv32i2p0_zcd1p0"
+; RV32ZCF: .attribute 5, "rv32i2p0_zcf1p0"
 
 ; RV64M: .attribute 5, "rv64i2p0_m2p0"
 ; RV64ZMMUL: .attribute 5, "rv64i2p0_zmmul1p0"
@@ -177,8 +182,9 @@
 ; RV64XVENTANACONDOPS: .attribute 5, "rv64i2p0_xventanacondops1p0"
 ; RV64XTHEADVDOT: .attribute 5, "rv64i2p0_f2p0_d2p0_v1p0_zve32f1p0_zve32x1p0_zve64d1p0_zve64f1p0_zve64x1p0_zvl128b1p0_zvl32b1p0_zvl64b1p0_xtheadvdot1p0"
 ; RV64ZTSO: .attribute 5, "rv64i2p0_ztso0p1"
-; RV64ZCA: .attribute 5, "rv64i2p0_zca0p70"
-; RV64ZCB: .attribute 5, "rv64i2p0_zca0p70_zcb0p70"
+; RV64ZCA: .attribute 5, "rv64i2p0_zca1p0"
+; RV64ZCB: .attribute 5, "rv64i2p0_zca1p0_zcb1p0"
+; RV64ZCD: .attribute 5, "rv64i2p0_zcd1p0"
 
 define i32 @addi(i32 %a) {
   %1 = add i32 %a, 1
Index: llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
===
--- llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
+++ llvm/lib/Target/RISCV/RISCVInstrInfoZc.td
@@ -7,7 +7,7 @@
 //===--===//
 ///
 /// This file describes the RISC-V instructions from the 'Zc*' compressed
-/// instruction extensions, version 0.70.4.
+/// instruction extensions, version 1.0.1.
 /// This version is still experimental as the 'Zc*' extensions haven't been
 /// ratified yet.
 ///
Index: llvm/lib/Support/RISCVISAInfo.cpp
===
---

[clang] d6d29dc - Revert commit 01adf96ebc86 because it caused "Unhandled DeclRefExpr" errors.

2023-01-28 Thread Liming Liu via cfe-commits

Author: Liming Liu
Date: 2023-01-29T14:37:13+08:00
New Revision: d6d29dc4fa9cbb6d4d5622f9fea4697669edf214

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

LOG: Revert commit 01adf96ebc86 because it caused "Unhandled DeclRefExpr" 
errors.

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/AST/DeclCXX.h
clang/lib/AST/CXXInheritance.cpp
clang/lib/Sema/SemaExpr.cpp
clang/test/SemaCXX/decltype.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index a73a750cbe305..4c72ec64f6e19 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -57,9 +57,6 @@ Bug Fixes
 - Fix crash on invalid code when looking up a destructor in a templated class
   inside a namespace. This fixes
   `Issue 59446 `_.
-- Fix an issue about ``decltype`` in the members of class templates derived 
from
-  templates with related parameters. This fixes
-  `Issue 58674 `_.
 
 Improvements to Clang's diagnostics
 ^^^

diff  --git a/clang/include/clang/AST/DeclCXX.h 
b/clang/include/clang/AST/DeclCXX.h
index 30200a1785a3f..11276c77490ce 100644
--- a/clang/include/clang/AST/DeclCXX.h
+++ b/clang/include/clang/AST/DeclCXX.h
@@ -1547,8 +1547,7 @@ class CXXRecordDecl : public RecordDecl {
   /// \param Base the base class we are searching for.
   ///
   /// \returns true if this class is derived from Base, false otherwise.
-  bool isDerivedFrom(const CXXRecordDecl *Base,
- bool LookupIndependent = false) const;
+  bool isDerivedFrom(const CXXRecordDecl *Base) const;
 
   /// Determine whether this class is derived from the type \p Base.
   ///
@@ -1566,8 +1565,7 @@ class CXXRecordDecl : public RecordDecl {
   ///
   /// \todo add a separate parameter to configure IsDerivedFrom, rather than
   /// tangling input and output in \p Paths
-  bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths,
- bool LookupIndependent = false) const;
+  bool isDerivedFrom(const CXXRecordDecl *Base, CXXBasePaths &Paths) const;
 
   /// Determine whether this class is virtually derived from
   /// the class \p Base.

diff  --git a/clang/lib/AST/CXXInheritance.cpp 
b/clang/lib/AST/CXXInheritance.cpp
index 175e461787fdf..25de2a20a7f3b 100644
--- a/clang/lib/AST/CXXInheritance.cpp
+++ b/clang/lib/AST/CXXInheritance.cpp
@@ -64,16 +64,14 @@ void CXXBasePaths::swap(CXXBasePaths &Other) {
   std::swap(DetectedVirtual, Other.DetectedVirtual);
 }
 
-bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  bool LookupIndependent) const {
+bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base) const {
   CXXBasePaths Paths(/*FindAmbiguities=*/false, /*RecordPaths=*/false,
  /*DetectVirtual=*/false);
-  return isDerivedFrom(Base, Paths, LookupIndependent);
+  return isDerivedFrom(Base, Paths);
 }
 
 bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
-  CXXBasePaths &Paths,
-  bool LookupIndependent) const {
+  CXXBasePaths &Paths) const {
   if (getCanonicalDecl() == Base->getCanonicalDecl())
 return false;
 
@@ -85,7 +83,7 @@ bool CXXRecordDecl::isDerivedFrom(const CXXRecordDecl *Base,
 return Specifier->getType()->getAsRecordDecl() &&
FindBaseClass(Specifier, Path, BaseDecl);
   },
-  Paths, LookupIndependent);
+  Paths);
 }
 
 bool CXXRecordDecl::isVirtuallyDerivedFrom(const CXXRecordDecl *Base) const {

diff  --git a/clang/lib/Sema/SemaExpr.cpp b/clang/lib/Sema/SemaExpr.cpp
index b7c62f5375e42..2842add2cc4af 100644
--- a/clang/lib/Sema/SemaExpr.cpp
+++ b/clang/lib/Sema/SemaExpr.cpp
@@ -2693,36 +2693,20 @@ Sema::ActOnIdExpression(Scope *S, CXXScopeSpec &SS,
   // to get this right here so that we don't end up making a
   // spuriously dependent expression if we're inside a dependent
   // instance method.
-  //
-  // We also don't need to do this if R resolved to a member in another
-  // class, which can happen in an unevaluated operand:
-  //
-  // C++ [expr.prim.id]p3.3:
-  //   If that id-expression denotes a non-static data member and it
-  //   appears in an unevaluated operand.
   if (!R.empty() && (*R.begin())->isCXXClassMember()) {
-bool MightBeImplicitMember = true, CheckField = true;
-if (IsAddressOfOperand) {
-  MightBeImplicitMember = SS.isEmpty() && !R.isOverloadedResult();
-  CheckField = !R.isUnresolvableResult();
-}
-if (MightBeImplicitMember && CheckField) {
-  if (R.isSingleResult() &&
-  isa(R.getFoundDecl())) 
{
-

[PATCH] D142804: [clang-format] Support clang-format on/off line comments as prefixes

2023-01-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan updated this revision to Diff 493069.
owenpan added a comment.

Only allows `:` as the first character after `// clang-format on` or `// 
clang-format off`.


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

https://reviews.llvm.org/D142804

Files:
  clang/docs/ClangFormatStyleOptions.rst
  clang/include/clang/Format/Format.h
  clang/lib/Format/Format.cpp
  clang/lib/Format/FormatTokenLexer.cpp
  clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
  clang/lib/Format/SortJavaScriptImports.cpp
  clang/unittests/Format/FormatTest.cpp

Index: clang/unittests/Format/FormatTest.cpp
===
--- clang/unittests/Format/FormatTest.cpp
+++ clang/unittests/Format/FormatTest.cpp
@@ -22619,6 +22619,28 @@
"/* clang-format off */\n"
"/* long long long long long long line */\n",
getLLVMStyleWithColumns(20)));
+
+  verifyFormat("int *i;\n"
+   "// clang-format off:\n"
+   "int* j;\n"
+   "// clang-format on: 1\n"
+   "int *k;",
+   "int* i;\n"
+   "// clang-format off:\n"
+   "int* j;\n"
+   "// clang-format on: 1\n"
+   "int* k;");
+
+  verifyFormat("int *i;\n"
+   "// clang-format off:0\n"
+   "int* j;\n"
+   "// clang-format only\n"
+   "int* k;",
+   "int* i;\n"
+   "// clang-format off:0\n"
+   "int* j;\n"
+   "// clang-format only\n"
+   "int* k;");
 }
 
 TEST_F(FormatTest, DoNotCrashOnInvalidInput) {
Index: clang/lib/Format/SortJavaScriptImports.cpp
===
--- clang/lib/Format/SortJavaScriptImports.cpp
+++ clang/lib/Format/SortJavaScriptImports.cpp
@@ -195,8 +195,7 @@
 // Separate references from the main code body of the file.
 if (FirstNonImportLine && FirstNonImportLine->First->NewlinesBefore < 2 &&
 !(FirstNonImportLine->First->is(tok::comment) &&
-  FirstNonImportLine->First->TokenText.trim() ==
-  "// clang-format on")) {
+  isClangFormatOn(FirstNonImportLine->First->TokenText.trim( {
   ReferencesText += "\n";
 }
 
@@ -376,9 +375,9 @@
   // This is tracked in FormattingOff here and on JsModuleReference.
   while (Current && Current->is(tok::comment)) {
 StringRef CommentText = Current->TokenText.trim();
-if (CommentText == "// clang-format off") {
+if (isClangFormatOff(CommentText)) {
   FormattingOff = true;
-} else if (CommentText == "// clang-format on") {
+} else if (isClangFormatOn(CommentText)) {
   FormattingOff = false;
   // Special case: consider a trailing "clang-format on" line to be part
   // of the module reference, so that it gets moved around together with
Index: clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
===
--- clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
+++ clang/lib/Format/IntegerLiteralSeparatorFixer.cpp
@@ -87,9 +87,9 @@
 auto Location = Tok.getLocation();
 auto Text = StringRef(SourceMgr.getCharacterData(Location), Length);
 if (Tok.is(tok::comment)) {
-  if (Text == "// clang-format off" || Text == "/* clang-format off */")
+  if (isClangFormatOff(Text))
 Skip = true;
-  else if (Text == "// clang-format on" || Text == "/* clang-format on */")
+  else if (isClangFormatOn(Text))
 Skip = false;
   continue;
 }
Index: clang/lib/Format/FormatTokenLexer.cpp
===
--- clang/lib/Format/FormatTokenLexer.cpp
+++ clang/lib/Format/FormatTokenLexer.cpp
@@ -1286,17 +1286,13 @@
 Tok.Tok.setKind(tok::string_literal);
   }
 
-  if (Tok.is(tok::comment) && (Tok.TokenText == "// clang-format on" ||
-   Tok.TokenText == "/* clang-format on */")) {
+  if (Tok.is(tok::comment) && isClangFormatOn(Tok.TokenText))
 FormattingDisabled = false;
-  }
 
   Tok.Finalized = FormattingDisabled;
 
-  if (Tok.is(tok::comment) && (Tok.TokenText == "// clang-format off" ||
-   Tok.TokenText == "/* clang-format off */")) {
+  if (Tok.is(tok::comment) && isClangFormatOff(Tok.TokenText))
 FormattingDisabled = true;
-  }
 }
 
 void FormatTokenLexer::resetLexer(unsigned Offset) {
Index: clang/lib/Format/Format.cpp
===
--- clang/lib/Format/Format.cpp
+++ clang/lib/Format/Format.cpp
@@ -3002,13 +3002,10 @@
 if (Trimmed.contains(RawStringTermination))
   FormattingOff = false;
 
-if (Trimmed == "// clang-format off" ||
-Trimmed == "/* clang-format off */") {
+if (isClangFormatOff(Trimmed))
   FormattingOff = true;
-} else if (Trimmed

[PATCH] D141907: [CMake] Ensure `CLANG_RESOURCE_DIR` is respected

2023-01-28 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

While the general direction seems sound, I suspect this may be a real PITA 
given that for us:

  -DCLANG_RESOURCE_DIR="../../../../lib/clang/${LLVM_MAJOR}"

I'm going to try and see later throughout the week if it's possible to keep 
that working with this patch.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D141907

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