[PATCH] D128782: [CodeGen] Keep track of decls that were deferred and have been emitted.

2022-06-28 Thread Jun Zhang via Phabricator via cfe-commits
junaire created this revision.
junaire added a reviewer: v.g.vassilev.
Herald added a project: All.
junaire requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This patch adds a new field called EmittedDeferredDecls in CodeGenModule
that keeps track of decls that were deferred and have been emitted.

The intention of this patch is to solve issues in the incremental c++,
we'll lose info of decls that are lazily emitted when we undo their
usage.

See example below:

clang-repl> inline int foo() { return 42;}
clang-repl> int bar = foo();
clang-repl> %undo
clang-repl> int baz = foo();
JIT session error: Symbols not found: [ _Z3foov ]
error: Failed to materialize symbols: { (main, { baz, $.incr_module_2.__inits.0,
__orc_init_func.incr_module_2 }) }

Signed-off-by: Jun Zhang 


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128782

Files:
  clang/lib/CodeGen/CodeGenModule.cpp
  clang/lib/CodeGen/CodeGenModule.h
  clang/test/Interpreter/code-undo.cpp


Index: clang/test/Interpreter/code-undo.cpp
===
--- clang/test/Interpreter/code-undo.cpp
+++ clang/test/Interpreter/code-undo.cpp
@@ -20,4 +20,11 @@
 auto r3 = printf("foo() = %d\n", foo());
 // CHECK-NEXT: foo() = 2
 
+inline int bar() { return 42;}
+auto r4 = printf("r4 = %d\n", bar());
+// CHECK-NEXT: r4 = 42
+%undo
+auto r5 = printf("r5 = %d\n", bar());
+// CHECK-NEXT: r5 = 42
+
 %quit
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -344,6 +344,20 @@
   std::vector DeferredDeclsToEmit;
   void addDeferredDeclToEmit(GlobalDecl GD) {
 DeferredDeclsToEmit.emplace_back(GD);
+addEmittedDeferredDecl(GD);
+  }
+
+  /// Decls that were DeferredDecls and have now been emitted.
+  llvm::DenseMap EmittedDeferredDecls;
+
+  void addEmittedDeferredDecl(GlobalDecl GD) {
+if (!llvm::isa(GD.getDecl()))
+  return;
+llvm::GlobalVariable::LinkageTypes L = getFunctionLinkage(GD);
+if (llvm::GlobalValue::isLinkOnceLinkage(L) ||
+llvm::GlobalValue::isWeakLinkage(L)) {
+  EmittedDeferredDecls[getMangledName(GD)] = GD;
+}
   }
 
   /// List of alias we have emitted. Used to make sure that what they point to
@@ -1516,6 +1530,10 @@
 NewBuilder->WeakRefReferences = std::move(WeakRefReferences);
 
 NewBuilder->TBAA = std::move(TBAA);
+assert(NewBuilder->EmittedDeferredDecls.empty() &&
+   "Still have (unmerged) EmittedDeferredDecls deferred decls");
+
+NewBuilder->EmittedDeferredDecls = std::move(EmittedDeferredDecls);
   }
 
 private:
Index: clang/lib/CodeGen/CodeGenModule.cpp
===
--- clang/lib/CodeGen/CodeGenModule.cpp
+++ clang/lib/CodeGen/CodeGenModule.cpp
@@ -445,6 +445,7 @@
 
 void CodeGenModule::clear() {
   DeferredDeclsToEmit.clear();
+  EmittedDeferredDecls.clear();
   if (OpenMPRuntime)
 OpenMPRuntime->clear();
 }
@@ -510,6 +511,9 @@
 
 void CodeGenModule::Release() {
   EmitDeferred();
+  DeferredDecls.insert(EmittedDeferredDecls.begin(),
+   EmittedDeferredDecls.end());
+  EmittedDeferredDecls.clear();
   EmitVTablesOpportunistically();
   applyGlobalValReplacements();
   applyReplacements();


Index: clang/test/Interpreter/code-undo.cpp
===
--- clang/test/Interpreter/code-undo.cpp
+++ clang/test/Interpreter/code-undo.cpp
@@ -20,4 +20,11 @@
 auto r3 = printf("foo() = %d\n", foo());
 // CHECK-NEXT: foo() = 2
 
+inline int bar() { return 42;}
+auto r4 = printf("r4 = %d\n", bar());
+// CHECK-NEXT: r4 = 42
+%undo
+auto r5 = printf("r5 = %d\n", bar());
+// CHECK-NEXT: r5 = 42
+
 %quit
Index: clang/lib/CodeGen/CodeGenModule.h
===
--- clang/lib/CodeGen/CodeGenModule.h
+++ clang/lib/CodeGen/CodeGenModule.h
@@ -344,6 +344,20 @@
   std::vector DeferredDeclsToEmit;
   void addDeferredDeclToEmit(GlobalDecl GD) {
 DeferredDeclsToEmit.emplace_back(GD);
+addEmittedDeferredDecl(GD);
+  }
+
+  /// Decls that were DeferredDecls and have now been emitted.
+  llvm::DenseMap EmittedDeferredDecls;
+
+  void addEmittedDeferredDecl(GlobalDecl GD) {
+if (!llvm::isa(GD.getDecl()))
+  return;
+llvm::GlobalVariable::LinkageTypes L = getFunctionLinkage(GD);
+if (llvm::GlobalValue::isLinkOnceLinkage(L) ||
+llvm::GlobalValue::isWeakLinkage(L)) {
+  EmittedDeferredDecls[getMangledName(GD)] = GD;
+}
   }
 
   /// List of alias we have emitted. Used to make sure that what they point to
@@ -1516,6 +1530,10 @@
 NewBuilder->WeakRefReferences = std::move(WeakRefReferences);
 
 NewBuilder->TBAA = std::move(TBAA);
+assert(NewBuilder->EmittedDeferredDecls.empty() &&
+   "Still have (unmerged) 

[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-06-28 Thread Kai Luo via Phabricator via cfe-commits
lkail updated this revision to Diff 440860.
lkail added a comment.

Address comments.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

Files:
  clang/include/clang/Basic/LangOptions.def
  clang/include/clang/Driver/Options.td
  clang/lib/Basic/Targets/PPC.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Frontend/CompilerInvocation.cpp
  clang/test/CodeGen/PowerPC/quadword-atomics.c
  clang/test/Driver/aix-quadword-atomics-abi.c
  clang/test/Driver/ppc-unsupported.c
  clang/test/Sema/atomic-ops.c

Index: clang/test/Sema/atomic-ops.c
===
--- clang/test/Sema/atomic-ops.c
+++ clang/test/Sema/atomic-ops.c
@@ -10,6 +10,12 @@
 // RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
 // RUN:   -fsyntax-only -triple=powerpc64le-linux-gnu -std=c11 \
 // RUN:   -target-cpu pwr8 -DPPC64_PWR8
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64-unknown-aix -std=c11 \
+// RUN:   -target-cpu pwr8
+// RUN: %clang_cc1 %s -verify -fgnuc-version=4.2.1 -ffreestanding \
+// RUN:   -fsyntax-only -triple=powerpc64-unknown-aix -std=c11 \
+// RUN:   -maix64-quadword-atomics -target-cpu pwr8 -DPPC64_PWR8
 
 // Basic parsing/Sema tests for __c11_atomic_*
 
Index: clang/test/Driver/ppc-unsupported.c
===
--- clang/test/Driver/ppc-unsupported.c
+++ clang/test/Driver/ppc-unsupported.c
@@ -7,4 +7,14 @@
 // RUN:   -c %s 2>&1 | FileCheck %s
 // RUN: not %clang -target powerpc64le-unknown-linux -msvr4-struct-return \
 // RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64-unknown-freebsd -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64-unknown-linux -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-unknown-linux -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc-unknown-unknown -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc-unknown-aix -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s
 // CHECK: unsupported option
Index: clang/test/Driver/aix-quadword-atomics-abi.c
===
--- /dev/null
+++ clang/test/Driver/aix-quadword-atomics-abi.c
@@ -0,0 +1,11 @@
+// RUN:  %clang -### -target powerpc-unknown-aix -S %s 2>&1 | FileCheck %s
+// RUN:  %clang -### -target powerpc64-unknown-aix -S %s 2>&1 | FileCheck %s
+// RUN:  %clang -### -target powerpc-unknown-aix -maix64-quadword-atomics -S \
+// RUN:%s 2>&1 | FileCheck --check-prefix=CHECK-UNSUPPORTED-TARGET %s
+// RUN:  %clang -### -target powerpc64-unknown-aix -maix64-quadword-atomics -S \
+// RUN:%s 2>&1 | FileCheck %s --check-prefix=CHECK-QUADWORD-ATOMICS
+//
+// CHECK-UNSUPPORTED-TARGET: unsupported option '-maix64-quadword-atomics' for target 'powerpc-unknown-aix'
+// CHECK-NOT: "-maix64-quadword-atomics"
+// CHECK-QUADWORD-ATOMICS: "-cc1"
+// CHECK-QUADWORD-ATOMICS-SAME: "-maix64-quadword-atomics"
Index: clang/test/CodeGen/PowerPC/quadword-atomics.c
===
--- clang/test/CodeGen/PowerPC/quadword-atomics.c
+++ clang/test/CodeGen/PowerPC/quadword-atomics.c
@@ -1,9 +1,15 @@
 // RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
-// RUN:   -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64-PWR8
+// RUN:   -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64-QUADWORD-ATOMICS
 // RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64le-linux-gnu \
 // RUN:   -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
 // RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
 // RUN:   -target-cpu pwr7 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
+// RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
+// RUN:   -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s --check-prefix=PPC64
+// RUN: %clang_cc1 -no-opaque-pointers -Werror -Wno-atomic-alignment -triple powerpc64-unknown-aix \
+// RUN:   -maix64-quadword-atomics -target-cpu pwr8 -emit-llvm -o - %s | FileCheck %s \
+// RUN:   --check-prefix=PPC64-QUADWORD-ATOMICS
+
 
 typedef struct {
   char x[16];
@@ -13,8 +19,8 @@
 
 typedef __int128_t int128_t;
 
-// PPC64-PWR8-LABEL: @test_load(
-// PPC64-PWR8:[[TMP3:%.*]] = load atomic i128, i128* [[TMP1:%.*]] acquire, align 16
+// PPC64-QUADWORD-ATOMICS-LABEL: @test_load(
+// PPC64-QUADWORD-ATOMICS:[[TMP3:%.*]] = load atomic i128, i128* [[TMP1:%.*]] acquire, align 16
 //
 // PPC64-LABEL: @test_load(
 // PPC64:call void 

[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-06-28 Thread Valentin Clement via Phabricator via cfe-commits
clementval added a comment.

In D105584#3617456 , 
@abidmalikwaterloo wrote:

>   // CHECK-LABEL: omp_DistributeOp
>   func.func @omp_DistributeOp(%lb : index, %ub : index, %step : index, 
> %data_var : memref, %chunk_var : i32) -> () {
>  // CHECK: omp.DistributeOp collapse(2)
> "omp.DistributeOp" (%lb, %ub, %step) ({
>   ^bb0(%iv: index):
>omp.yield
> }) {operand_segment_sizes = dense<[1,1,1,0,0]> : vector<5xi32>, 
> collapse_val = 2} :
>   (index, index, index) -> ()
>
>return
>}
>
> Is this a valid test case for the operation?

Should it be `"omp.distribute" (%lb, %ub, %step) ({`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-28 Thread Prathit Aswar via Phabricator via cfe-commits
appmonster007 updated this revision to Diff 440859.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/SemaCXX/typeinfo
  clang/test/SemaCXX/warn-infinite-recursion.cpp

Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
 
+#include "typeinfo"
+
 void a() {  // expected-warning{{call itself}}
   a();
 }
@@ -171,3 +173,18 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+struct Q {
+  virtual ~Q(){};
+};
+
+Q q;
+Q _recursive_function(int x) { // expected-warning{{call itself}}
+  (void)typeid(evaluated_recursive_function(x)); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
\ No newline at end of file
Index: clang/test/SemaCXX/typeinfo
===
--- /dev/null
+++ clang/test/SemaCXX/typeinfo
@@ -0,0 +1,16 @@
+namespace std {
+  class type_info {
+  public:
+virtual ~type_info();
+const char* name() const { return __name; }
+bool operator==(const type_info& __arg) const {
+ return __name == __arg.__name;
+}
+
+bool operator!=(const type_info& __arg) const {
+  return !operator==(__arg);
+}
+  protected:
+const char *__name;
+  };
+}
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,28 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class type [...] [the] expression is an unevaluated
+  //   operand. [...]
+  // We add only potentially evaluated statements to block to avoid
+  // CFG generation for unevaluated operands.
+  if (S && !S->isTypeDependent()) {
+if (S->isPotentiallyEvaluated()) {
+  return VisitChildren(S);
+}
+  }
+
+  // Return block without CFG for unevaluated operands.
+  return Block;
+}
+
 CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
   CFGBlock *LoopSuccessor = nullptr;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128709: [clang-format] Handle Verilog attributes

2022-06-28 Thread Owen Pan via Phabricator via cfe-commits
owenpan added inline comments.



Comment at: clang/lib/Format/UnwrappedLineParser.cpp:1466-1471
+  } else if (FormatTok->is(tok::l_paren)) {
+const FormatToken *Next = Tokens->peekNextToken();
+if (Next && Next->is(tok::star))
+  parseParens();
+else
+  break;

as `peekNextToken()` never returns null.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128709

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


[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-28 Thread Prathit Aswar via Phabricator via cfe-commits
appmonster007 updated this revision to Diff 440856.

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/SemaCXX/warn-infinite-recursion.cpp


Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
 
+#include "typeinfo"
+
 void a() {  // expected-warning{{call itself}}
   a();
 }
@@ -171,3 +173,18 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+struct Q {
+  virtual ~Q(){};
+};
+
+Q q;
+Q _recursive_function(int x) { // expected-warning{{call 
itself}}
+  (void)typeid(evaluated_recursive_function(x)); // expected-warning 
{{expression with side effects will be evaluated despite being used as an 
operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
\ No newline at end of file
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,28 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class type [...] [the] expression is an unevaluated
+  //   operand. [...]
+  // We add only potentially evaluated statements to block to avoid
+  // CFG generation for unevaluated operands.
+  if (S && !S->isTypeDependent()) {
+if (S->isPotentiallyEvaluated()) {
+  return VisitChildren(S);
+}
+  }
+
+  // Return block without CFG for unevaluated operands.
+  return Block;
+}
+
 CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
   CFGBlock *LoopSuccessor = nullptr;
 


Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
 
+#include "typeinfo"
+
 void a() {  // expected-warning{{call itself}}
   a();
 }
@@ -171,3 +173,18 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+struct Q {
+  virtual ~Q(){};
+};
+
+Q q;
+Q _recursive_function(int x) { // expected-warning{{call itself}}
+  (void)typeid(evaluated_recursive_function(x)); // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
\ No newline at end of file
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,28 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class 

[PATCH] D118034: [C++20] [Modules] Don't complain about duplicated default template argument across modules

2022-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@rsmith @iains gentle ping~


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

https://reviews.llvm.org/D118034

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


[PATCH] D126694: [C++20][Modules] Implementation of GMF decl elision.

2022-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added inline comments.



Comment at: clang/include/clang/AST/DeclBase.h:624
   bool isModulePrivate() const {
 return getModuleOwnershipKind() == ModuleOwnershipKind::ModulePrivate;
   }

According to the opinion from @rsmith, the discarded declaration is private too.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126694

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


[PATCH] D125291: Introduce @llvm.threadlocal.address intrinsic to access TLS variable

2022-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

@jyknight ping!

Or someone else is willing to review this one?


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

https://reviews.llvm.org/D125291

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


[PATCH] D128248: [clang] Avoid an assertion in APValue::hasArrayFiller()

2022-06-28 Thread Timm Bäder via Phabricator via cfe-commits
tbaeder added a comment.

If you apply e.g.

  @@ -10739,6 +10779,7 @@ bool ArrayExprEvaluator::VisitInitListExpr(const 
InitListExpr *E,
 << NumEltsToInit << ".\n");
  
 Result = APValue(APValue::UninitArray(), NumEltsToInit, NumElts);
  +  llvm::errs() << "Result " <<  << ": " << Result.isArray() << "\n";
  
 // If the array was previously zero-initialized, preserve the
 // zero-initialized values.
  @@ -10764,6 +10805,7 @@ bool ArrayExprEvaluator::VisitInitListExpr(const 
InitListExpr *E,
   }
 }
  
  +  llvm::errs() << "Result " <<  << ": " << Result.isArray() << "\n";
 if (!Result.hasArrayFiller())
   return Success;

and run the test case, the first added line prints `1` and the second one `0`. 
`Result` is being mutated when doing the in-place evaluation.

> I take that to mean that the expectation for this interface is that the 
> caller validates the APValue in the cases where it doesn't already know the 
> answer.

Sure, that was the other option.


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

https://reviews.llvm.org/D128248

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


[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-06-28 Thread Chuanqi Xu 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 rG9c04851cf580: [C++20] [Module] Support reachable definition 
initially/partially (authored by ChuanqiXu).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D113545

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/Module.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  
clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/CXX/module/module.context/p7.cpp
  clang/test/CXX/module/module.import/p2.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/module/module.interface/p7.cpp
  clang/test/CXX/module/module.reach/ex1.cpp
  clang/test/CXX/module/module.reach/p2.cpp
  clang/test/CXX/module/module.reach/p4/TransitiveImport.cpp
  clang/test/CXX/module/module.reach/p5.cpp
  clang/test/CXX/module/module.unit/p7/t6.cpp
  clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp
  clang/test/Modules/Reachability-Private.cpp
  clang/test/Modules/Reachability-func-default-arg.cpp
  clang/test/Modules/Reachability-func-ret.cpp
  clang/test/Modules/Reachability-template-default-arg.cpp
  clang/test/Modules/Reachability-template-instantiation.cpp
  clang/test/Modules/Reachability-using-templates.cpp
  clang/test/Modules/Reachability-using.cpp
  clang/test/Modules/cxx20-10-1-ex2.cpp
  clang/test/Modules/derived_class.cpp
  clang/test/Modules/explicitly-specialized-template.cpp
  clang/test/Modules/module-private.cpp
  clang/test/Modules/template-function-specialization.cpp
  clang/test/Modules/template_default_argument.cpp

Index: clang/test/Modules/template_default_argument.cpp
===
--- /dev/null
+++ clang/test/Modules/template_default_argument.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify
+//
+//--- templ.h
+template 
+class templ {};
+template 
+void templ_func() {}
+
+//--- B.cppm
+module;
+#include "templ.h"
+export module B;
+export template 
+templ bar() {
+  templ_func();
+  return {};
+}
+
+//--- Use.cpp
+// expected-no-diagnostics
+import B;
+auto foo() {
+  return bar();
+}
Index: clang/test/Modules/template-function-specialization.cpp
===
--- /dev/null
+++ clang/test/Modules/template-function-specialization.cpp
@@ -0,0 +1,60 @@
+// RUN: rm -fr %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/foo.cppm -o %t/foo.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only
+//
+//--- foo.cppm
+module;
+# 3 __FILE__ 1 // use the next physical line number here (and below)
+template 
+void foo() {
+}
+
+template <>
+void foo() {
+}
+
+template 
+void foo2() {
+}
+
+template <>
+void foo2() {
+}
+
+template 
+void foo3() {
+}
+
+template <>
+void foo3();
+
+export module foo;
+export using ::foo;
+export using ::foo3;
+
+export template 
+void foo4() {
+}
+
+export template <>
+void foo4() {
+}
+
+//--- Use.cpp
+import foo;
+void use() {
+  foo();
+  foo();
+  foo2(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
+ // expected-note@* {{declaration here is not visible}}
+  foo2();   // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
+ // expected-note@* {{declaration here is not visible}}
+  foo3();
+  foo3();
+
+  foo4();
+  foo4();
+}
Index: clang/test/Modules/module-private.cpp
===
--- clang/test/Modules/module-private.cpp
+++ clang/test/Modules/module-private.cpp
@@ -21,8 +21,8 @@
   vector vec; // expected-error{{no template named 'vector'}}
 
   VisibleStruct vs;
-  vs.field = 0; // expected-error{{no member named 'field' in 'VisibleStruct'}}
-  vs.setField(1); // expected-error{{no member named 'setField' in 'VisibleStruct'}}
+  vs.field = 0;
+  vs.setField(1);
 
   return hidden_var; // expected-error{{use of undeclared identifier 'hidden_var'}}
 }
Index: clang/test/Modules/explicitly-specialized-template.cpp
===
--- /dev/null

[clang] 9c04851 - [C++20] [Module] Support reachable definition initially/partially

2022-06-28 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-06-29T12:48:48+08:00
New Revision: 9c04851cf5809c80862183481f8ced0b3e9ee301

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

LOG: [C++20] [Module] Support reachable definition initially/partially

This patch introduces a new kind of ModuleOwnershipKind as
ReachableWhenImported. This intended the status for reachable described
at: https://eel.is/c++draft/module.reach#3.

Note that this patch is not intended to support all semantics about
reachable semantics. For example, this patch didn't implement discarded
declarations in GMF. (https://eel.is/c++draft/module.global.frag#3).

This fixes: https://bugs.llvm.org/show_bug.cgi?id=52281 and
https://godbolt.org/z/81f3ocjfW.

Reviewed By: rsmith, iains

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

Added: 

clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
clang/test/CXX/module/module.context/p7.cpp
clang/test/CXX/module/module.interface/p7.cpp
clang/test/CXX/module/module.reach/ex1.cpp
clang/test/CXX/module/module.reach/p2.cpp
clang/test/CXX/module/module.reach/p4/TransitiveImport.cpp
clang/test/CXX/module/module.reach/p5.cpp
clang/test/Modules/Reachability-Private.cpp
clang/test/Modules/Reachability-func-default-arg.cpp
clang/test/Modules/Reachability-func-ret.cpp
clang/test/Modules/Reachability-template-default-arg.cpp
clang/test/Modules/Reachability-template-instantiation.cpp
clang/test/Modules/Reachability-using-templates.cpp
clang/test/Modules/Reachability-using.cpp
clang/test/Modules/derived_class.cpp
clang/test/Modules/explicitly-specialized-template.cpp
clang/test/Modules/template-function-specialization.cpp
clang/test/Modules/template_default_argument.cpp

Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/Basic/Module.h
clang/include/clang/Sema/Lookup.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
clang/test/CXX/module/module.import/p2.cpp
clang/test/CXX/module/module.interface/p2.cpp
clang/test/CXX/module/module.unit/p7/t6.cpp
clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp
clang/test/Modules/cxx20-10-1-ex2.cpp
clang/test/Modules/module-private.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 0611cf5ccb000..52fe8dd6b1e57 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -225,8 +225,15 @@ class alignas(8) Decl {
 /// module is imported.
 VisibleWhenImported,
 
+/// This declaration has an owning module, and is visible to lookups
+/// that occurs within that module. And it is reachable in other module
+/// when the owning module is transitively imported.
+ReachableWhenImported,
+
 /// This declaration has an owning module, but is only visible to
 /// lookups that occur within that module.
+/// The discarded declarations in global module fragment belongs
+/// to this group too.
 ModulePrivate
   };
 
@@ -235,8 +242,8 @@ class alignas(8) Decl {
   /// DeclContext. These pointers form the linked list that is
   /// traversed via DeclContext's decls_begin()/decls_end().
   ///
-  /// The extra two bits are used for the ModuleOwnershipKind.
-  llvm::PointerIntPair NextInContextAndBits;
+  /// The extra three bits are used for the ModuleOwnershipKind.
+  llvm::PointerIntPair NextInContextAndBits;
 
 private:
   friend class DeclContext;
@@ -622,6 +629,14 @@ class alignas(8) Decl {
   ///   export void B::f2(); // isInExportDeclContext() == true
   bool isInExportDeclContext() const;
 
+  bool isInvisibleOutsideTheOwningModule() const {
+return getModuleOwnershipKind() > ModuleOwnershipKind::VisibleWhenImported;
+  }
+
+  /// FIXME: Implement discarding declarations actually in global module
+  /// fragment. See [module.global.frag]p3,4 for details.
+  bool isDiscardedInGlobalModuleFragment() const { return false; }
+
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
   bool hasDefiningAttr() const;
@@ -799,6 +814,11 @@ class alignas(8) Decl {
 return (int)getModuleOwnershipKind() <= (int)ModuleOwnershipKind::Visible;
   }
 
+  bool isReachable() const {
+return 

[clang] 7a54140 - Revert "[C++20] [Modules] Implement Reachable initiallly"

2022-06-28 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-06-29T12:43:26+08:00
New Revision: 7a541406b5a23a811a4f37432292a6de3307b0f1

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

LOG: Revert "[C++20] [Modules] Implement Reachable initiallly"

This reverts commit a223ba0a697c1598b434cf2495c9cd9ec5640fc7.

The previous commit don't contain additional information, which is bad.

Added: 


Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/Basic/Module.h
clang/include/clang/Sema/Lookup.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
clang/test/CXX/module/module.import/p2.cpp
clang/test/CXX/module/module.interface/p2.cpp
clang/test/CXX/module/module.unit/p7/t6.cpp
clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp
clang/test/Modules/cxx20-10-1-ex2.cpp
clang/test/Modules/module-private.cpp

Removed: 

clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
clang/test/CXX/module/module.context/p7.cpp
clang/test/CXX/module/module.interface/p7.cpp
clang/test/CXX/module/module.reach/ex1.cpp
clang/test/CXX/module/module.reach/p2.cpp
clang/test/CXX/module/module.reach/p4/TransitiveImport.cpp
clang/test/CXX/module/module.reach/p5.cpp
clang/test/Modules/Reachability-Private.cpp
clang/test/Modules/Reachability-func-default-arg.cpp
clang/test/Modules/Reachability-func-ret.cpp
clang/test/Modules/Reachability-template-default-arg.cpp
clang/test/Modules/Reachability-template-instantiation.cpp
clang/test/Modules/Reachability-using-templates.cpp
clang/test/Modules/Reachability-using.cpp
clang/test/Modules/derived_class.cpp
clang/test/Modules/explicitly-specialized-template.cpp
clang/test/Modules/template-function-specialization.cpp
clang/test/Modules/template_default_argument.cpp



diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 52fe8dd6b1e57..0611cf5ccb000 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -225,15 +225,8 @@ class alignas(8) Decl {
 /// module is imported.
 VisibleWhenImported,
 
-/// This declaration has an owning module, and is visible to lookups
-/// that occurs within that module. And it is reachable in other module
-/// when the owning module is transitively imported.
-ReachableWhenImported,
-
 /// This declaration has an owning module, but is only visible to
 /// lookups that occur within that module.
-/// The discarded declarations in global module fragment belongs
-/// to this group too.
 ModulePrivate
   };
 
@@ -242,8 +235,8 @@ class alignas(8) Decl {
   /// DeclContext. These pointers form the linked list that is
   /// traversed via DeclContext's decls_begin()/decls_end().
   ///
-  /// The extra three bits are used for the ModuleOwnershipKind.
-  llvm::PointerIntPair NextInContextAndBits;
+  /// The extra two bits are used for the ModuleOwnershipKind.
+  llvm::PointerIntPair NextInContextAndBits;
 
 private:
   friend class DeclContext;
@@ -629,14 +622,6 @@ class alignas(8) Decl {
   ///   export void B::f2(); // isInExportDeclContext() == true
   bool isInExportDeclContext() const;
 
-  bool isInvisibleOutsideTheOwningModule() const {
-return getModuleOwnershipKind() > ModuleOwnershipKind::VisibleWhenImported;
-  }
-
-  /// FIXME: Implement discarding declarations actually in global module
-  /// fragment. See [module.global.frag]p3,4 for details.
-  bool isDiscardedInGlobalModuleFragment() const { return false; }
-
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
   bool hasDefiningAttr() const;
@@ -814,11 +799,6 @@ class alignas(8) Decl {
 return (int)getModuleOwnershipKind() <= (int)ModuleOwnershipKind::Visible;
   }
 
-  bool isReachable() const {
-return (int)getModuleOwnershipKind() <=
-   (int)ModuleOwnershipKind::ReachableWhenImported;
-  }
-
   /// Set that this declaration is globally visible, even if it came from a
   /// module that is not visible.
   void setVisibleDespiteOwningModule() {

diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index a1778baa04530..5ce5fea45c670 100644
--- a/clang/include/clang/Basic/Module.h
+++ 

[clang] a223ba0 - [C++20] [Modules] Implement Reachable initiallly

2022-06-28 Thread Chuanqi Xu via cfe-commits

Author: Chuanqi Xu
Date: 2022-06-29T12:32:31+08:00
New Revision: a223ba0a697c1598b434cf2495c9cd9ec5640fc7

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

LOG: [C++20] [Modules] Implement Reachable initiallly

Added: 

clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
clang/test/CXX/module/module.context/p7.cpp
clang/test/CXX/module/module.interface/p7.cpp
clang/test/CXX/module/module.reach/ex1.cpp
clang/test/CXX/module/module.reach/p2.cpp
clang/test/CXX/module/module.reach/p4/TransitiveImport.cpp
clang/test/CXX/module/module.reach/p5.cpp
clang/test/Modules/Reachability-Private.cpp
clang/test/Modules/Reachability-func-default-arg.cpp
clang/test/Modules/Reachability-func-ret.cpp
clang/test/Modules/Reachability-template-default-arg.cpp
clang/test/Modules/Reachability-template-instantiation.cpp
clang/test/Modules/Reachability-using-templates.cpp
clang/test/Modules/Reachability-using.cpp
clang/test/Modules/derived_class.cpp
clang/test/Modules/explicitly-specialized-template.cpp
clang/test/Modules/template-function-specialization.cpp
clang/test/Modules/template_default_argument.cpp

Modified: 
clang/include/clang/AST/DeclBase.h
clang/include/clang/Basic/Module.h
clang/include/clang/Sema/Lookup.h
clang/include/clang/Sema/Sema.h
clang/lib/AST/Decl.cpp
clang/lib/Sema/SemaCXXScopeSpec.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/Sema/SemaExpr.cpp
clang/lib/Sema/SemaLookup.cpp
clang/lib/Sema/SemaModule.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/lib/Sema/SemaType.cpp
clang/lib/Serialization/ASTReaderDecl.cpp
clang/lib/Serialization/ASTWriterDecl.cpp
clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
clang/test/CXX/module/module.import/p2.cpp
clang/test/CXX/module/module.interface/p2.cpp
clang/test/CXX/module/module.unit/p7/t6.cpp
clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp
clang/test/Modules/cxx20-10-1-ex2.cpp
clang/test/Modules/module-private.cpp

Removed: 




diff  --git a/clang/include/clang/AST/DeclBase.h 
b/clang/include/clang/AST/DeclBase.h
index 0611cf5ccb000..52fe8dd6b1e57 100644
--- a/clang/include/clang/AST/DeclBase.h
+++ b/clang/include/clang/AST/DeclBase.h
@@ -225,8 +225,15 @@ class alignas(8) Decl {
 /// module is imported.
 VisibleWhenImported,
 
+/// This declaration has an owning module, and is visible to lookups
+/// that occurs within that module. And it is reachable in other module
+/// when the owning module is transitively imported.
+ReachableWhenImported,
+
 /// This declaration has an owning module, but is only visible to
 /// lookups that occur within that module.
+/// The discarded declarations in global module fragment belongs
+/// to this group too.
 ModulePrivate
   };
 
@@ -235,8 +242,8 @@ class alignas(8) Decl {
   /// DeclContext. These pointers form the linked list that is
   /// traversed via DeclContext's decls_begin()/decls_end().
   ///
-  /// The extra two bits are used for the ModuleOwnershipKind.
-  llvm::PointerIntPair NextInContextAndBits;
+  /// The extra three bits are used for the ModuleOwnershipKind.
+  llvm::PointerIntPair NextInContextAndBits;
 
 private:
   friend class DeclContext;
@@ -622,6 +629,14 @@ class alignas(8) Decl {
   ///   export void B::f2(); // isInExportDeclContext() == true
   bool isInExportDeclContext() const;
 
+  bool isInvisibleOutsideTheOwningModule() const {
+return getModuleOwnershipKind() > ModuleOwnershipKind::VisibleWhenImported;
+  }
+
+  /// FIXME: Implement discarding declarations actually in global module
+  /// fragment. See [module.global.frag]p3,4 for details.
+  bool isDiscardedInGlobalModuleFragment() const { return false; }
+
   /// Return true if this declaration has an attribute which acts as
   /// definition of the entity, such as 'alias' or 'ifunc'.
   bool hasDefiningAttr() const;
@@ -799,6 +814,11 @@ class alignas(8) Decl {
 return (int)getModuleOwnershipKind() <= (int)ModuleOwnershipKind::Visible;
   }
 
+  bool isReachable() const {
+return (int)getModuleOwnershipKind() <=
+   (int)ModuleOwnershipKind::ReachableWhenImported;
+  }
+
   /// Set that this declaration is globally visible, even if it came from a
   /// module that is not visible.
   void setVisibleDespiteOwningModule() {

diff  --git a/clang/include/clang/Basic/Module.h 
b/clang/include/clang/Basic/Module.h
index 5ce5fea45c670..a1778baa04530 100644
--- a/clang/include/clang/Basic/Module.h
+++ b/clang/include/clang/Basic/Module.h
@@ -170,6 +170,8 @@ class Module {
 
   bool isPrivateModule() const { return Kind == PrivateModuleFragment; }
 
+  bool 

[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-28 Thread Jeff Niu via Phabricator via cfe-commits
Mogball added inline comments.



Comment at: mlir/lib/Transforms/Utils/CommutativityUtils.cpp:178
+using UniquePtrOperandBFS = std::unique_ptr;
+using ArrayRefOperandBFS = ArrayRef;
+

Please remove these. They don't improve readability.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

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


[PATCH] D124750: [MLIR] Add a utility to sort the operands of commutative ops

2022-06-28 Thread Srishti Srivastava via Phabricator via cfe-commits
srishti-pm updated this revision to Diff 440848.
srishti-pm marked 2 inline comments as done.
srishti-pm added a comment.

Fixed memory leak.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124750

Files:
  mlir/include/mlir/Transforms/CommutativityUtils.h
  mlir/lib/Transforms/Utils/CMakeLists.txt
  mlir/lib/Transforms/Utils/CommutativityUtils.cpp
  mlir/test/Transforms/test-commutativity-utils.mlir
  mlir/test/lib/Dialect/Test/TestOps.td
  mlir/test/lib/Transforms/CMakeLists.txt
  mlir/test/lib/Transforms/TestCommutativityUtils.cpp
  mlir/tools/mlir-opt/mlir-opt.cpp

Index: mlir/tools/mlir-opt/mlir-opt.cpp
===
--- mlir/tools/mlir-opt/mlir-opt.cpp
+++ mlir/tools/mlir-opt/mlir-opt.cpp
@@ -57,6 +57,7 @@
 void registerVectorizerTestPass();
 
 namespace test {
+void registerCommutativityUtils();
 void registerConvertCallOpPass();
 void registerInliner();
 void registerMemRefBoundCheck();
@@ -152,6 +153,7 @@
   registerVectorizerTestPass();
   registerTosaTestQuantUtilAPIPass();
 
+  mlir::test::registerCommutativityUtils();
   mlir::test::registerConvertCallOpPass();
   mlir::test::registerInliner();
   mlir::test::registerMemRefBoundCheck();
Index: mlir/test/lib/Transforms/TestCommutativityUtils.cpp
===
--- /dev/null
+++ mlir/test/lib/Transforms/TestCommutativityUtils.cpp
@@ -0,0 +1,48 @@
+//===- TestCommutativityUtils.cpp - Pass to test the commutativity utility-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===--===//
+//
+// This pass tests the functionality of the commutativity utility pattern.
+//
+//===--===//
+
+#include "mlir/Transforms/CommutativityUtils.h"
+
+#include "TestDialect.h"
+#include "mlir/Pass/Pass.h"
+#include "mlir/Transforms/GreedyPatternRewriteDriver.h"
+
+using namespace mlir;
+
+namespace {
+
+struct CommutativityUtils
+: public PassWrapper> {
+  MLIR_DEFINE_EXPLICIT_INTERNAL_INLINE_TYPE_ID(CommutativityUtils)
+
+  StringRef getArgument() const final { return "test-commutativity-utils"; }
+  StringRef getDescription() const final {
+return "Test the functionality of the commutativity utility";
+  }
+
+  void runOnOperation() override {
+auto func = getOperation();
+auto *context = ();
+
+RewritePatternSet patterns(context);
+populateCommutativityUtilsPatterns(patterns);
+
+(void)applyPatternsAndFoldGreedily(func, std::move(patterns));
+  }
+};
+} // namespace
+
+namespace mlir {
+namespace test {
+void registerCommutativityUtils() { PassRegistration(); }
+} // namespace test
+} // namespace mlir
Index: mlir/test/lib/Transforms/CMakeLists.txt
===
--- mlir/test/lib/Transforms/CMakeLists.txt
+++ mlir/test/lib/Transforms/CMakeLists.txt
@@ -1,5 +1,6 @@
 # Exclude tests from libMLIR.so
 add_mlir_library(MLIRTestTransforms
+  TestCommutativityUtils.cpp
   TestConstantFold.cpp
   TestControlFlowSink.cpp
   TestInlining.cpp
Index: mlir/test/lib/Dialect/Test/TestOps.td
===
--- mlir/test/lib/Dialect/Test/TestOps.td
+++ mlir/test/lib/Dialect/Test/TestOps.td
@@ -1162,11 +1162,21 @@
   let hasFolder = 1;
 }
 
+def TestAddIOp : TEST_Op<"addi"> {
+  let arguments = (ins I32:$op1, I32:$op2);
+  let results = (outs I32);
+}
+
 def TestCommutativeOp : TEST_Op<"op_commutative", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4);
   let results = (outs I32);
 }
 
+def TestLargeCommutativeOp : TEST_Op<"op_large_commutative", [Commutative]> {
+  let arguments = (ins I32:$op1, I32:$op2, I32:$op3, I32:$op4, I32:$op5, I32:$op6, I32:$op7);
+  let results = (outs I32);
+}
+
 def TestCommutative2Op : TEST_Op<"op_commutative2", [Commutative]> {
   let arguments = (ins I32:$op1, I32:$op2);
   let results = (outs I32);
Index: mlir/test/Transforms/test-commutativity-utils.mlir
===
--- /dev/null
+++ mlir/test/Transforms/test-commutativity-utils.mlir
@@ -0,0 +1,116 @@
+// RUN: mlir-opt %s -test-commutativity-utils | FileCheck %s
+
+// CHECK-LABEL: @test_small_pattern_1
+func.func @test_small_pattern_1(%arg0 : i32) -> i32 {
+  // CHECK-NEXT: %[[ARITH_CONST:.*]] = arith.constant
+  %0 = arith.constant 45 : i32
+
+  // CHECK-NEXT: %[[TEST_ADD:.*]] = "test.addi"
+  %1 = "test.addi"(%arg0, %arg0): (i32, i32) -> i32
+
+  // CHECK-NEXT: %[[ARITH_ADD:.*]] = arith.addi
+  %2 = arith.addi %arg0, %arg0 : i32
+
+  // CHECK-NEXT: %[[ARITH_MUL:.*]] = arith.muli
+  %3 = 

[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu added a comment.

In D113545#3616814 , @rsmith wrote:

> A few comments, but they're all minor things or FIXMEs. I'm happy for this to 
> land once they're addressed.

Thanks for reviewing!




Comment at: clang/lib/Sema/SemaLookup.cpp:2000-2004
+  // Class and enumeration member names can be found by name lookup in any
+  // context in which a definition of the type is reachable.
+  if (auto *ECD = dyn_cast(ND))
+return getSema().hasReachableDeclaration(
+cast(ECD->getDeclContext()));

rsmith wrote:
> ChuanqiXu wrote:
> > rsmith wrote:
> > > I don't think this is quite right. Given:
> > > 
> > > ```
> > > export module M {
> > > export enum E1 { e1 };
> > > enum E2 { e2 };
> > > export using E2U = E2;
> > > enum E3 { e3 };
> > > export E3 f();
> > > ```
> > > 
> > > ... the intent is:
> > > 
> > > ```
> > > import M;
> > > int main() {
> > >   auto a = E1::e1; // OK, namespace-scope name E1 is visible and e1 is 
> > > reachable
> > >   auto b = e1; // OK, namespace-scope name e1 is visible
> > >   auto c = E2::e2; // error, namespace-scope name E2 is not visible
> > >   auto d = e2; // error, namespace-scope name e2 is not visible
> > >   auto e = E2U::e2; // OK, namespace-scope name E2U is visible and E2::e2 
> > > is reachable
> > >   auto f = E3::e3; // error, namespace-scope name E3 is not visible
> > >   auto g = e3; // error, namespace-scope name e3 is not visible
> > >   auto h = decltype(f())::e3; // OK, namespace-scope name f is visible 
> > > and E3::e3 is reachable
> > > }
> > > ```
> > > 
> > > Instead of doing the check in this function, I think we need to consider 
> > > the scope in which we're doing a lookup: if that scope is a class or 
> > > enumeration scope, and the class or enumeration has a reachable 
> > > definition, then we don't do any visibility checks for its members.
> > Oh, your example makes sense. The current implementation would accept `d` 
> > and `g` unexpectedly. I spent some time to look into this one. And I find 
> > it is not so easy to fix. I left a FIXME below and I would file an issue if 
> > this patch landed. Do you think this is OK?
> > 
> > BTW, I feel like the wording of spec need to be adjusted too. From the 
> > wording, I feel like `d` and `g` should be accepted.
> Yes, I'm fine with having FIXMEs for things that don't work yet -- so long as 
> we don't regress things (particularly, so long as we don't regress module map 
> module support, which some of our users are heavily relying on).
> 
> I agree that the wording here is not capturing the rules properly; I've 
> mailed the CWG reflector and it sounds like Davis is going to fix that :)
Thanks! I believe it wouldn't be a regression.


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

https://reviews.llvm.org/D113545

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


[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-06-28 Thread Chuanqi Xu via Phabricator via cfe-commits
ChuanqiXu updated this revision to Diff 440847.
ChuanqiXu marked 15 inline comments as done.
ChuanqiXu added a comment.

Address comments.


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

https://reviews.llvm.org/D113545

Files:
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Basic/Module.h
  clang/include/clang/Sema/Lookup.h
  clang/include/clang/Sema/Sema.h
  clang/lib/AST/Decl.cpp
  clang/lib/Sema/SemaCXXScopeSpec.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaLookup.cpp
  clang/lib/Sema/SemaModule.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  
clang/test/CXX/basic/basic.lookup/basic.lookup.argdep/p4-friend-in-reachable-class.cpp
  clang/test/CXX/basic/basic.scope/basic.scope.namespace/p2.cpp
  clang/test/CXX/module/module.context/p7.cpp
  clang/test/CXX/module/module.import/p2.cpp
  clang/test/CXX/module/module.interface/p2.cpp
  clang/test/CXX/module/module.interface/p7.cpp
  clang/test/CXX/module/module.reach/ex1.cpp
  clang/test/CXX/module/module.reach/p2.cpp
  clang/test/CXX/module/module.reach/p4/TransitiveImport.cpp
  clang/test/CXX/module/module.reach/p5.cpp
  clang/test/CXX/module/module.unit/p7/t6.cpp
  clang/test/CXX/modules-ts/basic/basic.link/p2/other.cpp
  clang/test/Modules/Reachability-Private.cpp
  clang/test/Modules/Reachability-func-default-arg.cpp
  clang/test/Modules/Reachability-func-ret.cpp
  clang/test/Modules/Reachability-template-default-arg.cpp
  clang/test/Modules/Reachability-template-instantiation.cpp
  clang/test/Modules/Reachability-using-templates.cpp
  clang/test/Modules/Reachability-using.cpp
  clang/test/Modules/cxx20-10-1-ex2.cpp
  clang/test/Modules/derived_class.cpp
  clang/test/Modules/explicitly-specialized-template.cpp
  clang/test/Modules/module-private.cpp
  clang/test/Modules/template-function-specialization.cpp
  clang/test/Modules/template_default_argument.cpp

Index: clang/test/Modules/template_default_argument.cpp
===
--- /dev/null
+++ clang/test/Modules/template_default_argument.cpp
@@ -0,0 +1,29 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 %t/B.cppm -emit-module-interface -o %t/B.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -fsyntax-only -verify
+//
+//--- templ.h
+template 
+class templ {};
+template 
+void templ_func() {}
+
+//--- B.cppm
+module;
+#include "templ.h"
+export module B;
+export template 
+templ bar() {
+  templ_func();
+  return {};
+}
+
+//--- Use.cpp
+// expected-no-diagnostics
+import B;
+auto foo() {
+  return bar();
+}
Index: clang/test/Modules/template-function-specialization.cpp
===
--- /dev/null
+++ clang/test/Modules/template-function-specialization.cpp
@@ -0,0 +1,60 @@
+// RUN: rm -fr %t
+// RUN: mkdir %t
+// RUN: split-file %s %t
+//
+// RUN: %clang_cc1 -std=c++20 -emit-module-interface %t/foo.cppm -o %t/foo.pcm
+// RUN: %clang_cc1 -std=c++20 -fprebuilt-module-path=%t %t/Use.cpp -verify -fsyntax-only
+//
+//--- foo.cppm
+module;
+# 3 __FILE__ 1 // use the next physical line number here (and below)
+template 
+void foo() {
+}
+
+template <>
+void foo() {
+}
+
+template 
+void foo2() {
+}
+
+template <>
+void foo2() {
+}
+
+template 
+void foo3() {
+}
+
+template <>
+void foo3();
+
+export module foo;
+export using ::foo;
+export using ::foo3;
+
+export template 
+void foo4() {
+}
+
+export template <>
+void foo4() {
+}
+
+//--- Use.cpp
+import foo;
+void use() {
+  foo();
+  foo();
+  foo2(); // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
+ // expected-note@* {{declaration here is not visible}}
+  foo2();   // expected-error {{missing '#include'; 'foo2' must be declared before it is used}}
+ // expected-note@* {{declaration here is not visible}}
+  foo3();
+  foo3();
+
+  foo4();
+  foo4();
+}
Index: clang/test/Modules/module-private.cpp
===
--- clang/test/Modules/module-private.cpp
+++ clang/test/Modules/module-private.cpp
@@ -21,8 +21,8 @@
   vector vec; // expected-error{{no template named 'vector'}}
 
   VisibleStruct vs;
-  vs.field = 0; // expected-error{{no member named 'field' in 'VisibleStruct'}}
-  vs.setField(1); // expected-error{{no member named 'setField' in 'VisibleStruct'}}
+  vs.field = 0;
+  vs.setField(1);
 
   return hidden_var; // expected-error{{use of undeclared identifier 'hidden_var'}}
 }
Index: clang/test/Modules/explicitly-specialized-template.cpp
===
--- /dev/null
+++ clang/test/Modules/explicitly-specialized-template.cpp
@@ -0,0 +1,47 @@
+// RUN: rm -rf %t
+// RUN: mkdir -p %t
+// RUN: split-file %s %t
+//
+// RUN: 

[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-28 Thread Prathit Aswar via Phabricator via cfe-commits
appmonster007 added inline comments.



Comment at: clang/test/SemaCXX/warn-infinite-recursion.cpp:3
 
+#include "typeinfo"
+

`#include ` resulted in 'typeinfo' file not found with  
include; use "quotes" instead


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

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


[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-28 Thread Prathit Aswar via Phabricator via cfe-commits
appmonster007 updated this revision to Diff 440845.
appmonster007 added a comment.

#include "typeinfo"


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/SemaCXX/typeinfo
  clang/test/SemaCXX/warn-infinite-recursion.cpp

Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
 
+#include "typeinfo"
+
 void a() {  // expected-warning{{call itself}}
   a();
 }
@@ -171,3 +173,18 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+struct Q {
+  virtual ~Q(){};
+};
+
+Q q;
+Q _recursive_function(int x) {  // expected-warning{{call itself}}
+  (void)typeid(evaluated_recursive_function(x));  // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
\ No newline at end of file
Index: clang/test/SemaCXX/typeinfo
===
--- /dev/null
+++ clang/test/SemaCXX/typeinfo
@@ -0,0 +1,16 @@
+namespace std {
+  class type_info {
+  public:
+virtual ~type_info();
+const char* name() const { return __name; }
+bool operator==(const type_info& __arg) const {
+ return __name == __arg.__name;
+}
+
+bool operator!=(const type_info& __arg) const {
+  return !operator==(__arg);
+}
+  protected:
+const char *__name;
+  };
+}
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,28 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class type [...] [the] expression is an unevaluated
+  //   operand. [...]
+  // We add only potentially evaluated statements to block to avoid
+  // CFG generation for unevaluated operands.
+  if (S && !S->isTypeDependent()) {
+if (S->isPotentiallyEvaluated()) {
+  return VisitChildren(S);
+}
+  }
+
+  // Return block without CFG for unevaluated operands.
+  return Block;
+}
+
 CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
   CFGBlock *LoopSuccessor = nullptr;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-06-28 Thread Kai Luo via Phabricator via cfe-commits
lkail added inline comments.



Comment at: clang/test/Driver/ppc-unsupported.c:12
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-unknown-linux -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s

amyk wrote:
> amyk wrote:
> > Should we have a big endian Linux check, too?
> Oh, sorry. I noticed there wasn't `powerpc64-unknown-linux` but I realized I 
> think `powerpc64-unknown-freebsd` is supposed to be the big endian 64-bit 
> Linux check, right?
Added OS check is following lines above. I'm ok to add 
`powerpc64-unknown-linux` too. Thanks for pointing it out.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-28 Thread Prathit Aswar via Phabricator via cfe-commits
appmonster007 updated this revision to Diff 440835.
appmonster007 added a comment.

included typeinfo file, in clang/test/SemaCXX directory


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/SemaCXX/typeinfo
  clang/test/SemaCXX/warn-infinite-recursion.cpp

Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
 
+#include 
+
 void a() {  // expected-warning{{call itself}}
   a();
 }
@@ -171,3 +173,18 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+struct Q {
+  virtual ~Q(){};
+};
+
+Q q;
+Q _recursive_function(int x) {  // expected-warning{{call itself}}
+  (void)typeid(evaluated_recursive_function(x));  // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
\ No newline at end of file
Index: clang/test/SemaCXX/typeinfo
===
--- /dev/null
+++ clang/test/SemaCXX/typeinfo
@@ -0,0 +1,16 @@
+namespace std {
+  class type_info {
+  public:
+virtual ~type_info();
+const char* name() const { return __name; }
+bool operator==(const type_info& __arg) const {
+ return __name == __arg.__name;
+}
+
+bool operator!=(const type_info& __arg) const {
+  return !operator==(__arg);
+}
+  protected:
+const char *__name;
+  };
+}
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,28 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class type [...] [the] expression is an unevaluated
+  //   operand. [...]
+  // We add only potentially evaluated statements to block to avoid
+  // CFG generation for unevaluated operands.
+  if (S && !S->isTypeDependent()) {
+if (S->isPotentiallyEvaluated()) {
+  return VisitChildren(S);
+}
+  }
+
+  // Return block without CFG for unevaluated operands.
+  return Block;
+}
+
 CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
   CFGBlock *LoopSuccessor = nullptr;
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128550: [OpenMP] Change OpenMP code generation for target region entries

2022-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 440831.
jhuber6 added a comment.

Format


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128550

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_data_member_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_defaultmap_codegen_02.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_00.cpp
  clang/test/OpenMP/target_map_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_02.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_04.cpp
  clang/test/OpenMP/target_map_codegen_05.cpp
  clang/test/OpenMP/target_map_codegen_06.cpp
  clang/test/OpenMP/target_map_codegen_07.cpp
  clang/test/OpenMP/target_map_codegen_08.cpp
  clang/test/OpenMP/target_map_codegen_09.cpp
  clang/test/OpenMP/target_map_codegen_10.cpp
  clang/test/OpenMP/target_map_codegen_11.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_15.cpp
  clang/test/OpenMP/target_map_codegen_16.cpp
  clang/test/OpenMP/target_map_codegen_17.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_19.cpp
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_21.cpp
  clang/test/OpenMP/target_map_codegen_22.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_24.cpp
  clang/test/OpenMP/target_map_codegen_25.cpp
  clang/test/OpenMP/target_map_codegen_26.cpp
  clang/test/OpenMP/target_map_codegen_27.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_30.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_33.cpp
  clang/test/OpenMP/target_map_codegen_34.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_map_names.cpp
  clang/test/OpenMP/target_map_names_attr.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  

[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-06-28 Thread Amy Kwan via Phabricator via cfe-commits
amyk added inline comments.



Comment at: clang/test/Driver/ppc-unsupported.c:12
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-unknown-linux -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s

amyk wrote:
> Should we have a big endian Linux check, too?
Oh, sorry. I noticed there wasn't `powerpc64-unknown-linux` but I realized I 
think `powerpc64-unknown-freebsd` is supposed to be the big endian 64-bit Linux 
check, right?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D127189: [clang][AIX] Add option to control quadword lock free atomics ABI on AIX

2022-06-28 Thread Amy Kwan via Phabricator via cfe-commits
amyk added a comment.

This patch makes sense. I had some questions regarding it.




Comment at: clang/include/clang/Driver/Options.td:3611
   HelpText<"Enable the default Altivec ABI on AIX (AIX only). Uses only 
volatile vector registers.">;
+def maix_quadword_atomics : Flag<["-"], "maix64-quadword-atomics">,
+  Group, Flags<[CC1Option]>,

Would it be better if we called this `maix64-quadword-atomics` instead? 



Comment at: clang/test/Driver/ppc-unsupported.c:12
+// RUN:   -c %s 2>&1 | FileCheck %s
+// RUN: not %clang -target powerpc64le-unknown-linux -maix64-quadword-atomics \
+// RUN:   -c %s 2>&1 | FileCheck %s

Should we have a big endian Linux check, too?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127189

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


[PATCH] D128754: Refactor LLVM compression namespaces

2022-06-28 Thread Cole Kissane via Phabricator via cfe-commits
ckissane marked an inline comment as done.
ckissane added inline comments.



Comment at: clang-tools-extra/clangd/index/Serialization.cpp:242
+return error(
+"Compressed string table, but compression::serialize is unavailable");
 

leonardchan wrote:
> nit: Could we add some function that returns a string of whatever compression 
> is used? This way we have a more descriptive error message showing what 
> specifically is unavailable. Same comment elsewhere there's logging/error 
> reporting but the string is "compression::serialize".
sure, I can add a AlgorithmName property to the zlib namespace and future 
compression namespaces, then we can print out 
compression::serialize::AlgorithmName to see what is being used


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

https://reviews.llvm.org/D128754

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


[PATCH] D128754: Refactor LLVM compression namespaces

2022-06-28 Thread Cole Kissane via Phabricator via cfe-commits
ckissane marked an inline comment as done.
ckissane added inline comments.



Comment at: llvm/unittests/Support/CompressionTest.cpp:68
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}

leonardchan wrote:
> Should this be replaced with `llvm::crc32` rather than deleting this?
No Because llvm::crc32 has it's own tests already


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

https://reviews.llvm.org/D128754

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


[PATCH] D105584: [MLIR][OpenMP] Distribute Construct Operation

2022-06-28 Thread Abid via Phabricator via cfe-commits
abidmalikwaterloo added a comment.

  // CHECK-LABEL: omp_DistributeOp
  func.func @omp_DistributeOp(%lb : index, %ub : index, %step : index, 
%data_var : memref, %chunk_var : i32) -> () {
 // CHECK: omp.wsloop collapse(2)
"omp.DistributeOp" (%lb, %ub, %step) ({
  ^bb0(%iv: index):
   omp.yield
}) {operand_segment_sizes = dense<[1,1,1,0,0]> : vector<5xi32>, 
collapse_val = 2} :
  (index, index, index) -> ()
   
   return
   }

Is this a valid test case for the operation?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D105584

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


[PATCH] D128487: [ODRHash diagnostics] Move repetetive code at lambda calls into lambdas themselves. NFC.

2022-06-28 Thread Volodymyr Sapsai via Phabricator via cfe-commits
vsapsai added a comment.

Thanks for the review!

In D128487#3614251 , @ChuanqiXu wrote:

> Is it possible to combine the several `DiagNote` into `DiagError`? So that 
> the code would be further reduced. I am OK to do this kind of change in other 
> revisions.

Do you have any immediate ideas? I have more changes in this area (see the 
stack), so I'm interested in improving this code. I've started thinking about 
some approach that has less repetition but my initial approach was using macros 
and it started to look pretty complicated without finishing the whole change. 
So I've decided that the repetitive but simple code is easier to work with than 
something complicated. But maybe you have some good ideas.




Comment at: clang/lib/Serialization/ASTReader.cpp:9827
 return false;
-  };
+  };
 

ChuanqiXu wrote:
> Unitentional change?
I believe I've clang-formatted all of it. And in 
https://reviews.llvm.org/D128490 I'll change this lambda into 
`ODRDiagsEmitter::diagnoseSubMismatchTypedef`, so it will have a different 
formatting.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128487

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


[PATCH] D128550: [OpenMP] Change OpenMP code generation for target region entries

2022-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 updated this revision to Diff 440822.
jhuber6 added a comment.
Herald added subscribers: mattd, asavonic.

Fix tests, lots of lines.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128550

Files:
  clang/lib/CodeGen/CGOpenMPRuntime.cpp
  clang/test/OpenMP/capturing_in_templates.cpp
  clang/test/OpenMP/declare_mapper_codegen.cpp
  clang/test/OpenMP/declare_target_link_codegen.cpp
  clang/test/OpenMP/distribute_codegen.cpp
  clang/test/OpenMP/distribute_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_reduction_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_if_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_num_threads_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_parallel_for_simd_proc_bind_codegen.cpp
  clang/test/OpenMP/distribute_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_codegen.cpp
  clang/test/OpenMP/distribute_simd_firstprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_lastprivate_codegen.cpp
  clang/test/OpenMP/distribute_simd_private_codegen.cpp
  clang/test/OpenMP/distribute_simd_reduction_codegen.cpp
  clang/test/OpenMP/nvptx_lambda_capturing.cpp
  clang/test/OpenMP/nvptx_lambda_pointer_capturing.cpp
  clang/test/OpenMP/nvptx_target_requires_unified_shared_memory.cpp
  clang/test/OpenMP/openmp_offload_codegen.cpp
  clang/test/OpenMP/reduction_implicit_map.cpp
  clang/test/OpenMP/target_codegen.cpp
  clang/test/OpenMP/target_codegen_global_capture.cpp
  clang/test/OpenMP/target_data_member_codegen.cpp
  clang/test/OpenMP/target_data_use_device_ptr_if_codegen.cpp
  clang/test/OpenMP/target_defaultmap_codegen_01.cpp
  clang/test/OpenMP/target_defaultmap_codegen_02.cpp
  clang/test/OpenMP/target_depend_codegen.cpp
  clang/test/OpenMP/target_device_codegen.cpp
  clang/test/OpenMP/target_firstprivate_codegen.cpp
  clang/test/OpenMP/target_is_device_ptr_codegen.cpp
  clang/test/OpenMP/target_map_codegen_00.cpp
  clang/test/OpenMP/target_map_codegen_01.cpp
  clang/test/OpenMP/target_map_codegen_02.cpp
  clang/test/OpenMP/target_map_codegen_03.cpp
  clang/test/OpenMP/target_map_codegen_04.cpp
  clang/test/OpenMP/target_map_codegen_05.cpp
  clang/test/OpenMP/target_map_codegen_06.cpp
  clang/test/OpenMP/target_map_codegen_07.cpp
  clang/test/OpenMP/target_map_codegen_08.cpp
  clang/test/OpenMP/target_map_codegen_09.cpp
  clang/test/OpenMP/target_map_codegen_10.cpp
  clang/test/OpenMP/target_map_codegen_11.cpp
  clang/test/OpenMP/target_map_codegen_12.cpp
  clang/test/OpenMP/target_map_codegen_13.cpp
  clang/test/OpenMP/target_map_codegen_14.cpp
  clang/test/OpenMP/target_map_codegen_15.cpp
  clang/test/OpenMP/target_map_codegen_16.cpp
  clang/test/OpenMP/target_map_codegen_17.cpp
  clang/test/OpenMP/target_map_codegen_18.inc
  clang/test/OpenMP/target_map_codegen_19.cpp
  clang/test/OpenMP/target_map_codegen_20.cpp
  clang/test/OpenMP/target_map_codegen_21.cpp
  clang/test/OpenMP/target_map_codegen_22.cpp
  clang/test/OpenMP/target_map_codegen_23.cpp
  clang/test/OpenMP/target_map_codegen_24.cpp
  clang/test/OpenMP/target_map_codegen_25.cpp
  clang/test/OpenMP/target_map_codegen_26.cpp
  clang/test/OpenMP/target_map_codegen_27.cpp
  clang/test/OpenMP/target_map_codegen_28.cpp
  clang/test/OpenMP/target_map_codegen_29.cpp
  clang/test/OpenMP/target_map_codegen_30.cpp
  clang/test/OpenMP/target_map_codegen_31.cpp
  clang/test/OpenMP/target_map_codegen_32.cpp
  clang/test/OpenMP/target_map_codegen_33.cpp
  clang/test/OpenMP/target_map_codegen_34.cpp
  clang/test/OpenMP/target_map_codegen_35.cpp
  clang/test/OpenMP/target_map_codegen_hold.cpp
  clang/test/OpenMP/target_map_names.cpp
  clang/test/OpenMP/target_map_names_attr.cpp
  clang/test/OpenMP/target_offload_mandatory_codegen.cpp
  clang/test/OpenMP/target_parallel_codegen.cpp
  clang/test/OpenMP/target_parallel_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_codegen.cpp
  clang/test/OpenMP/target_parallel_for_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_depend_codegen.cpp
  clang/test/OpenMP/target_parallel_for_simd_uses_allocators_codegen.cpp
  

[PATCH] D128777: clang/cmake: Drop use of llvm-config for LLVM install discovery

2022-06-28 Thread Tom Stellard via Phabricator via cfe-commits
tstellar created this revision.
Herald added a subscriber: mgorny.
Herald added a project: All.
tstellar requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This has been deprecated for a while, remove it in favor of using
cmake's find_package() function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128777

Files:
  clang/CMakeLists.txt


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -15,76 +15,16 @@
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 
-  # Rely on llvm-config.
-  set(LLVM_CONFIG_OUTPUT)
-  if(LLVM_CONFIG)
-set (LLVM_CONFIG_FOUND 1)
-message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
-  deprecated.  The installed cmake files should be used \
-  instead.  CMake should be able to detect your LLVM install \
-  automatically, but you can also use LLVM_DIR to specify \
-  the path containing LLVMConfig.cmake.")
-set(CONFIG_COMMAND ${LLVM_CONFIG}
-  "--includedir"
-  "--prefix"
-  "--src-root"
-  "--cmakedir"
-  "--bindir"
-  "--libdir"
-  "--assertion-mode"
-  )
-execute_process(
-  COMMAND ${CONFIG_COMMAND}
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
-)
-if(NOT HAD_ERROR)
-  string(REGEX REPLACE
-"[ \t]*[\r\n]+[ \t]*" ";"
-LLVM_CONFIG_OUTPUT ${LLVM_CONFIG_OUTPUT})
-else()
-  string(REPLACE ";" " " CONFIG_COMMAND_STR "${CONFIG_COMMAND}")
-  message(STATUS "${CONFIG_COMMAND_STR}")
-  message(FATAL_ERROR "llvm-config failed with status ${HAD_ERROR}")
-endif()
-
-list(GET LLVM_CONFIG_OUTPUT 0 MAIN_INCLUDE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 1 LLVM_OBJ_ROOT)
-list(GET LLVM_CONFIG_OUTPUT 2 MAIN_SRC_DIR)
-list(GET LLVM_CONFIG_OUTPUT 3 LLVM_CONFIG_CMAKE_DIR)
-list(GET LLVM_CONFIG_OUTPUT 4 TOOLS_BINARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 5 LIBRARY_DIR)
-list(GET LLVM_CONFIG_OUTPUT 6 ENABLE_ASSERTIONS)
-
-# Normalize LLVM_CMAKE_DIR. --cmakedir might contain backslashes.
-# CMake assumes slashes as PATH.
-file(TO_CMAKE_PATH ${LLVM_CONFIG_CMAKE_DIR} LLVM_CMAKE_DIR)
-  endif()
-
-
-  if(NOT MSVC_IDE)
-set(LLVM_ENABLE_ASSERTIONS ${ENABLE_ASSERTIONS}
-  CACHE BOOL "Enable assertions")
-# Assertions should follow llvm-config's.
-mark_as_advanced(LLVM_ENABLE_ASSERTIONS)
-  endif()
-
   find_package(LLVM REQUIRED HINTS "${LLVM_CMAKE_DIR}")
   list(APPEND CMAKE_MODULE_PATH "${LLVM_DIR}")
 
-  # We can't check LLVM_CONFIG here, because find_package(LLVM ...) also sets
-  # LLVM_CONFIG.
-  if (NOT LLVM_CONFIG_FOUND)
-# Pull values from LLVMConfig.cmake.  We can drop this once the llvm-config
-# path is removed.
-set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
-set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
-# N.B. this is just a default value, the CACHE PATHs below can be 
overriden.
-set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
-set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
-set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
-  endif()
+  # Pull values from LLVMConfig.cmake.
+  set(MAIN_INCLUDE_DIR "${LLVM_INCLUDE_DIR}")
+  set(LLVM_OBJ_DIR "${LLVM_BINARY_DIR}")
+  # N.B. this is just a default value, the CACHE PATHs below can be overriden.
+  set(MAIN_SRC_DIR "${CMAKE_CURRENT_SOURCE_DIR}/../llvm")
+  set(TOOLS_BINARY_DIR "${LLVM_TOOLS_BINARY_DIR}")
+  set(LIBRARY_DIR "${LLVM_LIBRARY_DIR}")
 
   set(LLVM_MAIN_INCLUDE_DIR "${MAIN_INCLUDE_DIR}" CACHE PATH "Path to 
llvm/include")
   set(LLVM_BINARY_DIR "${LLVM_OBJ_ROOT}" CACHE PATH "Path to LLVM build tree")


Index: clang/CMakeLists.txt
===
--- clang/CMakeLists.txt
+++ clang/CMakeLists.txt
@@ -15,76 +15,16 @@
   set(CMAKE_CXX_STANDARD_REQUIRED YES)
   set(CMAKE_CXX_EXTENSIONS NO)
 
-  # Rely on llvm-config.
-  set(LLVM_CONFIG_OUTPUT)
-  if(LLVM_CONFIG)
-set (LLVM_CONFIG_FOUND 1)
-message(STATUS "Found LLVM_CONFIG as ${LLVM_CONFIG}")
-message(DEPRECATION "Using llvm-config to detect the LLVM installation is \
-  deprecated.  The installed cmake files should be used \
-  instead.  CMake should be able to detect your LLVM install \
-  automatically, but you can also use LLVM_DIR to specify \
-  the path containing LLVMConfig.cmake.")
-set(CONFIG_COMMAND ${LLVM_CONFIG}
-  "--includedir"
-  "--prefix"
-  "--src-root"
-  "--cmakedir"
-  "--bindir"
-  "--libdir"
-  "--assertion-mode"
-  )
-execute_process(
-  COMMAND ${CONFIG_COMMAND}
-  RESULT_VARIABLE HAD_ERROR
-  OUTPUT_VARIABLE LLVM_CONFIG_OUTPUT
-)
-if(NOT HAD_ERROR)
-  string(REGEX REPLACE
-"[ \t]*[\r\n]+[ \t]*" ";"
-

[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-28 Thread Prathit Aswar via Phabricator via cfe-commits
appmonster007 updated this revision to Diff 440819.
appmonster007 added a comment.

fixed warning comments for test cases


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

Files:
  clang/lib/Analysis/CFG.cpp
  clang/test/SemaCXX/warn-infinite-recursion.cpp


Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
 
+#include 
+
 void a() {  // expected-warning{{call itself}}
   a();
 }
@@ -171,3 +173,18 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+struct Q {
+  virtual ~Q(){};
+};
+
+Q q;
+Q _recursive_function(int x) {  // expected-warning{{call itself}}
+  (void)typeid(evaluated_recursive_function(x));  // expected-warning 
{{expression with side effects will be evaluated despite being used as an 
operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
\ No newline at end of file
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,28 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an glvalue of a
+  //   polymorphic class type [...] [the] expression is an unevaluated
+  //   operand. [...]
+  // We add only potentially evaluated statements to block to avoid
+  // CFG generation for unevaluated operands.
+  if (S && !S->isTypeDependent()) {
+if (S->isPotentiallyEvaluated()) {
+  return VisitChildren(S);
+}
+  }
+
+  // Return block without CFG for unevaluated operands.
+  return Block;
+}
+
 CFGBlock *CFGBuilder::VisitDoStmt(DoStmt *D) {
   CFGBlock *LoopSuccessor = nullptr;
 


Index: clang/test/SemaCXX/warn-infinite-recursion.cpp
===
--- clang/test/SemaCXX/warn-infinite-recursion.cpp
+++ clang/test/SemaCXX/warn-infinite-recursion.cpp
@@ -1,5 +1,7 @@
 // RUN: %clang_cc1 %s -fsyntax-only -verify -Winfinite-recursion
 
+#include 
+
 void a() {  // expected-warning{{call itself}}
   a();
 }
@@ -171,3 +173,18 @@
 }
 
 int wrapper_sum = test_wrapper<2>();  // expected-note{{instantiation}}
+
+struct Q {
+  virtual ~Q(){};
+};
+
+Q q;
+Q _recursive_function(int x) {  // expected-warning{{call itself}}
+  (void)typeid(evaluated_recursive_function(x));  // expected-warning {{expression with side effects will be evaluated despite being used as an operand to 'typeid'}}
+  return q;
+}
+
+int unevaluated_recursive_function() {
+  (void)typeid(unevaluated_recursive_function());
+  return 0;
+}
\ No newline at end of file
Index: clang/lib/Analysis/CFG.cpp
===
--- clang/lib/Analysis/CFG.cpp
+++ clang/lib/Analysis/CFG.cpp
@@ -564,6 +564,7 @@
 AddStmtChoice asc);
   CFGBlock *VisitCXXThrowExpr(CXXThrowExpr *T);
   CFGBlock *VisitCXXTryStmt(CXXTryStmt *S);
+  CFGBlock *VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc);
   CFGBlock *VisitDeclStmt(DeclStmt *DS);
   CFGBlock *VisitDeclSubExpr(DeclStmt *DS);
   CFGBlock *VisitDefaultStmt(DefaultStmt *D);
@@ -2220,6 +2221,9 @@
 case Stmt::CXXTryStmtClass:
   return VisitCXXTryStmt(cast(S));
 
+case Stmt::CXXTypeidExprClass:
+  return VisitCXXTypeidExpr(cast(S), asc);
+
 case Stmt::CXXForRangeStmtClass:
   return VisitCXXForRangeStmt(cast(S));
 
@@ -4045,6 +4049,28 @@
   return VisitStmt(T, AddStmtChoice::AlwaysAdd);
 }
 
+CFGBlock *CFGBuilder::VisitCXXTypeidExpr(CXXTypeidExpr *S, AddStmtChoice asc) {
+  if (asc.alwaysAdd(*this, S)) {
+autoCreateBlock();
+appendStmt(Block, S);
+  }
+
+  // C++ [expr.typeid]p3:
+  //   When typeid is applied to an expression other than an 

[PATCH] D128645: Update developer policy.

2022-06-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/docs/DeveloperPolicy.rst:403-405
+Note, these mailing lists are moderated and it is not unusual for a large
+commit to require a moderator to approve the email, so do not be concerned if a
+commit does not immediately appear in the archives.

"Note," => "Note that"
Add comma before "and".


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

https://reviews.llvm.org/D128645

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


[PATCH] D128645: Update developer policy.

2022-06-28 Thread Hubert Tong via Phabricator via cfe-commits
hubert.reinterpretcast added inline comments.



Comment at: llvm/docs/DeveloperPolicy.rst:88
+#. Patches should be unified diffs with "infinite context" (i.e. using 
something
+   like `git diff -U99 main`).
+

Using `git diff` like this, there are risks that `main` is now ahead of your 
branch's base. Probably safer to use `HEAD~n` where `n` is the number of 
commits you have on your branch.



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

https://reviews.llvm.org/D128645

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


[PATCH] D128774: [libTooling] Add a comment about comment parsing to getAssociatedRange.

2022-06-28 Thread Aaron Jacobs via Phabricator via cfe-commits
jacobsa created this revision.
jacobsa added a reviewer: klimek.
Herald added a project: All.
jacobsa requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

It took me multiple hours of debugging plus asking an expert for help to
figure out why this function didn't do what it promised to do. It turns
out there is a flag that needs to be set. Document this, in an attempt
to save the next person the surprise.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128774

Files:
  clang/include/clang/Tooling/Transformer/SourceCode.h


Index: clang/include/clang/Tooling/Transformer/SourceCode.h
===
--- clang/include/clang/Tooling/Transformer/SourceCode.h
+++ clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -41,6 +41,10 @@
 /// terminators. The returned range consists of file locations, if valid file
 /// locations can be found for the associated content; otherwise, an invalid
 /// range is returned.
+///
+/// Note that parsing comments is disabled by default. In order to select a
+/// range containing associated comments, you may need to invoke the tool with
+/// -fparse-all-comments.
 CharSourceRange getAssociatedRange(const Decl , ASTContext );
 
 /// Returns the source-code text in the specified range.


Index: clang/include/clang/Tooling/Transformer/SourceCode.h
===
--- clang/include/clang/Tooling/Transformer/SourceCode.h
+++ clang/include/clang/Tooling/Transformer/SourceCode.h
@@ -41,6 +41,10 @@
 /// terminators. The returned range consists of file locations, if valid file
 /// locations can be found for the associated content; otherwise, an invalid
 /// range is returned.
+///
+/// Note that parsing comments is disabled by default. In order to select a
+/// range containing associated comments, you may need to invoke the tool with
+/// -fparse-all-comments.
 CharSourceRange getAssociatedRange(const Decl , ASTContext );
 
 /// Returns the source-code text in the specified range.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128772: [Lex] Make sure to notify `MultipleIncludeOpt` for "read tokens" during fast dependency directive lexing

2022-06-28 Thread Argyrios Kyrtzidis via Phabricator via cfe-commits
akyrtzi created this revision.
Herald added a project: All.
akyrtzi requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Otherwise a header may be erroneously marked as having a header macro guard and 
won't get re-included.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128772

Files:
  clang/lib/Lex/Lexer.cpp
  clang/test/ClangScanDeps/more-content-after-headerguard.c


Index: clang/test/ClangScanDeps/more-content-after-headerguard.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/more-content-after-headerguard.c
@@ -0,0 +1,47 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json | FileCheck %s
+
+// CHECK: t.c
+// CHECK: top.h
+// CHECK: n1.h
+// CHECK: n2.h
+// CHECK: n3.h
+
+//--- cdb.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -fsyntax-only DIR/t.c",
+"file": "DIR/t.c"
+  }
+]
+
+//--- t.c
+
+#include "top.h"
+#define INCLUDE_N3
+#include "top.h"
+
+//--- top.h
+#ifndef _TOP_H_
+#define _TOP_H_
+
+#include "n1.h"
+
+#endif
+
+// More stuff after following '#endif', should invalidate the macro guard 
optimization.
+// and allow `top.h` to get re-included.
+#include "n2.h"
+
+//--- n1.h
+
+//--- n2.h
+#ifdef INCLUDE_N3
+#include "n3.h"
+#endif
+
+//--- n3.h
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -4248,6 +4248,10 @@
 
   const dependency_directives_scan::Token  =
   DepDirectives.front().Tokens[NextDepDirectiveTokenIndex++];
+  if (NextDepDirectiveTokenIndex > 1 || DDTok.Kind != tok::hash) {
+// Read something other than a preprocessor directive hash.
+MIOpt.ReadToken();
+  }
 
   const char *TokPtr = convertDependencyDirectiveToken(DDTok, Result);
 


Index: clang/test/ClangScanDeps/more-content-after-headerguard.c
===
--- /dev/null
+++ clang/test/ClangScanDeps/more-content-after-headerguard.c
@@ -0,0 +1,47 @@
+// RUN: rm -rf %t
+// RUN: split-file %s %t
+// RUN: sed -e "s|DIR|%/t|g" %t/cdb.json.template > %t/cdb.json
+
+// RUN: clang-scan-deps -compilation-database %t/cdb.json | FileCheck %s
+
+// CHECK: t.c
+// CHECK: top.h
+// CHECK: n1.h
+// CHECK: n2.h
+// CHECK: n3.h
+
+//--- cdb.json.template
+[
+  {
+"directory": "DIR",
+"command": "clang -fsyntax-only DIR/t.c",
+"file": "DIR/t.c"
+  }
+]
+
+//--- t.c
+
+#include "top.h"
+#define INCLUDE_N3
+#include "top.h"
+
+//--- top.h
+#ifndef _TOP_H_
+#define _TOP_H_
+
+#include "n1.h"
+
+#endif
+
+// More stuff after following '#endif', should invalidate the macro guard optimization.
+// and allow `top.h` to get re-included.
+#include "n2.h"
+
+//--- n1.h
+
+//--- n2.h
+#ifdef INCLUDE_N3
+#include "n3.h"
+#endif
+
+//--- n3.h
Index: clang/lib/Lex/Lexer.cpp
===
--- clang/lib/Lex/Lexer.cpp
+++ clang/lib/Lex/Lexer.cpp
@@ -4248,6 +4248,10 @@
 
   const dependency_directives_scan::Token  =
   DepDirectives.front().Tokens[NextDepDirectiveTokenIndex++];
+  if (NextDepDirectiveTokenIndex > 1 || DDTok.Kind != tok::hash) {
+// Read something other than a preprocessor directive hash.
+MIOpt.ReadToken();
+  }
 
   const char *TokPtr = convertDependencyDirectiveToken(DDTok, Result);
 
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-06-28 Thread Nathan James via Phabricator via cfe-commits
njames93 added inline comments.



Comment at: 
clang-tools-extra/test/clang-tidy/checkers/bugprone/branch-clone-unknown-expr.cpp:1
+// RUN: %check_clang_tidy -fix-errors %s bugprone-branch-clone %t
+

is -fix-errors necessary here, given we aren't verifying any fixits?


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

https://reviews.llvm.org/D128402

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


[PATCH] D128754: Refactor LLVM compression namespaces

2022-06-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

> Feedback needed on:
> this namespace approach will result in tooling compression methods being set 
> at compile time, however we may want to aim for a runtime configurable 
> approach in the future, likely a new revision of the compressed data formats 
> that llvm interfaces with with outside tools IE:
>
> - clang ast serialization code could be changed so compressed data could have 
> a flag indicating a compression type.
> - profile data code could be changed so compressed data could have a flag 
> indicating a compression type as well.

Using the compile time approach for now with the runtime approach in the future 
SGTM. I think some flag that could specify the decompression type is what we 
want in the long term, but the compile time approach I think is ok for now to 
not block you.




Comment at: clang-tools-extra/clangd/index/Serialization.cpp:242
+return error(
+"Compressed string table, but compression::serialize is unavailable");
 

nit: Could we add some function that returns a string of whatever compression 
is used? This way we have a more descriptive error message showing what 
specifically is unavailable. Same comment elsewhere there's logging/error 
reporting but the string is "compression::serialize".



Comment at: llvm/unittests/Support/CompressionTest.cpp:68
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}

Should this be replaced with `llvm::crc32` rather than deleting this?


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

https://reviews.llvm.org/D128754

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


[PATCH] D108469: Improve handling of static assert messages.

2022-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin updated this revision to Diff 440804.
cor3ntin added a comment.

- Undo the change of diagnostic message formatting as they break

libc++ tests
so we will keep printing  instead


Changing the format should be done -if at all- in a separate 
change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

Files:
  clang/docs/ReleaseNotes.rst
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/Lexer/null-character-in-literal.c
  clang/test/Misc/diag-special-chars.c
  clang/test/Misc/wrong-encoding.c
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/Unicode.cpp

Index: llvm/lib/Support/Unicode.cpp
===
--- llvm/lib/Support/Unicode.cpp
+++ llvm/lib/Support/Unicode.cpp
@@ -19,197 +19,271 @@
 namespace sys {
 namespace unicode {
 
+/// Unicode code points of the categories L, M, N, P, S and Zs are considered
+/// printable.
+/// In addition, U+00AD SOFT HYPHEN is also considered printable, as
+/// it's actually displayed on most terminals. \return true if the character is
+/// considered printable.
 bool isPrintable(int UCS) {
-  // Sorted list of non-overlapping intervals of code points that are not
-  // supposed to be printable.
-  static const UnicodeCharRange NonPrintableRanges[] = {
-{ 0x, 0x001F }, { 0x007F, 0x009F }, { 0x034F, 0x034F },
-{ 0x0378, 0x0379 }, { 0x037F, 0x0383 }, { 0x038B, 0x038B },
-{ 0x038D, 0x038D }, { 0x03A2, 0x03A2 }, { 0x0528, 0x0530 },
-{ 0x0557, 0x0558 }, { 0x0560, 0x0560 }, { 0x0588, 0x0588 },
-{ 0x058B, 0x058E }, { 0x0590, 0x0590 }, { 0x05C8, 0x05CF },
-{ 0x05EB, 0x05EF }, { 0x05F5, 0x0605 }, { 0x061C, 0x061D },
-{ 0x06DD, 0x06DD }, { 0x070E, 0x070F }, { 0x074B, 0x074C },
-{ 0x07B2, 0x07BF }, { 0x07FB, 0x07FF }, { 0x082E, 0x082F },
-{ 0x083F, 0x083F }, { 0x085C, 0x085D }, { 0x085F, 0x089F },
-{ 0x08A1, 0x08A1 }, { 0x08AD, 0x08E3 }, { 0x08FF, 0x08FF },
-{ 0x0978, 0x0978 }, { 0x0980, 0x0980 }, { 0x0984, 0x0984 },
-{ 0x098D, 0x098E }, { 0x0991, 0x0992 }, { 0x09A9, 0x09A9 },
-{ 0x09B1, 0x09B1 }, { 0x09B3, 0x09B5 }, { 0x09BA, 0x09BB },
-{ 0x09C5, 0x09C6 }, { 0x09C9, 0x09CA }, { 0x09CF, 0x09D6 },
-{ 0x09D8, 0x09DB }, { 0x09DE, 0x09DE }, { 0x09E4, 0x09E5 },
-{ 0x09FC, 0x0A00 }, { 0x0A04, 0x0A04 }, { 0x0A0B, 0x0A0E },
-{ 0x0A11, 0x0A12 }, { 0x0A29, 0x0A29 }, { 0x0A31, 0x0A31 },
-{ 0x0A34, 0x0A34 }, { 0x0A37, 0x0A37 }, { 0x0A3A, 0x0A3B },
-{ 0x0A3D, 0x0A3D }, { 0x0A43, 0x0A46 }, { 0x0A49, 0x0A4A },
-{ 0x0A4E, 0x0A50 }, { 0x0A52, 0x0A58 }, { 0x0A5D, 0x0A5D },
-{ 0x0A5F, 0x0A65 }, { 0x0A76, 0x0A80 }, { 0x0A84, 0x0A84 },
-{ 0x0A8E, 0x0A8E }, { 0x0A92, 0x0A92 }, { 0x0AA9, 0x0AA9 },
-{ 0x0AB1, 0x0AB1 }, { 0x0AB4, 0x0AB4 }, { 0x0ABA, 0x0ABB },
-{ 0x0AC6, 0x0AC6 }, { 0x0ACA, 0x0ACA }, { 0x0ACE, 0x0ACF },
-{ 0x0AD1, 0x0ADF }, { 0x0AE4, 0x0AE5 }, { 0x0AF2, 0x0B00 },
-{ 0x0B04, 0x0B04 }, { 0x0B0D, 0x0B0E }, { 0x0B11, 0x0B12 },
-{ 0x0B29, 0x0B29 }, { 0x0B31, 0x0B31 }, { 0x0B34, 0x0B34 },
-{ 0x0B3A, 0x0B3B }, { 0x0B45, 0x0B46 }, { 0x0B49, 0x0B4A },
-{ 0x0B4E, 0x0B55 }, { 0x0B58, 0x0B5B }, { 0x0B5E, 0x0B5E },
-{ 0x0B64, 0x0B65 }, { 0x0B78, 0x0B81 }, { 0x0B84, 0x0B84 },
-{ 0x0B8B, 0x0B8D }, { 0x0B91, 0x0B91 }, { 0x0B96, 0x0B98 },
-{ 0x0B9B, 0x0B9B }, { 0x0B9D, 0x0B9D }, { 0x0BA0, 0x0BA2 },
-{ 0x0BA5, 0x0BA7 }, { 0x0BAB, 0x0BAD }, { 0x0BBA, 0x0BBD },
-{ 0x0BC3, 0x0BC5 }, { 0x0BC9, 0x0BC9 }, { 0x0BCE, 0x0BCF },
-{ 0x0BD1, 0x0BD6 }, { 0x0BD8, 0x0BE5 }, { 0x0BFB, 0x0C00 },
-{ 0x0C04, 0x0C04 }, { 0x0C0D, 0x0C0D }, { 0x0C11, 0x0C11 },
-{ 0x0C29, 0x0C29 }, { 0x0C34, 0x0C34 }, { 0x0C3A, 0x0C3C },
-{ 0x0C45, 0x0C45 }, { 0x0C49, 0x0C49 }, { 0x0C4E, 0x0C54 },
-{ 0x0C57, 0x0C57 }, { 0x0C5A, 0x0C5F }, { 0x0C64, 0x0C65 },
-{ 0x0C70, 0x0C77 }, { 0x0C80, 0x0C81 }, { 0x0C84, 0x0C84 },
-{ 0x0C8D, 0x0C8D }, { 0x0C91, 0x0C91 }, { 0x0CA9, 0x0CA9 },
-{ 0x0CB4, 0x0CB4 }, { 0x0CBA, 0x0CBB }, { 0x0CC5, 0x0CC5 },
-{ 0x0CC9, 0x0CC9 }, { 0x0CCE, 0x0CD4 }, { 0x0CD7, 0x0CDD },
-{ 0x0CDF, 0x0CDF }, { 0x0CE4, 0x0CE5 }, { 0x0CF0, 0x0CF0 },
-{ 0x0CF3, 0x0D01 }, { 0x0D04, 0x0D04 }, { 0x0D0D, 0x0D0D },
-{ 0x0D11, 0x0D11 }, { 0x0D3B, 0x0D3C }, { 0x0D45, 0x0D45 },
-{ 0x0D49, 0x0D49 }, { 0x0D4F, 0x0D56 }, { 0x0D58, 0x0D5F },
-{ 0x0D64, 0x0D65 }, { 0x0D76, 0x0D78 }, { 0x0D80, 0x0D81 },
-{ 0x0D84, 0x0D84 }, { 0x0D97, 0x0D99 }, { 0x0DB2, 0x0DB2 },
-{ 0x0DBC, 0x0DBC }, { 0x0DBE, 0x0DBF }, { 0x0DC7, 0x0DC9 },
-{ 0x0DCB, 0x0DCE }, { 0x0DD5, 0x0DD5 }, { 0x0DD7, 0x0DD7 },
-{ 0x0DE0, 0x0DF1 }, { 0x0DF5, 0x0E00 }, { 0x0E3B, 0x0E3E },
-{ 0x0E5C, 0x0E80 }, { 0x0E83, 0x0E83 }, { 0x0E85, 0x0E86 },
-{ 0x0E89, 0x0E89 }, { 0x0E8B, 0x0E8C }, { 0x0E8E, 0x0E93 },

[clang] 57fa688 - [Driver][ARM][AArch64] Use err_drv_unsupported_option_argument for -march=/-mcpu=/-mtune= diagnostics

2022-06-28 Thread Fangrui Song via cfe-commits

Author: Fangrui Song
Date: 2022-06-28T16:01:30-07:00
New Revision: 57fa68897bb76e1fe5442784bca4e0629033c384

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

LOG: [Driver][ARM][AArch64] Use err_drv_unsupported_option_argument for 
-march=/-mcpu=/-mtune= diagnostics

err_drv_clang_unsupported is for a Clang unsupported option (any value is 
rejected).
err_drv_unsupported_option_argument is for an unsupported value (other values 
may be supported).

Added: 


Modified: 
clang/lib/Driver/ToolChains/Arch/AArch64.cpp
clang/lib/Driver/ToolChains/Arch/ARM.cpp
clang/test/Driver/aarch64-target-as-march.s
clang/test/Driver/arm-cortex-cpus-2.c
clang/test/Driver/arm-ias-Wa.s
clang/test/Preprocessor/aarch64-target-features.c

Removed: 




diff  --git a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp 
b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
index b17743b728d92..cf7e201b4972c 100644
--- a/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/AArch64.cpp
@@ -265,13 +265,13 @@ void aarch64::getAArch64TargetFeatures(const Driver ,
 D, getAArch64TargetCPU(Args, Triple, A), Args, Features);
 
   if (!success) {
-auto Diag = D.Diag(diag::err_drv_clang_unsupported);
+auto Diag = D.Diag(diag::err_drv_unsupported_option_argument);
 // If "-Wa,-march=" is used, 'WaMArch' will contain the argument's value,
 // while 'A' is uninitialized. Only dereference 'A' in the other case.
 if (!WaMArch.empty())
-  Diag << "-march=" + WaMArch.str();
+  Diag << "march=" << WaMArch;
 else
-  Diag << A->getAsString(Args);
+  Diag << A->getOption().getName() << A->getValue();
   }
 
   if (Args.getLastArg(options::OPT_mgeneral_regs_only)) {

diff  --git a/clang/lib/Driver/ToolChains/Arch/ARM.cpp 
b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
index b79d1f00ea48b..5c49db2f08379 100644
--- a/clang/lib/Driver/ToolChains/Arch/ARM.cpp
+++ b/clang/lib/Driver/ToolChains/Arch/ARM.cpp
@@ -121,7 +121,8 @@ static void checkARMArchName(const Driver , const Arg *A, 
const ArgList ,
   if (ArchKind == llvm::ARM::ArchKind::INVALID ||
   (Split.second.size() && !DecodeARMFeatures(D, Split.second, CPUName,
  ArchKind, Features, 
ArgFPUID)))
-D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
+D.Diag(clang::diag::err_drv_unsupported_option_argument)
+<< A->getOption().getName() << A->getValue();
 }
 
 // Check -mcpu=. Needs ArchName to handle -mcpu=generic.
@@ -137,7 +138,8 @@ static void checkARMCPUName(const Driver , const Arg *A, 
const ArgList ,
   if (ArchKind == llvm::ARM::ArchKind::INVALID ||
   (Split.second.size() &&
!DecodeARMFeatures(D, Split.second, CPU, ArchKind, Features, ArgFPUID)))
-D.Diag(clang::diag::err_drv_clang_unsupported) << A->getAsString(Args);
+D.Diag(clang::diag::err_drv_unsupported_option_argument)
+<< A->getOption().getName() << A->getValue();
 }
 
 bool arm::useAAPCSForMachO(const llvm::Triple ) {

diff  --git a/clang/test/Driver/aarch64-target-as-march.s 
b/clang/test/Driver/aarch64-target-as-march.s
index 03c3e395230df..7475414e12e61 100644
--- a/clang/test/Driver/aarch64-target-as-march.s
+++ b/clang/test/Driver/aarch64-target-as-march.s
@@ -51,5 +51,5 @@
 // RUN: %clang --target=aarch64-linux-gnueabi -### -c -Wa,-march=foobar %s 
2>&1 | \
 // RUN: FileCheck --check-prefix=INVALID-ARCH-2 %s
 
-// INVALID-ARCH-1: error: the clang compiler does not support '-march=all'
-// INVALID-ARCH-2: error: the clang compiler does not support '-march=foobar'
+// INVALID-ARCH-1: error: unsupported argument 'all' to option '-march='
+// INVALID-ARCH-2: error: unsupported argument 'foobar' to option '-march='

diff  --git a/clang/test/Driver/arm-cortex-cpus-2.c 
b/clang/test/Driver/arm-cortex-cpus-2.c
index beb3dbc3749b7..7d2c38b7cc0e3 100644
--- a/clang/test/Driver/arm-cortex-cpus-2.c
+++ b/clang/test/Driver/arm-cortex-cpus-2.c
@@ -143,20 +143,20 @@
 
 // == Check that a bogus architecture gives an error
 // RUN: %clang -target arm -march=armbogusv6 -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BOGUS %s
-// CHECK-BOGUS: error: {{.*}} does not support '-march=armbogusv6' 
+// CHECK-BOGUS: error: unsupported argument 'armbogusv6' to option '-march='
 // RUN: %clang -target arm---eabihf -march=armbogusv7 -### -c %s 2>&1 | 
FileCheck -check-prefix=CHECK-BOGUS-HF %s
-// CHECK-BOGUS-HF: error: {{.*}} does not support '-march=armbogusv7' 
+// CHECK-BOGUS-HF: error: unsupported argument 'armbogusv7' to option '-march='
 // RUN: %clang -target arm -march=armv6bogus -### -c %s 2>&1 | FileCheck 
-check-prefix=CHECK-BOGUS2 %s
-// CHECK-BOGUS2: error: {{.*}} does not support '-march=armv6bogus'
+// 

[PATCH] D124690: [clangd] add inlay hints for std::forward-ed parameter packs

2022-06-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge added inline comments.



Comment at: clang-tools-extra/clangd/InlayHints.cpp:483
+   !Type.getNonReferenceType().isConstQualified() &&
+   !isExpandedParameterPack(Param);
   }

sammccall wrote:
> why is this check needed if we already decline to provide a name for the 
> parameter on line 534 in chooseParameterNames?
`shouldHintName` and `shouldHintReference` are [two independent 
conditions](https://searchfox.org/llvm/rev/508eb41d82ca956c30950d9a16b522a29aeeb333/clang-tools-extra/clangd/InlayHints.cpp#411-418)
 governing whether we show the parameter name and/or a `&` indicating 
pass-by-mutable-ref, respectively

(I did approve the [patch](https://reviews.llvm.org/D124359) that introduced 
`shouldHintReference` myself, hope that's ok)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124690

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


[PATCH] D128329: [clangd] Also mark output arguments of operator call expressions

2022-06-28 Thread Nathan Ridge via Phabricator via cfe-commits
nridge accepted this revision.
nridge added a comment.
This revision is now accepted and ready to land.

Thanks!

I'm going to take the liberty of approving this, as it seems straightforward 
and unlikely to be contentious in any way.

Please let me know if you need me to commit it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128329

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


[PATCH] D128103: Adds AST Matcher for ObjCStringLiteral

2022-06-28 Thread Artem Dergachev via Phabricator via cfe-commits
NoQ added a comment.

Yes the use case is coming up in D126097 ; 
it's not used yet because `hasDescendant(StringLiteral)` is used to skip it but 
this matchert would be a more precise solution (yes there's an actual 
`StringLiteral` inside `ObjCStringLiteral`).


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

https://reviews.llvm.org/D128103

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


[PATCH] D128685: [OpenMP][NFC] Remove unused check lines in Clang/OpenMP tests

2022-06-28 Thread Johannes Doerfert 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 rG178674e23a71: [OpenMP][NFC] Remove unused check lines in 
Clang/OpenMP tests (authored by jdoerfert).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128685

Files:
  clang/test/OpenMP/nvptx_data_sharing.cpp
  clang/test/OpenMP/nvptx_distribute_parallel_generic_mode_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_codegen.cpp
  clang/test/OpenMP/nvptx_parallel_for_codegen.cpp
  clang/test/OpenMP/nvptx_target_teams_distribute_codegen.cpp
  clang/test/OpenMP/nvptx_teams_codegen.cpp
  clang/test/OpenMP/nvptx_teams_reduction_codegen.cpp

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


[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen updated this revision to Diff 440789.
ychen added a comment.

- add release notes
- update www-status


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
  clang/www/cxx_status.html

Index: clang/www/cxx_status.html
===
--- clang/www/cxx_status.html
+++ clang/www/cxx_status.html
@@ -959,7 +959,7 @@
   
   
 https://wg21.link/p2113r0;>P2113R0
-No
+Clang 15
   
 
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -15,12 +15,32 @@
 
 template  struct X {};
 
+namespace p6_2_1_1 {
+template 
+   bool operator==(X, V);
+templatebool operator==(T, X) = delete;
+
+bool h() {
+  // Prefer the first operator== since it is not a rewritten candidate.
+  return X{} == 0;
+}
+}
+
+namespace p6 {
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+} // namespace p6
+
+namespace PR49964 {
+  template  int f(T, U); // expected-note {{candidate function [with T = int, U = int]}}
+  template  int f(U, T); // expected-note {{candidate function [with T = int, U = int]}}
+
+  int x = f(0, 0); // expected-error {{call to 'f' is ambiguous}}
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 // expected-no-diagnostics
 
 namespace OrderWithStaticMember {
@@ -37,3 +38,17 @@
   void f(S s, V v) { s >> v; }
 }
 #endif
+
+#if __cplusplus >= 202002L
+namespace CWG2445 {
+  template  struct A { };
+
+  template 
+  bool operator==(T, A);
+
+  template 
+  bool operator!=(A, U) = delete;
+
+  bool f(A ax, A ay) { return ay != ax; }
+}
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -386,6 +386,7 @@
 return Sema::TDK_Inconsistent;
   }
 
+  Info.DeduceOrder.push_back(NTTP->getIndex());
   Deduced[NTTP->getIndex()] = Result;
   if (!S.getLangOpts().CPlusPlus17)
 return Sema::TDK_Success;
@@ -512,6 +513,7 @@
   return Sema::TDK_Inconsistent;
 }
 
+Info.DeduceOrder.push_back(TempParam->getIndex());
 Deduced[TempParam->getIndex()] = Result;
 return Sema::TDK_Success;
   }
@@ -1517,6 +1519,7 @@
   return Sema::TDK_Inconsistent;
 }
 
+Info.DeduceOrder.push_back(Index);
 Deduced[Index] = Result;
 return Sema::TDK_Success;
   }
@@ -4942,7 +4945,7 @@
 /// Determine whether the function template \p FT1 is at least as
 /// specialized as \p FT2.
 static bool isAtLeastAsSpecializedAs(Sema ,
- SourceLocation Loc,
+ TemplateDeductionInfo ,
  FunctionTemplateDecl *FT1,
  FunctionTemplateDecl *FT2,
  TemplatePartialOrderingContext TPOC,
@@ -4963,7 +4966,6 @@
   // C++0x [temp.deduct.partial]p3:
   //   The types used to determine the ordering depend on the context in which
   //   the partial ordering is done:
-  TemplateDeductionInfo Info(Loc);
   SmallVector Args2;
   switch (TPOC) {
   case TPOC_Call: {
@@ -5111,16 +5113,7 @@
 return false;
 
   ParmVarDecl *Last = Function->getParamDecl(NumParams - 1);
-  if (!Last->isParameterPack())
-return false;
-
-  // Make sure that no previous parameter is a parameter pack.
-  while (--NumParams > 0) {
-if (Function->getParamDecl(NumParams - 1)->isParameterPack())
-  return false;
-  }
-
-  return true;
+  return Last->isParameterPack();
 }
 
 /// Returns the more specialized function template according
@@ -5154,33 +5147,20 @@
 unsigned NumCallArguments2, bool Reversed,
 bool AllowOrderingByConstraints) {
 
-  auto JudgeByConstraints = [&]() -> FunctionTemplateDecl * {

[PATCH] D128766: Update references to Discourse instead of the mailing lists.

2022-06-28 Thread Tanya Lattner via Phabricator via cfe-commits
tonic created this revision.
Herald added a project: All.
tonic requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: cfe-commits, sstefan1.
Herald added a project: clang.

Update the references to the old Mailman mailing lists to point to Discourse 
forums.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128766

Files:
  clang/docs/ExternalClangExamples.rst
  clang/docs/InternalsManual.rst
  clang/docs/OpenCLSupport.rst
  clang/docs/OpenMPSupport.rst
  clang/docs/ReleaseNotes.rst
  clang/www/get_involved.html

Index: clang/www/get_involved.html
===
--- clang/www/get_involved.html
+++ clang/www/get_involved.html
@@ -28,41 +28,28 @@
 
 Follow what's going on
 
-Clang is a subproject of the https://llvm.org;>LLVM Project, but
-has its own mailing lists because the communities have people with different
-interests.  The two clang lists are:
+Clang is a subproject of the https://llvm.org;>LLVM Project
+and has a Discourse forum and mailing list:
 
 
 https://lists.llvm.org/mailman/listinfo/cfe-commits;>cfe-commits
  - This list is for patch submission/discussion.
 
-https://lists.llvm.org/mailman/listinfo/cfe-dev;>cfe-dev -
-This list is for everything else Clang related (questions and answers, design
+https://discourse.llvm.org/c/clang/6;>Clang Frontend Discourse forum -
+This forums is for everything else Clang related (questions and answers, design
 discussions, etc).
 
 
 
-If you are interested in clang only, these two lists should be all
-you need.  If you are interested in the LLVM optimizer and code generator,
-please consider signing up for https://lists.llvm.org/mailman/listinfo/llvm-dev;>llvm-dev and https://lists.llvm.org/mailman/listinfo/llvm-commits;>llvm-commits
-as well.
-
-
 The most common way to talk with other developers on the project is through
-the https://lists.llvm.org/mailman/listinfo/cfe-dev;>cfe-dev mailing
-list.  The clang mailing list is a very friendly place and we welcome
-newcomers.  In addition to the cfe-dev list, a significant amount of design
+the https://discourse.llvm.org/c/clang/6;>Clang Frontend Discourse forum
+.  The clang forum is a very friendly place and we welcome
+newcomers.  In addition to the forum, a significant amount of design
 discussion takes place on the https://lists.llvm.org/mailman/listinfo/cfe-commits;>cfe-commits mailing
 list.  All of these lists have archives, so you can browse through previous
 discussions or follow the list development on the web if you prefer.
 
-You can also follow the http://planet.clang.org/;>Planet Clang
-community news feed which offers a window into the world, work and lives of
-Clang developers, contributors and the standards they implement.
-
 If you're looking for something to work on, check out our Open Projects page or look through the https://github.com/llvm/llvm-project/issues/;>LLVM bug tracker.
Index: clang/docs/ReleaseNotes.rst
===
--- clang/docs/ReleaseNotes.rst
+++ clang/docs/ReleaseNotes.rst
@@ -639,5 +639,5 @@
 tree.
 
 If you have any questions or comments about Clang, please feel free to
-contact us via the `mailing
-list `_.
+contact us on the Discourse forums (Clang Frontend category)
+`_.
Index: clang/docs/OpenMPSupport.rst
===
--- clang/docs/OpenMPSupport.rst
+++ clang/docs/OpenMPSupport.rst
@@ -110,8 +110,9 @@
 =
 
 The following table provides a quick overview over various OpenMP 5.0 features
-and their implementation status. Please contact *openmp-dev* at
-*lists.llvm.org* for more information or if you want to help with the
+and their implementation status. Please post on the
+`Discourse forums (Runtimes - OpenMP category)`_ for more 
+information or if you want to help with the
 implementation.
 
 +--+--+--+---+
@@ -256,8 +257,10 @@
 
 The following table provides a quick overview over various OpenMP 5.1 features
 and their implementation status, as defined in the technical report 8 (TR8).
-Please contact *openmp-dev* at *lists.llvm.org* for more information or if you
-want to help with the implementation.
+Please post on the 
+`Discourse forums (Runtimes - OpenMP category)`_ for more 
+information or if you want to help with the
+implementation.
 
 +--+--+--+---+
 |Category  | Feature  | Status 

[PATCH] D108469: Improve handling of static assert messages.

2022-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin added a comment.

In D108469#3616983 , @leonardchan 
wrote:

> I think this might be the cause of the many libc++ static_assert failures 
> we're seeing on our builders: 
> https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8810079977358640657/overview

Thanks for the heads up, i reverted the patch until i can look into it. Sorry 
for the inconvenience


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

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


[clang] a774ba7 - Revert "Improve handling of static assert messages."

2022-06-28 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-06-29T00:03:23+02:00
New Revision: a774ba7f60d1fef403b5507b1b1a7475d3684d71

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

LOG: Revert "Improve handling of static assert messages."

This reverts commit 870b6d21839707a3e4c40a29b526995f065a220f.

This seems to break some libc++ tests, reverting while investigating

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Basic/Diagnostic.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
clang/test/C/drs/dr0xx.c
clang/test/CXX/dcl.dcl/p4-0x.cpp
clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
clang/test/Lexer/null-character-in-literal.c
clang/test/Misc/diag-special-chars.c
clang/test/Misc/wrong-encoding.c
clang/test/PCH/cxx-static_assert.cpp
clang/test/Sema/static-assert.c
clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
clang/test/SemaCXX/static-assert.cpp
llvm/include/llvm/Support/Unicode.h
llvm/lib/Support/Unicode.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 815430839489d..3e29987ad2631 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -273,8 +273,6 @@ Improvements to Clang's diagnostics
 - When using class templates without arguments, clang now tells developers
   that template arguments are missing in certain contexts.
   This fixes `Issue 55962 
`_.
-- Printable Unicode characters within ``static_assert`` messages are no longer
-  escaped.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 843024c988ef6..442088d078d98 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1527,9 +1527,9 @@ def err_static_assert_expression_is_not_constant : Error<
   "static_assert expression is not an integral constant expression">;
 def err_constexpr_if_condition_expression_is_not_constant : Error<
   "constexpr if condition is not a constant expression">;
-def err_static_assert_failed : Error<"static_assert failed%select{: %1|}0">;
+def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">;
 def err_static_assert_requirement_failed : Error<
-  "static_assert failed due to requirement '%0'%select{: %2 |}1">;
+  "static_assert failed due to requirement '%0'%select{ %2|}1">;
 
 def warn_consteval_if_always_true : Warning<
   "consteval if is always true in an %select{unevaluated|immediate}0 context">,

diff  --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index dbe62ecb50d33..deb398756e373 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -25,9 +25,8 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
-#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/CrashRecoveryContext.h"
-#include "llvm/Support/Unicode.h"
+#include "llvm/Support/Locale.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -804,50 +803,6 @@ FormatDiagnostic(SmallVectorImpl ) const {
   FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
 }
 
-/// pushEscapedString - Append Str to the diagnostic buffer,
-/// escaping non-printable characters and ill-formed code unit sequences.
-static void pushEscapedString(StringRef Str, SmallVectorImpl ) {
-  OutStr.reserve(OutStr.size() + Str.size());
-  auto *Begin = reinterpret_cast(Str.data());
-  llvm::raw_svector_ostream OutStream(OutStr);
-  const unsigned char *End = Begin + Str.size();
-  while (Begin != End) {
-// ASCII case
-if (isPrintable(*Begin) || isWhitespace(*Begin)) {
-  OutStream << *Begin;
-  ++Begin;
-  continue;
-}
-if (llvm::isLegalUTF8Sequence(Begin, End)) {
-  llvm::UTF32 CodepointValue;
-  llvm::UTF32 *CpPtr = 
-  const unsigned char *CodepointBegin = Begin;
-  const unsigned char *CodepointEnd =
-  Begin + llvm::getNumBytesForUTF8(*Begin);
-  llvm::ConversionResult Res = llvm::ConvertUTF8toUTF32(
-  , CodepointEnd, , CpPtr + 1, llvm::strictConversion);
-  (void)Res;
-  assert(
-  llvm::conversionOK == Res &&
-  "the sequence is legal UTF-8 but we couldn't convert it to UTF-32");
-  assert(Begin == CodepointEnd &&
- "we must be further along in the string now");
-  if (llvm::sys::unicode::isPrintable(CodepointValue) ||
-  llvm::sys::unicode::isFormatting(CodepointValue)) {
-

[PATCH] D128762: [Clang] Rename StringLiteral::isAscii() => isOrdinary() [NFC]

2022-06-28 Thread Corentin Jabot via Phabricator via cfe-commits
cor3ntin created this revision.
Herald added a reviewer: aaron.ballman.
Herald added a project: All.
cor3ntin requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

"Ascii" StringLiteral instances are actually narrow strings
that are UTF-8 encoded and do not have an encoding prefix.
(UTF8 StringLiteral are also UTF-8 encoded strings, but with
the u8 prefix.

To avoid possible confusion both with actuall ASCII strings,
and with future works extending the set of literal encodings
supported by clang, this rename StringLiteral::isAscii() to
isOrdinary(), matching C++ standard terminology.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128762

Files:
  clang/include/clang/AST/Expr.h
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/Expr.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/OSLog.cpp
  clang/lib/Frontend/Rewrite/RewriteModernObjC.cpp
  clang/lib/Frontend/Rewrite/RewriteObjC.cpp
  clang/lib/Parse/ParseDecl.cpp
  clang/lib/Parse/Parser.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDeclAttr.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaExprCXX.cpp
  clang/lib/Sema/SemaExprObjC.cpp
  clang/lib/Sema/SemaInit.cpp
  clang/lib/Sema/SemaStmtAsm.cpp

Index: clang/lib/Sema/SemaStmtAsm.cpp
===
--- clang/lib/Sema/SemaStmtAsm.cpp
+++ clang/lib/Sema/SemaStmtAsm.cpp
@@ -254,7 +254,7 @@
   SmallVector OutputConstraintInfos;
 
   // The parser verifies that there is a string literal here.
-  assert(AsmString->isAscii());
+  assert(AsmString->isOrdinary());
 
   FunctionDecl *FD = dyn_cast(getCurLexicalContext());
   llvm::StringMap FeatureMap;
@@ -262,7 +262,7 @@
 
   for (unsigned i = 0; i != NumOutputs; i++) {
 StringLiteral *Literal = Constraints[i];
-assert(Literal->isAscii());
+assert(Literal->isOrdinary());
 
 StringRef OutputName;
 if (Names[i])
@@ -353,7 +353,7 @@
 
   for (unsigned i = NumOutputs, e = NumOutputs + NumInputs; i != e; i++) {
 StringLiteral *Literal = Constraints[i];
-assert(Literal->isAscii());
+assert(Literal->isOrdinary());
 
 StringRef InputName;
 if (Names[i])
@@ -459,7 +459,7 @@
   // Check that the clobbers are valid.
   for (unsigned i = 0; i != NumClobbers; i++) {
 StringLiteral *Literal = Clobbers[i];
-assert(Literal->isAscii());
+assert(Literal->isOrdinary());
 
 StringRef Clobber = Literal->getString();
 
Index: clang/lib/Sema/SemaInit.cpp
===
--- clang/lib/Sema/SemaInit.cpp
+++ clang/lib/Sema/SemaInit.cpp
@@ -87,7 +87,7 @@
 if (ElemTy->isChar8Type())
   return SIF_None;
 LLVM_FALLTHROUGH;
-  case StringLiteral::Ascii:
+  case StringLiteral::Ordinary:
 // char array can be initialized with a narrow string.
 // Only allow char x[] = "foo";  not char x[] = L"foo";
 if (ElemTy->isCharType())
Index: clang/lib/Sema/SemaExprObjC.cpp
===
--- clang/lib/Sema/SemaExprObjC.cpp
+++ clang/lib/Sema/SemaExprObjC.cpp
@@ -50,7 +50,7 @@
   S = cast(E);
 
   // ObjC strings can't be wide or UTF.
-  if (!S->isAscii()) {
+  if (!S->isOrdinary()) {
 Diag(S->getBeginLoc(), diag::err_cfstring_literal_not_string_constant)
 << S->getSourceRange();
 return true;
@@ -70,7 +70,7 @@
 QualType StrTy = Context.getConstantArrayType(
 CAT->getElementType(), llvm::APInt(32, StrBuf.size() + 1), nullptr,
 CAT->getSizeModifier(), CAT->getIndexTypeCVRQualifiers());
-S = StringLiteral::Create(Context, StrBuf, StringLiteral::Ascii,
+S = StringLiteral::Create(Context, StrBuf, StringLiteral::Ordinary,
   /*Pascal=*/false, StrTy, [0],
   StrLocs.size());
   }
@@ -448,7 +448,7 @@
 }
 // If this is potentially an Objective-C string literal, add the '@'.
 else if (StringLiteral *String = dyn_cast(OrigElement)) {
-  if (String->isAscii()) {
+  if (String->isOrdinary()) {
 S.Diag(OrigElement->getBeginLoc(), diag::err_box_literal_collection)
 << 0 << OrigElement->getSourceRange()
 << FixItHint::CreateInsertion(OrigElement->getBeginLoc(), "@");
@@ -533,7 +533,7 @@
 if (CE->getCastKind() == CK_ArrayToPointerDecay)
   if (auto *SL =
   dyn_cast(CE->getSubExpr()->IgnoreParens())) {
-assert((SL->isAscii() || SL->isUTF8()) &&
+assert((SL->isOrdinary() || SL->isUTF8()) &&
"unexpected character encoding");
 StringRef Str = SL->getString();
 const llvm::UTF8 *StrBegin = Str.bytes_begin();
Index: clang/lib/Sema/SemaExprCXX.cpp
===
--- clang/lib/Sema/SemaExprCXX.cpp
+++ clang/lib/Sema/SemaExprCXX.cpp
@@ -4009,7 

[PATCH] D128569: Start support for HLSL `RWBuffer`

2022-06-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz updated this revision to Diff 440778.
beanz added a comment.

Updating based on PR feedback and removing the new builtins.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128569

Files:
  clang/include/clang/Sema/HLSLExternalSemaSource.h
  clang/lib/AST/DeclTemplate.cpp
  clang/lib/Sema/HLSLExternalSemaSource.cpp
  clang/test/AST/HLSL/RWBuffer-AST.hlsl
  clang/test/AST/HLSL/ResourceStruct.hlsl
  clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl

Index: clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
===
--- /dev/null
+++ clang/test/SemaHLSL/BuiltIns/RWBuffers.hlsl
@@ -0,0 +1,12 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-compute -x hlsl -fsyntax-only -verify %s
+
+Resource ResourceDescriptorHeap[5];
+typedef vector float3;
+
+RWBuffer Buffer;
+
+[numthreads(1,1,1)]
+void main() {
+  (void)Buffer.h; // expected-error {{'h' is a private member of 'hlsl::RWBuffer'}}
+  // expected-note@* {{implicitly declared private here}}
+}
Index: clang/test/AST/HLSL/ResourceStruct.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/ResourceStruct.hlsl
@@ -0,0 +1,13 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.3-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s 
+
+// CHECK: NamespaceDecl {{.*}} implicit hlsl
+// CHECK: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit  class Resource definition
+// CHECK-NEXT: DefinitionData pass_in_registers standard_layout trivially_copyable trivial literal
+// CHECK-NEXT: DefaultConstructor exists trivial needs_implicit
+// CHECK-NEXT: CopyConstructor simple trivial has_const_param needs_implicit implicit_has_const_param
+// CHECK-NEXT: MoveConstructor exists simple trivial needs_implicit
+// CHECK-NEXT: CopyAssignment simple trivial has_const_param needs_implicit implicit_has_const_param
+// CHECK-NEXT: MoveAssignment exists simple trivial needs_implicit
+// CHECK-NEXT: Destructor simple irrelevant trivial needs_implicit
+// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'int'
Index: clang/test/AST/HLSL/RWBuffer-AST.hlsl
===
--- /dev/null
+++ clang/test/AST/HLSL/RWBuffer-AST.hlsl
@@ -0,0 +1,37 @@
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump -DEMPTY %s | FileCheck -check-prefix=EMPTY %s 
+// RUN: %clang_cc1 -triple dxil-pc-shadermodel6.0-library -x hlsl -fsyntax-only -ast-dump %s | FileCheck %s 
+
+// EMPTY: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <>  implicit RWBuffer
+// EMPTY-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <>  class depth 0 index 0 element_type
+// EMPTY-NEXT: TemplateArgument type 'float'
+// EMPTY-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
+// EMPTY-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit  class RWBuffer
+// EMPTY-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+
+// There should be no more occurrances of RWBuffer
+// EMPTY-NOT: RWBuffer
+
+#ifndef EMPTY
+
+RWBuffer Buffer;
+
+#endif
+
+// CHECK: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit  class Resource definition
+// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'int'
+
+// CHECK: ClassTemplateDecl 0x{{[0-9A-Fa-f]+}} <>  implicit RWBuffer
+// CHECK-NEXT: TemplateTypeParmDecl 0x{{[0-9A-Fa-f]+}} <>  class depth 0 index 0 element_type
+// CHECK-NEXT: TemplateArgument type 'float'
+// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
+// CHECK-NEXT: CXXRecordDecl 0x{{[0-9A-Fa-f]+}} <>  implicit class RWBuffer definition
+
+// CHECK: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'int'
+// CHECK-NEXT: ClassTemplateSpecializationDecl 0x{{[0-9A-Fa-f]+}} <>  class RWBuffer definition
+
+// CHECK: TemplateArgument type 'float'
+// CHECK-NEXT: BuiltinType 0x{{[0-9A-Fa-f]+}} 'float'
+// CHECK-NEXT: FinalAttr 0x{{[0-9A-Fa-f]+}} <> Implicit final
+// CHECK-NEXT: FieldDecl 0x{{[0-9A-Fa-f]+}} <>  implicit h 'int'
Index: clang/lib/Sema/HLSLExternalSemaSource.cpp
===
--- clang/lib/Sema/HLSLExternalSemaSource.cpp
+++ clang/lib/Sema/HLSLExternalSemaSource.cpp
@@ -15,8 +15,160 @@
 #include "clang/Basic/AttrKinds.h"
 #include "clang/Sema/Sema.h"
 
+#include 
+
 using namespace clang;
 
+namespace {
+
+struct TemplateParameterListBuilder;
+
+struct BuiltinTypeDeclBuilder {
+  CXXRecordDecl *Record = nullptr;
+  ClassTemplateDecl *Template = nullptr;
+  NamespaceDecl *HLSLNamespace = nullptr;
+
+  BuiltinTypeDeclBuilder(CXXRecordDecl *R) : Record(R) {
+Record->startDefinition();
+Template = Record->getDescribedClassTemplate();
+  }
+
+  BuiltinTypeDeclBuilder(Sema , NamespaceDecl *Namespace, StringRef Name)
+  : 

[PATCH] D128569: Start support for HLSL `RWBuffer`

2022-06-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:1703
 LANGBUILTIN(WaveActiveCountBits, "Uib", "nc", HLSL_LANG)
+LANGBUILTIN(__builtin_hlsl_get_resource_pointer, "v*", "i", HLSL_LANG)
+LANGBUILTIN(__builtin_hlsl_get_resource_status, "Ui", "i", HLSL_LANG)

python3kgae wrote:
> Is it possible to return a ptr with special address space so we know it is 
> from a resource?
Yes, although I'm going to actually hold back the builtins from this patch. I 
don't think these are quite what we want to generate.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128569

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


[PATCH] D108469: Improve handling of static assert messages.

2022-06-28 Thread Leonard Chan via Phabricator via cfe-commits
leonardchan added a comment.

I think this might be the cause of the many libc++ static_assert failures we're 
seeing on our builders: 
https://luci-milo.appspot.com/ui/p/fuchsia/builders/toolchain.ci/clang-linux-x64/b8810079977358640657/overview


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

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


[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D128752#3616837 , @jhuber6 wrote:

> In D128752#3616831 , @tra wrote:
>
>> Do we have tests that verify `-target-feature` arguments? It may be worth 
>> adding a test case there checking for redundant features.
>
> Yeah, we have some existing tests that check for including the target 
> features at least once. I felt like there was no need to include a test for 
> what was more or less an oversight

The test helps a lot to illustrate what the patch does. There are enough moving 
parts in the driver that, while I do believe that what the patch description 
says is intended to be true, I would like to see specific evidence that it's 
indeed the case. 
Think of it as a test case that should've been added when we've started passing 
the feature flags.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128752

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


[PATCH] D114728: [Coroutine] Remove the prologue data of `-fsanitize=function` for split functions

2022-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen abandoned this revision.
ychen added a comment.
Herald added a project: All.

D115844  and D116130 
 supersede this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114728

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


[PATCH] D128653: [PowerPC] Fix the check for scalar MASS conversion

2022-06-28 Thread Bardia Mahjour via Phabricator via cfe-commits
bmahjour added inline comments.



Comment at: clang/test/CodeGen/lower-mass-end-to-end.c:33
+// CHECK-MASS-AFN: __xl_sin
+// CHECK-NO-MASS-FAST-NOT: __xl_sin{{_finite}}
+// CHECK-NO-MASS-AFN-NOT: __xl_sin{{_finite}}

I don't think this works the way you expect it:

```
> cat input.txt
; CHECK-NOT: __xl_sin{{_finite}}
> echo "__xl_sin" | ./bin/FileCheck ./input.txt
>
```

this seems closer to what you want:
```
; CHECK-NOT: {{__xl_sin|__xl_sin_finite}}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128653

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


[PATCH] D128747: ISSUE - incorrect -Winfinite-recursion warning on potentially-unevaluated operand #21668

2022-06-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

Thank for looking at this bug, just a small comment on the test.




Comment at: clang/test/SemaCXX/warn-infinite-recursion.cpp:178
+struct Q {
+  virtual ~Q(){};
+};

Looks like your missing `// expected-warning{{call itself}}` 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128747

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


[PATCH] D128333: [clang][flang] Disable defaulting to `-fpie` for LLVM Flang

2022-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay accepted this revision.
MaskRay added inline comments.
This revision is now accepted and ready to land.



Comment at: flang/test/Driver/no-pie.f90:3
+
+!-
+! RUN COMMANDS

awarzynski wrote:
> MaskRay wrote:
> > The `! RUN COMMANDS` and `EXPECTED OUTPUT` comments seem rather redundant. 
> > I'd remove them.
> This style is quite common in this directory, see e.g. 
> https://github.com/llvm/llvm-project/blob/main/flang/test/Driver/emit-asm-aarch64.f90.
>  I'm hoping that this makes these tests easier to follow for folks less 
> familiar with LIT in general.
> 
> If that's OK, I'll leave this here (but I don't expect others to follow 
> similar approach, IMO it's a matter of personal preference).
Since this is precedent, I assume this is fine. I will note here that this is 
contrary to the convention almost everywhere in llvm-project...



Comment at: flang/test/Driver/pic-flags.f90:6
+!-
+! RUN: %flang -### %s -target aarch64-linux-gnu 2>&1 | FileCheck %s 
--check-prefix=CHECK-NOPIE
+! RUN: %flang -### %s -target aarch64-linux-gnu -fno-pie 2>&1 | FileCheck %s 
--check-prefix=CHECK-NOPIE

In clang driver, `-target ` is a deprecated form (`Separate` style options are 
very uncommon in external command line utilities). The preferred spelling is 
`--target=`



Comment at: flang/test/Driver/pic-flags.f90:15
+! CHECK-NOPIE: "-fc1"
+! CHECk-NOPIE-NOT: fpic
+! CHECK-NOPIE: "{{.*}}ld"

fpic is not waterproof. The temporary object file name or the working directory 
may have `fpic` as a substring. Use `"-fpic"`



Comment at: flang/test/Driver/pic-flags.f90:20
+! CHECK-PIE: "-fc1"
+! TODO: Once Flang supports `-fpie`, it //should// use -fpic when invoking 
`flang -fc1`. Update the following line once `-fpie` is
+! available.

`! TODO:` may possibly be recognized a future FileCheck/lit as a stale check 
prefix. Personally I may use something like `!! TODO:`. I guess you are just 
following existing practice so this may be fine.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128333

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


[PATCH] D124624: [OpenMP] Add variant extension that applies to declarations

2022-06-28 Thread Johannes Doerfert via Phabricator via cfe-commits
jdoerfert accepted this revision.
jdoerfert added a comment.
This revision is now accepted and ready to land.

LG. one nit.




Comment at: clang/include/clang/Basic/AttrDocs.td:4312
 declarations with the same name. The template parameters for the base functions
-are used to instantiate the specialization.
-
+are used to instantiate the specialization. if ``bind_to_declartion`` is given,
+apply the same variant rules to function declarations. This allows the user to




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D124624

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


[PATCH] D126857: [HLSL] Add WaveActiveCountBits as Langugage builtin function for HLSL

2022-06-28 Thread Chris Bieneman via Phabricator via cfe-commits
beanz added inline comments.



Comment at: clang/include/clang/Basic/Builtins.def:1697
+// HLSL
+LANGBUILTIN(WaveActiveCountBits, "Uib", "nc", HLSL_LANG)
+

beanz wrote:
> python3kgae wrote:
> > Anastasia wrote:
> > > python3kgae wrote:
> > > > Anastasia wrote:
> > > > > FYI we most of time try to add a builtin name using a reserved 
> > > > > identifier which is not part of the language standard (mostly 
> > > > > prefixed by `__`). Then we add regular function that just calls the 
> > > > > clang builtins. This way provides more flexibility to the 
> > > > > implementers. However you might not need this... in which case using 
> > > > > original name avoids an extra call.
> > > > Yes. For this one, it is without prefix to avoid extra call.
> > > > I'm following things like enqueue_kernel in opencl.
> > > > For other things support overload which has to make extra call, I'll 
> > > > add the prefix.
> > > Ok, although `enqueue_kernel` was implemented as a builtin because it has 
> > > a weird variadic prototype that can't be implemented using normal 
> > > features of C/C++ languages. Hence it is a builtin with custom 
> > > SemaChecking.
> > I see.
> > Since HLSL also has things cannot implemented using HLSL itself, we cannot  
> >  put all HLSL intrinsic in one place anyway.
> > So when it is possible to reduce an extra call, I just reduce it.
> I don't think this was the right decision. It is trivial for the optimizer to 
> remove a function that is more or less a tail-call of another function, and 
> since HLSL has no call semantics anyways they will disappear.
> 
> It would be much better if this was a function that called the builtin, this 
> could even be trivially implemented as a sub-header of hlsl.h as a wrapper 
> function. 
Let me expand a little here. I think we need to change this. We should name 
builtins as builtins (i.e. __builtin_hlsl_...), and we can implement a wrapper 
function in one of the headers from hlsl.h.

There are two reasons I think we should take this approach:

1) Matching existing builtin patterns makes it clear in the code
2) Clang builtins don't populate in the AST for AST queries, which impacts how 
the function for IDE tooling. Having the HLSL user-surfaced functions exist in 
the AST will allow for better IDE tooling for autocomplete.

If hlsl.h gets too slow to parse, there are other approaches we can take like 
using the external sema source, modules or PCH to speed it up later.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126857

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


[PATCH] D128679: [pseudo] Define a clangPseudoCLI library.

2022-06-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein added inline comments.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/GLR.h:115
 // Parameters for the GLR parsing.
+// FIXME: refine it with the ParseLang struct.
 struct ParseParams {

sammccall wrote:
> You're already touching the callsites of the glr* functions, it might be 
> worth just doing this already... up to you
these callsites are trivial to update. I'd prefer to do it in a separate patch.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h:1
+//===--- ParseLang.h --- -*- 
C++-*-===//
+//

sammccall wrote:
> The "ParseLang" name doesn't feel right to me :-(
> 
> I think it's a combination of:
>  - Lang is unneccesarily abbreviated
>  - "Parse" doesn't actually disambiguate much, as "parse" is the whole project
> 
> Do you think `clang::pseudo::Language` would work?
> 
> 
> (Sorry for not realizing this on the previous pass, I know it's a pain... 
> happy to chat more offline)
That sounds good to me. Regarding the location of this file, I think the subdir 
grammar will be a better fit.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h:19
+// Specify a language that can be parsed by the pseduoparser.
+// Manifest generated from a bnf grammar file.
+struct ParseLang {

sammccall wrote:
> I don't know what this sentence means - is it always true? is it necessary?
I think it is always true for the grammar and LRTable object, but might not be 
true for the LangOptions. Removed.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/ParseLang.h:24
+
+  // FIXME: add clang::LangOptions.
+  // FIXME: add default start symbols.

sammccall wrote:
> is this "fix right after this patch" or "fix sometime, maybe" or something in 
> between?
> 
> (I think these make a lot of sense, and am worried the structure will be 
> incoherent if we don't actually add them soon)
I would expect we will add them soon.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h:9
+//
+// A library shared among different pseudoparser-based tools. It provides a
+// uniform way to get basic pieces of the parser (Grammar, LRTable etc) from

sammccall wrote:
> The first sentence should say what it is, rather than what calls it.
> 
> If the file by design defines a single thing function I'm not sure a file 
> comment distinct from the function comment helps much, maybe merge them?
I'm not sure whether we will add more functions in this library (though I can't 
come up with one), I will just keep the file comment.



Comment at: clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h:27
+// Returns the corresponding language from the '--grammar' command-line flag.
+const ParseLang ();
+

sammccall wrote:
> this should generally be called exactly one from CLI tools - why does it need 
> to be memoized and returned as a reference?
yeah, for now, returning an object is ok, but in the future, when we build the 
ParseLang (LRTable, LRGrammar) for cxx.bnf in a fully-static way, we might have 
trouble right?



Comment at: clang-tools-extra/pseudo/lib/cli/CLI.cpp:38
+   << "': " << EC.message() << "\n";
+  std::exit(1);
+}

sammccall wrote:
> this is extremely surprising.
> At minimum it needs to be very clearly documented, but I think it's probably 
> better to return null to the caller
It doesn't seem to be surprising to me, as this function is used for the CLI 
tools, crashing the program when the input grammar text is invalid seems 
reasonable (all our exiting CLI tools at the moment behave like this), and we 
have print the error message. 

Returning a nullptr seems annoying IMO -- it requires all callers to handle 
this unimportant case. Updated the document for this function.



Comment at: clang-tools-extra/pseudo/lib/cli/CLI.cpp:42
+auto G = Grammar::parseBNF(GrammarText->get()->getBuffer(), Diags);
+if (!Diags.empty()) {
+  for (const auto  : Diags)

sammccall wrote:
> this if() isn't needed unless you want to print a header to provide some 
> context (which might be a good idea)
I don't get your point of the comment.  Not sure what you meant by  `Print a 
header`? 

I think for the CLI tool use-case, printing the diagnostic of the grammar by 
default is reasonable.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128679

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


[PATCH] D128103: Adds AST Matcher for ObjCStringLiteral

2022-06-28 Thread Rashmi Mudduluru via Phabricator via cfe-commits
t-rasmud updated this revision to Diff 440766.
t-rasmud added a comment.

Removes manually added documentation and adds it in the header file.


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

https://reviews.llvm.org/D128103

Files:
  clang/include/clang/ASTMatchers/ASTMatchers.h
  clang/lib/ASTMatchers/ASTMatchersInternal.cpp
  clang/lib/ASTMatchers/Dynamic/Registry.cpp
  clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp


Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2352,6 +2352,26 @@
argumentCountIs(0;
 }
 
+TEST(ASTMatchersTestObjC, ObjCStringLiteral) {
+
+  StringRef Objc1String = "@interface NSObject "
+  "@end "
+  "@interface NSString "
+  "@end "
+  "@interface Test : NSObject "
+  "+ (void)someFunction:(NSString *)Desc; "
+  "@end "
+  "@implementation Test "
+  "+ (void)someFunction:(NSString *)Desc { "
+  "return; "
+  "} "
+  "- (void) foo { "
+  "[Test someFunction:@\"Ola!\"]; "
+  "}\n"
+  "@end ";
+EXPECT_TRUE(matchesObjC(Objc1String, objcStringLiteral()));
+}
+
 TEST(ASTMatchersTestObjC, ObjCDecls) {
   StringRef ObjCString = "@protocol Proto "
  "- (void)protoDidThing; "
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -505,6 +505,7 @@
   REGISTER_MATCHER(objcObjectPointerType);
   REGISTER_MATCHER(objcPropertyDecl);
   REGISTER_MATCHER(objcProtocolDecl);
+  REGISTER_MATCHER(objcStringLiteral);
   REGISTER_MATCHER(objcThrowStmt);
   REGISTER_MATCHER(objcTryStmt);
   REGISTER_MATCHER(ofClass);
Index: clang/lib/ASTMatchers/ASTMatchersInternal.cpp
===
--- clang/lib/ASTMatchers/ASTMatchersInternal.cpp
+++ clang/lib/ASTMatchers/ASTMatchersInternal.cpp
@@ -917,6 +917,7 @@
 const internal::VariadicDynCastAllOfMatcher
 cxxBoolLiteral;
 const internal::VariadicDynCastAllOfMatcher stringLiteral;
+const internal::VariadicDynCastAllOfMatcher 
objcStringLiteral;
 const internal::VariadicDynCastAllOfMatcher
 characterLiteral;
 const internal::VariadicDynCastAllOfMatcher
Index: clang/include/clang/ASTMatchers/ASTMatchers.h
===
--- clang/include/clang/ASTMatchers/ASTMatchers.h
+++ clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -1515,6 +1515,15 @@
 extern const internal::VariadicDynCastAllOfMatcher
 objcMessageExpr;
 
+/// Matches ObjectiveC String literal expressions.
+///
+/// Example matches @"abcd"
+/// \code
+///   NSString *s = @"abcd";
+/// \endcode
+extern const internal::VariadicDynCastAllOfMatcher
+objcStringLiteral;
+
 /// Matches Objective-C interface declarations.
 ///
 /// Example matches Foo


Index: clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
===
--- clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
+++ clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp
@@ -2352,6 +2352,26 @@
argumentCountIs(0;
 }
 
+TEST(ASTMatchersTestObjC, ObjCStringLiteral) {
+
+  StringRef Objc1String = "@interface NSObject "
+  "@end "
+  "@interface NSString "
+  "@end "
+  "@interface Test : NSObject "
+  "+ (void)someFunction:(NSString *)Desc; "
+  "@end "
+  "@implementation Test "
+  "+ (void)someFunction:(NSString *)Desc { "
+  "return; "
+  "} "
+  "- (void) foo { "
+  "[Test someFunction:@\"Ola!\"]; "
+  "}\n"
+  "@end ";
+EXPECT_TRUE(matchesObjC(Objc1String, objcStringLiteral()));
+}
+
 TEST(ASTMatchersTestObjC, ObjCDecls) {
   StringRef ObjCString = "@protocol Proto "
  "- (void)protoDidThing; "
Index: clang/lib/ASTMatchers/Dynamic/Registry.cpp
===
--- clang/lib/ASTMatchers/Dynamic/Registry.cpp
+++ clang/lib/ASTMatchers/Dynamic/Registry.cpp
@@ -505,6 +505,7 @@
   REGISTER_MATCHER(objcObjectPointerType);
   

[PATCH] D128679: [pseudo] Define a clangPseudoCLI library.

2022-06-28 Thread Haojian Wu via Phabricator via cfe-commits
hokein updated this revision to Diff 440765.
hokein marked an inline comment as done.
hokein added a comment.

address comments


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128679

Files:
  clang-tools-extra/pseudo/benchmarks/Benchmark.cpp
  clang-tools-extra/pseudo/benchmarks/CMakeLists.txt
  clang-tools-extra/pseudo/fuzzer/CMakeLists.txt
  clang-tools-extra/pseudo/fuzzer/Fuzzer.cpp
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/cli/CLI.h
  clang-tools-extra/pseudo/include/clang-pseudo/cxx/CXX.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Language.h
  clang-tools-extra/pseudo/lib/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cli/CLI.cpp
  clang-tools-extra/pseudo/lib/cli/CMakeLists.txt
  clang-tools-extra/pseudo/lib/cxx/CXX.cpp
  clang-tools-extra/pseudo/tool/CMakeLists.txt
  clang-tools-extra/pseudo/tool/ClangPseudo.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -8,6 +8,7 @@
 
 #include "clang-pseudo/GLR.h"
 #include "clang-pseudo/Token.h"
+#include "clang-pseudo/grammar/Language.h"
 #include "clang-pseudo/grammar/Grammar.h"
 #include "clang/Basic/LangOptions.h"
 #include "clang/Basic/TokenKinds.h"
@@ -48,9 +49,15 @@
 public:
   void build(llvm::StringRef GrammarBNF) {
 std::vector Diags;
-G = Grammar::parseBNF(GrammarBNF, Diags);
+TestLang.G = Grammar::parseBNF(GrammarBNF, Diags);
   }
 
+  TokenStream emptyTokenStream() {
+TokenStream Empty;
+Empty.finalize();
+return Empty;
+  }
+ 
   void buildGrammar(std::vector Nonterminals,
 std::vector Rules) {
 Nonterminals.push_back("_");
@@ -66,19 +73,22 @@
 
   SymbolID id(llvm::StringRef Name) const {
 for (unsigned I = 0; I < NumTerminals; ++I)
-  if (G.table().Terminals[I] == Name)
+  if (TestLang.G.table().Terminals[I] == Name)
 return tokenSymbol(static_cast(I));
-for (SymbolID ID = 0; ID < G.table().Nonterminals.size(); ++ID)
-  if (G.table().Nonterminals[ID].Name == Name)
+for (SymbolID ID = 0; ID < TestLang.G.table().Nonterminals.size(); ++ID)
+  if (TestLang.G.table().Nonterminals[ID].Name == Name)
 return ID;
 ADD_FAILURE() << "No such symbol found: " << Name;
 return 0;
   }
 
   RuleID ruleFor(llvm::StringRef NonterminalName) const {
-auto RuleRange = G.table().Nonterminals[id(NonterminalName)].RuleRange;
+auto RuleRange =
+TestLang.G.table().Nonterminals[id(NonterminalName)].RuleRange;
 if (RuleRange.End - RuleRange.Start == 1)
-  return G.table().Nonterminals[id(NonterminalName)].RuleRange.Start;
+  return TestLang.G.table()
+  .Nonterminals[id(NonterminalName)]
+  .RuleRange.Start;
 ADD_FAILURE() << "Expected a single rule for " << NonterminalName
   << ", but it has " << RuleRange.End - RuleRange.Start
   << " rule!\n";
@@ -86,7 +96,7 @@
   }
 
 protected:
-  Grammar G;
+  Language TestLang;
   ForestArena Arena;
   GSS GSStack;
 };
@@ -112,9 +122,8 @@
/*Parents=*/{GSSNode0});
 
   buildGrammar({}, {}); // Create a fake empty grammar.
-  LRTable T =
-  LRTable::buildForTests(G, /*Entries=*/
- {
+  TestLang.Table =
+  LRTable::buildForTests(TestLang.G, /*Entries=*/{
  {1, tokenSymbol(tok::semi), Action::shift(4)},
  {2, tokenSymbol(tok::semi), Action::shift(4)},
  {3, tokenSymbol(tok::semi), Action::shift(5)},
@@ -123,8 +132,8 @@
 
   ForestNode  = Arena.createTerminal(tok::semi, 0);
   std::vector NewHeads;
-  glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal, {G, T, Arena, GSStack},
-   NewHeads);
+  glrShift({GSSNode1, GSSNode2, GSSNode3}, SemiTerminal,
+   {TestLang.G, TestLang.Table, Arena, GSStack}, NewHeads);
 
   EXPECT_THAT(NewHeads,
   UnorderedElementsAre(AllOf(state(4), parsedSymbol(),
@@ -144,8 +153,8 @@
   buildGrammar({"class-name", "enum-name"},
{"class-name := IDENTIFIER", "enum-name := IDENTIFIER"});
 
-  LRTable Table = LRTable::buildForTests(
-  G,
+  TestLang.Table = LRTable::buildForTests(
+  TestLang.G,
   {
   {/*State=*/0, id("class-name"), Action::goTo(2)},
   {/*State=*/0, id("enum-name"), Action::goTo(3)},
@@ -161,7 +170,8 @@
   GSStack.addNode(1, (tok::identifier, 0), {GSSNode0});
 
   std::vector Heads = {GSSNode1};
-  glrReduce(Heads, tokenSymbol(tok::eof), {G, Table, Arena, GSStack});
+  glrReduce(Heads, tokenSymbol(tok::eof),
+

[PATCH] D128402: [clang-tidy] Don't treat invalid branches as identical

2022-06-28 Thread Ishaan Gandhi via Phabricator via cfe-commits
ishaangandhi added a comment.

Does anybody on this thread have land permissions? If not, would anyone know 
who to tag?


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

https://reviews.llvm.org/D128402

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


[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128752#3616831 , @tra wrote:

> Do we have tests that verify `-target-feature` arguments? It may be worth 
> adding a test case there checking for redundant features.

Yeah, we have some existing tests that check for including the target features 
at least once. I felt like there was no need to include a test for what was 
more or less an oversight


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128752

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


[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Artem Belevich via Phabricator via cfe-commits
tra accepted this revision.
tra added a comment.
This revision is now accepted and ready to land.

Do we have tests that verify `-target-feature` arguments? It may be worth 
adding a test case there checking for redundant features.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128752

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


[PATCH] D113545: [C++20] [Module] Support reachable definition initially/partially

2022-06-28 Thread Richard Smith - zygoloid via Phabricator via cfe-commits
rsmith accepted this revision.
rsmith added a comment.
This revision is now accepted and ready to land.

A few comments, but they're all minor things or FIXMEs. I'm happy for this to 
land once they're addressed.




Comment at: clang/include/clang/AST/DeclBase.h:229
+/// This declaration has an owning module, and is visible to lookups
+/// that occurs within that module. And it is reachable to other module
+/// when the owning module is transitively imported.





Comment at: clang/include/clang/Sema/Lookup.h:360-361
+  /// Determine whether this lookup is permitted to see the declaration.
+  /// Note that the reachable but not visible declaration inhabit at namespace
+  /// is not allowed to be seen during name lookup.
+  ///





Comment at: clang/include/clang/Sema/Lookup.h:373-374
+  ///   // Not valid. We couldn't see reachable here.
+  ///   // So isAvailableForLookup would return false when we looks
+  ///   'reachable' here.
+  ///   // return reachable(43).v;





Comment at: clang/include/clang/Sema/Lookup.h:377
+  ///   // Valid. The field name 'v' is allowed during name lookup.
+  ///   // So isAvailableForLookup would return true when we looks 'v' here.
+  ///   return func().v;





Comment at: clang/lib/Sema/SemaLookup.cpp:1634-1658
 bool Sema::hasVisibleDefaultArgument(const NamedDecl *D,
  llvm::SmallVectorImpl *Modules) 
{
   if (auto *P = dyn_cast(D))
-return ::hasVisibleDefaultArgument(*this, P, Modules);
+return ::hasAcceptableDefaultArgument(*this, P, Modules,
+  Sema::AcceptableKind::Visible);
   if (auto *P = dyn_cast(D))
+return ::hasAcceptableDefaultArgument(*this, P, Modules,

Consider adding a `Sema::hasAcceptableDefaultArgument` to remove the duplicated 
dispatch here.



Comment at: clang/lib/Sema/SemaLookup.cpp:1796
 // set of declarations for tags in prototype scope.
-bool VisibleWithinParent;
+bool AcceptableWithParent;
 if (D->isTemplateParameter()) {

Please rename `With` back to `Within`.



Comment at: clang/lib/Sema/SemaLookup.cpp:1895
 
-bool Sema::isVisibleSlow(const NamedDecl *D) {
-  return LookupResult::isVisible(*this, const_cast(D));
+bool LookupResult::isReachableSlow(Sema , NamedDecl *D) {
+  assert(!isVisible(SemaRef, D) && "Shouldn't call the slow case.\n");

This function is assuming that any declaration in the `ASTContext` is in a 
translation unit on which we have an interface dependency. That's not going to 
be true in general (for example, using `-fmodule-file` you can load AST files 
on which there is no interface dependency, and clang-as-a-library users might 
even build an `ASTContext` containing the entire program), but seems good 
enough for now. Please add a FIXME (eg: "FIXME: Return false if we don't have 
an interface dependency on the translation unit containing D.").



Comment at: clang/lib/Sema/SemaLookup.cpp:1898-1907
+  // Filter the use other than C++20 Considering the case we are using clang
+  // module + -std=c++20 combination.
+  if (llvm::any_of(D->redecls(), [](Decl *D) {
+return D->getOwningModule() &&
+   D->getOwningModule()->isModuleMapModule();
+  }))
+return false;

The `any_of` here doesn't seem right to me for two reasons:

1) The rest of this function is answering the question, "is this particular 
declaration reachable?", not "is any declaration of this entity reachable?"
2) An entity should be reachable if any declaration of it is. Adding a 
declaration in a module map module should not cause other declarations to 
become less reachable.



Comment at: clang/lib/Sema/SemaLookup.cpp:1926
+  //   fragment.
+  if (D->isModulePrivate() || D->isDiscardedInGlobalModuleFragment())
+return false;

I don't think we should need the second check here: a declaration that's 
discarded in the GMF should be module-private, per your comment change on 
`ModueOwnershipKind`.



Comment at: clang/lib/Sema/SemaLookup.cpp:1947
+  // DeclModule if it isn't (transitively) imported.
+  if (DeclModule->getTopLevelModule()->isModuleInterfaceUnit())
+return true;

ChuanqiXu wrote:
> iains wrote:
> > ChuanqiXu wrote:
> > > iains wrote:
> > > > ChuanqiXu wrote:
> > > > > iains wrote:
> > > > > > I think isModuleInterfaceUnit needs to include implementation 
> > > > > > partition units, since they also have a BMI  (is 
> > > > > > `isInterfaceOrPartition()` the right thing to use here?
> > > > > I think we couldn't use `isInterfaceOrPartition()` here. The call for 
> > > > > `isModuleInterfaceUnit()` here is sufficient. For example, we could 
> > > > > find the example at [[ 

[PATCH] D122768: [Clang][C++20] Support capturing structured bindings in lambdas

2022-06-28 Thread Shafik Yaghmour via Phabricator via cfe-commits
shafik added a comment.

I think I need to do another sweep of this PR but mostly minor comments.

You should add tests for structured bindings binding to array and tuple-like 
types b/c the AST under the `BindingDecl` will be different for each of those 
cases and it would be worth verifying it works for all the cases. Although I 
don't see anything that looks like it would not.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D122768

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


[PATCH] D128757: [Driver][test] Add -fuse-ld= option tests for NetBSD

2022-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added a comment.

I am unsure it is useful to add a test for all OSxfuse_ld_value combinations, 
especially for an ELF OS like NetBSD which shares many characteristics with 
other ELF OSes. It will be overwhelming.
The option may be better added in a netbsd specific file.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128757

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


[PATCH] D128352: [clang][dataflow] Use diagnosis API in optional checker

2022-06-28 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.



Comment at: 
clang-tools-extra/clang-tidy/bugprone/UncheckedOptionalAccessCheck.cpp:67
+std::move(StmtDiagnostics.begin(), StmtDiagnostics.end(),
+  std::back_inserter(Diagnostics));
+  });

Please use the range-based llvm;:move() from 
llvm-project/llvm/include/llvm/ADT/STLExtras.h.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128352

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


[PATCH] D127898: [clang][dataflow] Add API to separate analysis from diagnosis

2022-06-28 Thread Dmitri Gribenko via Phabricator via cfe-commits
gribozavr2 accepted this revision.
gribozavr2 added inline comments.



Comment at: 
clang/include/clang/Analysis/FlowSensitive/Models/UncheckedOptionalAccessModel.h:78
+public:
+  UncheckedOptionalAccessDiagnosis(
+  ASTContext , UncheckedOptionalAccessModelOptions Options = 
{});

samestep wrote:
> gribozavr2 wrote:
> > "Diagnosis" sounds like the result. Should this be a "Diagnoser"?
> Sure, I can change it to say "Diagnoser" instead (unless we want to just 
> replace it with "Visitor").
Not done?



Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:144-145
 
+// Runs dataflow on the body of the function that matches `func_matcher` in 
code
+// snippet `code`. Requires: `Analysis` contains a type `Lattice`.
+template 





Comment at: clang/unittests/Analysis/FlowSensitive/TestingSupport.h:155
+ASTContext &)>
+Expectations,
+ArrayRef Args,





Comment at: 
clang/unittests/Analysis/FlowSensitive/UncheckedOptionalAccessModelTest.cpp:2338
   //   if (opt1.has_value()) {
   // opt2.value();
   //   }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127898

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


[PATCH] D128465: Zstandard as a second compression method to LLVM

2022-06-28 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 440747.
ckissane edited the summary of this revision.
ckissane added a comment.

make it the second stage


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

https://reviews.llvm.org/D128465

Files:
  clang-tools-extra/clangd/CMakeLists.txt
  clang-tools-extra/clangd/test/lit.site.cfg.py.in
  clang/test/CMakeLists.txt
  clang/test/lit.site.cfg.py.in
  compiler-rt/lib/sanitizer_common/symbolizer/scripts/build_symbolizer.sh
  compiler-rt/test/lit.common.configured.in
  flang/CMakeLists.txt
  lld/ELF/CMakeLists.txt
  lldb/source/Plugins/Process/gdb-remote/CMakeLists.txt
  llvm/CMakeLists.txt
  llvm/cmake/config-ix.cmake
  llvm/cmake/modules/FindZSTD.cmake
  llvm/cmake/modules/LLVMConfig.cmake.in
  llvm/include/llvm/Config/llvm-config.h.cmake
  llvm/include/llvm/Support/Compression.h
  llvm/lib/Support/Compression.cpp
  utils/bazel/llvm_configs/llvm-config.h.cmake

Index: utils/bazel/llvm_configs/llvm-config.h.cmake
===
--- utils/bazel/llvm_configs/llvm-config.h.cmake
+++ utils/bazel/llvm_configs/llvm-config.h.cmake
@@ -92,6 +92,9 @@
 /* Define if zlib compression is available */
 #cmakedefine01 LLVM_ENABLE_ZLIB
 
+/* Define if zstd compression is available */
+#cmakedefine01 LLVM_ENABLE_ZSTD
+
 /* Define if LLVM was built with a dependency to the libtensorflow dynamic library */
 #cmakedefine LLVM_HAVE_TF_API
 
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -20,6 +20,9 @@
 #if LLVM_ENABLE_ZLIB
 #include 
 #endif
+#if LLVM_ENABLE_ZSTD
+#include 
+#endif
 
 using namespace llvm;
 
@@ -102,3 +105,63 @@
   llvm_unreachable("zlib::uncompress is unavailable");
 }
 #endif
+
+#if LLVM_ENABLE_ZSTD
+
+bool zstd::isAvailable() { return true; }
+
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl , int Level) {
+  unsigned long CompressedBufferSize = ::ZSTD_compressBound(InputBuffer.size());
+  CompressedBuffer.resize_for_overwrite(CompressedBufferSize);
+  unsigned long CompressedSize = ::ZSTD_compress(
+  (Bytef *)CompressedBuffer.data(), CompressedBufferSize,
+  (const Bytef *)InputBuffer.data(), InputBuffer.size(), Level);
+  if (ZSTD_isError(CompressedSize))
+report_bad_alloc_error("Allocation failed");
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(CompressedBuffer.data(), CompressedSize);
+  CompressedBuffer.truncate(CompressedSize);
+}
+
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t ) {
+  unsigned long long const rSize = ZSTD_getFrameContentSize(
+  (const Bytef *)InputBuffer.data(), InputBuffer.size());
+  size_t const Res =
+  ::ZSTD_decompress((Bytef *)UncompressedBuffer, rSize,
+(const Bytef *)InputBuffer.data(), InputBuffer.size());
+  UncompressedSize = Res;
+  // Tell MemorySanitizer that zstd output buffer is fully initialized.
+  // This avoids a false report when running LLVM with uninstrumented ZLib.
+  __msan_unpoison(UncompressedBuffer, UncompressedSize);
+  return Res != rSize ? createError(ZSTD_getErrorName(Res)) : Error::success();
+}
+
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl ,
+   size_t UncompressedSize) {
+  UncompressedBuffer.resize_for_overwrite(UncompressedSize);
+  Error E = zstd::uncompress(InputBuffer, UncompressedBuffer.data(),
+ UncompressedSize);
+  UncompressedBuffer.truncate(UncompressedSize);
+  return E;
+}
+
+#else
+bool zstd::isAvailable() { return false; }
+void zstd::compress(StringRef InputBuffer,
+SmallVectorImpl , int Level) {
+  llvm_unreachable("zstd::compress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer, char *UncompressedBuffer,
+   size_t ) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+Error zstd::uncompress(StringRef InputBuffer,
+   SmallVectorImpl ,
+   size_t UncompressedSize) {
+  llvm_unreachable("zstd::uncompress is unavailable");
+}
+#endif
\ No newline at end of file
Index: llvm/include/llvm/Support/Compression.h
===
--- llvm/include/llvm/Support/Compression.h
+++ llvm/include/llvm/Support/Compression.h
@@ -43,7 +43,32 @@
 
 } // End of namespace zlib
 
+namespace zstd {
+
+static constexpr int NoCompression = -5;
+static constexpr int BestSpeedCompression = 1;
+static constexpr int DefaultCompression = 5;
+static constexpr int BestSizeCompression = 12;
+
+bool isAvailable();
+
+void compress(StringRef InputBuffer, SmallVectorImpl ,
+  int Level = DefaultCompression);
+

[PATCH] D108469: Improve handling of static assert messages.

2022-06-28 Thread Corentin Jabot 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 rG870b6d218397: Improve handling of static assert messages. 
(authored by cor3ntin).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D108469

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/lib/Basic/Diagnostic.cpp
  clang/lib/Sema/SemaDeclCXX.cpp
  clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
  clang/test/C/drs/dr0xx.c
  clang/test/CXX/dcl.dcl/p4-0x.cpp
  clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
  clang/test/Lexer/null-character-in-literal.c
  clang/test/Misc/diag-special-chars.c
  clang/test/Misc/wrong-encoding.c
  clang/test/PCH/cxx-static_assert.cpp
  clang/test/Sema/static-assert.c
  clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
  clang/test/SemaCXX/static-assert.cpp
  llvm/include/llvm/Support/Unicode.h
  llvm/lib/Support/Unicode.cpp

Index: llvm/lib/Support/Unicode.cpp
===
--- llvm/lib/Support/Unicode.cpp
+++ llvm/lib/Support/Unicode.cpp
@@ -19,197 +19,271 @@
 namespace sys {
 namespace unicode {
 
+/// Unicode code points of the categories L, M, N, P, S and Zs are considered
+/// printable.
+/// In addition, U+00AD SOFT HYPHEN is also considered printable, as
+/// it's actually displayed on most terminals. \return true if the character is
+/// considered printable.
 bool isPrintable(int UCS) {
-  // Sorted list of non-overlapping intervals of code points that are not
-  // supposed to be printable.
-  static const UnicodeCharRange NonPrintableRanges[] = {
-{ 0x, 0x001F }, { 0x007F, 0x009F }, { 0x034F, 0x034F },
-{ 0x0378, 0x0379 }, { 0x037F, 0x0383 }, { 0x038B, 0x038B },
-{ 0x038D, 0x038D }, { 0x03A2, 0x03A2 }, { 0x0528, 0x0530 },
-{ 0x0557, 0x0558 }, { 0x0560, 0x0560 }, { 0x0588, 0x0588 },
-{ 0x058B, 0x058E }, { 0x0590, 0x0590 }, { 0x05C8, 0x05CF },
-{ 0x05EB, 0x05EF }, { 0x05F5, 0x0605 }, { 0x061C, 0x061D },
-{ 0x06DD, 0x06DD }, { 0x070E, 0x070F }, { 0x074B, 0x074C },
-{ 0x07B2, 0x07BF }, { 0x07FB, 0x07FF }, { 0x082E, 0x082F },
-{ 0x083F, 0x083F }, { 0x085C, 0x085D }, { 0x085F, 0x089F },
-{ 0x08A1, 0x08A1 }, { 0x08AD, 0x08E3 }, { 0x08FF, 0x08FF },
-{ 0x0978, 0x0978 }, { 0x0980, 0x0980 }, { 0x0984, 0x0984 },
-{ 0x098D, 0x098E }, { 0x0991, 0x0992 }, { 0x09A9, 0x09A9 },
-{ 0x09B1, 0x09B1 }, { 0x09B3, 0x09B5 }, { 0x09BA, 0x09BB },
-{ 0x09C5, 0x09C6 }, { 0x09C9, 0x09CA }, { 0x09CF, 0x09D6 },
-{ 0x09D8, 0x09DB }, { 0x09DE, 0x09DE }, { 0x09E4, 0x09E5 },
-{ 0x09FC, 0x0A00 }, { 0x0A04, 0x0A04 }, { 0x0A0B, 0x0A0E },
-{ 0x0A11, 0x0A12 }, { 0x0A29, 0x0A29 }, { 0x0A31, 0x0A31 },
-{ 0x0A34, 0x0A34 }, { 0x0A37, 0x0A37 }, { 0x0A3A, 0x0A3B },
-{ 0x0A3D, 0x0A3D }, { 0x0A43, 0x0A46 }, { 0x0A49, 0x0A4A },
-{ 0x0A4E, 0x0A50 }, { 0x0A52, 0x0A58 }, { 0x0A5D, 0x0A5D },
-{ 0x0A5F, 0x0A65 }, { 0x0A76, 0x0A80 }, { 0x0A84, 0x0A84 },
-{ 0x0A8E, 0x0A8E }, { 0x0A92, 0x0A92 }, { 0x0AA9, 0x0AA9 },
-{ 0x0AB1, 0x0AB1 }, { 0x0AB4, 0x0AB4 }, { 0x0ABA, 0x0ABB },
-{ 0x0AC6, 0x0AC6 }, { 0x0ACA, 0x0ACA }, { 0x0ACE, 0x0ACF },
-{ 0x0AD1, 0x0ADF }, { 0x0AE4, 0x0AE5 }, { 0x0AF2, 0x0B00 },
-{ 0x0B04, 0x0B04 }, { 0x0B0D, 0x0B0E }, { 0x0B11, 0x0B12 },
-{ 0x0B29, 0x0B29 }, { 0x0B31, 0x0B31 }, { 0x0B34, 0x0B34 },
-{ 0x0B3A, 0x0B3B }, { 0x0B45, 0x0B46 }, { 0x0B49, 0x0B4A },
-{ 0x0B4E, 0x0B55 }, { 0x0B58, 0x0B5B }, { 0x0B5E, 0x0B5E },
-{ 0x0B64, 0x0B65 }, { 0x0B78, 0x0B81 }, { 0x0B84, 0x0B84 },
-{ 0x0B8B, 0x0B8D }, { 0x0B91, 0x0B91 }, { 0x0B96, 0x0B98 },
-{ 0x0B9B, 0x0B9B }, { 0x0B9D, 0x0B9D }, { 0x0BA0, 0x0BA2 },
-{ 0x0BA5, 0x0BA7 }, { 0x0BAB, 0x0BAD }, { 0x0BBA, 0x0BBD },
-{ 0x0BC3, 0x0BC5 }, { 0x0BC9, 0x0BC9 }, { 0x0BCE, 0x0BCF },
-{ 0x0BD1, 0x0BD6 }, { 0x0BD8, 0x0BE5 }, { 0x0BFB, 0x0C00 },
-{ 0x0C04, 0x0C04 }, { 0x0C0D, 0x0C0D }, { 0x0C11, 0x0C11 },
-{ 0x0C29, 0x0C29 }, { 0x0C34, 0x0C34 }, { 0x0C3A, 0x0C3C },
-{ 0x0C45, 0x0C45 }, { 0x0C49, 0x0C49 }, { 0x0C4E, 0x0C54 },
-{ 0x0C57, 0x0C57 }, { 0x0C5A, 0x0C5F }, { 0x0C64, 0x0C65 },
-{ 0x0C70, 0x0C77 }, { 0x0C80, 0x0C81 }, { 0x0C84, 0x0C84 },
-{ 0x0C8D, 0x0C8D }, { 0x0C91, 0x0C91 }, { 0x0CA9, 0x0CA9 },
-{ 0x0CB4, 0x0CB4 }, { 0x0CBA, 0x0CBB }, { 0x0CC5, 0x0CC5 },
-{ 0x0CC9, 0x0CC9 }, { 0x0CCE, 0x0CD4 }, { 0x0CD7, 0x0CDD },
-{ 0x0CDF, 0x0CDF }, { 0x0CE4, 0x0CE5 }, { 0x0CF0, 0x0CF0 },
-{ 0x0CF3, 0x0D01 }, { 0x0D04, 0x0D04 }, { 0x0D0D, 0x0D0D },
-{ 0x0D11, 0x0D11 }, { 0x0D3B, 0x0D3C }, { 0x0D45, 0x0D45 },
-{ 0x0D49, 0x0D49 }, { 0x0D4F, 0x0D56 }, { 0x0D58, 0x0D5F },
-{ 0x0D64, 0x0D65 }, { 0x0D76, 0x0D78 }, { 0x0D80, 0x0D81 },
-{ 0x0D84, 0x0D84 }, { 0x0D97, 0x0D99 }, { 0x0DB2, 0x0DB2 },
-{ 0x0DBC, 0x0DBC }, { 0x0DBE, 0x0DBF }, { 0x0DC7, 0x0DC9 },
-

[clang] 870b6d2 - Improve handling of static assert messages.

2022-06-28 Thread Corentin Jabot via cfe-commits

Author: Corentin Jabot
Date: 2022-06-28T22:26:00+02:00
New Revision: 870b6d21839707a3e4c40a29b526995f065a220f

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

LOG: Improve handling of static assert messages.

Instead of dumping the string literal (which
quotes it and escape every non-ascii symbol),
we can use the content of the string when it is a
8 byte string.

Wide, UTF-8/UTF-16/32 strings are still completely
escaped, until we clarify how these entities should
behave (cf https://wg21.link/p2361).

`FormatDiagnostic` is modified to escape
non printable characters and invalid UTF-8.

This ensures that unicode characters, spaces and new
lines are properly rendered in static messages.
This make clang more consistent with other implementation
and fixes this tweet
https://twitter.com/jfbastien/status/1298307325443231744 :)

Of note, `PaddingChecker` did print out new lines that were
later removed by the diagnostic printing code.
To be consistent with its tests, the new lines are removed
from the diagnostic.

Unicode tables updated to both use the Unicode definitions
and the Unicode 14.0 data.

U+00AD SOFT HYPHEN is still considered a print character
to match existing practices in terminals, in addition of
being considered a formatting character as per Unicode.

Reviewed By: aaron.ballman, #clang-language-wg

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

Added: 


Modified: 
clang/docs/ReleaseNotes.rst
clang/include/clang/Basic/DiagnosticSemaKinds.td
clang/lib/Basic/Diagnostic.cpp
clang/lib/Sema/SemaDeclCXX.cpp
clang/lib/StaticAnalyzer/Checkers/PaddingChecker.cpp
clang/test/C/drs/dr0xx.c
clang/test/CXX/dcl.dcl/p4-0x.cpp
clang/test/CXX/expr/expr.prim/expr.prim.id/p3.cpp
clang/test/Lexer/null-character-in-literal.c
clang/test/Misc/diag-special-chars.c
clang/test/Misc/wrong-encoding.c
clang/test/PCH/cxx-static_assert.cpp
clang/test/Sema/static-assert.c
clang/test/SemaCXX/int-ptr-cast-SFINAE.cpp
clang/test/SemaCXX/static-assert.cpp
llvm/include/llvm/Support/Unicode.h
llvm/lib/Support/Unicode.cpp

Removed: 




diff  --git a/clang/docs/ReleaseNotes.rst b/clang/docs/ReleaseNotes.rst
index 3e29987ad2631..815430839489d 100644
--- a/clang/docs/ReleaseNotes.rst
+++ b/clang/docs/ReleaseNotes.rst
@@ -273,6 +273,8 @@ Improvements to Clang's diagnostics
 - When using class templates without arguments, clang now tells developers
   that template arguments are missing in certain contexts.
   This fixes `Issue 55962 
`_.
+- Printable Unicode characters within ``static_assert`` messages are no longer
+  escaped.
 
 Non-comprehensive list of changes in this release
 -

diff  --git a/clang/include/clang/Basic/DiagnosticSemaKinds.td 
b/clang/include/clang/Basic/DiagnosticSemaKinds.td
index 442088d078d98..843024c988ef6 100644
--- a/clang/include/clang/Basic/DiagnosticSemaKinds.td
+++ b/clang/include/clang/Basic/DiagnosticSemaKinds.td
@@ -1527,9 +1527,9 @@ def err_static_assert_expression_is_not_constant : Error<
   "static_assert expression is not an integral constant expression">;
 def err_constexpr_if_condition_expression_is_not_constant : Error<
   "constexpr if condition is not a constant expression">;
-def err_static_assert_failed : Error<"static_assert failed%select{ %1|}0">;
+def err_static_assert_failed : Error<"static_assert failed%select{: %1|}0">;
 def err_static_assert_requirement_failed : Error<
-  "static_assert failed due to requirement '%0'%select{ %2|}1">;
+  "static_assert failed due to requirement '%0'%select{: %2 |}1">;
 
 def warn_consteval_if_always_true : Warning<
   "consteval if is always true in an %select{unevaluated|immediate}0 context">,

diff  --git a/clang/lib/Basic/Diagnostic.cpp b/clang/lib/Basic/Diagnostic.cpp
index deb398756e373..dbe62ecb50d33 100644
--- a/clang/lib/Basic/Diagnostic.cpp
+++ b/clang/lib/Basic/Diagnostic.cpp
@@ -25,8 +25,9 @@
 #include "llvm/ADT/SmallVector.h"
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/ADT/StringRef.h"
+#include "llvm/Support/ConvertUTF.h"
 #include "llvm/Support/CrashRecoveryContext.h"
-#include "llvm/Support/Locale.h"
+#include "llvm/Support/Unicode.h"
 #include "llvm/Support/raw_ostream.h"
 #include 
 #include 
@@ -803,6 +804,50 @@ FormatDiagnostic(SmallVectorImpl ) const {
   FormatDiagnostic(Diag.begin(), Diag.end(), OutStr);
 }
 
+/// pushEscapedString - Append Str to the diagnostic buffer,
+/// escaping non-printable characters and ill-formed code unit sequences.
+static void pushEscapedString(StringRef Str, SmallVectorImpl ) {
+  OutStr.reserve(OutStr.size() + Str.size());
+  auto *Begin = reinterpret_cast(Str.data());
+  llvm::raw_svector_ostream 

[PATCH] D128372: [Clang-Tidy] Empty Check

2022-06-28 Thread Abraham Corea Diaz via Phabricator via cfe-commits
abrahamcd planned changes to this revision.
abrahamcd added a comment.

Stuck on determining unused return value, uploaded current state for @denik and 
@cjdb to take a look.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128372

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


[PATCH] D128757: [Driver][test] Add -fuse-ld= option tests for NetBSD

2022-06-28 Thread Frederic Cambus via Phabricator via cfe-commits
fcambus created this revision.
fcambus added a reviewer: MaskRay.
Herald added a subscriber: StephenFan.
Herald added a project: All.
fcambus requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128757

Files:
  clang/test/Driver/Inputs/basic_netbsd_tree/usr/bin/ld.bfd
  clang/test/Driver/Inputs/basic_netbsd_tree/usr/bin/ld.gold
  clang/test/Driver/fuse-ld.c


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -40,6 +40,25 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// RUN: %clang %s -### \
+// RUN: -target x86_64-unknown-netbsd 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NETBSD-LD
+// CHECK-NETBSD-LD: ld
+
+// RUN: %clang %s -### -fuse-ld=bfd \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree \
+// RUN: -target x86_64-unknown-netbsd \
+// RUN: -B%S/Inputs/basic_netbsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-NETBSD-BFD
+// CHECK-NETBSD-BFD: Inputs/basic_netbsd_tree/usr/bin{{/|\\+}}ld.bfd
+
+// RUN: %clang %s -### -fuse-ld=gold \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree \
+// RUN: -target x86_64-unknown-netbsd \
+// RUN: -B%S/Inputs/basic_netbsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-NETBSD-GOLD
+// CHECK-NETBSD-GOLD: Inputs/basic_netbsd_tree/usr/bin{{/|\\+}}ld.gold
+
 // RUN: %clang %s -### -fuse-ld=ld \
 // RUN: -target arm-linux-androideabi \
 // RUN: -B%S/Inputs/basic_android_tree/bin/arm-linux-androideabi- 2>&1 \


Index: clang/test/Driver/fuse-ld.c
===
--- clang/test/Driver/fuse-ld.c
+++ clang/test/Driver/fuse-ld.c
@@ -40,6 +40,25 @@
 // RUN:   | FileCheck %s -check-prefix=CHECK-FREEBSD-PLIB
 // CHECK-FREEBSD-PLIB: error: invalid linker name
 
+// RUN: %clang %s -### \
+// RUN: -target x86_64-unknown-netbsd 2>&1 \
+// RUN:   | FileCheck %s --check-prefix=CHECK-NETBSD-LD
+// CHECK-NETBSD-LD: ld
+
+// RUN: %clang %s -### -fuse-ld=bfd \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree \
+// RUN: -target x86_64-unknown-netbsd \
+// RUN: -B%S/Inputs/basic_netbsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-NETBSD-BFD
+// CHECK-NETBSD-BFD: Inputs/basic_netbsd_tree/usr/bin{{/|\\+}}ld.bfd
+
+// RUN: %clang %s -### -fuse-ld=gold \
+// RUN: --sysroot=%S/Inputs/basic_netbsd_tree \
+// RUN: -target x86_64-unknown-netbsd \
+// RUN: -B%S/Inputs/basic_netbsd_tree/usr/bin 2>&1 \
+// RUN:   | FileCheck %s -check-prefix=CHECK-NETBSD-GOLD
+// CHECK-NETBSD-GOLD: Inputs/basic_netbsd_tree/usr/bin{{/|\\+}}ld.gold
+
 // RUN: %clang %s -### -fuse-ld=ld \
 // RUN: -target arm-linux-androideabi \
 // RUN: -B%S/Inputs/basic_android_tree/bin/arm-linux-androideabi- 2>&1 \
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D128372: [Clang-Tidy] Empty Check

2022-06-28 Thread Abraham Corea Diaz via Phabricator via cfe-commits
abrahamcd updated this revision to Diff 440742.
abrahamcd added a comment.

Progress Update

Hit a roadblock with determining unused return value,
uploading current state for further work.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128372

Files:
  clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
  clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
  clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.cpp
  clang-tools-extra/clang-tidy/bugprone/StandaloneEmptyCheck.h
  clang-tools-extra/docs/ReleaseNotes.rst
  clang-tools-extra/docs/clang-tidy/checks/bugprone/standalone-empty.rst
  clang-tools-extra/docs/clang-tidy/checks/list.rst
  clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp

Index: clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp
===
--- /dev/null
+++ clang-tools-extra/test/clang-tidy/checkers/bugprone/standalone-empty.cpp
@@ -0,0 +1,244 @@
+// RUN: %check_clang_tidy %s bugprone-standalone-empty %t
+
+namespace std {
+template 
+struct vector {
+  bool empty();
+};
+
+template 
+struct vector_with_clear {
+  bool empty();
+  void clear();
+};
+
+template 
+struct vector_with_void_empty {
+  void empty();
+  void clear();
+};
+
+template 
+struct vector_with_int_empty {
+  int empty();
+  void clear();
+};
+
+template 
+bool empty(T &&);
+
+} // namespace std
+
+namespace absl {
+struct string {
+  bool empty();
+};
+
+struct string_with_clear {
+  bool empty();
+  void clear();
+};
+
+struct string_with_void_empty {
+  void empty();
+  void clear();
+};
+
+struct string_with_int_empty {
+  int empty();
+  void clear();
+};
+
+template 
+bool empty(T &&);
+} // namespace absl
+
+namespace test {
+template 
+void empty(T &&);
+} // namespace test
+
+int test_member_empty() {
+  {
+std::vector v;
+
+v.empty();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'empty()' [bugprone-standalone-empty]
+
+bool test = v.empty();
+//(void) v.empty();
+// no-warning
+// NOTE: This test not currently passing.
+  }
+
+  {
+std::vector_with_void_empty v;
+
+v.empty();
+// no-warning
+  }
+
+  {
+std::vector_with_clear v;
+
+v.empty();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  v.clear();{{$}}
+  }
+
+  {
+std::vector_with_int_empty v;
+
+v.empty();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  v.clear();{{$}}
+  }
+
+  {
+absl::string s;
+
+s.empty();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'empty()' [bugprone-standalone-empty]
+  }
+
+  {
+absl::string_with_void_empty s;
+
+s.empty();
+// no-warning
+  }
+
+  {
+absl::string_with_clear s;
+
+s.empty();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  s.clear();{{$}}
+  }
+
+  {
+absl::string_with_int_empty s;
+
+s.empty();
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'empty()', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  s.clear();{{$}}
+  }
+}
+
+int test_qualified_empty() {
+  {
+absl::string_with_clear v;
+
+std::empty(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'std::empty', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  v.clear();{{$}}
+
+absl::empty(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'absl::empty', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  v.clear();{{$}}
+
+test::empty(v);
+// no-warning
+  }
+
+  {
+absl::string s;
+
+std::empty(s);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty]
+  }
+}
+
+int test_unqualified_empty() {
+  {
+std::vector v;
+
+empty(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'std::empty' [bugprone-standalone-empty]
+  }
+
+  {
+std::vector_with_void_empty v;
+
+empty(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'std::empty', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  v.clear();{{$}}
+  }
+
+  {
+std::vector_with_clear v;
+
+empty(v);
+// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: ignoring the result of 'std::empty', did you mean 'clear()'? [bugprone-standalone-empty]
+// CHECK-FIXES: {{^  }}  v.clear();{{$}}
+  }
+
+  {
+std::vector_with_int_empty v;
+
+empty(v);
+// CHECK-MESSAGES: 

[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128752#3616675 , @tra wrote:

> We already heard complaints that searching for CUDA installation in multiple 
> places does add a measurable delay when the search hits NFS-mounted 
> directories.
>
> Replacing uses of `CudaInstallation` with a getter function returning a 
> reference to a singleton would be great.

Sounds good, I'll make a patch for it. Considering that this one doesn't change 
that this one doesn't change anything we don't already do on that front is it 
good to land separately?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128752

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


[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

In D128752#3616579 , @jhuber6 wrote:

> In D128752#3616553 , @tra wrote:
>
>>> we no longer will have a cached CUDA installation so we will usually create 
>>> it twice.
>>
>> Does that result in extra output in case we find an unexpected CUDA version, 
>> or when compiler is run with `-v` ?
>>
>> We may want to wrap installation detector creation into some sort of 
>> singleton creation function.
>
> We already create another one for the call coming from Clang, this patch just 
> gets rid of the other call. I think the printouts you're talking about come 
> from the variable in the CUDA toolchain specifically. Here we simply create 
> one to get the version and throw it away. It's not ideal to do the same work 
> twice, so we could wrap this into some singleton interface. Maybe a static 
> optional value inside of the `Toolchains/Cuda.cpp` file wither a getter that 
> returns a reference to it. Though I don't think this is likely to be a 
> bottleneck.

We already heard complaints that searching for CUDA installation in multiple 
places does add a measurable delay when the search hits NFS-mounted directories.

Replacing uses of `CudaInstallation` with a getter function returning a 
reference to a singleton would be great.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128752

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


[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128750#3616471 , @ychen wrote:

> In D128750#3616449 , @erichkeane 
> wrote:
>
>> Is there any chance you can validate this against 
>> https://reviews.llvm.org/D126907 as well? We touch similar code, and I'm 
>> intending to get that committed in the near future.  Otherwise, after a 
>> quick look, I don't see anything particualrly bad, other than a lack of 
>> release notes and update of www-status.
>
> Sure. I will test it.

`check-all` passes with this patch + D126907 .


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D128048: Add a new clang option "-ftime-trace-path"

2022-06-28 Thread Fangrui Song via Phabricator via cfe-commits
MaskRay added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2819
"'per-pass-run': one report for each pass invocation">;
 def ftime_trace : Flag<["-"], "ftime-trace">, Group,
   HelpText<"Turn on time profiler. Generates JSON file based on output 
filename.">,

dongjunduo wrote:
> @MaskRay @jamieschmeiser May I change the option "-ftime-trace" from a "Flag" 
> type to a "Joined" type?
> 
> I have noticed that lld's option "[[ 
> https://reviews.llvm.org/rG661c089a402e0d41a28c94fab35d85c8ef90747e | 
> -ftime-trace-file ]]" is used to specify the output file name. It must be 
> specified simultaneously with "-ftime-trace". 
lld has removed --time-trace-file=. --time-trace= is the "Joined" option to 
specify the filename. `clang -ftime-trace=` LGTM.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128048

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


[PATCH] D128754: Refactor LLVM compression namespaces

2022-06-28 Thread Cole Kissane via Phabricator via cfe-commits
ckissane updated this revision to Diff 440736.
ckissane added a comment.

up release notes


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

https://reviews.llvm.org/D128754

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  lld/ELF/CMakeLists.txt
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Compression.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -19,6 +19,8 @@
 
 using namespace llvm;
 
+using namespace compression;
+
 namespace {
 
 #if LLVM_ENABLE_ZLIB
@@ -62,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1146,17 +1146,19 @@
   for (bool DoCompression : {false, true}) {
 // Compressing:
 std::string FuncNameStrings1;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings1),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames1, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings1),
+Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings2),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames2, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings2),
+Succeeded());
 
 for (int Padding = 0; Padding < 2; Padding++) {
   // Join with paddings :
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -740,7 +740,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -999,7 +999,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
 errc::invalid_argument,
 "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -403,7 +403,7 @@
   MAI->setRelaxELFRelocations(RelaxELFRel);
 
   if (CompressDebugSections != DebugCompressionType::None) {
-if (!zlib::isAvailable()) {
+if (!compression::zlib::isAvailable()) {
   WithColor::error(errs(), ProgName)
   << "build tools with zlib to enable -compress-debug-sections";
   return 1;
Index: llvm/lib/Support/Compression.cpp
===
--- llvm/lib/Support/Compression.cpp
+++ llvm/lib/Support/Compression.cpp
@@ -23,11 +23,14 @@
 
 using namespace llvm;
 
-#if LLVM_ENABLE_ZLIB
+using namespace compression;
+
 static Error createError(StringRef Err) {
   return make_error(Err, inconvertibleErrorCode());
 }
 
+#if LLVM_ENABLE_ZLIB
+
 static StringRef 

[PATCH] D128754: Refactor LLVM compression namespaces

2022-06-28 Thread Cole Kissane via Phabricator via cfe-commits
ckissane created this revision.
ckissane added a reviewer: MaskRay.
ckissane added a project: LLVM.
Herald added subscribers: StephenFan, wenlei, usaxena95, kadircet, arphaman, 
hiraditya, arichardson, mgorny, emaste.
Herald added a reviewer: alexander-shaposhnikov.
Herald added a reviewer: rupprecht.
Herald added a reviewer: jhenderson.
Herald added a project: All.
ckissane requested review of this revision.
Herald added projects: clang, clang-tools-extra.
Herald added subscribers: cfe-commits, llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128754

Files:
  clang-tools-extra/clangd/index/Serialization.cpp
  clang-tools-extra/clangd/unittests/SerializationTests.cpp
  clang/lib/Driver/ToolChains/Clang.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/lib/Serialization/ASTWriter.cpp
  lld/ELF/CMakeLists.txt
  lld/ELF/Driver.cpp
  lld/ELF/InputSection.cpp
  llvm/docs/ReleaseNotes.rst
  llvm/include/llvm/ProfileData/InstrProf.h
  llvm/include/llvm/ProfileData/SampleProf.h
  llvm/include/llvm/Support/Compression.h
  llvm/lib/MC/ELFObjectWriter.cpp
  llvm/lib/ObjCopy/ELF/ELFObject.cpp
  llvm/lib/Object/Decompressor.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingReader.cpp
  llvm/lib/ProfileData/Coverage/CoverageMappingWriter.cpp
  llvm/lib/ProfileData/InstrProf.cpp
  llvm/lib/ProfileData/SampleProf.cpp
  llvm/lib/ProfileData/SampleProfReader.cpp
  llvm/lib/ProfileData/SampleProfWriter.cpp
  llvm/lib/Support/CMakeLists.txt
  llvm/lib/Support/Compression.cpp
  llvm/tools/llvm-mc/llvm-mc.cpp
  llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
  llvm/unittests/ProfileData/InstrProfTest.cpp
  llvm/unittests/Support/CompressionTest.cpp

Index: llvm/unittests/Support/CompressionTest.cpp
===
--- llvm/unittests/Support/CompressionTest.cpp
+++ llvm/unittests/Support/CompressionTest.cpp
@@ -19,6 +19,8 @@
 
 using namespace llvm;
 
+using namespace compression;
+
 namespace {
 
 #if LLVM_ENABLE_ZLIB
@@ -62,12 +64,6 @@
   TestZlibCompression(BinaryDataStr, zlib::DefaultCompression);
 }
 
-TEST(CompressionTest, ZlibCRC32) {
-  EXPECT_EQ(
-  0x414FA339U,
-  zlib::crc32(StringRef("The quick brown fox jumps over the lazy dog")));
-}
-
 #endif
 
 }
Index: llvm/unittests/ProfileData/InstrProfTest.cpp
===
--- llvm/unittests/ProfileData/InstrProfTest.cpp
+++ llvm/unittests/ProfileData/InstrProfTest.cpp
@@ -1146,17 +1146,19 @@
   for (bool DoCompression : {false, true}) {
 // Compressing:
 std::string FuncNameStrings1;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames1, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings1),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames1, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings1),
+Succeeded());
 
 // Compressing:
 std::string FuncNameStrings2;
-EXPECT_THAT_ERROR(collectPGOFuncNameStrings(
-  FuncNames2, (DoCompression && zlib::isAvailable()),
-  FuncNameStrings2),
-  Succeeded());
+EXPECT_THAT_ERROR(
+collectPGOFuncNameStrings(
+FuncNames2, (DoCompression && compression::profile::isAvailable()),
+FuncNameStrings2),
+Succeeded());
 
 for (int Padding = 0; Padding < 2; Padding++) {
   // Join with paddings :
Index: llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
===
--- llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
+++ llvm/tools/llvm-objcopy/ObjcopyOptions.cpp
@@ -740,7 +740,7 @@
 .str()
 .c_str());
 }
-if (!zlib::isAvailable())
+if (!compression::zlib::isAvailable())
   return createStringError(
   errc::invalid_argument,
   "LLVM was not compiled with LLVM_ENABLE_ZLIB: can not compress");
@@ -999,7 +999,7 @@
 "--decompress-debug-sections");
   }
 
-  if (Config.DecompressDebugSections && !zlib::isAvailable())
+  if (Config.DecompressDebugSections && !compression::zlib::isAvailable())
 return createStringError(
 errc::invalid_argument,
 "LLVM was not compiled with LLVM_ENABLE_ZLIB: cannot decompress");
Index: llvm/tools/llvm-mc/llvm-mc.cpp
===
--- llvm/tools/llvm-mc/llvm-mc.cpp
+++ llvm/tools/llvm-mc/llvm-mc.cpp
@@ -403,7 +403,7 @@
   MAI->setRelaxELFRelocations(RelaxELFRel);
 
   if (CompressDebugSections != DebugCompressionType::None) {
-if (!zlib::isAvailable()) {
+if (!compression::zlib::isAvailable()) {
   WithColor::error(errs(), ProgName)
   << "build tools with zlib to enable -compress-debug-sections";
   return 1;
Index: llvm/lib/Support/Compression.cpp

[PATCH] D123967: Disable update_cc_test_checks.py tests in stand-alone builds

2022-06-28 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

ping.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D123967

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


[PATCH] D127812: [AArch64] Function multiversioning support added.

2022-06-28 Thread Daniel Kiss via Phabricator via cfe-commits
danielkiss added a comment.

In D127812#3602688 , @aaron.ballman 
wrote:

> In D127812#3602645 , @erichkeane 
> wrote:
>
>> In D127812#3601476 , @danielkiss 
>> wrote:
>>
>>> Your understanding is correct. `target` attribute has two usage model. One 
>>> is just redefine the to be used codegen options, this is used already 
>>> widely for Arm and AArch64. The other use of the `target` attribute is the 
>>> multi versioning and the rational for the `target_version` attribute is the 
>>> easier distinction between the two usage mode, also not to break any code 
>>> out there by changing the behaviour of an attribute.
>>
>> I don't think differentiating the uses here is a good idea.  I think it 
>> would have been a GREAT idea about 10 years ago, but that ship has already 
>> sailed once GCC started using it that way however.  We should be keeping the 
>> current behavior, otherwise we're going to have a horrible mix of 
>> target/target_version working inconsistently between platforms.
>
> That largely is my concern as well. The existing behavior of `target` is just 
> that -- the existing behavior. I think deviating from that existing behavior 
> will be confusing in practice. Adding additional attributes doesn't improve 
> that confusion because users then have to know to decide between two very 
> similar attributes, which means they then need to educate themselves on the 
> differences between them. If we're going to push them towards the 
> documentation to correctly use the attribute anyway, that's basically the 
> same situation they're in today with the confusing dual behavior of `target`.

We started with the ACLE to be sure the platforms and compilers will implement 
the same for Arm targets so make the developers life easier with a consistent 
behaviour on Arm platforms. Users of the attributes anyway need to aware of the 
architecture differences. Like `-mtune` is different between Arm/AArch64 and 
x86.

I have some hope others may see the benefits of the new semantics (e.g. make 
the `"default"` optional for `target_clones` ) will be picked up by other 
architectures.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D127812

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


[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 added a comment.

In D128752#3616553 , @tra wrote:

>> we no longer will have a cached CUDA installation so we will usually create 
>> it twice.
>
> Does that result in extra output in case we find an unexpected CUDA version, 
> or when compiler is run with `-v` ?
>
> We may want to wrap installation detector creation into some sort of 
> singleton creation function.

We already create another one for the call coming from Clang, this patch just 
gets rid of the other call. I think the printouts you're talking about come 
from the variable in the CUDA toolchain specifically. Here we simply create one 
to get the version and throw it away. It's not ideal to do the same work twice, 
so we could wrap this into some singleton interface. Maybe a static optional 
value inside of the `Toolchains/Cuda.cpp` file wither a getter that returns a 
reference to it. Though I don't think this is likely to be a bottleneck.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128752

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


[PATCH] D128182: [NFC] Switch FloatModeKind enum class to use bitmask enums

2022-06-28 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM again, this time for real.




Comment at: clang/include/clang/Basic/TargetInfo.h:225-226
   unsigned HasAlignMac68kSupport : 1;
-  unsigned RealTypeUsesObjCFPRetMask : (int)FloatModeKind::Last + 1;
+  unsigned RealTypeUsesObjCFPRetMask
+  : (int)FloatModeKind::LLVM_BITMASK_LARGEST_ENUMERATOR;
   unsigned ComplexLongDoubleUsesFP2Ret : 1;

jolanta.jensen wrote:
> aaron.ballman wrote:
> > Whoops, I missed this (thanks @shafik for asking me about it in private)!
> > 
> > I believe the original code was setting the field width to be `1 << 5` bits 
> > wide instead of specifying it as being 6 bits wide.
> Oh dear, I was to replace log2 with bitWidth and I only did half the job. 
> Thanks for spotting!
Yeah, it was a great catch -- the code would have worked, but been space 
inefficient, which likely would have been a head scratcher for somebody later 
wondering why the code was written that way. :-)


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128182

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


[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Artem Belevich via Phabricator via cfe-commits
tra added a comment.

> we no longer will have a cached CUDA installation so we will usually create 
> it twice.

Does that result in extra output in case we find an unexpected CUDA version, or 
when compiler is run with `-v` ?

We may want to wrap installation detector creation into some sort of singleton 
creation function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128752

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


[PATCH] D126864: [clang] Introduce -fstrict-flex-arrays= for stricter handling of flexible arrays

2022-06-28 Thread serge via Phabricator via cfe-commits
serge-sans-paille added a comment.

GCC and Clang don't have the same behavior wrt. macros-as-abound and 
standard-layout-requirement, see https://godbolt.org/z/3vc4TcTYz
I'm fine with keeping the CLang behavior, but do we want to keep it only for 
level=0, and drop it for higher level (this would look odd to me).

I'd say that we keep it for level 0,1,2, but then I think we should *not* make 
it an option of the `isFlexibleArrayMember` method. That would allow for 
inconsistent behavior wrt. FAM across the codebase and I'm not a fan of it.

Thoughts?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D126864

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


[PATCH] D125624: [gold] Remove an external dependency to GNU binutils' header file

2022-06-28 Thread Tom Stellard via Phabricator via cfe-commits
tstellar added a comment.

In D125624#3614298 , @ruiu wrote:

> In D125624#3552770 , @tstellar 
> wrote:
>
>> In D125624#3552463 , @ruiu wrote:
>>
 OK, as I mentioned. I think we need an attorney to review this change and 
 confirm that it actually accomplishes this goal.
>>>
>>> Can you add an attorney as a reviewer of this change so that we can proceed?
>>
>> Yes, I've notified @tonic and she will reach out to the attorney.
>
> @tstellar @tonic Did you guys get any response from the attorney?

Yes, the header file will still be GPLv3 licensed even if it's copied into the 
LLVM tree, so even if we were to do this change, LLVMgold would still be GPLv3.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125624

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


[PATCH] D128752: [CUDA] Stop adding CUDA features twice

2022-06-28 Thread Joseph Huber via Phabricator via cfe-commits
jhuber6 created this revision.
jhuber6 added reviewers: jdoerfert, tra, yaxunl.
Herald added subscribers: mattd, carlosgalvezp.
Herald added a project: All.
jhuber6 requested review of this revision.
Herald added subscribers: cfe-commits, MaskRay.
Herald added a project: clang.

We currently call the `addNVPTXFeatures` function in two places, inside
of the CUDA Toolchain and inside of Clang in the standard entry point.
We normally add features to the job in Clang, so the call inside of the
CUDA toolchain is redundant and results in `+ptx` features being added.
Since we remove this call, we no longer will have a cached CUDA
installation so we will usually create it twice.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128752

Files:
  clang/lib/Driver/ToolChains/Cuda.cpp
  clang/lib/Driver/ToolChains/Cuda.h


Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -126,8 +126,7 @@
 
 void getNVPTXTargetFeatures(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList ,
-std::vector ,
-Optional Version = None);
+std::vector );
 
 } // end namespace NVPTX
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -636,23 +636,20 @@
 
 void NVPTX::getNVPTXTargetFeatures(const Driver , const llvm::Triple ,
const llvm::opt::ArgList ,
-   std::vector ,
-   Optional Version) {
+   std::vector ) {
   if (Args.hasArg(options::OPT_cuda_feature_EQ)) {
 StringRef PtxFeature =
 Args.getLastArgValue(options::OPT_cuda_feature_EQ, "+ptx42");
 Features.push_back(Args.MakeArgString(PtxFeature));
 return;
-  } else if (!Version) {
-CudaInstallationDetector CudaInstallation(D, Triple, Args);
-Version = CudaInstallation.version();
   }
+  CudaInstallationDetector CudaInstallation(D, Triple, Args);
 
   // New CUDA versions often introduce new instructions that are only supported
   // by new PTX version, so we need to raise PTX level to enable them in NVPTX
   // back-end.
   const char *PtxFeature = nullptr;
-  switch (*Version) {
+  switch (CudaInstallation.version()) {
 #define CASE_CUDA_VERSION(CUDA_VER, PTX_VER)   
\
   case CudaVersion::CUDA_##CUDA_VER:   
\
 PtxFeature = "+ptx" #PTX_VER;  
\
@@ -746,11 +743,6 @@
 
   clang::CudaVersion CudaInstallationVersion = CudaInstallation.version();
 
-  std::vector Features;
-  NVPTX::getNVPTXTargetFeatures(getDriver(), getTriple(), DriverArgs, Features,
-CudaInstallationVersion);
-  for (StringRef PtxFeature : Features)
-CC1Args.append({"-target-feature", DriverArgs.MakeArgString(PtxFeature)});
   if (DriverArgs.hasFlag(options::OPT_fcuda_short_ptr,
  options::OPT_fno_cuda_short_ptr, false))
 CC1Args.append({"-mllvm", "--nvptx-short-ptr"});


Index: clang/lib/Driver/ToolChains/Cuda.h
===
--- clang/lib/Driver/ToolChains/Cuda.h
+++ clang/lib/Driver/ToolChains/Cuda.h
@@ -126,8 +126,7 @@
 
 void getNVPTXTargetFeatures(const Driver , const llvm::Triple ,
 const llvm::opt::ArgList ,
-std::vector ,
-Optional Version = None);
+std::vector );
 
 } // end namespace NVPTX
 } // end namespace tools
Index: clang/lib/Driver/ToolChains/Cuda.cpp
===
--- clang/lib/Driver/ToolChains/Cuda.cpp
+++ clang/lib/Driver/ToolChains/Cuda.cpp
@@ -636,23 +636,20 @@
 
 void NVPTX::getNVPTXTargetFeatures(const Driver , const llvm::Triple ,
const llvm::opt::ArgList ,
-   std::vector ,
-   Optional Version) {
+   std::vector ) {
   if (Args.hasArg(options::OPT_cuda_feature_EQ)) {
 StringRef PtxFeature =
 Args.getLastArgValue(options::OPT_cuda_feature_EQ, "+ptx42");
 Features.push_back(Args.MakeArgString(PtxFeature));
 return;
-  } else if (!Version) {
-CudaInstallationDetector CudaInstallation(D, Triple, Args);
-Version = CudaInstallation.version();
   }
+  CudaInstallationDetector CudaInstallation(D, Triple, Args);
 
   // New CUDA versions often introduce new instructions that are only supported
   // by new PTX version, so we need to raise PTX level to 

[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen added a comment.

In D128750#3616449 , @erichkeane 
wrote:

> Is there any chance you can validate this against 
> https://reviews.llvm.org/D126907 as well? We touch similar code, and I'm 
> intending to get that committed in the near future.  Otherwise, after a quick 
> look, I don't see anything particualrly bad, other than a lack of release 
> notes and update of www-status.

Sure. I will test it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[clang-tools-extra] 743971f - Revert "[pseudo] Add error-recovery framework & brace-based recovery"

2022-06-28 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-06-28T21:11:09+02:00
New Revision: 743971faaf84eaa0e6310bdc22c68f34c20330f1

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

LOG: Revert "[pseudo] Add error-recovery framework & brace-based recovery"

This reverts commit a0f4c10ae227a62c2a63611e64eba83f0ff0f577.
This commit hadn't been reviewed yet, and was unintentionally included
on another branch.

Added: 


Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
clang-tools-extra/pseudo/lib/GLR.cpp
clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp
clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
clang-tools-extra/pseudo/unittests/GLRTest.cpp

Removed: 
clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp



diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
index edc4b2acc0a8..a3e8611de425 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
@@ -144,26 +144,6 @@ void glrShift(llvm::ArrayRef OldHeads,
 void glrReduce(std::vector , SymbolID Lookahead,
const ParseParams );
 
-// Heuristically recover from a state where no further parsing is possible.
-//
-// OldHeads is the parse state at TokenIndex.
-// This function consumes consumes zero or more tokens (advancing TokenIndex),
-// and places any recovery states created in NewHeads.
-//
-// On failure, NewHeads is empty and TokenIndex is unchanged.
-//
-// WARNING: glrRecover acts as a "fallback shift". If it consumes no tokens,
-// there is a risk of the parser falling into an infinite loop, creating an
-// endless sequence of recovery nodes.
-// Generally it is safe for recovery to match 0 tokens against sequence symbols
-// like `statement-seq`, as the grammar won't permit another statement-seq
-// immediately afterwards. However recovery strategies for `statement` should
-// consume at least one token, as statements may be adjacent in the input.
-void glrRecover(llvm::ArrayRef OldHeads,
-unsigned , const TokenStream ,
-const ParseParams ,
-std::vector );
-
 } // namespace pseudo
 } // namespace clang
 

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
index 7240f5adbb03..382da41397f0 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
@@ -81,12 +81,9 @@ inline tok::TokenKind symbolToToken(SymbolID SID) {
   assert(SID < NumTerminals);
   return static_cast(SID);
 }
-inline constexpr SymbolID tokenSymbol(tok::TokenKind TK) {
+inline SymbolID tokenSymbol(tok::TokenKind TK) {
   return TokenFlag | static_cast(TK);
 }
-// Error recovery strategies.
-// FIXME: these should be provided as extensions instead.
-enum class RecoveryStrategy : uint8_t { None, Braces };
 
 // An extension is a piece of native code specific to a grammar that modifies
 // the behavior of annotated rules. One ExtensionID is assigned for each unique
@@ -110,7 +107,7 @@ struct Rule {
   // length to 9 (this is the longest sequence in cxx grammar).
   static constexpr unsigned SizeBits = 4;
   static constexpr unsigned MaxElements = 9;
-  static_assert(MaxElements < (1 << SizeBits), "Exceeds the maximum limit");
+  static_assert(MaxElements <= (1 << SizeBits), "Exceeds the maximum limit");
   static_assert(SizeBits + SymbolBits <= 16,
 "Must be able to store symbol ID + size efficiently");
 
@@ -126,13 +123,6 @@ struct Rule {
   // being set for this rule.
   ExtensionID Guard = 0;
 
-  // Specifies the index within Sequence eligible for error recovery.
-  // Given stmt := { stmt-seq_opt }, if we fail to parse the stmt-seq then we
-  // should recover by finding the matching brace, and forcing stmt-seq to 
match
-  // everything between braces.
-  uint8_t RecoveryIndex = -1;
-  RecoveryStrategy Recovery = RecoveryStrategy::None;
-
   llvm::ArrayRef seq() const {
 return llvm::ArrayRef(Sequence, Size);
   }

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h
index f5c2cc7a1623..1b5365327431 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h
+++ 

[PATCH] D128486: [pseudo] Add error-recovery framework & brace-based recovery

2022-06-28 Thread Sam McCall via Phabricator via cfe-commits
sammccall reopened this revision.
sammccall added a comment.

Sorry, I committed this by mistake when working on another change.
Reverted and this is ready for review.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128486

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


[PATCH] D128486: [pseudo] Add error-recovery framework & brace-based recovery

2022-06-28 Thread Sam McCall 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 rGa0f4c10ae227: [pseudo] Add error-recovery framework  
brace-based recovery (authored by sammccall).

Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128486

Files:
  clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h
  clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
  clang-tools-extra/pseudo/lib/GLR.cpp
  clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
  clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
  clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp
  clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
  clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
  clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp
  clang-tools-extra/pseudo/unittests/GLRTest.cpp

Index: clang-tools-extra/pseudo/unittests/GLRTest.cpp
===
--- clang-tools-extra/pseudo/unittests/GLRTest.cpp
+++ clang-tools-extra/pseudo/unittests/GLRTest.cpp
@@ -7,6 +7,7 @@
 //===--===//
 
 #include "clang-pseudo/GLR.h"
+#include "clang-pseudo/Bracket.h"
 #include "clang-pseudo/Token.h"
 #include "clang-pseudo/grammar/Grammar.h"
 #include "clang/Basic/LangOptions.h"
@@ -32,11 +33,13 @@
 using Action = LRTable::Action;
 using testing::AllOf;
 using testing::ElementsAre;
+using testing::IsEmpty;
 using testing::UnorderedElementsAre;
 
 MATCHER_P(state, StateID, "") { return arg->State == StateID; }
 MATCHER_P(parsedSymbol, FNode, "") { return arg->Payload == FNode; }
 MATCHER_P(parsedSymbolID, SID, "") { return arg->Payload->symbol() == SID; }
+MATCHER_P(start, Start, "") { return arg->Payload->startTokenIndex() == Start; }
 
 testing::Matcher
 parents(llvm::ArrayRef Parents) {
@@ -238,9 +241,9 @@
   /*State=*/1, /*ForestNode=*/CVQualifierNode, /*Parents=*/{GSSNode0});
   const auto *GSSNode2 = GSStack.addNode(
   /*State=*/2, /*ForestNode=*/CVQualifierNode, /*Parents=*/{GSSNode0});
-  const auto *GSSNode3 =
-  GSStack.addNode(/*State=*/3, /*ForestNode=*/ClassNameNode,
-  /*Parents=*/{GSSNode1});
+  const auto *GSSNode3 = GSStack.addNode(
+  /*State=*/3, /*ForestNode=*/ClassNameNode,
+  /*Parents=*/{GSSNode1});
   const auto *GSSNode4 =
   GSStack.addNode(/*State=*/4, /*ForestNode=*/EnumNameNode,
   /*Parents=*/{GSSNode2});
@@ -363,6 +366,124 @@
   EXPECT_THAT(Heads, ElementsAre(GSSNode1));
 }
 
+TEST_F(GLRTest, Recover) {
+  // Recovery while parsing "word" inside braces.
+  //  Before:
+  //0--1({)--2(?)
+  //  After recovering a `word` at state 1:
+  //0--3(word)  // 3 is goto(1, word)
+  buildGrammar({"word"}, {});
+  LRTable Table = LRTable::buildForTests(
+  G, {{/*State=*/1, id("word"), Action::goTo(3)}}, /*Reduce=*/{},
+  /*Recovery=*/{{/*State=*/1, RecoveryStrategy::Braces, id("word")}});
+
+  auto *LBrace = (tok::l_brace, 0);
+  auto *Question1 = (tok::question, 1);
+  const auto *Root = GSStack.addNode(0, nullptr, {});
+  const auto *OpenedBraces = GSStack.addNode(1, LBrace, {Root});
+  const auto *AfterQuestion1 = GSStack.addNode(2, Question1, {OpenedBraces});
+
+  // Need a token stream with paired braces so the strategy works.
+  clang::LangOptions LOptions;
+  TokenStream Tokens = cook(lex("{ ? ? ? }", LOptions), LOptions);
+  pairBrackets(Tokens);
+  std::vector NewHeads;
+
+  unsigned TokenIndex = 2;
+  glrRecover({AfterQuestion1}, TokenIndex, Tokens, {G, Table, Arena, GSStack},
+ NewHeads);
+  EXPECT_EQ(TokenIndex, 4u) << "should skip ahead to matching brace";
+  EXPECT_THAT(NewHeads, ElementsAre(
+AllOf(state(3), parsedSymbolID(id("word")),
+  parents({OpenedBraces}), start(1u;
+  EXPECT_EQ(NewHeads.front()->Payload->kind(), ForestNode::Opaque);
+
+  // Test recovery failure: omit closing brace so strategy fails
+  TokenStream NoRBrace = cook(lex("{ ? ? ? ?", LOptions), LOptions);
+  pairBrackets(NoRBrace);
+  NewHeads.clear();
+  TokenIndex = 2;
+  glrRecover({AfterQuestion1}, TokenIndex, NoRBrace,
+ {G, Table, Arena, GSStack}, NewHeads);
+  EXPECT_EQ(TokenIndex, 3u) << "should advance by 1 by default";
+  EXPECT_THAT(NewHeads, IsEmpty());
+}
+
+TEST_F(GLRTest, RecoverRightmost) {
+  // In a nested block structure, we recover at the innermost possible block.
+  //  Before:
+  //0--1({)--1({)--1({)
+  //  After recovering a `block` at inside the second braces:
+  //0--1({)--2(body)  // 2 is goto(1, body)
+  buildGrammar({"body"}, {});
+  LRTable Table = 

[clang-tools-extra] d25361c - [pseudo] Move ellipsis into initializer-list-item. NFC

2022-06-28 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-06-28T21:08:43+02:00
New Revision: d25361c3afa6c3774c4f814a1142ceee9085db9e

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

LOG: [pseudo] Move ellipsis into initializer-list-item. NFC

This makes the list formation a bit simpler.

Added: 


Modified: 
clang-tools-extra/pseudo/lib/cxx/cxx.bnf

Removed: 




diff  --git a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf 
b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
index d6f292d0ee24..03a7d00182e9 100644
--- a/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
+++ b/clang-tools-extra/pseudo/lib/cxx/cxx.bnf
@@ -460,10 +460,10 @@ initializer-clause := braced-init-list
 # This is standard C, and accepted by clang and others as an extension.
 braced-init-list := { initializer-list ,_opt }
 braced-init-list := { }
-initializer-list := initializer-list-item ..._opt
-initializer-list := initializer-list , initializer-list-item ..._opt
-initializer-list-item := initializer-clause
-initializer-list-item := designator brace-or-equal-initializer
+initializer-list := initializer-list-item
+initializer-list := initializer-list , initializer-list-item
+initializer-list-item := initializer-clause ..._opt
+initializer-list-item := designator brace-or-equal-initializer ..._opt
 designator := . IDENTIFIER
 #! Array designators are legal in C, and a common extension in C++.
 designator := [ expression ]



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


[clang-tools-extra] a0f4c10 - [pseudo] Add error-recovery framework & brace-based recovery

2022-06-28 Thread Sam McCall via cfe-commits

Author: Sam McCall
Date: 2022-06-28T21:08:43+02:00
New Revision: a0f4c10ae227a62c2a63611e64eba83f0ff0f577

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

LOG: [pseudo] Add error-recovery framework & brace-based recovery

The idea is:
 - a parse failure is detected when all heads die when trying to shift
   the next token
 - we can recover by choosing a nonterminal we're partway through parsing,
   and determining where it ends through nonlocal means (e.g. matching brackets)
 - we can find candidates by walking up the stack from the (ex-)heads
 - the token range is defined using heuristics attached to grammar rules
 - the unparsed region is represented in the forest by an Opaque node

This patch has the core GLR functionality.
It does not allow recovery heuristics to be attached as extensions to
the grammar, but rather infers a brace-based heuristic.

Expected followups:
 - make recovery heuristics grammar extensions (depends on D127448)
 - add recover to our grammar for bracketed constructs and sequence nodes
 - change the structure of our augmented `_ := start` rules to eliminate
   some special-cases in glrParse.
 - (if I can work out how): avoid some spurious recovery cases described
   in comments
 - grammar changes to eliminate the hard distinction between init-list
   and designated-init-list shown in the recovery-init-list.cpp testcase

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

Added: 
clang-tools-extra/pseudo/test/cxx/recovery-init-list.cpp

Modified: 
clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRGraph.h
clang-tools-extra/pseudo/include/clang-pseudo/grammar/LRTable.h
clang-tools-extra/pseudo/lib/GLR.cpp
clang-tools-extra/pseudo/lib/grammar/Grammar.cpp
clang-tools-extra/pseudo/lib/grammar/GrammarBNF.cpp
clang-tools-extra/pseudo/lib/grammar/LRGraph.cpp
clang-tools-extra/pseudo/lib/grammar/LRTableBuild.cpp
clang-tools-extra/pseudo/test/cxx/empty-member-spec.cpp
clang-tools-extra/pseudo/unittests/GLRTest.cpp

Removed: 




diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
index a3e8611de425..edc4b2acc0a8 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/GLR.h
@@ -144,6 +144,26 @@ void glrShift(llvm::ArrayRef OldHeads,
 void glrReduce(std::vector , SymbolID Lookahead,
const ParseParams );
 
+// Heuristically recover from a state where no further parsing is possible.
+//
+// OldHeads is the parse state at TokenIndex.
+// This function consumes consumes zero or more tokens (advancing TokenIndex),
+// and places any recovery states created in NewHeads.
+//
+// On failure, NewHeads is empty and TokenIndex is unchanged.
+//
+// WARNING: glrRecover acts as a "fallback shift". If it consumes no tokens,
+// there is a risk of the parser falling into an infinite loop, creating an
+// endless sequence of recovery nodes.
+// Generally it is safe for recovery to match 0 tokens against sequence symbols
+// like `statement-seq`, as the grammar won't permit another statement-seq
+// immediately afterwards. However recovery strategies for `statement` should
+// consume at least one token, as statements may be adjacent in the input.
+void glrRecover(llvm::ArrayRef OldHeads,
+unsigned , const TokenStream ,
+const ParseParams ,
+std::vector );
+
 } // namespace pseudo
 } // namespace clang
 

diff  --git a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h 
b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
index 382da41397f0..7240f5adbb03 100644
--- a/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
+++ b/clang-tools-extra/pseudo/include/clang-pseudo/grammar/Grammar.h
@@ -81,9 +81,12 @@ inline tok::TokenKind symbolToToken(SymbolID SID) {
   assert(SID < NumTerminals);
   return static_cast(SID);
 }
-inline SymbolID tokenSymbol(tok::TokenKind TK) {
+inline constexpr SymbolID tokenSymbol(tok::TokenKind TK) {
   return TokenFlag | static_cast(TK);
 }
+// Error recovery strategies.
+// FIXME: these should be provided as extensions instead.
+enum class RecoveryStrategy : uint8_t { None, Braces };
 
 // An extension is a piece of native code specific to a grammar that modifies
 // the behavior of annotated rules. One ExtensionID is assigned for each unique
@@ -107,7 +110,7 @@ struct Rule {
   // length to 9 (this is the longest sequence in cxx grammar).
   static constexpr unsigned SizeBits = 4;
   static constexpr unsigned MaxElements = 9;
-  static_assert(MaxElements <= (1 

[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-06-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane added a comment.

Is there any chance you can validate this against 
https://reviews.llvm.org/D126907 as well? We touch similar code, and I'm 
intending to get that committed in the near future.  Otherwise, after a quick 
look, I don't see anything particualrly bad, other than a lack of release notes 
and update of www-status.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128750

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


[PATCH] D128750: [c++20] Implement P2113R0: Changes to the Partial Ordering of Constrained Functions

2022-06-28 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen created this revision.
ychen added reviewers: hubert.reinterpretcast, erichkeane, rsmith, 
aaron.ballman, royjacobson.
Herald added a project: All.
ychen requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Most of the wordings are implemented straightforwardly. However,
for https://eel.is/c++draft/temp.fct#temp.func.order-6.2.1.2, I didn't
directly check `... no reordering or more than one reordering ...`.
Instead, the reordering (or the correspondence between template
parameters) is according to the order of template parameter deducing
(this also helps to fix PR49964).

Fixes https://github.com/llvm/llvm-project/issues/54039
Fixes https://github.com/llvm/llvm-project/issues/49308 (PR49964)


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D128750

Files:
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/TemplateDeduction.h
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
  clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp

Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p6.cpp
@@ -15,12 +15,32 @@
 
 template  struct X {};
 
+namespace p6_2_1_1 {
+template 
+   bool operator==(X, V);
+templatebool operator==(T, X) = delete;
+
+bool h() {
+  // Prefer the first operator== since it is not a rewritten candidate.
+  return X{} == 0;
+}
+}
+
+namespace p6 {
 template  bool operator==(X, V) = delete;
 templatebool operator==(T, X);
 
 bool h() {
   return X{} == 0;
 }
+} // namespace p6
+
+namespace PR49964 {
+  template  int f(T, U); // expected-note {{candidate function [with T = int, U = int]}}
+  template  int f(U, T); // expected-note {{candidate function [with T = int, U = int]}}
+
+  int x = f(0, 0); // expected-error {{call to 'f' is ambiguous}}
+}
 
 namespace PR53640 {
 
Index: clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
===
--- clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
+++ clang/test/CXX/temp/temp.decls/temp.fct/temp.func.order/p3.cpp
@@ -1,5 +1,6 @@
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++98 %s
 // RUN: %clang_cc1 -fsyntax-only -verify -std=c++11 %s
+// RUN: %clang_cc1 -fsyntax-only -verify -std=c++20 %s
 // expected-no-diagnostics
 
 namespace OrderWithStaticMember {
@@ -37,3 +38,17 @@
   void f(S s, V v) { s >> v; }
 }
 #endif
+
+#if __cplusplus >= 202002L
+namespace CWG2445 {
+  template  struct A { };
+
+  template 
+  bool operator==(T, A);
+
+  template 
+  bool operator!=(A, U) = delete;
+
+  bool f(A ax, A ay) { return ay != ax; }
+}
+#endif
Index: clang/lib/Sema/SemaTemplateDeduction.cpp
===
--- clang/lib/Sema/SemaTemplateDeduction.cpp
+++ clang/lib/Sema/SemaTemplateDeduction.cpp
@@ -386,6 +386,7 @@
 return Sema::TDK_Inconsistent;
   }
 
+  Info.DeduceOrder.push_back(NTTP->getIndex());
   Deduced[NTTP->getIndex()] = Result;
   if (!S.getLangOpts().CPlusPlus17)
 return Sema::TDK_Success;
@@ -512,6 +513,7 @@
   return Sema::TDK_Inconsistent;
 }
 
+Info.DeduceOrder.push_back(TempParam->getIndex());
 Deduced[TempParam->getIndex()] = Result;
 return Sema::TDK_Success;
   }
@@ -1517,6 +1519,7 @@
   return Sema::TDK_Inconsistent;
 }
 
+Info.DeduceOrder.push_back(Index);
 Deduced[Index] = Result;
 return Sema::TDK_Success;
   }
@@ -4942,7 +4945,7 @@
 /// Determine whether the function template \p FT1 is at least as
 /// specialized as \p FT2.
 static bool isAtLeastAsSpecializedAs(Sema ,
- SourceLocation Loc,
+ TemplateDeductionInfo ,
  FunctionTemplateDecl *FT1,
  FunctionTemplateDecl *FT2,
  TemplatePartialOrderingContext TPOC,
@@ -4963,7 +4966,6 @@
   // C++0x [temp.deduct.partial]p3:
   //   The types used to determine the ordering depend on the context in which
   //   the partial ordering is done:
-  TemplateDeductionInfo Info(Loc);
   SmallVector Args2;
   switch (TPOC) {
   case TPOC_Call: {
@@ -5111,16 +5113,7 @@
 return false;
 
   ParmVarDecl *Last = Function->getParamDecl(NumParams - 1);
-  if (!Last->isParameterPack())
-return false;
-
-  // Make sure that no previous parameter is a parameter pack.
-  while (--NumParams > 0) {
-if (Function->getParamDecl(NumParams - 1)->isParameterPack())
-  return false;
-  }
-
-  return true;
+  return Last->isParameterPack();
 }
 
 

[PATCH] D128604: [RISCV] Support Zbpbo extension

2022-06-28 Thread Shao-Ce SUN via Phabricator via cfe-commits
sunshaoce updated this revision to Diff 440714.
sunshaoce marked an inline comment as done.
sunshaoce added a comment.

Address @craig.topper's comment. Thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D128604

Files:
  clang/include/clang/Basic/BuiltinsRISCV.def
  clang/lib/Sema/SemaChecking.cpp
  clang/test/CodeGen/RISCV/rvp-intrinsics/riscv32-zbpbo.c
  clang/test/CodeGen/RISCV/rvp-intrinsics/riscv64-zbpbo.c
  clang/test/Driver/riscv-arch.c
  clang/test/Preprocessor/riscv-target-features.c
  llvm/lib/Support/RISCVISAInfo.cpp
  llvm/lib/Target/RISCV/RISCV.td
  llvm/lib/Target/RISCV/RISCVISelLowering.cpp
  llvm/lib/Target/RISCV/RISCVInstrInfoZb.td
  llvm/lib/Target/RISCV/RISCVSubtarget.h
  llvm/test/CodeGen/RISCV/attributes.ll
  llvm/test/CodeGen/RISCV/rv32zbpbo-intrinsics.ll
  llvm/test/CodeGen/RISCV/rv32zbpbo.ll
  llvm/test/CodeGen/RISCV/rv64zbpbo-intrinsics.ll
  llvm/test/CodeGen/RISCV/rv64zbpbo.ll
  llvm/test/MC/RISCV/attribute-arch.s
  llvm/test/MC/RISCV/rv32zbpbo-aliases-valid.s
  llvm/test/MC/RISCV/rv32zbpbo-valid.s
  llvm/test/MC/RISCV/rv64zbpbo-aliases-valid.s
  llvm/test/MC/RISCV/rv64zbpbo-valid.s

Index: llvm/test/MC/RISCV/rv64zbpbo-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zbpbo-valid.s
@@ -0,0 +1,29 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zbpbo -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv64 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zbpbo -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: pack t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x08]
+pack t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: packu t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x48]
+packu t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: fsrw t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xbb,0x52,0xc3,0x3d]
+fsrw t0, t1, t2, t3
+
+# CHECK-ASM-AND-OBJ: max t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x62,0x73,0x0a]
+max t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: min t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x0a]
+min t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: cmix t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xb3,0x92,0x63,0xe6]
+cmix t0, t1, t2, t3
Index: llvm/test/MC/RISCV/rv64zbpbo-aliases-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv64zbpbo-aliases-valid.s
@@ -0,0 +1,18 @@
+# RUN: llvm-mc %s -triple=riscv64 -mattr=+experimental-zbpbo -riscv-no-aliases \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
+# RUN: llvm-mc %s  -triple=riscv64 -mattr=+experimental-zbpbo \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump -d -r -M no-aliases --mattr=+experimental-zbpbo - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ-NOALIAS %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump -d -r --mattr=+experimental-zbpbo - \
+# RUN: | FileCheck -check-prefixes=CHECK-S-OBJ %s
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 8
+# CHECK-S-OBJ: rev8.h t0, t1
+rev8.h x5, x6
+
+# CHECK-S-OBJ-NOALIAS: grevi t0, t1, 63
+# CHECK-S-OBJ: rev t0, t1
+rev x5, x6
Index: llvm/test/MC/RISCV/rv32zbpbo-valid.s
===
--- /dev/null
+++ llvm/test/MC/RISCV/rv32zbpbo-valid.s
@@ -0,0 +1,37 @@
+# RUN: llvm-mc %s -triple=riscv32 -mattr=+experimental-zbpbo -riscv-no-aliases -show-encoding \
+# RUN: | FileCheck -check-prefixes=CHECK-ASM,CHECK-ASM-AND-OBJ %s
+# RUN: llvm-mc -filetype=obj -triple=riscv32 -mattr=+experimental-zbpbo < %s \
+# RUN: | llvm-objdump --mattr=+experimental-zbpbo -M no-aliases -d -r - \
+# RUN: | FileCheck --check-prefix=CHECK-ASM-AND-OBJ %s
+
+# CHECK-ASM-AND-OBJ: clz t0, t1
+# CHECK-ASM: encoding: [0x93,0x12,0x03,0x60]
+clz t0, t1
+
+# CHECK-ASM-AND-OBJ: pack t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x08]
+pack t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: packu t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x48]
+packu t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: fsr t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xb3,0x52,0xc3,0x3d]
+fsr t0, t1, t2, t3
+
+# CHECK-ASM-AND-OBJ: fsri t0, t1, t2, 0
+# CHECK-ASM: encoding: [0x93,0x52,0x03,0x3c]
+fsri t0, t1, t2, 0
+
+# CHECK-ASM-AND-OBJ: max t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x62,0x73,0x0a]
+max t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: min t0, t1, t2
+# CHECK-ASM: encoding: [0xb3,0x42,0x73,0x0a]
+min t0, t1, t2
+
+# CHECK-ASM-AND-OBJ: cmix t0, t1, t2, t3
+# CHECK-ASM: encoding: [0xb3,0x92,0x63,0xe6]
+cmix t0, t1, t2, t3
Index: llvm/test/MC/RISCV/rv32zbpbo-aliases-valid.s

[PATCH] D126907: Deferred Concept Instantiation Implementation Take 2

2022-06-28 Thread Erich Keane via Phabricator via cfe-commits
erichkeane updated this revision to Diff 440712.
erichkeane added a comment.

Rebased!


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

https://reviews.llvm.org/D126907

Files:
  clang/docs/ReleaseNotes.rst
  clang/include/clang/AST/Decl.h
  clang/include/clang/AST/DeclBase.h
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Sema/Template.h
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/Decl.cpp
  clang/lib/AST/DeclBase.cpp
  clang/lib/ExtractAPI/ExtractAPIConsumer.cpp
  clang/lib/Sema/SemaConcept.cpp
  clang/lib/Sema/SemaOverload.cpp
  clang/lib/Sema/SemaTemplate.cpp
  clang/lib/Sema/SemaTemplateDeduction.cpp
  clang/lib/Sema/SemaTemplateInstantiate.cpp
  clang/lib/Sema/SemaTemplateInstantiateDecl.cpp
  clang/lib/Sema/TreeTransform.h
  clang/lib/Serialization/ASTReaderDecl.cpp
  clang/lib/Serialization/ASTWriterDecl.cpp
  clang/test/CXX/temp/temp.constr/temp.constr.constr/non-function-templates.cpp
  
clang/test/CXX/temp/temp.constr/temp.constr.order/class-template-partial-specializations.cpp
  
clang/test/CXX/temp/temp.constr/temp.constr.order/var-template-partial-specializations.cpp
  clang/test/SemaTemplate/concepts-friends.cpp
  clang/test/SemaTemplate/concepts.cpp
  clang/test/SemaTemplate/deferred-concept-inst.cpp
  clang/test/SemaTemplate/instantiate-requires-clause.cpp
  clang/test/SemaTemplate/trailing-return-short-circuit.cpp

Index: clang/test/SemaTemplate/trailing-return-short-circuit.cpp
===
--- /dev/null
+++ clang/test/SemaTemplate/trailing-return-short-circuit.cpp
@@ -0,0 +1,62 @@
+// RUN: %clang_cc1 -std=c++20 -verify %s
+
+template 
+  requires(sizeof(T) > 2) || T::value // #FOO_REQ
+void Foo(T){};// #FOO
+
+template 
+void TrailingReturn(T)   // #TRAILING
+  requires(sizeof(T) > 2) || // #TRAILING_REQ
+  T::value   // #TRAILING_REQ_VAL
+{};
+template 
+struct HasValue {
+  static constexpr bool value = B;
+};
+static_assert(sizeof(HasValue) <= 2);
+
+template 
+struct HasValueLarge {
+  static constexpr bool value = B;
+  int I;
+};
+static_assert(sizeof(HasValueLarge) > 2);
+
+void usage() {
+  // Passes the 1st check, short-circuit so the 2nd ::value is not evaluated.
+  Foo(1.0);
+  TrailingReturn(1.0);
+
+  // Fails the 1st check, but has a ::value, so the check happens correctly.
+  Foo(HasValue{});
+  TrailingReturn(HasValue{});
+
+  // Passes the 1st check, but would have passed the 2nd one.
+  Foo(HasValueLarge{});
+  TrailingReturn(HasValueLarge{});
+
+  // Fails the 1st check, fails 2nd because there is no ::value.
+  Foo(true);
+  // expected-error@-1{{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  TrailingReturn(true);
+  // expected-error@-1{{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = bool]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(_Bool) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{because substituted constraint expression is ill-formed: type 'bool' cannot be used prior to '::' because it has no members}}
+
+  // Fails the 1st check, fails 2nd because ::value is false.
+  Foo(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'Foo'}}
+  // expected-note@#FOO{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#FOO_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#FOO_REQ{{and 'HasValue::value' evaluated to false}}
+  TrailingReturn(HasValue{});
+  // expected-error@-1 {{no matching function for call to 'TrailingReturn'}}
+  // expected-note@#TRAILING{{candidate template ignored: constraints not satisfied [with T = HasValue]}}
+  // expected-note@#TRAILING_REQ{{because 'sizeof(HasValue) > 2' (1 > 2) evaluated to false}}
+  // expected-note@#TRAILING_REQ_VAL{{and 'HasValue::value' evaluated to false}}
+}
Index: clang/test/SemaTemplate/instantiate-requires-clause.cpp
===
--- clang/test/SemaTemplate/instantiate-requires-clause.cpp
+++ clang/test/SemaTemplate/instantiate-requires-clause.cpp
@@ -1,4 +1,4 @@
-// RUN: %clang_cc1 -std=c++2a -x c++ %s -verify
+// RUN: %clang_cc1 -std=c++2a -x c++ %s -Wno-unused-value -verify
 
 template  requires ((sizeof(Args) == 1), ...)
 // expected-note@-1 {{because '(sizeof(int) == 1) , (sizeof(char) == 1) , (sizeof(int) == 1)' evaluated to false}}
@@ -40,6 +40,20 @@
 
 static_assert(S::f(1));
 
+// Similar to the 'S' test, but tries to use 'U' in the requires clause.

  1   2   3   >